/* ================================
   DESIGN TOKENS
   ================================ */
:root{
  --ink:#0f172a;
  --ink-secondary:#334155;
  --muted:#64748b;
  --ring:#e2e8f0;
  --ring-hover:#cbd5e1;
  --bg:#f1f5f9;
  --card:#ffffff;
  --brand:#2563eb;
  --brand-light:#dbeafe;
  --brand-dark:#1d4ed8;
  --brand-glow:rgba(37,99,235,.12);
  --sidebar:#0f172a;
  --sidebar-hover:rgba(148,163,184,.15);
  --success:#10b981;
  --danger:#ef4444;
  --radius:10px;
  --radius-lg:14px;
  --radius-sm:8px;
  --shadow-sm:0 1px 2px rgba(0,0,0,.04), 0 1px 3px rgba(0,0,0,.06);
  --shadow-md:0 4px 6px -1px rgba(0,0,0,.06), 0 2px 4px -2px rgba(0,0,0,.06);
  --shadow-lg:0 10px 25px -5px rgba(0,0,0,.08), 0 8px 10px -6px rgba(0,0,0,.06);
  --transition-fast:.15s cubic-bezier(.4,0,.2,1);
  --transition:.2s cubic-bezier(.4,0,.2,1);
}

/* ================================
   RESET & BASE
   ================================ */
*{box-sizing:border-box;margin:0;padding:0}
html{scroll-behavior:smooth}
body{
  margin:0;
  background:var(--bg);
  color:var(--ink);
  font:14px/1.6 'Inter',system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif;
  -webkit-font-smoothing:antialiased;
  -moz-osx-font-smoothing:grayscale;
  overflow-x:hidden;
  -webkit-tap-highlight-color:transparent;
}
img,svg,canvas,iframe{max-width:100%}
a{word-break:break-word}

::-webkit-scrollbar{width:6px;height:6px}
::-webkit-scrollbar-track{background:transparent}
::-webkit-scrollbar-thumb{background:#cbd5e1;border-radius:999px}
::-webkit-scrollbar-thumb:hover{background:#94a3b8}

/* ================================
   LOGIN PAGE
   ================================ */
#login-view{
  min-height:100vh;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  padding:20px;
}
.login-card{
  width:100%;
  max-width:440px;
  background:var(--card);
  border-radius:16px;
  border:1px solid var(--ring);
  padding:36px 32px;
  box-shadow:0 10px 40px rgba(15,23,42,.08), 0 1px 3px rgba(15,23,42,.04);
  text-align:center;
  animation:cardIn .35s ease-out;
}
@keyframes cardIn{
  from{opacity:0;transform:translateY(10px) scale(.98)}
  to{opacity:1;transform:translateY(0) scale(1)}
}
.login-card .login-logo{
  display:block;
  width:72px;
  height:72px;
  object-fit:contain;
  margin:0 auto 14px;
}
.login-card h1{
  margin:0 0 6px;
  font-size:24px;
  font-weight:700;
  letter-spacing:-.02em;
}
.login-card p{
  margin:0 0 24px;
  font-size:13px;
  color:var(--muted);
}
.login-card .login-status{
  margin-top:16px;
  font-size:13px;
  color:var(--muted);
  min-height:20px;
}
.login-card .login-status.error{
  color:var(--danger);
}

/* Google Sign-In button */
.google-btn{
  display:inline-flex;
  align-items:center;
  gap:10px;
  border:1px solid var(--ring);
  background:#fff;
  color:var(--ink);
  padding:10px 24px;
  border-radius:var(--radius);
  cursor:pointer;
  font-size:14px;
  font-weight:600;
  transition:all var(--transition-fast);
  box-shadow:var(--shadow-sm);
}
.google-btn:hover{
  box-shadow:var(--shadow-md);
  border-color:var(--ring-hover);
  transform:translateY(-1px);
}
.google-btn:active{
  transform:translateY(0);
}
.google-btn:disabled{
  opacity:.6;
  cursor:not-allowed;
  transform:none;
}
.google-btn svg{
  width:20px;
  height:20px;
}

.login-footer{
  margin-top:24px;
  text-align:center;
  font-size:12px;
  color:var(--muted);
}

/* ================================
   HEADER
   ================================ */
header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:12px 20px;
  background:rgba(255,255,255,.82);
  backdrop-filter:blur(12px);
  -webkit-backdrop-filter:blur(12px);
  border-bottom:1px solid var(--ring);
  position:sticky;
  top:0;
  z-index:100;
  box-shadow:0 1px 3px rgba(0,0,0,.04);
}
.header-left{
  display:flex;
  align-items:center;
  gap:12px;
  min-width:0;
}
.header-logo{
  width:28px;
  height:28px;
  object-fit:contain;
}
header h1{
  margin:0;
  font-size:17px;
  font-weight:700;
  letter-spacing:-.02em;
  color:var(--ink);
}
.nav-toggle{
  display:none;
  width:42px;
  height:42px;
  border:1px solid var(--ring);
  background:#fff;
  border-radius:12px;
  padding:0;
  align-items:center;
  justify-content:center;
  flex-direction:column;
  gap:4px;
  cursor:pointer;
  box-shadow:var(--shadow-sm);
}
.nav-toggle span{
  display:block;
  width:18px;
  height:2px;
  border-radius:999px;
  background:var(--ink);
}
.header-right{
  display:flex;
  align-items:center;
  gap:12px;
  min-width:0;
}
.signed-in{
  font-size:12px;
  color:var(--muted);
  min-width:0;
}
.signed-in span{
  font-weight:600;
  color:var(--ink);
  display:block;
  max-width:min(40vw,340px);
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}
.user-avatar{
  width:30px;
  height:30px;
  border-radius:50%;
  border:2px solid var(--ring);
}

