/* futbid — app shell layout. Loaded after design-system/tokens.css and components/bundle.css. */
html { background: var(--bg); }
body { min-height: 100vh; }
a { color: var(--brand-text); text-decoration: none; }
a:hover { text-decoration: underline; }
a.fb-btn:hover { text-decoration: none; }

.app { display: flex; min-height: 100vh; background: var(--bg); color: var(--ink); font-family: var(--font-sans); }
.main { flex: 1; min-width: 0; box-sizing: border-box; display: flex; flex-direction: column; gap: var(--space-6); padding: 28px var(--space-6); }

/* Sidebar */
.sidebar { width: var(--sidebar-width); flex: none; box-sizing: border-box; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: var(--space-6); padding: 20px var(--space-3); background: var(--surface); border-right: 1px solid var(--line); }
.sidebar-logo { display: flex; align-items: center; height: 32px; padding: 0 10px; }
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; }
.nav-link { display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 10px; border-radius: var(--radius-md); color: var(--ink-muted); font-size: 14px; font-weight: 500; }
.nav-link:hover { background: var(--surface-raised); color: var(--ink); text-decoration: none; }
.nav-link.is-on { background: var(--surface-raised); color: var(--ink); box-shadow: inset 2px 0 0 var(--brand); }
.nav-icon { flex: none; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.plan-card { margin-top: auto; display: flex; flex-direction: column; gap: var(--space-3); padding: var(--space-3); border: 1px solid var(--line); border-radius: var(--radius-lg); }
.plan-row { display: flex; justify-content: space-between; align-items: center; }
.plan-name { font-size: 13px; font-weight: 600; }
.plan-count { font-family: var(--font-mono); font-size: 12px; color: var(--ink-muted); }
.plan-bar { height: 4px; border-radius: var(--radius-pill); background: var(--surface-sunken); }
.plan-bar > div { height: 4px; border-radius: var(--radius-pill); background: var(--brand); }
.plan-renew { font-size: 12px; color: var(--ink-subtle); }
.sidebar-foot { display: flex; flex-direction: column; gap: var(--space-3); padding: 0 10px; }
.live { display: flex; align-items: center; gap: var(--space-2); font-size: 12px; color: var(--ink-muted); }
.live-dot { width: 6px; height: 6px; border-radius: var(--radius-pill); background: var(--gain); }

/* Page header */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-4); }
.page-title { margin: 0; font-size: 20px; line-height: 28px; font-weight: 600; letter-spacing: -0.01em; }
.page-sub { font-size: 13px; color: var(--ink-muted); }
.actions { display: flex; gap: var(--space-2); }
.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: var(--space-4); }
.toolbar { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.panel { display: flex; flex-direction: column; gap: var(--space-4); padding: var(--space-4); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); }
.panel-title { margin: 0; font-size: 15px; line-height: 22px; font-weight: 600; }
.footnote { display: flex; justify-content: space-between; gap: var(--space-4); font-size: 12px; color: var(--ink-subtle); }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

@media (max-width: 1200px) { .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 860px) {
  .app { flex-direction: column; }
  .sidebar { position: static; width: 100%; height: auto; flex-direction: row; align-items: center; overflow-x: auto; padding: var(--space-3); }
  .sidebar-nav { flex-direction: row; }
  .plan-card, .sidebar-foot { display: none; }
  .main { padding: var(--space-4); }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Wide tables (13 columns on All accounts): tighter cells; the panel scrolls horizontally below ~1440px. */
.main .fb-table th, .main .fb-table td { padding: 0 10px; }
.main .fb-table th:first-child, .main .fb-table td:first-child { padding-left: var(--space-3); }

/* ── Mobile (≤ 860px) ─────────────────────────────────────────────────────
   In a column, each block takes the min width of its content: a 13-column
   table or a non-wrapping row of buttons used to widen the whole page.
   Here nothing may exceed the screen width; tables scroll inside their box
   and rows of controls wrap. */
@media (max-width: 860px) {
  html, body { overflow-x: hidden; }
  .main { gap: var(--space-4); }
  .main > *, .col, .col > *, .panel, .detail-grid > * { min-width: 0; max-width: 100%; }
  .fb-table-wrap { max-width: 100%; -webkit-overflow-scrolling: touch; }
  /* Only the page header stacks; panels and modals keep their row. */
  .main > .page-head, .main > header > .page-head { flex-direction: column; align-items: stretch; gap: var(--space-3); }
  .panel .page-head { flex-wrap: wrap; }
  .page-title { font-size: 18px; line-height: 24px; overflow-wrap: anywhere; }
  .actions { flex-wrap: wrap; }
  .toolbar > .fb-input { width: 100% !important; box-sizing: border-box; }
  .toolbar > .actions { margin-left: 0 !important; }
  .fb-seg { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
  .fb-seg::-webkit-scrollbar { display: none; }
  .footnote { flex-direction: column; gap: var(--space-1); }
  .kpis { gap: var(--space-2); }
  .kpis .fb-kpi { padding: var(--space-3); }
  .sidebar { gap: var(--space-3); padding: var(--space-2) var(--space-3); scrollbar-width: none; }
  .sidebar::-webkit-scrollbar { display: none; }
  .sidebar-logo { padding: 0 4px; }
  .nav-link { height: 32px; padding: 0 8px; font-size: 13px; white-space: nowrap; }
}
@media (max-width: 520px) {
  .actions > .fb-btn, .actions > a.fb-btn { flex: 1 1 auto; justify-content: center; }
}

/* Account cards (All accounts on mobile, replace the 13-column table). */
.acct-cards { display: flex; flex-direction: column; gap: var(--space-2); }
.acct-card { display: flex; flex-direction: column; gap: var(--space-3); padding: var(--space-3) var(--space-4); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); color: var(--ink); }
.acct-card:hover { text-decoration: none; border-color: var(--line-strong); }
.acct-card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); }
.acct-card-email { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.acct-card-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2) var(--space-4); }
.acct-card-grid > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.acct-card-grid .label { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-subtle); }
.acct-card-foot { display: flex; justify-content: space-between; gap: var(--space-2); font-size: 12px; color: var(--ink-muted); }

