/* account.css — account-page rules (W3B zone).
   These used to be inline style="" attributes. The production CSP
   (deploy/nginx.conf: style-src 'self') refuses inline styles, so on the live
   host they never applied — the key and model tables lost their scroll
   wrappers at 375px. A same-origin stylesheet is allowed by that policy. */

.table-scroll { overflow-x: auto; }
.field.field-inline { margin: 0; }
caption.caption-left { text-align: left; }

/* In-text links carry an underline so they never rely on colour alone
   (WCAG 1.4.1; ember-300 on ink-200 body text is ~1.4:1). Buttons keep
   their own treatment. */
#main p a:not(.btn), #main li a:not(.btn) {
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

/* Quickstart card: sub-headings sit close to the snippet they label. */
.qstart h3 { margin-top: var(--sp-5); }

/* Account recovery forms (W1-A3) title themselves with an h2 under the auth
   card's h1; at the page h2 size (26-36px) they would outweigh it. */
.auth-card h2 { font-size: var(--fs-125); letter-spacing: -0.01em; }

/* ---- dashboard shell (W2 account polish) ----
   #dash-view is the query container, so the layout follows the room the
   dashboard has, not the viewport. Order: account strip, status line, stat
   tiles, then the cards. The grid is one column, or two from 44rem of room:
   Subscription and Usage share a row and every other card takes the full row
   (.span-2). In a browser without container queries everything is one
   column. */
#dash-view { container-type: inline-size; }
#dash-view .dash { grid-template-columns: minmax(0, 1fr); align-items: stretch; }
@container (min-width: 44rem) {
  #dash-view .dash { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Account strip: who is signed in, the plan in one line, Sign out, and jump
   links to the cards below. */
.acct-head {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center;
  gap: var(--sp-3) var(--sp-4); margin-bottom: var(--sp-5); padding: var(--sp-4) var(--sp-5) 0;
  background: var(--surface-1); border: var(--border-1); border-radius: var(--radius-l);
  box-shadow: var(--shadow-card);
}
.acct-label {
  margin: 0; color: var(--text-faint); font-size: var(--fs-75); font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em;
}
.acct-email { margin: 0; color: var(--text-strong); font-size: var(--fs-112); overflow-wrap: anywhere; }
.acct-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-1) var(--sp-3);
  margin: var(--sp-1) 0 0; color: var(--text-muted); font-size: var(--fs-875);
}
.acct-nav {
  grid-column: 1 / -1; margin-inline: calc(-1 * var(--sp-5)); padding-inline: var(--sp-5);
  border-top: var(--border-1); overflow-x: auto; scrollbar-width: none;
}
.acct-nav::-webkit-scrollbar { display: none; }
.acct-nav ul { display: flex; gap: var(--sp-1); width: max-content; list-style: none; margin: 0 calc(-1 * var(--sp-2)); padding: 0; }
#main .acct-nav li a {
  display: inline-flex; align-items: center; min-height: var(--tap-min); padding-inline: var(--sp-2);
  border-radius: var(--radius-s); color: var(--text-muted); font-size: var(--fs-875); font-weight: 600;
  white-space: nowrap; text-decoration: none;
  transition: color var(--dur-1) var(--ease-1), background-color var(--dur-1) var(--ease-1);
}
#main .acct-nav li a:hover { color: var(--text-strong); background: var(--surface-2); }
#main .acct-nav li a:focus-visible { outline-offset: -2px; }   /* the strip clips an outside ring */
/* Narrow: Sign out moves up beside the "Signed in as" label, so the email
   has the full row and does not break around the button. */
@container (max-width: 30rem) {
  .acct-head { position: relative; grid-template-columns: minmax(0, 1fr); padding: var(--sp-3) var(--sp-4) 0; }
  .acct-head > .btn { position: absolute; top: var(--sp-3); right: var(--sp-4); }
  .acct-label { display: flex; align-items: center; min-height: 2rem; }
  .acct-email { font-size: var(--fs-100); }
  .acct-nav { margin-inline: calc(-1 * var(--sp-4)); padding-inline: var(--sp-4); }
}