/* ================================
   LAYOUT
   ================================ */
#app-view{display:none}
.layout{
  display:flex;
  width:100%;
}

/* ================================
   SIDEBAR
   ================================ */
aside{
  width:240px;
  background:linear-gradient(180deg,#0f172a 0%,#1e293b 100%);
  color:#cbd5f5;
  padding:16px 10px;
  display:flex;
  flex-direction:column;
  gap:2px;
  position:sticky;
  top:52px;
  height:calc(100vh - 52px);
  overflow-y:auto;
  flex-shrink:0;
}
.nav-backdrop{
  position:fixed;
  inset:52px 0 0 0;
  background:rgba(15,23,42,.45);
  backdrop-filter:blur(2px);
  -webkit-backdrop-filter:blur(2px);
  z-index:90;
}
.brand-mini{
  font-size:10px;
  font-weight:600;
  color:#475569;
  text-transform:uppercase;
  letter-spacing:.08em;
  margin:0 8px 10px;
}
.nav-btn{
  border:0;
  background:transparent;
  color:#94a3b8;
  text-align:left;
  padding:9px 12px;
  border-radius:var(--radius-sm);
  cursor:pointer;
  font-size:13px;
  font-weight:500;
  display:flex;
  align-items:center;
  gap:10px;
  transition:all var(--transition);
  position:relative;
}
.nav-btn span{flex:1}
.nav-btn:hover{
  background:var(--sidebar-hover);
  color:#e2e8f0;
}
.nav-btn.active{
  background:var(--brand);
  color:#fff;
  box-shadow:0 2px 8px rgba(37,99,235,.35);
  font-weight:600;
}
.nav-btn.logout-btn{
  color:#f87171;
  font-weight:600;
  margin-top:auto;
}
.nav-btn.logout-btn:hover{
  background:rgba(239,68,68,.12);
  color:#ef4444;
}

/* ================================
   FOOTER
   ================================ */
#app-footer{
  width:100%;
  padding:14px 24px;
  text-align:center;
  font-size:12px;
  color:var(--muted);
  border-top:1px solid var(--ring);
  background:var(--card);
}
#app-footer > div{
  line-height:1.5;
}

/* ================================
   MAIN CONTENT
   ================================ */
main{
  flex:1;
  padding:20px 24px;
  max-width:1200px;
  margin:0 auto;
  width:100%;
  min-width:0;
  padding-bottom:120px;
}
.page{
  display:none;
  animation:fadeIn .3s ease-out;
}
.page.active{
  display:block;
}
@keyframes fadeIn{
  from{opacity:0;transform:translateY(6px)}
  to{opacity:1;transform:translateY(0)}
}

/* ================================
   CARDS
   ================================ */
