/* ==========================================================================
   Hyve Outreach — built on the HyveChain design system
   "Term sheet meets trading terminal": Archivo + IBM Plex Mono, gold on
   near-black, 2px corners, hairline rules. Dark is the default; light is a
   deliberate second theme, not an inversion.
   ========================================================================== */

:root {
  /* brand */
  --gold: #c9a227;
  --gold-bright: #e6c15c;
  --gold-deep: #8f7118;
  --gold-rgb: 201, 162, 39;

  /* dark theme (default) */
  --bg0: #0a0a0c;
  --bg1: #0e0f12;
  --bg2: #14151a;
  --bg3: #1a1b21;
  --ink: #ecebe6;
  --ink2: #a6a69e;
  --ink3: #71716a;
  --line: rgba(236, 235, 230, 0.08);
  --line-strong: rgba(236, 235, 230, 0.16);
  --accent-ink: var(--gold-bright);
  --ok: #4caf7d;
  --warn: #d9a441;
  --bad: #c25b52;
  --info: #5a8fd6;
  --card-shadow: 0 24px 60px -30px rgba(0, 0, 0, 0.8);
  --on-gold: #14120a;

  /* chart series — validated for CVD separation and contrast on --bg1 */
  --c1: #b98c00;
  --c2: #3d84d6;
  --c3: #27a96c;

  --font-sans: 'Archivo', 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'IBM Plex Mono', 'SFMono-Regular', Consolas, monospace;

  --radius: 2px;
  --sidebar: 244px;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --t-fast: 0.18s var(--ease-out);
  --t-med: 0.4s var(--ease-out);

  color-scheme: dark;
}

html[data-theme='light'] {
  --bg0: #f4f3ee;
  --bg1: #faf9f5;
  --bg2: #ffffff;
  --bg3: #eceae2;
  --ink: #17160f;
  --ink2: #55544c;
  --ink3: #8b8a80;
  --line: rgba(23, 22, 15, 0.1);
  --line-strong: rgba(23, 22, 15, 0.22);
  --accent-ink: var(--gold-deep);
  --ok: #2e7d57;
  --warn: #9c6f12;
  --bad: #a8453c;
  --info: #2a5da8;
  --card-shadow: 0 20px 50px -30px rgba(40, 36, 20, 0.35);
  --c1: #8f7118;
  --c2: #2a5da8;
  --c3: #1f7a52;
  color-scheme: light;
}

/* ---------- Reset & base ---------- */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
}
body {
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  background: var(--bg0);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  transition: background 0.35s ease, color 0.35s ease;
}
img,
svg {
  max-width: 100%;
  display: block;
}
a {
  color: var(--accent-ink);
  text-decoration: none;
  transition: color var(--t-fast);
}
a:hover {
  color: var(--gold-bright);
}
html[data-theme='light'] a:hover {
  color: var(--gold);
}
ul,
ol {
  list-style: none;
}
::selection {
  background: rgba(var(--gold-rgb), 0.28);
  color: var(--ink);
}
:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}
:focus:not(:focus-visible) {
  outline: none;
}
:where(div, section, main, aside, li, dd, td) {
  min-width: 0;
}

h1,
h2,
h3,
h4 {
  font-weight: 560;
  line-height: 1.1;
  letter-spacing: -0.015em;
  font-stretch: 108%;
  text-wrap: balance;
}
h1 {
  font-size: clamp(1.7rem, 2.6vw, 2.2rem);
  font-weight: 590;
  letter-spacing: -0.022em;
}
h2 {
  font-size: 1.02rem;
}
h3 {
  font-size: 0.95rem;
}
p {
  margin: 0 0 10px;
}

