/*
 * Moniemate admin console - design system.
 * Brand (from the marketing site, the e-mail theme and the Flutter tokens in Mobile/packages/mm_ui/lib/src/tokens.dart):
 *   green #034402 (logo, CTAs), mid #026C00, credit #03CD00, mint #9CFF9A, pale mint #EDFFEC, neon #05FF00; Montserrat.
 * No inline styles anywhere (the CSP is style-src 'self'); colours are tokens so light and dark share every rule.
 * Theme: follows the OS unless <html data-theme="light|dark"> is set (theme.js, remembered per browser).
 */

/* ------------------------------------------------------------------ fonts (self-hosted; CSP font-src 'self') */
@font-face { font-family: 'Montserrat'; font-style: normal; font-weight: 400; font-display: swap; src: url('/admin/fonts/montserrat-regular.woff2') format('woff2'); }
@font-face { font-family: 'Montserrat'; font-style: normal; font-weight: 500; font-display: swap; src: url('/admin/fonts/montserrat-medium.woff2') format('woff2'); }
@font-face { font-family: 'Montserrat'; font-style: normal; font-weight: 600; font-display: swap; src: url('/admin/fonts/montserrat-semibold.woff2') format('woff2'); }
@font-face { font-family: 'Montserrat'; font-style: normal; font-weight: 700; font-display: swap; src: url('/admin/fonts/montserrat-bold.woff2') format('woff2'); }

/* ------------------------------------------------------------------ tokens */
:root {
  color-scheme: light;
  --brand: #034402;
  --brand-mid: #026c00;
  --brand-strong: #022e01;
  --mint: #9cff9a;
  --mint-pale: #edffec;
  --neon: #05ff00;

  --bg: #f6f7f6;
  --panel: #ffffff;
  --panel-2: #f8faf8;
  --sunken: #f1f4f1;
  --ink: #101a12;
  --ink-2: #344238;
  --muted: #5f6b63;
  --line: #e3e8e3;
  --line-strong: #cdd5ce;

  --accent: #034402;          /* links, active states, primary buttons */
  --accent-ink: #ffffff;      /* text on --accent */
  --accent-hover: #026c00;
  --accent-soft: #edffec;     /* selected rows, icon tiles */
  --accent-soft-ink: #034402;

  --ok: #067a26; --ok-soft: #e8f8ea; --ok-line: #b5e3bc;
  --warn: #8a4b00; --warn-soft: #fff5e0; --warn-line: #f3d08f;
  --bad: #b42318; --bad-soft: #fff0ee; --bad-line: #f4c2bc;
  --info: #175cd3; --info-soft: #eef4ff; --info-line: #c2d6fb;
  --neutral-soft: #f0f2f0; --neutral-ink: #475249;

  --focus: #1f8f3a;
  --focus-ring: 0 0 0 3px color-mix(in srgb, var(--focus) 35%, transparent);

  --side-bg: #034402;
  --side-ink: #ffffff;
  --side-muted: rgba(255, 255, 255, .72);
  --side-hover: rgba(255, 255, 255, .08);
  --side-active: rgba(156, 255, 154, .16);
  --side-active-ink: #9cff9a;
  --side-line: rgba(255, 255, 255, .12);

  --shadow-sm: 0 1px 2px rgba(16, 26, 18, .06);
  --shadow: 0 1px 2px rgba(16, 26, 18, .05), 0 4px 16px rgba(16, 26, 18, .06);
  --shadow-lg: 0 12px 40px rgba(16, 26, 18, .18);
  --scrim: rgba(6, 14, 8, .48);

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --pill: 999px;

  --font: 'Montserrat', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, 'Cascadia Mono', Consolas, Menlo, monospace;
  --side-w: 256px;
  --top-h: 64px;
}

