/* ==========================================================================
   ENVELOPES — Desktop layout (≥ 1024px)
   Mobile styling in app.css is untouched; this file overlays a wider layout.
   ========================================================================== */

@media (min-width: 1024px) {

  :root {
    --sidebar-w: 224px;
    --content-max: 1280px;
    --content-pad: 40px;
  }

  /* ---------- Shell -------------------------------------------------------- */
  body {
    max-width: none !important;
    margin: 0;
    overflow-x: hidden;
    font-size: 14.5px;
  }

  /* ---------- Top nav: full-width, polished -------------------------------- */
  .nav {
    padding: 14px 28px;
    height: 64px;
    z-index: 110;
    gap: 14px;
  }
  .nav-logo { font-size: 24px; }

  /* Desktop nav: brand pinned far left, then [cycle-nav, theme, user-chip]
     clustered far right. margin-left:auto on .cycle-nav absorbs the free
     space, and the .nav gap (14px) gives consistent breathing room between
     cycle-nav ↔ theme ↔ user-chip. */
  .brand     { flex: 0 0 auto; }
  .nav-right { flex: 0 0 auto; gap: 14px !important; }
  .cycle-nav { margin-left: auto; flex: 0 0 auto; }
  .cycle-nav {
    background: var(--s2);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 4px;
    gap: 4px;
  }
  .cycle-btn { width: 28px; height: 28px; border: none; background: transparent; }
  .cycle-btn:hover { background: var(--s3); }
  .cycle-label { padding: 0 8px; }

  /* ---------- Sidebar (the .tabs strip) ------------------------------------ */
  /* Desktop has room for the full destination list — hide the mobile More tab
     and surface Net worth / Projection / Import / Settings as direct rows. */
  .tab-more-only { display: none; }
  .tab-desktop-only { display: flex; }
  .tabs {
    display: flex;
    grid-template-columns: none;
    position: fixed;
    top: 64px;
    left: 0;
    right: auto;
    bottom: 0;
    width: var(--sidebar-w);
    flex-direction: column;
    align-items: stretch;
    overflow-x: visible;
    overflow-y: auto;
    border-right: 1px solid var(--border);
    border-top: none;
    border-bottom: none;
    background: var(--s1);
    padding: 18px 14px;
    gap: 3px;
    z-index: 95;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
  /* Show More tile inline in sidebar (desktop has room for all destinations,
     but keep markup unified). The More tab opens the same sheet. */
  .tab {
    flex-shrink: 0;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    text-align: left;
    padding: 11px 14px;
    border-bottom: none;
    border-radius: 10px;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--muted);
    letter-spacing: 0.2px;
    transition: background .15s, color .15s;
    position: relative;
    background: transparent;
    box-shadow: none;
  }
  .tab .tab-glyph { color: var(--muted); }
  .tab:hover { background: var(--s2); color: var(--text); }
  .tab:hover .tab-glyph { color: var(--text); }
  .tab.active {
    background: var(--gold-bg);
    color: var(--gold);
    border-bottom: none;
    box-shadow: none;
  }
  .tab.active .tab-glyph { color: var(--gold); }
  .tab.active::before {
    content: "";
    position: absolute;
    left: 0; top: 8px; bottom: 8px;
    width: 3px;
    background: var(--gold);
    border-radius: 0 3px 3px 0;
  }

  /* ---------- Content area ------------------------------------------------- */
  #content-wrapper {
    margin-left: var(--sidebar-w);
    min-height: calc(100vh - 64px);
  }
  .content {
    max-width: var(--content-max);
    margin: 0 auto;
    padding: 32px var(--content-pad) 120px;
  }

  /* ---------- Top headline cards (Free to spend, NW total, summary hero) --- */
  .fts-card,
  .summary-hero,
  #tab-networth > .card:first-child {
    padding: 32px 36px;
    border-radius: 22px;
  }
  .fts-amount { font-size: 64px; }
  .nw-total { font-size: 48px; }
  .hero-amount { font-size: 56px; }
  .hero-amount .dec { font-size: 32px; }

  /* Hero stat row spaces nicely on desktop */
  .hero-row { gap: 0; padding-top: 18px; }
  .hero-stat .v { font-size: 19px; }
  .hero-stat .l { font-size: 11px; }

  /* ---------- ENVELOPES TAB: multi-column grid ----------------------------- */
  #env-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 14px;
    align-items: start;
  }
  /* Section headers inside env-list (rendered as div headers) span full row */
  #env-list > .sec,
  #env-list > h2,
  #env-list > h3,
  #env-list > [data-section-header] {
    grid-column: 1 / -1;
  }
  /* Reorder hint spans full row */
  #env-list > .reorder-hint { grid-column: 1 / -1; }
  /* Cards keep their styling but lose vertical-only mb */
  #env-list .env-card { margin-bottom: 0; height: 100%; }

  /* The env-tab top row (reorder/transfer) */
  #tab-envelopes > div:first-child { margin-bottom: 14px; }

  /* ---------- TRANSACTIONS TAB: wider rows --------------------------------- */
  #tab-transactions .form-input { font-size: 14px; }
  #txn-list {
    background: var(--s1);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 4px 18px;
  }
  .txn-item { padding: 14px 0; gap: 14px; }
  .txn-name { font-size: 14px; }
  .txn-meta { font-size: 12px; }
  .txn-amt { font-size: 15px; min-width: 110px; text-align: right; }

  /* ---------- HISTORY TAB: heatmap + sparklines side-by-side --------------- */
  /* Scope to .active so .content{display:none} keeps winning when inactive */
  #tab-history.active {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
    gap: 18px;
  }
  #tab-history > .page-heading { grid-column: 1 / -1; }
  #hist-heatmap { grid-column: 1; grid-row: 2; margin-bottom: 0; }
  #hist-sparklines-wrap { grid-column: 2; grid-row: 2; margin: 0; }
  #hist-sparklines-wrap > .card { margin-bottom: 0; height: 100%; }
  #hist-list { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; }
  #hist-list .hist-item { margin-bottom: 0; }
  #hist-list > .hist-insight-label { grid-column: 1 / -1; }

  /* ---------- NET WORTH TAB: assets / liabilities side-by-side ------------- */
  /* Children rendered (in order):
     1) total card  2) progress card  3) assets umbrella  4) liabilities umbrella  5) "last updated" */
  #tab-networth.active {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    align-content: start;
  }
  #tab-networth > .card:first-child,            /* total */
  #tab-networth > #nw-progress-card,            /* progress */
  #tab-networth > div[style*="text-align:center"] /* footer line */ {
    grid-column: 1 / -1;
  }
  /* Assets umbrella (3rd child) and Liabilities umbrella (4th child) side-by-side */
  #tab-networth > .nw-section:nth-child(3) { grid-column: 1 / 2; }
  #tab-networth > .nw-section:nth-child(4) { grid-column: 2 / 3; }

  /* ---------- PROJECTION ---------------------------------------------------- */
  #tab-projection .card {
    padding: 24px 28px;
  }

  /* ---------- IMPORT -------------------------------------------------------- */
  #tab-import {
    max-width: 720px;
    margin: 0 auto;
  }
  .import-zone {
    padding: 60px 32px;
  }
  .import-icon { font-size: 52px; }

  /* ---------- SETTINGS ----------------------------------------------------- */
  #tab-settings {
    max-width: 760px;
    margin: 0 auto;
  }
  .set-row { padding: 16px 18px; }
  .set-label { font-size: 14.5px; }

  /* ---------- BUTTONS / FORMS ---------------------------------------------- */
  .btn {
    width: auto;
    min-width: 160px;
    padding: 12px 22px;
    border-radius: 10px;
    transition: transform .15s, opacity .15s, background .15s;
  }
  .btn-primary:hover { transform: translateY(-1px); opacity: 0.95; }
  .form-input { padding: 11px 14px; font-size: 14px; border-radius: 10px; }

  /* ---------- MODALS: centered dialog, not bottom sheet -------------------- */
  .modal-overlay {
    align-items: center;
    justify-content: center;
    padding: 32px;
  }
  .modal {
    width: auto;
    min-width: 420px;
    max-width: 560px;
    max-height: 86vh;
    border-radius: 18px;
    border: 1px solid var(--border);
    padding: 28px 30px 30px;
    animation: dlgIn .22s cubic-bezier(.2,.8,.2,1);
  }
  @keyframes dlgIn {
    from { opacity: 0; transform: translateY(8px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
  }
  .modal-handle { display: none; }
  .modal-title { font-size: 24px; }
  .modal .btn { width: auto; }
  /* Side-by-side action buttons in modals (last 2 .btn elements) */
  .modal > .btn + .btn {
    margin-left: 8px;
  }

  /* ---------- FAB / sync / notif ------------------------------------------- */
  .fab {
    bottom: 32px;
    right: 32px;
    width: 56px; height: 56px;
    box-shadow: 0 6px 24px rgba(201,168,76,.4);
  }
  .fab:hover { transform: scale(1.05); }

  #sync-indicator {
    bottom: 24px;
    left: calc(var(--sidebar-w) + 24px);
    transform: none;
  }

  .notif {
    left: 50%;
    right: auto;
    transform: translateX(-50%) translateY(-80px);
    min-width: 320px;
    max-width: 480px;
    top: 80px;
  }
  .notif.show { transform: translateX(-50%) translateY(0); }

  /* ---------- AUTH GATE — let the scene breathe on desktop ----------------- */
  #auth-gate { padding: 60px 56px; }
  .auth-card {
    max-width: 460px;
    padding: 52px 44px 44px;
    border-radius: 16px;
  }
  .auth-mark { width: 72px; height: 72px; margin-bottom: 22px; }
  .auth-mark svg { width: 48px; height: 48px; }
  .auth-eyebrow { margin-bottom: 18px; }
  .auth-heading { font-size: 44px; }
  .auth-blurb { font-size: 15px; margin-bottom: 28px; }
  .auth-back  { height: 34vh; }
  .auth-mid   { height: 38vh; }
  .auth-front { height: 36vh; }
  .auth-foot  { margin-top: 36px; font-size: 11px; }

  /* ---------- Section titles --------------------------------------------- */
  /* Page-level heading sits a touch larger on desktop. */
  .page-heading { font-size: 38px; margin: 12px 0 22px; }
  /* Section heads scale up slightly on desktop for hierarchy clarity. */
  .sec, .sec-l, .nw-section-title, .hist-insight-label { font-size: 24px; }
  .sec { margin: 32px 0 16px; }
  /* Nested NW labels stay at sub-heading size. */
  .nw-section .nw-section .nw-section-title { font-size: 14px; }

  /* ---------- Cards: subtle hover lift --------------------------------- */
  .env-card,
  .hist-item,
  .set-row {
    transition: transform .15s, border-color .2s, box-shadow .2s;
  }
  .env-card:hover,
  .hist-item:hover,
  .set-row:hover {
    transform: translateY(-1px);
    border-color: var(--gold);
    box-shadow: 0 6px 20px -8px rgba(0,0,0,0.3);
  }
  .env-card:active { transform: translateY(0); }
  :root .env-card:hover,
  :root .hist-item:hover,
  :root .set-row:hover {
    box-shadow: 0 6px 20px -8px rgba(31,40,30,0.10);
  }
  [data-theme="dusk"] .env-card:hover,
  [data-theme="dusk"] .hist-item:hover,
  [data-theme="dusk"] .set-row:hover {
    box-shadow: 0 6px 20px -8px rgba(0,0,0,0.40);
  }

  /* ---------- Heatmap looks better with bigger cells on desktop ------------ */
  .hm-grid {
    --hm-label-w: 130px;
    --hm-cell-w:  48px;
    --hm-row-h:   44px;
  }
  .hist-spark-grid { grid-template-columns: var(--hm-label-w) minmax(0, 1fr) 76px; }
  .hm-grid > .hm-cell { font-size: 11px; }
  .hm-grid > .hm-row-label { font-size: 12px; }

  /* ---------- Overview tab — keep the hero centered, but use the room ------ */
  #tab-overview {
    max-width: var(--content-max);
  }
  .ov-env-scroll {
    margin: 0 0 16px;
    padding-left: 0;
    padding-right: 0;
    flex-wrap: wrap;
    overflow-x: visible;
  }
  .ov-env-tile { width: 156px; }
}

/* ==========================================================================
   Wider screens (≥ 1440px) — give the content even more breathing room.
   ========================================================================== */
@media (min-width: 1440px) {
  :root { --content-pad: 56px; }
  .fts-amount { font-size: 72px; }
  .nw-total { font-size: 56px; }
  #env-list { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }
}
