.font-headline { font-family: 'Manrope', sans-serif; }
    .material-symbols-outlined { font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24; display: inline-block; vertical-align: middle; }
    .gradient-brand { background: linear-gradient(135deg, #0058be 0%, #2170e4 100%); }
    :root {
      --bg: #f4f5f9;
      --surface: #ffffff;
      --surface2: #f8fafc;
      --border: rgba(168, 85, 247, 0.08);
      --text: #0f172a;
      --muted: #64748b;

      --accent-green: #10b981;
      --accent-red: #ef4444;
      --accent-blue: #3b82f6;
      --accent-amber: #f59e0b;
      --accent-purple: #a855f7;

      --glass-shadow: 0 10px 30px -5px rgba(168, 85, 247, 0.08), 0 4px 10px -4px rgba(59, 130, 246, 0.05);
      --glass-backdrop: blur(12px);
      --radius: 24px;
      --font-body: 'Inter', sans-serif;
    }

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

    body {
      background: var(--bg);
      color: var(--text);
      font-family: var(--font-body);
      font-size: 15px;
      min-height: 100vh;
      overflow-x: hidden;
    }
    
    @keyframes fadeUp {
      from { opacity: 0; transform: translateY(20px); }
      to { opacity: 1; transform: translateY(0); }
    }
    
    .fade-up {
      animation: fadeUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
      opacity: 0;
    }
    .delay-100 { animation-delay: 100ms; }
    .delay-200 { animation-delay: 200ms; }
    .delay-300 { animation-delay: 300ms; }
    .delay-400 { animation-delay: 400ms; }
    .delay-500 { animation-delay: 500ms; }

    .section:not(#sec-dashboard) {
      background: var(--bg);
      border-radius: var(--radius);
      padding: 24px;
      margin: 24px auto;
      max-width: 1200px;
    }

    /* ── Auth screen ── */
    .auth-screen {
      min-height: 100vh;
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 20px;
      overflow-x: hidden;
    }

    /* Fix: ensure auth container does not overflow or clip */
    #authScreen > div[class*="relative z-10"] {
      width: 100%;
      max-width: 480px;
    }

    /* Fix: All form inputs in auth card fill full width reliably */
    #form-login input,
    #form-register input {
      width: 100% !important;
      min-width: 0 !important;
      box-sizing: border-box !important;
    }

    /* Fix: browser autofill background override */
    input:-webkit-autofill,
    input:-webkit-autofill:hover,
    input:-webkit-autofill:focus,
    input:-webkit-autofill:active {
      -webkit-box-shadow: 0 0 0 1000px #f8fafc inset !important;
      -webkit-text-fill-color: #0f172a !important;
      transition: background-color 5000s ease-in-out 0s;
    }

    /* Fix: auth form blocks should be full-width flex columns — do NOT force display here,
       form visibility is toggled via inline styles by switchTab() */
    #form-login,
    #form-register {
      flex-direction: column;
      width: 100%;
    }

    /* Fix: space-y-5 inputs take full width */
    #form-login .space-y-5 > div,
    #form-register .space-y-5 > div {
      width: 100%;
    }

    /* Fix: the auth card itself */
    #authScreen .bg-surface-container-lowest {
      width: 100%;
    }

    .auth-box {
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 24px;
      backdrop-filter: var(--glass-backdrop);
      -webkit-backdrop-filter: var(--glass-backdrop);
      box-shadow: var(--glass-shadow);
      padding: 48px 40px;
      width: 100%;
      max-width: 420px;
    }

    .auth-logo {
      font-size: 32px;
      font-weight: 700;
      background: linear-gradient(135deg, #34d399, #60a5fa);
      -webkit-background-clip: text;
      background-clip: text;
      -webkit-text-fill-color: transparent;
      margin-bottom: 4px;
      letter-spacing: -1px;
    }

    .auth-logo span {
      font-size: 14px;
      color: var(--muted);
      display: block;
      margin-top: 0px;
      font-weight: 400;
      -webkit-text-fill-color: var(--muted);
    }

    .auth-tabs {
      display: flex;
      gap: 0;
      margin: 32px 0 24px;
      background: rgba(0, 0, 0, 0.4);
      border-radius: 12px;
      padding: 4px;
      border: 1px solid var(--border);
    }

    .auth-tab {
      flex: 1;
      padding: 10px;
      text-align: center;
      font-size: 14px;
      font-weight: 500;
      border-radius: 8px;
      cursor: pointer;
      color: var(--muted);
      border: none;
      background: none;
      font-family: var(--font-body);
      transition: all .2s ease;
    }

    .auth-tab.active {
      background: rgba(255, 255, 255, 0.1);
      color: var(--text);
      box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    }

    .auth-form {
      display: flex;
      flex-direction: column;
      gap: 16px;
    }

    .auth-form input,
    select {
      background: rgba(0, 0, 0, 0.5);
      border: 1px solid var(--border);
      border-radius: 12px;
      padding: 14px 16px;
      color: var(--text);
      font-family: var(--font-body);
      font-size: 15px;
      outline: none;
      transition: border-color .2s ease, box-shadow .2s ease;
      width: 100%;
    }

    .auth-form input:focus {
      border-color: var(--accent-green);
      box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.1);
    }

    .auth-submit {
      background: linear-gradient(135deg, var(--accent-green), #10b981);
      color: #000;
      border: none;
      border-radius: 12px;
      padding: 14px;
      font-size: 15px;
      font-weight: 600;
      cursor: pointer;
      font-family: var(--font-body);
      transition: all .2s ease;
      margin-top: 8px;
      box-shadow: 0 4px 14px rgba(52, 211, 153, 0.3);
    }

    .auth-submit:hover {
      transform: translateY(-1px);
      box-shadow: 0 6px 20px rgba(52, 211, 153, 0.4);
    }

    .auth-submit:active {
      transform: translateY(1px);
    }

    .auth-submit:disabled {
      opacity: 0.6;
      cursor: not-allowed;
      transform: none;
    }

    .auth-error {
      background: rgba(248, 113, 113, 0.1);
      border: 1px solid rgba(248, 113, 113, 0.2);
      border-radius: 12px;
      padding: 12px 16px;
      font-size: 14px;
      color: var(--accent-red);
      margin-bottom: 20px;
    }

    /* ── App shell ── */
    .app-shell {
      display: none;
    }

    .app-shell.visible {
      display: flex;
      min-height: 100vh;
    }

    .sidebar {
      width: 260px;
      flex-shrink: 0;
      background: var(--surface);
      border-right: 1px solid var(--border);
      backdrop-filter: var(--glass-backdrop);
      -webkit-backdrop-filter: var(--glass-backdrop);
      display: flex;
      flex-direction: column;
      padding: 32px 24px;
      position: sticky;
      top: 0;
      height: 100vh;
    }

    .logo {
      font-size: 24px;
      font-weight: 700;
      background: linear-gradient(135deg, #34d399, #60a5fa);
      -webkit-background-clip: text;
      background-clip: text;
      -webkit-text-fill-color: transparent;
      letter-spacing: -0.5px;
    }

    .logo-user {
      font-size: 13px;
      color: var(--muted);
      margin-top: 4px;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    .nav {
      margin-top: 40px;
      display: flex;
      flex-direction: column;
      gap: 8px;
    }

    .nav-btn {
      display: flex;
      align-items: center;
      gap: 14px;
      padding: 12px 16px;
      border-radius: 12px;
      background: transparent;
      border: none;
      color: var(--muted);
      font-family: var(--font-body);
      font-size: 14px;
      font-weight: 500;
      cursor: pointer;
      text-align: left;
      transition: all .2s ease;
    }

    .nav-btn:hover {
      background: rgba(255, 255, 255, 0.05);
      color: var(--text);
    }

    .nav-btn.active {
      background: rgba(255, 255, 255, 0.1);
      color: var(--text);
      font-weight: 600;
      box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    }

    .logout-btn {
      margin-top: auto;
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 10px;
      padding: 12px;
      border-radius: 12px;
      background: transparent;
      border: 1px solid var(--border);
      color: var(--muted);
      font-family: var(--font-body);
      font-size: 14px;
      font-weight: 500;
      cursor: pointer;
      transition: all .2s ease;
      margin-bottom: 20px;
    }

    .logout-btn:hover {
      border-color: var(--accent-red);
      color: var(--accent-red);
      background: rgba(248, 113, 113, 0.05);
    }

    .month-selector {
      background: rgba(0, 0, 0, 0.4);
      border: 1px solid var(--border);
      border-radius: 12px;
      padding: 14px 16px;
    }

    .month-selector label {
      font-size: 11px;
      color: var(--muted);
      text-transform: uppercase;
      letter-spacing: .1em;
      display: block;
      margin-bottom: 8px;
      font-weight: 600;
    }

    .month-selector select {
      width: 100%;
      background: transparent;
      border: none;
      color: var(--text);
      font-family: var(--font-body);
      font-size: 14px;
      cursor: pointer;
      outline: none;
      padding: 0;
      font-weight: 500;
    }

    .month-selector select option {
      background: var(--surface);
      color: var(--text);
    }

    /* Main Area */
    .main {
      flex: 1;
      overflow-y: auto;
      padding: 48px;
      max-width: 1100px;
      margin: 0 auto;
      width: 100%;
    }

    .section {
      display: none;
      animation: fadeIn 0.3s ease;
    }

    .section.active {
      display: block;
    }

    @keyframes fadeIn {
      from {
        opacity: 0;
        transform: translateY(10px);
      }

      to {
        opacity: 1;
        transform: translateY(0);
      }
    }

    .page-header {
      margin-bottom: 40px;
    }

    .page-header h1 {
      font-size: 32px;
      font-weight: 700;
      letter-spacing: -1px;
      margin-bottom: 8px;
    }

    .page-header p {
      color: var(--muted);
      font-size: 15px;
    }

    /* Cards */
    .cards-row {
      display: grid;
      grid-template-columns: repeat(4, 1fr);
      gap: 20px;
      margin-bottom: 32px;
    }

    .card {
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: var(--radius);
      padding: 24px;
      position: relative;
      overflow: hidden;
      backdrop-filter: var(--glass-backdrop);
      -webkit-backdrop-filter: var(--glass-backdrop);
      box-shadow: var(--glass-shadow);
      transition: transform 0.2s ease, box-shadow 0.2s ease;
    }

    .card:hover {
      transform: translateY(-4px);
      box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
    }

    .card::before {
      content: '';
      position: absolute;
      top: 0;
      left: 0;
      right: 0;
      height: 3px;
      background: var(--card-accent, var(--border));
    }

    .card.green {
      --card-accent: var(--accent-green);
    }

    .card.red {
      --card-accent: var(--accent-red);
    }

    .card.blue {
      --card-accent: var(--accent-blue);
    }

    .card.purple {
      --card-accent: var(--accent-purple);
    }

    .card-label {
      font-size: 12px;
      color: var(--muted);
      font-weight: 600;
      text-transform: uppercase;
      letter-spacing: .05em;
      margin-bottom: 12px;
    }

    .card-value {
      font-size: 28px;
      font-weight: 700;
      letter-spacing: -0.5px;
    }

    .card.green .card-value {
      color: var(--accent-green);
    }

    .card.red .card-value {
      color: var(--accent-red);
    }

    .card.blue .card-value {
      color: var(--accent-blue);
    }

    .card.purple .card-value {
      color: var(--accent-purple);
    }

    .card-sub {
      font-size: 13px;
      color: var(--muted);
      margin-top: 8px;
      font-weight: 500;
    }

    /* Form Cards */
    .form-card {
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: var(--radius);
      padding: 28px;
      margin-bottom: 28px;
      backdrop-filter: var(--glass-backdrop);
      -webkit-backdrop-filter: var(--glass-backdrop);
    }

    .form-title {
      font-size: 16px;
      font-weight: 600;
      margin-bottom: 20px;
      letter-spacing: -0.3px;
    }

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

    .form-row.three {
      grid-template-columns: 1fr 1fr 1fr;
    }

    .form-group {
      display: flex;
      flex-direction: column;
      gap: 8px;
    }

    .form-group label {
      font-size: 13px;
      color: var(--muted);
      font-weight: 500;
    }

    .form-group input,
    .form-group select {
      background: var(--surface2);
      border: 1px solid var(--border);
      border-radius: 10px;
      padding: 12px 14px;
      color: var(--text);
      font-family: var(--font-body);
      font-size: 14px;
      outline: none;
      transition: border-color .2s ease;
    }

    .form-group input:focus,
    .form-group select:focus {
      border-color: var(--accent-green);
    }

    .form-group select option {
      background: var(--surface);
      color: var(--text);
    }

    .btn {
      padding: 12px 24px;
      border-radius: 10px;
      border: none;
      font-family: var(--font-body);
      font-size: 14px;
      font-weight: 600;
      cursor: pointer;
      transition: all .2s ease;
    }

    .btn-primary {
      background: var(--accent-green);
      color: #000;
      box-shadow: 0 4px 14px rgba(52, 211, 153, 0.2);
    }

    .btn-primary:hover {
      transform: translateY(-1px);
      box-shadow: 0 6px 20px rgba(52, 211, 153, 0.3);
    }

    .btn-primary:disabled {
      opacity: 0.6;
      cursor: not-allowed;
    }

    .btn-danger {
      background: transparent;
      border: 1px solid var(--border);
      color: var(--accent-red);
      padding: 6px 12px;
      font-size: 12px;
      border-radius: 8px;
    }

    .btn-danger:hover {
      background: rgba(248, 113, 113, 0.1);
      border-color: var(--accent-red);
    }

    /* Tables */
    .table-card {
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: var(--radius);
      overflow: hidden;
      margin-bottom: 28px;
      backdrop-filter: var(--glass-backdrop);
      -webkit-backdrop-filter: var(--glass-backdrop);
    }

    .table-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 20px 24px;
      border-bottom: 1px solid var(--border);
    }

    .table-header h3 {
      font-size: 16px;
      font-weight: 600;
    }

    .table-responsive {
      overflow-x: auto;
    }

    table {
      width: 100%;
      border-collapse: collapse;
      min-width: 600px;
    }

    th {
      padding: 16px 24px;
      text-align: left;
      font-size: 12px;
      color: var(--muted);
      text-transform: uppercase;
      letter-spacing: .05em;
      font-weight: 600;
      border-bottom: 1px solid var(--border);
      background: rgba(0, 0, 0, 0.2);
    }

    td {
      padding: 16px 24px;
      font-size: 14px;
      border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    }

    tr:last-child td {
      border-bottom: none;
    }

    tr:hover td {
      background: rgba(255, 255, 255, 0.03);
    }

    .badge {
      display: inline-block;
      padding: 4px 10px;
      border-radius: 20px;
      font-size: 12px;
      font-weight: 600;
    }

    .badge-food {
      background: rgba(251, 191, 36, .15);
      color: var(--accent-amber);
    }

    .badge-transport {
      background: rgba(96, 165, 250, .15);
      color: var(--accent-blue);
    }

    .badge-bills {
      background: rgba(192, 132, 252, .15);
      color: var(--accent-purple);
    }

    .badge-shopping {
      background: rgba(248, 113, 113, .15);
      color: var(--accent-red);
    }

    .badge-health {
      background: rgba(52, 211, 153, .15);
      color: var(--accent-green);
    }

    .badge-other {
      background: rgba(161, 161, 170, .15);
      color: var(--muted);
    }

    .badge-auto {
      background: rgba(251, 191, 36, .15);
      color: var(--accent-amber);
    }

    .amount-neg {
      color: var(--accent-red);
      font-weight: 600;
      font-family: monospace;
      font-size: 15px;
    }

    .amount-pos {
      color: var(--accent-green);
      font-weight: 600;
      font-family: monospace;
      font-size: 15px;
    }

    .empty-state {
      text-align: center;
      padding: 60px 40px;
      color: var(--muted);
      font-size: 15px;
    }

    /* Progress Bars */
    .progress-wrap {
      margin-bottom: 18px;
    }

    .progress-label {
      display: flex;
      justify-content: space-between;
      font-size: 13px;
      margin-bottom: 8px;
      font-weight: 500;
    }

    .progress-bar-bg {
      background: rgba(255, 255, 255, 0.1);
      border-radius: 99px;
      height: 8px;
      overflow: hidden;
    }

    .progress-bar {
      height: 100%;
      border-radius: 99px;
      transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    }

    /* Misc */
    .savings-ring {
      display: flex;
      align-items: center;
      gap: 32px;
      margin-bottom: 32px;
      flex-wrap: wrap;
    }

    .ring-wrap {
      position: relative;
      width: 120px;
      height: 120px;
      flex-shrink: 0;
    }

    .ring-wrap svg {
      transform: rotate(-90deg);
      width: 100%;
      height: 100%;
    }

    .ring-center {
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      text-align: center;
    }

    .ring-center .pct {
      font-size: 24px;
      font-weight: 700;
      color: var(--accent-green);
      letter-spacing: -0.5px;
    }

    .ring-center .lbl {
      font-size: 11px;
      color: var(--muted);
      font-weight: 500;
      text-transform: uppercase;
    }

    .alert {
      background: rgba(251, 191, 36, 0.1);
      border: 1px solid rgba(251, 191, 36, 0.3);
      border-radius: 12px;
      padding: 16px 20px;
      font-size: 14px;
      color: var(--accent-amber);
      margin-bottom: 24px;
      font-weight: 500;
    }

    /* ── Mobile Layout Overrides ── */
    .mobile-header,
    .mobile-nav {
      display: none;
    }

    @media(max-width: 768px) {
      .app-shell.visible {
        flex-direction: column;
      }

      .sidebar {
        display: none;
      }

      /* Hide sidebar for standard view */

      .main {
        padding: 24px 20px 100px;
        max-width: 100%;
      }

      .mobile-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 24px;
        padding-bottom: 20px;
        border-bottom: 1px solid var(--border);
      }

      .mobile-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: rgba(15, 15, 15, 0.85);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border-top: 1px solid var(--border);
        padding: 12px 16px 20px;
        justify-content: space-around;
        z-index: 100;
        box-shadow: 0 -4px 30px rgba(0, 0, 0, 0.5);
      }

      .mobile-nav-btn {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 4px;
        background: none;
        border: none;
        color: var(--muted);
        cursor: pointer;
        font-size: 10px;
        font-weight: 600;
        transition: color 0.2s;
        font-family: var(--font-body);
      }

      .mobile-nav-btn .icon {
        font-size: 22px;
        margin-bottom: 2px;
      }

      .mobile-nav-btn.active {
        color: var(--accent-green);
      }

      .cards-row {
        grid-template-columns: 1fr;
        gap: 16px;
      }

      .form-row,
      .form-row.three {
        grid-template-columns: 1fr;
        gap: 16px;
      }

      /* Make tables responsive */
      th,
      td {
        padding: 12px 16px;
      }

      .report-grid {
        grid-template-columns: 1fr;
      }

      /* Mobile: shift AI button above bottom nav */
      .ai-fab {
        bottom: 84px !important;
        right: 16px !important;
      }

      /* Mobile: AI drawer becomes a bottom sheet */
      .ai-drawer {
        top: auto !important;
        bottom: 0 !important;
        right: 0 !important;
        left: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        height: 90vh !important;
        border-radius: 20px 20px 0 0 !important;
        transform: translateY(100%) !important;
      }

      .ai-drawer.ai-drawer-open {
        transform: translateY(0) !important;
      }

      /* Upload modal responsive */
      .upload-modal-inner {
        width: min(95vw, 680px) !important;
        max-height: 90vh !important;
      }

      /* Dashboard button group stacks on mobile */
      .dash-action-group {
        flex-wrap: wrap !important;
      }

      .dash-action-group button {
        flex: 1 !important;
        min-width: 130px !important;
      }
    }

    /* ════════════════════════════════════════════════
       AI FLOATING BUTTON
    ════════════════════════════════════════════════ */
    /* ════════════════════════════════════════════════
       AI FLOATING BUTTON (ORB)
    ════════════════════════════════════════════════ */
    .ai-fab {
      position: fixed;
      bottom: 28px;
      right: 28px;
      width: 68px; /* Desktop size */
      height: 68px;
      border-radius: 50%;
      background: radial-gradient(circle at 30% 30%, #e0e7ff 0%, #a855f7 30%, #4f46e5 80%, #312e81 100%);
      background-size: 200% 200%;
      box-shadow: inset 0 -4px 10px rgba(0,0,0,0.3), 0 0 15px rgba(168, 85, 247, 0.4), 0 8px 24px rgba(59, 130, 246, 0.4);
      border: 1px solid rgba(255,255,255,0.2);
      cursor: pointer;
      display: none; /* shown via JS after auth */
      align-items: center;
      justify-content: center;
      z-index: 999;
      color: #fff;
      /* Layer 1: Breathing Glow */
      box-shadow: 0 0 15px rgba(168, 85, 247, 0.4), 0 8px 24px rgba(59, 130, 246, 0.4);
      animation: aiBreathingGlow 3.5s ease-in-out infinite;
      transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
    }
    
    @media (max-width: 768px) {
      .ai-fab {
        width: 60px;
        height: 60px;
        bottom: 80px; /* Stay above mobile nav */
        right: 16px;
      }
    }

    /* Layer 2: Rotating Gradient Ring */
    .ai-fab::before {
      content: '';
      position: absolute;
      inset: -3px;
      border-radius: 50%;
      padding: 3px; /* border thickness */
      background: conic-gradient(from 0deg, transparent 0%, #a855f7 40%, transparent 80%);
      -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
      -webkit-mask-composite: xor;
      mask-composite: exclude;
      animation: aiRotateRing 4s linear infinite;
      opacity: 0.8;
      transition: animation-duration 0.3s ease;
    }

    /* Layer 3: Orbiting Particles */
    .ai-fab-particle {
      position: absolute;
      width: 100%;
      height: 100%;
      border-radius: 50%;
      pointer-events: none;
    }
    .ai-fab-particle::after {
      content: '';
      position: absolute;
      border-radius: 50%;
      background: #e0e7ff;
      box-shadow: 0 0 8px 2px rgba(255,255,255,0.7), 0 0 12px 4px rgba(168,85,247,0.5);
      transition: box-shadow 0.3s ease;
    }

    .particle-1 { animation: aiRotateParticle1 6s linear infinite; }
    .particle-1::after { top: -2px; left: 50%; transform: translateX(-50%); width: 6px; height: 6px; }

    .particle-2 { animation: aiRotateParticle2 8s linear infinite reverse; }
    .particle-2::after { right: -2px; top: 50%; transform: translateY(-50%); width: 4px; height: 4px; }

    .particle-3 { animation: aiRotateParticle3 10s linear infinite; }
    .particle-3::after { bottom: -1px; left: 30%; width: 5px; height: 5px; }

    /* Layer 4: Icon Motion */
    .ai-fab-icon {
      font-size: 32px !important;
      position: relative;
      z-index: 2;
      animation: aiIconSubtleFloat 4s ease-in-out infinite;
      transition: transform 0.3s ease;
    }
    @media (max-width: 768px) {
       .ai-fab-icon { font-size: 28px !important; }
    }

    /* ── Hover State ── */
    .ai-fab:hover {
      transform: scale(1.08);
      box-shadow: inset 0 -4px 10px rgba(0,0,0,0.3), 0 0 25px rgba(168, 85, 247, 0.6), 0 12px 32px rgba(59, 130, 246, 0.5);
    }
    .ai-fab:hover::before {
      animation-duration: 2s; /* Speed up ring */
    }
    .ai-fab:hover .ai-fab-particle::after {
      box-shadow: 0 0 12px 4px rgba(255,255,255,0.9), 0 0 16px 6px rgba(168,85,247,0.8);
    }
    .ai-fab:hover .ai-fab-icon {
      transform: scale(1.1) translateY(-2px);
    }

    /* ── Click/Press Animation (Triggered by JS Class) ── */
    .ai-fab.clicking {
      animation: aiClickPress 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    }

    /* ── Drawer Open State ── */
    .ai-fab.is-open {
      transform: scale(1);
      box-shadow: 0 4px 12px rgba(0,0,0,0.1);
      animation: none; /* reduce ambient */
      background: var(--surface);
      color: var(--on-surface);
      border: 1px solid var(--border);
    }
    .ai-fab.is-open::before,
    .ai-fab.is-open .ai-fab-particle {
      display: none;
    }
    .ai-fab.is-open .ai-fab-icon {
      animation: none;
      color: var(--slate-600);
      transform: none;
      font-size: 24px !important;
    }

    /* ── Attention State ── */
    .ai-fab.attention {
      animation: aiAttentionPulse 2s ease-in-out infinite;
    }
    .ai-fab.attention::after {
      content: '';
      position: absolute;
      top: 2px;
      right: 6px;
      width: 12px;
      height: 12px;
      background: #ef4444;
      border-radius: 50%;
      border: 2px solid var(--surface);
      z-index: 3;
    }

    /* ── Animations ── */
    @keyframes aiBreathingGlow {
      0%, 100% { box-shadow: 0 0 15px rgba(168,85,247,0.4), 0 8px 24px rgba(59,130,246,0.3); }
      50% { box-shadow: 0 0 25px rgba(168,85,247,0.7), 0 12px 32px rgba(59,130,246,0.6); }
    }
    @keyframes aiRotateRing {
      0% { transform: rotate(0deg); }
      100% { transform: rotate(360deg); }
    }
    @keyframes aiRotateParticle1 { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
    @keyframes aiRotateParticle2 { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
    @keyframes aiRotateParticle3 { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
    
    @keyframes aiInnerGradient {
      0% { background-position: 0% 50%; }
      50% { background-position: 100% 50%; }
      100% { background-position: 0% 50%; }
    }
    @keyframes aiIconSubtleFloat {
      0%, 100% { transform: translateY(0) scale(1); }
      50% { transform: translateY(-3px) scale(1.03); }
    }
    @keyframes aiClickPress {
      0% { transform: scale(1); }
      40% { transform: scale(0.92); }
      75% { transform: scale(1.07); }
      100% { transform: scale(1); }
    }
    @keyframes aiAttentionPulse {
      0%, 100% { box-shadow: 0 0 15px rgba(168,85,247,0.4), 0 0 0 0 rgba(239, 68, 68, 0.4); transform: scale(1); }
      50% { box-shadow: 0 0 25px rgba(168,85,247,0.7), 0 0 0 10px rgba(239, 68, 68, 0); transform: scale(1.03); }
    }

    /* Accessibility / Reduced Motion */
    @media (prefers-reduced-motion: reduce) {
      .ai-fab,
      .ai-fab::before,
      .ai-fab-particle,
      .ai-fab-icon {
        animation: none !important;
        transition: none !important;
      }
      .ai-fab-particle { display: none; }
    }

    /* ════════════════════════════════════════════════
       AI DRAWER
    ════════════════════════════════════════════════ */
    .ai-drawer {
      position: fixed;
      top: 0;
      right: 0;
      bottom: 0;
      width: 420px;
      max-width: 100vw;
      background: #fff;
      border-left: 1px solid rgba(15,23,42,0.08);
      box-shadow: -8px 0 48px rgba(0,0,0,0.12);
      z-index: 1001;
      display: flex;
      flex-direction: column;
      transform: translateX(100%);
      transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .ai-drawer.ai-drawer-open {
      transform: translateX(0);
    }

    .ai-drawer-overlay {
      position: fixed;
      inset: 0;
      background: rgba(15, 23, 42, 0.35);
      z-index: 1000;
      opacity: 0;
      pointer-events: none;
      transition: opacity 0.3s ease;
      backdrop-filter: blur(2px);
    }

    .ai-drawer-overlay.ai-overlay-open {
      opacity: 1;
      pointer-events: all;
    }

    .ai-drawer-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 20px 20px 16px;
      border-bottom: 1px solid rgba(15,23,42,0.08);
      flex-shrink: 0;
    }

    .ai-drawer-messages {
      flex: 1;
      overflow-y: auto;
      padding: 16px;
      display: flex;
      flex-direction: column;
      gap: 12px;
      scroll-behavior: smooth;
    }

    .ai-drawer-messages::-webkit-scrollbar {
      width: 4px;
    }
    .ai-drawer-messages::-webkit-scrollbar-track { background: transparent; }
    .ai-drawer-messages::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.1); border-radius: 4px; }

    .ai-msg {
      display: flex;
      gap: 10px;
      animation: aiMsgFade 0.25s ease;
    }

    @keyframes aiMsgFade {
      from { opacity: 0; transform: translateY(6px); }
      to   { opacity: 1; transform: translateY(0); }
    }

    .ai-msg-user {
      flex-direction: row-reverse;
    }

    .ai-msg-bubble {
      max-width: 85%;
      padding: 10px 14px;
      border-radius: 18px;
      font-size: 13.5px;
      line-height: 1.5;
    }

    .ai-msg-ai .ai-msg-bubble {
      background: #f8fafc;
      border: 1px solid rgba(15,23,42,0.08);
      color: #0f172a;
      border-radius: 4px 18px 18px 18px;
    }

    .ai-msg-user .ai-msg-bubble {
      background: linear-gradient(135deg, #a855f7, #3b82f6);
      color: #fff;
      border-radius: 18px 4px 18px 18px;
    }

    .ai-msg-avatar {
      width: 28px;
      height: 28px;
      border-radius: 50%;
      flex-shrink: 0;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 13px;
    }

    .ai-msg-ai .ai-msg-avatar {
      background: linear-gradient(135deg, #a855f7, #3b82f6);
      color: #fff;
    }

    .ai-msg-user .ai-msg-avatar {
      background: #e2e8f0;
      color: #475569;
      font-weight: 700;
    }

    /* AI action confirmation card */
    .ai-action-card {
      background: linear-gradient(135deg, rgba(168,85,247,0.06), rgba(59,130,246,0.06));
      border: 1px solid rgba(168,85,247,0.2);
      border-radius: 14px;
      padding: 14px;
      margin-top: 8px;
    }

    .ai-action-card-title {
      font-size: 12px;
      font-weight: 700;
      color: #a855f7;
      text-transform: uppercase;
      letter-spacing: 0.05em;
      margin-bottom: 8px;
    }

    .ai-action-card-body {
      font-size: 13px;
      color: #334155;
      margin-bottom: 12px;
      line-height: 1.5;
    }

    .ai-action-buttons {
      display: flex;
      gap: 8px;
    }

    .ai-action-confirm {
      flex: 1;
      padding: 8px 14px;
      background: linear-gradient(135deg, #a855f7, #3b82f6);
      color: #fff;
      border: none;
      border-radius: 10px;
      font-size: 12px;
      font-weight: 700;
      cursor: pointer;
      transition: opacity 0.2s;
    }
    .ai-action-confirm:hover { opacity: 0.9; }

    .ai-action-cancel {
      padding: 8px 14px;
      background: transparent;
      border: 1px solid rgba(15,23,42,0.12);
      border-radius: 10px;
      font-size: 12px;
      color: #64748b;
      cursor: pointer;
      transition: all 0.2s;
    }
    .ai-action-cancel:hover { background: #f8fafc; }

    /* Quick chip suggestions */
    .ai-chips {
      display: flex;
      gap: 6px;
      flex-wrap: wrap;
      padding: 10px 16px;
      border-top: 1px solid rgba(15,23,42,0.06);
      flex-shrink: 0;
    }

    .ai-chip {
      padding: 5px 11px;
      background: rgba(168,85,247,0.08);
      border: 1px solid rgba(168,85,247,0.2);
      border-radius: 20px;
      font-size: 11.5px;
      color: #7c3aed;
      font-weight: 600;
      cursor: pointer;
      transition: all 0.15s;
      white-space: nowrap;
    }
    .ai-chip:hover {
      background: rgba(168,85,247,0.15);
      color: #6d28d9;
    }

    .ai-drawer-input-area {
      padding: 12px 16px 16px;
      border-top: 1px solid rgba(15,23,42,0.08);
      flex-shrink: 0;
      display: flex;
      gap: 8px;
      align-items: flex-end;
    }

    .ai-drawer-input {
      flex: 1;
      border: 1px solid rgba(15,23,42,0.12);
      border-radius: 14px;
      padding: 10px 14px;
      font-size: 13.5px;
      font-family: var(--font-body);
      color: #0f172a;
      outline: none;
      resize: none;
      min-height: 44px;
      max-height: 120px;
      transition: border-color 0.2s;
      line-height: 1.4;
      overflow-y: auto;
    }
    .ai-drawer-input:focus {
      border-color: #a855f7;
      box-shadow: 0 0 0 3px rgba(168,85,247,0.1);
    }

    .ai-drawer-send {
      width: 40px;
      height: 40px;
      border-radius: 50%;
      background: linear-gradient(135deg, #a855f7, #3b82f6);
      border: none;
      color: #fff;
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      flex-shrink: 0;
      transition: opacity 0.2s, transform 0.15s;
    }
    .ai-drawer-send:hover { opacity: 0.9; transform: scale(1.05); }
    .ai-drawer-send:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

    /* Typing indicator */
    .ai-typing {
      display: flex;
      gap: 4px;
      align-items: center;
      padding: 8px 12px;
    }
    .ai-typing span {
      width: 7px;
      height: 7px;
      border-radius: 50%;
      background: #a855f7;
      animation: aiTypingBounce 1.2s ease infinite;
    }
    .ai-typing span:nth-child(2) { animation-delay: 0.2s; }
    .ai-typing span:nth-child(3) { animation-delay: 0.4s; }
    @keyframes aiTypingBounce {
      0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
      30%            { transform: translateY(-5px); opacity: 1; }
    }

    /* ════════════════════════════════════════════════
       UPLOAD STATEMENT MODAL
    ════════════════════════════════════════════════ */
    .upload-modal-overlay {
      position: fixed;
      inset: 0;
      background: rgba(15,23,42,0.55);
      backdrop-filter: blur(6px);
      z-index: 500;
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 16px;
    }

    .upload-modal-inner {
      background: #fff;
      border-radius: 24px;
      box-shadow: 0 30px 80px rgba(0,0,0,0.2);
      width: min(92vw, 680px);
      max-height: 90vh;
      display: flex;
      flex-direction: column;
      overflow: hidden;
      animation: uploadModalIn 0.25s ease;
    }

    @keyframes uploadModalIn {
      from { opacity: 0; transform: scale(0.95) translateY(10px); }
      to   { opacity: 1; transform: scale(1) translateY(0); }
    }

    .upload-modal-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 24px 28px 20px;
      border-bottom: 1px solid rgba(15,23,42,0.08);
      flex-shrink: 0;
    }

    .upload-modal-body {
      flex: 1;
      overflow-y: auto;
      padding: 28px;
    }

    .upload-modal-footer {
      display: flex;
      gap: 12px;
      justify-content: flex-end;
      padding: 20px 28px;
      border-top: 1px solid rgba(15,23,42,0.08);
      flex-shrink: 0;
    }

    /* Step indicator */
    .upload-steps {
      display: flex;
      align-items: center;
      gap: 0;
      margin-bottom: 28px;
    }

    .upload-step {
      display: flex;
      align-items: center;
      gap: 6px;
      font-size: 12px;
      font-weight: 600;
      color: #94a3b8;
    }

    .upload-step.active { color: #7c3aed; }
    .upload-step.done   { color: #10b981; }

    .upload-step-num {
      width: 24px;
      height: 24px;
      border-radius: 50%;
      background: #e2e8f0;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 11px;
      font-weight: 800;
    }

    .upload-step.active .upload-step-num {
      background: linear-gradient(135deg, #a855f7, #3b82f6);
      color: #fff;
    }

    .upload-step.done .upload-step-num {
      background: #10b981;
      color: #fff;
    }

    .upload-step-line {
      flex: 1;
      height: 2px;
      background: #e2e8f0;
      margin: 0 8px;
    }

    .upload-step-line.done { background: #10b981; }

    /* Drop zone */
    .upload-dropzone {
      border: 2px dashed rgba(168,85,247,0.3);
      border-radius: 16px;
      padding: 48px 24px;
      text-align: center;
      background: rgba(168,85,247,0.03);
      cursor: pointer;
      transition: all 0.2s;
    }

    .upload-dropzone:hover,
    .upload-dropzone.dragover {
      border-color: #a855f7;
      background: rgba(168,85,247,0.06);
    }

    /* Review table */
    .review-table-wrap {
      overflow-x: auto;
      border-radius: 12px;
      border: 1px solid rgba(15,23,42,0.08);
    }

    .review-table {
      width: 100%;
      border-collapse: collapse;
      min-width: 640px;
      font-size: 13px;
    }

    .review-table th {
      padding: 10px 12px;
      background: #f8fafc;
      text-align: left;
      font-size: 11px;
      font-weight: 700;
      color: #64748b;
      text-transform: uppercase;
      letter-spacing: 0.04em;
      border-bottom: 1px solid rgba(15,23,42,0.08);
    }

    .review-table td {
      padding: 9px 12px;
      border-bottom: 1px solid rgba(15,23,42,0.05);
      vertical-align: middle;
    }

    .review-table tr:last-child td { border-bottom: none; }

    .review-table tr.duplicate-row { background: rgba(245,158,11,0.04); }

    .review-table select {
      font-size: 12px;
      padding: 4px 6px;
      border-radius: 8px;
      border: 1px solid rgba(15,23,42,0.12);
      background: #f8fafc;
      color: #0f172a;
      cursor: pointer;
    }

    .dup-badge {
      display: inline-flex;
      align-items: center;
      gap: 3px;
      padding: 2px 7px;
      background: rgba(245,158,11,0.12);
      border: 1px solid rgba(245,158,11,0.3);
      border-radius: 8px;
      font-size: 10px;
      font-weight: 700;
      color: #b45309;
    }

    .import-summary-card {
      background: linear-gradient(135deg, rgba(168,85,247,0.05), rgba(59,130,246,0.05));
      border: 1px solid rgba(168,85,247,0.15);
      border-radius: 16px;
      padding: 20px 24px;
      margin-bottom: 20px;
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
      gap: 16px;
    }

    .import-summary-item {
      text-align: center;
    }

    .import-summary-val {
      font-size: 22px;
      font-weight: 800;
      font-family: 'Manrope', sans-serif;
      letter-spacing: -0.5px;
    }

    .import-summary-lbl {
      font-size: 10px;
      color: #64748b;
      font-weight: 600;
      text-transform: uppercase;
      letter-spacing: 0.06em;
      margin-top: 2px;
    }

    /* ════════════════════════════════════════════════
       DASHBOARD ACTION BUTTON GROUP
    ════════════════════════════════════════════════ */
    .dash-action-group {
      display: flex;
      gap: 10px;
      align-items: center;
      flex-wrap: wrap;
    }

    .btn-upload-statement {
      display: flex;
      align-items: center;
      gap: 8px;
      padding: 11px 18px;
      background: #fff;
      border: 1.5px solid rgba(15,23,42,0.12);
      border-radius: 12px;
      font-size: 13px;
      font-weight: 700;
      color: #334155;
      cursor: pointer;
      transition: all 0.2s;
      font-family: 'Manrope', sans-serif;
    }

    .btn-upload-statement:hover {
      background: #f8fafc;
      border-color: rgba(15,23,42,0.2);
      transform: translateY(-1px);
      box-shadow: 0 4px 12px rgba(0,0,0,0.06);
    }

    .btn-upload-statement:active {
      transform: scale(0.98);
    }

    /* Analysis spinner */
    .analyze-spinner {
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      padding: 60px 24px;
      gap: 16px;
    }

    .analyze-ring {
      width: 48px;
      height: 48px;
      border: 4px solid #e2e8f0;
      border-top-color: #a855f7;
      border-radius: 50%;
      animation: spinRing 0.8s linear infinite;
    }

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

    /* Success state */
    .import-success {
      display: flex;
      flex-direction: column;
      align-items: center;
      padding: 40px 24px;
      text-align: center;
      gap: 12px;
    }

    .import-success-icon {
      width: 64px;
      height: 64px;
      border-radius: 50%;
      background: linear-gradient(135deg, #10b981, #34d399);
      display: flex;
      align-items: center;
      justify-content: center;
      color: #fff;
      box-shadow: 0 8px 24px rgba(16,185,129,0.3);
    }