.card{
  background:var(--card);
  border-radius:var(--radius-lg);
  border:1px solid var(--ring);
  padding:18px 20px;
  margin-bottom:16px;
  box-shadow:var(--shadow-sm);
  transition:box-shadow var(--transition), border-color var(--transition);
  min-width:0;
}
.card:hover{
  box-shadow:var(--shadow-md);
  border-color:var(--ring-hover);
}
.section-head{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:10px;
}
.section-head h2{
  margin:0;
  font-size:16px;
  font-weight:700;
  letter-spacing:-.01em;
  color:var(--ink);
}
hr{
  border:none;
  border-top:1px solid var(--ring);
}

/* ================================
   FORM ELEMENTS
   ================================ */
label{
  display:block;
  font-size:12px;
  font-weight:500;
  color:var(--muted);
  margin-bottom:5px;
}
input, select, textarea{
  width:100%;
  padding:8px 12px;
  border-radius:var(--radius-sm);
  border:1px solid var(--ring);
  font:inherit;
  font-size:13px;
  color:var(--ink);
  background:#fff;
  transition:border-color var(--transition-fast), box-shadow var(--transition-fast);
}
input:focus, select:focus, textarea:focus{
  outline:none;
  border-color:var(--brand);
  box-shadow:0 0 0 3px var(--brand-glow);
}
input::placeholder, textarea::placeholder{
  color:#94a3b8;
}
.icon{
  min-width:40px;
  min-height:40px;
}
.table-wrap{
  width:100%;
  overflow-x:auto;
  -webkit-overflow-scrolling:touch;
}
.table-wrap table{
  min-width:640px;
}
.row > *{min-width:0}
.section-head > *{min-width:0}

/* ================================
   BUTTONS
   ================================ */
button.primary{
  border:0;
  background:var(--brand);
  color:#fff;
  padding:8px 16px;
  border-radius:var(--radius-sm);
  cursor:pointer;
  font-size:13px;
  font-weight:600;
  letter-spacing:.01em;
  transition:all var(--transition-fast);
  box-shadow:0 1px 2px rgba(37,99,235,.2);
}
button.primary:hover{
  background:var(--brand-dark);
  box-shadow:0 4px 12px rgba(37,99,235,.3);
  transform:translateY(-1px);
}
button.primary:active{
  transform:translateY(0);
  box-shadow:0 1px 2px rgba(37,99,235,.2);
}
button.secondary{
  border:1px solid var(--brand);
  background:var(--brand-light);
  color:var(--brand-dark);
  padding:8px 16px;
  border-radius:var(--radius-sm);
  cursor:pointer;
  font-size:13px;
  font-weight:600;
  transition:all var(--transition-fast);
}
button.secondary:hover{
  background:var(--brand);
  color:#fff;
  box-shadow:0 4px 12px rgba(37,99,235,.25);
  transform:translateY(-1px);
}
button.secondary:active{
  transform:translateY(0);
}
button.danger{
  border:1px solid #fecaca;
  background:#fef2f2;
  color:#dc2626;
  padding:8px 16px;
  border-radius:var(--radius-sm);
  cursor:pointer;
  font-size:13px;
  font-weight:600;
  transition:all var(--transition-fast);
}
button.danger:hover{
  background:#dc2626;
  color:#fff;
  border-color:#dc2626;
  box-shadow:0 4px 12px rgba(220,38,38,.3);
  transform:translateY(-1px);
}
button.primary,
button.secondary,
button.danger{
  min-height:40px;
}

/* ================================
   TABLE
   ================================ */
.table-frame{
  width:100%;
  border-collapse:separate;
  border-spacing:0;
  border:1px solid var(--ring);
  border-radius:var(--radius);
  overflow:visible;
  background:#fff;
  box-shadow:var(--shadow-sm);
}
.table{
  min-width:640px;
}

/* Some migrated pages still use inline overflow wrappers instead of .table-wrap */
#page-spending .card > div[style*="overflow:auto"],
#page-assets .card > div[style*="overflow:auto"],
#page-income .card > div[style*="overflow:auto"],
#page-report .card > div[style*="overflow:auto"]{
  width:100%;
  overflow-x:auto !important;
  overflow-y:hidden !important;
  -webkit-overflow-scrolling:touch;
}

#page-spending .table,
#page-assets .table,
#page-income .table,
#page-report .table{
  min-width:640px;
}

