/* Atlas — the one stylesheet, for the customer portal AND the admin panel.
 *
 * It was called admin.css until Batch 26, kept that way because renaming
 * looked like edits that bought nothing. It bought something in the end:
 * the filename appeared in a <link> on every customer page, so the word
 * "admin" could not be removed from the public site while it stood. Al
 * asked for the staff door to stop being advertised anywhere a customer
 * can see, and a stylesheet named after the admin panel is advertising.
 *
 * DESIGN LANGUAGE: extracted from the Atlas desktop app, not invented.
 * Tokens below come from desktop/src/styles/atlas.css:17-62 and the
 * component shapes from desktop/src/styles/global.css — see the batch
 * report for line-by-line provenance. Al asked for the portal to match the
 * app he already uses, so it does.
 *
 * THE CSP THIS MUST LIVE INSIDE:
 *     default-src 'none'; style-src 'self'; img-src 'self';
 *     form-action 'self'; base-uri 'none'; frame-ancestors 'none'
 *
 * Consequences, all deliberate:
 *   - NO imported sheets, no off-site asset reference of any kind, no
 *     webfonts. `default-src 'none'` covers font-src, so even a self-hosted
 *     font face is blocked. (This comment deliberately spells none of those
 *     out literally: a test greps this file for them, and a rule that its
 *     own documentation trips is a rule nobody trusts.)
 *     The desktop app loads Source Serif 4 / Inter / JetBrains Mono via
 *     bundled npm packages; we cannot, so we use their own declared
 *     fallback stacks and land on system faces. Same shapes, same
 *     hierarchy, different letterforms — an honest limitation.
 *   - NO inline style="" anywhere in any template. Everything is a class.
 *   - Charts are server-rendered inline SVG (atlas_api/charts.py), styled
 *     from here.
 */

:root {
  /* --- extracted verbatim: desktop/src/styles/atlas.css:17-23 --- */
  --atlas-bg: #0e1a2b;
  --atlas-bg-deep: #0a1422;
  --atlas-surface: #16263d;
  --atlas-surface-2: #1e3251;
  --atlas-surface-hover: #233a5d;
  --atlas-border: #2a4061;
  --atlas-border-strong: #3a557d;

  /* atlas.css:25-27 */
  --atlas-accent: #f4b942;
  --atlas-accent-strong: #ffcb66;
  --atlas-accent-dim: rgba(244, 185, 66, 0.15);

  /* atlas.css:29-31 */
  --atlas-text: #e6ecf5;
  --atlas-text-dim: #94a4bd;
  --atlas-text-mute: #6b7c99;

  /* atlas.css:33-36 */
  --atlas-good: #5bd2a0;
  --atlas-warn: #f4b942;
  --atlas-bad: #f47373;
  --atlas-info: #66b5ff;

  /* atlas.css:47-49 */
  --atlas-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --atlas-shadow-md: 0 4px 12px rgba(0, 0, 0, 0.35);

  /* atlas.css:51-57, minus the webfonts the CSP will not load */
  --font-display: "Source Serif 4", "Source Serif Pro", Georgia, serif;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;

  /* atlas.css:60-62 */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 10px;

  /* INVENTED — the desktop app is a fixed-size Electron window with
   * body{overflow:hidden}; it has no page-scrolled web layout and no
   * responsive breakpoints to copy. */
  --page-max: 1100px;
  --gap: 16px;
  --tap: 44px;
}

* { box-sizing: border-box; }

/* global.css:11-19, minus overflow:hidden — that is an Electron window
 * behaviour and would trap a web page's scroll. */
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--atlas-bg);
  color: var(--atlas-text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-wrap: anywhere;
}

a { color: var(--atlas-accent); text-decoration: none; }
a:hover { color: var(--atlas-accent-strong); text-decoration: underline; }

