/* FT Marketing Platform — the agency shell.
 *
 * Deliberately NOT Whizmo-branded. This is a Finclutech tool that will hold several
 * clients; dressing it in one client's palette would make the others look like guests
 * in someone else's product. The warm neutral + workhorse blue below is FT's own.
 *
 * Whizmo's brand colours belong to generated creative, not to the chrome around it —
 * and the brand book's primary orange measures 3.52:1 on white, which fails WCAG AA for
 * body text, so it would be the wrong choice for UI copy regardless.
 *
 * One vocabulary, one file. Every template speaks the same small set of classes
 * (.card, .pill, .note, .stat, .stack-sm …), which is why restyling this file restyles
 * all sixty screens at once — and why `test_stylesheet_coverage.py` can prove no template
 * wears a class that no selector can reach. Add classes here BEFORE using them in a
 * template; the suite fails otherwise, and that is the point.
 */

:root {
  --bg: #f7f6f3;          /* warm paper, not admin grey-blue */
  --side: #fbfaf7;
  --card: #ffffff;
  --ink: #191b22;
  --ink-2: #4a4f60;
  --ink-3: #7e8394;
  --line: #e4e2db;
  --line-2: #efeee9;
  --accent: #1f5fd0;      /* the workhorse blue from the rebuild plan */
  --accent-deep: #17479e;
  --accent-wash: #e9effc;
  --accent-ink: #ffffff;
  --ok: #157347;
  --ok-bg: #e2f1e9;
  --warn: #8a5300;
  --warn-bg: #f9eeda;
  --bad: #a3261f;
  --bad-bg: #fbeae8;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(25, 27, 34, 0.04), 0 4px 16px rgba(25, 27, 34, 0.04);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

html { height: 100%; }
body {
  margin: 0;
  font: 15px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  min-height: 100%;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

.skip {
  position: absolute; left: -9999px; top: 8px; z-index: 100;
  background: var(--card); padding: 8px 14px; border-radius: 8px; box-shadow: var(--shadow);
}
.skip:focus { left: 8px; }

/* ---------------------------------------------------------------- shell
   Signed in, the page is a two-column grid: a sticky sidebar and a content column.
   Signed out (login, 2FA challenge before the shell loads user chrome) the body has no
   .with-side class and everything centres in a single column. */

body.with-side {
  display: grid;
  grid-template-columns: 252px minmax(0, 1fr);
}

.side {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column;
  background: var(--side);
  border-right: 1px solid var(--line);
}

.side-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 20px 10px;
}
.brand { color: var(--ink); font-weight: 700; letter-spacing: -0.2px; white-space: nowrap; font-size: 15px; }
.brand:hover { text-decoration: none; }
.brand span { color: var(--ink-3); font-weight: 500; margin-left: 5px; }
.mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 8px; flex: 0 0 auto;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-deep) 100%);
  color: #fff; font-size: 12.5px; font-weight: 800; letter-spacing: -0.5px;
}

.side-nav { flex: 1; padding: 2px 12px 18px; }
.grouplabel {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--ink-3); margin: 20px 10px 5px;
}
.side-nav a {
  display: flex; align-items: center; gap: 8px;
  padding: 6.5px 10px; border-radius: 8px;
  color: var(--ink-2); font-size: 13.5px; font-weight: 530;
}
.side-nav a:hover { background: var(--line-2); color: var(--ink); text-decoration: none; }
.side-nav a.on { background: var(--accent-wash); color: var(--accent-deep); font-weight: 650; }
.side-nav a .badge { margin-left: auto; }

.side-user {
  border-top: 1px solid var(--line); padding: 14px 20px;
  font-size: 12.5px; color: var(--ink-3);
  display: flex; flex-direction: column; gap: 6px;
}
.side-user .email {
  color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.envtag {
  align-self: flex-start;
  background: var(--warn-bg); color: var(--warn); font-weight: 700;
  padding: 1px 8px; border-radius: 5px; text-transform: uppercase; font-size: 10.5px;
}
.linkish {
  background: none; border: 0; color: var(--ink-3); cursor: pointer; font: inherit;
  padding: 0; text-align: left;
}
.linkish:hover { color: var(--accent); text-decoration: underline; }

/* The content column. */
.content { min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }
main { width: 100%; max-width: 1140px; margin: 0 auto; padding: 34px 40px 70px; flex: 1; }
main.wide { max-width: 1420px; }
body:not(.with-side) main { max-width: 1140px; margin: 0 auto; }

/* Mobile top strip — hidden on desktop, shown when the sidebar goes off-canvas. */
.mobilebar {
  display: none;
  align-items: center; gap: 12px;
  padding: 10px 16px;
  background: var(--side); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 40;
}
.mobilebar .brand { margin-right: auto; }
.menubtn {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--card); color: var(--ink-2); border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 12px; font: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer;
}
/* Own hover, because `button:hover` (0,1,1 with the pseudo-class) out-specifies the bare
   `.menubtn` class and painted the accent fill under ink-2 text — a dark chip with darker
   text, caught in the first mobile screenshot. */