/* Card titles are labels inside a dashboard, not page sections: the page h2
   (26-36px) made every card shout. */
#dash-view .card > h2, #dash-view .card-head > h2 {
  font-size: var(--fs-125); line-height: var(--lh-snug); letter-spacing: -0.01em;
}
#dash-view .card h3 { font-size: var(--fs-100); letter-spacing: 0; }
#main dialog > h2 { font-size: var(--fs-150); line-height: var(--lh-snug); }
.card-head {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: var(--sp-2) var(--sp-3); margin-bottom: var(--sp-3);
}
.card-head > h2 { margin: 0; }
.card-foot {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2) var(--sp-4);
  margin-top: var(--sp-4); padding-top: var(--sp-4); border-top: var(--border-1);
}
.card-foot > .hint { flex: 1 1 14rem; margin: 0; }

/* A field and the button that acts on it share a baseline: the button sits
   on the input's bottom edge at the input's height (it used to stretch to
   the label + input). */
#main .dash-actions { align-items: flex-end; }
#main .dash-actions > .field-inline { flex: 1 1 12rem; max-width: 22rem; }
#main .dash-actions > .field-inline ~ .btn { min-height: var(--tap-min); }

/* Inline confirm (Cancel plan): the question and its two answers take the
   place of the button that asked. */
.card-foot.confirm { display: block; }
.card-foot.confirm > p { margin: 0; color: var(--text-strong); font-size: var(--fs-875); }
.card-foot.confirm > .dash-actions { margin-top: var(--sp-3); }

/* ---- billing & activity: one line per ledger event ---- */
.event-list { list-style: none; margin: 0; padding: 0; }
.event-list > li.muted { padding-block: var(--sp-2); }
.event {
  display: grid; grid-template-columns: 11.5rem 4.5rem minmax(0, 1fr); align-items: baseline;
  gap: var(--sp-1) var(--sp-3); padding-block: var(--sp-3); border-bottom: 1px solid var(--slate-800);
  font-size: var(--fs-875);
}
.event:last-child { border-bottom: 0; }
.event-when { color: var(--text-faint); font-variant-numeric: tabular-nums; }
.event-tag { color: var(--text-muted); font-size: var(--fs-75); font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; }
.event-text { color: var(--text); overflow-wrap: anywhere; }
@container (max-width: 38rem) {
  .event { grid-template-columns: minmax(0, 1fr) auto; }
  .event-tag { text-align: right; }
  .event-text { grid-column: 1 / -1; }
}

/* ---- plan comparison dialog: one card per plan ---- */
#plans-dialog { max-width: 56rem; width: min(56rem, calc(100vw - 2rem)); }
.plan-grid {
  display: grid; gap: var(--sp-4); grid-template-columns: repeat(auto-fit, minmax(min(11.5rem, 100%), 1fr));
  list-style: none; margin: 0 0 var(--sp-4); padding: 0;
}
.plan-opt {
  display: flex; flex-direction: column; gap: var(--sp-2); min-width: 0; padding: var(--sp-4);
  background: var(--surface-inset); border: var(--border-1); border-radius: var(--radius-m);
}
.plan-opt.is-current { border-color: var(--line-control); }
.plan-opt h3 { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); margin: 0; font-size: var(--fs-100); letter-spacing: 0; }
.plan-opt .price { margin: 0; color: var(--text-strong); font-size: var(--fs-150); font-weight: 700; }
.plan-opt .price small { color: var(--text-muted); font-size: var(--fs-875); font-weight: 400; }
.plan-opt .tagline { margin: 0; color: var(--text-muted); font-size: var(--fs-875); }
.plan-opt .facts { grid-template-columns: minmax(0, 1fr); gap: 0; margin-block: var(--sp-2); }
.plan-opt .facts dd { margin: 0 0 var(--sp-2); color: var(--text-strong); font-variant-numeric: tabular-nums; }
.plan-opt .facts dd:last-child { margin-bottom: 0; }
.plan-opt .btn, .plan-opt .plan-state { margin-top: auto; }
.plan-opt .plan-state { margin-bottom: 0; color: var(--text-faint); font-size: var(--fs-75); }