/* ===== topbar — global.css:82-91 ===== */

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 16px;
  background: var(--atlas-bg-deep);
  border-bottom: 1px solid var(--atlas-border);
}

.topbar .brand {
  display: inline-flex;
  align-items: center;
  /* It is a link to the front door on a phone, so it has to be tappable. */
  min-height: var(--tap);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 18px;
  letter-spacing: 0.2px;
  color: var(--atlas-text);
  margin-right: 4px;
}
a.brand:hover { color: var(--atlas-accent-strong); text-decoration: none; }

.topbar nav { display: flex; flex-wrap: wrap; gap: 2px; flex: 1 1 auto; }

.topbar nav a {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  padding: 0 12px;
  border-radius: var(--radius-md);
  color: var(--atlas-text-dim);
  font-size: 13px;
  font-weight: 500;
}
.topbar nav a:hover {
  background: var(--atlas-surface);
  color: var(--atlas-text);
  text-decoration: none;
}
.topbar nav a.current {
  background: var(--atlas-accent-dim);
  color: var(--atlas-accent-strong);
}

.topbar .brand-tag {
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--atlas-accent);
  vertical-align: middle;
}

main {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 24px 16px 64px;
}

.narrow { max-width: 34rem; margin: 0 auto; }

.site-foot {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 20px 16px 40px;
  border-top: 1px solid var(--atlas-border);
  color: var(--atlas-text-mute);
  font-size: 12px;
}

/* ===== headings — global.css:244-257 ===== */

h1 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 28px;
  letter-spacing: 0.2px;
  margin: 0 0 4px;
}

h2 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 16px;
  margin: 32px 0 12px;
}

.muted { color: var(--atlas-text-dim); font-size: 13px; }
.page-sub { color: var(--atlas-text-dim); font-size: 13px; margin: 0 0 28px; }
.footnote { color: var(--atlas-text-mute); font-size: 12px; margin-top: 32px; }
code, .mono { font-family: var(--font-mono); font-size: 13px; }
code {
  background: var(--atlas-bg-deep);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
}

/* ===== card — global.css:259-270 ===== */

.panel, .card {
  background: var(--atlas-surface);
  border: 1px solid var(--atlas-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: var(--gap);
}

.card-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 12px;
}

/* First heading in a card should not push away from the card's own padding. */
.card > h2:first-child, .card-head h2 { margin-top: 0; }

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}
.page-head .page-sub { margin-bottom: 0; }

/* INVENTED — a two-up card row that collapses to one on a phone. */
.cols {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--gap);
  align-items: start;
}
.cols .card { margin-bottom: 0; }

/* INVENTED — the landing page's opening block. */
.hero { padding: 24px 0 8px; }
.hero h1 { font-size: 34px; max-width: 20ch; }
.hero-sub {
  color: var(--atlas-text-dim);
  font-size: 15px;
  max-width: 60ch;
  margin: 12px 0 20px;
}

.total { font-size: 15px; margin-top: 16px; }

/* ===== stat tiles — INVENTED, built from the card + display type.
 * The desktop app has no dashboard equivalent. ===== */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--gap);
  margin-bottom: var(--gap);
}

.stat {
  background: var(--atlas-surface);
  border: 1px solid var(--atlas-border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
}

/* The three parts are spans so the tile is one flow of text to a screen
 * reader; they stack because of this, not because of a wrapper element. */
.stat-label, .stat-value, .stat-note { display: block; }

.stat-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--atlas-text-mute);
  margin-bottom: 8px;
}

.stat-value {
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 600;
  line-height: 1.1;
  color: var(--atlas-text);
}

.stat-accent .stat-value { color: var(--atlas-accent); }
.stat-note { font-size: 12px; color: var(--atlas-text-dim); margin-top: 8px; }

/* ===== status blocks — global.css:583-606 ===== */