/* ---------- Typographic primitives from the design system ---------- */
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent-ink);
}
.eyebrow::before {
  content: '';
  width: 26px;
  height: 1px;
  background: var(--gold);
  flex: none;
}
.sec-label {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink3);
}
.mono {
  font-family: var(--font-mono);
  font-feature-settings: 'tnum' 1;
  font-size: 0.8rem;
}
.num {
  font-variant-numeric: tabular-nums;
}
.muted {
  color: var(--ink3);
}
.dim {
  color: var(--ink2);
}
.small {
  font-size: 0.8rem;
}
.lede {
  color: var(--ink2);
  max-width: 68ch;
}
.hidden {
  display: none !important;
}
.nowrap {
  white-space: nowrap;
}
.right {
  text-align: right;
}
.flex {
  display: flex;
  gap: 10px;
  align-items: center;
}
.flex-wrap {
  flex-wrap: wrap;
}
.grow {
  flex: 1;
}
.mt {
  margin-top: 16px;
}
.mb {
  margin-bottom: 16px;
}
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 320px;
}
code {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  background: var(--bg3);
  padding: 1px 5px;
  border-radius: var(--radius);
}
pre {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  background: var(--bg0);
  border: 1px solid var(--line);
  padding: 14px;
  border-radius: var(--radius);
  overflow: auto;
  white-space: pre-wrap;
  color: var(--ink2);
}
hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 18px 0;
}
.rule {
  height: 1px;
  background: var(--line-strong);
  margin: 20px 0;
}

/* ---------- App layout ---------- */
.app {
  display: grid;
  grid-template-columns: var(--sidebar) 1fr;
  min-height: 100vh;
}
.sidebar {
  background: var(--bg1);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  scrollbar-width: thin;
}
.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 22px 20px 20px;
  border-bottom: 1px solid var(--line);
}
/* The logo is a gold ring on transparency, so it reads on both surfaces unchanged.
   A 128px source keeps the thin ring crisp on high-density screens. */
.brand img {
  width: 34px;
  height: 34px;
  flex: none;
  object-fit: contain;
}
.auth-card .brand img {
  width: 52px;
  height: 52px;
}
.brand-name {
  font-weight: 620;
  font-stretch: 118%;
  letter-spacing: 0.06em;
  font-size: 0.95rem;
  line-height: 1.1;
}
.brand-name em {
  font-style: normal;
  color: var(--accent-ink);
}
.brand-sub {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink3);
  margin-top: 3px;
}

.nav {
  padding: 14px 0 8px;
  flex: 1;
}
.nav-group {
  padding: 0 20px;
  margin: 16px 0 6px;
}
.nav-group:first-child {
  margin-top: 0;
}
.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 20px;
  color: var(--ink2);
  font-size: 0.86rem;
  font-weight: 500;
  border-left: 2px solid transparent;
  transition: color var(--t-fast), background var(--t-fast), border-color var(--t-fast);
}
.nav a .code {
  font-family: var(--font-mono);
  font-size: 0.64rem;
  letter-spacing: 0.1em;
  color: var(--ink3);
  min-width: 26px;
  transition: color var(--t-fast);
}
.nav a:hover {
  color: var(--ink);
  background: color-mix(in srgb, var(--ink) 4%, transparent);
}
.nav a.active {
  color: var(--ink);
  border-left-color: var(--gold);
  background: rgba(var(--gold-rgb), 0.08);
}
.nav a.active .code {
  color: var(--accent-ink);
}
.nav a .badge {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  color: var(--on-gold);
  background: var(--gold);
  padding: 1px 6px;
  border-radius: var(--radius);
}

.sidebar-foot {
  border-top: 1px solid var(--line);
  padding: 14px 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.switcher {
  display: flex;
  gap: 6px;
}
.switcher button {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 6px 0;
  background: transparent;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--ink3);
  cursor: pointer;
  transition: all var(--t-fast);
}
.switcher button:hover {
  color: var(--ink);
  border-color: var(--ink3);
}
.switcher button.on {
  background: var(--gold);
  border-color: var(--gold);
  color: var(--on-gold);
}
.user-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: var(--ink2);
  gap: 10px;
}

