/*
 * Account Shell v3 (LAT-1042 / LAT-1304) — the account INDEX frame.
 *
 * Activates ONLY on account.mcpanalytics.ai (js/account-shell.js adds
 * html.acct-shell-on). A persistent LEFT SIDEBAR frames every account
 * surface; Create Analysis is the centered default view after login.
 * Replaces the marketing header/footer AND account-app's internal sidebar.
 * On mcpanalytics.ai the same pages keep the marketing chrome — inert there.
 * Mobile (<900px): the sidebar collapses to a fixed top bar.
 *
 * LAT-1304: reskinned WHITE on the #C65000 accent to match the creator
 * (create-analysis), with monoline nav icons (variant A). Was dark #0b0b0d.
 */

html.acct-shell-on #sticky-banner,
html.acct-shell-on footer.footer,
html.acct-shell-on .account-sidebar,
html.acct-shell-on .sidebar-toggle,
html.acct-shell-on .sidebar-overlay {
  display: none !important;
}

html.acct-shell-on body {
  padding-left: 232px !important;
}

/* account-app's two-column layout collapses to one — the shell owns nav */
html.acct-shell-on .account-layout {
  display: block !important;
}

.acct-shell {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 232px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-right: 1px solid #e2e8f0;
  font-family: 'Geist', -apple-system, sans-serif;
  overflow-y: auto;
}

.acct-shell-brand {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  padding: 1.1rem 1rem 0.9rem;
  text-decoration: none;
  border-bottom: 1px solid #f1f5f9;
}