/* ---- quickstart: a title and its Copy button share a row ---- */
.code-head {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: var(--sp-2) var(--sp-3); margin: var(--sp-5) 0 var(--sp-2);
}
.qstart .code-head h3 { margin: 0; }

/* ---- stat tiles: four figures at a glance (two by two on a narrow page).
   Plain figures, not meters: the gauges below carry the meter roles. */
.stat-tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-3); margin: 0 0 var(--sp-5); }
@container (min-width: 44rem) { .stat-tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--sp-4); } }
.stat { min-width: 0; padding: var(--sp-4); background: var(--surface-1); border: var(--border-1); border-radius: var(--radius-m); }
.stat dt { color: var(--text-faint); font-size: var(--fs-75); font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; }
.stat dd {
  margin: var(--sp-1) 0 0; color: var(--text-strong); overflow-wrap: anywhere;
  font: 700 var(--fs-150)/1.15 var(--font-mono); font-variant-numeric: tabular-nums;
}
.stat dd.stat-sub { color: var(--text-muted); font: 400 var(--fs-75)/1.4 var(--font-body); }

/* ---- usage chart ---- */
.chart-controls { display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-3); }
.seg { display: inline-flex; border: var(--border-control); border-radius: var(--radius-m); overflow: hidden; }
.seg-btn {
  min-height: 2rem; padding: var(--sp-1) var(--sp-3); border: 0; background: transparent; cursor: pointer;
  color: var(--text-muted); font: 600 var(--fs-75)/1.2 var(--font-body);
  transition: color var(--dur-1) var(--ease-1), background-color var(--dur-1) var(--ease-1);
}
.seg-btn + .seg-btn { border-left: var(--border-control); }
.seg-btn:hover { color: var(--text-strong); background: var(--surface-2); }
.seg-btn[aria-pressed="true"] { color: var(--text-strong); background: var(--surface-2); box-shadow: inset 0 -2px 0 var(--accent); }
.seg-btn:focus-visible { outline-offset: -2px; }
.chart-fig { margin: 0; }
.chart-readout { min-height: 1.6em; margin: 0 0 var(--sp-2); color: var(--text-muted); font-size: var(--fs-875); font-variant-numeric: tabular-nums; }
#usage-chart { height: 13rem; border-radius: var(--radius-s); touch-action: pan-y; }
#usage-chart rect { fill: var(--ember-500); }
#usage-chart rect.is-active { fill: var(--ember-300); }
#usage-chart .grid { stroke: var(--line); stroke-width: 1; }
#usage-chart .base { stroke: var(--line-strong); stroke-width: 1; }
#usage-chart text { fill: var(--text-faint); font: 11px var(--font-body); font-variant-numeric: tabular-nums; }
#usage-chart text.peak { fill: var(--text-quiet); font-weight: 600; }
#usage-chart text.empty { font-size: 13px; }
#usage-chart.is-blank { display: none; }   /* nothing to draw: no empty frame */
.chart-table { max-height: 20rem; overflow-y: auto; margin-bottom: var(--sp-2); }
.chart-fig .chart-note { margin-top: var(--sp-2); }
.usage-split { margin-top: var(--sp-5); align-items: start; }
/* By model / by surface: five columns in half a card. The headers may wrap,
   the cells sit closer, and a long model id only breaks where the page is
   narrow (where the Share column steps aside too). */
.split-table thead th, .split-table thead th.num { white-space: normal; }
.split-table tbody th { white-space: nowrap; }
#dash-view .split-table :is(th, td) { padding-inline: var(--sp-2); }
#dash-view .split-table :is(th, td):first-child { padding-left: var(--sp-4); }
#dash-view .split-table :is(th, td):last-child { padding-right: var(--sp-4); }
@container (max-width: 38rem) {
  .col-share, .col-req { display: none; }
  .split-table tbody th { white-space: normal; }
}

/* Security card: full row; its halves (.grid-2, 18rem minimum each) sit side
   by side where there is room. The password form keeps a readable width. */
#pw-change-form { max-width: 26rem; }