.main {
  min-width: 0;
  padding: 28px clamp(20px, 3vw, 40px) 72px;
}
.loading {
  color: var(--ink3);
  padding: 60px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line-strong);
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.page-head .sub {
  color: var(--ink2);
  margin-top: 8px;
  font-size: 0.88rem;
  max-width: 78ch;
}
.page-head h1 {
  margin-top: 10px;
}
.page-head .actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 18px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--ink);
  background: transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast), transform var(--t-fast);
}
.btn:hover:not(:disabled) {
  border-color: var(--ink2);
  background: color-mix(in srgb, var(--ink) 5%, transparent);
}
.btn:active:not(:disabled) {
  transform: translateY(1px);
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.btn-primary {
  background: var(--gold);
  border-color: var(--gold);
  color: var(--on-gold);
}
.btn-primary:hover:not(:disabled) {
  background: var(--gold-bright);
  border-color: var(--gold-bright);
  color: var(--on-gold);
}
.btn-danger {
  border-color: color-mix(in srgb, var(--bad) 55%, transparent);
  color: var(--bad);
}
.btn-danger:hover:not(:disabled) {
  background: color-mix(in srgb, var(--bad) 12%, transparent);
  border-color: var(--bad);
}
.btn-ok {
  border-color: color-mix(in srgb, var(--ok) 55%, transparent);
  color: var(--ok);
}
.btn-ok:hover:not(:disabled) {
  background: color-mix(in srgb, var(--ok) 12%, transparent);
  border-color: var(--ok);
}
.btn-sm {
  height: 30px;
  padding: 0 11px;
  font-size: 0.65rem;
  letter-spacing: 0.1em;
}
.btn-lg {
  height: 48px;
  padding: 0 26px;
}
.btn-block {
  width: 100%;
}
.btn-group {
  display: inline-flex;
  gap: 6px;
  flex-wrap: wrap;
}
.link {
  background: none;
  border: 0;
  color: var(--accent-ink);
  cursor: pointer;
  font: inherit;
  padding: 0;
  border-bottom: 1px solid transparent;
}
.link:hover {
  border-bottom-color: var(--gold);
}
.btn-text {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent-ink);
  border-bottom: 1px solid transparent;
  padding-bottom: 2px;
  cursor: pointer;
  background: none;
  border-left: 0;
  border-right: 0;
  border-top: 0;
  transition: gap var(--t-fast), border-color var(--t-fast);
}
.btn-text:hover {
  border-bottom-color: var(--gold);
  gap: 11px;
}

/* ---------- Panels, grid, stats ---------- */
.card {
  background: var(--bg1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
  transition: border-color var(--t-med);
}
html[data-theme='light'] .card {
  background: var(--bg2);
}
.card + .card {
  margin-top: 16px;
}
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 14px;
  padding-bottom: 12px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.card-head h2 {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink2);
}

.grid {
  display: grid;
  gap: 16px;
}
.grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.grid-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.grid-6 {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}
@media (max-width: 1400px) {
  .grid-6 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
@media (max-width: 1100px) {
  .grid-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 900px) {
  .app {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: relative;
    height: auto;
  }
  .nav {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    padding: 8px;
  }
  .nav-group {
    grid-column: 1 / -1;
  }
  .main {
    padding: 18px 16px 48px;
  }
  .grid-6 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.stat {
  background: var(--bg1);
  border: 1px solid var(--line);
  border-top: 2px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 16px 18px;
}
html[data-theme='light'] .stat {
  background: var(--bg2);
}
.stat .label {
  font-family: var(--font-mono);
  font-size: 0.64rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--ink3);
}
.stat .value {
  font-size: 1.85rem;
  font-weight: 590;
  font-stretch: 106%;
  margin-top: 8px;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
}
.stat .value small {
  font-size: 0.8rem;
  color: var(--ink3);
  font-weight: 500;
  margin-left: 3px;
  letter-spacing: 0;
}
.stat .hint {
  font-size: 0.76rem;
  color: var(--ink2);
  margin-top: 6px;
}
.stat.accent {
  border-top-color: var(--gold);
}
.stat.accent .value {
  color: var(--accent-ink);
}

.progress {
  height: 4px;
  background: var(--bg3);
  border-radius: var(--radius);
  overflow: hidden;
}
.progress > span {
  display: block;
  height: 100%;
  background: var(--gold);
  transition: width var(--t-med);
}
.progress.ok > span {
  background: var(--ok);
}

/* ---------- Alerts ---------- */
.banner,
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--line-strong);
  border-left-width: 2px;
  background: var(--bg1);
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  font-size: 0.88rem;
}
.banner {
  margin-bottom: 20px;
}
.alert-error,
.banner.alert-error {
  border-left-color: var(--bad);
  background: color-mix(in srgb, var(--bad) 8%, var(--bg1));
}
.alert-warn,
.banner.alert-warn {
  border-left-color: var(--gold);
  background: rgba(var(--gold-rgb), 0.08);
}
.alert-ok {
  border-left-color: var(--ok);
  background: color-mix(in srgb, var(--ok) 8%, var(--bg1));
}
.alert-info {
  border-left-color: var(--info);
  background: color-mix(in srgb, var(--info) 8%, var(--bg1));
}
.error {
  color: var(--bad);
  font-size: 0.85rem;
}

