/* Follows the purchasing-tool design standard exactly.
 * Source: purchasing-tool/docs/style/STYLE.md and frontend/app/tokens.css
 *
 * The rules that are easiest to break by accident:
 *
 *  - **Light only.** No dark palette. The original stopped following the OS setting on
 *    2026-08-12, which removes a whole class of bug where a shared component drags dark
 *    colours into a page that is locked to light.
 *  - **No uppercasing or letter-spacing on headings.** In the original's words, "the single
 *    strongest tell of a dated internal tool". Column headers are sentence case, body size, bold.
 *  - **Six type sizes and no others.** 11/12/13/15/17, plus 20 for a section heading.
 *  - **Three weights.** 400 body, 500 emphasis and nav, 600 headings and column headers.
 *  - **One shadow, and only for something that floats.** Menu, popover, toast. A shadow on
 *    a panel that just sits there is decoration.
 *  - **Nothing lifts or slides on hover.** Colour changes, in 100ms.
 *  - No <style> or style="" inside a page. The CSP blocks them.
 */

:root {
  --bg: #f7f8f9;
  --surface: #ffffff;
  --surface-sunken: #f5f6f8;
  --surface-hover: #f7f8f9;
  --surface-selected: #eef4fe;

  --border: #e6e8eb;
  --border-subtle: #f1f3f5;
  --border-strong: #d1d5db;
  /* A control's edge is its whole affordance, so it clears the 3:1 non-text floor. */
  --border-control: #767f8c;

  --text: #0f1115;
  --text-muted: #5f6774;
  --text-faint: #9ca3af;

  --accent: #1f6feb;
  --warn-bg: #fef3c7;
  --warn-fg: #92600e;
  --danger-bg: #fee2e2;
  --danger-fg: #b42318;
  --ok-bg: #dcfce7;
  --ok-fg: #166534;
  --neutral-bg: #f3f4f6;
  --neutral-fg: #4b5563;

  --fs-2xs: 11px;
  --fs-xs: 12px;
  --fs-sm: 12px;
  --fs-base: 13px;
  --fs-lg: 15px;
  --fs-xl: 17px;

  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --pad-x: 16px;

  --r-xs: 6px;
  --r-sm: 8px;
  --r-md: 12px;
  --r-full: 999px;

  --font-ui: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial,
             'Malgun Gothic', sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --shadow-layer: 0 12px 36px rgb(15 17 21 / 16%);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: var(--s5) var(--s4);
  background: var(--bg);
  color: var(--text);
  font: 400 var(--fs-base)/1.45 var(--font-ui);
}
body.narrow { padding-top: 56px; }

main { max-width: 1180px; margin: 0 auto; }
body.narrow main { max-width: 380px; }
body.wide main { max-width: 1180px; }

/* Section heading 20px, card title 17px, subtitle 15px. Sentence case throughout. */
h1 { font-size: 20px; font-weight: 600; margin: 0 0 var(--s1); letter-spacing: .2px; }
.sub { color: var(--text-muted); margin: 0 0 var(--s5); font-size: var(--fs-base); }
.sub.small { font-size: var(--fs-xs); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: var(--pad-x);
  margin-bottom: var(--s3);
}
/* No uppercasing, no letter-spacing. This one line changes the feel more than any other. */
.card h2 {
  font-size: var(--fs-lg);
  font-weight: 600;
  color: var(--text);
  margin: 0 0 var(--s3);
}
.card p.plain { margin: 0; }
.card p.lead { margin: 0 0 var(--s2); }
.card p.note { margin: 0 0 var(--s4); color: var(--text-muted); }
.card p.tight { margin: 0; color: var(--text-muted); }

dl {
  display: grid; grid-template-columns: auto 1fr;
  gap: var(--s2) var(--s5); margin: 0;
}
dt { color: var(--text-muted); }
dd {
  margin: 0; font-family: var(--font-mono); font-size: var(--fs-xs);
  font-variant-numeric: tabular-nums; word-break: break-all;
}

