/*
  Design tokens copied verbatim from web/dashboard/src/style.css (which
  copied them from web/contact) — kept as a literal copy, not a shared
  import, because all three apps are separate builds/bundles/CloudFront
  distributions, but the values must stay identical so the ops console
  reads as part of the same product family as the customer-facing pages
  instead of a bolted-on internal tool. This intentionally reverses an
  earlier design decision (a deliberately distinct amber/slate palette
  "so a screenshot is never confusable with the customer-facing product")
  in favor of visual consistency, per explicit direction.

  Font paths use './fonts/...' rather than web/contact and web/dashboard's
  './assets/fonts/...' — those two ship a CSS relative-path bug (the
  stylesheet itself lives in .../assets/, so './assets/fonts/...' resolves
  to a nonexistent .../assets/assets/fonts/... in the browser and silently
  404s, falling back to the system font stack; verified live 2026-07-14,
  see foundly-reimagined-redesign memory's "verified" claim, which checked
  the wrong URL). Not fixed here since it's out of scope for this app —
  fixed locally by pointing at where build.mjs actually copies fonts.

  Theme: same data-theme="light"|"dark" convention as the rest of the
  project (see theme-init.js). A few extra tokens beyond web/contact's set
  (shadows, hover-only border/text tints) match web/dashboard's superset
  rather than web/contact's, since the ops console has the same kind of
  card/table/focus-ring UI patterns dashboard does.
*/
@font-face {
  font-family: 'Bricolage Grotesque';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url('./fonts/bricolage-grotesque-variable.woff2') format('woff2');
}
@font-face {
  font-family: 'Instrument Sans';
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url('./fonts/instrument-sans-variable.woff2') format('woff2');
}

:root {
  --color-paper: #F7F5F1;
  --color-surface: #FBFAF7;
  --color-surface-2: #FFFFFF;
  --color-ink: #171410;
  --color-ink-muted: #6F6A60;
  --color-ink-soft: #9C968A;
  --color-ink-faint: #E4DFD2;
  --color-ink-faintest: #E1DCCF;
  --color-border-hover: #CFC8B7;
  --color-border: #8A806C;
  --color-accent: #D94F30;
  --color-accent-hover: #A03318;
  --color-accent-text: var(--color-accent-hover);
  --color-accent-ink: #F7F5F1;
  --color-warning: #C8862A;
  --color-warning-bg: #F7EEDD;
  --color-warning-text: #171410;
  --color-success: #3F6B34;
  --color-success-bg: #E1E8D5;
  --color-danger: #8A1F11;
  --color-danger-bg: #F5E3DE;
  --color-danger-hover: #69180D;
  --shadow-card: 0 4px 16px rgba(23, 20, 15, 0.08);
  --shadow-sm: 0 1px 2px rgba(23, 20, 15, 0.12);
  --shadow-ring-subtle: inset 0 0 0 1px rgba(23, 20, 15, 0.12);
  --color-shimmer-highlight: #FBFAF5;
  --shadow-focus: 0 0 0 3px rgba(217, 79, 48, 0.16);
  --shadow-focus-strong: 0 0 0 3px rgba(217, 79, 48, 0.28);

  --font-display: "Bricolage Grotesque", "Avenir Next", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-body: "Instrument Sans", "Segoe UI", system-ui, -apple-system, sans-serif;

  --radius: 16px;
  --space-1: 8px;
  --space-2: 16px;
  --space-3: 24px;
  --space-4: 32px;
  --space-6: 48px;

  --target-min: 48px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --color-paper: #1C1913;
    --color-surface: #242019;
    --color-surface-2: #2A251D;
    --color-ink: #F0EDE4;
    --color-ink-muted: #A39C8C;
    --color-ink-soft: #857F70;
    --color-ink-faint: #362F24;
    --color-ink-faintest: #332E25;
    --color-border-hover: #453D2F;
    --color-border: #746A5A;
    --color-accent: #D68876;
    --color-accent-hover: #CE8574;
    --color-accent-text: var(--color-accent-hover);
    --color-accent-ink: #171410;
    --color-warning: #E0A44C;
    --color-warning-bg: #3A2E18;
    --color-warning-text: #F0EDE4;
    --color-success: #7FA66C;
    --color-success-bg: #2E3B24;
    --color-danger: #D24326;
    --color-danger-bg: #3A211B;
    --color-danger-hover: #E76548;
    --shadow-card: 0 4px 16px rgba(0, 0, 0, 0.35);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-ring-subtle: inset 0 0 0 1px rgba(255, 255, 255, 0.14);
    --color-shimmer-highlight: #322C22;
    --shadow-focus: 0 0 0 3px rgba(214, 136, 118, 0.25);
    --shadow-focus-strong: 0 0 0 3px rgba(214, 136, 118, 0.35);
  }
}
:root[data-theme="dark"] {
  --color-paper: #1C1913;
  --color-surface: #242019;
  --color-surface-2: #2A251D;
  --color-ink: #F0EDE4;
  --color-ink-muted: #A39C8C;
  --color-ink-soft: #857F70;
  --color-ink-faint: #362F24;
  --color-ink-faintest: #332E25;
  --color-border-hover: #453D2F;
  --color-border: #746A5A;
  --color-accent: #D68876;
  --color-accent-hover: #CE8574;
  --color-accent-text: var(--color-accent-hover);
  --color-accent-ink: #171410;
  --color-warning: #E0A44C;
  --color-warning-bg: #3A2E18;
  --color-warning-text: #F0EDE4;
  --color-success: #7FA66C;
  --color-success-bg: #2E3B24;
  --color-danger: #D24326;
  --color-danger-bg: #3A211B;
  --color-danger-hover: #E76548;
  --shadow-card: 0 4px 16px rgba(0, 0, 0, 0.35);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-ring-subtle: inset 0 0 0 1px rgba(255, 255, 255, 0.14);
  --color-shimmer-highlight: #322C22;
  --shadow-focus: 0 0 0 3px rgba(214, 136, 118, 0.25);
  --shadow-focus-strong: 0 0 0 3px rgba(214, 136, 118, 0.35);
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--color-paper);
  color: var(--color-ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  min-height: 100%;
}

