  :root {
    --sidebar-width: 248px; --accent: #1a73e8; --success: #1e7e34; --danger: #b71c1c; --warn: #e65100;
    --bg-sidebar: #1e2329; --bg-content: #f7f8fc; --card-shadow: 0 1px 4px rgba(0,0,0,.10);
  }
  body { background: var(--bg-content); font-family: 'Segoe UI', system-ui, sans-serif; font-size: 14px; }
  #sidebar { width: var(--sidebar-width); background: var(--bg-sidebar); color: #c9d1d9; display: flex; flex-direction: column; }
  #sidebar .brand { padding: 20px 18px 14px; font-size: 15px; font-weight: 700; color: #fff; border-bottom: 1px solid rgba(255,255,255,.08); display: flex; align-items: center; gap: 8px; }
  #sidebar .brand img { width: 28px; height: 28px; object-fit: contain; border-radius: 4px; }
  .tab-section { padding: 14px 12px 4px; }
  .tab-section label { font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: #8b949e; margin-bottom: 4px; display: block; }
  .tab-section select { background: rgba(255,255,255,.06); color: #e6edf3; border: 1px solid rgba(255,255,255,.12); border-left: 3px solid var(--accent); border-radius: 6px; width: 100%; padding: 6px 10px; font-size: 13px; }
  .tab-section select option { color: #111; }
  .phase-nav { padding: 10px 0; flex: 1; }
  .nav-item { padding: 9px 18px; cursor: pointer; display: flex; align-items: center; gap: 10px; border-left: 3px solid transparent; color: #c9d1d9; text-decoration: none; }
  .nav-item:hover { background: rgba(255,255,255,.05); color: #e6edf3; }
  .nav-item.active { background: rgba(26,115,232,.18); border-left-color: var(--accent); color: #e6edf3; }
  .nav-item.disabled { opacity: .45; cursor: default; }
  .nav-item i { width: 18px; text-align: center; }
  .soon { font-size: 9px; text-transform: uppercase; background: rgba(255,255,255,.1); border-radius: 3px; padding: 1px 5px; margin-left: auto; }
  .sidebar-foot { border-top: 1px solid rgba(255,255,255,.08); padding: 10px 0; }

  #main { padding: 28px 32px; min-height: 100vh; }
  .page-header h2 { font-size: 20px; font-weight: 700; margin: 0 0 4px; color: #1a1a2e; }
  .page-header p { color: #6b7280; margin: 0; font-size: 13px; }
  .card { border: none; border-radius: 10px; box-shadow: var(--card-shadow); margin-bottom: 16px; }
  .card-header { background: #fff; border-bottom: 1px solid #eee; font-weight: 600; font-size: 13px; border-radius: 10px 10px 0 0 !important; }

  .stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
  .stat-grid-5 { grid-template-columns: repeat(5, 1fr); }
  .stat-card { background: #fff; border-radius: 10px; padding: 16px 18px; box-shadow: var(--card-shadow); }
  .stat-card .label { font-size: 11px; color: #6b7280; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 4px; }
  .stat-card .value { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
  .stat-card .delta { font-size: 12px; margin-top: 2px; color: #6b7280; }
  .stat-breakdown { margin-top: 10px; padding-top: 8px; border-top: 1px solid #f0f0f0; }

  .pace { background: #fff; border-radius: 10px; box-shadow: var(--card-shadow); padding: 14px 18px; margin-bottom: 18px; display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
  .pace .bars { flex: 1; min-width: 220px; }
  .bar-wrap { background: #e5e7eb; border-radius: 4px; height: 8px; overflow: hidden; margin: 4px 0; }
  .bar-fill { height: 100%; border-radius: 4px; transition: width .5s; }
  .bar-label { font-size: 11px; color: #6b7280; display: flex; justify-content: space-between; }

  .amt { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
  .line-table { margin: 0; }
  .line-table th { font-size: 11px; text-transform: uppercase; color: #6b7280; font-weight: 600; white-space: nowrap; border-top: none; }
  .line-table td { vertical-align: middle; padding-top: 7px; padding-bottom: 7px; }
  .line-table tr.line-row { cursor: pointer; }
  .line-table tr.line-row:hover td { background: #f9fafb; }
  .line-table tr.detail td { background: #f8fafc; font-size: 12px; }
  .acct { font-size: 10px; background: #f3f4f6; color: #6b7280; border-radius: 4px; padding: 2px 6px; }
  .split { font-size: 10px; color: #9ca3af; }

  .st { font-size: 11px; font-weight: 600; border-radius: 12px; padding: 2px 9px; white-space: nowrap; display: inline-block; }
  .st-paid, .st-received { background: #e8f5e9; color: var(--success); }
  .st-over, .st-overdue, .st-missed { background: #fce8e8; color: var(--danger); }
  .st-short { background: #fff4e5; color: var(--warn); }
  .st-due, .st-awaiting, .st-not_started, .st-unspent { background: #f3f4f6; color: #6b7280; }
  .st-spending { background: #e8f0fe; color: var(--accent); }
  .st-skipped { background: #f3f4f6; color: #9ca3af; text-decoration: line-through; }
  .st-nil { background: transparent; color: #cbd5e1; }

  .sec-head { display: flex; align-items: center; gap: 12px; cursor: pointer; }
  .sec-head .sec-bar { width: 140px; }
  .sec-head .sec-meta { font-size: 12px; color: #6b7280; font-weight: 400; margin-left: auto; white-space: nowrap; }

  .chip { border: 1px solid #d1d5db; background: #fff; border-radius: 16px; padding: 3px 12px; font-size: 12px; cursor: pointer; }
  .chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }

  .decide-row { display: grid; grid-template-columns: 90px 1fr 90px 260px auto; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid #f1f1f1; }
  .decide-row:last-child { border-bottom: none; }
  .txn-desc { font-size: 13px; color: #1a1a2e; }
  .txn-meta { font-size: 11px; color: #6b7280; }

  .alert-strip { border-radius: 10px; padding: 10px 16px; margin-bottom: 14px; font-size: 13px; }
  .alert-overdue { background: #fce8e8; color: var(--danger); }
  .alert-soon { background: #e8f0fe; color: #1557b0; }

  #toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
  .toast-msg { background: #1e2329; color: #fff; padding: 12px 18px; border-radius: 8px; font-size: 13px; min-width: 260px; box-shadow: 0 4px 12px rgba(0,0,0,.2); }
  .toast-msg.success { border-left: 4px solid #34a853; } .toast-msg.error { border-left: 4px solid var(--danger); }

  /* ---- Nigel AI assistant ---- */
  #nigel-btn {
    position: fixed; bottom: 24px; right: 24px; z-index: 1050;
    width: 54px; height: 54px; border-radius: 50%; border: none; cursor: pointer;
    background: linear-gradient(135deg, #1a73e8, #0d47a1);
    color: #fff; font-size: 22px; box-shadow: 0 4px 16px rgba(26,115,232,.45);
    display: flex; align-items: center; justify-content: center;
    transition: transform .15s, box-shadow .15s;
  }
  #nigel-btn:hover { transform: scale(1.08); box-shadow: 0 6px 20px rgba(26,115,232,.55); }
  #nigel-btn .nigel-badge { position: absolute; top: -2px; right: -2px; background: #34a853; color: #fff;
    font-size: 9px; font-weight: 700; border-radius: 50%; width: 18px; height: 18px;
    display: flex; align-items: center; justify-content: center; display: none; }

  #nigel-panel {
    position: fixed; bottom: 90px; right: 24px; z-index: 1049;
    width: 380px; max-width: calc(100vw - 32px);
    background: #fff; border-radius: 16px; box-shadow: 0 8px 40px rgba(0,0,0,.18);
    display: flex; flex-direction: column; overflow: hidden;
    transform: scale(.95) translateY(10px); opacity: 0;
    transition: transform .18s, opacity .18s; pointer-events: none;
  }
  #nigel-panel.open { transform: scale(1) translateY(0); opacity: 1; pointer-events: all; }
  #nigel-panel .np-head {
    background: linear-gradient(135deg, #1a73e8, #0d47a1);
    color: #fff; padding: 14px 16px; display: flex; align-items: center; gap: 10px;
  }
  #nigel-panel .np-head .np-avatar {
    width: 36px; height: 36px; border-radius: 50%; background: rgba(255,255,255,.2);
    display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0;
  }
  #nigel-panel .np-head .np-title { font-weight: 700; font-size: 15px; }
  #nigel-panel .np-head .np-sub { font-size: 11px; opacity: .8; }
  #nigel-panel .np-head button { margin-left: auto; background: none; border: none; color: #fff; opacity: .7; cursor: pointer; font-size: 18px; line-height: 1; padding: 2px 4px; }
  #nigel-panel .np-head button:hover { opacity: 1; }

  #nigel-msgs {
    flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px;
    max-height: 320px; min-height: 100px;
  }
  .nm-bubble { max-width: 90%; border-radius: 12px; padding: 10px 14px; font-size: 13px; line-height: 1.55; }
  .nm-bubble.nigel { background: #f0f4ff; color: #1a1a2e; border-bottom-left-radius: 4px; align-self: flex-start; }
  .nm-bubble.user  { background: #1a73e8; color: #fff; border-bottom-right-radius: 4px; align-self: flex-end; }
  .nm-bubble.nigel strong { color: #0d47a1; }
  .nm-bubble.nigel em { color: #374151; font-style: italic; }
  .nm-typing { align-self: flex-start; background: #f0f4ff; border-radius: 12px 12px 12px 4px; padding: 10px 16px; display: flex; gap: 5px; align-items: center; }
  .nm-typing span { width: 7px; height: 7px; border-radius: 50%; background: #1a73e8; opacity: .4; animation: nmDot 1.2s infinite; }
  .nm-typing span:nth-child(2) { animation-delay: .2s; }
  .nm-typing span:nth-child(3) { animation-delay: .4s; }
  @keyframes nmDot { 0%,80%,100%{opacity:.4;transform:scale(1)} 40%{opacity:1;transform:scale(1.3)} }

  #nigel-chips { padding: 0 14px 10px; display: flex; flex-wrap: wrap; gap: 6px; }
  .nm-chip { font-size: 11px; padding: 5px 10px; border-radius: 20px; border: 1.5px solid #1a73e8;
    color: #1a73e8; background: #fff; cursor: pointer; white-space: nowrap; transition: background .12s; }
  .nm-chip:hover { background: #e8f0fe; }

  #nigel-input-row { display: flex; border-top: 1px solid #eee; padding: 10px 12px; gap: 8px; align-items: flex-end; }
  #nigel-input { flex: 1; border: 1.5px solid #e5e7eb; border-radius: 20px; padding: 8px 14px;
    font-size: 13px; resize: none; outline: none; max-height: 90px; line-height: 1.4;
    font-family: inherit; }
  #nigel-input:focus { border-color: #1a73e8; }
  #nigel-send { width: 36px; height: 36px; border-radius: 50%; background: #1a73e8; border: none;
    color: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer;
    flex-shrink: 0; transition: background .12s; }
  #nigel-send:hover { background: #0d47a1; }
  #nigel-send:disabled { background: #9ca3af; cursor: default; }

  @media (min-width: 768px) {
    #sidebar { position: fixed !important; top: 0; left: 0; height: 100vh !important; transform: none !important; visibility: visible !important; display: flex !important; overflow-y: auto; }
    .offcanvas-backdrop { display: none !important; }
    #main { margin-left: var(--sidebar-width); }
    #mobile-topbar { display: none !important; }
    .sidebar-close-btn { display: none !important; }
  }
  @media (max-width: 767.98px) {
    #main { padding: 14px; }
    .stat-grid, .stat-grid-5 { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .stat-card .value { font-size: 18px; }
    .decide-row { grid-template-columns: 1fr auto; }
    .decide-row .d-date { display: none; }
    .decide-row .d-pick { grid-column: 1 / -1; }
    .sec-head .sec-bar { display: none; }
    .hide-sm { display: none; }
  }

/* ── Plan Next Month ── */
.lock-banner { background: #fff4e5; color: var(--warn); border-radius: 10px; padding: 10px 16px; margin-bottom: 14px; font-size: 13px; }
.cu-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.cu-card { background: #fff; border-radius: 10px; box-shadow: var(--card-shadow); display: flex; flex-direction: column; }
.cu-card.decided { opacity: .85; }
.cu-head { padding: 14px 16px 6px; display: flex; gap: 10px; align-items: flex-start; }
.cu-head .ic { width: 34px; height: 34px; border-radius: 8px; background: #e8f0fe; color: var(--accent); display: flex; align-items: center; justify-content: center; font-size: 17px; flex-shrink: 0; }
.cu-head h6 { margin: 0; font-size: 14px; font-weight: 700; color: #1a1a2e; }
.cu-head .line { font-size: 11px; color: #6b7280; margin-top: 2px; }
.cu-explain { font-size: 12px; color: #6b7280; padding: 0 16px 8px 60px; }
.cu-items { padding: 0 16px; flex: 1; }
.cu-item { display: grid; grid-template-columns: 22px 54px 1fr auto 92px; gap: 8px; align-items: center; padding: 5px 0; border-top: 1px solid #f3f4f6; font-size: 13px; }
.cu-item.simple { grid-template-columns: 54px 1fr auto; }
.cu-item .dt { font-size: 11px; color: #6b7280; }
.cu-item .who { font-size: 10px; background: #f3f4f6; color: #6b7280; border-radius: 4px; padding: 1px 6px; white-space: nowrap; }
.cu-item .hint { font-size: 11px; color: #9ca3af; }
.cu-item input[type=number] { text-align: right; }
.cu-item.off { color: #9ca3af; }
.cu-sub { display: grid; grid-template-columns: 1fr auto 110px; gap: 8px; align-items: center; padding: 6px 0; border-top: 1px solid #f3f4f6; font-size: 13px; }
.cu-foot { padding: 12px 16px; border-top: 1px solid #eee; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; background: #fafbfc; border-radius: 0 0 10px 10px; }
.cu-foot .delta { font-weight: 700; font-size: 15px; font-variant-numeric: tabular-nums; }
.cu-foot .delta.up { color: var(--danger); } .cu-foot .delta.down { color: var(--success); }
.cu-done { font-size: 12px; font-weight: 600; }
.cu-covered { background: #fff; border-radius: 10px; box-shadow: var(--card-shadow); padding: 12px 16px; margin-top: 16px; font-size: 12px; color: #6b7280; }
.cu-covered summary { cursor: pointer; font-size: 13px; color: #374151; }
.chg-list { font-size: 12px; }
.chg-list div { display: flex; justify-content: space-between; padding: 2px 0; }
@media (max-width: 991px) { .cu-grid { grid-template-columns: 1fr; } }
@media (max-width: 767.98px) { .cu-explain { padding-left: 16px; } .cu-item { grid-template-columns: 22px 1fr 86px; } .cu-item .dt, .cu-item .who { display: none; } }

/* ── Plan: budget lines ── */
.plan-head { display: flex; align-items: center; gap: 10px; margin: 26px 0 8px; flex-wrap: wrap; }
.plan-head h5 { margin: 0; font-size: 16px; font-weight: 700; }
.approve-box { margin-left: auto; display: flex; align-items: center; gap: 8px; font-size: 12px; }
.pl-table td, .pl-table th { vertical-align: middle; padding-top: 6px; padding-bottom: 6px; }
.pl-table th { font-size: 11px; text-transform: uppercase; color: #6b7280; font-weight: 600; white-space: nowrap; border-top: none; }
.pl-table .hist { font-size: 11px; color: #9ca3af; white-space: nowrap; }
.pl-table .hist b { color: #374151; font-weight: 600; font-size: 12px; }
.pl-table input.nb { width: 100px; text-align: right; }
.pl-table tr.dirty td { background: #fff8e6; }
.pl-table tr.note-row td { background: #fff8e6; border-top: none; padding-top: 0; }
.flag { font-size: 11px; border-radius: 10px; padding: 1px 8px; white-space: nowrap; cursor: pointer; border: none; }
.flag-under { background: #fce8e8; color: var(--danger); }
.flag-headroom { background: #e8f5e9; color: var(--success); }
.adj { font-size: 11px; white-space: nowrap; }
.adj.cal { color: var(--accent); } .adj.man { color: #7c3aed; }
.save-bar { position: sticky; bottom: 12px; z-index: 50; background: #1e2329; color: #fff; border-radius: 10px; padding: 10px 16px; display: flex; align-items: center; gap: 12px; box-shadow: 0 6px 18px rgba(0,0,0,.25); margin-top: 10px; }
.sec-total { font-size: 12px; color: #6b7280; font-weight: 400; margin-left: auto; }
.pl-table { table-layout: fixed; width: 100%; }
.pl-table th:nth-child(1) { width: 26%; } .pl-table th:nth-child(2) { width: 24%; } .pl-table th:nth-child(3) { width: 10%; }
.pl-table th:nth-child(4) { width: 14%; } .pl-table th:nth-child(5) { width: 14%; } .pl-table th:nth-child(6) { width: 12%; }
.pl-table td { overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 767.98px) { .pl-table { table-layout: auto; } .pl-table th, .pl-table td { width: auto !important; } .pl-table td:nth-child(2) .hist { display: none; } }

/* ── Debt ── */
.card-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; margin-bottom: 18px; }
.cc { background: #fff; border-radius: 10px; box-shadow: var(--card-shadow); padding: 16px 18px; display: flex; flex-direction: column; gap: 10px; }
.cc .top { display: flex; align-items: flex-start; gap: 10px; }
.cc h6 { margin: 0; font-size: 15px; font-weight: 700; }
.cc .bal { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.cc .sub { font-size: 11px; color: #6b7280; }
.countdown { margin-left: auto; text-align: right; border-radius: 8px; padding: 6px 10px; font-size: 11px; line-height: 1.3; }
.countdown b { display: block; font-size: 18px; }
.lvl-ok { background: #e8f5e9; color: var(--success); } .lvl-amber { background: #fff4e5; color: var(--warn); }
.lvl-red, .lvl-passed { background: #fce8e8; color: var(--danger); }
.owe-bar { display: flex; height: 8px; border-radius: 4px; overflow: hidden; background: #e5e7eb; }
.owe-bar .j { background: #1a73e8; } .owe-bar .e { background: #c084fc; }
.owe-legend { font-size: 12px; display: flex; gap: 14px; }
.owe-legend i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 4px; }
.plan-box { background: #f8fafc; border-radius: 8px; padding: 10px 12px; font-size: 12px; }
.plan-box.plan-box-sm { padding: 8px 12px; margin-top: 8px; }
.plan-box .big { font-size: 15px; font-weight: 700; }
.mini-hist { font-size: 11px; color: #9ca3af; }
.item-missing td { background: #fff8e6; }
.bg-success-subtle { background-color: #d1fae5 !important; }
.tabs-row .chip { margin-right: 4px; }
@media (max-width: 991px) { .card-grid { grid-template-columns: 1fr; } }

/* ── Emma ── */
.em-table td, .em-table th { vertical-align: middle; font-size: 13px; padding: 6px 8px; white-space: nowrap; }
.em-table th { font-size: 11px; text-transform: uppercase; color: #6b7280; font-weight: 600; border-top: none; }
.em-table tr.hist td { color: #6b7280; background: #fafafa; }
.em-table tr.now td { background: #e8f0fe; }
.em-table input { width: 92px; text-align: right; }
.em-table .draw { color: var(--danger); font-weight: 600; }
.em-table .good { color: var(--success); font-weight: 600; }
.basis { font-size: 9px; text-transform: uppercase; border-radius: 3px; padding: 0 4px; background: #e5e7eb; color: #6b7280; margin-left: 4px; }
.em-table input { width: 74px; padding: 2px 6px; }
.em-table td, .em-table th { padding: 5px 6px; font-size: 12.5px; }
.em-table th { white-space: normal; line-height: 1.2; }

.st-assumed { background: #f3e8ff; color: #7c3aed; }

/* ── Page tabs (always visible) ── */
.page-tabs { display: flex; align-items: center; gap: 4px; margin: -8px 0 18px; border-bottom: 1px solid #e5e7eb; flex-wrap: wrap; }
.ptab { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; font-size: 13px; font-weight: 600; color: #6b7280; text-decoration: none; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.ptab:hover { color: #1a1a2e; }
.ptab.active { color: var(--accent); border-bottom-color: var(--accent); }
.ptab-next { margin-left: auto; font-size: 12px; font-weight: 600; text-decoration: none; color: #fff; background: var(--accent); border-radius: 6px; padding: 5px 12px; }
.ptab-next:hover { background: #1557b0; color: #fff; }
@media (max-width: 767.98px) { .page-tabs { margin-top: 0; } .ptab span { display: none; } .ptab { padding: 8px 10px; font-size: 16px; } }

.debt-sum td, .debt-sum th { vertical-align: middle; padding-top: 9px; padding-bottom: 9px; }
.debt-sum th { font-size: 11px; text-transform: uppercase; color: #6b7280; font-weight: 600; border-top: none; }
.debt-sum td.amt { font-size: 15px; }
.debt-sum .sub { font-size: 11px; color: #9ca3af; font-weight: 400; }
.debt-sum tfoot td { background: #f8fafc; font-size: 15px; }