code {
  font-family: var(--font-mono); font-size: var(--fs-xs);
  background: var(--surface-sunken); border: 1px solid var(--border-subtle);
  border-radius: var(--r-xs); padding: 1px 5px;
}
a { color: var(--accent); }
.failed { color: var(--danger-fg); }

/* ------------------------------------------------------------------- Forms */

label {
  display: block; font-size: var(--fs-xs); font-weight: 500;
  color: var(--text-muted); margin-bottom: var(--s1);
}
input[type="email"], input[type="password"], input[type="text"] {
  width: 100%; padding: 7px 9px;
  font: 400 var(--fs-base)/1.45 var(--font-ui);
  color: var(--text); background: var(--surface);
  border: 1px solid var(--border-control); border-radius: var(--r-xs);
  transition: border-color 100ms;
}
input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.field { margin-bottom: var(--s3); }

button {
  font: 600 var(--fs-base)/1.45 var(--font-ui);
  padding: var(--s2) var(--s4);
  border: 1px solid transparent; border-radius: var(--r-xs);
  background: var(--accent); color: #fff; cursor: pointer;
  transition: background-color 100ms, border-color 100ms, color 100ms;
}
button:hover:not(:disabled) { background: #1a5fd0; }
button:disabled { opacity: .5; cursor: default; }
button.quiet {
  background: var(--surface); color: var(--text);
  border-color: var(--border); font-weight: 500;
}
button.quiet:hover:not(:disabled) { color: var(--accent); border-color: var(--accent); }

.error {
  background: var(--danger-bg); color: var(--danger-fg);
  border-radius: var(--r-xs); padding: var(--s2) var(--s3);
  margin-bottom: var(--s3); font-size: var(--fs-base);
}
.pill {
  display: inline-block; padding: 1px 7px; border-radius: var(--r-full);
  background: var(--ok-bg); color: var(--ok-fg);
  font-weight: 600; font-size: var(--fs-xs);
}

.row { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); }
.stack { display: grid; gap: var(--s1); }
.stack div { display: flex; gap: var(--s2); align-items: baseline; }
.stack .arrow { color: var(--text-muted); font-family: var(--font-mono); }

/* The top toolbar. Makes links look like buttons. */
.toolbar { display: flex; gap: var(--s2); align-items: center; }
.toolbar .button-link {
  display: inline-block; font: 500 var(--fs-base)/1.45 var(--font-ui);
  padding: var(--s2) var(--s3); border-radius: var(--r-xs);
  border: 1px solid var(--border); color: var(--text-muted); text-decoration: none;
  transition: color 100ms, border-color 100ms;
}
.toolbar .button-link:hover { color: var(--accent); border-color: var(--accent); }
.toolbar .button-link.back { padding: var(--s1) var(--s2); }

/* ------------------------------------------------ Sign-in and two-factor */

.code-input {
  width: 100%; padding: var(--s2) var(--s3);
  color: var(--text); background: var(--surface);
  border: 1px solid var(--border-control); border-radius: var(--r-xs);
  font-family: var(--font-mono); font-size: var(--fs-xl);
  font-variant-numeric: tabular-nums;
  letter-spacing: .4em; text-align: center;
}
.code-input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.qr {
  background: #fff; border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: var(--s3); width: 200px; margin: 0 auto var(--s3); display: block;
}
.qr svg { display: block; width: 100%; height: auto; }
.secret {
  font-family: var(--font-mono); font-size: var(--fs-xs);
  background: var(--surface-sunken); border: 1px solid var(--border);
  border-radius: var(--r-xs); padding: var(--s2);
  word-break: break-all; text-align: center; margin: 0 0 var(--s3);
}
.steps {
  margin: 0 0 var(--s4); padding-left: var(--s4);
  color: var(--text-muted); font-size: var(--fs-base);
}
.steps li { margin-bottom: var(--s1); }
.steps li strong { color: var(--text); font-weight: 600; }

/* ------------------------------------------------- Setting a password */

