    *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

    :root {
      --bg: #f4f6f9;
      --card: #ffffff;
      --border: #e1e5eb;
      --primary: #2563eb;
      --primary-dark: #1d4ed8;
      --text: #1e293b;
      --muted: #64748b;
      --green: #16a34a;
      --red: #dc2626;
      --header-bg: #1e293b;
    }

    body {
      font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
      background: var(--bg);
      color: var(--text);
      min-height: 100vh;
    }

    header {
      background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
      color: #fff;
      padding: 20px 32px;
      display: flex;
      align-items: center;
      justify-content: space-between;
    }

    header h1 { font-size: 1.35rem; font-weight: 700; letter-spacing: 0.02em; }
    header span { font-size: 0.8rem; color: #94a3b8; letter-spacing: 0.04em; }

    .tabs {
      display: flex;
      gap: 0;
      background: var(--header-bg);
      padding: 0 32px;
      border-bottom: 1px solid #334155;
    }

    .tab {
      padding: 10px 20px;
      cursor: pointer;
      font-size: 0.875rem;
      color: #94a3b8;
      border-bottom: 3px solid transparent;
      transition: all 0.15s;
      user-select: none;
    }

    .tab:hover { color: #e2e8f0; }
    .tab.active { color: #fff; border-bottom-color: var(--primary); }

    .container {
      max-width: 1100px;
      margin: 0 auto;
      padding: 28px 20px;
    }

    .page { display: none; }
    .page.active { display: block; }

    @media (max-width: 700px) {
      header { padding: 14px 16px; }
      .tabs { padding: 0 16px; }
      .container { padding: 20px 12px; }
    }

    .card {
      background: var(--card);
      border: 1px solid var(--border);
      border-radius: 10px;
      padding: 22px;
      margin-bottom: 20px;
    }

    .card-title {
      font-size: 0.9rem;
      font-weight: 600;
      text-transform: uppercase;
      letter-spacing: 0.05em;
      color: var(--muted);
      margin-bottom: 16px;
      padding-bottom: 10px;
      border-bottom: 1px solid var(--border);
    }

    .btn {
      padding: 8px 16px;
      border-radius: 7px;
      border: none;
      cursor: pointer;
      font-size: 0.875rem;
      font-weight: 500;
      transition: background 0.15s;
    }

    .btn-primary { background: var(--primary); color: #fff; }
    .btn-primary:hover { background: var(--primary-dark); }
    .btn-sm { padding: 5px 11px; font-size: 0.8rem; }
    .btn-ghost {
      background: transparent;
      border: 1px solid var(--border);
      color: var(--muted);
    }
    .btn-ghost:hover { background: var(--bg); }
    .btn-danger { background: #fee2e2; color: var(--red); border: none; }
    .btn-danger:hover { background: #fecaca; }

    .actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }

    /* Statement output styles */
    .statement {
      background: var(--card);
      border: 1px solid var(--border);
      border-radius: 10px;
      padding: 32px;
      margin-bottom: 24px;
    }

    .stmt-header {
      text-align: center;
      margin-bottom: 28px;
    }

    .stmt-header .company { font-size: 1.2rem; font-weight: 700; }
    .stmt-header .title { font-size: 1rem; font-weight: 600; color: var(--muted); margin: 4px 0; }
    .stmt-header .period { font-size: 0.85rem; color: var(--muted); }

    .stmt-table {
      width: 100%;
      border-collapse: collapse;
      font-size: 0.9rem;
    }

    .stmt-table td { padding: 6px 8px; }
    .stmt-table .col-label { width: 60%; }
    .stmt-table .col-amount { text-align: right; width: 20%; }
    .stmt-table .col-total { text-align: right; width: 20%; }

    .stmt-table .section-header td {
      font-weight: 700;
      padding-top: 16px;
      padding-bottom: 4px;
      font-size: 0.8rem;
      text-transform: uppercase;
      letter-spacing: 0.05em;
      color: var(--muted);
    }

    .stmt-table .item td { border-bottom: 1px solid #f1f5f9; }
    .stmt-table .item td:first-child { padding-left: 20px; }

    .stmt-table .subtotal td {
      font-weight: 600;
      border-top: 1px solid var(--border);
      border-bottom: 1px solid var(--border);
    }

    .stmt-table .grand-total td {
      font-weight: 700;
      border-top: 2px solid var(--text);
      border-bottom: 2px solid var(--text);
      font-size: 0.95rem;
    }

    .positive { color: var(--green); }
    .negative { color: var(--red); }

    .print-actions {
      display: flex;
      gap: 10px;
      justify-content: flex-end;
      margin-bottom: 20px;
    }

    .meta-row {
      display: grid;
      grid-template-columns: 1fr 1fr 1fr;
      gap: 14px;
      margin-bottom: 20px;
    }

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

    .meta-row label { font-size: 0.8rem; color: var(--muted); display: block; margin-bottom: 4px; }
    .meta-row input {
      width: 100%;
      padding: 8px 10px;
      border: 1px solid var(--border);
      border-radius: 6px;
      font-size: 0.875rem;
      outline: none;
    }
    .meta-row input:focus { border-color: var(--primary); }

    /* ── Import UI ─────────────────────────────────────────────────────── */
    .import-zone {
      border: 2px dashed var(--border);
      border-radius: 8px;
      padding: 18px 14px;
      text-align: center;
      cursor: pointer;
      transition: all 0.15s;
      background: var(--bg);
      position: relative;
      min-height: 90px;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 4px;
    }
    .import-zone:hover, .import-zone.drag-over {
      border-color: var(--primary);
      background: #eff6ff;
    }
    .import-zone input[type="file"] {
      position: absolute; inset: 0; opacity: 0; cursor: pointer;
      width: 100%; height: 100%;
    }
    .import-zone .zone-label {
      font-size: 0.72rem;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 0.06em;
      color: var(--muted);
      pointer-events: none;
    }
    .import-zone .zone-hint {
      font-size: 0.78rem;
      color: #94a3b8;
      pointer-events: none;
    }
    .import-zone .zone-file {
      font-size: 0.8rem;
      color: var(--primary);
      font-weight: 600;
      pointer-events: none;
      max-width: 180px;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    .import-zone.has-file { border-color: var(--primary); border-style: solid; background: #eff6ff; }

    .import-status {
      margin-top: 12px;
      font-size: 0.85rem;
      border-radius: 7px;
      padding: 10px 14px;
    }
    .import-status.success { background: #f0fdf4; color: var(--green); border: 1px solid #bbf7d0; }
    .import-status.error   { background: #fef2f2; color: var(--red);   border: 1px solid #fecaca; }
    .import-status.info    { background: #eff6ff; color: var(--primary); border: 1px solid #bfdbfe; }

    .unmapped-list {
      margin-top: 12px;
      max-height: 320px;
      overflow-y: auto;
      font-size: 0.82rem;
    }
    .unmapped-list table { width: 100%; border-collapse: collapse; }
    .unmapped-list th, .unmapped-list td {
      text-align: left;
      padding: 6px 8px;
      border-bottom: 1px solid var(--border);
      vertical-align: middle;
    }
    .unmapped-list th { font-weight: 600; color: var(--text); background: var(--bg); position: sticky; top: 0; }
    .unmapped-list select {
      width: 100%;
      padding: 5px 8px;
      border: 1px solid var(--border);
      border-radius: 5px;
      font-size: 0.8rem;
      background: #fff;
      color: var(--text);
      cursor: pointer;
    }
    .unmapped-list select:focus { border-color: var(--primary); outline: none; }
    .unmapped-list select.mapped { border-color: var(--green); background: #f0fdf4; }
    .map-actions { margin-top: 12px; display: flex; gap: 10px; align-items: center; }
    .map-count { font-size: 0.8rem; color: var(--muted); }

    /* ── Notes questionnaire ──────────────────────────────────────────── */
    .notes-form { display: flex; flex-direction: column; gap: 18px; }
    .note-group { border-bottom: 1px solid var(--border); padding-bottom: 16px; }
    .note-group:last-child { border-bottom: none; }
    .note-group-title {
      font-size: 0.82rem; font-weight: 700; text-transform: uppercase;
      letter-spacing: 0.05em; color: var(--primary); margin-bottom: 10px;
    }
    .note-field { margin-bottom: 12px; }
    .note-field label {
      display: block; font-size: 0.85rem; font-weight: 500;
      color: var(--text); margin-bottom: 4px; line-height: 1.4;
    }
    .note-field label .hint {
      font-weight: 400; font-size: 0.78rem; color: var(--muted); display: block;
    }
    .note-field input[type="text"],
    .note-field textarea,
    .note-field select {
      width: 100%; padding: 8px 10px; border: 1px solid var(--border);
      border-radius: 6px; font-size: 0.875rem; font-family: inherit; outline: none;
    }
    .note-field textarea { resize: vertical; min-height: 60px; }
    .note-field input:focus, .note-field textarea:focus, .note-field select:focus {
      border-color: var(--primary);
    }
    .note-field .radio-row {
      display: flex; gap: 16px; margin-top: 4px; font-size: 0.85rem;
    }
    .note-field .radio-row label { display: inline-flex; align-items: center; gap: 5px; font-weight: 400; }

    .notes-output { font-size: 0.9rem; line-height: 1.7; }
    .notes-output h3 {
      font-size: 0.95rem; font-weight: 700; margin: 20px 0 6px; color: var(--text);
    }
    .notes-output h3:first-child { margin-top: 0; }
    .notes-output p { margin-bottom: 8px; color: #334155; }

    /* ── Comparative note tables ─────────────────────────────────────── */
    .note-table { width: 100%; border-collapse: collapse; margin: 12px 0 20px; font-size: 0.85rem; }
    .note-table th { background: #f8fafc; font-weight: 600; text-align: right; padding: 6px 10px; border-bottom: 2px solid #e1e5eb; }
    .note-table th:first-child { text-align: left; width: 45%; }
    .note-table td { padding: 6px 10px; border-bottom: 1px solid #f1f5f9; }
    .note-table td:not(:first-child) { text-align: right; font-variant-numeric: tabular-nums; }
    .note-table .nt-total td { font-weight: 600; border-top: 1px solid #cbd5e1; }

    /* ── Firm Profile modal ──────────────────────────────────────────── */
    .modal-overlay { display:none; position:fixed; inset:0; background:rgba(0,0,0,0.5); z-index:100; align-items:center; justify-content:center; }
    .modal-overlay.open { display:flex; }
    .modal-box { background:var(--card); border-radius:12px; padding:28px 32px; max-width:560px; width:90%; max-height:85vh; overflow-y:auto; box-shadow:0 20px 60px rgba(0,0,0,0.3); }
    .modal-box h2 { font-size:1.1rem; margin-bottom:16px; color:var(--text); }
    .modal-box .note-field { margin-bottom:12px; }
    .modal-box .note-field label { font-size:0.82rem; font-weight:600; display:block; margin-bottom:4px; }

    /* ── Statement Template ──────────────────────────────────────────── */
    .tpl-row { display:flex; gap:16px; margin-bottom:12px; flex-wrap:wrap; }
    .tpl-row .tpl-col { flex:1; min-width:140px; }
    .tpl-row label { font-size:0.78rem; font-weight:600; color:var(--muted); display:block; margin-bottom:4px; }
    .tpl-row select, .tpl-row input[type="color"] { width:100%; padding:6px 8px; border:1px solid var(--border); border-radius:6px; font-size:0.82rem; }
    .tpl-row input[type="color"] { height:34px; padding:2px; cursor:pointer; }
    .tpl-preview { background:#fff; border:1px solid var(--border); border-radius:8px; padding:16px; margin:16px 0; font-size:0.85rem; }

    /* ── Smart suggestions banner ────────────────────────────────────── */
    .suggestion-card { border:1px solid #93c5fd; background:#eff6ff; border-radius:8px; padding:14px 18px; margin-bottom:12px; }
    .suggestion-card .sg-title { font-weight:600; font-size:0.85rem; color:#1d4ed8; margin-bottom:4px; }
    .suggestion-card .sg-text { font-size:0.8rem; color:#1e40af; line-height:1.5; }
    .suggestion-card .sg-actions { margin-top:8px; display:flex; gap:8px; }
    .suggestion-card .sg-btn { font-size:0.72rem; padding:4px 10px; border-radius:5px; border:1px solid #93c5fd; background:#fff; color:#2563eb; cursor:pointer; }
    .suggestion-card .sg-btn:hover { background:#dbeafe; }

    /* ── Login screen ─────────────────────────────────────────────────── */
    .login-screen {
      min-height: 100vh;
      display: flex;
      align-items: center;
      justify-content: center;
      background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
      padding: 20px;
      position: relative;
      overflow: hidden;
    }
    .login-screen::before {
      content: '';
      position: absolute;
      top: -50%;
      left: -50%;
      width: 200%;
      height: 200%;
      background:
        radial-gradient(ellipse at 20% 50%, rgba(37, 99, 235, 0.12) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(99, 102, 241, 0.1) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 80%, rgba(16, 185, 129, 0.08) 0%, transparent 50%);
      animation: loginBgShift 20s ease-in-out infinite alternate;
      pointer-events: none;
    }
    @keyframes loginBgShift {
      0% { transform: translate(0, 0) rotate(0deg); }
      100% { transform: translate(-3%, -3%) rotate(3deg); }
    }
    .login-screen::after {
      content: '';
      position: absolute;
      inset: 0;
      background-image:
        radial-gradient(rgba(255,255,255,0.03) 1px, transparent 1px);
      background-size: 30px 30px;
      pointer-events: none;
    }
    .login-card {
      background: rgba(255, 255, 255, 0.97);
      border-radius: 18px;
      padding: 40px 34px;
      width: 100%;
      max-width: 400px;
      box-shadow: 0 25px 80px rgba(0,0,0,0.35), 0 0 0 1px rgba(255,255,255,0.05);
      position: relative;
      z-index: 1;
      backdrop-filter: blur(10px);
    }
    .login-card .logo {
      text-align: center;
      margin-bottom: 28px;
    }
    .login-card .logo-icon {
      width: 56px;
      height: 56px;
      background: linear-gradient(135deg, #2563eb 0%, #6366f1 100%);
      border-radius: 14px;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      margin-bottom: 14px;
      box-shadow: 0 8px 24px rgba(37, 99, 235, 0.3);
    }
    .login-card .logo-icon svg {
      width: 28px;
      height: 28px;
    }
    .login-card .logo h2 {
      font-size: 1.5rem;
      font-weight: 800;
      color: var(--text);
      letter-spacing: -0.02em;
    }
    .login-card .logo p {
      font-size: 0.82rem;
      color: var(--muted);
      margin-top: 6px;
      letter-spacing: 0.01em;
    }
    .login-features {
      display: flex;
      justify-content: center;
      gap: 16px;
      margin-top: 14px;
      margin-bottom: 4px;
    }
    .login-features span {
      font-size: 0.7rem;
      color: #94a3b8;
      display: flex;
      align-items: center;
      gap: 4px;
    }
    .login-features span::before {
      content: '';
      width: 5px;
      height: 5px;
      background: #10b981;
      border-radius: 50%;
      display: inline-block;
    }
    .login-card .form-title {
      font-size: 1rem;
      font-weight: 600;
      margin-bottom: 18px;
      color: var(--text);
    }
    .login-field {
      margin-bottom: 14px;
    }
    .login-field label {
      display: block;
      font-size: 0.82rem;
      font-weight: 500;
      color: var(--text);
      margin-bottom: 4px;
    }
    .login-field input {
      width: 100%;
      padding: 11px 14px;
      border: 1.5px solid var(--border);
      border-radius: 9px;
      font-size: 0.875rem;
      outline: none;
      transition: border-color 0.2s, box-shadow 0.2s;
      background: #f8fafc;
    }
    .login-field input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1); background: #fff; }
    .login-btn {
      width: 100%;
      padding: 12px;
      border: none;
      border-radius: 9px;
      background: linear-gradient(135deg, #2563eb 0%, #4f46e5 100%);
      color: #fff;
      font-size: 0.9rem;
      font-weight: 600;
      cursor: pointer;
      margin-top: 8px;
      transition: all 0.2s;
      box-shadow: 0 4px 14px rgba(37, 99, 235, 0.3);
    }
    .login-btn:hover { background: linear-gradient(135deg, #1d4ed8 0%, #4338ca 100%); box-shadow: 0 6px 20px rgba(37, 99, 235, 0.4); transform: translateY(-1px); }
    .login-btn:active { transform: translateY(0); box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3); }
    .login-footer {
      margin-top: 16px;
      text-align: center;
      font-size: 0.82rem;
      color: var(--muted);
    }
    .login-footer a {
      color: var(--primary);
      text-decoration: none;
      cursor: pointer;
      font-weight: 500;
    }
    .login-footer a:hover { text-decoration: underline; }
    .login-msg {
      padding: 8px 12px;
      border-radius: 6px;
      font-size: 0.82rem;
      margin-bottom: 14px;
    }
    .login-msg.error { background: #fef2f2; color: var(--red); border: 1px solid #fecaca; }
    .login-msg.success { background: #f0fdf4; color: var(--green); border: 1px solid #bbf7d0; }
    .login-msg.info { background: #eff6ff; color: #2563eb; border: 1px solid #bfdbfe; }
    .app-wrapper { display: none; }
    .app-wrapper.visible { display: block; }

    /* ── Dashboard ───────────────────────────────────────────────────── */
    .dashboard { display: none; min-height: 100vh; background: var(--bg); }
    .dashboard.visible { display: block; }
    .dash-header {
      background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
      color: #fff; padding: 20px 32px;
      display: flex; align-items: center; justify-content: space-between;
    }
    .dash-header h1 { font-size: 1.35rem; font-weight: 700; }
    .dash-header .user-area { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
    .dash-header .user-area span { font-size: 0.8rem; color: #94a3b8; }
    .dash-content {
      max-width: 1100px; margin: 0 auto; padding: 32px 24px;
    }

    /* Stats Row */
    .dash-stats {
      display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
      gap: 14px; margin-bottom: 28px;
    }
    .dash-stat-card {
      background: var(--card); border: 1px solid var(--border); border-radius: 12px;
      padding: 18px 20px; text-align: center;
    }
    .dash-stat-card .stat-value { font-size: 1.6rem; font-weight: 800; color: var(--primary); }
    .dash-stat-card .stat-label { font-size: 0.75rem; color: var(--muted); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.03em; }

    .dash-welcome {
      margin-bottom: 24px; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px;
    }
    .dash-welcome h2 { font-size: 1.5rem; font-weight: 700; color: var(--text); }
    .dash-welcome p { font-size: 0.85rem; color: var(--muted); margin-top: 4px; }
    .dash-actions {
      display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
    }

    /* Workflow filter tabs */
    .wf-filter-bar {
      display: flex; gap: 6px; margin-bottom: 20px; flex-wrap: wrap;
    }
    .wf-filter-btn {
      padding: 7px 16px; border: 1px solid var(--border); border-radius: 20px;
      background: var(--card); color: var(--muted); font-size: 0.78rem; font-weight: 500;
      cursor: pointer; transition: all 0.15s;
    }
    .wf-filter-btn:hover { border-color: var(--primary); color: var(--primary); }
    .wf-filter-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
    .wf-filter-btn .wf-count {
      display: inline-block; background: rgba(255,255,255,0.2); border-radius: 10px;
      padding: 1px 7px; font-size: 0.7rem; margin-left: 4px;
    }
    .wf-filter-btn.active .wf-count { background: rgba(255,255,255,0.3); }
    .wf-filter-btn:not(.active) .wf-count { background: var(--border); color: var(--text); }

    .project-grid {
      display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
      gap: 16px;
    }
    .project-card {
      background: var(--card); border: 1px solid var(--border); border-radius: 14px;
      padding: 22px; cursor: pointer; transition: all 0.2s;
      display: flex; flex-direction: column; gap: 6px; position: relative;
    }
    .project-card:hover { border-color: var(--primary); box-shadow: 0 8px 24px rgba(37,99,235,0.08); transform: translateY(-2px); }
    .project-card .pc-top { display: flex; align-items: flex-start; justify-content: space-between; }
    .project-card .pc-name { font-size: 1.05rem; font-weight: 700; color: var(--text); line-height: 1.3; }
    .project-card .pc-client { font-size: 0.78rem; color: var(--muted); margin-top: 2px; }
    .project-card .pc-meta { font-size: 0.75rem; color: var(--muted); display: flex; gap: 12px; align-items: center; margin-top: 6px; }
    .project-card .pc-meta span { display: flex; align-items: center; gap: 3px; }
    .project-card .pc-footer { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }

    /* Workflow status badge */
    .wf-badge {
      display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px;
      border-radius: 12px; font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.02em;
    }
    .wf-badge.draft { background: #f1f5f9; color: #64748b; }
    .wf-badge.in-review { background: #fef3c7; color: #92400e; }
    .wf-badge.manager-approved { background: #dbeafe; color: #1e40af; }
    .wf-badge.partner-approved { background: #dcfce7; color: #166534; }
    .wf-badge.returned { background: #fef2f2; color: #dc2626; }
    .wf-badge-dot { width: 6px; height: 6px; border-radius: 50%; }
    .wf-badge.draft .wf-badge-dot { background: #94a3b8; }
    .wf-badge.in-review .wf-badge-dot { background: #f59e0b; }
    .wf-badge.manager-approved .wf-badge-dot { background: #3b82f6; }
    .wf-badge.partner-approved .wf-badge-dot { background: #22c55e; }
    .wf-badge.returned .wf-badge-dot { background: #ef4444; }

    /* Assigned avatar */
    .pc-assignee { font-size: 0.72rem; color: var(--muted); }
    .pc-comment-count { font-size: 0.72rem; color: var(--muted); display: flex; align-items: center; gap: 3px; }

    .pc-menu-wrap { position: absolute; top: 14px; right: 14px; }
    .pc-dots { background: none; border: none; cursor: pointer; font-size: 1.2rem; color: var(--muted); padding: 4px 8px; border-radius: 6px; line-height: 1; }
    .pc-dots:hover { background: var(--border); color: var(--text); }
    .pc-dropdown { display: none; position: absolute; right: 0; top: 100%; background: var(--card); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,0.12); min-width: 160px; z-index: 20; overflow: hidden; }
    .pc-dropdown.open { display: block; }
    .pc-dropdown button { display: block; width: 100%; text-align: left; padding: 10px 14px; border: none; background: none; cursor: pointer; font-size: 0.82rem; color: var(--text); }
    .pc-dropdown button:hover { background: var(--bg); }
    .pc-dropdown button.danger { color: #dc2626; }
    .pc-dropdown button.danger:hover { background: #fef2f2; }

    .empty-state {
      text-align: center; padding: 60px 20px; color: var(--muted);
    }
    .empty-state p { font-size: 0.9rem; margin-bottom: 16px; }

    /* Comments panel */
    .comments-panel {
      background: var(--card); border: 1px solid var(--border); border-radius: 14px;
      padding: 24px; margin-top: 20px;
    }
    .comment-item {
      padding: 12px 0; border-bottom: 1px solid var(--border);
    }
    .comment-item:last-child { border-bottom: none; }
    .comment-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
    .comment-author { font-size: 0.82rem; font-weight: 600; color: var(--text); }
    .comment-time { font-size: 0.72rem; color: var(--muted); }
    .comment-body { font-size: 0.85rem; color: var(--text); line-height: 1.5; }
    .comment-input-wrap { display: flex; gap: 8px; margin-top: 12px; }
    .comment-input-wrap textarea { flex: 1; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 0.85rem; resize: vertical; min-height: 40px; background: var(--bg); color: var(--text); font-family: inherit; }

    /* Workflow modal */
    .wf-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
    .wf-actions .btn { font-size: 0.8rem; }
    .wf-assign-row { display: flex; gap: 8px; align-items: center; margin-top: 10px; }
    .wf-assign-row input { flex: 1; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 0.85rem; background: var(--bg); color: var(--text); }
    .wf-timeline { margin-top: 16px; padding-left: 16px; border-left: 2px solid var(--border); }
    .wf-timeline-item { padding: 8px 0 8px 12px; font-size: 0.8rem; color: var(--muted); position: relative; }
    .wf-timeline-item::before { content: ''; position: absolute; left: -21px; top: 14px; width: 8px; height: 8px; border-radius: 50%; background: var(--border); }
    .wf-timeline-item.active::before { background: var(--primary); }
    .wf-timeline-item .wf-tl-action { font-weight: 600; color: var(--text); }
    .wf-timeline-item .wf-tl-time { font-size: 0.72rem; }

    /* ── Project bar ─────────────────────────────────────────────────── */
    .project-bar {
      background: #0f172a;
      padding: 8px 32px;
      display: flex;
      align-items: center;
      gap: 12px;
      border-bottom: 1px solid #1e293b;
    }
    .project-bar select {
      padding: 5px 10px;
      border: 1px solid #334155;
      border-radius: 5px;
      background: #1e293b;
      color: #e2e8f0;
      font-size: 0.82rem;
      outline: none;
      min-width: 180px;
    }
    .project-bar select:focus { border-color: var(--primary); }
    .project-bar .proj-btn {
      padding: 4px 10px;
      border: 1px solid #334155;
      border-radius: 5px;
      background: transparent;
      color: #94a3b8;
      font-size: 0.75rem;
      cursor: pointer;
      white-space: nowrap;
    }
    .project-bar .proj-btn:hover { background: #1e293b; color: #e2e8f0; }
    .project-bar .proj-btn.danger { border-color: #7f1d1d; color: #fca5a5; }
    .project-bar .proj-btn.danger:hover { background: #7f1d1d; color: #fff; }
    .project-bar .proj-label { font-size: 0.75rem; color: #64748b; text-transform: uppercase; letter-spacing: 0.05em; }

    /* ── Import period toggle ────────────────────────────────────────── */
    .period-toggle {
      display: flex; gap: 0; margin-bottom: 14px; border: 1px solid var(--border); border-radius: 7px; overflow: hidden; width: fit-content;
    }
    .period-toggle label {
      padding: 7px 16px; font-size: 0.82rem; cursor: pointer; color: var(--muted); transition: all 0.15s; user-select: none;
    }
    .period-toggle input { display: none; }
    .period-toggle input:checked + label { background: var(--primary); color: #fff; }

    /* ── Multi-period statement columns ──────────────────────────────── */
    .stmt-table.multi-period .col-label { width: 36%; }
    .stmt-table.multi-period .col-current { text-align: right; width: 16%; }
    .stmt-table.multi-period .col-prior { text-align: right; width: 16%; }

    /* ── Company Research panel ────────────────────────────────────── */
    .research-btn {
      padding: 8px 14px; border-radius: 7px; border: 1px solid var(--primary);
      background: #eff6ff; color: var(--primary); font-size: 0.82rem; font-weight: 600;
      cursor: pointer; transition: all 0.15s; white-space: nowrap;
      display: inline-flex; align-items: center; gap: 5px;
    }
    .research-btn:hover { background: var(--primary); color: #fff; }
    .research-btn:disabled { opacity: 0.5; cursor: not-allowed; }
    .research-btn .spinner {
      display: inline-block; width: 14px; height: 14px; border: 2px solid currentColor;
      border-top-color: transparent; border-radius: 50%; animation: spin 0.6s linear infinite;
    }
    @keyframes spin { to { transform: rotate(360deg); } }

    .research-panel {
      margin-top: 16px; border: 1px solid var(--border); border-radius: 10px;
      overflow: hidden; display: none;
    }
    .research-panel.open { display: block; }
    .research-panel-header {
      background: #f8fafc; padding: 14px 18px; border-bottom: 1px solid var(--border);
      display: flex; align-items: center; justify-content: space-between;
    }
    .research-panel-header h3 { font-size: 0.9rem; font-weight: 600; color: var(--text); }
    .research-panel-body { padding: 18px; }
    .research-finding {
      display: flex; align-items: flex-start; gap: 12px; padding: 10px 0;
      border-bottom: 1px solid #f1f5f9; font-size: 0.85rem;
    }
    .research-finding:last-child { border-bottom: none; }
    .research-finding .rf-label {
      flex-shrink: 0; width: 140px; font-weight: 600; color: var(--muted);
      font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em; padding-top: 2px;
    }
    .research-finding .rf-value { flex: 1; color: var(--text); line-height: 1.5; }
    .research-finding .rf-value.muted { color: var(--muted); font-style: italic; }
    .research-finding .rf-apply {
      flex-shrink: 0; font-size: 0.72rem; padding: 3px 8px; border-radius: 4px;
      border: 1px solid var(--primary); background: transparent; color: var(--primary);
      cursor: pointer; white-space: nowrap; transition: all 0.15s;
    }
    .research-finding .rf-apply:hover { background: var(--primary); color: #fff; }
    .research-finding .rf-apply.applied {
      background: #f0fdf4; border-color: var(--green); color: var(--green);
      cursor: default; pointer-events: none;
    }
    .research-sources {
      margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border);
      font-size: 0.75rem; color: var(--muted); line-height: 1.6;
    }
    .research-sources a { color: var(--primary); text-decoration: none; }
    .research-sources a:hover { text-decoration: underline; }
    .research-apply-all {
      margin-top: 14px; display: flex; gap: 10px;
    }

    body.dark-mode .research-panel { border-color: #334155; }
    body.dark-mode .research-panel-header { background: #0f172a; border-color: #334155; }
    body.dark-mode .research-finding { border-color: #334155; }
    body.dark-mode .research-btn { background: #1e3a5f; border-color: #2563eb; }

    /* ── GAAP reference badges on checklist ─────────────────────────── */
    .checklist-label { display: block; }
    .asc-ref {
      display: inline-block; margin-top: 4px; font-size: 0.7rem; font-weight: 600;
      color: #2563eb; background: #eff6ff; border: 1px solid #bfdbfe;
      border-radius: 4px; padding: 2px 7px; text-decoration: none;
      cursor: pointer; position: relative; letter-spacing: 0.01em;
      transition: all 0.15s;
    }
    .asc-ref:hover {
      background: #dbeafe; border-color: #93c5fd; color: #1d4ed8;
    }
    .asc-ref::after {
      content: attr(title); position: absolute; left: 0; top: calc(100% + 6px);
      background: #1e293b; color: #e2e8f0; font-size: 0.75rem; font-weight: 400;
      padding: 10px 14px; border-radius: 8px; width: 340px; line-height: 1.5;
      box-shadow: 0 8px 24px rgba(0,0,0,0.25); z-index: 100;
      opacity: 0; visibility: hidden; transition: opacity 0.2s, visibility 0.2s;
      pointer-events: none; white-space: normal; letter-spacing: normal;
    }
    .asc-ref:hover::after { opacity: 1; visibility: visible; }
    /* Ensure tooltip doesn't overflow right edge */
    .asc-ref { position: relative; }
    body.dark-mode .asc-ref { background: #1e3a5f; border-color: #2563eb; color: #93c5fd; }
    body.dark-mode .asc-ref:hover { background: #1e40af; color: #bfdbfe; }
    body.dark-mode .asc-ref::after { background: #0f172a; border: 1px solid #334155; }

    /* ── #1 Mobile tabs horizontal scroll ────────────────────────────── */
    .tabs {
      overflow-x: auto;
      -webkit-overflow-scrolling: touch;
      scrollbar-width: none;
    }
    .tabs::-webkit-scrollbar { display: none; }
    .tab { white-space: nowrap; flex-shrink: 0; }

    /* ── #2 Responsive header / hamburger ─────────────────────────────── */
    .header-actions { display: flex; align-items: center; gap: 14px; }
    .hamburger-btn {
      display: none; background: none; border: 1px solid #475569; color: #94a3b8;
      border-radius: 6px; padding: 6px 9px; cursor: pointer; font-size: 1.1rem; line-height: 1;
    }
    .hamburger-btn:hover { background: #1e293b; color: #e2e8f0; }
    .mobile-menu {
      display: none; position: absolute; right: 16px; top: 100%; background: #1e293b;
      border: 1px solid #334155; border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,0.3);
      z-index: 50; overflow: hidden; min-width: 180px;
    }
    .mobile-menu.open { display: block; }
    .mobile-menu button {
      display: block; width: 100%; text-align: left; padding: 12px 16px; border: none;
      background: none; color: #cbd5e1; font-size: 0.85rem; cursor: pointer;
    }
    .mobile-menu button:hover { background: #334155; color: #fff; }
    .mobile-menu button.danger { color: #fca5a5; }
    .mobile-menu button.danger:hover { background: #7f1d1d; color: #fff; }

    @media (max-width: 768px) {
      .hamburger-btn { display: block; }
      .header-actions .btn, .header-actions span#user-display { display: none; }
      header { position: relative; }
    }

    /* ── #3 Tab completion badges ─────────────────────────────────────── */
    .tab { position: relative; }
    .tab-badge {
      position: absolute; top: 4px; right: 4px; width: 8px; height: 8px;
      border-radius: 50%; background: var(--green); display: none;
    }
    .tab-badge.active { display: block; }
    .tab-badge.partial { background: #f59e0b; }

    /* ── #6 Enhanced tab active state ─────────────────────────────────── */
    .tab.active {
      color: #fff; border-bottom-color: var(--primary);
      background: rgba(37, 99, 235, 0.12); border-radius: 6px 6px 0 0;
    }

    /* ── #8 Auto-save indicator ──────────────────────────────────────── */
    .save-indicator {
      font-size: 0.72rem; color: #64748b; transition: all 0.3s ease;
      display: inline-flex; align-items: center; gap: 4px;
    }
    .save-indicator.saved { color: #16a34a; }
    .save-indicator.saving { color: #f59e0b; }

    /* ── #9 Accordion note groups ────────────────────────────────────── */
    .note-group-title {
      cursor: pointer; display: flex; align-items: center; justify-content: space-between;
      padding: 8px 0; transition: color 0.15s; user-select: none;
    }
    .note-group-title:hover { color: var(--primary-dark); }
    .note-group-title::after {
      content: '▾'; font-size: 0.75rem; color: var(--muted); transition: transform 0.2s;
    }
    .note-group.collapsed .note-group-title::after { transform: rotate(-90deg); }
    .note-group-body { transition: max-height 0.3s ease, opacity 0.2s ease; overflow: hidden; }
    .note-group.collapsed .note-group-body { max-height: 0 !important; opacity: 0; padding: 0; }

    /* ── #12 Persistent statement toolbar ─────────────────────────────── */
    .stmt-toolbar {
      position: sticky; top: 0; z-index: 10; background: var(--bg);
      padding: 10px 0; display: flex; gap: 10px; justify-content: flex-end;
      border-bottom: 1px solid var(--border); margin-bottom: 16px;
    }

    /* ── #14 Empty state for statement tabs ───────────────────────────── */
    .stmt-empty {
      text-align: center; padding: 60px 20px; color: var(--muted);
    }
    .stmt-empty .stmt-empty-icon { font-size: 2.5rem; margin-bottom: 12px; opacity: 0.4; }
    .stmt-empty p { font-size: 0.92rem; margin-bottom: 16px; line-height: 1.6; }
    .stmt-empty .btn { margin-top: 4px; }

    /* ── #7 Sticky generate bar on Import tab ────────────────────────── */
    .generate-bar {
      position: sticky; bottom: 0; background: var(--card); border-top: 1px solid var(--border);
      padding: 14px 22px; display: flex; gap: 10px; align-items: center;
      margin: 0 -20px -28px; border-radius: 0 0 10px 10px;
      box-shadow: 0 -4px 12px rgba(0,0,0,0.05); z-index: 5;
    }
    .generate-bar .btn-primary { padding: 10px 24px; font-size: 0.95rem; }

    /* ── #5 Dark mode ────────────────────────────────────────────────── */
    .dark-toggle {
      background: none; border: 1px solid #475569; color: #94a3b8; border-radius: 6px;
      padding: 5px 9px; cursor: pointer; font-size: 0.85rem; line-height: 1;
    }
    .dark-toggle:hover { background: #1e293b; color: #e2e8f0; }

    body.dark-mode {
      --bg: #0f172a; --card: #1e293b; --border: #334155;
      --text: #e2e8f0; --muted: #94a3b8; --primary: #3b82f6;
      --primary-dark: #2563eb; --header-bg: #0f172a;
    }
    body.dark-mode header { background: linear-gradient(135deg, #0f172a 0%, #020617 100%); }
    body.dark-mode .tabs { background: #0f172a; border-color: #1e293b; }
    body.dark-mode .project-bar { background: #020617; }
    body.dark-mode .import-zone { background: #1e293b; border-color: #475569; }
    body.dark-mode .import-zone:hover, body.dark-mode .import-zone.drag-over { background: #1e3a5f; border-color: var(--primary); }
    body.dark-mode .import-zone.has-file { background: #1e3a5f; }
    body.dark-mode .meta-row input, body.dark-mode .note-field input[type="text"],
    body.dark-mode .note-field textarea, body.dark-mode .note-field select {
      background: #0f172a; color: #e2e8f0; border-color: #475569;
    }
    body.dark-mode .stmt-table .item td { border-color: #334155; }
    body.dark-mode .stmt-table .section-header td { color: #94a3b8; }
    body.dark-mode .stmt-table .subtotal td { border-color: #475569; }
    body.dark-mode .stmt-table .grand-total td { border-color: #e2e8f0; color: #f1f5f9; }
    body.dark-mode .login-screen { background: linear-gradient(135deg, #020617 0%, #0f172a 50%, #020617 100%); }
    body.dark-mode .login-card, body.dark-mode .modal-box { background: rgba(30, 41, 59, 0.97); }
    body.dark-mode .login-field input { background: #0f172a; color: #e2e8f0; border-color: #475569; }
    body.dark-mode .dashboard { background: #0f172a; }
    body.dark-mode .project-card { background: #1e293b; border-color: #334155; }
    body.dark-mode .project-card:hover { border-color: var(--primary); }
    body.dark-mode .dash-stat-card { background: #1e293b; border-color: #334155; }
    body.dark-mode .wf-filter-btn { background: #1e293b; border-color: #334155; color: #94a3b8; }
    body.dark-mode .wf-badge.draft { background: #334155; color: #94a3b8; }
    body.dark-mode .wf-badge.in-review { background: #422006; color: #fbbf24; }
    body.dark-mode .wf-badge.manager-approved { background: #1e3a5f; color: #60a5fa; }
    body.dark-mode .wf-badge.partner-approved { background: #052e16; color: #4ade80; }
    body.dark-mode .wf-badge.returned { background: #450a0a; color: #f87171; }
    body.dark-mode .comments-panel { background: #1e293b; border-color: #334155; }
    body.dark-mode .comment-input-wrap textarea { background: #0f172a; border-color: #334155; color: #e2e8f0; }
    body.dark-mode .suggestion-card { background: #1e3a5f; border-color: #2563eb; }
    body.dark-mode .suggestion-card .sg-title { color: #93c5fd; }
    body.dark-mode .suggestion-card .sg-text { color: #bfdbfe; }
    body.dark-mode .note-table th { background: #0f172a; }
    body.dark-mode .note-table td { border-color: #334155; }
    body.dark-mode .notes-output p { color: #cbd5e1; }
    body.dark-mode .generate-bar { background: #1e293b; border-color: #475569; box-shadow: 0 -4px 12px rgba(0,0,0,0.2); }
    body.dark-mode .stmt-toolbar { background: #0f172a; border-color: #334155; }
    body.dark-mode .pc-dropdown { background: #1e293b; border-color: #475569; }
    body.dark-mode .pc-dropdown button { color: #cbd5e1; }
    body.dark-mode .pc-dropdown button:hover { background: #334155; }

    /* ── Collapsible card sections ──────────────────────────────────── */
    .card-collapsible .card-title {
      cursor: pointer; display: flex; align-items: center; justify-content: space-between; user-select: none;
    }
    .card-collapsible .card-title::after {
      content: '\25BE'; font-size: 0.75rem; color: var(--muted); transition: transform 0.2s;
    }
    .card-collapsible.collapsed .card-title::after { transform: rotate(-90deg); }
    .card-collapsible .card-body { transition: max-height 0.3s ease, opacity 0.2s ease; overflow: hidden; }
    .card-collapsible.collapsed .card-body { max-height: 0 !important; opacity: 0; padding: 0; overflow: hidden; }

    /* ── Trial Balance Editor ────────────────────────────────────────── */
    .tb-editor-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
    .tb-editor-table th {
      text-align: left; padding: 8px 10px; font-size: 0.78rem; font-weight: 600;
      color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em;
      border-bottom: 2px solid var(--border); background: var(--bg);
    }
    .tb-editor-table th:nth-child(3), .tb-editor-table td:nth-child(3) { text-align: right; }
    .tb-editor-table td { padding: 6px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
    .tb-editor-table .tb-section-header td {
      font-weight: 700; font-size: 0.8rem; text-transform: uppercase;
      letter-spacing: 0.04em; color: var(--primary); background: var(--bg);
      padding-top: 14px;
    }
    .tb-editor-table .tb-total td { font-weight: 600; border-top: 1px solid var(--border); }
    .tb-editor-table .tb-grand-total td { font-weight: 700; border-top: 2px solid var(--text); border-bottom: 2px solid var(--text); }
    .tb-editor-table input[type="number"] {
      width: 120px; padding: 4px 8px; border: 1px solid var(--border); border-radius: 5px;
      font-size: 0.85rem; text-align: right; outline: none; font-family: inherit;
    }
    .tb-editor-table input[type="number"]:focus { border-color: var(--primary); }
    .tb-editor-table input[type="text"] {
      width: 100%; padding: 4px 8px; border: 1px solid var(--border); border-radius: 5px;
      font-size: 0.85rem; outline: none; font-family: inherit;
    }
    .tb-editor-table input[type="text"]:focus { border-color: var(--primary); }
    .tb-add-row { background: var(--bg); }
    .tb-add-row td { padding: 8px 10px; }
    .tb-add-row select {
      padding: 4px 8px; border: 1px solid var(--border); border-radius: 5px;
      font-size: 0.82rem; background: var(--card); color: var(--text); outline: none;
    }
    .tb-add-row select:focus { border-color: var(--primary); }
    .tb-summary { display: flex; gap: 24px; margin-top: 14px; font-size: 0.85rem; color: var(--muted); }
    .tb-summary strong { color: var(--text); }

    /* ── Prior Year Balances ─────────────────────────────────────────── */
    .py-grid {
      display: grid; grid-template-columns: 1fr 1fr; gap: 12px 20px;
    }
    @media (max-width: 600px) { .py-grid { grid-template-columns: 1fr; } }
    .py-grid label {
      font-size: 0.82rem; font-weight: 500; color: var(--text); display: block; margin-bottom: 3px;
    }
    .py-grid input[type="number"] {
      width: 100%; padding: 7px 10px; border: 1px solid var(--border); border-radius: 6px;
      font-size: 0.875rem; outline: none; font-family: inherit;
    }
    .py-grid input[type="number"]:focus { border-color: var(--primary); }
    .py-section-title {
      grid-column: 1 / -1; font-size: 0.78rem; font-weight: 700; text-transform: uppercase;
      letter-spacing: 0.05em; color: var(--primary); margin-top: 8px; padding-bottom: 4px;
      border-bottom: 1px solid var(--border);
    }
    .py-warning {
      background: #fefce8; border: 1px solid #fde68a; color: #92400e; border-radius: 7px;
      padding: 10px 14px; font-size: 0.82rem; margin-bottom: 14px; line-height: 1.5;
    }

    /* ── Adjusting Journal Entries ───────────────────────────────────── */
    .aje-entry {
      border: 1px solid var(--border); border-radius: 8px; padding: 14px; margin-bottom: 14px;
      background: var(--card);
    }
    .aje-entry.out-of-balance { border-color: var(--red); background: #fef2f2; }
    .aje-header {
      display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 10px;
    }
    .aje-header .aje-num {
      font-weight: 700; font-size: 0.85rem; color: var(--primary); min-width: 60px;
    }
    .aje-header input[type="date"], .aje-header input[type="text"] {
      padding: 5px 8px; border: 1px solid var(--border); border-radius: 5px;
      font-size: 0.82rem; outline: none; font-family: inherit;
    }
    .aje-header input:focus { border-color: var(--primary); }
    .aje-lines-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; margin-bottom: 8px; }
    .aje-lines-table th {
      text-align: left; padding: 5px 8px; font-size: 0.75rem; font-weight: 600;
      color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em;
      border-bottom: 1px solid var(--border);
    }
    .aje-lines-table th:nth-child(4), .aje-lines-table th:nth-child(5),
    .aje-lines-table td:nth-child(4), .aje-lines-table td:nth-child(5) { text-align: right; width: 110px; }
    .aje-lines-table td { padding: 4px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
    .aje-lines-table input[type="text"], .aje-lines-table input[type="number"] {
      width: 100%; padding: 4px 6px; border: 1px solid var(--border); border-radius: 4px;
      font-size: 0.82rem; outline: none; font-family: inherit;
    }
    .aje-lines-table input[type="number"] { text-align: right; }
    .aje-lines-table input:focus { border-color: var(--primary); }
    .aje-lines-table select {
      width: 100%; padding: 4px 6px; border: 1px solid var(--border); border-radius: 4px;
      font-size: 0.82rem; background: var(--card); color: var(--text); outline: none;
    }
    .aje-lines-table select:focus { border-color: var(--primary); }
    .aje-totals {
      display: flex; gap: 20px; font-size: 0.82rem; color: var(--muted); padding: 4px 8px;
    }
    .aje-totals .balanced { color: var(--green); font-weight: 600; }
    .aje-totals .unbalanced { color: var(--red); font-weight: 600; }
    .aje-footer { display: flex; gap: 8px; align-items: center; }
    .aje-summary {
      margin-top: 14px; padding: 10px 14px; background: var(--bg); border-radius: 7px;
      font-size: 0.85rem; color: var(--muted);
    }
    .aje-summary strong { color: var(--text); }
    .aje-posted-badge {
      display: inline-block; padding: 2px 8px; border-radius: 4px;
      font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
    }
    .aje-posted-badge.posted { background: #f0fdf4; color: var(--green); border: 1px solid #bbf7d0; }
    .aje-posted-badge.unposted { background: #fef2f2; color: var(--red); border: 1px solid #fecaca; }

    body.dark-mode .tb-editor-table th { background: #0f172a; }
    body.dark-mode .tb-editor-table td { border-color: #334155; }
    body.dark-mode .tb-editor-table input[type="number"],
    body.dark-mode .tb-editor-table input[type="text"],
    body.dark-mode .tb-add-row select {
      background: #0f172a; color: #e2e8f0; border-color: #475569;
    }
    body.dark-mode .tb-add-row { background: #0f172a; }
    body.dark-mode .py-grid input[type="number"] { background: #0f172a; color: #e2e8f0; border-color: #475569; }
    body.dark-mode .py-warning { background: #422006; border-color: #92400e; color: #fde68a; }
    body.dark-mode .aje-entry { background: #1e293b; border-color: #334155; }
    body.dark-mode .aje-entry.out-of-balance { background: #450a0a; border-color: #dc2626; }
    body.dark-mode .aje-header input { background: #0f172a; color: #e2e8f0; border-color: #475569; }
    body.dark-mode .aje-lines-table th { border-color: #475569; }
    body.dark-mode .aje-lines-table td { border-color: #334155; }
    body.dark-mode .aje-lines-table input,
    body.dark-mode .aje-lines-table select {
      background: #0f172a; color: #e2e8f0; border-color: #475569;
    }
    body.dark-mode .aje-summary { background: #0f172a; }

    /* ── Financial Ratios Card ────────────────────────────────────── */
    .ratios-card { margin-top: 20px; }
    .ratios-card .card-title { cursor: pointer; display: flex; align-items: center; justify-content: space-between; user-select: none; }
    .ratios-card .card-title::after { content: '\25B8'; font-size: 0.8rem; color: var(--muted); transition: transform 0.2s; }
    .ratios-card.expanded .card-title::after { transform: rotate(90deg); }
    .ratios-grid { display: none; }
    .ratios-card.expanded .ratios-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; padding-top: 14px; }
    .ratio-item { padding: 12px; background: var(--bg); border-radius: 8px; }
    .ratio-name { font-size: 0.78rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }
    .ratio-value { font-size: 1.2rem; font-weight: 700; margin-top: 4px; }
    .ratio-prior { font-size: 0.78rem; color: var(--muted); margin-top: 2px; }
    .ratio-change { font-size: 0.75rem; font-weight: 600; }
    .ratio-change.favorable { color: var(--green); }
    .ratio-change.unfavorable { color: var(--red); }
    @media (max-width: 700px) {
      .ratios-card.expanded .ratios-grid { grid-template-columns: 1fr; }
    }
    body.dark-mode .ratio-item { background: #0f172a; }

    /* ── Ratios Dashboard ──────────────────────────────────────── */
    .ratios-scorecard-row {
      display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px;
    }
    .ratios-scorecard {
      background: var(--card); border: 1px solid var(--border); border-radius: 10px;
      padding: 18px; text-align: center; position: relative; overflow: hidden;
    }
    .ratios-scorecard .sc-label {
      font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em;
      color: var(--muted); margin-bottom: 6px;
    }
    .ratios-scorecard .sc-value {
      font-size: 1.6rem; font-weight: 800; color: var(--text);
    }
    .ratios-scorecard .sc-sub {
      font-size: 0.75rem; color: var(--muted); margin-top: 4px;
    }
    .ratios-scorecard .sc-badge {
      display: inline-block; font-size: 0.7rem; font-weight: 600; padding: 2px 8px;
      border-radius: 10px; margin-top: 6px;
    }
    .ratios-scorecard .sc-badge.good { background: #dcfce7; color: #166534; }
    .ratios-scorecard .sc-badge.warning { background: #fef9c3; color: #854d0e; }
    .ratios-scorecard .sc-badge.concern { background: #fee2e2; color: #991b1b; }
    body.dark-mode .ratios-scorecard .sc-badge.good { background: #14532d; color: #86efac; }
    body.dark-mode .ratios-scorecard .sc-badge.warning { background: #713f12; color: #fde047; }
    body.dark-mode .ratios-scorecard .sc-badge.concern { background: #7f1d1d; color: #fca5a5; }
    body.dark-mode .ratios-scorecard { background: #1e293b; border-color: #334155; }

    .ratios-section-card { margin-bottom: 16px; }
    .ratios-section-card.collapsed .ratios-section-body { display: none; }
    .ratios-section-title {
      cursor: pointer; display: flex; align-items: center; gap: 12px; user-select: none;
    }
    .ratios-section-title::before {
      content: '\25BE'; font-size: 0.75rem; color: var(--muted); transition: transform 0.2s;
    }
    .ratios-section-card.collapsed .ratios-section-title::before { transform: rotate(-90deg); }
    .ratios-section-hint {
      font-size: 0.75rem; font-weight: 400; color: var(--muted); text-transform: none;
      letter-spacing: normal;
    }

    .ratios-section-body {
      display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
      gap: 14px; padding-top: 16px;
    }
    .ratio-detail {
      background: var(--bg); border-radius: 8px; padding: 16px;
    }
    .ratio-detail .rd-header { display: flex; justify-content: space-between; align-items: flex-start; }
    .ratio-detail .rd-name { font-size: 0.8rem; font-weight: 600; color: var(--text); }
    .ratio-detail .rd-value { font-size: 1.35rem; font-weight: 800; color: var(--text); margin: 6px 0; }
    .ratio-detail .rd-formula { font-size: 0.7rem; color: var(--muted); font-style: italic; margin-bottom: 6px; }
    .ratio-detail .rd-bar { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; margin: 8px 0 4px; }
    .ratio-detail .rd-bar-fill { height: 100%; border-radius: 3px; transition: width 0.4s ease; }
    .ratio-detail .rd-bar-fill.good { background: var(--green); }
    .ratio-detail .rd-bar-fill.warning { background: #eab308; }
    .ratio-detail .rd-bar-fill.concern { background: var(--red); }
    .ratio-detail .rd-prior { font-size: 0.72rem; color: var(--muted); }
    .ratio-detail .rd-change { font-size: 0.72rem; font-weight: 600; }
    .ratio-detail .rd-change.favorable { color: var(--green); }
    .ratio-detail .rd-change.unfavorable { color: var(--red); }
    body.dark-mode .ratio-detail { background: #0f172a; }

    .insight-item {
      display: flex; align-items: flex-start; gap: 10px; padding: 10px 0;
      border-bottom: 1px solid var(--border); font-size: 0.85rem; line-height: 1.5;
    }
    .insight-item:last-child { border-bottom: none; }
    .insight-icon { font-size: 1rem; flex-shrink: 0; margin-top: 2px; }
    .insight-text strong { color: var(--text); }

    @media (max-width: 700px) {
      .ratios-scorecard-row { grid-template-columns: repeat(2, 1fr); }
      .ratios-section-body { grid-template-columns: 1fr; }
    }


    @media print {
      body { background: #fff !important; color: #000 !important; }
      header, .tabs, .actions, .print-actions, .card, .stmt-toolbar, .generate-bar { display: none !important; }
      .page { display: block !important; }
      .statement { border: none; padding: 0; }
      .page.active .statement { display: block; }
    }