h1, h2, .display {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
}

.panel-title { font-family: var(--font-display); font-size: 22px; margin: 0 0 4px; color: var(--color-ink); }
.panel-subtitle { color: var(--color-ink-muted); margin: 0 0 var(--space-3); font-size: 14px; }
.section-title { font-family: var(--font-display); font-size: 16px; font-weight: 700; margin: var(--space-3) 0 var(--space-1); }
.muted { color: var(--color-ink-muted); }
.owner-note { margin-top: var(--space-1); color: var(--color-ink-muted); font-size: 15px; }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: var(--space-1); }
.label-sm {
  font-family: var(--font-display);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-ink-soft);
  display: block;
  margin-bottom: 6px;
}
.label-block { display: block; }

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  min-height: 40px;
  padding: 10px 18px;
  border-radius: var(--radius);
  border: none;
  font-family: var(--font-display);
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 200ms ease-out, opacity 200ms ease-out, border-color 200ms ease-out, color 200ms ease-out;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* --color-accent (Signal clay, #D94F30) is the primary-action color per the
   design brief's own labeling — see web/dashboard's .btn-primary comment
   for the palette update this supersedes. */
.btn-primary { background: var(--color-accent); color: var(--color-accent-ink); }
.btn-primary:hover:not(:disabled) { background: var(--color-accent-hover); }

.btn-secondary { background: var(--color-surface); color: var(--color-ink); border: 1px solid var(--color-ink-faint); }
.btn-secondary:hover:not(:disabled) { background: var(--color-ink-faint); }

.btn-danger { background: var(--color-danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: var(--color-danger-hover); }
.btn-danger-outline { background: transparent; border: 1px solid var(--color-danger); color: var(--color-danger); }
.btn-danger-outline:hover:not(:disabled) { background: var(--color-danger-bg); }

/*
  --color-accent is the design's "Safe" swatch — reserved for
  status/safety signals (status-active, spam-deliver) and genuine outbound
  links, never for plain row identity or an in-place toggle. A table row's
  own name/label stays ink even when it's the clickable element (matches
  web/dashboard's <strong className="tag-card-label">, which is plain ink,
  never colored, even though that card's separate Edit/Preview/Pause
  actions do use accent-colored .btn-link — those are link-phrased CTAs,
  not identity text).
*/
.row-title-btn {
  background: none;
  border: none;
  padding: 0;
  color: var(--color-ink);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: inherit;
  text-align: left;
  cursor: pointer;
}
.row-title-btn:hover { text-decoration: underline; }

/* --- Forms --- */
input[type="text"], input[type="email"], input[type="password"], input[type="date"], select {
  width: 100%;
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--color-ink);
  background: var(--color-surface);
  border: 1px solid var(--color-ink-faint);
  border-radius: var(--radius);
  padding: 11px var(--space-2);
  min-height: 44px;
}
input, select, textarea {
  transition: border-color 150ms ease-out, box-shadow 150ms ease-out;
}
input:focus, select:focus, textarea:focus,
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: var(--shadow-focus);
}