/* `.banner` is the portal's name for the same thing the admin panel calls
 * `.warning`. THE ADMIN BANNERS MUST STAY LOUD — a restyle that quietened
 * "BACKUP IS STALE" or "SANDBOX INVOICE" into decoration would be worse
 * than no restyle at all, so `.warning` keeps its full-strength amber and
 * gains a left rule rather than losing anything. */
.warning, .error, .success, .info, .banner {
  display: block;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  font-size: 13px;
  margin: 12px 0;
  border: 1px solid transparent;
}

.warning, .banner-warn {
  background: rgba(244, 185, 66, 0.10);
  border-color: rgba(244, 185, 66, 0.30);
  border-left: 3px solid var(--atlas-warn);
  color: var(--atlas-warn);
}
.error, .banner-bad {
  background: rgba(244, 115, 115, 0.10);
  border-color: rgba(244, 115, 115, 0.30);
  border-left: 3px solid var(--atlas-bad);
  color: var(--atlas-bad);
}
.success, .banner-good {
  background: rgba(91, 210, 160, 0.10);
  border-color: rgba(91, 210, 160, 0.30);
  border-left: 3px solid var(--atlas-good);
  color: var(--atlas-good);
}
.info {
  background: rgba(102, 181, 255, 0.10);
  border-color: rgba(102, 181, 255, 0.30);
  color: var(--atlas-info);
}

/* A banner's own table must not inherit the banner's text colour. */
.warning table, .banner table { color: var(--atlas-text); }
.warning code, .banner code { color: inherit; }

/* ===== status pill — global.css:801-814 ===== */

.pill {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--atlas-text-mute);
  background: var(--atlas-bg-deep);
  border: 1px solid var(--atlas-border);
  border-radius: 999px;
  padding: 3px 10px;
  white-space: nowrap;
}
.pill-good { color: var(--atlas-good); border-color: rgba(91, 210, 160, 0.4); }
.pill-warn { color: var(--atlas-warn); border-color: rgba(244, 185, 66, 0.4); }
.pill-bad  { color: var(--atlas-bad);  border-color: rgba(244, 115, 115, 0.45); }

.status-pending { color: var(--atlas-warn); font-weight: 600; }
.status-active { color: var(--atlas-good); font-weight: 600; }

/* ===== sandbox banner — Batch 16, restyled to the tokens ===== */

.sandbox-banner {
  background: rgba(244, 185, 66, 0.14);
  border-bottom: 1px solid rgba(244, 185, 66, 0.45);
  color: var(--atlas-accent-strong);
  padding: 10px 16px;
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.4px;
}

/* ===== tables — global.css:739-773, made to degrade on a phone ===== */

/* A wide table scrolls INSIDE its own box. The page body must never scroll
 * sideways — that is the difference between a table you can read on a phone
 * and a layout that is broken on one. */
.table-wrap, .table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: var(--gap);
}
.table-wrap {
  background: var(--atlas-surface);
  border: 1px solid var(--atlas-border);
  border-radius: var(--radius-md);
}
.card > .table-scroll:last-child { margin-bottom: 0; }
.table-nested { margin-top: 12px; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  background: var(--atlas-surface);
  border: 1px solid var(--atlas-border);
  border-radius: var(--radius-md);
  margin-bottom: var(--gap);
}

.table-wrap table { border: 0; margin: 0; }

thead th {
  background: var(--atlas-bg-deep);
  text-align: left;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--atlas-text-mute);
  padding: 10px 12px;
  white-space: nowrap;
}

tbody td, tbody th {
  padding: 10px 12px;
  border-top: 1px solid var(--atlas-border);
  color: var(--atlas-text);
  vertical-align: top;
  text-align: left;
}