.acct-shell-brand strong {
  color: #0f172a;
  font-size: 0.92rem;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.acct-shell-brand span {
  font-family: 'Geist Mono', monospace;
  font-size: 0.6rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #C65000;
  background: #fff7ed;
  border: 1px solid rgba(198, 80, 0, 0.28);
  border-radius: 3px;
  padding: 0.08rem 0.32rem;
}

.acct-shell-nav {
  flex: 1;
  padding: 0.9rem 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* The centerpiece action — reads as a button, not a nav row */
.acct-shell-primary {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0.25rem 0.9rem;
  padding: 0.6rem 0.8rem;
  background: #C65000;
  color: #fff;
  font-size: 0.85rem;
  font-weight: 650;
  text-decoration: none;
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(198, 80, 0, 0.22);
  transition: background 0.15s ease;
}

.acct-shell-primary:hover { background: #a84400; }

.acct-shell-primary.active {
  outline: 2px solid rgba(198, 80, 0, 0.4);
  outline-offset: 2px;
}

/* LAT-1540 / LAT-1571 — balance indicator directly under the primary CTA.
   ONE shape now: a tier gauge. The flat chip it replaced (LAT-1540) showed
   a bare number with no denomination — "200 credits" only means something
   if you already know a Snapshot costs 200, and a user sitting exactly one
   credit above the gate got no warning at all. The gauge lists the
   web-routable tiers and lights the ones the balance can actually afford,
   so the ceiling is visible BEFORE the affordability gate rejects them.
   (JSON is deliberately absent — it's an MCP-server tier with no web
   surface, so listing it here would advertise a door that isn't there.)

   The is-low branch keeps LAT-1540's whole point: the escalated door that
   used to exist only inside the /create-analysis gate follows a 0-credit
   user across EVERY account page. */
.acct-shell-balance:empty { display: none; }
.acct-shell-balance {
  margin: 0 0.25rem 0.9rem;
  padding: 0;
}
.acct-shell-bal-card {
  display: block;
  padding: 0.5rem 0.6rem 0.55rem;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  text-decoration: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.acct-shell-bal-card:hover { border-color: rgba(198, 80, 0, 0.28); }

/* headline row — the raw balance, with the unit demoted to a label */
.acct-shell-bal-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.4rem;
}
.acct-shell-bal-num {
  color: #0f172a;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  font-variant-numeric: tabular-nums;
}
.acct-shell-bal-unit {
  font-family: 'Geist Mono', monospace;
  font-size: 0.55rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #94a3b8;
}

/* the gauge — one row per web-routable tier, lit when affordable */
.acct-shell-bal-tiers {
  margin-top: 0.45rem;
  display: flex;
  flex-direction: column;
  gap: 0.24rem;
}
.acct-shell-bal-tier {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.7rem;
}
.acct-shell-bal-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex: none;
  background: #e2e8f0;
}
.acct-shell-bal-tier.is-on .acct-shell-bal-dot { background: #15803d; }
.acct-shell-bal-name { flex: 1; color: #94a3b8; }
.acct-shell-bal-tier.is-on .acct-shell-bal-name { color: #475569; font-weight: 550; }
.acct-shell-bal-cost {
  font-family: 'Geist Mono', monospace;
  font-size: 0.62rem;
  color: #94a3b8;
  font-variant-numeric: tabular-nums;
}
.acct-shell-bal-tier.is-on .acct-shell-bal-cost { color: #64748b; }

/* quiet top-up affordance when they CAN afford something (option A's link) */
.acct-shell-bal-topup {
  margin-top: 0.45rem;
  padding-top: 0.4rem;
  border-top: 1px solid #f1f5f9;
  font-size: 0.71rem;
  font-weight: 620;
  color: #C65000;
}

/* Escalated form — same yellow language as the tier-panel affordability
   gate (LAT-1520) so a user who saw both recognises the same door. */
.acct-shell-balance.is-low .acct-shell-bal-card {
  background: #fffbeb;
  border-color: #fde68a;
}
.acct-shell-balance.is-low .acct-shell-bal-num { color: #78350f; }
.acct-shell-balance.is-low .acct-shell-bal-unit,
.acct-shell-balance.is-low .acct-shell-bal-cost { color: #b45309; }
.acct-shell-balance.is-low .acct-shell-bal-name { color: #92400e; }
.acct-shell-balance.is-low .acct-shell-bal-dot { background: #fcd34d; }
.acct-shell-bal-msg {
  margin-top: 0.45rem;
  color: #92400e;
  font-size: 0.7rem;
  line-height: 1.35;
}
.acct-shell-bal-cta {
  display: block;
  margin-top: 0.5rem;
  padding: 0.4rem 0.6rem;
  background: #C65000;
  color: #fff;
  font-size: 0.78rem;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
  border-radius: 6px;
  transition: background 0.15s ease;
}
.acct-shell-bal-cta:hover { background: #a84400; }

.acct-shell-group {
  font-family: 'Geist Mono', monospace;
  font-size: 0.58rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: #94a3b8;
  padding: 0.85rem 0.85rem 0.3rem;
}

.acct-shell-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.85rem;
  color: #475569;
  font-size: 0.84rem;
  font-weight: 500;
  text-decoration: none;
  border-radius: 7px;
  transition: color 0.12s ease, background 0.12s ease;
}

/* variant A: monoline icons, muted grey → accent on the active row */
.acct-shell-item svg {
  width: 16px;
  height: 16px;
  flex: none;
  stroke: #94a3b8;
  fill: none;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: stroke 0.12s ease;
}

.acct-shell-item:hover {
  color: #0f172a;
  background: #f8fafc;
}
.acct-shell-item:hover svg { stroke: #64748b; }

.acct-shell-item.active {
  color: #C65000;
  font-weight: 600;
  background: #fff7ed;
  box-shadow: inset 2px 0 0 #C65000;
}
.acct-shell-item.active svg { stroke: #C65000; }

/* "Soon" placeholder pill (LAT-1305 — Run/Modify analysis) */
.acct-shell-soon {
  margin-left: auto;
  font-family: 'Geist Mono', monospace;
  font-size: 0.54rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #94a3b8;
  background: #f1f5f9;
  border-radius: 999px;
  padding: 0.05rem 0.4rem;
}

.acct-shell-foot {
  padding: 0.8rem 0.85rem 1rem;
  border-top: 1px solid #f1f5f9;
}

.acct-shell-user {
  color: #64748b;
  font-size: 0.72rem;
  font-family: 'Geist Mono', monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 0.45rem;
}

/* LAT-1635 — the tutorial switch (rail foot + mobile drawer) */
.acct-shell-tut {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  color: #475569;
  font-size: 0.78rem;
  cursor: pointer;
  margin-bottom: 0.45rem;
}
.acct-shell-tut:hover { color: #0f172a; }
.acct-tut-sw {
  flex: none;
  width: 28px;
  height: 16px;
  border-radius: 999px;
  background: #cbd5e1;
  position: relative;
  transition: background 0.15s;
}
.acct-tut-sw::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
  transition: left 0.15s;
}
.on > .acct-tut-sw { background: #C65000; }
.on > .acct-tut-sw::after { left: 14px; }
#acct-drawer-tut { justify-content: flex-start; }
#acct-drawer-tut .acct-tut-sw { margin-left: auto; }

.acct-shell-signout {
  display: inline-block;
  color: #475569;
  font-size: 0.78rem;
  text-decoration: none;
  cursor: pointer;
}

.acct-shell-signout:hover { color: #0f172a; }

/* ── LAT-1628: mobile menu — burger + drawer. Both are display:none on
   desktop; every rule that makes them real lives inside the 900px block,
   so desktop is untouched. ── */
.acct-shell-burger { display: none; }
.acct-shell-drawer { display: none; }

/* ── Mobile: sidebar becomes a top bar ── */
@media (max-width: 900px) {
  html.acct-shell-on body {
    padding-left: 0 !important;
    padding-top: 52px !important;
  }
  .acct-shell {
    top: 0; left: 0; right: 0; bottom: auto;
    width: auto;
    height: 52px;
    flex-direction: row;
    align-items: center;
    overflow-y: hidden;
    overflow-x: auto;
    scrollbar-width: none;
    border-right: none;
    border-bottom: 1px solid #e2e8f0;
  }
  .acct-shell::-webkit-scrollbar { display: none; }
  .acct-shell-brand { border-bottom: none; padding: 0 0.4rem; flex-shrink: 0; }
  .acct-shell-brand strong { display: none; }
  /* Balanced bar (operator, 2026-07-23): burger + brand anchor left, the
     New Analysis + credits cluster pins right. Left-packed flex looked fine
     at exactly 390px but lopsided at other device widths. */
  .acct-shell-nav { flex: 1 1 auto; flex-direction: row; align-items: center; justify-content: flex-end; padding: 0 0.25rem; gap: 0.3rem; }
  .acct-shell-primary { margin: 0; padding: 0.35rem 0.7rem; white-space: nowrap; }
  .acct-shell-group { display: none; }
  /* LAT-1628: nav items live in the drawer at this width, not the bar.
     Before, they sat off-screen in a hidden-scrollbar bar — undiscoverable. */
  .acct-shell-item { display: none; }
  .acct-shell-foot { display: none; }
  /* LAT-1629: the getting-started checklist card has no business inside a
     52px bar (it rendered as a clipped blob). ID selector because
     #acct-gs-wrap .acct-shell-group outranks class-level rules. */
  #acct-gs-wrap { display: none; }

  /* LAT-1628 — the burger */
  .acct-shell-burger {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    margin-left: 0.25rem;
    background: none;
    border: none;
    border-radius: 10px;
    color: #334155;
    cursor: pointer;
  }
  .acct-shell-burger.open { color: #C65000; background: #fff7ed; }

  /* LAT-1628 — the drawer: full-height sheet under the bar */
  .acct-shell-drawer.open {
    display: block;
    position: fixed;
    top: 52px; left: 0; right: 0; bottom: 0;
    z-index: 999;
    background: #fff;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0.35rem 1rem 2.5rem;
  }
  html.acct-drawer-lock, html.acct-drawer-lock body { overflow: hidden; }
  .acct-drawer-group {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #94a3b8;
    margin: 1.15rem 0 0.25rem;
    padding: 0 0.5rem;
  }
  .acct-drawer-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-height: 46px;
    padding: 0.55rem 0.5rem;
    border-radius: 10px;
    color: #334155;
    font-size: 0.95rem;
    text-decoration: none;
  }
  .acct-drawer-item svg {
    width: 18px; height: 18px; flex: none;
    fill: none; stroke: #94a3b8; stroke-width: 2;
    stroke-linecap: round; stroke-linejoin: round;
  }
  .acct-drawer-item.active { background: #fff7ed; color: #C65000; font-weight: 600; }
  .acct-drawer-item.active svg { stroke: #C65000; }
  .acct-drawer-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-top: 1.5rem;
    padding: 1rem 0.5rem 0;
    border-top: 1px solid #f1f5f9;
  }
  .acct-drawer-user {
    color: #64748b;
    font-size: 0.75rem;
    font-family: 'Geist Mono', monospace;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
  }
  .acct-drawer-signout {
    color: #475569;
    font-size: 0.85rem;
    padding: 0.5rem 0.6rem;
    cursor: pointer;
    flex-shrink: 0;
  }

  /* LAT-1571 — the gauge collapses to its headline row in the 52px top bar.
     The tier list, message, and top-up line need vertical space the bar
     doesn't have. Since LAT-1628 the inline "Add credits" CTA is dropped
     here too — stacked under the number it made the chip 59px tall in a
     52px bar (operator report, 2026-07-23). The is-low chip keeps its
     amber card as the alert, the whole chip still taps through to
     billing, and the drawer carries the Billing entry. */
  .acct-shell-balance { margin: 0; flex-shrink: 0; }
  .acct-shell-bal-card { padding: 0.3rem 0.55rem; white-space: nowrap; }
  .acct-shell-bal-top { gap: 0.3rem; }
  .acct-shell-bal-num { font-size: 0.85rem; }
  .acct-shell-bal-tiers,
  .acct-shell-bal-topup { display: none; }
  .acct-shell-bal-msg { display: none; }
  .acct-shell-bal-cta { display: none; }
}

/* LAT-1495 — optional page-supplied block under the nav (create-analysis's
   recent builds). Nav stays the shell's; pages contribute context only. */
.acct-shell-extra-body { display: flex; flex-direction: column; gap: 1px; padding: 0 0.35rem; }
.acct-shell-extra-body a {
  display: block; font-size: 0.78rem; color: #64748b; text-decoration: none;
  padding: 0.32rem 0.5rem; border-radius: 6px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.acct-shell-extra-body a:hover { background: #f1f5f9; color: #0f172a; }
.acct-shell-extra-body .acct-shell-extra-empty { font-size: 0.75rem; color: #94a3b8; padding: 0.32rem 0.5rem; }
@media (max-width: 900px) { .acct-shell-extra { display: none; } }

/* ── Getting-started checklist card in the rail (LAT-1606/1617) ─────────── */
#acct-gs-wrap .acct-shell-group { display: flex; align-items: center; justify-content: space-between; }
#acct-gs-wrap .acct-shell-group button { background: none; border: none; color: #94a3b8; cursor: pointer; font-size: 12px; padding: 0 2px; line-height: 1; }
#acct-gs-wrap .acct-shell-group button:hover { color: #1e2633; }
#acct-gs-card { margin: 2px 0.85rem 6px; border: 1px solid #f0e9de; background: #fffdf9; border-radius: 12px; padding: 8px; }
.acct-gs-row { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 8px; font-size: 12.5px; color: #475569; text-decoration: none; }
.acct-gs-row:hover { background: #fff7ed; color: #C65000; }
.acct-gs-tick { flex: none; width: 18px; height: 18px; border-radius: 50%; border: 1px solid #e2e8f0; display: inline-flex; align-items: center; justify-content: center; font-size: 10.5px; font-weight: 700; color: #94a3b8; background: #fff; }
.acct-gs-row.done { color: #94a3b8; text-decoration: line-through; }
.acct-gs-row.done .acct-gs-tick { background: #16a34a; border-color: #16a34a; color: #fff; }
#acct-gs-tour { display: block; width: 100%; margin-top: 6px; background: none; border: none; color: #C65000; font-size: 12px; font-weight: 600; cursor: pointer; text-align: left; padding: 6px 8px; border-radius: 8px; }
#acct-gs-tour:hover { background: #fff7ed; }