/* Dark: the same roles on green-tinted near-black surfaces; mint becomes the accent so it reads on dark. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0a0f0b; --panel: #111813; --panel-2: #141c16; --sunken: #0d130e;
    --ink: #e9f1eb; --ink-2: #c3cec6; --muted: #93a197; --line: #223026; --line-strong: #2f4034;
    --accent: #9cff9a; --accent-ink: #022e01; --accent-hover: #bcffaf; --accent-soft: rgba(156, 255, 154, .12); --accent-soft-ink: #9cff9a;
    --ok: #6ee787; --ok-soft: rgba(110, 231, 135, .12); --ok-line: rgba(110, 231, 135, .35);
    --warn: #fbc65a; --warn-soft: rgba(251, 198, 90, .12); --warn-line: rgba(251, 198, 90, .35);
    --bad: #ff8a7f; --bad-soft: rgba(255, 138, 127, .12); --bad-line: rgba(255, 138, 127, .35);
    --info: #84adff; --info-soft: rgba(132, 173, 255, .12); --info-line: rgba(132, 173, 255, .35);
    --neutral-soft: rgba(255, 255, 255, .07); --neutral-ink: #b7c3ba;
    --focus: #9cff9a;
    --side-bg: #07150a; --side-line: rgba(255, 255, 255, .08);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4); --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 16px rgba(0, 0, 0, .3); --shadow-lg: 0 16px 48px rgba(0, 0, 0, .6);
    --scrim: rgba(0, 0, 0, .62);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0a0f0b; --panel: #111813; --panel-2: #141c16; --sunken: #0d130e;
  --ink: #e9f1eb; --ink-2: #c3cec6; --muted: #93a197; --line: #223026; --line-strong: #2f4034;
  --accent: #9cff9a; --accent-ink: #022e01; --accent-hover: #bcffaf; --accent-soft: rgba(156, 255, 154, .12); --accent-soft-ink: #9cff9a;
  --ok: #6ee787; --ok-soft: rgba(110, 231, 135, .12); --ok-line: rgba(110, 231, 135, .35);
  --warn: #fbc65a; --warn-soft: rgba(251, 198, 90, .12); --warn-line: rgba(251, 198, 90, .35);
  --bad: #ff8a7f; --bad-soft: rgba(255, 138, 127, .12); --bad-line: rgba(255, 138, 127, .35);
  --info: #84adff; --info-soft: rgba(132, 173, 255, .12); --info-line: rgba(132, 173, 255, .35);
  --neutral-soft: rgba(255, 255, 255, .07); --neutral-ink: #b7c3ba;
  --focus: #9cff9a;
  --side-bg: #07150a; --side-line: rgba(255, 255, 255, .08);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4); --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 16px rgba(0, 0, 0, .3); --shadow-lg: 0 16px 48px rgba(0, 0, 0, .6);
  --scrim: rgba(0, 0, 0, .62);
}

/* ------------------------------------------------------------------ base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 400 14px/1.5 var(--font); letter-spacing: -.005em; background: var(--bg); color: var(--ink); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { letter-spacing: -.03em; line-height: 1.25; color: var(--ink); }
h1 { font-size: 24px; font-weight: 600; margin: 0; }
h2 { font-size: 16px; font-weight: 600; margin: 24px 0 10px; }
h3 { font-size: 14px; font-weight: 600; margin: 20px 0 8px; }
p { margin: 4px 0 12px; }
b, strong { font-weight: 600; }
a { color: var(--accent); text-underline-offset: 2px; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 12.5px; letter-spacing: 0; overflow-wrap: anywhere; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
::selection { background: color-mix(in srgb, var(--mint) 60%, transparent); color: #022e01; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
details > summary { cursor: pointer; color: var(--ink-2); font-weight: 500; padding: 6px 0; }
details > summary:hover { color: var(--accent); }
ul { padding-left: 20px; }

.skip { position: absolute; left: 12px; top: -48px; z-index: 100; padding: 8px 14px; border-radius: var(--radius-sm); background: var(--accent); color: var(--accent-ink); font-weight: 600; text-decoration: none; }
.skip:focus { top: 12px; }

/* ------------------------------------------------------------------ form controls */
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
input, select, textarea {
  width: 100%; min-height: 40px; padding: 8px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background-color: var(--panel); color: var(--ink); transition: border-color .12s, box-shadow .12s;
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .85; }
input:hover, select:hover, textarea:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--line-strong)); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--focus); box-shadow: var(--focus-ring); }
input:disabled, select:disabled, textarea:disabled { background-color: var(--sunken); color: var(--muted); cursor: not-allowed; }
textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
select {
  appearance: none; padding-right: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%237d8a80' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
input[type=checkbox], input[type=radio] { width: 18px; height: 18px; min-height: 0; padding: 0; margin: 0; flex: none; accent-color: var(--brand-mid); cursor: pointer; }
input[type=search] { padding-left: 36px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%237d8a80' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: 12px center; }
input[type=number] { font-variant-numeric: tabular-nums; }

label { display: block; font-weight: 600; font-size: 13px; color: var(--ink-2); margin: 16px 0 6px; }
label.inline { display: flex; gap: 10px; align-items: center; font-weight: 500; font-size: 14px; color: var(--ink); margin: 8px 0; cursor: pointer; }
label.inline input:not([type=checkbox]):not([type=radio]) { width: auto; }
.field-err { color: var(--bad); font-size: 12.5px; }
.field-err:empty { display: none; }

/* ------------------------------------------------------------------ buttons */
button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 8px 16px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--panel); color: var(--ink);
  font-weight: 600; font-size: 13.5px; line-height: 1.2; cursor: pointer; white-space: nowrap; box-shadow: var(--shadow-sm);
  transition: background-color .12s, border-color .12s, color .12s, box-shadow .12s;
}
button:hover { background: var(--panel-2); border-color: color-mix(in srgb, var(--accent) 45%, var(--line-strong)); }
button:focus-visible { outline: none; box-shadow: var(--focus-ring); border-color: var(--focus); }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
button.danger { color: var(--bad); border-color: var(--bad-line); background: var(--panel); }
button.danger:hover { background: var(--bad-soft); border-color: var(--bad); }
button.ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--ink-2); }
button.ghost:hover { background: var(--neutral-soft); color: var(--ink); }
button.sm, td button, .row.tight button { min-height: 32px; padding: 5px 12px; font-size: 12.5px; }
button:disabled, button:disabled:hover { opacity: .5; cursor: not-allowed; background: var(--panel); border-color: var(--line-strong); color: var(--ink); }
button.primary:disabled { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button svg { width: 16px; height: 16px; flex: none; }
.icon-btn { min-height: 38px; width: 38px; padding: 0; box-shadow: none; border-color: transparent; background: transparent; color: var(--ink-2); }
.icon-btn:hover { background: var(--neutral-soft); border-color: transparent; color: var(--ink); }
.icon-btn svg { width: 20px; height: 20px; }

/* ------------------------------------------------------------------ layout helpers */
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row.top { align-items: flex-start; }
.row.tight { gap: 6px; }
.row > select { width: auto; min-width: 160px; }
.row > input[type=text], .row > input[type=search], .row > input[type=email], .row > input:not([type]) { width: auto; min-width: 180px; flex: 1 1 180px; }
.grow { flex: 1; min-width: 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 12px; margin: 0 0 12px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.toolbar > select { width: auto; min-width: 150px; }
.toolbar > .grow { min-width: 240px; }
.meta { color: var(--muted); font-size: 12.5px; margin: 0 0 14px; display: block; }
.sticky { position: sticky; top: calc(var(--top-h) + 8px); z-index: 5; box-shadow: var(--shadow); }

/* ------------------------------------------------------------------ app shell */
.shell { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100vh; background: linear-gradient(to right, var(--side-bg) var(--side-w), var(--bg) var(--side-w)); }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column;
  background: var(--side-bg); color: var(--side-ink); padding: 18px 12px 14px; scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, .2) transparent;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 12px; color: inherit; text-decoration: none; border-radius: var(--radius-sm); }