/* ---------- Forms ---------- */
label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink3);
}
label.inline {
  flex-direction: row;
  align-items: center;
  gap: 9px;
  text-transform: none;
  letter-spacing: 0;
  font-family: var(--font-sans);
  font-size: 0.88rem;
  color: var(--ink);
}
input,
select,
textarea {
  font-family: var(--font-sans);
  font-size: 0.92rem;
  color: var(--ink);
  background: var(--bg0);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 9px 11px;
  outline: none;
  width: 100%;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
html[data-theme='light'] input,
html[data-theme='light'] select,
html[data-theme='light'] textarea {
  background: var(--bg2);
}
input:focus,
select:focus,
textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(var(--gold-rgb), 0.16);
}
input[type='checkbox'],
input[type='radio'] {
  width: auto;
  accent-color: var(--gold);
  flex: none;
}
textarea {
  min-height: 120px;
  resize: vertical;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.6;
}
textarea.plain {
  font-family: var(--font-sans);
  font-size: 0.92rem;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.form-grid .full {
  grid-column: 1 / -1;
}
.form-grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
@media (max-width: 900px) {
  .form-grid,
  .form-grid-3 {
    grid-template-columns: 1fr;
  }
}
.help {
  font-family: var(--font-sans);
  font-size: 0.78rem;
  color: var(--ink3);
  text-transform: none;
  letter-spacing: 0;
  line-height: 1.5;
}
fieldset {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 18px 20px;
  margin: 0 0 16px;
}
legend {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--accent-ink);
  padding: 0 8px;
}
.checks {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}
.toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 16px;
}
.toolbar input,
.toolbar select {
  width: auto;
  min-width: 140px;
  height: 36px;
  padding-top: 0;
  padding-bottom: 0;
}
.toolbar input[type='search'] {
  min-width: 250px;
}
.toolbar label.inline {
  font-size: 0.82rem;
  color: var(--ink2);
}

/* ---------- Tables ---------- */
.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg1);
}
html[data-theme='light'] .table-wrap {
  background: var(--bg2);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}
th,
td {
  padding: 10px 13px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
th {
  font-family: var(--font-mono);
  font-size: 0.64rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--ink3);
  font-weight: 500;
  background: var(--bg1);
  position: sticky;
  top: 0;
  white-space: nowrap;
  border-bottom-color: var(--line-strong);
  z-index: 1;
}
html[data-theme='light'] th {
  background: var(--bg3);
}
th.sortable {
  cursor: pointer;
  user-select: none;
}
th.sortable:hover {
  color: var(--ink);
}
tbody tr:hover td {
  background: color-mix(in srgb, var(--ink) 3%, transparent);
}
tr.clickable {
  cursor: pointer;
}
td.num,
th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.table-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 11px 13px;
  color: var(--ink3);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  gap: 12px;
  flex-wrap: wrap;
}
.empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--ink3);
  font-size: 0.88rem;
}

