  :root {
    --bg: #121826;
    --bg-elevated: #1a2233;
    --bg-card: #1c2537;
    --border: #2a3448;
    --text: #e7ebf3;
    --text-dim: #98a4bd;
    --text-faint: #6d7996;
    --accent: #2dd4bf;
    --accent-dim: #1c8f80;
    --accent-fg: #05201c;
    --danger: #f87171;
    --danger-dim: #7f1d1d;
    --positive: #4ade80;
    --warn: #fbbf24;
    --radius: 10px;
    --shadow: 0 10px 30px rgba(0,0,0,0.35);
  }
  :root[data-theme="light"] {
    --bg: #f4f6fa;
    --bg-elevated: #ffffff;
    --bg-card: #ffffff;
    --border: #e0e4ec;
    --text: #1a2233;
    --text-dim: #5b6478;
    --text-faint: #8891a3;
    --accent: #0f9c8c;
    --accent-dim: #0c7c70;
    --accent-fg: #ffffff;
    --danger: #dc2626;
    --danger-dim: #fca5a5;
    --positive: #16a34a;
    --warn: #b45309;
    --shadow: 0 10px 30px rgba(20,30,50,0.09);
  }
  * { box-sizing: border-box; }
  html, body { margin: 0; padding: 0; }
  #navbar, .login-card, .summary-card, .company-card, table, .modal-box, input, select, .toast {
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  }
  body {
    background: var(--bg);
    color: var(--text);
    transition: background-color 0.15s ease, color 0.15s ease;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    min-height: 100vh;
  }
  .hidden { display: none !important; }
  a { color: var(--accent); }

  /* ---------- App shell (icon-rail sidebar + content) ---------- */
  .app-shell { display: flex; align-items: stretch; min-height: 100vh; }
  #navbar {
    display: flex;
    flex-direction: column;
    width: 240px;
    flex-shrink: 0;
    padding: 20px 16px;
    background: var(--bg-elevated);
    border-right: 1px solid var(--border);
    border-bottom: none;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 20;
  }
  .sidebar-top {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    padding-bottom: 16px; margin-bottom: 14px; border-bottom: 1px solid var(--border);
  }
  #navbar .brand {
    font-weight: 700;
    font-size: 15px;
    letter-spacing: 0.2px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    min-width: 0;
  }
  #navbar .brand .brand-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .brand-logo-chip {
    display: inline-flex; align-items: center; justify-content: center;
    width: 30px; height: 30px; background: #ffffff; border-radius: 8px;
    padding: 3px; box-shadow: 0 1px 3px rgba(0,0,0,0.18); flex-shrink: 0;
  }
  .brand-logo-chip img { width: 100%; height: 100%; object-fit: contain; display: block; }
  .login-logo { display: flex; justify-content: center; margin: 44px 0 18px; }
  .login-logo img {
    max-width: 170px; width: 100%; height: auto; display: block;
    background: #ffffff; border-radius: 10px; padding: 12px 16px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.10);
  }
  .nav-links { display: flex; flex-direction: column; gap: 2px; flex: 1; }
  #navbar .nav-link {
    display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
    background: none; border: none; color: var(--text-dim); font-size: 14px;
    cursor: pointer; padding: 9px 10px; border-radius: 8px;
  }
  #navbar .nav-link .nav-icon { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.8; }
  #navbar .nav-link:hover { color: var(--text); background: rgba(255,255,255,0.04); }
  #navbar .nav-link.active { color: var(--accent); background: rgba(45,212,191,0.12); }
  #navbar .nav-link.active .nav-icon { opacity: 1; }
  .sidebar-bottom {
    margin-top: auto; padding-top: 14px; border-top: 1px solid var(--border);
    display: flex; flex-direction: column; gap: 8px;
  }
  #navbar .sidebar-bottom .btn { width: 100%; justify-content: center; }
  #navbar .user-chip { font-size: 13px; color: var(--text-dim); text-align: left; line-height: 1.3; }
  #navbar .user-chip .role { color: var(--text-faint); font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; }

  /* ---------- Layout ---------- */
  /* flex-grow + max-width + auto margins: #main grows to fill the space
     beside the sidebar, is capped at max-width, and any space left over
     beyond that cap is split evenly by the auto margins — which is what
     centers it (the login card included) instead of hugging the sidebar
     with everything left-aligned and the rest of a wide screen empty. */
  #main { flex: 1; min-width: 0; max-width: 1600px; margin: 0 auto; padding: 28px 34px 80px; }
  .view { }

  /* ---------- Buttons ---------- */
  button { font-family: inherit; }
  .btn {
    display: inline-flex; align-items: center; gap: 6px;
    background: var(--bg-card); color: var(--text);
    border: 1px solid var(--border); border-radius: 8px;
    padding: 9px 14px; font-size: 14px; cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
  }
  .btn:hover { border-color: var(--accent-dim); }
  .btn-primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); font-weight: 600; }
  .btn-primary:hover { background: #26bdaa; }
  .btn-danger { background: transparent; color: var(--danger); border-color: var(--danger-dim); }
  .btn-danger:hover { background: rgba(248,113,113,0.08); }
  .btn-sm { padding: 5px 9px; font-size: 12px; border-radius: 6px; }
  .btn-icon { padding: 6px 8px; line-height: 1; }
  .btn:disabled { opacity: 0.4; cursor: not-allowed; }

  /* ---------- Login ---------- */
  #view-login { display: flex; align-items: center; justify-content: center; min-height: 80vh; }
  .login-card {
    position: relative;
    width: 100%; max-width: 360px; background: var(--bg-card);
    border: 1px solid var(--border); border-radius: var(--radius);
    padding: 32px; box-shadow: var(--shadow);
  }
  .login-card h1 { font-size: 20px; margin: 0 0 4px; }
  .login-card p.sub { color: var(--text-dim); font-size: 13px; margin: 0 0 22px; }

  /* ---------- Theme toggle ---------- */
  .theme-toggle-btn {
    background: var(--bg); border: 1px solid var(--border); color: var(--text);
    width: 34px; height: 34px; border-radius: 50%; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center; font-size: 15px;
    line-height: 1; padding: 0;
  }
  .theme-toggle-btn:hover { border-color: var(--accent-dim); }
  .login-card .theme-toggle-btn { position: absolute; top: 16px; right: 16px; }

  /* ---------- Form elements ---------- */
  label { display: block; font-size: 13px; color: var(--text-dim); margin: 14px 0 6px; }
  label:first-of-type { margin-top: 0; }
  input[type=text], input[type=email], input[type=password], input[type=number], select {
    width: 100%; background: var(--bg); border: 1px solid var(--border); color: var(--text);
    border-radius: 7px; padding: 10px 11px; font-size: 14px; outline: none;
  }
  input:focus, select:focus { border-color: var(--accent); }
  .field-error { color: var(--danger); font-size: 13px; margin-top: 10px; min-height: 0; }

  /* Two-factor sign-in */
  .link-btn { background: none; border: 0; padding: 0; font: inherit; font-size: 13px; color: var(--accent); cursor: pointer; text-decoration: underline; }
  .link-btn:hover { color: var(--text); }
  .login-alt { margin: 12px 0 0; text-align: center; }
  .code-input { font-size: 20px !important; letter-spacing: 3px; font-variant-numeric: tabular-nums; }
  .tf-text { font-size: 14px; line-height: 1.5; margin: 12px 0 0; color: var(--text); }
  .tf-steps { margin: 12px 0; padding-left: 20px; font-size: 14px; line-height: 1.6; }
  .tf-status { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 14px; }
  .tf-pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; border: 1px solid var(--border); color: var(--text-dim); }
  .tf-pill.on { border-color: var(--accent); color: var(--accent); }
  .tf-qr { display: flex; justify-content: center; margin: 4px 0 8px; }
  .tf-qr svg { width: 208px; height: 208px; background: #fff; border-radius: 6px; }
  .tf-key { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; word-break: break-all; user-select: all; color: var(--text); }
  .tf-codes { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 18px; margin: 12px 0; padding: 12px 14px; list-style: none; border: 1px solid var(--border); border-radius: 6px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 15px; user-select: all; }
  .tf-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
  .remember-row { display: flex !important; align-items: center; gap: 8px; margin: 12px 0 2px; font-size: 14px; cursor: pointer; color: var(--text); }
  .remember-row input { width: auto !important; margin: 0; }
  .remember-hint { font-size: 12px; }
  .tf-devices { margin: 8px 0 0; padding: 0; list-style: none; font-size: 13px; }
  .tf-devices li { padding: 6px 0; border-top: 1px solid var(--border); color: var(--text); }
  .tf-devices li:first-child { border-top: 0; }
  .tf-admin-row { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--text); }
  .role-badge.tf-badge { background: rgba(45,212,191,0.10); color: var(--accent); }
  .form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }

  /* ---------- Dashboard header ---------- */
  .summary-card {
    background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 24px 28px; margin-bottom: 24px; display: flex; flex-direction: column; gap: 18px;
  }
  .summary-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
  .summary-total .label { color: var(--text-dim); font-size: 13px; margin-bottom: 4px; }
  .summary-total .amount { font-size: 38px; font-weight: 700; letter-spacing: -0.5px; }
  .summary-net-badge {
    display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 20px;
    font-size: 13px; font-weight: 600; background: var(--bg); border: 1px solid var(--border); margin-top: 4px;
  }
  .summary-net-badge.positive { color: var(--positive); }
  .summary-net-badge.negative { color: var(--danger); }
  .summary-chart { width: 100%; min-height: 220px; position: relative; }
  .summary-chart .empty-note { color: var(--text-faint); font-size: 13px; }
  .combo-bar { opacity: 0.5; }
  .combo-bar.positive { fill: var(--positive); }
  .combo-bar.negative { fill: var(--danger); }
  .combo-chart-caption { font-size: 11px; color: var(--text-faint); margin-top: 8px; }
  .chart-tooltip {
    position: fixed; z-index: 500; pointer-events: none;
    background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 8px;
    box-shadow: var(--shadow); padding: 8px 12px; font-size: 12px; color: var(--text);
    opacity: 0; transform: translate(-50%, -100%); transition: opacity 0.1s ease;
    white-space: nowrap;
  }
  .chart-tooltip.visible { opacity: 1; }
  .chart-tooltip .tt-date { color: var(--text-faint); font-size: 11px; margin-bottom: 2px; }
  .chart-tooltip .tt-amount { font-weight: 700; }

  /* ---------- Toolbar ---------- */
  .toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
  .toolbar .search-box { position: relative; flex: 1; min-width: 200px; max-width: 320px; }
  .toolbar input[type=text].search { padding-left: 32px; }
  .toolbar .search-box::before {
    content: "🔍"; position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
    font-size: 12px; opacity: 0.5;
  }
  .sort-control { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-dim); }
  .sort-control select { width: auto; padding: 7px 9px; font-size: 13px; }

  /* ---------- Company table (dense consolidated list) ---------- */
  .company-table td:first-child, .company-table th:first-child { padding-left: 16px; }
  .company-row { cursor: pointer; }
  .company-row:hover { background: rgba(255,255,255,0.03); }
  td .mini-spark { width: 90px; margin-top: 0; }
  .empty-state { color: var(--text-faint); padding: 40px 0; text-align: center; font-size: 14px; }

  /* ---------- Company detail ---------- */
  .back-link { background: none; border: none; color: var(--text-dim); cursor: pointer; font-size: 13px; padding: 0; margin-bottom: 14px; }
  .back-link:hover { color: var(--text); }
  .company-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 20px; gap: 12px; flex-wrap: wrap; }
  .company-header h1 { margin: 0 0 4px; font-size: 24px; }
  .company-header .total { color: var(--text-dim); font-size: 14px; }
  .company-header .total strong { color: var(--text); font-size: 16px; }
  .header-actions { display: flex; gap: 8px; }

  table { width: 100%; border-collapse: collapse; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
  thead th {
    text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px;
    color: var(--text-faint); padding: 12px 14px; border-bottom: 1px solid var(--border); cursor: pointer; user-select: none;
  }
  thead th:hover { color: var(--text-dim); }
  thead th.sortable::after { content: ""; margin-left: 4px; }
  thead th.sort-asc::after { content: "▲"; font-size: 9px; }
  thead th.sort-desc::after { content: "▼"; font-size: 9px; }
  tbody td { padding: 12px 14px; border-bottom: 1px solid var(--border); font-size: 14px; }
  tbody tr:last-child td { border-bottom: none; }
  tbody tr:hover { background: rgba(255,255,255,0.02); }
  td.actions-col, th.actions-col { text-align: right; }
  .row-actions { display: inline-flex; gap: 6px; }
  .balance-cell { font-weight: 600; }
  .dim { color: var(--text-faint); }

  /* ---------- Users view ---------- */
  .role-badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px; }
  .role-badge.admin { background: rgba(45,212,191,0.14); color: var(--accent); }
  .role-badge.viewer { background: rgba(152,164,189,0.14); color: var(--text-dim); }

  .company-access-note { font-size: 12px; color: var(--text-faint); margin: 2px 0 8px; }
  .company-access-list {
    max-height: 220px; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px;
    padding: 4px 12px; margin-top: 4px;
  }
  .company-access-list label {
    display: flex; align-items: center; gap: 8px; padding: 7px 0; font-size: 13px; font-weight: 400;
    border-bottom: 1px solid var(--border); cursor: pointer;
  }
  .company-access-list label:last-child { border-bottom: none; }
  .company-access-list input[type=checkbox] { width: 15px; height: 15px; flex-shrink: 0; }
  .company-access-list.hidden, .company-access-toggle-row.hidden { display: none; }
  .company-access-empty { font-size: 13px; color: var(--text-faint); padding: 10px 0; }

  /* ---------- Debt Summary ----------
     A quieter, "tap for detail" layout instead of wide multi-column tables:
     a segmented control switches between the three sections (one list
     visible at a time, not three stacked grids), each loan is a single row
     with just a name + the one or two facts that matter at a glance, and
     everything else lives in a detail sheet opened by tapping the row. */

  .debt-tabs {
    display: inline-flex; gap: 2px; background: var(--bg); border: 1px solid var(--border);
    border-radius: 10px; padding: 3px; margin-bottom: 18px;
  }
  .debt-tab {
    appearance: none; border: none; background: transparent; cursor: pointer;
    padding: 7px 14px; border-radius: 7px; font-size: 13px; font-weight: 600;
    color: var(--text-dim); font-family: inherit; white-space: nowrap;
    transition: background 0.12s ease, color 0.12s ease;
  }
  .debt-tab:hover { color: var(--text); }
  .debt-tab.active { background: var(--bg-card); color: var(--text); box-shadow: var(--shadow); }
  .debt-tab .debt-tab-total { color: var(--text-faint); font-weight: 400; margin-left: 6px; }
  .debt-tab.active .debt-tab-total { color: var(--text-dim); }

  .debt-list-card {
    background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 4px 20px; margin-bottom: 24px;
  }
  .debt-list-meta {
    display: flex; justify-content: space-between; align-items: baseline;
    padding: 14px 0 10px; font-size: 12px; color: var(--text-faint);
    text-transform: uppercase; letter-spacing: 0.4px;
  }
  .debt-row {
    display: flex; align-items: center; justify-content: space-between; gap: 18px;
    padding: 13px 0; border-top: 1px solid var(--border); cursor: pointer;
  }
  .debt-list-meta + .debt-row { border-top: none; }
  .debt-row:hover .debt-row-title { color: var(--accent); }
  .debt-row-main { min-width: 0; }
  .debt-row-title { font-size: 14px; font-weight: 600; color: var(--text); transition: color 0.12s ease; }
  .debt-row-sub {
    font-size: 12.5px; color: var(--text-faint); margin-top: 2px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 46vw;
  }
  .debt-row-trailing { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
  .debt-row-amounts { text-align: right; }
  .debt-row-balance { font-size: 14px; font-weight: 600; color: var(--text); white-space: nowrap; }
  .debt-row-meta { font-size: 12px; color: var(--text-faint); margin-top: 2px; white-space: nowrap; }
  .debt-row-chevron { color: var(--text-faint); font-size: 13px; }
  .debt-list-empty { padding: 36px 0; text-align: center; color: var(--text-faint); font-size: 13px; }

  .debt-detail-list { margin-top: 4px; }
  .debt-detail-row {
    display: flex; justify-content: space-between; align-items: baseline; gap: 16px;
    padding: 10px 0; border-top: 1px solid var(--border); font-size: 13px;
  }
  .debt-detail-row:first-child { border-top: none; }
  .debt-detail-label { color: var(--text-faint); flex-shrink: 0; }
  .debt-detail-value { color: var(--text); font-weight: 600; text-align: right; }

  .debt-notes-card { padding: 18px 2px 0; }
  .debt-notes-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
  .debt-notes-title { font-size: 13px; font-weight: 600; color: var(--text-dim); margin: 0; }
  #debt-notes-view { font-size: 13px; color: var(--text-dim); white-space: pre-wrap; line-height: 1.5; }
  #debt-notes-textarea {
    width: 100%; background: var(--bg); border: 1px solid var(--border); color: var(--text);
    border-radius: 7px; padding: 10px 11px; font-size: 13px; outline: none; resize: vertical; font-family: inherit;
  }
  #debt-notes-textarea:focus { border-color: var(--accent); }

  /* ---------- Modal ---------- */
  .modal-overlay {
    position: fixed; inset: 0; background: rgba(6,10,18,0.6); backdrop-filter: blur(2px);
    display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px;
  }
  .modal-box {
    width: 100%; max-width: 420px; background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 26px; box-shadow: var(--shadow);
  }
  .modal-box.modal-wide { max-width: 640px; }
  .modal-box h2 { margin: 0 0 4px; font-size: 17px; }
  .modal-box p.modal-sub { margin: 0; color: var(--text-dim); font-size: 13px; }
  .two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }

  .csv-dropzone {
    border: 1.5px dashed var(--border); border-radius: 8px; padding: 22px;
    text-align: center; color: var(--text-dim); font-size: 13px; margin-top: 6px;
  }
  .csv-dropzone input[type=file] { margin-top: 10px; font-size: 13px; color: var(--text-dim); width: 100%; }
  .csv-preview-wrap { max-height: 320px; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; margin-top: 14px; }
  .csv-preview-wrap table { border: none; border-radius: 0; }
  .csv-preview-wrap thead th { position: sticky; top: 0; background: var(--bg-card); cursor: default; }
  .csv-preview-wrap thead th::after { content: none; }
  .csv-summary { display: flex; gap: 16px; font-size: 13px; margin-top: 14px; flex-wrap: wrap; }
  .csv-summary span strong { display: block; font-size: 18px; }
  .status-pill { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.3px; }
  .status-pill.updated, .status-pill.live { background: rgba(74,222,128,0.14); color: var(--positive); }
  .status-pill.unchanged, .status-pill.pending { background: rgba(152,164,189,0.14); color: var(--text-dim); }
  .status-pill.error { background: rgba(248,113,113,0.14); color: var(--danger); }


  /* ---------- Lease management ---------- */
  input[type=date], textarea {
    width: 100%; background: var(--bg); border: 1px solid var(--border); color: var(--text);
    border-radius: 7px; padding: 10px 11px; font-size: 14px; outline: none; font-family: inherit;
  }
  input[type=date] { color-scheme: dark; }
  :root[data-theme="light"] input[type=date] { color-scheme: light; }
  textarea { resize: vertical; }
  input[type=date]:focus, textarea:focus { border-color: var(--accent); }
  .page-title { font-size: 20px; margin: 0; }
  .page-sub { font-size: 12px; color: var(--text-faint); margin-top: 4px; }

  .kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
  .stat-tile { background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
  .stat-tile .stat-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.3px; color: var(--text-faint); margin-bottom: 6px; }
  .stat-tile .stat-value { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
  .stat-tile .stat-sub { font-size: 11px; color: var(--text-faint); margin-top: 4px; }

  /* ---------- Loan calculator ---------- */
  .calc-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px 16px; }
  .calc-field label { margin: 0 0 6px; }
  .calc-field .hint { font-size: 11.5px; color: var(--text-dim); margin-top: 5px; line-height: 1.35; }
  .calc-field input.invalid { border-color: var(--danger); }
  .calc-prefill { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 16px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
  .calc-prefill label { margin: 0; }
  .calc-prefill select { flex: 1 1 260px; min-width: 0; max-width: 460px; }
  .calc-fee-row { display: grid; grid-template-columns: minmax(190px, 240px) 1fr; gap: 14px 16px; align-items: start; }
  .calc-fee-row .kpi-grid:empty { display: none; }
  .calc-fee-empty { font-size: 13px; color: var(--text-dim); padding-top: 28px; }
  @media (max-width: 640px) { .calc-fee-row { grid-template-columns: 1fr; } .calc-fee-empty { padding-top: 0; } }
  .calc-chart { width: 100%; height: auto; display: block; }
  .calc-chart .axis { stroke: var(--border); stroke-width: 1; }
  .calc-chart .bal-line { fill: none; stroke: var(--accent); stroke-width: 2; }
  .calc-chart .bal-area { fill: var(--accent); opacity: 0.12; }
  .calc-chart text { fill: var(--text-dim); font-size: 11px; }
  .calc-seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
  .calc-seg button { background: transparent; color: var(--text-dim); border: 0; padding: 6px 12px; font-size: 13px; cursor: pointer; }
  .calc-seg button.active { background: var(--accent); color: var(--accent-fg); font-weight: 600; }
  .calc-table-wrap { max-height: 520px; overflow: auto; border-radius: var(--radius); border: 1px solid var(--border); }
  .calc-table-wrap table { border: 0; border-radius: 0; min-width: 640px; }
  .calc-table-wrap thead th { position: sticky; top: 0; background: var(--bg-card); cursor: default; text-align: right; }
  .calc-table-wrap thead th:first-child, .calc-table-wrap thead th:nth-child(2) { text-align: left; }
  .calc-table-wrap td { text-align: right; padding: 8px 14px; font-size: 13.5px; }
  .calc-table-wrap td:first-child, .calc-table-wrap td:nth-child(2) { text-align: left; }
  .calc-table-wrap tr.balloon td { font-weight: 700; }

  .split-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; margin-bottom: 24px; }
  .panel {
    background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 18px 22px; min-width: 0;
  }
  .panel-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; }
  .panel-title { font-size: 14px; font-weight: 700; margin: 0; }
  .panel-sub { font-size: 12px; color: var(--text-faint); }
  .panel + .panel { margin-top: 20px; }
  .split-row > .panel + .panel { margin-top: 0; }
  .schedule-wrap { overflow-x: auto; margin: 0 -4px; }
  .schedule-table { border: none; }
  .schedule-table thead th, .schedule-table tbody td { padding: 10px 8px; }

  .alert-list { max-height: 300px; overflow-y: auto; }
  .alert-row {
    display: flex; align-items: center; gap: 12px; padding: 10px 0;
    border-top: 1px solid var(--border); cursor: pointer;
  }
  .alert-row:first-child { border-top: none; }
  .alert-row:hover .alert-title { color: var(--accent); }
  .alert-when { width: 64px; flex-shrink: 0; text-align: center; }
  .alert-when .d { font-size: 15px; font-weight: 700; line-height: 1.1; }
  .alert-when .m { font-size: 10px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--text-faint); }
  .alert-main { min-width: 0; flex: 1; }
  .alert-title { font-size: 13.5px; font-weight: 600; transition: color 0.12s; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .alert-sub { font-size: 12px; color: var(--text-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .alert-days { font-size: 12px; color: var(--text-dim); white-space: nowrap; }
  .alert-days.overdue { color: var(--danger); font-weight: 600; }
  .alert-days.soon { color: var(--warn); font-weight: 600; }

  .kind-pill {
    display: inline-block; padding: 1px 8px; border-radius: 20px; font-size: 10.5px;
    text-transform: uppercase; letter-spacing: 0.3px; background: rgba(152,164,189,0.14); color: var(--text-dim);
    white-space: nowrap; margin-right: 6px; vertical-align: 1px;
  }
  .status-pill.active { background: rgba(74,222,128,0.14); color: var(--positive); }
  .status-pill.future { background: rgba(45,212,191,0.14); color: var(--accent); }
  .status-pill.expired, .status-pill.vacant { background: rgba(152,164,189,0.14); color: var(--text-dim); }
  .status-pill.overdue { background: rgba(248,113,113,0.14); color: var(--danger); }
  .status-pill.soon { background: rgba(251,191,36,0.15); color: var(--warn); }

  .exp-chart { position: relative; }
  .exp-chart svg { display: block; width: 100%; height: auto; overflow: visible; }
  .exp-chart .bar { fill: var(--accent); }
  .exp-chart .bar-hit { fill: transparent; cursor: default; }
  .exp-chart .bar-group:hover .bar { fill: var(--accent-dim); }
  .exp-chart .axis-label { fill: var(--text-faint); font-size: 11px; }
  .exp-chart .value-label { fill: var(--text-dim); font-size: 11px; font-weight: 600; }
  .exp-chart .baseline { stroke: var(--border); stroke-width: 1; }
  .empty-note { color: var(--text-faint); font-size: 13px; padding: 20px 0; }

  .occ-cell { display: flex; align-items: center; gap: 8px; }
  .occ-bar { width: 70px; height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; flex-shrink: 0; }
  .occ-bar > span { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
  .num { font-variant-numeric: tabular-nums; white-space: nowrap; }
  .clickable-row { cursor: pointer; }
  .clickable-row:hover { background: rgba(255,255,255,0.03); }
  .table-wrap { overflow-x: auto; border-radius: var(--radius); }
  .table-wrap table { min-width: 720px; }
  .tenant-link { font-weight: 600; color: var(--text); }
  .clickable-row:hover .tenant-link { color: var(--accent); }
  .section-heading { font-size: 15px; font-weight: 700; margin: 28px 0 10px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }

  .facts-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 24px; }
  .fact { padding: 10px 0; border-top: 1px solid var(--border); }
  .fact-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.3px; color: var(--text-faint); }
  .fact-value { font-size: 14px; font-weight: 600; margin-top: 3px; overflow-wrap: anywhere; }

  .schedule-table td, .schedule-table th { cursor: default; }
  .schedule-table tr.current-step td { background: rgba(45,212,191,0.08); }
  .schedule-table tr.current-step td:first-child { box-shadow: inset 3px 0 0 var(--accent); }

  .doc-row, .kd-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--border); }
  .doc-row:first-child, .kd-row:first-child { border-top: none; }
  .doc-icon { width: 32px; height: 38px; border: 1px solid var(--border); border-radius: 5px; display: flex; align-items: flex-end; justify-content: center; font-size: 9px; font-weight: 700; color: var(--text-dim); padding-bottom: 4px; flex-shrink: 0; text-transform: uppercase; }
  .doc-main, .kd-main { flex: 1; min-width: 0; }
  .doc-name { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .doc-meta, .kd-meta { font-size: 12px; color: var(--text-faint); }
  .kd-title { font-size: 13.5px; font-weight: 600; }
  .kd-row.done .kd-title { color: var(--text-dim); }
  .kd-status { text-align: right; flex-shrink: 0; }
  .kd-status .kd-meta { margin-top: 2px; }
  .link-btn { background: none; border: none; padding: 0; color: var(--accent); font-size: 12px; cursor: pointer; font-family: inherit; }
  .link-btn:hover { text-decoration: underline; }
  .alert-actions { flex-shrink: 0; }
  .schedule-table tr.option-row td { color: var(--text-faint); font-style: italic; }
  .upload-zone { border: 1.5px dashed var(--border); border-radius: 8px; padding: 14px; text-align: center; font-size: 13px; color: var(--text-dim); margin-top: 10px; }
  .upload-zone.dragover { border-color: var(--accent); color: var(--accent); }
  .notes-text { font-size: 13px; color: var(--text-dim); white-space: pre-wrap; line-height: 1.5; }

  .lease-header-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; color: var(--text-dim); font-size: 14px; }

  .filters { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
  .filters select { width: auto; padding: 7px 9px; font-size: 13px; }
  .filters label.check { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-size: 13px; color: var(--text-dim); }
  .month-group { margin-bottom: 18px; }
  .month-label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-faint); margin: 0 0 6px 2px; font-weight: 600; }
  .month-group .panel { padding: 4px 20px; }

  .schedule-editor-row { display: grid; grid-template-columns: 1fr 1fr 34px; gap: 8px; margin-bottom: 8px; align-items: center; }
  .schedule-gen { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin: 12px 0; }
  .schedule-gen label { margin: 0 0 4px; font-size: 12px; }
  .schedule-gen > div { flex: 1; min-width: 110px; }
  .charge-toggles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 12px; }
  .charge-toggles select { padding: 8px 9px; }
  .payments-table td, .payments-table th { cursor: default; }
  .payments-table tr.na td { color: var(--text-faint); }
  .payments-table tr.total-row td { font-weight: 700; border-top: 1px solid var(--border); }
  .na-tag { font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--text-faint); }
  .charge-input-na { display: flex; align-items: center; height: 41px; padding: 0 11px; border: 1px dashed var(--border); border-radius: 7px; color: var(--text-faint); font-size: 13px; }
  .notify-status { font-size: 13px; border-radius: 8px; padding: 10px 12px; margin: 14px 0 4px; }
  .notify-status.ok { background: rgba(74,222,128,0.10); color: var(--positive); }
  .notify-status.warn { background: rgba(251,191,36,0.12); color: var(--warn); }
  .company-access-list label.disabled { color: var(--text-faint); cursor: not-allowed; }
  .notify-section { border-top: 1px solid var(--border); margin-top: 20px; padding-top: 16px; }
  .notify-log { max-height: 140px; overflow-y: auto; font-size: 12.5px; }
  .notify-log-row { display: grid; grid-template-columns: 1.4fr 1.4fr 1fr; gap: 8px; padding: 6px 0; border-top: 1px solid var(--border); color: var(--text-dim); }
  .notify-log-row:first-child { border-top: none; }
  .notify-log-row .good { color: var(--positive); text-align: right; } .notify-log-row .bad { color: var(--danger); text-align: right; }
  .notify-log-err { grid-column: 1 / -1; color: var(--danger); font-size: 12px; }
  .entity-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--border); }
  .entity-row:first-child { border-top: none; }
  .entity-row .entity-name { flex: 1; font-size: 14px; }
  .entity-list { max-height: 320px; overflow-y: auto; margin: 12px 0; }

  /* ---------- Leasing pipeline ---------- */
  .pipeline-board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(200px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 8px; margin-bottom: 18px; }
  .pipeline-col { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; min-height: 140px; }
  .pipeline-col-head { display: flex; justify-content: space-between; font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px; font-weight: 700; color: var(--text-dim); padding: 2px 4px 10px; }
  .pipeline-empty { color: var(--text-faint); text-align: center; font-size: 13px; padding: 14px 0; }
  .pcard { background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; cursor: pointer; transition: border-color 0.12s; }
  .pcard:hover { border-color: var(--accent-dim); }
  .pcard-name { font-weight: 700; font-size: 13.5px; }
  .pcard-space { font-size: 12px; color: var(--text-faint); margin-top: 2px; }
  .pcard-row { display: flex; justify-content: space-between; gap: 8px; font-size: 12.5px; margin-top: 8px; font-variant-numeric: tabular-nums; }
  .pcard-next { font-size: 12px; color: var(--text-dim); margin-top: 6px; }
  .pcard-docs { font-size: 11.5px; color: var(--text-faint); margin-top: 6px; }
  .stage-track { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
  .stage-step { display: flex; align-items: center; gap: 7px; padding: 6px 10px 6px 6px; border-radius: 20px; border: 1px solid var(--border); font-size: 12.5px; color: var(--text-faint); background: var(--bg); }
  .stage-dot { width: 20px; height: 20px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; background: var(--border); color: var(--text-dim); }
  .stage-step.reached { color: var(--text-dim); }
  .stage-step.reached .stage-dot { background: rgba(45,212,191,0.18); color: var(--accent); }
  .stage-step.current { color: var(--text); border-color: var(--accent); font-weight: 700; }
  .stage-step.current .stage-dot { background: var(--accent); color: var(--accent-fg); }
  .stage-step.lost { border-color: var(--danger-dim); }
  .stage-lost { padding: 6px 12px; border-radius: 20px; font-size: 12.5px; font-weight: 700; color: var(--danger); background: rgba(248,113,113,0.12); }
  .prospect-badge { display: inline-block; margin-left: 8px; font-size: 11px; color: var(--accent); }

  @media (max-width: 960px) {
    .split-row { grid-template-columns: 1fr; }
  }

  .toast {
    position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
    background: var(--bg-elevated); border: 1px solid var(--border); color: var(--text);
    padding: 11px 18px; border-radius: 8px; font-size: 13px; box-shadow: var(--shadow); z-index: 200;
  }
  .toast.error { border-color: var(--danger-dim); color: #fecaca; }

  @media (max-width: 860px) {
    .app-shell { flex-direction: column; }
    #main { width: 100%; }
    #navbar {
      width: 100%; height: auto; position: sticky; top: 0;
      flex-direction: row; align-items: center; padding: 10px 16px;
      border-right: none; border-bottom: 1px solid var(--border);
      overflow-x: auto; overflow-y: visible;
    }
    .sidebar-top { border-bottom: none; margin-bottom: 0; padding-bottom: 0; flex-shrink: 0; }
    .nav-links { flex-direction: row; flex: 0 0 auto; margin: 0 6px; gap: 2px; }
    #navbar .nav-link span:not(.nav-icon) { display: none; }
    .sidebar-bottom {
      margin-top: 0; margin-left: auto; padding-top: 0; border-top: none;
      flex-direction: row; align-items: center; gap: 8px; flex-shrink: 0;
    }
    #navbar .sidebar-bottom .btn { width: auto; }
    #navbar .user-chip { display: none; }
  }
  @media (max-width: 560px) {
    .charge-toggles { grid-template-columns: 1fr; }
    #main { padding: 20px 14px 60px; }
    .summary-total .amount { font-size: 26px; }
    .two-col { grid-template-columns: 1fr; }
  }

  /* ---------- Market Rates ---------- */
  .rates-grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
  .rate-tile { display: flex; flex-direction: column; }
  .rate-tile.highlight { border-color: var(--accent-dim); }
  .rate-tile .rate-change { font-size: 12px; color: var(--text-dim); margin-top: 2px; font-variant-numeric: tabular-nums; }
  .rate-tile .rate-change.up { color: var(--positive); }
  .rate-tile .rate-change.down { color: var(--danger); }
  .rate-tile .rate-stale { color: var(--warn); }
  .rate-tile.stale .stat-value { color: var(--text-dim); }
  .rates-spark { display: block; width: 100%; height: 30px; margin-top: 8px; }
  .rates-spark path { fill: none; stroke: var(--accent); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
  .rates-notice { border: 1px solid var(--warn); color: var(--text); background: var(--bg-card); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 20px; font-size: 13.5px; line-height: 1.45; }
  .rates-curve-row { display: grid; grid-template-columns: minmax(0, 2fr) minmax(200px, 1fr); gap: 20px; align-items: start; margin-bottom: 16px; }
  .rates-grid-narrow { grid-template-columns: 1fr; }
  @media (max-width: 900px) { .rates-curve-row { grid-template-columns: 1fr; } .rates-grid-narrow { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); } }
  .rates-curve .grid { stroke: var(--border); stroke-width: 1; }
  .rates-curve path { fill: none; stroke-width: 2; }
  .rates-curve .curve-now { stroke: var(--accent); stroke-width: 2.5; }
  .rates-curve .curve-month { stroke: var(--text-dim); stroke-dasharray: 5 4; }
  .rates-curve .curve-year { stroke: var(--warn); stroke-dasharray: 2 4; }
  .rates-curve .curve-dot { fill: var(--accent); }
  .rates-legend { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 12px; color: var(--text-dim); margin-top: 6px; }
  .legend-item { display: inline-flex; align-items: center; gap: 6px; }
  .legend-swatch { display: inline-block; width: 18px; height: 0; border-top: 2.5px solid var(--accent); }
  .legend-swatch.curve-month { border-top: 2px dashed var(--text-dim); }
  .legend-swatch.curve-year { border-top: 2px dotted var(--warn); }
  .rates-table-wrap { max-height: none; }
  .rates-table-wrap tr.row-highlight td { font-weight: 700; }
  .rates-sources { font-size: 12px; color: var(--text-faint); line-height: 1.5; margin: 20px 2px 8px; }
  .rates-manual-row { display: grid; grid-template-columns: minmax(160px, 1.3fr) 1fr 1fr; gap: 10px 14px; align-items: end; padding: 10px 0; border-bottom: 1px solid var(--border); }
  .rates-manual-row label { margin: 0 0 4px; }
  .rates-manual-label { font-weight: 600; font-size: 14px; }
  .rates-manual-label .dim { font-weight: 400; font-size: 12px; margin-top: 3px; }
  @media (max-width: 640px) { .rates-manual-row { grid-template-columns: 1fr 1fr; } .rates-manual-label { grid-column: 1 / -1; } }
  .rates-table-wrap thead th:nth-child(2), .rates-table-wrap td:nth-child(2) { text-align: right; }