tbody tr:hover { background: var(--atlas-surface-hover); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.body-cell { max-width: 30rem; overflow-wrap: anywhere; }

/* A label-and-value table, not a grid of records. */
table.keyvalue tbody th {
  width: 12rem;
  color: var(--atlas-text-mute);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

/* ===== buttons — global.css:643-668 ===== */

button, .btn, a.button {
  font: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.2px;
  border: 1px solid var(--atlas-border-strong);
  background: transparent;
  color: var(--atlas-text-dim);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
button:hover, .btn:hover {
  border-color: var(--atlas-accent);
  color: var(--atlas-text);
  text-decoration: none;
}
button:disabled { opacity: 0.45; cursor: not-allowed; }

/* `.button` on a link is the filled call to action; a bare <button> and
 * anything carrying `.ghost` is the outlined one. */
.btn-primary, button.primary, a.button {
  background: var(--atlas-accent);
  border-color: var(--atlas-accent);
  color: #1a1106;
}
.btn-primary:hover, button.primary:hover, a.button:hover {
  background: var(--atlas-accent-strong);
  border-color: var(--atlas-accent-strong);
  color: #1a1106;
  text-decoration: none;
}

.ghost, a.button.ghost {
  background: transparent;
  border-color: var(--atlas-border-strong);
  color: var(--atlas-text-dim);
}
.ghost:hover, a.button.ghost:hover {
  background: var(--atlas-surface-hover);
  border-color: var(--atlas-accent);
  color: var(--atlas-text);
}

form.inline { display: inline-block; margin: 2px 4px 2px 0; }
form.inline label { font-size: 12px; color: var(--atlas-text-dim); }
form.inline input, form.inline select { width: auto; min-width: 12rem; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.action-row { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }

/* ===== inputs — global.css:457-472 ===== */

input[type="text"], input[type="email"], input[type="password"],
select, textarea {
  font: inherit;
  width: 100%;
  min-height: var(--tap);
  background: var(--atlas-bg-deep);
  border: 1px solid var(--atlas-border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  font-size: 14px;
  color: var(--atlas-text);
  transition: border-color 0.12s, background 0.12s;
}
textarea { min-height: 90px; resize: vertical; }

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--atlas-accent);
  background: var(--atlas-bg);
}

form.stacked { max-width: 32rem; }
form.stacked label {
  display: block;
  margin: 16px 0 6px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.3px;
  color: var(--atlas-text-dim);
}

/* ===== charts — INVENTED. The desktop app has none. ===== */

.chart-wrap { margin: 4px 0 8px; }

.chart {
  width: 100%;
  height: auto;
  display: block;
  overflow: visible;
}
.chart-bar { fill: var(--atlas-accent); }
.chart-axis { stroke: var(--atlas-border-strong); stroke-width: 1; }
.chart-label { fill: var(--atlas-text-mute); font-size: 13px; font-family: var(--font-sans); }
.chart-peak { fill: var(--atlas-text-mute); font-size: 13px; font-family: var(--font-sans); }
.chart-empty { fill: var(--atlas-text-mute); font-size: 16px; font-family: var(--font-sans); }

.meter { width: 100%; height: 8px; display: block; margin: 10px 0 6px; }
.meter-track { fill: var(--atlas-bg-deep); stroke: var(--atlas-border); stroke-width: 0.4; }
.meter-fill { fill: var(--atlas-accent); }

/* ===== the one-time key box — Batch 16 ===== */

.keybox { margin: 12px 0 20px; }

.keybox code {
  display: block;
  font-size: 15px;
  padding: 14px 16px;
  background: var(--atlas-bg-deep);
  border: 1px solid var(--atlas-border-strong);
  border-radius: var(--radius-md);
  overflow-wrap: anywhere;
}

pre.connection-block {
  background: var(--atlas-bg-deep);
  border: 1px solid var(--atlas-border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--atlas-text);
}

/* ===== landing doors — Batch 16, restyled ===== */

.doors {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--gap);
  margin: 24px 0;
}
.doors .door {
  background: var(--atlas-surface);
  border: 1px solid var(--atlas-border);
  border-radius: var(--radius-lg);
  padding: 20px;
}
.doors .door h2 { margin-top: 0; }

/* ===== how-it-works — Batch 26 =====
 *
 * EVERY RULE HERE EXISTS BECAUSE THE CSP FORBIDS THE ALTERNATIVE. There is
 * no `'unsafe-inline'` in `style-src`, so an inline `style=""` on the SVG
 * is dropped by the browser and the drawing renders at some arbitrary
 * intrinsic size. Sizing therefore has to live in this file, which is the
 * only stylesheet the policy will load. */

.steps {
  margin: 8px 0 4px;
  padding-left: 22px;
  color: var(--atlas-text-dim);
  font-size: 14px;
  line-height: 1.7;
}
.steps li { margin-bottom: 8px; }
.steps strong { color: var(--atlas-text); font-weight: 600; }

/* The flow strip. `viewBox` + width:100% keeps it readable at 375px. */
.flow { width: 100%; height: auto; display: block; overflow: visible; }

.shots {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--gap);
  margin: 16px 0 8px;
}

.shot { margin: 0; }

/* THE SLOT. Sized to the drawing's 16:10 viewBox, which is also the shape a
 * real screenshot of the app window should be cropped to. Dropping a PNG in
 * here — `<img src="/static/screenshots/atlas-scan.png" alt="...">` — moves
 * nothing: the frame keeps the same box and the caption stays put. */
.shot-frame {
  background: var(--atlas-bg-deep);
  border: 1px solid var(--atlas-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  aspect-ratio: 16 / 10;
}
.shot-frame > svg,
.shot-frame > img {
  width: 100%;
  height: 100%;
  display: block;
}
.mockup { width: 100%; height: auto; display: block; }

.shot figcaption {
  margin-top: 10px;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--atlas-text-dim);
}

/* ===== phone. A friend checking what they owe will do it on their phone.
 * INVENTED — nothing to extract; the app is a fixed desktop window. ===== */

@media (max-width: 720px) {
  main { padding: 16px 12px 48px; }
  h1 { font-size: 22px; }
  .hero h1 { font-size: 26px; }
  .hero-sub { font-size: 14px; }
  .page-head { flex-direction: column; align-items: stretch; }

  /* A link that IS the whole line is an action, and an action on a phone
   * needs a thumb-sized target. A link inside a sentence is left at text
   * height on purpose: padding it out would break the paragraph it lives
   * in, and that is the normal, expected shape of prose everywhere. */
  p > a:only-child, .footnote a, .page-sub a, li > a:only-child,
  /* In stacked-record mode the client name and the period ARE how you get
   * to that record — the whole reason to open the table on a phone. */
  table.responsive td > a:only-child {
    display: inline-block;
    padding: 9px 0;
  }
  form.inline input, form.inline select { width: 100%; min-width: 0; }
  form.inline { display: block; margin: 8px 0; }
  .stat-value { font-size: 26px; }
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat { padding: 14px; }
  .panel, .card { padding: 16px; }
  .topbar { padding: 8px 12px; gap: 8px; }
  .topbar nav a { padding: 0 10px; font-size: 12px; }

  /* Wide tables stop being tables and become stacked records, so nothing
   * overflows sideways at 375px. */
  table.responsive, table.responsive thead, table.responsive tbody,
  table.responsive tr, table.responsive td, table.responsive th {
    display: block;
    width: 100%;
  }
  table.responsive thead { display: none; }
  table.responsive tr {
    border: 1px solid var(--atlas-border);
    border-radius: var(--radius-md);
    margin-bottom: 10px;
    padding: 4px 0;
  }
  table.responsive td { border-top: 0; padding: 6px 12px; text-align: left; }
  table.responsive td.num { text-align: left; }
  table.responsive td::before {
    content: attr(data-label);
    display: block;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--atlas-text-mute);
    margin-bottom: 2px;
  }
}

@media (max-width: 400px) {
  .stats { grid-template-columns: 1fr; }
}