#page-spending .table-frame > .table,
#page-assets .table-frame > .table{
  width:100% !important;
  min-width:720px;
  max-width:none !important;
  display:table !important;
}

#page-spending .table-wrap,
#page-assets .table-wrap{
  width:100%;
  overflow-x:auto;
  overflow-y:hidden;
  -webkit-overflow-scrolling:touch;
}

#page-spending .table-frame,
#page-assets .table-frame{
  width:100%;
}

#page-spending .table{
  min-width:980px !important;
}

#page-assets .table{
  min-width:860px !important;
}

#page-spending .table th,
#page-spending .table td,
#page-assets .table th,
#page-assets .table td{
  white-space:nowrap;
}
.table-frame thead th{
  background:#f8fafc;
  color:var(--ink-secondary);
  border-bottom:2px solid var(--ring);
  padding:10px 12px;
  font-size:12px;
  font-weight:600;
  text-align:left;
  text-transform:uppercase;
  letter-spacing:.03em;
}
.table-frame tbody td{
  border-bottom:1px solid #f1f5f9;
  padding:10px 12px;
  font-size:13px;
  color:var(--ink-secondary);
}
.table-frame tbody tr:last-child td{border-bottom:none}
.table-frame tbody tr{transition:background var(--transition-fast)}
.table-frame tbody tr:hover{background:#f8fafc}

/* ================================
   GRIDS & UTILITY
   ================================ */
.grid.two{display:grid;grid-template-columns:repeat(auto-fit,minmax(200px,1fr));gap:12px}
.grid.three{display:grid;grid-template-columns:repeat(auto-fit,minmax(180px,1fr));gap:12px}
.row{display:flex;gap:10px;flex-wrap:wrap;align-items:flex-start}

.stat-card{
  background:var(--card);
  border-radius:var(--radius-lg);
  border:1px solid var(--ring);
  padding:16px 18px;
  box-shadow:var(--shadow-sm);
}
.stat-card .stat-label{
  font-size:11px;
  font-weight:600;
  color:var(--muted);
  text-transform:uppercase;
  letter-spacing:.04em;
  margin-bottom:4px;
}
.stat-card .stat-value{
  font-size:22px;
  font-weight:700;
  color:var(--ink);
  letter-spacing:-.01em;
}

.btn-loading{
  position:relative;
  pointer-events:none;
  opacity:.75;
}
.btn-loading::after{
  content:"";
  position:absolute;
  right:10px;
  top:50%;
  width:14px;
  height:14px;
  margin-top:-7px;
  border-radius:50%;
  border:2px solid #fff;
  border-top-color:transparent;
  animation:spin .6s linear infinite;
}
@keyframes spin{
  to{transform:rotate(360deg)}
}

.empty-state{
  text-align:center;
  padding:40px 20px;
  color:var(--muted);
}
.empty-state svg{
  margin-bottom:12px;
  opacity:.4;
}
.empty-state h3{
  font-size:15px;
  font-weight:600;
  color:var(--ink-secondary);
  margin-bottom:4px;
}
.empty-state p{
  font-size:13px;
}

/* ================================
   AI CHAT
   ================================ */
#ai-chat-fab{
  position:fixed;
  right:18px;
  bottom:calc(18px + env(safe-area-inset-bottom, 0px));
  min-width:72px;
  height:58px;
  padding:0 18px;
  display:none;
  align-items:center;
  justify-content:center;
  border:none;
  border-radius:999px;
  background:linear-gradient(135deg, #0f172a 0%, var(--brand) 100%);
  color:#fff;
  font-size:16px;
  font-weight:800;
  letter-spacing:.02em;
  cursor:pointer;
  box-shadow:0 14px 30px rgba(15,23,42,.24);
  z-index:1200;
}
#ai-chat-fab:hover{
  transform:translateY(-1px);
}
#ai-chat-panel{
  position:fixed;
  right:18px;
  bottom:calc(90px + env(safe-area-inset-bottom, 0px));
  width:min(390px, calc(100vw - 24px));
  height:min(620px, calc(100vh - 120px));
  display:none;
  flex-direction:column;
  background:rgba(255,255,255,.98);
  border:1px solid var(--ring);
  border-radius:18px;
  box-shadow:0 22px 50px rgba(15,23,42,.18);
  overflow:hidden;
  z-index:1200;
}
#ai-chat-panel.open{
  display:flex;
}
.ai-chat-head{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:12px;
  padding:16px 16px 12px;
  border-bottom:1px solid var(--ring);
  background:linear-gradient(180deg, rgba(248,250,252,.98) 0%, rgba(255,255,255,.98) 100%);
}
.ai-chat-title{
  font-size:15px;
  font-weight:700;
  color:var(--ink);
}
.ai-chat-sub{
  margin-top:3px;
  font-size:12px;
  color:var(--muted);
}
.ai-chat-messages{
  flex:1;
  overflow:auto;
  padding:14px;
  display:flex;
  flex-direction:column;
  gap:10px;
  background:
    radial-gradient(circle at top right, rgba(37,99,235,.08), transparent 34%),
    linear-gradient(180deg, #fbfdff 0%, #f8fafc 100%);
}
.ai-chat-msg{
  max-width:88%;
  padding:10px 12px;
  border-radius:14px;
  line-height:1.45;
  white-space:pre-wrap;
  word-break:break-word;
  font-size:13px;
  box-shadow:0 3px 10px rgba(15,23,42,.05);
}
.ai-chat-msg.user{
  align-self:flex-end;
  background:var(--brand);
  color:#fff;
  border-bottom-right-radius:6px;
}
.ai-chat-msg.assistant{
  align-self:flex-start;
  background:#fff;
  color:var(--ink);
  border:1px solid #dbe4f0;
  border-bottom-left-radius:6px;
}
.ai-chat-status{
  min-height:18px;
  padding:0 14px 8px;
  font-size:12px;
  color:var(--muted);
}
.ai-chat-form{
  border-top:1px solid var(--ring);
  padding:12px;
  background:#fff;
}
#ai-chat-input{
  min-height:84px;
  max-height:180px;
  resize:vertical;
}
.ai-chat-actions{
  margin-top:10px;
  display:flex;
  justify-content:flex-end;
  align-items:center;
  gap:8px;
  flex-wrap:wrap;
}
.ai-chat-file-label{
  cursor:pointer;
  padding:6px 12px;
  border-radius:8px;
  font-size:12px;
  font-weight:600;
  border:1px solid var(--ring);
  background:#fff;
  color:var(--ink);
}
.ai-chat-file-label:hover{
  background:#f1f5f9;
}
.ai-chat-web-toggle{
  display:flex;
  align-items:center;
  padding:6px 10px;
  font-size:12px;
  cursor:pointer;
}
.ai-chat-attachments{
  margin-top:8px;
  display:flex;
  flex-wrap:wrap;
  gap:6px;
}
.ai-chat-attachment-chip{
  display:inline-flex;
  align-items:center;
  gap:6px;
  background:#eef2ff;
  border:1px solid #c7d2fe;
  color:#3730a3;
  padding:4px 8px;
  border-radius:999px;
  font-size:11px;
  max-width:100%;
}
.ai-chat-attachment-chip button{
  background:transparent;
  border:none;
  color:#3730a3;
  cursor:pointer;
  font-weight:700;
  padding:0 2px;
  line-height:1;
}
.ai-chat-msg .ai-chat-msg-file{
  display:block;
  margin-top:6px;
  font-size:11px;
  opacity:.85;
  font-style:italic;
}
.ai-chat-msg .ai-chat-msg-sources{
  display:block;
  margin-top:8px;
  padding-top:6px;
  border-top:1px dashed rgba(15,23,42,.15);
  font-size:11px;
}
.ai-chat-msg .ai-chat-msg-sources a{
  color:inherit;
  text-decoration:underline;
  display:block;
  margin-top:3px;
  word-break:break-all;
}