.brand-tag { margin-left: auto; padding: 2px 8px; border-radius: var(--pill); background: rgba(156, 255, 154, .16); color: #9cff9a; font-size: 11px; font-weight: 600; letter-spacing: .02em; }
/* The mark: the site's glyph on a #034402 rounded square, in the website's proportions (30.27 box, glyph at 5.76 / 18.74 x 24.5). */
.mark { position: relative; flex: none; width: 32px; height: 32px; border-radius: 10.57px; background: #034402; overflow: hidden; }
.mark img { position: absolute; left: 19.03%; top: 19.03%; width: 61.9%; height: 80.97%; }
.sidebar .mark { background: rgba(255, 255, 255, .1); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .14); }
.wordmark { display: block; width: 108px; height: 16px; }
.nav-group { margin-top: 14px; }
.nav-label { padding: 0 12px 6px; font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--side-muted); }
.nav-item {
  display: flex; align-items: center; gap: 12px; min-height: 36px; padding: 7px 12px; margin: 1px 0; border-radius: var(--radius-sm);
  color: var(--side-muted); text-decoration: none; font-weight: 500; position: relative; transition: background-color .12s, color .12s;
}
.nav-item svg { width: 18px; height: 18px; flex: none; }
.nav-item:hover { background: var(--side-hover); color: var(--side-ink); }
.nav-item[aria-current="page"] { background: var(--side-active); color: var(--side-active-ink); font-weight: 600; }
.nav-item[aria-current="page"]::before { content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: #9cff9a; }
.nav-item:focus-visible, .brand:focus-visible { outline: 2px solid #9cff9a; outline-offset: -2px; }
.side-foot { margin-top: auto; padding: 16px 12px 4px; border-top: 1px solid var(--side-line); font-size: 12px; color: var(--side-muted); display: flex; flex-direction: column; gap: 4px; }
.side-foot .env { display: inline-flex; align-items: center; gap: 8px; color: var(--side-ink); font-weight: 600; }
.side-foot .dot { width: 8px; height: 8px; border-radius: 50%; background: #9cff9a; }
.side-foot .dot.warn { background: #fbc65a; }

.main-col { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; height: var(--top-h); padding: 0 28px;
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--line);
}
.crumbs { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 13px; color: var(--muted); }
.crumbs b { color: var(--ink); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumbs svg { width: 14px; height: 14px; opacity: .7; flex: none; }
.menu-toggle { display: none; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.env-pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: var(--pill); font-size: 12px; font-weight: 600; background: var(--warn-soft); color: var(--warn); border: 1px solid var(--warn-line); white-space: nowrap; }
.user-menu { position: relative; }
.user-btn { gap: 10px; padding: 4px 10px 4px 4px; min-height: 40px; border-color: transparent; background: transparent; box-shadow: none; font-weight: 600; }
.user-btn:hover { background: var(--neutral-soft); border-color: transparent; }
.avatar { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: #034402; color: #9cff9a; font-size: 12px; font-weight: 700; letter-spacing: 0; flex: none; }
.user-btn .who { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.25; text-align: left; }
.user-btn .who small { color: var(--muted); font-weight: 500; font-size: 11.5px; }
.user-btn > svg { color: var(--muted); }
.menu {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 260px; padding: 6px; z-index: 40;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg);
}
.menu-head { padding: 10px 12px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.menu-head div { overflow-wrap: anywhere; }
.menu-head .muted { font-size: 12.5px; }
.menu a, .menu button { display: flex; width: 100%; justify-content: flex-start; gap: 10px; padding: 8px 12px; min-height: 38px; border: 0; border-radius: var(--radius-sm); background: transparent; box-shadow: none; color: var(--ink); font-weight: 500; text-decoration: none; font-size: 13.5px; }
.menu a:hover, .menu button:hover, .menu a:focus-visible, .menu button:focus-visible { background: var(--neutral-soft); box-shadow: none; }
.menu svg { width: 16px; height: 16px; color: var(--muted); }

main.content { padding: 28px 32px 64px; width: 100%; max-width: 1280px; }
main.content:focus { outline: none; }
.scrim { display: none; }

/* Tablet and below: the sidebar becomes an off-canvas drawer. */
@media (max-width: 1100px) {
  .shell { grid-template-columns: minmax(0, 1fr); background: var(--bg); }
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 60; width: min(var(--side-w), 86vw); transform: translateX(-100%); visibility: hidden; transition: transform .2s ease, visibility 0s linear .2s; }
  .shell.nav-open .sidebar { transform: none; visibility: visible; box-shadow: var(--shadow-lg); transition: transform .2s ease; }
  .shell.nav-open .scrim { display: block; position: fixed; inset: 0; z-index: 55; background: var(--scrim); }
  .menu-toggle { display: inline-flex; }
  .topbar { padding: 0 16px; }
  main.content { padding: 22px 20px 56px; }
}
@media (max-width: 640px) {
  .user-btn .who, .user-btn > svg { display: none; }
  .user-btn { padding: 4px; }
  main.content { padding: 18px 14px 48px; }
  .topbar .env-pill { display: none; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }

/* ------------------------------------------------------------------ page header */
.page-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin: 0 0 22px; }
.page-head p { margin: 6px 0 0; color: var(--muted); max-width: 780px; }

/* ------------------------------------------------------------------ cards */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin: 0 0 16px; box-shadow: var(--shadow-sm); }
.card > h2:first-child, .card > .row:first-child > h2 { margin-top: 0; }
.card > .row:first-child { margin-bottom: 4px; }
.card.row { padding: 12px 16px; }
.section-title { display: flex; align-items: center; gap: 10px; margin: 28px 0 12px; }
.section-title h2 { margin: 0; }

.stat { display: flex; flex-direction: column; gap: 2px; position: relative; text-decoration: none; color: inherit; margin: 0; transition: border-color .12s, box-shadow .12s; }
a.stat:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); box-shadow: var(--shadow); }
.stat .stat-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: var(--accent-soft); color: var(--accent-soft-ink); margin-bottom: 10px; }
.stat .stat-icon svg { width: 18px; height: 18px; }
.stat b { display: block; font-size: 28px; font-weight: 600; letter-spacing: -.04em; line-height: 1.15; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: 13px; }
.stat.hero { background: linear-gradient(116.94deg, #034402 15.7%, #026c00 48.8%, #034402 74.6%); border-color: transparent; color: #fff; }
.stat.hero b { color: #fff; }
.stat.hero span { color: rgba(255, 255, 255, .8); }
.stat.hero .stat-icon { background: rgba(156, 255, 154, .18); color: #9cff9a; }

/* ------------------------------------------------------------------ tables */
.table-wrap { width: 100%; overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); margin: 0 0 16px; }
.card .table-wrap, dialog .table-wrap, .rules .table-wrap { box-shadow: none; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: var(--panel-2); color: var(--muted); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: color-mix(in srgb, var(--accent-soft) 50%, transparent); }
td .row { flex-wrap: nowrap; }
table:not(.kv) td:first-child, td > span.mono { white-space: nowrap; }
td details.detail { min-width: 280px; }
td details.detail > summary { padding: 0; color: var(--ink-2); font-weight: 400; overflow-wrap: anywhere; }
td details.detail[open] > summary { color: var(--muted); }
td input, td select { min-width: 140px; }
table.kv thead { display: none; }
table.kv td:first-child { width: 34%; color: var(--muted); font-weight: 500; }
table.kv tbody tr:hover td { background: transparent; }
tbody tr:hover td.empty-cell { background: transparent; }
td.empty-cell { padding: 0; }

/* ------------------------------------------------------------------ badges */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: var(--pill); font-size: 12px; font-weight: 600; line-height: 1.6; white-space: nowrap; background: var(--neutral-soft); color: var(--neutral-ink); letter-spacing: 0; vertical-align: middle; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .75; flex: none; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.info { background: var(--info-soft); color: var(--info); }

/* ------------------------------------------------------------------ notices, toasts */
.notice { display: flex; gap: 10px; align-items: flex-start; flex-wrap: wrap; padding: 12px 14px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--panel-2); margin: 12px 0; color: var(--ink); }
.notice::before {
  content: ""; flex: none; width: 18px; height: 18px; margin-top: 1px; background: currentColor;
  -webkit-mask: var(--ico) center / 18px no-repeat; mask: var(--ico) center / 18px no-repeat;
  --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 11v5M12 8h.01'/%3E%3C/svg%3E");
}
.notice.error { border-color: var(--bad-line); background: var(--bad-soft); color: var(--bad); }
.notice.error::before { --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 7v6M12 16.5h.01'/%3E%3C/svg%3E"); }
.notice.ok { border-color: var(--ok-line); background: var(--ok-soft); color: var(--ok); }
.notice.ok::before { --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='m8 12.5 2.8 2.8L16.5 9.5'/%3E%3C/svg%3E"); }
.notice.warn { border-color: var(--warn-line); background: var(--warn-soft); color: var(--warn); }
.notice.warn::before { --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 3 2 20h20L12 3z'/%3E%3Cpath d='M12 10v4M12 17h.01'/%3E%3C/svg%3E"); }
.notice > * { color: var(--ink); }
.notice > .notice-text { flex: 1; min-width: 200px; color: inherit; font-weight: 500; }
.notice button { min-height: 32px; padding: 5px 12px; font-size: 12.5px; }
.notice:not(.error):not(.ok):not(.warn) { flex-direction: column; }
.notice:not(.error):not(.ok):not(.warn)::before { display: none; }

.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 200; display: flex; flex-direction: column; gap: 10px; width: min(380px, calc(100vw - 32px)); pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; gap: 10px; align-items: flex-start; padding: 12px 12px 12px 14px; border-radius: var(--radius);
  background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-left: 4px solid var(--ok); box-shadow: var(--shadow-lg);
  animation: toast-in .18s ease-out;
}
.toast.error { border-left-color: var(--bad); }
.toast.warn { border-left-color: var(--warn); }
.toast > svg { width: 18px; height: 18px; flex: none; margin-top: 2px; color: var(--ok); }
.toast.error > svg { color: var(--bad); }
.toast.warn > svg { color: var(--warn); }
.toast .grow { padding-top: 1px; overflow-wrap: anywhere; font-weight: 500; }
.toast .icon-btn { width: 28px; min-height: 28px; margin: -3px -2px 0 0; }
.toast .icon-btn svg { width: 16px; height: 16px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ------------------------------------------------------------------ empty, loading, error states */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: 36px 20px; color: var(--muted); background: var(--panel); border: 1px dashed var(--line-strong); border-radius: var(--radius); margin: 0 0 16px; }
.card .empty, .table-wrap .empty, dialog .empty { border: 0; background: transparent; padding: 28px 16px; margin: 0; }
.empty-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; background: var(--accent-soft); color: var(--accent-soft-ink); margin-bottom: 6px; }
.empty-icon svg { width: 22px; height: 22px; }
.empty b { color: var(--ink); font-size: 14px; }
.empty p { margin: 0; max-width: 440px; }

.skeleton { display: block; border-radius: 6px; background: linear-gradient(90deg, var(--sunken) 0%, var(--line) 40%, var(--sunken) 80%); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; }
.sk-title { height: 28px; width: 260px; margin-bottom: 12px; }
.sk-line { height: 14px; width: 55%; margin-bottom: 8px; }
.sk-card { height: 118px; border-radius: var(--radius); }
.sk-block { height: 280px; border-radius: var(--radius); }
.loading-state .grid { margin: 26px 0 16px; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

.error-state { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 48px 24px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.error-state .empty-icon { width: 48px; height: 48px; border-radius: 14px; background: var(--bad-soft); color: var(--bad); }
.error-state h2 { margin: 6px 0 0; }
.error-state p { color: var(--muted); max-width: 560px; margin: 0 0 8px; }

/* ------------------------------------------------------------------ switches */
.switch { position: relative; width: 44px; height: 24px; flex: none; margin-top: 1px; }
.switch input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.switch input:disabled { cursor: not-allowed; }
.switch i { position: absolute; inset: 0; background: var(--line-strong); border-radius: var(--pill); transition: background-color .15s; pointer-events: none; }
.switch i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .25); transition: transform .15s; }
.switch input:checked + i { background: var(--brand-mid); }
.switch input:checked + i::after { transform: translateX(20px); }
.switch input:disabled + i { opacity: .55; }
.switch input:focus-visible + i { box-shadow: var(--focus-ring); }

/* ------------------------------------------------------------------ list rows (flags, settings, adapters, policy) */
.flag { display: flex; gap: 14px; align-items: flex-start; padding: 14px 0; border-bottom: 1px solid var(--line); }
.flag:last-child { border-bottom: 0; padding-bottom: 2px; }
.flag.col { flex-direction: column; gap: 8px; }
.flag b { font-weight: 600; }
.flag .row.tight .mono { font-size: 12px; }
.flag label.inline { margin: 0; align-items: flex-start; }
.flag label.inline > input { margin-top: 2px; }
.kill { display: inline-block; color: var(--warn); font-size: 12.5px; font-weight: 500; }
.rules { margin: 4px 0 0 58px; padding: 16px; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.rules h2 { font-size: 14px; margin-top: 18px; }
.rules .grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.rules .grid label { margin-top: 0; }
.flag details .grid { margin-top: 8px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }

/* ------------------------------------------------------------------ tabs (segmented) */
.tabs { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; margin: 0 0 16px; background: var(--sunken); border: 1px solid var(--line); border-radius: var(--radius); }
.tabs button { min-height: 34px; padding: 6px 14px; border: 0; background: transparent; box-shadow: none; color: var(--muted); font-weight: 600; }
.tabs button:hover { background: var(--panel); color: var(--ink); }
.tabs button[aria-selected="true"] { background: var(--panel); color: var(--ink); box-shadow: var(--shadow-sm); }

/* ------------------------------------------------------------------ dialogs & drawers */
dialog {
  border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--panel); color: var(--ink);
  max-width: 480px; width: calc(100% - 32px); padding: 24px; box-shadow: var(--shadow-lg);
}
dialog[open] { animation: dialog-in .16s ease-out; }
dialog::backdrop { background: var(--scrim); }
dialog > h2:first-child { margin: 0 0 6px; font-size: 18px; }
dialog > .row.end:last-child { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }
dialog textarea { min-height: 84px; }
dialog pre.mono { max-height: 260px; }
dialog .code-input { margin-top: 8px; }
dialog.drawer { max-width: 760px; width: min(760px, 100%); height: 100vh; max-height: 100vh; margin: 0 0 0 auto; border-radius: var(--radius-lg) 0 0 var(--radius-lg); border-right: 0; overflow: auto; padding: 0; }
dialog.drawer > .row:first-child { position: sticky; top: 0; z-index: 2; padding: 16px 24px; background: var(--panel); border-bottom: 1px solid var(--line); }
dialog.drawer > .row:first-child h2 { margin: 0; }
dialog.drawer > :not(:first-child) { margin: 20px 24px; }
dialog.drawer[open] { animation: drawer-in .2s ease-out; }
@keyframes dialog-in { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes drawer-in { from { transform: translateX(40px); opacity: .4; } to { transform: none; opacity: 1; } }

/* ------------------------------------------------------------------ code & misc */
pre.mono { white-space: pre-wrap; background: var(--sunken); border: 1px solid var(--line); padding: 12px 14px; border-radius: var(--radius-sm); max-height: 380px; overflow: auto; margin: 8px 0; }
.qr { width: 216px; height: 216px; background: #fff; padding: 10px; border-radius: var(--radius); border: 1px solid var(--line); margin: 8px auto 14px; }
.qr svg { width: 100%; height: 100%; display: block; }
.secret { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: center; padding: 10px 12px; background: var(--sunken); border: 1px dashed var(--line-strong); border-radius: var(--radius-sm); font-size: 12.5px; color: var(--muted); }
.secret .mono { font-size: 13px; letter-spacing: .06em; color: var(--ink); }
.codes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px 16px; font-family: var(--mono); font-size: 14px; letter-spacing: .04em; background: var(--sunken); border: 1px solid var(--line); padding: 16px; border-radius: var(--radius-sm); margin: 12px 0; }
.thread { display: flex; flex-direction: column; gap: 10px; margin: 16px 0; }
.bubble { padding: 12px 14px; border-radius: var(--radius); background: var(--panel-2); border: 1px solid var(--line); }
.bubble b { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 4px; }
.bubble.customer { background: var(--accent-soft); border-color: transparent; }
.slot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; margin-top: 12px; }
.slot { display: flex; flex-direction: column; gap: 4px; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--panel-2); }
.slot .badge { align-self: flex-start; }
.email-preview { width: 100%; height: 680px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff; margin-top: 8px; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
@media (max-width: 900px) { .split { grid-template-columns: 1fr; } }

/* ------------------------------------------------------------------ sign-in & onboarding */
.auth { display: grid; grid-template-columns: minmax(380px, 5fr) 7fr; min-height: 100vh; }
.auth-brand {
  position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between; gap: 40px; padding: 40px 48px;
  color: #fff; background: radial-gradient(120% 80% at 100% 100%, rgba(5, 255, 0, .2) 0%, rgba(5, 255, 0, 0) 55%), linear-gradient(160deg, #034402 0%, #022e01 100%);
}
.auth-brand::after { content: ""; position: absolute; right: -140px; bottom: -140px; width: 440px; height: 440px; border-radius: 50%; border: 1px solid rgba(156, 255, 154, .18); box-shadow: 0 0 0 60px rgba(156, 255, 154, .04), 0 0 0 120px rgba(156, 255, 154, .03); pointer-events: none; }
.auth-brand .brand { padding: 0; }
.auth-brand .mark { width: 40px; height: 40px; border-radius: 13.2px; background: rgba(255, 255, 255, .1); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .16); }
.auth-brand .wordmark { width: 135px; height: 20px; }
.auth-brand h2 { color: #fff; font-size: 36px; font-weight: 500; letter-spacing: -.05em; line-height: 1.08; margin: 0 0 16px; max-width: 420px; }
.auth-brand p { color: rgba(255, 255, 255, .8); max-width: 400px; margin: 0; font-size: 15px; }
.auth-brand small { color: rgba(255, 255, 255, .62); font-size: 12px; position: relative; z-index: 1; }
.auth-main { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px 24px; position: relative; }
.theme-corner { position: absolute; top: 16px; right: 16px; }
.auth-card { width: 100%; max-width: 440px; }
.auth-card > h1 { font-size: 28px; letter-spacing: -.04em; }
.auth-card > p.muted { margin: 8px 0 24px; }
.auth-card .card { padding: 24px; box-shadow: var(--shadow); }
.auth-card .card > label:first-child, .auth-card .card > .notice:first-child + label { margin-top: 0; }
.auth-card .block { width: 100%; min-height: 44px; margin-top: 20px; }
.auth-card .foot { margin-top: 18px; text-align: center; color: var(--muted); font-size: 12.5px; }
.code-input { font-family: var(--mono); font-size: 20px; letter-spacing: .3em; text-align: center; min-height: 52px; }
.steps { display: flex; gap: 8px; list-style: none; padding: 0; margin: 0 0 22px; }
.steps li { flex: 1; display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); font-weight: 500; }
.steps li::before { content: ""; height: 4px; border-radius: 4px; background: var(--line); }
.steps li.done::before, .steps li.current::before { background: var(--brand-mid); }
.steps li.current { color: var(--ink); font-weight: 600; }
.choice { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0 0 14px; }
.choice label { margin: 0; padding: 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); font-size: 13px; }
.choice label:has(input:checked) { border-color: var(--brand-mid); background: var(--accent-soft); }
.auth-mobile-brand { display: none; }

@media (max-width: 900px) {
  .auth { grid-template-columns: 1fr; }
  .auth-brand { display: none; }
  .auth-mobile-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 28px; text-decoration: none; }
  .auth-main { justify-content: flex-start; padding-top: 80px; }
}

/* Logo variants: the green wordmark on light surfaces, the white one on dark. */
.on-light { display: block; }
.on-dark { display: none; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .on-light { display: none; } :root:not([data-theme="light"]) .on-dark { display: block; } }
:root[data-theme="dark"] .on-light { display: none; }
:root[data-theme="dark"] .on-dark { display: block; }

@media print { .sidebar, .topbar, .toasts { display: none !important; } .shell { display: block; } }