.inline-form { display: flex; gap: var(--space-1); align-items: flex-start; margin-bottom: var(--space-3); flex-wrap: wrap; }
.inline-form input, .inline-form select { width: auto; flex: 1; min-width: 200px; }

.banner { padding: 12px 16px; border-radius: 8px; background: var(--color-ink-faint); color: var(--color-ink); font-size: 14px; }
.banner.danger { background: var(--color-danger-bg); color: var(--color-danger); }

/* --- Login --- */
.login-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: var(--space-2); }
.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--color-surface);
  border: 1px solid var(--color-ink-faint);
  border-radius: var(--radius);
  padding: var(--space-4);
}
.login-card h1 { font-size: 22px; margin-bottom: var(--space-1); }
.login-card .btn-primary { width: 100%; margin-top: var(--space-3); }

/*
  Sidebar nav — same shape as web/dashboard's Reimagined shell. Mobile-first
  base below renders as a horizontal top bar; the >=760px media query at
  the bottom turns it into the vertical sidebar.
*/
.dash-shell { display: flex; flex-direction: column; min-height: 100vh; }
.dash-sidebar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-2);
  border-bottom: 1px solid var(--color-ink-faint);
  background: var(--color-surface);
  flex-shrink: 0;
  overflow-x: auto;
}
@media (min-width: 480px) {
  .dash-sidebar { gap: var(--space-3); padding: var(--space-2); }
}

.dash-brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
  color: var(--color-ink);
  background: none;
  border: none;
  padding: 6px 4px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: opacity 150ms ease-out;
}
.dash-brand:hover { opacity: 0.7; }
.dash-brand:focus-visible { outline: none; box-shadow: var(--shadow-focus-strong); }
.dash-brand-mark {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--color-ink);
  color: var(--color-paper);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 14px;
  flex-shrink: 0;
}

.dash-nav { display: flex; gap: 4px; flex-shrink: 0; }
.dash-nav-item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 13.5px;
  background: none;
  border: none;
  border-radius: 999px;
  padding: 10px 14px;
  min-height: var(--target-min);
  color: var(--color-ink-muted);
  cursor: pointer;
  transition: background-color 150ms ease-out, color 150ms ease-out;
}
.dash-nav-item-icon-label { display: inline-flex; align-items: center; gap: 6px; }
.dash-nav-item:hover { background: var(--color-ink-faint); color: var(--color-ink); }
.dash-nav-item-active, .dash-nav-item-active:hover { background: var(--color-surface-2); color: var(--color-ink); border: 1px solid var(--color-ink-faint); }

@media (max-width: 420px) {
  .dash-nav-item-label { display: none; }
  .dash-nav-item { padding: 10px; }
}

.dash-sidebar-footer { display: flex; align-items: center; gap: var(--space-2); flex-shrink: 0; }
.account-email { color: var(--color-ink-muted); font-size: 13px; white-space: nowrap; }
.staff-identity { color: var(--color-ink-muted); font-size: 13px; white-space: nowrap; }