.menubtn:hover { background: var(--line-2); border-color: var(--ink-3); }
/* The scrim is a <button> (it must be reachable and clickable), which drags in the global
   button styling — and `button:hover` (0,1,1) out-specifies `.scrim` (0,1,0), so the moment
   the cursor rested on it the overlay painted solid accent blue. The hover state is pinned
   here for the same reason .menubtn pins its own. */
.scrim, .scrim:hover {
  display: none; position: fixed; inset: 0; z-index: 45;
  background: rgba(25, 27, 34, 0.4); border: 0; padding: 0; width: 100%; border-radius: 0;
}
body.nav-open .scrim { display: block; }

/* ---------------------------------------------------------------- typography */

h1 {
  font-size: 27px; font-weight: 720; margin: 0 0 8px;
  letter-spacing: -0.55px; line-height: 1.18; text-wrap: balance;
}
h2 { font-size: 18.5px; font-weight: 680; margin: 34px 0 12px; letter-spacing: -0.25px; text-wrap: balance; }
h3 { font-size: 12px; margin: 22px 0 8px; text-transform: uppercase;
     letter-spacing: 0.08em; color: var(--ink-3); }
.sub { color: var(--ink-2); margin: 0 0 26px; max-width: 70ch; font-size: 15.5px; }

/* Coloured headings and body text. Scoped to block elements on purpose: a bare `.bad { color }`
   would land on `<span class="badge bad">`, whose white-on-red is set by `.badge` at the same
   specificity — the later rule would win and paint dark red text on a dark red chip. */
h1.ok,   h2.ok,   h3.ok,   p.ok,   li.ok   { color: var(--ok); }
h1.warn, h2.warn, h3.warn, p.warn, li.warn { color: var(--warn); }
h1.bad,  h2.bad,  h3.bad,  p.bad,  li.bad  { color: var(--bad); }

.muted { color: var(--ink-3); }
.small { font-size: 12.5px; }
td.mono, .mono { font-family: var(--mono); font-size: 12.5px; }

.subnav { margin: -14px 0 24px; font-size: 13.5px; color: var(--ink-3); }
.subnav a { margin-right: 2px; font-weight: 550; }

/* ---------------------------------------------------------------- surfaces */

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 22px; margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }

.stat {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow);
}
.stat .n {
  font-size: 30px; font-weight: 720; letter-spacing: -1px; display: block;
  font-variant-numeric: tabular-nums; line-height: 1.15;
}
.stat .k { color: var(--ink-3); font-size: 11.5px; font-weight: 650; text-transform: uppercase;
           letter-spacing: 0.07em; }
.stat .hint { color: var(--ink-2); font-size: 13px; margin-top: 6px; display: block; }
a.stat { color: inherit; display: block; }
a.stat:hover { border-color: var(--accent); text-decoration: none; }

.cards {
  display: grid; gap: 12px; margin: 0 0 20px;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}