/* Keys table on a narrow dashboard: the key id and the created date move
   under the label (.key-sub), so the table keeps four readable columns
   instead of scrolling sideways. Both forms are in the DOM; only one shows. */
.key-sub { display: none; white-space: nowrap; margin-top: var(--sp-1); color: var(--text-faint); font-size: var(--fs-75); font-weight: 400; }
@container (max-width: 38rem) {
  .keys-table .col-wide { display: none; }
  .key-sub { display: block; }
  #dash-view .table-scroll :is(th, td) { padding-inline: var(--sp-2); }
  #dash-view .table-scroll :is(th, td):first-child { padding-left: var(--sp-3); }
  #dash-view .table-scroll :is(th, td):last-child { padding-right: var(--sp-3); }
}

/* ---- Help & tickets card + thread dialog (W1-S3) ----
   Ticket text is the customer's own words: line breaks are kept, and long
   unbroken runs (masked tokens, URLs) wrap instead of widening the page. */
#help-card h3 { margin-top: var(--sp-6); }
#help-card .field > span.hint { font-weight: 400; color: var(--text-faint); font-size: var(--fs-75); margin: var(--sp-1) 0 0; }
#help-count.over { color: var(--danger-400); }
.ticket-list { list-style: none; margin: 0 0 var(--sp-4); padding: 0; display: grid; gap: var(--sp-2); }
.ticket-list > li.muted { padding-block: var(--sp-2); }
.ticket-row {
  display: grid; gap: var(--sp-1); width: 100%; min-height: var(--tap-min);
  padding: var(--sp-3) var(--sp-4); text-align: left; cursor: pointer;
  background: var(--surface-inset); color: var(--text); font: inherit;
  border: var(--border-1); border-radius: var(--radius-m);
  transition: border-color var(--dur-1) var(--ease-1), background-color var(--dur-1) var(--ease-1);
}
.ticket-row:hover { background: var(--surface-2); border-color: var(--line-control); }
.ticket-subject { color: var(--text-strong); font-weight: 600; overflow-wrap: anywhere; }
.ticket-meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-1) var(--sp-3); color: var(--text-faint); font-size: var(--fs-75); }
.help-attach {   /* the box and exactly what it attaches, read as one unit */
  align-items: start; margin-bottom: var(--sp-2); padding: var(--sp-4);
  background: var(--surface-inset); border: var(--border-1); border-radius: var(--radius-m);
}
.help-check { display: inline-flex; align-items: center; gap: var(--sp-2); min-height: var(--tap-min); color: var(--text-strong); font-weight: 600; cursor: pointer; }
.help-check input, .rate-row input { width: 1.125rem; height: 1.125rem; margin: 0; accent-color: var(--accent); }
.help-preview > p { margin-bottom: var(--sp-2); }
.help-preview .facts { margin-bottom: var(--sp-2); }
#thread-dialog h2 {   /* a subject line (up to 200 chars), not a page title */
  font-size: var(--fs-150); line-height: var(--lh-snug); overflow-wrap: anywhere; padding-right: var(--sp-6);
}
.thread-meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2) var(--sp-3); }
#thread-facts { margin-bottom: var(--sp-4); }
.thread { list-style: none; margin: var(--sp-4) 0; padding: 0; display: grid; gap: var(--sp-3); }
.thread .msg { padding: var(--sp-3) var(--sp-4); background: var(--surface-inset); border: var(--border-1); border-radius: var(--radius-m); }
.thread .msg.from-support { background: var(--surface-2); border-left: 3px solid var(--accent); }
.thread .msg-head { margin: 0 0 var(--sp-1); color: var(--text-muted); font-size: var(--fs-75); font-weight: 600; }
.thread .msg-body { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.rate-row { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin: 0 0 var(--sp-4); padding: 0; border: 0; min-width: 0; }
.rate-row legend { padding: 0; margin-bottom: var(--sp-2); color: var(--text); font-size: var(--fs-875); font-weight: 600; }
.rate-row label { display: inline-flex; align-items: center; gap: var(--sp-2); min-height: var(--tap-min); padding-inline: var(--sp-3); border: var(--border-control); border-radius: var(--radius-m); cursor: pointer; }