/* ── Hamburger menu ────────────────────────────────────────────────────── */
/* Desktop: .sidebar-top and .sidebar-drawer don't exist for layout (display: contents). */
.sidebar-top, .sidebar-drawer { display: contents; }
.burger { display: none; }
.sidebar-scrim { display: none; }
@media (max-width: 860px) {
  .sidebar { position: sticky; top: 0; z-index: 40; flex-direction: column; align-items: stretch; gap: 0; overflow: visible; padding: 0; height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar-top { display: flex; align-items: center; justify-content: space-between; height: 52px; padding: 0 var(--space-2) 0 var(--space-3); }
  .burger { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border: 0; border-radius: var(--radius-md); background: transparent; color: var(--ink); cursor: pointer; }
  .burger:hover, .sidebar.is-open .burger { background: var(--surface-raised); }
  .burger .nav-icon { stroke-width: 1.75; }
  .sidebar-drawer { display: none; }
  .sidebar.is-open .sidebar-drawer { display: flex; flex-direction: column; gap: var(--space-6); position: fixed; top: 53px; left: 0; right: 0; max-height: calc(100vh - 53px); overflow-y: auto; box-sizing: border-box; padding: var(--space-4); background: var(--surface); border-bottom: 1px solid var(--line); box-shadow: var(--shadow-pop); z-index: 42; }
  .sidebar.is-open .sidebar-scrim { display: block; position: fixed; top: 53px; left: 0; right: 0; bottom: 0; background: rgba(4, 6, 8, 0.6); z-index: 41; }
  .sidebar.is-open .sidebar-nav { flex-direction: column; gap: 2px; }
  .sidebar.is-open .nav-link { height: 44px; font-size: 15px; }
  .sidebar.is-open .plan-card, .sidebar.is-open .sidebar-foot { display: flex; }
  .sidebar.is-open .sidebar-foot { padding: 0; }
}

/* ── Printer / Insights / Proxies / Settings / Billing screens ─────────── */
.nav-section { margin: var(--space-4) 10px var(--space-1); font-size: 11px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-subtle); }
.kpis-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.card-cell { display: inline-flex; gap: 8px; align-items: baseline; }
.card-cell .ovr { font-family: var(--font-mono); font-weight: 600; color: var(--warn); }
.card-cell .pos { font-size: 12px; color: var(--ink-subtle); }
.coverage { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; font-size: 12px; }
.field-inline { display: inline-flex; align-items: center; gap: var(--space-2); font-size: 13px; }
.field-help { font-size: 12px; line-height: 16px; color: var(--ink-muted); }
.row-actions { display: inline-flex; gap: var(--space-2); align-items: center; justify-content: flex-end; }
.proxy-acct + .proxy-acct::before { content: ', '; color: var(--ink-subtle); }
.rate { display: inline-flex; align-items: center; justify-content: flex-end; gap: 8px; }
.rate-bar { display: inline-block; height: 4px; border-radius: 2px; background: var(--brand); opacity: .5; }
.fb-select { height: var(--control-md); padding: 0 var(--space-3); background: var(--surface-sunken); border: 1px solid var(--line-strong); border-radius: var(--radius-md); color: var(--ink); font: inherit; font-size: 13px; }
.setting { display: flex; justify-content: space-between; align-items: center; gap: var(--space-4); padding: var(--space-3) 0; border-top: 1px solid var(--line); }
.setting:first-of-type { border-top: 0; }
.setting-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.setting-label { font-size: 14px; font-weight: 500; display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; }
.setting-control { display: flex; gap: var(--space-2); align-items: center; flex: none; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; max-width: 420px; }
.chip { height: 28px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: var(--radius-pill); background: transparent; color: var(--ink-muted); font: inherit; font-size: 12px; font-weight: 500; cursor: pointer; }
.chip.is-on { background: var(--loss-soft, var(--surface-raised)); border-color: var(--loss); color: var(--ink); }
@media (max-width: 1200px) { .kpis-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 860px) {
  .setting { flex-direction: column; align-items: stretch; }
  .setting-control { flex-wrap: wrap; }
  .field-inline { width: 100%; }
  .fb-select { width: 100%; }
}

/* Account detail: 8 KPIs in 2 rows of 4. */
.kpis-8 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 860px) { .kpis-8 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* User + logout in the sidebar */
.user-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); min-width: 0; }
.user-email { font-size: 12px; color: var(--ink-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.logout { flex: none; border: 1px solid var(--line-strong); background: transparent; color: var(--ink); border-radius: var(--radius-md); height: 26px; padding: 0 10px; font: inherit; font-size: 12px; font-weight: 500; cursor: pointer; }
.logout:hover { background: var(--surface-raised); }
