/* LoomiTV — client dashboard styles (standalone theme system)
   Architecture: tokens/reset → layout → sidebar → topbar → cards →
   buttons → badges → timeline/lists → forms → tables → knowledge base →
   messages → utilities → responsive. */

/* ===== TOKENS / RESET ===== */
:root{
    --success:#3E8F72; --info:#2E5FA8; --warning:#E3A63E; --danger:#C6342A;
    --radius:14px; --radius-sm:8px;
    --shadow-card:0 1px 2px rgba(0,0,0,0.3), 0 10px 24px -10px rgba(0,0,0,0.45);
    --shadow-hover:0 1px 2px rgba(0,0,0,0.3), 0 20px 36px -12px rgba(0,0,0,0.5);
    --sidebar-w:264px;
  }
  [data-theme="light"]{
    --bg:#F3ECDD; --bg-warm:#EAE0C9; --bg-deep:#EDE4D2; --bg-card:#FFFFFF;
    --fg:#1C1420; --muted:#6E6480; --muted-2:#8C82A0;
    --line:rgba(28,20,32,0.1); --line-strong:rgba(28,20,32,0.18);
  }
  *{box-sizing:border-box; margin:0; padding:0;}
  .skip-link{
    position:absolute; top:-100px; left:12px; z-index:1000;
    background:var(--gold); color:#241802; font-weight:700; font-size:13.5px;
    padding:10px 18px; border-radius:var(--radius-sm); transition:top .2s ease;
  }
  .skip-link:focus{ top:12px; }
  body{
    background:var(--bg); color:var(--fg);
    font-family:'Inter', sans-serif; line-height:1.5;
    -webkit-font-smoothing:antialiased;
    transition:background .3s ease, color .3s ease;
  }
  img,svg{display:block;}
  a{color:inherit; text-decoration:none;}
  ul{list-style:none;}
  button{font-family:inherit; cursor:pointer;}
  input,select,textarea{font-family:inherit;}
  h1,h2,h3,h4{ font-family:'Fraunces', serif; font-weight:600; letter-spacing:-0.01em; }
  ::-webkit-scrollbar{ width:8px; height:8px; }
  ::-webkit-scrollbar-thumb{ background:var(--line-strong); border-radius:10px; }
  *{ scrollbar-width:thin; scrollbar-color:var(--line-strong) transparent; }
  :focus-visible{ outline:2px solid var(--gold); outline-offset:2px; }

  /* ===== LAYOUT ===== */
  .app{ display:flex; min-height:100vh; }

  /* ===== SIDEBAR ===== */
  .sidebar{
    width:var(--sidebar-w); flex-shrink:0;
    background:var(--bg-deep); border-right:1px solid var(--line);
    display:flex; flex-direction:column;
    position:fixed; top:0; left:0; bottom:0; z-index:50;
    transition:transform .3s ease, width .3s ease;
  }
  .sidebar-head{ padding:26px 24px 20px; border-bottom:1px solid var(--line); transition:padding .3s ease; }
  .sb-logo{ display:inline-flex; font-family:'Fraunces', serif; font-weight:700; font-size:21px; cursor:pointer; }
  .sb-logo:hover{ opacity:.85; }
  .sb-logo::after{ content:'.'; color:var(--gold); }
  /* The topbar's own logo instance (mobile header, ≤768px only — see the
     LOCKED mobile block below) — hidden here, shown there. Same .sb-logo
     markup/href as the sidebar logo, not a second implementation. */
  .topbar-logo{ display:none; }
  .sidebar-nav{ flex:1; overflow-y:auto; padding:18px 14px; }
  .nav-group{ margin-bottom:22px; }
  .nav-group-label{
    font-family:'Inter',sans-serif; font-weight:600; font-size:10.5px; letter-spacing:0.1em;
    text-transform:uppercase; color:var(--muted-2); padding:0 12px 8px;
  }
  .nav-item{
    display:flex; align-items:center; gap:12px;
    padding:10px 12px; border-radius:var(--radius-sm);
    font-size:13.5px; font-weight:500; color:var(--muted);
    transition:background .2s ease, color .2s ease;
    position:relative;
  }
  .nav-item svg{ width:17px; height:17px; stroke:currentColor; flex-shrink:0; }
  .nav-item:hover{ background:rgba(255,255,255,0.04); color:var(--fg); }
  .nav-item.active{ background:rgba(227,166,62,0.12); color:var(--gold); }
  .nav-item .nav-badge{
    margin-left:auto; background:var(--crimson); color:#fff;
    font-size:10px; font-weight:700; padding:2px 6px; border-radius:20px;
  }
  .sidebar-foot{ padding:16px; border-top:1px solid var(--line); }
  .user-card{
    display:flex; align-items:center; gap:10px; padding:8px;
    border-radius:var(--radius-sm); cursor:pointer; transition:background .2s ease;
  }
  .user-card:hover{ background:rgba(255,255,255,0.04); }
  .avatar{
    width:34px; height:34px; border-radius:50%; flex-shrink:0;
    background:linear-gradient(135deg, var(--gold), var(--crimson));
    display:flex; align-items:center; justify-content:center;
    font-family:'Fraunces',serif; font-weight:700; font-size:13px; color:#fff;
  }
  .avatar-lg{ width:72px; height:72px; font-size:24px; margin:0 auto 16px; }
  .avatar-md{ width:60px; height:60px; font-size:20px; }
  .user-card .u-meta{ min-width:0; }
  .u-name{ font-size:13px; font-weight:600; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
  .u-plan{ font-size:11.5px; color:var(--muted-2); }

  .sidebar-toggle{ display:none; }

  /* ===== TOPBAR ===== */
  .main{ flex:1; margin-left:var(--sidebar-w); min-width:0; transition:margin-left .3s ease; }
  .topbar{
    position:sticky; top:0; z-index:40;
    display:flex; align-items:center; justify-content:space-between; gap:20px;
    padding:18px 32px; background:rgba(21,15,26,0.85); -webkit-backdrop-filter:blur(10px); backdrop-filter:blur(10px);
    border-bottom:1px solid var(--line);
  }
  [data-theme="light"] .topbar{ background:rgba(243,236,221,0.85); }
  .topbar-left{ display:flex; align-items:center; gap:14px; }
  .topbar-title{ font-family:'Fraunces',serif; font-weight:600; font-size:22px; }
  .topbar-right{ display:flex; align-items:center; gap:14px; }
  .search-wrap{ position:relative; }
  .search-box{
    display:flex; align-items:center; gap:8px;
    background:var(--bg-card); border:1px solid var(--line); border-radius:20px;
    padding:8px 14px; width:220px;
  }
  .search-box-lg{ width:100%; max-width:480px; margin-bottom:28px; padding:12px 16px; }
  .search-box svg{ width:15px; height:15px; stroke:var(--muted-2); flex-shrink:0; }
  .search-box input{ background:none; border:none; color:var(--fg); font-size:13px; width:100%; }
  .search-box input:focus{ outline:none; }
  .search-results{
    position:absolute; top:calc(100% + 8px); left:0; right:0; z-index:60;
    background:var(--bg-card); border:1px solid var(--line); border-radius:var(--radius-sm);
    box-shadow:var(--shadow-hover); max-height:320px; overflow-y:auto; padding:6px;
  }
  .search-results[hidden]{ display:none; }
  .search-result-item{
    display:flex; align-items:center; gap:10px; width:100%; text-align:left;
    padding:9px 10px; border-radius:var(--radius-sm); font-size:13px;
    background:none; border:none; color:var(--fg); cursor:pointer;
  }
  .search-result-item svg{ width:15px; height:15px; stroke:var(--muted-2); flex-shrink:0; }
  .search-result-item:hover, .search-result-item:focus-visible{ background:rgba(255,255,255,0.06); }
  .search-result-empty{ padding:14px 10px; color:var(--muted-2); font-size:12.5px; text-align:center; }
  .icon-btn{
    width:38px; height:38px; border-radius:50%; background:var(--bg-card);
    border:1px solid var(--line); display:flex; align-items:center; justify-content:center;
    position:relative; color:var(--muted); transition:all .2s ease;
  }
  /* Invisible hit-area expansion — brings the ~38px icon buttons closer to the ~44px recommended tap target without resizing them */
  .icon-btn::before{ content:''; position:absolute; inset:-4px; }
  .icon-btn:hover{ color:var(--fg); border-color:var(--line-strong); }
  .icon-btn svg{ width:17px; height:17px; }
  .icon-btn .dot{
    position:absolute; top:8px; right:8px; width:7px; height:7px; border-radius:50%;
    background:var(--crimson); border:1.5px solid var(--bg-deep);
  }
  .notif-wrap, .avatar-wrap{ position:relative; display:flex; align-items:center; }
  button.avatar{ border:none; padding:0; font:inherit; }

  /* Shared dropdown panel — notifications, account menu */
  .dropdown-panel{
    position:absolute; top:calc(100% + 10px); right:0; z-index:60;
    background:var(--bg-card); border:1px solid var(--line); border-radius:var(--radius);
    box-shadow:var(--shadow-hover); padding:8px; min-width:230px;
    animation:fxDropdownIn .16s ease;
  }
  .dropdown-panel[hidden]{ display:none; }
  @keyframes fxDropdownIn{ from{ opacity:0; transform:translateY(-6px); } to{ opacity:1; transform:translateY(0); } }
  .dropdown-header{
    padding:10px 12px 12px; font-size:12.5px; font-weight:600; color:var(--muted-2);
    border-bottom:1px solid var(--line); margin-bottom:6px;
  }
  .dropdown-header strong{ display:block; color:var(--fg); font-size:13.5px; margin-bottom:2px; }
  .dropdown-item{
    display:flex; align-items:center; gap:10px; width:100%; text-align:left;
    padding:10px 12px; border-radius:var(--radius-sm); font-size:13.5px; font-weight:500;
    color:var(--fg); background:none; border:none; cursor:pointer; transition:background .15s ease;
  }
  .dropdown-item:hover, .dropdown-item:focus-visible{ background:rgba(255,255,255,0.06); }
  .dropdown-item svg{ width:16px; height:16px; stroke:currentColor; flex-shrink:0; }
  .dropdown-item.danger{ color:#E06256; }
  .dropdown-divider{ height:1px; background:var(--line); margin:6px 4px; }
  .dropdown-empty{ padding:20px 14px; text-align:center; color:var(--muted-2); font-size:13px; }
  .dropdown-empty svg{ width:26px; height:26px; margin:0 auto 10px; stroke:var(--muted-2); }
  .content{ padding:32px; max-width:1280px; }
  .view{ display:none; animation:fadeUp .45s ease; }
  .view.active{ display:block; }
  @keyframes fadeUp{ from{ opacity:0; transform:translateY(10px);} to{ opacity:1; transform:translateY(0);} }

  /* ===== CARDS & GRIDS ===== */
  .grid{ display:grid; gap:20px; }
  .grid-4{ grid-template-columns:repeat(4,1fr); }
  .grid-3{ grid-template-columns:repeat(3,1fr); }
  .grid-2{ grid-template-columns:repeat(2,1fr); }
  .grid-dash{ grid-template-columns:1.3fr 1fr; }
  .grid-account{ grid-template-columns:1fr 2fr; }
  .grid-rewards{ grid-template-columns:1.2fr 1fr; }
  .card{
    background:var(--bg-card); border:1px solid var(--line); border-radius:var(--radius);
    padding:26px; box-shadow:var(--shadow-card);
    transition:box-shadow .25s ease, transform .25s ease, border-color .25s ease;
  }
  a.card:hover, .kb-cat:hover{ box-shadow:var(--shadow-hover); transform:translateY(-2px); border-color:var(--line-strong); }
  .card-head{ display:flex; align-items:center; justify-content:space-between; margin-bottom:18px; }
  .card-head h3{ font-size:16px; font-weight:600; }
  .card-head .muted-link{ font-size:12.5px; color:var(--muted-2); font-weight:500; }
  .card-head .muted-link:hover{ color:var(--gold); }
  .card-danger{ border-color:rgba(198,52,42,0.3); }
  .section-title{ margin-bottom:6px; font-size:26px; }
  .section-sub{ color:var(--muted); font-size:14px; margin-bottom:28px; }

  .stat-card{ padding:22px; }
  .stat-label{ font-size:12px; color:var(--muted-2); font-weight:500; margin-bottom:10px; }
  .stat-value{ font-family:'Fraunces',serif; font-weight:700; font-size:28px; }
  .stat-delta{ font-size:12px; margin-top:8px; display:flex; align-items:center; gap:4px; }
  .stat-delta.up{ color:var(--success); }
  .stat-delta.flat{ color:var(--muted-2); }

  /* Ticket-styled subscription card — brand signature carried from the landing page */
  .ticket-card{
    background:var(--light); color:var(--fg-on-light); border-radius:10px;
    padding:28px; position:relative;
  }
  .ticket-card::before, .ticket-card::after{
    content:''; position:absolute; width:22px; height:22px; background:var(--bg);
    border-radius:50%; top:50%; transform:translateY(-50%);
  }
  .ticket-card::before{ left:-11px; } .ticket-card::after{ right:-11px; }
  .ticket-top{ display:flex; justify-content:space-between; align-items:flex-start; border-bottom:2px dashed var(--line-on-light); padding-bottom:16px; margin-bottom:16px; }
  .ticket-eyebrow{ font-size:11px; font-weight:600; letter-spacing:0.12em; text-transform:uppercase; color:var(--muted-2); }
  .ticket-plan{ font-family:'Fraunces',serif; font-size:24px; font-weight:600; margin-top:4px; }
  .ticket-code{ font-family:'IBM Plex Mono',monospace; font-size:11.5px; color:var(--crimson); }
  .ticket-card .row{ display:flex; justify-content:space-between; padding:8px 0; font-size:13px; }
  .ticket-card .row span:first-child{ color:var(--muted-2); }
  .ticket-card .row span:last-child{ font-weight:600; }
  .ticket-actions{ display:flex; gap:10px; margin-top:18px; }
  .barcode{ margin-top:14px; height:28px; opacity:0.7;
    background:repeating-linear-gradient(90deg, var(--fg-on-light) 0 2px, transparent 2px 5px, var(--fg-on-light) 5px 6px, transparent 6px 10px); }

  /* Plan price display (Subscription) */
  .price-display{ font-family:'Fraunces',serif; font-size:36px; font-weight:700; margin-bottom:4px; }
  .price-display .price-suffix{ font-size:14px; color:var(--muted-2); font-weight:400; }

  /* Billing-cycle segmented control (Subscription) */
  .segmented{ display:flex; border:1px solid var(--line-strong); border-radius:var(--radius-sm); overflow:hidden; margin-bottom:24px; }
  .cycle-opt{ flex:1; padding:12px; font-size:13px; font-weight:600; background:transparent; color:var(--muted); border:none; }
  .cycle-opt:not(:first-child){ border-left:1px solid var(--line-strong); }
  .cycle-opt.active{ background:var(--gold); color:#241802; }

  .field-caption{ display:flex; justify-content:space-between; margin-bottom:8px; font-size:12.5px; color:var(--muted); }
  .progress-caption{ display:flex; justify-content:space-between; font-size:11.5px; color:var(--muted-2); margin-bottom:24px; }
  .plan-actions{ display:flex; gap:10px; }

  /* Launch-stage Stripe self-serve restriction (js/dashboard.js's
     STRIPE_SELF_SERVE_ENABLED) — the small note that replaces a hidden
     Subscribe/Switch plan/Update payment method button. */
  .purchase-restriction-notice{ margin-top:10px; }
  .purchase-restriction-notice a{ color:var(--gold); font-weight:600; cursor:pointer; }
  .purchase-restriction-notice a:hover{ text-decoration:underline; }

  /* Extra-connection stepper (Subscription) */
  .stepper-btn{ width:34px; padding:0; justify-content:center; }
  .stepper-count{ font-family:'Fraunces',serif; font-weight:700; font-size:20px; width:20px; text-align:center; }

  /* Payment method swatch (Billing) */
  .payment-swatch{ width:48px; height:34px; border-radius:6px; background:linear-gradient(135deg,var(--gold),var(--crimson)); flex-shrink:0; }

  /* Referral link box (Rewards) */
  .ref-link-box{ flex:1; min-width:220px; background:var(--bg-warm); border:1px solid var(--line-strong); border-radius:var(--radius-sm); padding:12px 16px; font-family:'IBM Plex Mono',monospace; font-size:13px; color:var(--muted); }

  /* Contact-method cards (Support Center) */
  .contact-card{ text-align:center; }
  .contact-card svg{ width:26px; height:26px; margin:0 auto 14px; }
  .contact-card h3{ margin-bottom:8px; font-size:16px; }
  .contact-card p{ color:var(--muted); font-size:13px; margin-bottom:16px; }

  /* Toggle / switch rows (Security, Settings) */
  .switch-row{ display:flex; align-items:center; justify-content:space-between; }
  .switch-row:not(:last-child){ margin-bottom:18px; }
  .text-label{ font-weight:600; font-size:13.5px; }
  .toggle-row{ display:flex; align-items:center; justify-content:space-between; padding:12px 0; border-bottom:1px solid var(--line); }
  .toggle-row:last-child{ border-bottom:none; }

  /* ===== BUTTONS ===== */
  .btn{
    display:inline-flex; align-items:center; gap:8px;
    font-weight:600; font-size:13.5px; padding:11px 20px;
    border-radius:var(--radius-sm); border:1px solid var(--line-strong);
    background:transparent; color:var(--fg); transition:all .2s ease;
  }
  .btn:hover{ border-color:var(--fg); background:rgba(255,255,255,0.04); }
  .btn-primary{ background:var(--crimson); border-color:var(--crimson); color:#fff; }
  .btn-primary:hover{ background:#A9291F; border-color:#A9291F; }
  .btn-gold{ background:var(--gold); border-color:var(--gold); color:#241802; }
  .btn-gold:hover{ filter:brightness(1.06); }
  .btn-sm{ padding:7px 14px; font-size:12.5px; }
  .btn svg{ width:14px; height:14px; }
  .btn.active{ background:var(--gold); border-color:var(--gold); color:#241802; }
  .btn-block{ flex:1; justify-content:center; }
  .btn-danger-outline{ border-color:var(--crimson); color:#E06256; }

  /* ===== BADGES ===== */
  .badge{
    display:inline-flex; align-items:center; gap:5px;
    font-size:11px; font-weight:600; padding:4px 10px; border-radius:20px;
  }
  .badge-success{ background:rgba(62,143,114,0.16); color:#5FBA97; }
  .badge-warning{ background:rgba(227,166,62,0.16); color:var(--gold); }
  .badge-danger{ background:rgba(198,52,42,0.16); color:#E06256; }
  .badge-info{ background:rgba(46,95,168,0.16); color:#6D9BE0; }
  .badge-muted{ background:rgba(255,255,255,0.06); color:var(--muted); }

  /* ===== TABLES (legacy — kept for any future table-based view) ===== */
  .table{ width:100%; border-collapse:collapse; }
  .table th{
    text-align:left; font-size:11px; letter-spacing:0.06em; text-transform:uppercase;
    color:var(--muted-2); font-weight:600; padding:0 14px 12px; border-bottom:1px solid var(--line);
  }
  .table td{ padding:16px 14px; border-bottom:1px solid var(--line); font-size:13.5px; }
  .table tr:last-child td{ border-bottom:none; }
  .table tr{ transition:background .2s ease; }
  .table tbody tr:hover{ background:rgba(255,255,255,0.02); }
  .mono{ font-family:'IBM Plex Mono', monospace; font-size:12.5px; color:var(--muted); }

  /* ===== TIMELINE / TRANSACTION / LIST ROWS ===== */
  .timeline{ position:relative; padding-left:26px; }
  .timeline::before{ content:''; position:absolute; left:6px; top:8px; bottom:8px; width:2px; background:var(--line); }
  .timeline-item{ position:relative; padding-bottom:16px; }
  .timeline-item:last-child{ padding-bottom:0; }
  .timeline-dot{ position:absolute; left:-26px; top:18px; width:14px; height:14px; border-radius:50%; background:var(--bg-card); border:2px solid var(--gold); }
  .timeline-item.is-muted .timeline-dot{ border-color:var(--muted-2); }
  .tx-card{
    background:var(--bg-warm); border:1px solid var(--line); border-radius:12px;
    padding:16px 20px; display:flex; align-items:center; justify-content:space-between; gap:16px;
    transition:border-color .2s ease, transform .2s ease;
  }
  .tx-card:hover{ border-color:var(--line-strong); transform:translateX(2px); }
  .tx-card-current{ border-color:var(--gold); }
  .tx-left{ display:flex; align-items:center; gap:14px; min-width:0; }
  .tx-icon{ width:38px; height:38px; border-radius:10px; background:var(--bg-deep); display:flex; align-items:center; justify-content:center; flex-shrink:0; }
  .tx-icon-gold{ background:rgba(227,166,62,0.14); }
  .tx-icon svg{ width:16px; height:16px; stroke:var(--gold); }
  .tx-title{ font-size:13.5px; font-weight:600; }
  .tx-sub{ font-size:12px; color:var(--muted-2); margin-top:2px; }
  .tx-right{ display:flex; align-items:center; gap:14px; flex-shrink:0; }
  .tx-amount{ font-family:'IBM Plex Mono', monospace; font-size:13px; font-weight:600; }

  .progress{ height:6px; background:var(--line); border-radius:10px; overflow:hidden; }
  .progress-bar{ height:100%; background:linear-gradient(90deg, var(--gold), var(--crimson)); border-radius:10px; }

  .switch{ position:relative; display:inline-block; width:42px; height:24px; flex-shrink:0; }
  .switch input{ opacity:0; width:0; height:0; }
  .slider{ position:absolute; inset:0; background:var(--line-strong); border-radius:24px; transition:.25s; }
  .slider::before{ content:''; position:absolute; width:18px; height:18px; left:3px; top:3px; background:#fff; border-radius:50%; transition:.25s; }
  .switch input:checked + .slider{ background:var(--gold); }
  .switch input:checked + .slider::before{ transform:translateX(18px); }

  .list-row{
    display:flex; align-items:center; gap:14px; padding:14px 0; border-bottom:1px solid var(--line);
  }
  .list-row:last-child{ border-bottom:none; }
  .list-row-plain{ border:none; padding:6px 0; }
  .list-icon{
    width:38px; height:38px; border-radius:50%; flex-shrink:0;
    display:flex; align-items:center; justify-content:center; background:var(--bg-warm);
  }
  .list-icon-plain{ width:24px; height:24px; background:none; }
  .list-icon svg{ width:16px; height:16px; stroke:var(--gold); }
  .list-body{ flex:1; min-width:0; }
  .list-title{ font-size:13.5px; font-weight:600; }
  .list-sub{ font-size:12px; color:var(--muted-2); margin-top:2px; }
  .list-time{ font-size:11.5px; color:var(--muted-2); white-space:nowrap; }

  /* ===== FORMS ===== */
  .field{ margin-bottom:18px; }
  .field label{ display:block; font-size:12.5px; font-weight:600; color:var(--muted); margin-bottom:8px; }
  .field input, .field select, .field textarea{
    width:100%; background:var(--bg-warm); border:1px solid var(--line-strong); border-radius:var(--radius-sm);
    padding:11px 14px; color:var(--fg); font-size:13.5px;
  }
  .field input:focus, .field select:focus, .field textarea:focus{ outline:none; border-color:var(--gold); }
  .field-row{ display:grid; grid-template-columns:1fr 1fr; gap:16px; }

  .empty-state{ text-align:center; padding:60px 20px; color:var(--muted-2); }
  .empty-state svg{ width:40px; height:40px; margin:0 auto 16px; stroke:var(--muted-2); }

  /* ===== KNOWLEDGE BASE ===== */
  .kb-cat{
    padding:22px; cursor:pointer; transition:border-color .2s ease, transform .2s ease;
    appearance:none; -webkit-appearance:none; text-align:left; width:100%; font:inherit; color:inherit;
  }
  .kb-cat:hover{ border-color:var(--gold); transform:translateY(-3px); }
  .kb-cat.active{ border-color:var(--gold); box-shadow:var(--shadow-hover); }
  .kb-cat svg{ width:22px; height:22px; stroke:var(--gold); margin-bottom:14px; }
  .kb-cat h3{ font-size:15px; }
  .kb-cat p{ color:var(--muted-2); font-size:12.5px; margin-top:6px; }

  .kb-article-btn{
    display:flex; align-items:center; gap:14px; width:100%; text-align:left;
    padding:14px 0; border-bottom:1px solid var(--line);
    background:none; border-left:none; border-right:none; border-top:none;
    font:inherit; color:inherit; cursor:pointer;
  }
  .kb-item:last-child .kb-article-btn{ border-bottom:none; }
  .kb-article-chevron{ margin-left:auto; width:15px; height:15px; stroke:var(--muted-2); flex-shrink:0; transition:transform .2s ease; }
  .kb-article-btn[aria-expanded="true"] .kb-article-chevron{ transform:rotate(90deg); }
  .kb-answer{ display:none; padding:0 0 16px 52px; color:var(--muted); font-size:13px; }
  .kb-answer.open{ display:block; }
  .kb-empty{ padding:18px 0; color:var(--muted-2); font-size:13px; }

  /* ===== MESSAGES ===== */
  .filter-row{ display:flex; gap:8px; margin-bottom:20px; }
  .msg-layout{ display:grid; grid-template-columns:300px 1fr; gap:0; border:1px solid var(--line); border-radius:var(--radius); overflow:hidden; height:560px; }
  .msg-list{ border-right:1px solid var(--line); overflow-y:auto; }
  .msg-thread-item{ display:flex; gap:12px; padding:16px 18px; border-bottom:1px solid var(--line); cursor:pointer; transition:background .2s ease; }
  .msg-thread-item:hover, .msg-thread-item.active{ background:rgba(255,255,255,0.04); }
  .msg-panel{ display:flex; flex-direction:column; }
  .msg-panel-head{ padding:18px 22px; border-bottom:1px solid var(--line); font-weight:600; }
  .msg-body{ flex:1; padding:22px; overflow-y:auto; display:flex; flex-direction:column; gap:14px; }
  .bubble{ max-width:70%; padding:12px 16px; border-radius:14px; font-size:13.5px; }
  .bubble.them{ background:var(--bg-warm); align-self:flex-start; border-bottom-left-radius:4px; }
  .bubble.me{ background:var(--crimson); color:#fff; align-self:flex-end; border-bottom-right-radius:4px; }
  .msg-input{ display:flex; gap:10px; padding:16px; border-top:1px solid var(--line); }
  .msg-input input{ flex:1; background:var(--bg-warm); border:1px solid var(--line-strong); border-radius:20px; padding:11px 16px; color:var(--fg); }
  .msg-input input:focus{ outline:none; border-color:var(--gold); }

  /* ===== UTILITIES =====
     Small, generic, single-purpose classes for one-off presentational
     values that don't warrant a named component. Every value here maps
     1:1 to a former inline style — none are new/invented spacing. */
  .is-clickable{ cursor:pointer; }
  .text-center{ text-align:center; }
  .text-muted{ color:var(--muted); }
  .text-muted-2{ color:var(--muted-2); }
  .text-sub{ font-size:12px; color:var(--muted-2); }
  .text-success{ color:#5FBA97; }
  .text-status-active{ color:#2E8F5F; }
  .text-gold{ color:var(--gold); }
  .text-danger{ color:#E06256; }
  .text-11-5{ font-size:11.5px; }
  .text-12{ font-size:12px; }
  .text-12-5{ font-size:12.5px; }
  .text-13{ font-size:13px; }
  .text-14{ font-size:14px; }
  .text-18{ font-size:18px; }
  .text-sm{ font-size:13.5px; }
  .icon-sm{ width:16px; height:16px; }
  .font-weight-600{ font-weight:600; }
  .opacity-50{ opacity:0.5; }
  .max-w-480{ max-width:480px; }
  .max-w-520{ max-width:520px; }
  .max-w-640{ max-width:640px; }
  .ml-6{ margin-left:6px; }
  .mb-0{ margin-bottom:0; }
  .mb-4{ margin-bottom:4px; }
  .mb-6{ margin-bottom:6px; }
  .mb-8{ margin-bottom:8px; }
  .mb-10{ margin-bottom:10px; }
  .mb-14{ margin-bottom:14px; }
  .mb-16{ margin-bottom:16px; }
  .mb-18{ margin-bottom:18px; }
  .mb-20{ margin-bottom:20px; }
  .mb-22{ margin-bottom:22px; }
  .mb-24{ margin-bottom:24px; }
  .mb-28{ margin-bottom:28px; }
  .mt-20{ margin-top:20px; }
  .flex{ display:flex; }
  .flex-col{ display:flex; flex-direction:column; }
  .items-center{ align-items:center; }
  .items-start{ align-items:flex-start; }
  .justify-between{ justify-content:space-between; }
  .justify-center{ justify-content:center; }
  .justify-start{ justify-content:flex-start; }
  .flex-wrap{ flex-wrap:wrap; }
  .gap-8{ gap:8px; }
  .gap-10{ gap:10px; }
  .gap-14{ gap:14px; }
  .gap-16{ gap:16px; }
  .w-full{ width:100%; }

  /* ===== RESPONSIVE ===== */

  /* Desktop sidebar collapse — distinct from the ≤980px mobile drawer
     below (same #sidebarToggle button, different behavior per viewport,
     decided in dashboard.js by matchMedia). Shows the hamburger button
     on desktop too (it's hidden by default at .sidebar-toggle{display:
     none} above) and shrinks the sidebar to an icon rail rather than
     sliding it off-canvas. */
  @media (min-width:981px){
    .sidebar-toggle{ display:flex; }
    .sidebar.collapsed{ width:76px; }
    .sidebar.collapsed + .main{ margin-left:76px; }
    .sidebar.collapsed .sidebar-head{ display:flex; justify-content:center; padding:26px 10px 20px; }
    .sidebar.collapsed .sb-logo-text{ display:none; }
    .sidebar.collapsed .nav-group-label{ display:none; }
    .sidebar.collapsed .nav-item{ justify-content:center; padding:10px; }
    .sidebar.collapsed .nav-item span, .sidebar.collapsed .nav-item .coming-soon-badge{ display:none; }
    .sidebar.collapsed .user-card{ justify-content:center; }
    .sidebar.collapsed .u-meta{ display:none; }
    .sidebar.collapsed #logoutBtn{ padding:11px; justify-content:center; }
    .sidebar.collapsed #logoutBtn .btn-label{ display:none; }
  }

  @media (max-width:980px){
    .sidebar{ transform:translateX(-100%); box-shadow:0 0 60px rgba(0,0,0,0.5); }
    .sidebar.open{ transform:translateX(0); }
    .main{ margin-left:0; }
    .sidebar-toggle{ display:flex; }
    .grid-4, .grid-3{ grid-template-columns:repeat(2,1fr); }
    .field-row{ grid-template-columns:1fr; }
    .search-box{ display:none; }
    .msg-layout{ grid-template-columns:1fr; height:auto; }
    .msg-list{ max-height:220px; border-right:none; border-bottom:1px solid var(--line); }
    .content{ padding:20px; }
  }
  @media (max-width:560px){
    .grid-4, .grid-3, .grid-2{ grid-template-columns:1fr; }
  }

  /* ======================================================================
     CLIENT PORTAL — dedicated mobile redesign (≤768px). LOCKED — do not
     modify or redesign without explicit request. Everything above this
     point (including the ≤980px/≤560px tablet blocks) is untouched, and
     none of it is overridden here except where explicitly noted.
     Some inline `style="grid-template-columns:..."` attributes in
     dashboard.html carry higher specificity than any external stylesheet
     rule, so a couple of overrides below use !important — that is the
     only way to collapse those layouts on mobile without touching the
     shared HTML that desktop also renders from.
     ====================================================================== */
  @media (max-width:768px){

    /* ---- Foundation ---- */
    .content{ padding:16px; }
    .card{ padding:20px; }

    /* Every grid-based layout (stat rows, the Recent-activity/Access-card
       pair, plan/billing-cycle columns, account/billing/security columns,
       contact-method and knowledge-base rows) collapses to one full-width
       column. Source order in the HTML already puts Recent activity before
       the Access card, so it naturally lands above it once stacked. */
    .grid{ grid-template-columns:1fr !important; }

    /* ---- Navigation drawer ---- */
    body.drawer-open{ overflow:hidden; }
    body.drawer-open::after{
      content:''; position:fixed; inset:0; z-index:45;
      background:rgba(0,0,0,0.55);
      animation:fxDrawerBackdropIn .25s ease;
    }

    /* ---- Header ---- */
    .topbar{ padding:14px 16px; gap:10px; }
    #topbarTitle{ display:none; }
    /* Was a ::after{content:'Flixtele'} pseudo-element here — CSS-generated
       content can't be a real link (no href, no click handler, not
       focusable). Replaced with a real .topbar-logo instance of the same
       .sb-logo anchor used everywhere else, just shown here instead. */
    .topbar-logo{ display:inline-flex; }
    #themeToggle{ display:none; }

    /* ---- Buttons & form controls: consistent ≥44px touch targets ---- */
    .btn{ padding:13px 20px; }
    .btn-sm{ padding:10px 16px; }
    .field input, .field select, .field textarea{ padding:13px 14px; }

    /* ---- Transaction / timeline cards (Billing, Orders, Invoices,
       Security sessions, Rewards payouts, plan comparison) — wrap instead
       of overflowing, and drop any trailing button to its own full-width
       line beneath the amount/badge. ---- */
    .tx-card{ flex-wrap:wrap; row-gap:12px; }
    .tx-right{ flex-basis:100%; flex-wrap:wrap; justify-content:space-between; row-gap:10px; }
    .tx-right .btn{ flex-basis:100%; }

    /* ---- Subscription: primary plan actions (Upgrade / Cancel) stack
       full width instead of splitting a narrow row in half. */
    #view-subscription .grid > .card:first-child > div:last-child{ flex-direction:column; }
    #view-subscription .grid > .card:first-child > div:last-child > .btn{ width:100%; justify-content:center; }

    /* ---- Subscription: extra-connection stepper row can't fit the
       stepper + a long price button side by side on a narrow phone. */
    div:has(> div > #connMinus){ flex-wrap:wrap; row-gap:14px; }
    div:has(> div > #connMinus) > .btn-primary{ width:100%; justify-content:center; }

    /* ---- Notifications: filter row becomes horizontally scrollable
       chips instead of wrapping/overflowing. ---- */
    #view-notifications .card > div:first-child{
      flex-wrap:nowrap; overflow-x:auto; -webkit-overflow-scrolling:touch;
      scrollbar-width:none; -ms-overflow-style:none;
      margin:0 -20px 20px; padding:0 20px 2px;
    }
    #view-notifications .card > div:first-child::-webkit-scrollbar{ display:none; }
    #view-notifications .card > div:first-child .btn{ flex-shrink:0; border-radius:20px; }

    /* ---- Knowledge Base: search bar fills the width instead of
       capping at the desktop 480px. ---- */
    #view-knowledge .search-box{ max-width:none !important; }

    /* ---- Messages: bounded panel height restores the internal
       .msg-body scroll area, which pins .msg-input to the visible
       bottom of the chat — WhatsApp-style — instead of trailing off
       the end of a page-length, auto-height panel. */
    #view-messages .msg-panel{ height:65vh; }
    #view-messages .bubble{ max-width:82%; }
  }

  /* ===== AUTH VIEWS (Milestone 8) =====
     Login/register/forgot/reset live as views inside this same page
     (architecture doc decision #3) — #authGate is a sibling of .app,
     JS toggles which one is visible via body[data-authenticated]. */
  #authGate{
    min-height:100vh; display:flex; align-items:center; justify-content:center;
    padding:32px 20px;
  }
  body[data-authenticated="true"] #authGate{ display:none; }
  body[data-authenticated="false"] .app{ display:none; }
  .auth-card{
    width:100%; max-width:400px; background:var(--bg-card); border:1px solid var(--line);
    border-radius:var(--radius); padding:36px 32px; box-shadow:var(--shadow-card);
  }
  .auth-logo{ font-family:'Fraunces', serif; font-weight:700; font-size:22px; margin-bottom:6px; }
  .auth-logo::after{ content:'.'; color:var(--gold); }
  .auth-title{ font-size:19px; margin-bottom:6px; }
  .auth-sub{ color:var(--muted); font-size:13px; margin-bottom:24px; }
  .auth-view{ display:none; }
  .auth-view.active{ display:block; }
  .auth-footer{ margin-top:20px; font-size:13px; color:var(--muted); text-align:center; }
  .auth-footer a{ color:var(--gold); font-weight:600; cursor:pointer; }
  .auth-footer a:hover{ text-decoration:underline; }
  .auth-message{
    font-size:13px; padding:10px 14px; border-radius:var(--radius-sm); margin-bottom:18px;
  }
  .auth-message-success{ background:rgba(62,143,114,0.14); color:#5FBA97; }
  .auth-message-error{ background:rgba(198,52,42,0.14); color:#E06256; }
  .field-error{ color:#E06256; font-size:12px; margin-top:6px; }
  .field.has-error input{ border-color:var(--crimson); }

  /* ===== COMING SOON (Milestone 8) =====
     Applied to nav items and view bodies with no backend behind them
     yet — never faked data, never a silently-broken button. */
  .nav-item.is-coming-soon{ opacity:.55; cursor:default; }
  .coming-soon-badge{
    margin-left:auto; font-size:9.5px; font-weight:700; letter-spacing:.04em; text-transform:uppercase;
    color:var(--muted-2); background:var(--bg-warm); border:1px solid var(--line); padding:2px 7px; border-radius:20px;
  }
  .coming-soon-panel{
    text-align:center; padding:56px 24px; color:var(--muted);
  }
  .coming-soon-panel svg{ width:34px; height:34px; stroke:var(--muted-2); margin:0 auto 14px; }
  .coming-soon-panel h3{ font-size:15px; color:var(--fg); margin-bottom:6px; }
  .coming-soon-panel p{ font-size:13px; max-width:360px; margin:0 auto; }
  [disabled], .is-inert{ opacity:.5; cursor:not-allowed !important; pointer-events:none; }
  .is-hidden{ display:none !important; }

  /* ===== TOASTS (Milestone 8) ===== */
  #toastStack{
    position:fixed; top:20px; right:20px; z-index:2000;
    display:flex; flex-direction:column; gap:10px; max-width:340px;
  }
  .toast{
    background:var(--bg-card); border:1px solid var(--line); border-left:3px solid var(--info);
    border-radius:var(--radius-sm); padding:12px 16px; font-size:13px; box-shadow:var(--shadow-card);
    animation:toast-in .2s ease;
  }
  .toast-success{ border-left-color:var(--success); }
  .toast-error{ border-left-color:var(--danger); }
  .toast-warning{ border-left-color:var(--warning); }
  @keyframes toast-in{ from{ opacity:0; transform:translateY(-6px);} to{ opacity:1; transform:translateY(0);} }

  /* ===== RECOVERY CODES (Milestone 9) ===== */
  .recovery-codes-panel{
    margin-top:14px; padding-top:14px; border-top:1px solid var(--line);
  }
  .recovery-codes-status{ font-size:13px; color:var(--muted); }
  .recovery-codes-panel.is-low .recovery-codes-status{
    color:var(--warning); font-weight:600;
  }
  .recovery-codes-panel.is-low{
    background:color-mix(in srgb, var(--warning) 10%, transparent);
    border-radius:var(--radius-sm); padding:12px 14px; border-top:none;
  }
  .recovery-codes-list{
    display:grid; grid-template-columns:1fr 1fr; gap:6px 16px;
    font-family:'IBM Plex Mono', monospace; font-size:13px;
    background:var(--bg-warm); border:1px solid var(--line); border-radius:var(--radius-sm);
    padding:14px 16px; margin:12px 0;
  }

  /* ===== PASSKEYS (Milestone 11) ===== */
  .passkeys-panel{
    margin-top:14px; padding-top:14px; border-top:1px solid var(--line);
  }
  .passkeys-list{ margin-bottom:12px; }
  .passkeys-row{
    display:flex; align-items:center; justify-content:space-between; gap:12px;
    padding:10px 0; border-bottom:1px solid var(--line);
  }
  .passkeys-row:last-child{ border-bottom:none; }
  .passkeys-row-actions{ display:flex; gap:8px; flex-shrink:0; }

  /* ===== STAFF 2FA ENFORCEMENT BANNER (Milestone 10) ===== */
  .staff-2fa-banner{
    display:flex; align-items:center; justify-content:space-between; gap:16px; flex-wrap:wrap;
    margin-bottom:20px; padding:12px 16px; border-radius:var(--radius-sm);
    background:color-mix(in srgb, var(--warning) 12%, transparent);
    border:1px solid color-mix(in srgb, var(--warning) 40%, var(--line));
    font-size:13px; color:var(--fg);
  }
  .staff-2fa-banner.is-blocked{
    background:color-mix(in srgb, var(--danger) 10%, transparent);
    border-color:color-mix(in srgb, var(--danger) 40%, var(--line));
  }
  .staff-2fa-banner strong{ font-weight:600; }
  .staff-2fa-banner .btn{ flex-shrink:0; }

  .spinner{
    width:16px; height:16px; border-radius:50%;
    border:2px solid rgba(255,255,255,0.35); border-top-color:#fff;
    animation:spin .7s linear infinite; display:inline-block;
  }
  @keyframes spin{ to{ transform:rotate(360deg); } }

  @keyframes fxDrawerBackdropIn{ from{ opacity:0; } to{ opacity:1; } }