.dash-main { flex: 1; padding: var(--space-4) var(--space-2); max-width: 1100px; margin: 0 auto; width: 100%; }

@media (min-width: 760px) {
  .dash-shell { flex-direction: row; }
  .dash-sidebar {
    flex-direction: column;
    align-items: stretch;
    width: 236px;
    flex-shrink: 0;
    height: 100vh;
    position: sticky;
    top: 0;
    border-bottom: none;
    border-right: 1px solid var(--color-ink-faint);
    padding: var(--space-3) var(--space-2);
    overflow-x: visible;
    overflow-y: auto;
  }
  .dash-brand { padding: 0 6px; margin-bottom: var(--space-4); }
  .dash-nav { flex-direction: column; gap: 3px; flex: 1; }
  .dash-nav-item { justify-content: flex-start; padding: 11px 12px; }
  .dash-nav-item-label { display: inline; }
  .dash-sidebar-footer { flex-direction: column; align-items: stretch; gap: var(--space-1); margin-top: auto; padding-top: var(--space-2); border-top: 1px solid var(--color-ink-faint); }
  .account-email, .staff-identity { padding: 0 6px; white-space: normal; }
}

.theme-picker { display: inline-flex; gap: 2px; padding: 3px; background: var(--color-ink-faint); border-radius: 10px; }
.theme-picker-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border: none;
  border-radius: 7px;
  background: none;
  color: var(--color-ink-muted);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 150ms ease-out, color 150ms ease-out;
}
.theme-picker-btn:hover { color: var(--color-ink); }
.theme-picker-btn-active { background: var(--color-surface); color: var(--color-accent); box-shadow: var(--shadow-sm); }
@media (min-width: 760px) {
  .theme-picker { justify-content: stretch; }
  .theme-picker-btn { flex: 1; justify-content: center; }
}

/* --- Tables --- */
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; margin-bottom: var(--space-3); }
.data-table th {
  text-align: left;
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-ink-soft);
  border-bottom: 1px solid var(--color-ink-faint);
  padding: var(--space-1) 10px;
}
.data-table td { padding: 12px 10px; border-bottom: 1px solid var(--color-ink-faintest); }
.data-table tbody tr:hover { background: var(--color-surface); }
.data-table-compact td, .data-table-compact th { padding: 8px 10px; }
.log-message { font-family: monospace; font-size: 12px; white-space: pre-wrap; }
.row-selected, .row-selected:hover { background: var(--color-surface-2); box-shadow: var(--shadow-ring-subtle); }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.detail-row td { background: var(--color-paper); padding: var(--space-2) var(--space-3); }
.detail-row:hover { background: var(--color-paper); }

/* --- Badges --- */
.status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: capitalize;
  letter-spacing: 0.02em;
}
.status-active, .status-spam-deliver, .status-ok, .status-email-delivery { background: var(--color-success-bg); color: var(--color-success); }
.status-paused, .status-spam-flag, .status-approaching, .status-grace, .status-email-complaint { background: var(--color-warning-bg); color: var(--color-warning-text); }
.status-spam-quarantine, .status-throttled, .status-email-bounce { background: var(--color-danger-bg); color: var(--color-danger); }
.status-unclaimed { background: color-mix(in srgb, var(--color-accent) 18%, transparent); color: var(--color-accent-text); }

/* --- Message inspection / boxes ---
   Background-only surfaces (no border) — the tables around them already
   provide plenty of line-work, so bordered boxes here doubled the frame. */
.inspect-box, .message-body-box, .kill-switch-box {
  border-radius: var(--radius);
  background: var(--color-surface-2);
}
.inspect-box { margin-top: var(--space-2); padding: var(--space-2); }
.message-body-box { margin-top: var(--space-2); padding: var(--space-2); white-space: pre-wrap; }
.kill-switch-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: var(--space-2);
  margin-bottom: var(--space-3);
  flex-wrap: wrap;
}

.messages-section { margin-top: var(--space-1); }