.meter {
  height: 3px; border-radius: 2px; background: var(--border);
  margin-top: var(--s1); overflow: hidden;
}
.meter span {
  display: block; height: 100%; width: 0;
  transition: width 100ms, background-color 100ms;
}
.meter span.weak { background: var(--danger-fg); }
.meter span.fair { background: var(--warn-fg); }
.meter span.strong { background: var(--ok-fg); }
.hint { font-size: var(--fs-xs); color: var(--text-muted); margin: var(--s1) 0 0; }
.who {
  font-family: var(--font-mono); font-size: var(--fs-xs);
  background: var(--surface-sunken); border: 1px solid var(--border);
  border-radius: var(--r-xs); padding: var(--s2) var(--s3);
  margin: 0 0 var(--s3); text-align: center;
}

/* ---------------------------------------------------------- Settings */

table {
  width: 100%; border-collapse: separate; border-spacing: 0;
  font-size: var(--fs-base);
}
/* Column headers: sentence case, 12px 600, on a faintly sunken row. No uppercasing. */
th {
  text-align: left; font-size: var(--fs-sm); font-weight: 600;
  color: var(--text); background: var(--surface-sunken);
  padding: var(--s2) var(--s3); white-space: nowrap;
  border-bottom: 1px solid var(--border-strong);
}
td {
  padding: var(--row-pad, 6px 12px);
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}
tbody tr:hover td { background: var(--surface-hover); }
th:first-child, td:first-child { padding-left: var(--s2); }
th:last-child, td:last-child { padding-right: var(--s2); text-align: right; }
.email { font-weight: 500; }
.when {
  color: var(--text-muted); font-size: var(--fs-xs);
  font-variant-numeric: tabular-nums;
}

/* A status always comes with a word. Colour never carries the meaning by itself. */
.tag {
  display: inline-block; padding: 1px 7px; border-radius: var(--r-xs);
  font-size: var(--fs-xs); font-weight: 500; white-space: nowrap;
  background: var(--neutral-bg); color: var(--neutral-fg);
}
.tag.ok { background: var(--ok-bg); color: var(--ok-fg); }
.tag.warn { background: var(--danger-bg); color: var(--danger-fg); }

.actions { display: flex; gap: var(--s1); justify-content: flex-end; flex-wrap: wrap; }
.actions button {
  font-size: var(--fs-xs); font-weight: 500; padding: var(--s1) var(--s2);
  background: var(--surface); color: var(--text); border-color: var(--border);
}
.actions button:hover:not(:disabled) {
  background: var(--surface); border-color: var(--accent); color: var(--accent);
}
.actions button.danger { color: var(--danger-fg); }
.actions button.danger:hover:not(:disabled) {
  border-color: var(--danger-fg); color: var(--danger-fg);
}

.linkbox {
  background: var(--surface-selected); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: var(--s3) var(--s4); margin-bottom: var(--s3);
}
.linkbox p.title {
  margin: 0 0 var(--s2); font-size: var(--fs-base);
  color: var(--text); font-weight: 600;
}
.linkbox p.caption {
  margin: var(--s2) 0 0; color: var(--text-muted); font-size: var(--fs-xs);
}
.linkrow { display: flex; gap: var(--s2); }
.linkrow input {
  flex: 1; font-family: var(--font-mono); font-size: var(--fs-xs);
  padding: var(--s2); border: 1px solid var(--border-control);
  border-radius: var(--r-xs); background: var(--surface); color: var(--text);
}

.newuser { display: flex; gap: var(--s2); align-items: flex-end; flex-wrap: wrap; }
.newuser .field { margin: 0; flex: 1; min-width: 220px; }
.check { display: flex; align-items: center; gap: var(--s1); font-size: var(--fs-base); }
.check input { width: auto; }
.muted-row td { color: var(--text-muted); }

@media (max-width: 40rem) {
  th:nth-child(3), td:nth-child(3), th:nth-child(4), td:nth-child(4) { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