/* ================================
   RESPONSIVE
   ================================ */
@media (max-width:800px){
  header{
    padding:10px 12px;
    gap:10px;
  }
  .nav-toggle{
    display:inline-flex;
  }
  .layout{
    display:block;
    min-height:calc(100vh - 62px);
  }
  aside{
    width:min(320px,86vw);
    position:fixed;
    top:62px;
    left:0;
    bottom:0;
    height:auto;
    z-index:110;
    transform:translateX(-105%);
    transition:transform var(--transition);
    padding:14px 10px 16px;
  }
  body.nav-open aside{transform:translateX(0)}
  body.nav-open{overflow:hidden}
  body.nav-open .nav-backdrop{display:block}
  .nav-btn{
    width:100%;
    flex:0 0 auto;
    justify-content:flex-start;
    font-size:12px;
    padding:8px 10px;
  }
  .brand-mini{width:100%;margin-bottom:6px}
  main{
    padding:12px;
    max-width:none;
    padding-bottom:110px;
  }
  .card{
    padding:14px;
    border-radius:12px;
  }
  .section-head{
    align-items:flex-start;
    flex-direction:column;
  }
  .signed-in span{
    max-width:44vw;
  }
  .grid.two,
  .grid.three{
    grid-template-columns:1fr;
    gap:10px;
  }
  .table-wrap table{
    min-width:560px;
  }
  #page-spending .table,
  #page-assets .table,
  #page-income .table,
  #page-report .table{
    min-width:560px;
  }
  #page-spending .table-frame > .table,
  #page-assets .table-frame > .table{
    min-width:720px;
    width:100% !important;
    max-width:none !important;
    display:table !important;
  }
  input, select, textarea{
    min-height:44px;
    font-size:16px;
  }
  button.primary,
  button.secondary,
  button.danger,
  .nav-btn{
    min-height:44px;
  }
  .table-frame thead th,
  .table-frame tbody td{
    padding:9px 10px;
  }
  #ai-chat-fab{
    right:12px;
    bottom:calc(12px + env(safe-area-inset-bottom, 0px));
    min-width:54px;
    height:54px;
    padding:0 14px;
    font-size:13px;
  }
  #ai-chat-panel{
    right:12px;
    bottom:calc(76px + env(safe-area-inset-bottom, 0px));
    width:calc(100vw - 24px);
    height:min(74vh, 560px);
    border-radius:16px;
  }
}

