      *,
      *::before,
      *::after {
        box-sizing: border-box;
        margin: 0;
        padding: 0;
      }
      :root {
        --grass: #cfaa7d;
        --thicket: #b9af5f;
        --blossom: #8f944c;
        --berry: #cc7c72;
        --sky: #8096ad;
        --accent: #8096ad;
        --accent-light: #edf1f6;
        --accent-text: #3a4f63;
        --bg: #f5f3ef;
        --surface: #ffffff;
        --surface2: #f0ede7;
        --surface3: #e7e3db;
        --border: #ddd8cf;
        --border2: #c9c4ba;
        --text: #1e1c18;
        --text2: #6a665e;
        --text3: #9e9a93;
        --green: #5f8a6e;
        --red: #b85c52;
        --blue: #8096ad;
        --amber: #cfaa7d;
        --pink: #cc7c72;
        --teal: #b9af5f;
        --sidebar: 220px;
        --font-mono: 'DM Sans', sans-serif;
        --font-mono-features: 'zero' 1;
      }
      body {
        font-family: 'DM Sans', sans-serif;
        background: var(--bg);
        color: var(--text);
        font-size: 14px;
        line-height: 1.5;
        display: flex;
        min-height: 100vh;
      }

      /* SIDEBAR */
      #sidebar {
        width: var(--sidebar);
        background: var(--surface);
        border-right: 1px solid var(--border);
        display: flex;
        flex-direction: column;
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        overflow-y: auto;
        z-index: 200;
      }
      .sidebar-logo {
        padding: 18px 16px 12px;
        font-family: 'DM Mono', monospace;
        font-size: 14px;
        font-weight: 500;
        color: var(--accent);
        letter-spacing: -0.02em;
        border-bottom: 1px solid var(--border);
      }
      .sidebar-logo span {
        color: var(--text3);
        font-weight: 300;
      }
      .sidebar-section {
        padding: 10px 10px 4px;
        font-size: 10px;
        font-weight: 500;
        letter-spacing: 0.08em;
        text-transform: uppercase;
        color: var(--text3);
        font-family: 'DM Mono', monospace;
      }
      .nav-item {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 7px 12px;
        cursor: pointer;
        border-radius: 6px;
        margin: 1px 6px;
        font-size: 13px;
        color: var(--text2);
        transition:
          background 0.12s,
          color 0.12s;
        position: relative;
      }
      .nav-item:hover {
        background: var(--surface2);
        color: var(--text);
      }
      .nav-item.active {
        background: var(--accent-light);
        color: var(--accent-text);
        font-weight: 500;
      }
      .nav-dot {
        width: 8px;
        height: 8px;
        border-radius: 50%;
        flex-shrink: 0;
      }
      .sidebar-bottom {
        margin-top: auto;
        padding: 12px;
        border-top: 1px solid var(--border);
      }

      /* MAIN */
      #main {
        margin-left: var(--sidebar);
        flex: 1;
        min-height: 100vh;
      }
      .topbar {
        background: var(--surface);
        border-bottom: 1px solid var(--border);
        padding: 14px 24px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        position: sticky;
        top: 0;
        z-index: 100;
      }
      .topbar-title {
        font-size: 16px;
        font-weight: 500;
        color: var(--text);
      }
      .topbar-actions {
        display: flex;
        gap: 8px;
        align-items: center;
      }
      .page {
        display: none;
        padding: 24px;
      }
      .page.active {
        display: block;
      }

      /* BUTTONS */
      .btn {
        font-family: 'DM Sans', sans-serif;
        font-size: 13px;
        font-weight: 500;
        padding: 7px 14px;
        border-radius: 6px;
        border: 1px solid var(--border2);
        background: var(--surface);
        color: var(--text);
        cursor: pointer;
        transition:
          background 0.12s,
          transform 0.1s;
      }
      .btn:hover {
        background: var(--surface2);
      }
      .btn:active {
        transform: scale(0.97);
      }
      .btn.primary {
        background: var(--accent);
        border-color: var(--accent);
        color: #fff;
      }
      .btn.primary:hover {
        opacity: 0.88;
      }
      .btn.danger {
        background: #fdf0ed;
        border-color: #f0c4b4;
        color: #8b3010;
      }
      .btn.danger:hover {
        background: #f9e0d9;
      }
      .btn.sm {
        font-size: 12px;
        padding: 4px 10px;
      }

      /* FORMS */
      input,
      select,
      textarea {
        font-family: 'DM Sans', sans-serif;
        font-size: 13px;
        padding: 7px 10px;
        border: 1px solid var(--border);
        border-radius: 6px;
        background: var(--surface);
        color: var(--text);
        outline: none;
        transition: border-color 0.15s;
        width: 100%;
      }
      input:focus,
      select:focus,
      textarea:focus {
        border-color: var(--accent);
      }
      label {
        font-size: 12px;
        font-weight: 500;
        color: var(--text2);
        margin-bottom: 3px;
        display: block;
      }
      .field {
        display: flex;
        flex-direction: column;
        gap: 3px;
        margin-bottom: 12px;
      }
      .form-row {
        display: grid;
        gap: 10px;
        grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
      }

      /* CARDS */
      .card {
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: 10px;
        padding: 16px 18px;
        margin-bottom: 14px;
      }
      .card-title {
        font-size: 11px;
        font-weight: 500;
        letter-spacing: 0.07em;
        text-transform: uppercase;
        color: var(--text3);
        font-family: 'DM Mono', monospace;
        margin-bottom: 12px;
      }

      /* METRICS */
      .metrics {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
        gap: 10px;
        margin-bottom: 16px;
      }
      .metric {
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: 10px;
        padding: 13px 15px;
      }
      .metric-label {
        font-size: 10px;
        font-weight: 500;
        letter-spacing: 0.07em;
        text-transform: uppercase;
        color: var(--text3);
        font-family: 'DM Mono', monospace;
        margin-bottom: 5px;
      }
      .metric-value {
        font-size: 18px;
        font-weight: 600;
        font-family: var(--font-mono);
        letter-spacing: -0.02em;
        font-feature-settings: var(--font-mono-features, 'normal');
      }
      .metric-sub {
        font-size: 11px;
        color: var(--text3);
        margin-top: 2px;
      }
      .metric-value.pos {
        color: var(--green);
      }
      .metric-value.neg {
        color: var(--red);
      }

      /* TABLE */
      .table-wrap {
        overflow-x: auto;
        border-radius: 8px;
        border: 1px solid var(--border);
      }
      table {
        width: 100%;
        border-collapse: collapse;
        font-size: 13px;
      }
      th {
        background: var(--surface2);
        padding: 8px 12px;
        text-align: left;
        font-weight: 500;
        font-size: 11px;
        letter-spacing: 0.05em;
        text-transform: uppercase;
        color: var(--text3);
        border-bottom: 1px solid var(--border);
        white-space: nowrap;
      }
      td {
        padding: 8px 12px;
        border-bottom: 1px solid var(--border);
        color: var(--text);
        vertical-align: middle;
      }
      tr:last-child td {
        border-bottom: none;
      }
      tr:hover td {
        background: var(--surface2);
      }
      .flag-row td {
        background: color-mix(in srgb, var(--surface) 85%, var(--red) 15%) !important;
      }
      .uncat-row td {
        background: color-mix(in srgb, var(--surface) 80%, #d4a200 20%) !important;
      }
      /* ── Inline add row ───────────────────────────────── */
      .inline-add-row td {
        padding: 5px 4px;
        vertical-align: middle;
        background: var(--surface2);
      }
      .inline-add-row input[type='text'],
      .inline-add-row input[type='number'],
      .inline-add-row input[type='date'],
      .inline-add-row select {
        width: 100%;
        font-size: 12px;
        padding: 4px 6px;
        border: 1px solid var(--border);
        border-radius: 5px;
        background: var(--surface);
        color: var(--text);
        font-family: var(--font-ui);
      }
      .inline-add-row input[type='number'] {
        width: 90px;
        font-family: var(--font-mono);
      }
      .inline-add-row input[type='text']#iat-date-0,
      .inline-add-row input[type='text'][id^='iat-date-'] {
        width: 62px;
      }
      .inline-add-row input:focus,
      .inline-add-row select:focus {
        outline: none;
        border-color: var(--accent);
      }

      .amount-cell {
        font-family: var(--font-mono);
        font-size: 13px;
        text-align: right;
        white-space: nowrap;
        font-feature-settings: var(--font-mono-features, 'normal');
      }
      .badge {
        display: inline-block;
        padding: 2px 8px;
        border-radius: 4px;
        font-size: 11px;
        font-weight: 500;
      }
      .badge.elaine {
        background: #edf1f6;
        color: #3a4f63;
      }
      .badge.jinho {
        background: #f5f0e8;
        color: #5a4020;
      }

      /* FLOATING ADD BUTTON */
      #globalAddPicker {
        position: fixed;
        bottom: 86px;
        right: 28px;
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: 10px;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
        z-index: 299;
        overflow: hidden;
        display: none;
        flex-direction: column;
        min-width: 200px;
      }
      #globalAddPicker.open {
        display: flex;
      }
      #globalAddPicker button {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 13px 16px;
        font-size: 13px;
        font-weight: 500;
        font-family: var(--font-ui);
        background: none;
        border: none;
        color: var(--text);
        cursor: pointer;
        text-align: left;
        transition: background 0.1s;
      }
      #globalAddPicker button span {
        font-size: 16px;
        color: var(--accent);
        width: 20px;
        text-align: center;
      }
      #globalAddPicker button:hover {
        background: var(--surface2);
      }
      #globalAddPicker button + button {
        border-top: 1px solid var(--border);
      }
      #globalAddBtn {
        position: fixed;
        bottom: 28px;
        right: 28px;
        width: 48px;
        height: 48px;
        border-radius: 50%;
        background: var(--sky);
        border: none;
        color: #fff;
        font-size: 24px;
        cursor: pointer;
        z-index: 300;
        box-shadow: 0 3px 12px rgba(128, 150, 173, 0.45);
        display: flex;
        align-items: center;
        justify-content: center;
        transition:
          transform 0.15s,
          opacity 0.15s;
        line-height: 1;
      }
      #globalAddBtn:hover {
        transform: scale(1.08);
        opacity: 0.92;
      }
      #globalAddBtn:active {
        transform: scale(0.95);
      }

      /* MODAL */
      .modal-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.35);
        z-index: 1000;
        display: none;
        align-items: center;
        justify-content: center;
      }
      .modal-overlay.open {
        display: flex;
      }
      .modal {
        background: var(--surface);
        border-radius: 12px;
        padding: 22px 24px;
        width: 100%;
        max-width: 480px;
        max-height: 90vh;
        overflow-y: auto;
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
      }
      .modal-title {
        font-size: 15px;
        font-weight: 500;
        margin-bottom: 16px;
        color: var(--text);
      }
      .modal-actions {
        display: flex;
        gap: 8px;
        justify-content: flex-end;
        margin-top: 16px;
      }

      /* TABS */
      .tab-bar {
        display: flex;
        gap: 2px;
        border-bottom: 1px solid var(--border);
        margin-bottom: 18px;
      }
      .tab-btn {
        padding: 7px 14px;
        border: none;
        background: none;
        cursor: pointer;
        font-size: 13px;
        color: var(--text2);
        border-bottom: 2px solid transparent;
        margin-bottom: -1px;
        font-family: 'DM Sans', sans-serif;
        transition: color 0.12s;
      }
      .tab-btn.active {
        color: var(--accent);
        border-bottom-color: var(--accent);
        font-weight: 500;
      }
      .tab-pane {
        display: none;
      }
      .tab-pane.active {
        display: block;
      }

      /* PROGRESS BAR */
      .pbar {
        height: 5px;
        background: var(--surface3);
        border-radius: 3px;
        overflow: hidden;
        margin-top: 5px;
      }
      .pbar-fill {
        height: 100%;
        border-radius: 3px;
        transition: width 0.5s ease;
      }

      /* PLANNED vs ACTUAL TABLE */
      .pva-table {
        width: 100%;
        border-collapse: collapse;
        font-size: 13px;
      }
      .pva-table th {
        padding: 7px 10px;
        text-align: right;
        font-weight: 500;
        font-size: 11px;
        color: var(--text3);
        letter-spacing: 0.05em;
        background: var(--surface2);
        border-bottom: 1px solid var(--border);
      }
      .pva-table th:first-child {
        text-align: left;
      }
      .pva-table td {
        padding: 7px 10px;
        border-bottom: 1px solid var(--border);
        text-align: right;
        font-family: 'DM Mono', monospace;
        font-size: 12px;
      }
      .pva-table td:first-child {
        text-align: left;
        font-family: 'DM Sans', sans-serif;
        font-weight: 500;
        font-size: 13px;
      }
      .pva-table tr:last-child td {
        border-bottom: none;
      }
      .pva-table .pos {
        color: var(--green);
      }
      .pva-table .neg {
        color: var(--red);
      }
      .pva-table .total-row td {
        font-weight: 600;
        background: var(--surface2);
      }

      /* COLOR PICKER */
      .color-swatch {
        width: 22px;
        height: 22px;
        border-radius: 50%;
        cursor: pointer;
        border: 2px solid transparent;
        transition: transform 0.1s;
      }
      .color-swatch.selected {
        border-color: var(--text);
        transform: scale(1.15);
      }
      .swatches {
        display: flex;
        gap: 6px;
        flex-wrap: wrap;
      }

      /* YEARLY */
      .year-table-wrap {
        overflow-x: auto;
      }
      .year-table {
        border-collapse: collapse;
        font-size: 12px;
        width: 100%;
      }
      .year-table th,
      .year-table td {
        padding: 6px 10px;
        border: 1px solid var(--border);
        white-space: nowrap;
      }
      .year-table th {
        background: var(--surface2);
        font-weight: 500;
        font-size: 11px;
        color: var(--text2);
      }
      .year-table td {
        font-family: 'DM Mono', monospace;
        text-align: right;
      }
      .year-table td:first-child,
      .year-table th:first-child {
        text-align: left;
        font-family: 'DM Sans', sans-serif;
        position: sticky;
        left: 0;
        background: var(--surface2);
        z-index: 1;
      }
      .year-table .total-row td {
        background: color-mix(in srgb, var(--surface2) 70%, var(--text) 8%);
        font-weight: 600;
      }
      .year-table .total-row td:first-child {
        background: color-mix(in srgb, var(--surface2) 70%, var(--text) 8%);
      }

      .empty-state {
        text-align: center;
        padding: 3rem;
        color: var(--text3);
        font-size: 13px;
      }
      .section-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        margin-bottom: 12px;
      }
      .section-header h3 {
        font-size: 14px;
        font-weight: 500;
      }

      /* BUDGET COLLAPSIBLE */
      .budget-summary-row:hover td {
        background: var(--surface2);
        cursor: pointer;
      }
      .budget-summary-row td {
        transition: background 0.1s;
      }
      .budget-detail-row td {
        padding: 0 !important;
      }
      .budget-detail-row:hover td {
        background: inherit;
      }

      @keyframes spin {
        to {
          transform: rotate(360deg);
        }
      }
