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

  /* ── ICONS (Lucide, self-hosted inline SVG — see icons.js) ── */
  .icon { display: inline-block; vertical-align: -0.125em; flex-shrink: 0; }
  .icon-lg { width: 24px !important; height: 24px !important; }
  .icon-sm { width: 14px !important; height: 14px !important; }

  :root {
    --bg: #ffffff; --bg2: #f7f7f5; --bg3: #f0f0ed;
    --cream: #1a1916; --cream2: #4a4744;
    --amber: #2A9D8F; --amber2: #3DB5A6;
    --amber-text: #227E72;
    --muted: #6b6660;
    --border: rgba(26,25,22,0.08);
    --border2: rgba(26,25,22,0.15);
    --amber-bg: rgba(42,157,143,0.1);
    --amber-border: rgba(42,157,143,0.25);
    --amber-border2: rgba(42,157,143,0.07);
    --green: #2e7d5a; --green-bg: rgba(46,125,90,0.15);
    --red: #c0392b; --red-bg: rgba(192,57,43,0.15);
    --radius: 10px;
    --app-max: 960px;
  }

  /* ── ACCESSIBILITY: KEYBOARD FOCUS (WCAG 2.4.7) ── */
  /* Keyboard-only focus ring. :focus-visible skips mouse/touch clicks, so this
     doesn't add visual noise for pointer users while still meeting Focus Visible. */
  :focus-visible {
    outline: 2px solid var(--amber);
    outline-offset: 2px;
  }

  html, body { height: 100%; font-family: 'DM Sans', sans-serif; background: var(--bg); color: var(--cream); font-weight: 300; line-height: 1.6; overflow-x: hidden; }


  /* ONBOARDING */
  #onboardingScreen { flex-direction: column; align-items: center; justify-content: flex-start; padding: 2rem 1.5rem; min-height: 100vh; overflow-y: auto; }
  .onboard-wrap { width: 100%; max-width: 480px; padding-top: 2rem; }
  .onboard-logo { font-family: 'DM Sans', sans-serif; font-weight: 500; font-size: 1.5rem; color: var(--cream); margin-bottom: 0.25rem; }
  .onboard-logo span { color: var(--amber-text); }
  .onboard-step { display: none; }
  .onboard-step.active { display: block; }
  .onboard-title { font-family: 'Playfair Display', serif; font-size: 1.5rem; font-weight: 700; color: var(--cream); margin-bottom: 0.5rem; margin-top: 1.5rem; }
  .onboard-sub { font-size: 0.875rem; color: var(--muted); margin-bottom: 1.5rem; }
  .progress-bar { display: flex; gap: 6px; margin-bottom: 2rem; }
  .progress-step { height: 3px; flex: 1; border-radius: 2px; background: var(--border2); transition: background 0.3s; }
  .progress-step.done { background: var(--amber); }
  .type-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 1.5rem; }
  .type-card { background: var(--bg2); border: 2px solid var(--border); border-radius: 12px; padding: 1.1rem; cursor: pointer; transition: all 0.15s; text-align: center; }
  .type-card:hover { border-color: var(--border2); background: var(--bg3); }
  .type-card.selected { border-color: var(--amber-text); background: var(--amber-bg); }
  .type-card-icon { font-size: 1.6rem; margin-bottom: 6px; }
  .type-card-label { font-size: 0.82rem; font-weight: 500; color: var(--cream); }
  .class-grid { display: flex; flex-direction: column; gap: 8px; margin-bottom: 1.5rem; }
  .class-item { background: var(--bg2); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; display: flex; align-items: center; gap: 12px; cursor: pointer; transition: all 0.15s; }
  .class-item:hover { background: var(--bg3); }
  .class-item.selected { border-color: var(--amber-border); background: var(--amber-bg); }
  .class-check { width: 20px; height: 20px; border-radius: 5px; border: 2px solid var(--border2); display: flex; align-items: center; justify-content: center; font-size: 0.7rem; flex-shrink: 0; transition: all 0.15s; }
  .class-check svg { opacity: 0; }
  .class-item.selected .class-check { background: var(--amber); border-color: var(--amber-text); color: var(--cream); }
  .class-item.selected .class-check svg { opacity: 1; }
  .class-name { font-size: 0.9rem; color: var(--cream); flex: 1; }
  .class-fee-inputs { display: flex; gap: 8px; margin-top: 8px; display: none; }
  .class-item.selected .class-fee-inputs { display: flex; }
  .fee-input-wrap { flex: 1; }
  .fee-input-wrap label { font-size: 0.65rem; color: var(--muted); display: block; margin-bottom: 3px; }
  .fee-input-wrap input { width: 100%; background: var(--bg3); border: 1px solid var(--border2); border-radius: 6px; padding: 6px 8px; color: var(--cream); font-family: "DM Sans", sans-serif; font-size: 0.85rem; outline: none; }
  .fee-input-wrap input:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
  .fee-input-wrap .input-prefix-wrap { background: var(--bg3); border-radius: 6px; }
  .fee-input-wrap .input-prefix { padding: 6px 8px; font-size: 0.85rem; background: transparent; }
  .fee-input-wrap .input-prefix-wrap input { border: none; border-radius: 0; background: transparent; padding: 6px 8px; }
  .onboard-collapse { background: var(--bg2); border: 1px solid var(--border2); border-radius: 12px; margin-bottom: 16px; }
  .onboard-collapse summary { cursor: pointer; padding: 14px; font-size: 0.82rem; font-weight: 500; color: var(--cream); list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
  .onboard-collapse summary::-webkit-details-marker { display: none; }
  .onboard-collapse summary .icon { color: var(--muted); transition: transform 0.15s; flex-shrink: 0; }
  .onboard-collapse[open] summary .icon { transform: rotate(180deg); }
  .onboard-collapse-body { padding: 0 14px 14px; }
  .custom-class-row { display: flex; gap: 8px; margin-top: 10px; }
  .custom-class-row input { flex: 1; background: var(--bg2); border: 1px solid var(--border2); border-radius: 10px; padding: 10px 14px; color: var(--cream); font-family: "DM Sans", sans-serif; font-size: 0.9rem; outline: none; }
  .custom-class-row input:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
  .custom-class-row input::placeholder { color: var(--muted); }
  .btn-add-custom { background: var(--bg2); border: 1px solid var(--border2); border-radius: 10px; padding: 10px 14px; color: var(--amber-text); font-size: 0.9rem; cursor: pointer; white-space: nowrap; }
  .btn-add-custom:hover { background: var(--bg3); }
  .onboard-nav { display: flex; gap: 10px; margin-top: 1rem; padding-bottom: 2rem; }

  /* SCREENS */
  .screen { display: none; min-height: 100vh; }
  .screen.active { display: flex; }

  /* ── LOGIN SCREEN ── */
  #loginScreen { align-items: center; justify-content: center; padding: 2rem; background: var(--bg); position: relative; overflow: hidden; }
  #resetPasswordScreen { align-items: center; justify-content: center; padding: 2rem; background: var(--bg); }
  .login-glow { position: absolute; top: -100px; left: 50%; transform: translateX(-50%); width: 400px; height: 400px; background: radial-gradient(circle, rgba(42,157,143,0.06) 0%, transparent 70%); pointer-events: none; }
  .login-box { width: 100%; max-width: 380px; position: relative; z-index: 1; }
  .login-logo { font-family: 'DM Sans', sans-serif; font-weight: 500; font-size: 1.8rem; color: var(--cream); letter-spacing: -0.02em; margin-bottom: 0.25rem; }
  .login-logo span { color: var(--amber-text); }
  .login-tagline { font-size: 0.85rem; color: var(--muted); margin-bottom: 2.5rem; }
  .login-card { background: var(--bg2); border: 1px solid var(--border2); border-radius: 14px; padding: 2rem; }
  .login-title { font-family: 'Playfair Display', serif; font-size: 1.3rem; font-weight: 700; color: var(--cream); margin-bottom: 1.5rem; }
  .field { margin-bottom: 1rem; }
  .field label { display: block; font-size: 0.78rem; color: var(--cream2); margin-bottom: 6px; font-weight: 400; }
  .field input { width: 100%; background: var(--bg3); border: 1px solid var(--border2); border-radius: var(--radius); padding: 0.8rem 1rem; color: var(--cream); font-family: 'DM Sans', sans-serif; font-size: 0.95rem; font-weight: 300; outline: none; transition: border-color 0.2s; }
  .field input:focus { border-color: var(--amber-border); }
  .field input:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
  .field input::placeholder { color: var(--muted); }
  .forgot { font-size: 0.75rem; color: var(--amber-text); text-decoration: none; float: right; margin-top: -2px; }
  .btn-primary { width: 100%; background: var(--amber); color: var(--cream); border: none; border-radius: var(--radius); padding: 0.9rem; font-family: 'DM Sans', sans-serif; font-size: 0.95rem; font-weight: 500; cursor: pointer; transition: background 0.2s, transform 0.1s; margin-top: 0.5rem; }
  .btn-primary:hover { background: var(--amber2); }
  .btn-primary:active { transform: scale(0.98); }
  .btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
  .login-divider { text-align: center; font-size: 0.75rem; color: var(--muted); margin: 1.25rem 0; }
  .btn-secondary { width: 100%; background: var(--amber-border2); color: var(--amber-text); border: 1px solid var(--amber-text); border-radius: var(--radius); padding: 0.9rem; font-family: 'DM Sans', sans-serif; font-size: 0.95rem; font-weight: 400; cursor: pointer; transition: background 0.2s; }
  .btn-secondary:hover { background: var(--bg3); border-color: var(--amber-text); }
  .error-msg { background: var(--red-bg); border: 1px solid rgba(192,57,43,0.3); border-radius: var(--radius); padding: 0.75rem 1rem; font-size: 0.82rem; color: #a83226; margin-bottom: 1rem; display: none; }
  .success-msg { background: var(--green-bg); border: 1px solid rgba(46,125,90,0.3); border-radius: var(--radius); padding: 0.75rem 1rem; font-size: 0.82rem; color: #1f6144; margin-bottom: 1rem; display: none; }

  /* ── SETUP SCREEN ── */
  #setupScreen { flex-direction: column; align-items: center; justify-content: center; padding: 2rem; }
  .setup-box { width: 100%; max-width: 480px; }
  .setup-step { background: var(--bg2); border: 1px solid var(--border2); border-radius: 14px; padding: 2rem; margin-bottom: 1rem; }
  .setup-step h2 { font-family: 'Playfair Display', serif; font-size: 1.3rem; font-weight: 700; color: var(--cream); margin-bottom: 0.5rem; }
  .setup-step p { font-size: 0.85rem; color: var(--muted); margin-bottom: 1.5rem; }
  .step-indicator { display: flex; gap: 6px; margin-bottom: 2rem; }
  .step-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--bg3); border: 1px solid var(--border2); }
  .step-dot.active { background: var(--amber); border-color: var(--amber-text); }
  .step-dot.done { background: var(--green); border-color: var(--green); }

  /* ── MAIN APP ── */
  #appScreen { flex-direction: column; }
  .app-header { background: var(--bg2); border-bottom: 1px solid var(--border); padding: 14px 16px; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 50; }
  .app-logo { font-family: 'DM Sans', sans-serif; font-weight: 500; font-size: 1rem; color: var(--cream); }
  .app-logo span { color: var(--amber-text); }
  .app-school-name { font-size: 0.68rem; color: var(--muted); margin-top: 1px; }
  .app-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--amber-bg); border: 1px solid var(--amber-border); display: flex; align-items: center; justify-content: center; font-size: 0.72rem; font-weight: 500; color: var(--amber-text); cursor: pointer; flex-shrink: 0; }
  .hamburger-btn { width: 32px; height: 32px; border-radius: 50%; background: none; border: none; display: flex; align-items: center; justify-content: center; color: var(--cream2); cursor: pointer; flex-shrink: 0; padding: 0; }
  .hamburger-btn:hover { background: var(--bg3); }
  .more-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
  .more-tile { display: flex; flex-direction: column; align-items: center; gap: 6px; background: var(--bg2); border: 1px solid var(--border); border-radius: 12px; padding: 16px 8px; cursor: pointer; transition: background 0.15s; }
  .more-tile:hover { background: var(--bg3); }
  .more-tile-icon { font-size: 1.2rem; color: var(--cream2); }
  .more-tile-label { font-size: 0.75rem; color: var(--cream); font-weight: 500; }
  .app-content { flex: 1; overflow-y: auto; padding-bottom: 80px; }
  .bottom-nav { position: fixed; bottom: 0; left: 0; right: 0; background: var(--bg2); border-top: 1px solid var(--border); display: flex; padding: 8px 0 max(12px, env(safe-area-inset-bottom)); z-index: 50; }
  .nav-item { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; cursor: pointer; padding: 4px 0; }
  .nav-icon { font-size: 1.1rem; }
  .nav-label { font-size: 0.62rem; color: var(--muted); font-weight: 400; transition: color 0.2s; }
  .nav-item.active .nav-label { color: var(--amber-text); }

  /* VIEWS */
  .view { display: none; padding: 16px; }
  .view.active { display: block; }

  /* HQ OVERVIEW (All schools) */
  .hq-title { font-family: 'Playfair Display', serif; font-size: 1.7rem; font-weight: 700; color: var(--cream); line-height: 1.2; }
  .hq-subtitle { font-size: 0.78rem; color: var(--muted); margin-top: 4px; letter-spacing: 0.02em; }
  .hq-num { font-variant-numeric: tabular-nums; }
  .hq-lbl { font-size: 0.66rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
  .hq-chev { color: var(--muted); font-size: 1.1rem; line-height: 1; flex-shrink: 0; }
  .hq-summary { display: flex; align-items: center; gap: 24px; background: var(--bg2); border: 1px solid var(--border); border-radius: 14px; padding: 12px 16px; margin-bottom: 12px; box-shadow: 0 1px 2px rgba(26,25,22,0.05), 0 4px 12px rgba(26,25,22,0.04); }
  .hq-hero { flex-shrink: 0; }
  .hq-hero-num { font-family: 'Playfair Display', serif; font-size: 2.4rem; font-weight: 700; color: var(--cream); line-height: 1; margin-bottom: 4px; }
  .hq-secondary { flex: 1; min-width: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
  .hq-sec-num { font-size: 1.05rem; font-weight: 500; color: var(--cream); overflow-wrap: anywhere; }
  .hq-attn { border: 1px solid var(--border); border-left: 3px solid var(--red); background: var(--bg2); border-radius: 12px; padding: 8px 12px; margin-bottom: 12px; }
  .hq-attn-hdr { font-size: 0.68rem; font-weight: 500; text-transform: uppercase; letter-spacing: 0.08em; color: var(--red); margin-bottom: 2px; }
  .hq-attn-row { display: flex; align-items: center; gap: 8px; padding: 7px 0; font-size: 0.82rem; cursor: pointer; border-top: 1px solid var(--border); transition: opacity 0.1s; white-space: nowrap; }
  .hq-attn-hdr + .hq-attn-row { border-top: none; }
  .hq-attn-row:active { opacity: 0.6; }
  .hq-attn-toggle { color: var(--muted); font-size: 0.78rem; }
  .hq-attn-name { font-weight: 500; color: var(--cream); overflow: hidden; text-overflow: ellipsis; min-width: 0; flex-shrink: 1; }
  .hq-attn-text { color: var(--muted); font-size: 0.78rem; margin-left: auto; text-align: right; font-variant-numeric: tabular-nums; flex-shrink: 0; max-width: 60%; overflow: hidden; text-overflow: ellipsis; }
  .hq-search { width: 100%; box-sizing: border-box; margin-bottom: 12px; padding: 9px 12px; font-size: 0.9rem; font-family: inherit; color: var(--cream); background: var(--bg2); border: 1px solid var(--border); border-radius: 10px; }
  .hq-nomatch { color: var(--muted); font-size: 0.85rem; padding: 8px 0; }
  .hq-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
  .hq-card { display: flex; flex-direction: column; gap: 5px; min-width: 0; background: var(--bg2); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; cursor: pointer; box-shadow: 0 1px 2px rgba(26,25,22,0.05); transition: transform 0.12s, box-shadow 0.12s, background 0.15s; }
  .hq-card:active { transform: scale(0.985); box-shadow: 0 1px 1px rgba(26,25,22,0.06); background: var(--bg3); }
  .hq-card-top { display: flex; align-items: center; gap: 8px; min-width: 0; }
  .hq-mono { width: 28px; height: 28px; border-radius: 50%; background: var(--amber-bg); border: 1px solid var(--amber-border); color: var(--amber-text); display: flex; align-items: center; justify-content: center; font-size: 0.68rem; font-weight: 500; letter-spacing: 0.02em; flex-shrink: 0; }
  .hq-card-name { font-size: 0.88rem; font-weight: 500; color: var(--cream); flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .hq-card-head { display: flex; align-items: baseline; gap: 6px; }
  .hq-card-num { font-family: 'Playfair Display', serif; font-size: 1.6rem; font-weight: 700; color: var(--cream); line-height: 1; }
  .hq-att { display: flex; align-items: center; gap: 8px; }
  .hq-att-pct { font-size: 0.72rem; min-width: 2.4em; text-align: right; }
  .hq-bar { flex: 1; min-width: 0; height: 4px; border-radius: 2px; background: var(--bg3); border: 1px solid var(--border); overflow: hidden; box-sizing: content-box; }
  .hq-bar-fill { height: 100%; background: var(--amber); border-radius: 2px; }
  .hq-bar-fill.low { background: var(--red); }
  .hq-paid { font-size: 0.72rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .hq-chip { align-self: flex-start; max-width: 100%; box-sizing: border-box; font-size: 0.68rem; font-weight: 500; color: var(--red); border: 1px solid var(--red); border-radius: 999px; padding: 0 8px; line-height: 1.5; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
  .hq-skel { border-radius: 14px; border: 1px solid var(--border); background: linear-gradient(90deg, var(--bg2) 25%, var(--bg3) 50%, var(--bg2) 75%); background-size: 200% 100%; animation: hqShimmer 1.4s ease-in-out infinite; }
  .hq-roy-wrap { border-left-color: var(--amber); }
  .hq-roy-wrap .hq-attn-row { border-top: none; }
  .roy-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
  .roy-nav .roy-btn { flex: none; width: 2.25rem; height: 2.25rem; padding: 0; display: inline-flex; align-items: center; justify-content: center; font-size: 1.1rem; line-height: 1; }
  .roy-nav-label { font-weight: 600; color: var(--cream); }
  .hq-add-btn { display: block; margin-top: 4px; padding: 0; background: none; border: none; color: var(--amber-text); font-family: inherit; font-size: 0.72rem; font-weight: 500; cursor: pointer; }
  .hq-pending { border-left-color: var(--amber-text); }
  .hq-pending .hq-attn-hdr { color: var(--amber-text); }
  .hq-pend-row { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-top: 1px solid var(--border); }
  .hq-attn-hdr + .hq-pend-row { border-top: none; }
  .hq-pend-main { flex: 1; min-width: 0; }
  .hq-pend-sub { color: var(--muted); font-size: 0.74rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .roy-btn { flex: none; padding: 0.35rem 0.8rem; font-size: 0.78rem; }
  .roy-btn:disabled { opacity: 0.45; cursor: not-allowed; }
  .roy-sum { display: flex; gap: 24px; background: var(--bg3); border-radius: 10px; padding: 10px 14px; margin-bottom: 12px; }
  .roy-sum-num { font-size: 1.05rem; font-weight: 600; color: var(--cream); font-variant-numeric: tabular-nums; }
  .roy-row { display: flex; justify-content: space-between; gap: 10px; padding: 10px 0; border-top: 1px solid var(--border); }
  .roy-row-main { min-width: 0; }
  .roy-month { font-size: 0.9rem; font-weight: 500; color: var(--cream); overflow-wrap: anywhere; }
  .roy-sub { font-size: 0.74rem; color: var(--muted); margin-top: 2px; }
  .roy-rate { color: var(--amber-text); text-decoration: underline; }
  .roy-row-side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }
  .roy-amt { font-weight: 600; color: var(--cream); font-variant-numeric: tabular-nums; }
  .roy-pill { font-size: 0.66rem; font-weight: 500; border-radius: 999px; padding: 0 8px; line-height: 1.6; border: 1px solid var(--border2); color: var(--muted); }
  .roy-pill.roy-wait { color: var(--amber-text); border-color: var(--amber-border); }
  .roy-pill.roy-ok { color: var(--green, #2e7d5b); border-color: var(--green, #2e7d5b); }
  .roy-note { font-size: 0.74rem; color: var(--muted); margin: 6px 0 10px; }
  .roy-empty { color: var(--muted); font-size: 0.85rem; padding: 8px 0; }
  .roy-instr { background: var(--bg3); border-radius: 10px; padding: 10px 14px; margin-bottom: 12px; font-size: 0.82rem; color: var(--cream2); line-height: 1.5; }
  .roy-instr-hdr { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 4px; }
  .hq-skel-summary { height: 84px; margin-bottom: 12px; }
  .hq-skel-tile { height: 120px; border-radius: 12px; }
  @keyframes hqShimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
  @media (max-width: 600px) {
    .hq-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .hq-summary { flex-direction: column; align-items: stretch; gap: 10px; }
    .hq-sec-num { font-size: 0.92rem; }
  }
  @media (prefers-reduced-motion: reduce) { .hq-skel { animation: none; } .hq-card { transition: none; } }

  /* DASHBOARD */
  .dash-greeting { margin-bottom: 16px; }
  .dash-greeting h1 { font-family: 'Playfair Display', serif; font-size: 1.3rem; font-weight: 700; color: var(--cream); }
  .dash-greeting p { font-size: 0.78rem; color: var(--muted); margin-top: 2px; }
  .stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 18px; }
  .stat-card { background: var(--bg2); border: 1px solid var(--border); border-radius: 12px; padding: 14px; cursor: pointer; transition: background 0.15s, transform 0.1s; }
  .stat-card:hover { background: var(--bg3); }
  .stat-card:active { transform: scale(0.98); }
  .stat-card.highlight { border-color: var(--amber-border); background: var(--amber-bg); }
  .stat-card.highlight:hover { background: var(--amber-bg); filter: brightness(1.1); }
  .stat-val { font-family: 'Playfair Display', serif; font-size: 1.8rem; font-weight: 700; color: var(--cream); line-height: 1; }
  .stat-card.highlight .stat-val { color: var(--amber-text); }
  .stat-lbl { font-size: 0.68rem; color: var(--muted); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.05em; }
  .stat-sub { font-size: 0.68rem; color: var(--amber-text); margin-top: 6px; cursor: pointer; text-decoration: underline; }
  .section-hdr { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
  .section-hdr h3 { font-size: 0.72rem; font-weight: 500; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
  .section-hdr a { font-size: 0.72rem; color: var(--amber-text); text-decoration: none; cursor: pointer; }
  .today-card { margin-bottom: 18px; }
  .today-row { display: flex; align-items: center; gap: 10px; background: var(--bg2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin-bottom: 6px; cursor: pointer; transition: background 0.15s; }
  .today-row:hover { background: var(--bg3); }
  .today-row-off { cursor: default; opacity: 0.55; }
  .today-row-off:hover { background: var(--bg2); }
  .today-row-now { border-color: var(--amber-border); background: var(--amber-bg); }
  .today-row-now:hover { background: var(--amber-bg); filter: brightness(1.05); }
  .today-row-finished { opacity: 0.6; }
  .today-row-time { font-size: 0.75rem; color: var(--muted); width: 88px; flex-shrink: 0; }
  .today-row-main { flex: 1; min-width: 0; }
  .today-row-name { font-size: 0.875rem; font-weight: 500; color: var(--cream); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .today-row-meta { font-size: 0.72rem; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .today-now-badge { font-size: 0.62rem; font-weight: 600; text-transform: uppercase; color: var(--amber-text); background: var(--amber-bg); border: 1px solid var(--amber-border); border-radius: 999px; padding: 2px 8px; flex-shrink: 0; }
  .today-row-reg { font-size: 0.68rem; color: var(--muted); flex-shrink: 0; white-space: nowrap; }
  .today-empty { display: flex; align-items: center; gap: 8px; background: var(--bg2); border: 1px dashed var(--border2); border-radius: 10px; padding: 14px; cursor: pointer; color: var(--cream2); font-size: 0.85rem; transition: background 0.15s; }
  .today-empty:hover { background: var(--bg3); }
  .alert-item { background: var(--bg2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; display: flex; align-items: center; gap: 10px; margin-bottom: 6px; cursor: pointer; transition: background 0.15s; }
  .alert-item:hover { background: var(--bg3); }
  .alert-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
  .alert-dot.red { background: var(--red); }
  .alert-dot.amber { background: var(--amber); }
  .alert-dot.green { background: var(--green); }
  .alert-text { font-size: 0.8rem; color: var(--cream2); line-height: 1.4; flex: 1; }
  .alert-text strong { color: var(--cream); font-weight: 500; }
  .empty-state { text-align: center; padding: 3rem 1rem; color: var(--muted); font-size: 0.875rem; }
  .empty-icon { font-size: 2rem; margin-bottom: 0.75rem; }

  /* STUDENTS VIEW */
  .search-bar { background: var(--bg2); border: 1px solid var(--border2); border-radius: 10px; padding: 10px 14px; font-size: 0.9rem; color: var(--cream); font-family: 'DM Sans', sans-serif; width: 100%; outline: none; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
  .search-bar input { background: transparent; border: none; outline: none; color: var(--cream); font-family: 'DM Sans', sans-serif; font-size: 0.9rem; flex: 1; }
  .search-bar input::placeholder { color: var(--muted); }
  .search-bar input:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; border-radius: 6px; }
  .student-card { background: var(--bg2); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; display: flex; align-items: center; gap: 12px; margin-bottom: 8px; cursor: pointer; transition: background 0.15s; }
  .student-card:hover { background: var(--bg3); }
  .stu-avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--bg3); border: 1px solid var(--border2); display: flex; align-items: center; justify-content: center; font-size: 0.78rem; font-weight: 500; color: var(--amber-text); flex-shrink: 0; }
  .stu-name { font-size: 0.9rem; font-weight: 500; color: var(--cream); }
  .stu-classes { font-size: 0.72rem; color: var(--muted); margin-top: 2px; }
  .stu-classes .no-schedule-prompt { color: var(--amber-text); }
  .stu-amount { font-size: 0.9rem; font-weight: 500; color: var(--amber-text); margin-left: auto; text-align: right; flex-shrink: 0; }
  .stu-status { font-size: 0.65rem; margin-top: 2px; text-align: right; }
  .stu-status.paid { color: var(--green); }
  .stu-status.unpaid { color: var(--red); }
  .stu-status.pending { color: var(--amber-text); }
  .stu-status.none { color: var(--muted); }
  .fab { position: fixed; bottom: 80px; right: 20px; width: 52px; height: 52px; background: var(--amber); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 1.5rem; color: var(--cream); box-shadow: 0 4px 20px rgba(42,157,143,0.35); cursor: pointer; border: none; transition: transform 0.15s, background 0.15s; z-index: 40; }
  .fab:hover { background: var(--amber2); transform: scale(1.05); }

  /* INVOICES VIEW */
  .invoice-card { background: var(--bg2); border: 1px solid var(--border); border-radius: 12px; padding: 14px; margin-bottom: 8px; cursor: pointer; transition: background 0.15s; }
  .invoice-card:hover { background: var(--bg3); }
  .invoice-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 6px; }
  .invoice-student { font-size: 0.9rem; font-weight: 500; color: var(--cream); }
  .invoice-amount { font-size: 1rem; font-weight: 500; color: var(--amber-text); }
  .invoice-meta { display: flex; justify-content: space-between; align-items: center; }
  .invoice-term { font-size: 0.72rem; color: var(--muted); }
  .status-badge { font-size: 0.65rem; font-weight: 500; padding: 3px 9px; border-radius: 999px; }
  .status-badge.paid { background: var(--green-bg); color: #1f6144; border: 1px solid rgba(46,125,90,0.3); }
  .status-badge.sent { background: var(--amber-bg); color: var(--amber-text); border: 1px solid var(--amber-border); }
  .status-badge.overdue { background: var(--red-bg); color: #a83226; border: 1px solid rgba(192,57,43,0.3); }
  .status-badge.draft { background: var(--bg3); color: var(--muted); border: 1px solid var(--border2); }
  .status-badge.pending_confirmation { background: rgba(123,94,167,0.15); color: #5b3a8f; border: 1px solid rgba(123,94,167,0.3); }
  .status-badge.delivered { background: var(--amber-bg); color: var(--amber-text); border: 1px solid var(--amber-border); }
  .status-badge.opened { background: var(--green-bg); color: #1f6144; border: 1px solid rgba(46,125,90,0.3); }
  .status-badge.bounced, .status-badge.complained, .status-badge.failed { background: var(--red-bg); color: #a83226; border: 1px solid rgba(192,57,43,0.3); }

  /* SETTINGS VIEW */
  .settings-section { background: var(--bg2); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; margin-bottom: 16px; }
  .settings-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 16px; min-height: 56px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background 0.15s; }
  .settings-row:last-child { border-bottom: none; }
  .settings-row:hover { background: var(--bg3); }
  .settings-row.settings-row-static { cursor: default; }
  .settings-row.settings-row-static:hover { background: none; }
  .settings-label { font-size: 0.875rem; color: var(--cream); }
  .settings-value { font-size: 0.8rem; color: var(--muted); }
  .settings-arrow { color: var(--muted); font-size: 0.75rem; flex-shrink: 0; }

  /* Shared row layout: left content that can shrink, right controls that never wrap */
  .settings-row-main { min-width: 0; flex: 1; }
  .settings-row-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
  .settings-value-right { font-size: 0.8rem; color: var(--muted); max-width: 140px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: right; }
  .settings-group-header { font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 20px 2px 8px; }
  .settings-group-header:first-of-type { margin-top: 4px; }

  /* Status dot: connection/health indicator, used consistently across billing rows */
  .status-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; display: inline-block; }
  .status-dot-green { background: var(--green); }
  .status-dot-amber { background: var(--amber); }
  .status-dot-gray { background: var(--muted); }
  .status-dot-red { background: var(--red); }

  /* Action-button row: single fixed-height button, one line, consistent secondary weight */
  .btn-row-action { height: 32px; padding: 0 14px; border-radius: var(--radius); border: 1px solid var(--border2); background: transparent; color: var(--cream); font-family: 'DM Sans', sans-serif; font-size: 0.8rem; font-weight: 500; cursor: pointer; white-space: nowrap; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; transition: background 0.15s; }
  .btn-row-action:hover { background: var(--bg3); }
  .btn-row-action:disabled { opacity: 0.5; cursor: not-allowed; }

  /* Toggle row: inline switch, immediate effect */
  .switch { position: relative; display: inline-flex; align-items: center; width: 42px; height: 24px; flex-shrink: 0; cursor: pointer; }
  .switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
  .switch-track { position: absolute; inset: 0; background: var(--bg3); border: 1px solid var(--border2); border-radius: 999px; transition: background 0.15s, border-color 0.15s; pointer-events: none; }
  .switch-thumb { position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: var(--muted); transition: transform 0.15s, background 0.15s; }
  .switch input:checked + .switch-track { background: var(--green-bg); border-color: var(--green); }
  .switch input:checked + .switch-track .switch-thumb { transform: translateX(18px); background: var(--green); }
  .switch input:disabled + .switch-track { opacity: 0.5; }

  /* MODAL */
  .modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.7); z-index: 100; display: none; align-items: flex-end; justify-content: center; }
  .modal-overlay.active { display: flex; }
  .modal { background: var(--bg2); border: 1px solid var(--border2); border-radius: 20px 20px 0 0; width: 100%; max-width: 480px; padding: 1.5rem; max-height: 90vh; overflow-y: auto; animation: slideUp 0.25s ease; }
  @keyframes slideUp { from{transform:translateY(100%)}to{transform:translateY(0)} }
  .modal-handle { width: 40px; height: 4px; background: var(--border2); border-radius: 2px; margin: 0 auto 1.25rem; }
  .modal-title { font-family: 'Playfair Display', serif; font-size: 1.2rem; font-weight: 700; color: var(--cream); margin-bottom: 1.25rem; }
  .modal-actions { display: flex; gap: 10px; margin-top: 1.25rem; }
  .btn-ghost { flex: 1; background: transparent; color: var(--cream2); border: 1px solid var(--border2); border-radius: var(--radius); padding: 0.85rem; font-family: 'DM Sans', sans-serif; font-size: 0.9rem; cursor: pointer; }
  .btn-ghost:hover { background: var(--bg3); }


  .password-wrap { position: relative; }
  .password-wrap input { padding-right: 2.8rem; }
  .pw-toggle { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); background: none; border: none; cursor: pointer; color: var(--muted); font-size: 1rem; padding: 0; line-height: 1; }
  .pw-toggle:hover { color: var(--cream2); }

  /* TOOLTIP TOUR */
  .tour-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 200; pointer-events: none; }
  .tour-bubble { position: fixed; z-index: 201; background: white; color: #1a1916; border-radius: 14px; padding: 16px 18px; max-width: 260px; box-shadow: 0 8px 32px rgba(0,0,0,0.25); pointer-events: all; }
  .tour-bubble::before { content: ''; position: absolute; width: 12px; height: 12px; background: white; transform: rotate(45deg); }
  .tour-bubble.arrow-bottom::before { bottom: -6px; left: 50%; margin-left: -6px; }
  .tour-bubble.arrow-top::before { top: -6px; left: 50%; margin-left: -6px; }
  .tour-bubble.arrow-left::before { left: -6px; top: 50%; margin-top: -6px; }
  .tour-title { font-size: 0.85rem; font-weight: 600; color: #1a1916; margin-bottom: 4px; }
  .tour-text { font-size: 0.78rem; color: #6b6660; line-height: 1.5; margin-bottom: 12px; }
  .tour-actions { display: flex; justify-content: space-between; align-items: center; }
  .tour-next { background: #2A9D8F; color: #1a1916; border: none; border-radius: 6px; padding: 6px 14px; font-size: 0.78rem; font-weight: 500; cursor: pointer; }
  .tour-skip { font-size: 0.72rem; color: #6b6660; cursor: pointer; text-decoration: underline; white-space: nowrap; }
  .tour-explore-link { margin-bottom: 12px; }
  .tour-dots { display: flex; gap: 4px; flex-shrink: 0; }
  .tour-dot { width: 6px; height: 6px; border-radius: 50%; background: #e5e5e5; }
  .tour-dot.active { background: #2A9D8F; }
  .tour-highlight { position: fixed; z-index: 200; border-radius: 8px; box-shadow: 0 0 0 4px #2A9D8F, 0 0 0 9999px rgba(0,0,0,0.5); pointer-events: none; transition: all 0.3s ease; }

  /* LOADING */
  .loading-spinner { display: inline-block; width: 18px; height: 18px; border: 2px solid rgba(0,0,0,0.15); border-top-color: currentColor; border-radius: 50%; animation: spin 0.7s linear infinite; }
  @keyframes spin { to{transform:rotate(360deg)} }

  /* PAGE HEADER */
  .page-header { margin-bottom: 18px; }
  .page-header h1 { font-family: 'Playfair Display', serif; font-size: 1.4rem; font-weight: 700; color: var(--cream); }
  .page-header p { font-size: 0.78rem; color: var(--muted); margin-top: 2px; }

  /* FILTER TABS */
  .filter-tabs { display: flex; gap: 6px; margin-bottom: 14px; overflow-x: auto; scrollbar-width: none; }
  .filter-tabs::-webkit-scrollbar { display: none; }
  .filter-tab { padding: 6px 14px; border-radius: 999px; font-size: 0.78rem; font-weight: 400; border: 1px solid var(--border2); color: var(--cream2); background: transparent; cursor: pointer; white-space: nowrap; transition: all 0.15s; }
  .filter-tab.active { background: var(--amber); color: var(--cream); border-color: var(--amber-text); font-weight: 500; }

  /* PRINT STYLES */
  @media print {
    body * { visibility: hidden; }
    #printInvoice, #printInvoice * { visibility: visible; }
    #printInvoice { position: fixed; left: 0; top: 0; width: 100%; padding: 40px; background: white; color: #1a1916; }
    .print-hide { display: none !important; }
  }

  /* PRINT INVOICE */
  #printInvoice { display: none; }
  .inv-print-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 1.5rem; padding-bottom: 1rem; border-bottom: 2px solid var(--brand, #2A9D8F); }
  .inv-print-school-name { font-family: var(--font-header, 'Playfair Display', Georgia, serif); font-weight: 700; font-size: 1.5rem; color: var(--brand-text, var(--brand, #2A9D8F)); margin-bottom: 4px; }
  .inv-print-logo-img { max-height: 44px; object-fit: contain; display: block; margin-bottom: 8px; }
  .inv-print-invoice-label { font-family: var(--font-label, 'DM Sans', sans-serif); font-size: 0.66rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.15em; color: #8a8580; margin-top: 12px; }
  .inv-print-invoice-number { font-family: var(--font-header, 'Playfair Display', Georgia, serif); font-weight: 700; font-size: 1.1rem; color: #1a1916; margin-top: 2px; }
  .inv-print-issued { font-family: var(--font-body, 'DM Sans', sans-serif); font-size: 0.82rem; color: #6b6660; margin-top: 2px; }
  .inv-print-to { text-align: right; }
  .inv-print-to-label { font-family: var(--font-label, 'DM Sans', sans-serif); font-size: 0.66rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.15em; color: #8a8580; margin-bottom: 4px; }
  .inv-print-to-name { font-family: var(--font-header, 'Playfair Display', Georgia, serif); font-weight: 700; font-size: 1rem; color: #1a1916; }
  .inv-print-to-sub { font-family: var(--font-body, 'DM Sans', sans-serif); font-size: 0.82rem; color: #6b6660; margin-top: 2px; }
  .inv-print-table { width: 100%; border-collapse: collapse; margin-bottom: 1.25rem; font-family: var(--font-body, 'DM Sans', sans-serif); }
  .inv-print-table th { text-align: left; font-family: var(--font-label, 'DM Sans', sans-serif); font-size: 0.66rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.13em; color: #8a8580; padding: 8px 0; border-bottom: 2px solid var(--brand, #2A9D8F); }
  .inv-print-table th:not(:first-child) { text-align: right; }
  .inv-print-table td { padding: 10px 0; border-bottom: 1px solid #eee; font-size: 0.92rem; color: #1a1916; vertical-align: top; }
  .inv-print-table td:not(:first-child) { text-align: right; }
  .inv-print-table td small { display: block; font-size: 0.75rem; color: #6b6660; margin-top: 2px; }
  .inv-print-table tbody tr:last-child td { border-bottom: 2px solid var(--brand, #2A9D8F); }
  .inv-print-totals { width: 260px; margin-left: auto; margin-bottom: 1.5rem; font-family: var(--font-body, 'DM Sans', sans-serif); }
  .inv-print-total-row { display: flex; justify-content: space-between; font-size: 0.88rem; color: #6b6660; padding: 5px 0; }
  .inv-print-total-row.discount { color: #2e7d5a; }
  .inv-print-total-row.grand { font-size: 1.05rem; font-weight: 700; padding-top: 7px; }
  .inv-print-total-row.grand span:first-child { color: #1a1916; }
  .inv-print-total-row.grand span:last-child { color: var(--brand-text, var(--brand, #2A9D8F)); }
  .inv-print-bank { border: 1px solid var(--brand, #2A9D8F); border-radius: 8px; margin-bottom: 1.25rem; overflow: hidden; background: color-mix(in srgb, var(--brand, #2A9D8F) 5%, transparent); }
  .inv-print-bank-title { font-family: var(--font-label, 'DM Sans', sans-serif); font-size: 0.66rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.13em; color: #8a8580; padding: 9px 16px; }
  .inv-print-bank-row { display: flex; justify-content: space-between; padding: 8px 16px; border-top: 1px solid #eee; font-size: 0.85rem; font-family: var(--font-body, 'DM Sans', sans-serif); }
  .inv-print-bank-row .label { color: #6b6660; }
  .inv-print-bank-row .value { color: var(--brand-text, var(--brand, #2A9D8F)); font-weight: 600; }
  .inv-print-footer { font-family: var(--font-body, 'DM Sans', sans-serif); text-align: center; font-size: 0.75rem; color: #6b6660; border-top: 1px solid #e5e5e5; padding-top: 0.85rem; }
/* ── IMPORT & ONBOARDING ── */
.input-prefix-wrap {
  display: flex;
  align-items: center;
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  overflow: hidden;
}
.input-prefix {
  padding: 0.5rem 0.6rem;
  background: var(--bg3);
  color: var(--muted);
  font-size: 0.9rem;
  border-right: 1px solid var(--border2);
  flex-shrink: 0;
}
.input-prefix-wrap .form-input {
  border: none;
  border-radius: 0;
  flex: 1;
}
/* ── DESKTOP MODAL POSITIONING ── */
@media (min-width: 600px) {
  .modal-overlay {
    align-items: center;
  }
  .modal {
    border-radius: 16px;
    max-height: 80vh;
  }
}
/* FORM INPUTS */
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 0.78rem; color: var(--cream2); margin-bottom: 6px; font-weight: 400; }
.form-input {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 10px 12px;
  color: var(--cream);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  font-weight: 300;
  outline: none;
  transition: border-color 0.2s;
  -webkit-appearance: none;
}
.form-input:focus { border-color: var(--amber-border); }
.form-input:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
.form-input::placeholder { color: var(--muted); }
.form-input:-webkit-autofill {
  -webkit-box-shadow: 0 0 0px 1000px var(--bg3) inset;
  -webkit-text-fill-color: var(--cream);
}
.form-error { display: none; background: var(--red-bg); border: 1px solid rgba(192,57,43,0.3); border-radius: var(--radius); padding: 10px 12px; font-size: 0.8rem; color: #a83226; margin-top: 6px; }

/* ── DESKTOP LAYOUT ──
   Below 700px the app is untouched — that's where almost everyone is. At
   700px+ the content column is capped and centred instead of stretching
   edge to edge; the header/bottom-nav backgrounds stay full width but their
   contents line up with that same column. */
@media (min-width: 700px) {
  .app-content .view { max-width: var(--app-max); margin: 0 auto; }

  .app-header { padding-left: max(16px, calc((100vw - var(--app-max)) / 2)); padding-right: max(16px, calc((100vw - var(--app-max)) / 2)); }

  .bottom-nav { max-width: var(--app-max); margin: 0 auto; border-radius: 16px 16px 0 0; }

  .stat-grid { grid-template-columns: repeat(4, 1fr); }

  .fab { right: max(20px, calc((100vw - var(--app-max)) / 2 + 20px)); }

  /* Timetable week view (7 columns) is cramped at 960px — let it breathe
     without widening every other view on the page. */
  #classesSubtabTimetable { max-width: 1200px; width: 100vw; position: relative; left: 50%; transform: translateX(-50%); }
}