@media (max-width:1024px){
  main{
    max-width:none;
    padding:18px;
  }
  aside{
    width:220px;
  }
  .card{
    padding:16px 18px;
  }
}

@media (max-width:640px){
  header h1{
    font-size:16px;
  }
  .header-right{
    gap:8px;
  }
  .signed-in{
    font-size:11px;
  }
  .signed-in span{
    max-width:34vw;
  }
  .user-avatar{
    width:28px;
    height:28px;
  }
  #login-view{
    padding:16px;
  }
  .login-card{
    padding:28px 20px;
    border-radius:14px;
  }
  .login-card h1{
    font-size:22px;
  }
  .google-btn{
    width:100%;
    justify-content:center;
  }
  .empty-state{
    padding:28px 12px;
  }
  .table-wrap table{
    min-width:520px;
  }
  #page-spending .table,
  #page-assets .table,
  #page-income .table,
  #page-report .table{
    min-width:520px;
  }
  #page-spending .table-frame > .table,
  #page-assets .table-frame > .table{
    min-width:720px;
    width:100% !important;
    max-width:none !important;
    display:table !important;
  }
  main{
    padding-bottom:118px;
  }
  .card{
    padding:12px;
    margin-bottom:12px;
  }
  .section-head h2,
  #page-income h2,
  #page-spending h2,
  #page-assets h2,
  #page-debtloan h2,
  #page-dashboard h2,
  #page-report h2{
    font-size:22px;
    line-height:1.2;
  }
  .table-frame thead th{
    font-size:11px;
  }
  .table-frame tbody td{
    font-size:12px;
  }
}

/* ================================
   PAGE-LEVEL RESPONSIVE TUNING
   ================================ */
#page-income > .row:first-of-type,
#page-spending > .row:first-of-type,
#page-assets > .row:first-of-type,
#page-debtloan > .row:first-of-type,
#page-report .card .grid.three,
#page-dashboard .card .row,
#page-income .card .row,
#page-spending .card .row,
#page-assets .card .row,
#page-debtloan .card .row{
  min-width:0;
}

#page-income .income-tab{
  min-width:0;
}

#page-dashboard #dashWidgetsWrap{
  align-items:stretch;
}

#page-dashboard .dash-widget-card,
#page-dashboard .dash-custom-item{
  min-width:0;
}

#page-dashboard .dash-widget-body canvas{
  max-width:100% !important;
  height:auto !important;
}