.cards .card { padding: 14px 16px; margin: 0; }
.cards .card b {
  display: block; font-size: 27px; font-weight: 720; letter-spacing: -0.8px;
  line-height: 1.15; font-variant-numeric: tabular-nums;
}
.cards .card > span {
  display: block; color: var(--ink-3); font-size: 11.5px; font-weight: 650;
  text-transform: uppercase; letter-spacing: 0.07em; margin-top: 3px;
}
.card.ok   { border-color: #bfe0cd; background: var(--ok-bg); }
.card.ok b   { color: var(--ok); }
.card.warn { border-color: #eddbb2; background: var(--warn-bg); }
.card.warn b { color: var(--warn); }
.card.bad  { border-color: #f0cbc6; background: var(--bad-bg); }
.card.bad b  { color: var(--bad); }

/* The "what needs you" list on the overview — each row is one thing to act on, with
   where it takes you. A row, not a table: these are actions, not data. */
.tasklist { display: grid; gap: 10px; margin: 0 0 8px; }
.task {
  display: flex; align-items: center; gap: 14px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 18px; color: var(--ink); box-shadow: var(--shadow);
}
.task:hover { border-color: var(--accent); text-decoration: none; }
.task .dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; background: var(--ink-3); }
.task.bad .dot  { background: var(--bad); }
.task.warn .dot { background: var(--warn); }
.task.ok .dot   { background: var(--ok); }
.task .t-body { min-width: 0; flex: 1; }
.task .t-body strong { display: block; font-size: 14.5px; }
.task .t-body em { font-style: normal; color: var(--ink-3); font-size: 13px; }
.task .t-count {
  margin-left: auto; flex: 0 0 auto;
  font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ink-2);
}
.task::after { content: "›"; color: var(--ink-3); font-size: 19px; flex: 0 0 auto; }

/* ---------------------------------------------------------------- badges & pills */

.badge {
  display: inline-block; min-width: 18px; padding: 0 6px; margin-left: 3px;
  border-radius: 9px; color: #fff; background: var(--ink-3);
  font-size: 11px; font-weight: 700; text-align: center; line-height: 18px;
  font-variant-numeric: tabular-nums;
}
.badge.bad  { background: #b8352c; }
.badge.ok   { background: #157347; }
.badge.warn { background: #8a5300; }

.pill {
  display: inline-block; padding: 2.5px 10px; border-radius: 999px;
  font-size: 11.5px; font-weight: 650; white-space: nowrap;
}
.pill.ok   { background: var(--ok-bg);   color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad  { background: var(--bad-bg);  color: var(--bad); }
.pill.flat { background: var(--line-2);  color: var(--ink-2); }

/* ---------------------------------------------------------------- tables */

table { width: 100%; border-collapse: collapse; font-size: 14px; }
.scroll-x { overflow-x: auto; }
th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--ink-3); font-weight: 700;
  border-bottom: 1px solid var(--line); padding: 9px 12px;
  white-space: nowrap;
}
td { padding: 12px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
tbody tr:hover td { background: color-mix(in srgb, var(--line-2) 45%, transparent); }
tr:last-child td { border-bottom: 0; }

/* ---------------------------------------------------------------- forms */

label { display: block; font-weight: 620; font-size: 13.5px; margin: 16px 0 5px; }
label .opt { font-weight: 400; color: var(--ink-3); }
input[type=text], input[type=email], input[type=password], select, textarea {
  width: 100%; padding: 9.5px 12px; font: inherit; color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px; background: #fff;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-wash);
}
textarea { font: inherit; resize: vertical; }
textarea.mono { font-family: var(--mono); font-size: 12.5px; }
input.mono { font-family: var(--mono); letter-spacing: 0.12em; }
.help { color: var(--ink-3); font-size: 12.5px; margin-top: 4px; }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; margin: 16px 0 0; }
legend { font-weight: 620; font-size: 13.5px; padding: 0 5px; }
.checks { display: grid; gap: 7px; grid-template-columns: repeat(auto-fit, minmax(175px, 1fr)); }
.checks label { display: flex; gap: 7px; align-items: baseline; margin: 0; font-weight: 400; }
.checks input { width: auto; }
.field { margin: 0 0 12px; }
.field > label { display: block; margin-bottom: 4px; font-weight: 560; }
form.inline { display: inline-flex; gap: 8px; align-items: center; margin: 0; }
ul.tight { margin: 0; padding-left: 18px; }
ul.tight li { margin: 0; }

button, .btn {
  display: inline-block; padding: 9px 16px; font: inherit; font-size: 14px; font-weight: 640;
  border-radius: 8px; border: 1px solid var(--accent);
  background: var(--accent); color: var(--accent-ink); cursor: pointer;
  transition: background-color 0.12s ease, border-color 0.12s ease;
}
button:hover, .btn:hover {
  background: var(--accent-deep); border-color: var(--accent-deep); text-decoration: none;
}
.btn.ghost, button.ghost {
  background: var(--card); color: var(--ink); border-color: var(--line);
}
.btn.ghost:hover, button.ghost:hover { background: var(--line-2); border-color: var(--ink-3); }
.btn.small, button.small { padding: 5px 12px; font-size: 13px; }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button:disabled:hover { background: var(--accent); }
.actions { margin-top: 22px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

details > summary { cursor: pointer; padding: 6px 0; }
details[open] > summary { margin-bottom: 4px; }

/* ---------------------------------------------------------------- notes */

.note {
  padding: 12px 16px; border-radius: 8px; margin-bottom: 14px; font-size: 14px;
  border: 1px solid transparent; border-left-width: 3px;
}
.note.ok    { background: var(--ok-bg);   color: var(--ok);   border-color: #bfe0cd; border-left-color: var(--ok); }
.note.warn  { background: var(--warn-bg); color: var(--warn); border-color: #eddbb2; border-left-color: var(--warn); }
.note.error { background: var(--bad-bg);  color: var(--bad);  border-color: #f0cbc6; border-left-color: var(--bad); }
.note.info  { background: var(--accent-wash); color: #1c3766; border-color: #cbd9f6; border-left-color: var(--accent); }
.note pre { margin: 8px 0 0; white-space: pre-wrap; font-size: 13px; }

.empty {
  text-align: center; padding: 52px 24px; color: var(--ink-2);
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--card);
  box-shadow: var(--shadow);
}
.empty p { margin: 0 0 18px; }

.foot {
  border-top: 1px solid var(--line); padding: 16px 40px; color: var(--ink-3);
  font-size: 12.5px;
}

/* ---------------------------------------------------------------- login */

.login-wrap { max-width: 392px; margin: 11vh auto 0; padding: 0 22px; }
.login-wrap .card { padding: 30px 28px; }
.login-wrap h1 { font-size: 21px; }
.login-wrap button { width: 100%; margin-top: 20px; }
.login-brand { display: flex; align-items: center; gap: 10px; margin: 0 0 18px; }

/* ------------------------------------------------------------------ version diff (FR-6.3) */
.diff {
  border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px;
  background: var(--card); white-space: pre-wrap; line-height: 1.65;
  font-size: 15px; overflow-wrap: break-word;
}
.diff ins {
  background: #dff3e3; color: #14532d; text-decoration: none;
  border-radius: 3px; padding: 0 2px;
}
.diff del {
  background: #fbe0e0; color: #7f1d1d; text-decoration: line-through;
  border-radius: 3px; padding: 0 2px;
}

/* ------------------------------------------------------------------ bulk approval (FR-6.5) */
.bulkbar {
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--card); margin: 0 0 16px; box-shadow: var(--shadow);
}
.bulkbar .count { font-weight: 600; }
td.pick { width: 34px; text-align: center; }

/* ---------------------------------------------------------------- two-factor */

/* Deliberately white regardless of theme. The QR is rendered black-on-white because phone
   cameras are unreliable on inverted codes, so the quiet zone must stay light too. */
.qr {
  max-width: 232px; margin: 0 0 22px; background: #ffffff;
  padding: 10px; border: 1px solid var(--line); border-radius: var(--radius);
}
.qr svg { width: 100%; height: auto; display: block; }
.codes {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px; margin: 0 0 16px; max-width: 640px;
}
.codes span {
  background: var(--card); border: 1px solid var(--line); border-radius: 8px;
  padding: 9px 12px; text-align: center; letter-spacing: 0.06em; font-size: 13px;
}

/* ------------------------------------------------------------------ sidebar off-canvas
   Below 960px the sidebar slides in over the content instead of owning a column. */
@media (max-width: 960px) {
  body.with-side { display: block; }
  .mobilebar { display: flex; }
  .side {
    position: fixed; top: 0; bottom: 0; left: 0; width: 276px; z-index: 50;
    transform: translateX(-103%);
    box-shadow: 0 0 40px rgba(25, 27, 34, 0.25);
  }
  body.nav-open .side { transform: translateX(0); }
  main { padding: 22px 16px 60px; }
  .foot { padding: 16px; }
  h1 { font-size: 23px; }
  h2 { font-size: 17px; }
}
@media (prefers-reduced-motion: no-preference) {
  .side { transition: transform 0.18s ease; }
}

/* ------------------------------------------------------------------ mobile (FR-6.6, NFR-05)
   Review and approval have to work on a phone: the approver is one person (D-10) and the
   same-day target (D-37) does not wait for them to reach a desk.

   Tables become stacked rows below 640px rather than staying as tables in a scroller. A
   horizontal scroller is fine for a wide data grid nobody has to act on, but the queue is
   where somebody taps Approve — and a control you have to scroll sideways to find is a
   control that gets missed. */
@media (max-width: 640px) {
  main, main.wide { padding: 18px 12px 50px; }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  table.stack-sm thead { display: none; }
  table.stack-sm, table.stack-sm tbody, table.stack-sm tr, table.stack-sm td {
    display: block; width: 100%;
  }
  table.stack-sm tr {
    border: 1px solid var(--line); border-radius: 8px;
    padding: 10px 12px; margin: 0 0 10px; background: var(--card);
  }
  table.stack-sm td { border: 0; padding: 3px 0; }
  table.stack-sm tbody tr:hover td { background: transparent; }
  table.stack-sm td::before {
    content: attr(data-label); display: block;
    font-size: 11px; letter-spacing: .04em; text-transform: uppercase;
    color: var(--ink-2); margin-bottom: 2px;
  }
  table.stack-sm td:empty { display: none; }
  table.stack-sm td.pick { width: auto; text-align: left; }

  /* Actions become full-width so they are tappable rather than aimed at. */
  table.stack-sm td form { display: block; }
  table.stack-sm td button, .bulkbar button { width: 100%; padding: 11px 14px; }
  .bulkbar { flex-direction: column; align-items: stretch; }

  .stack label { display: block; }
  .stack input, .stack select, .stack textarea { width: 100%; box-sizing: border-box; }
  .row { flex-direction: column; align-items: stretch; }
  .row input, .row select, .row button { width: 100%; box-sizing: border-box; }
}