/* ---------- Pills, tags ---------- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border: 1px solid transparent;
  white-space: nowrap;
}
.pill .dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}
.pill-muted {
  background: var(--bg3);
  color: var(--ink2);
}
.pill-ok {
  background: color-mix(in srgb, var(--ok) 14%, transparent);
  color: var(--ok);
}
.pill-warn {
  background: rgba(var(--gold-rgb), 0.15);
  color: var(--accent-ink);
}
.pill-err {
  background: color-mix(in srgb, var(--bad) 14%, transparent);
  color: var(--bad);
}
.pill-info {
  background: color-mix(in srgb, var(--info) 14%, transparent);
  color: var(--info);
}
.pill-purple {
  background: rgba(var(--gold-rgb), 0.1);
  color: var(--gold-bright);
  border-color: rgba(var(--gold-rgb), 0.4);
}
html[data-theme='light'] .pill-purple {
  color: var(--gold-deep);
}
.tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.08em;
  color: var(--ink2);
  margin: 1px 6px 1px 0;
}
.tag::before {
  content: '[ ';
  color: var(--ink3);
}
.tag::after {
  content: ' ]';
  color: var(--ink3);
}

/* ---------- Tabs ---------- */
.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 20px;
  flex-wrap: wrap;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar {
  display: none;
}
.tabs button {
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--ink3);
  padding: 11px 15px;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  cursor: pointer;
  margin-bottom: -1px;
  white-space: nowrap;
  transition: color var(--t-fast), border-color var(--t-fast);
}
.tabs button.active {
  color: var(--ink);
  border-bottom-color: var(--gold);
}
.tabs button:hover {
  color: var(--ink);
}

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(6, 6, 8, 0.66);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  z-index: 50;
  overflow: auto;
}
.modal {
  background: var(--bg1);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  width: 100%;
  max-width: 780px;
  box-shadow: var(--card-shadow);
}
html[data-theme='light'] .modal {
  background: var(--bg2);
}
.modal.wide {
  max-width: 1140px;
}
.modal.narrow {
  max-width: 480px;
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line-strong);
  gap: 16px;
}
.modal-head h3 {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent-ink);
}
.modal-body {
  padding: 22px;
  max-height: calc(100vh - 210px);
  overflow: auto;
}
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px 22px;
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}
.close {
  background: none;
  border: 0;
  color: var(--ink3);
  font-size: 1.4rem;
  cursor: pointer;
  line-height: 1;
  padding: 0 4px;
}
.close:hover {
  color: var(--ink);
}

/* ---------- Toasts ---------- */
.toast-root {
  position: fixed;
  right: 22px;
  bottom: 22px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 100;
  max-width: min(440px, calc(100vw - 44px));
}
.toast {
  background: var(--bg2);
  border: 1px solid var(--line-strong);
  border-left: 2px solid var(--info);
  color: var(--ink);
  padding: 12px 16px;
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
  font-size: 0.86rem;
  animation: toast-in 0.24s var(--ease-out);
}
html[data-theme='light'] .toast {
  background: #fff;
}
.toast-ok {
  border-left-color: var(--ok);
}
.toast-err {
  border-left-color: var(--bad);
}
.toast-warn {
  border-left-color: var(--gold);
}
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ---------- Auth ---------- */
.auth-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 32px 20px;
  background: var(--bg0) radial-gradient(90% 60% at 50% -10%, rgba(var(--gold-rgb), 0.07), transparent 65%);
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg1);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 36px 34px 32px;
  box-shadow: var(--card-shadow);
}
html[data-theme='light'] .auth-card {
  background: var(--bg2);
}
.auth-card .brand {
  border: 0;
  padding: 0;
  justify-content: center;
  margin-bottom: 26px;
}
.auth-card h1 {
  font-size: 1.5rem;
  margin-bottom: 8px;
}
.auth-card .lede {
  margin-bottom: 26px;
  font-size: 0.86rem;
}
.auth-card form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.auth-lang {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin-top: 22px;
}