@media (max-width:1024px){
  #page-dashboard #dashWidgetsWrap{
    grid-template-columns:1fr;
  }
  #page-dashboard .dash-widget-controls.top-right{
    position:static;
    justify-content:flex-end;
    margin-top:8px;
    opacity:1;
  }
  #page-dashboard .dash-custom-item{
    flex-direction:column;
    align-items:stretch;
  }
  #page-dashboard .dash-custom-actions{
    display:flex;
    flex-wrap:wrap;
    gap:6px;
    justify-content:flex-end;
  }
  #page-income [data-inv-grid]{
    grid-template-columns:1fr !important;
  }
}

@media (max-width:800px){
  #page-income > div[style*="border-bottom"],
  #page-dashboard > .row[style*="border-bottom"]{
    overflow:auto;
    flex-wrap:nowrap;
    padding-bottom:4px;
  }

  #page-income .income-tab,
  #page-dashboard .dash-tab-btn{
    flex:1 0 auto;
    white-space:nowrap;
    text-align:center;
  }

  #page-income .card > .row[style*="justify-content:space-between"],
  #page-spending > .row[style*="justify-content:space-between"],
  #page-assets > .row[style*="justify-content:space-between"],
  #page-debtloan > .row[style*="justify-content:space-between"]{
    align-items:stretch !important;
  }

  #page-income #locumCard .row > span,
  #page-income #tab-locum .card .row > span,
  #page-income #tab-other .card .row > span,
  #page-spending .card .row > span,
  #page-assets .card .row > span,
  #page-debtloan .card .row > span,
  #page-report .card .grid.three > div,
  #page-report .card .grid.three > span{
    flex:1 1 100% !important;
    width:100%;
    min-width:0;
  }

  #page-income #tab-locum .card > .row:last-child,
  #page-income #tab-other .card > .row:last-child,
  #page-spending .card > .row:last-child,
  #page-assets .card > .row:last-child,
  #page-debtloan .card > .row:last-child{
    gap:10px;
  }

  #page-income #tab-locum .card > .row:last-child > div,
  #page-income #tab-other .card > .row:last-child > div,
  #page-spending .card > .row:last-child > div,
  #page-assets .card > .row:last-child > div,
  #page-debtloan .card > .row:last-child > div{
    width:100%;
    justify-content:space-between;
  }

  #page-report .card .grid.three{
    grid-template-columns:1fr;
  }

  #page-income #invModal > div,
  #page-income #locCalModal .card{
    width:min(96vw,720px) !important;
  }
}

@media (max-width:640px){
  #page-income,
  #page-spending,
  #page-assets,
  #page-debtloan,
  #page-dashboard,
  #page-report{
    padding:14px;
  }

  #page-income > .row:first-of-type,
  #page-spending > .row:first-of-type,
  #page-assets > .row:first-of-type,
  #page-debtloan > .row:first-of-type,
  #page-income #tab-other > .row:first-of-type{
    flex-direction:column;
    align-items:stretch !important;
    gap:10px !important;
  }

  #page-income > .row:first-of-type button,
  #page-spending > .row:first-of-type button,
  #page-assets > .row:first-of-type button,
  #page-debtloan > .row:first-of-type button,
  #page-income #tab-other > .row:first-of-type button{
    width:100%;
  }

  #page-income #tab-other > .row:first-of-type > .row{
    width:100%;
  }

  #page-income #tab-other > .row:first-of-type select,
  #page-income #tab-other > .row:first-of-type button{
    width:100%;
  }

  #page-income .card .row[style*="justify-content:space-between"],
  #page-spending .card .row[style*="justify-content:space-between"],
  #page-assets .card .row[style*="justify-content:space-between"],
  #page-debtloan .card .row[style*="justify-content:space-between"]{
    flex-direction:column;
    align-items:stretch !important;
  }

  #page-income .card .row[style*="justify-content:space-between"] > div,
  #page-spending .card .row[style*="justify-content:space-between"] > div,
  #page-assets .card .row[style*="justify-content:space-between"] > div,
  #page-debtloan .card .row[style*="justify-content:space-between"] > div{
    width:100%;
  }

  #page-income .card .row button,
  #page-spending .card .row button,
  #page-assets .card .row button,
  #page-debtloan .card .row button,
  #page-report .card button{
    min-height:40px;
  }
  #page-income .row[style*="justify-content:flex-end"] button,
  #page-income .row[style*="justify-content:space-between"] button,
  #page-spending .row[style*="justify-content:flex-end"] button,
  #page-spending .row[style*="justify-content:space-between"] button,
  #page-assets .row[style*="justify-content:flex-end"] button,
  #page-assets .row[style*="justify-content:space-between"] button,
  #page-debtloan .row[style*="justify-content:flex-end"] button,
  #page-debtloan .row[style*="justify-content:space-between"] button,
  #page-report .row[style*="justify-content:flex-end"] button,
  #page-report .row[style*="justify-content:space-between"] button{
    width:100%;
  }
  #page-income .row[style*="justify-content:flex-end"],
  #page-income .row[style*="justify-content:space-between"],
  #page-spending .row[style*="justify-content:flex-end"],
  #page-spending .row[style*="justify-content:space-between"],
  #page-assets .row[style*="justify-content:flex-end"],
  #page-assets .row[style*="justify-content:space-between"],
  #page-debtloan .row[style*="justify-content:flex-end"],
  #page-debtloan .row[style*="justify-content:space-between"],
  #page-report .row[style*="justify-content:flex-end"],
  #page-report .row[style*="justify-content:space-between"]{
    gap:8px !important;
  }

  #page-spending #spActionSummaryBar{
    gap:10px !important;
    padding:12px !important;
  }
  #page-spending #spActionSummaryBar > div{
    width:100%;
    justify-content:space-between;
  }

  #page-income #invModal{
    padding:10px !important;
  }
  #page-income #invModal > div{
    width:100% !important;
    max-height:94vh !important;
    margin:0 auto !important;
  }
  #page-income #locCalModal{
    padding:10px !important;
  }
  #page-income #locCalModal .card{
    width:100% !important;
  }

  #page-dashboard .dash-tab-btn,
  #page-income .income-tab{
    font-size:12px;
    padding:10px 6px !important;
  }
  #page-report .card .grid.three > div:last-child{
    display:flex;
    justify-content:stretch !important;
  }
  #page-report #btnGenerateReport{
    width:100%;
  }

  /* Spending / Assets mobile table compaction */
  #page-spending .table,
  #page-assets .table{
    min-width:720px;
    table-layout:auto !important;
  }
  #page-spending .table-frame,
  #page-assets .table-frame{
    border-radius:12px;
    display:block;
    overflow-x:auto;
    overflow-y:hidden;
    -webkit-overflow-scrolling:touch;
    white-space:nowrap;
  }
  #page-spending .table thead th,
  #page-spending .table tbody td,
  #page-assets .table thead th,
  #page-assets .table tbody td{
    padding:8px 8px !important;
    font-size:12px;
    white-space:nowrap;
  }
  #page-spending .table thead th:nth-child(1),
  #page-spending .table tbody td:nth-child(1),
  #page-assets .table thead th:nth-child(1),
  #page-assets .table tbody td:nth-child(1){
    width:36px;
    min-width:36px;
    text-align:center;
  }
  #page-spending .table thead th:nth-child(4),
  #page-spending .table tbody td:nth-child(4),
  #page-assets .table thead th:nth-child(4),
  #page-assets .table tbody td:nth-child(4){
    min-width:96px;
    text-align:right;
  }
  #page-spending .table thead th:nth-child(6),
  #page-spending .table tbody td:nth-child(6){
    min-width:110px;
  }
  #page-spending .table thead th:nth-child(7),
  #page-spending .table tbody td:nth-child(7){
    min-width:140px;
  }
  #page-spending .table thead th:nth-child(8),
  #page-spending .table tbody td:nth-child(8){
    min-width:84px;
  }
  #page-assets .table thead th:nth-child(2),
  #page-assets .table tbody td:nth-child(2){
    min-width:120px;
  }
  #page-assets .table thead th:nth-child(3),
  #page-assets .table tbody td:nth-child(3){
    min-width:88px;
  }
  #page-assets .table thead th:nth-child(6),
  #page-assets .table tbody td:nth-child(6){
    min-width:110px;
  }
  #page-spending .table-frame > .table,
  #page-assets .table-frame > .table{
    width:100% !important;
    min-width:720px !important;
    max-width:none !important;
    display:table !important;
  }
}