/* ---------- Chart ---------- */
.chart {
  position: relative;
}
.chart svg {
  width: 100%;
  height: 250px;
  display: block;
  overflow: visible;
}
.chart .grid-line {
  stroke: var(--line);
  stroke-width: 1;
}
.chart .axis-text {
  fill: var(--ink3);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
}
.chart .line {
  fill: none;
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.chart .crosshair {
  stroke: var(--line-strong);
  stroke-width: 1;
  stroke-dasharray: 3 3;
}
.chart-tip {
  position: absolute;
  pointer-events: none;
  background: var(--bg2);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 9px 11px;
  font-size: 0.78rem;
  box-shadow: var(--card-shadow);
  min-width: 150px;
  z-index: 5;
}
html[data-theme='light'] .chart-tip {
  background: #fff;
}
.chart-tip .t {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink3);
  margin-bottom: 6px;
}
.chart-tip .r {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  font-variant-numeric: tabular-nums;
}
.chart-tip .sw {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 1px;
  margin-right: 7px;
}
.legend {
  display: flex;
  gap: 16px;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink2);
  flex-wrap: wrap;
}
.legend span::before {
  content: '';
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 1px;
  margin-right: 7px;
  vertical-align: -1px;
  background: var(--c);
}

/* ---------- Timeline (queue) ---------- */
.timeline {
  position: relative;
  height: 56px;
  background: var(--bg0);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
html[data-theme='light'] .timeline {
  background: var(--bg3);
}
.timeline .tick {
  position: absolute;
  top: 6px;
  bottom: 16px;
  width: 2px;
  background: var(--gold);
}
.timeline .tick.sent {
  background: var(--ok);
}
.timeline .tick.other {
  background: var(--ink3);
  opacity: 0.55;
}
.timeline .now {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--bad);
}
.timeline .hour {
  position: absolute;
  bottom: 3px;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.08em;
  color: var(--ink3);
  transform: translateX(-50%);
}

/* ---------- Key/value ledger ---------- */
.kv {
  display: grid;
  grid-template-columns: 190px 1fr;
  gap: 0;
  font-size: 0.86rem;
}
.kv dt {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink3);
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}
.kv dd {
  margin: 0;
  word-break: break-word;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
}
@media (max-width: 700px) {
  .kv {
    grid-template-columns: 1fr;
  }
  .kv dt {
    border-bottom: 0;
    padding-bottom: 0;
  }
}

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
@media (max-width: 1100px) {
  .split {
    grid-template-columns: 1fr;
  }
}
.preview-frame {
  width: 100%;
  height: 520px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}
.var-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.var-list button {
  font-family: var(--font-mono);
  font-size: 0.64rem;
  letter-spacing: 0.04em;
  text-transform: none;
  padding: 0 8px;
  height: 26px;
}
.event-list {
  display: flex;
  flex-direction: column;
}
.event {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  font-size: 0.85rem;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}
.event:last-child {
  border-bottom: 0;
}
.event .when {
  color: var(--ink3);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  white-space: nowrap;
  min-width: 112px;
  padding-top: 2px;
}

.dropzone {
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  padding: 48px 24px;
  text-align: center;
  color: var(--ink2);
  cursor: pointer;
  transition: border-color var(--t-fast), background var(--t-fast);
}
.dropzone:hover,
.dropzone.over {
  border-color: var(--gold);
  background: rgba(var(--gold-rgb), 0.05);
}
.dropzone .big {
  font-family: var(--font-mono);
  font-size: 1.6rem;
  color: var(--accent-ink);
  margin-bottom: 12px;
}

/* ---------- Step indicator ---------- */
.steps {
  display: flex;
  gap: 0;
  margin-bottom: 22px;
  flex-wrap: wrap;
  border-top: 1px solid var(--line-strong);
  padding-top: 12px;
}
.steps span {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink3);
  padding: 4px 16px 4px 0;
}
.steps span.active {
  color: var(--accent-ink);
}
.steps span.done {
  color: var(--ok);
}

.lint {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.lint div {
  font-size: 0.8rem;
  padding: 8px 12px;
  border-radius: var(--radius);
  background: rgba(var(--gold-rgb), 0.07);
  color: var(--ink2);
  border-left: 2px solid var(--gold);
}

/* ---------- Setup wizard ---------- */
.wizard {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 28px;
  align-items: start;
}
@media (max-width: 1000px) {
  .wizard {
    grid-template-columns: 1fr;
  }
}
.wizard-steps {
  border-top: 1px solid var(--line-strong);
  position: sticky;
  top: 28px;
}
.wizard-steps button {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 12px 6px;
  cursor: pointer;
  color: var(--ink2);
  font-family: var(--font-sans);
  font-size: 0.86rem;
  transition: color var(--t-fast), background var(--t-fast);
}
.wizard-steps button:hover {
  color: var(--ink);
  background: color-mix(in srgb, var(--ink) 3%, transparent);
}
.wizard-steps button.current {
  color: var(--ink);
  font-weight: 600;
}
.wizard-steps button.current .wnum {
  background: var(--gold);
  border-color: var(--gold);
  color: var(--on-gold);
}
.wizard-steps .wnum {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  flex: none;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 0.66rem;
  color: var(--ink3);
}
.wizard-steps button.state-done .wnum {
  border-color: var(--ok);
  color: var(--ok);
}
.wizard-steps button.state-skipped .wnum {
  border-style: dashed;
}
.wizard-steps .wtag {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink3);
}
.wizard-steps button.state-done .wtag {
  color: var(--ok);
}

.wizard-panel {
  background: var(--bg1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: clamp(22px, 3vw, 34px);
}
html[data-theme='light'] .wizard-panel {
  background: var(--bg2);
}
.wizard-panel h2 {
  font-size: clamp(1.3rem, 2.2vw, 1.7rem);
  font-weight: 590;
  letter-spacing: -0.02em;
  margin: 10px 0 12px;
  text-transform: none;
  font-family: var(--font-sans);
}
.wizard-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--line-strong);
  flex-wrap: wrap;
}

/* numbered instruction list */
.howto {
  counter-reset: howto;
  border-top: 1px solid var(--line);
  margin: 18px 0;
}
.howto li {
  counter-increment: howto;
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 14px;
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
}
.howto li::before {
  content: counter(howto, decimal-leading-zero);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  color: var(--accent-ink);
  padding-top: 2px;
}
.howto strong {
  display: block;
  font-weight: 600;
  margin-bottom: 4px;
}
.howto p {
  color: var(--ink2);
  font-size: 0.88rem;
  margin: 0;
}

.checklist {
  border-top: 1px solid var(--line);
}
.checklist li {
  display: grid;
  grid-template-columns: 20px 1fr;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.86rem;
  color: var(--ink2);
}
.checklist li::before {
  content: '';
  width: 7px;
  height: 7px;
  margin-top: 8px;
  background: var(--gold);
  border-radius: 50%;
}

.factline {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.86rem;
}
.factline .k {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink3);
}
.factline .v {
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.day-row {
  display: grid;
  grid-template-columns: 90px 1fr 60px;
  gap: 10px;
  align-items: center;
  font-size: 0.8rem;
  padding: 4px 0;
}

/* Failure log: the cause and the fix are the point of the entry, so they read as
   prose under their label rather than as a right-aligned value. */
.explain {
  margin-top: 14px;
  padding-left: 14px;
  border-left: 1px solid var(--line-strong);
}
.explain p {
  margin: 6px 0 0;
  color: var(--ink2);
  font-size: 0.89rem;
  max-width: 78ch;
  line-height: 1.6;
}
.explain.fix {
  border-left-color: var(--gold);
}
.explain.fix p {
  color: var(--ink);
}
.sortable-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
