/* ═══════════════════════════════════════════════════════════════════════════
   Metrike Tracker — Operational Console
   Design system: refined, professional, minimalist.
   Fraunces (display) + Manrope (UI) + Geist Mono (data).
   Light + Dark themes via [data-theme].
   ═══════════════════════════════════════════════════════════════════════════ */

/* ─── Tokens — Light (default) ─────────────────────────────────────────────*/
:root {
  /* Brand */
  --brand:           #00ac69;
  --brand-dark:      #00865d;
  --brand-soft:      rgba(0, 172, 105, 0.10);
  --brand-line:      rgba(0, 172, 105, 0.32);

  /* Surfaces */
  --bg:              #fafafa;
  --surface:         #ffffff;
  --surface-2:       #f4f4f4;
  --surface-3:       #ebebeb;
  --line:            #e7e7e7;
  --line-2:          #d4d4d4;
  --line-3:          #a3a3a3;

  /* Text */
  --text-1:          #0a0a0a;
  --text-2:          #525252;
  --text-3:          #a3a3a3;
  --text-inverse:    #fafafa;

  /* Neutral graphite (secondary actions / contextual buttons) */
  --graphite:        #1f2328;
  --graphite-soft:   rgba(31, 35, 40, 0.06);

  /* Status */
  --ok:              #16a34a;
  --ok-soft:         rgba(22, 163, 74, 0.10);
  --warn:            #ca8a04;
  --warn-soft:       rgba(202, 138, 4, 0.10);
  --err:             #dc2626;
  --err-soft:        rgba(220, 38, 38, 0.10);
  --info:            #2563eb;
  --info-soft:       rgba(37, 99, 235, 0.10);

  /* Elevation */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 10px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.10), 0 4px 8px rgba(0,0,0,0.04);

  /* Radius — sharp, technical */
  --radius-sm: 3px;
  --radius-md: 6px;
  --radius-lg: 10px;
  --radius-pill: 999px;

  /* Type families */
  --font-display: 'Fraunces', Georgia, 'Times New Roman', serif;
  --font-sans:    'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono:    'Geist Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;

  /* Spacing (8-pt grid) */
  --sp-1:  4px;
  --sp-2:  8px;
  --sp-3:  12px;
  --sp-4:  16px;
  --sp-5:  20px;
  --sp-6:  24px;
  --sp-8:  32px;
  --sp-10: 40px;
  --sp-12: 48px;
  --sp-16: 64px;
  --sp-20: 80px;

  /* Motion */
  --ease-out: cubic-bezier(0.2, 0.7, 0.2, 1);
  --dur-fast: 120ms;
  --dur-mid:  220ms;
  --dur-slow: 420ms;

  /* Layout */
  --sidebar-w: 264px;
  --topbar-h:  56px;
  --content-max: 1180px;

  /* ─── Legacy token aliases (for templates with inline CSS) ─── */
  --bg-2:          var(--surface-2);
  --bg-3:          var(--surface-3);
  --text:          var(--text-1);
  --text-dim:      var(--text-2);
  --text-faint:    var(--text-3);
  --line-strong:   var(--line-2);
  --line-bright:   var(--line-3);
  --accent:        var(--brand);
  --accent-dim:    var(--brand-soft);
  --accent-line:   var(--brand-line);
  --accent-soft:   var(--brand);
  --font-serif:    var(--font-display);
  --metrike-green: var(--brand);
  --metrike-green-dark: var(--brand-dark);
  --metrike-gradient:      linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
  --metrike-gradient-soft: linear-gradient(135deg, var(--brand-soft) 0%, var(--brand-soft) 100%);
  --metrike-black: var(--text-1);
  --ok: var(--ok);
  --warn: var(--warn);
  --err: var(--err);
}

/* ─── Tokens — Dark ────────────────────────────────────────────────────────*/
[data-theme="dark"] {
  --brand:           #00d889;
  --brand-dark:      #00ac69;
  --brand-soft:      rgba(0, 216, 137, 0.12);
  --brand-line:      rgba(0, 216, 137, 0.40);

  --bg:              #0b0c0d;
  --surface:         #121315;
  --surface-2:       #1a1c1f;
  --surface-3:       #232629;
  --line:            #26292d;
  --line-2:          #353a40;
  --line-3:          #5a6168;

  --text-1:          #f5f5f5;
  --text-2:          #a3a3a3;
  --text-3:          #737373;
  --text-inverse:    #0a0a0a;

  --graphite:        #d4d4d4;
  --graphite-soft:   rgba(212, 212, 212, 0.06);

  --ok:              #22c55e;
  --ok-soft:         rgba(34, 197, 94, 0.10);
  --warn:            #eab308;
  --warn-soft:       rgba(234, 179, 8, 0.10);
  --err:             #ef4444;
  --err-soft:        rgba(239, 68, 68, 0.10);
  --info:            #3b82f6;
  --info-soft:       rgba(59, 130, 246, 0.10);

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.30);
  --shadow-md: 0 4px 10px rgba(0,0,0,0.40), 0 1px 2px rgba(0,0,0,0.20);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.50), 0 4px 8px rgba(0,0,0,0.20);
}

/* ─── Reset + base ────────────────────────────────────────────────────────*/
* { box-sizing: border-box; }
*::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text-1);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: 'cv11', 'ss03', 'ss05';
}

::selection { background: var(--brand); color: #fff; }

a { color: var(--text-1); text-decoration: none; transition: color var(--dur-fast) var(--ease-out); }
a:hover { color: var(--brand); }

h1, h2, h3, h4 { margin: 0; font-family: var(--font-display); font-weight: 500; letter-spacing: -0.02em; }
p { margin: 0; }
hr { border: 0; border-top: 1px solid var(--line); margin: var(--sp-8) 0; }

code, kbd, samp, pre { font-family: var(--font-mono); }

/* ─── Layout shell ────────────────────────────────────────────────────────*/
.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

@media (max-width: 920px) {
  .shell { grid-template-columns: 1fr; }
  .shell .sidebar {
    position: static; height: auto;
    border-right: 0; border-bottom: 1px solid var(--line);
  }
}

/* ─── Sidebar ─────────────────────────────────────────────────────────────*/
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--line);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  padding: var(--sp-6) 0;
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 0 var(--sp-6) var(--sp-6);
  border-bottom: 1px solid var(--line);
}
.sidebar__brand-mark {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex: 1;
  text-decoration: none;
}
.sidebar__brand-mark img {
  height: 24px;
  width: auto;
}
[data-theme="dark"] .sidebar__brand-logo--metrike { filter: brightness(0) invert(1); }
.sidebar__brand-text {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 16px;
  letter-spacing: -0.01em;
  color: var(--text-1);
  line-height: 1;
}
.sidebar__brand-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-top: 3px;
  display: block;
}

.sidebar__org {
  padding: var(--sp-4) var(--sp-6);
  border-bottom: 1px solid var(--line);
}
.sidebar__org-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: var(--sp-2);
}

.sidebar__nav {
  flex: 1;
  padding: var(--sp-4) 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}
.sidebar__section {
  margin: var(--sp-4) 0 var(--sp-1);
  padding: 0 var(--sp-6);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-3);
  font-weight: 500;
}
.sidebar__section:first-child { margin-top: 0; }

.sidebar__link {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 9px var(--sp-6);
  margin: 0 var(--sp-3) 0 0;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-2);
  text-decoration: none;
  border-left: 2px solid transparent;
  position: relative;
  transition: color var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out);
}
.sidebar__link:hover {
  color: var(--text-1);
  background: var(--surface-2);
}
.sidebar__link.is-active {
  color: var(--text-1);
  background: var(--brand-soft);
  border-left-color: var(--brand);
  font-weight: 600;
}
.sidebar__link-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  color: var(--text-3);
  transition: color var(--dur-fast) var(--ease-out);
}
.sidebar__link:hover .sidebar__link-icon { color: var(--text-1); }
.sidebar__link.is-active .sidebar__link-icon { color: var(--brand); }
.sidebar__link-cta {
  background: var(--brand);
  color: #fff;
  border-left-color: transparent;
  margin: var(--sp-2) var(--sp-4);
  padding: 10px var(--sp-4);
  border-radius: var(--radius-sm);
  font-weight: 600;
}
.sidebar__link-cta:hover {
  background: var(--brand-dark);
  color: #fff;
}
.sidebar__link-cta.is-active {
  background: var(--brand-dark);
  color: #fff;
  border-left-color: transparent;
}
.sidebar__link-cta .sidebar__link-icon { color: #fff; }
.sidebar__link-cta:hover .sidebar__link-icon { color: #fff; }

.sidebar__foot {
  border-top: 1px solid var(--line);
  padding: var(--sp-4) var(--sp-6);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}
/* sidebar__user / __avatar / __user-text / __logout removed —
   the user chip + logout button live in the topbar now (.topbar__user). */

.sidebar__build {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-3);
  letter-spacing: 0.04em;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.sidebar__build-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ok);
  margin-right: var(--sp-2);
  box-shadow: 0 0 0 3px var(--ok-soft);
}

/* ─── Theme toggle ────────────────────────────────────────────────────────*/
.theme-toggle {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-2);
  transition: all var(--dur-fast) var(--ease-out);
}
.theme-toggle:hover {
  color: var(--text-1);
  border-color: var(--line-2);
}
.theme-toggle .material-icons-outlined { font-size: 16px; }
[data-theme="light"] .theme-toggle .icon-dark { display: inline-flex; }
[data-theme="light"] .theme-toggle .icon-light { display: none; }
[data-theme="dark"]  .theme-toggle .icon-dark { display: none; }
[data-theme="dark"]  .theme-toggle .icon-light { display: inline-flex; }

/* ─── Topbar ──────────────────────────────────────────────────────────────*/
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  padding: 0 var(--sp-8);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(8px);
}
.topbar__crumbs {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-2);
  flex: 1;
}
.topbar__crumbs a { color: var(--text-2); }
.topbar__crumbs a:hover { color: var(--text-1); }
.topbar__crumbs .crumb-sep {
  color: var(--text-3);
  font-size: 11px;
}
.topbar__crumbs .crumb-current {
  color: var(--text-1);
  font-weight: 600;
}
.topbar__right {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
}
.topbar__actions {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

/* ─── Topbar user chip + logout (moved out of the sidebar) ───────────────*/
.topbar__user {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 4px 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  transition: border-color 140ms ease, background 140ms ease;
}
.topbar__user:hover { border-color: var(--line-2); background: var(--surface); }
.topbar__user-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-mono);
  font-size: 12px; font-weight: 700;
  flex-shrink: 0;
}
.topbar__user-text {
  display: flex; flex-direction: column;
  line-height: 1.2;
  min-width: 0;
}
.topbar__user-name {
  font-size: 12.5px; color: var(--text-1); font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: 160px;
}
.topbar__user-meta {
  font-family: var(--font-mono);
  font-size: 10px; color: var(--text-3);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: 160px;
}
.topbar__user-logout {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text-2);
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: color 140ms ease, border-color 140ms ease, background 140ms ease;
}
.topbar__user-logout .material-icons-outlined { font-size: 16px; }
.topbar__user-logout:hover {
  color: var(--err);
  border-color: var(--err);
  background: var(--err-soft);
}
@media (max-width: 720px) {
  .topbar__user-text { display: none; }
  .topbar__user { padding: 4px; }
}

/* ─── Main column ─────────────────────────────────────────────────────────*/
.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.main__inner {
  padding: var(--sp-10) var(--sp-12) var(--sp-16);
  max-width: var(--content-max);
  width: 100%;
  animation: fadeUp 360ms var(--ease-out) both;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
@media (max-width: 920px) {
  .main__inner { padding: var(--sp-6) var(--sp-5) var(--sp-12); }
}

/* ─── Page header ─────────────────────────────────────────────────────────*/
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-8);
  padding-bottom: var(--sp-6);
  border-bottom: 1px solid var(--line);
  margin-bottom: var(--sp-8);
}
.page-head__main { flex: 1; min-width: 0; }
.page-head__actions {
  display: flex;
  gap: var(--sp-2);
  flex-wrap: wrap;
  flex-shrink: 0;
}
.eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--brand);
  font-weight: 600;
  margin-bottom: var(--sp-3);
  display: inline-flex;
  align-items: center;
  gap: var(--sp-3);
}
.eyebrow::before {
  content: "";
  width: 20px;
  height: 1px;
  background: var(--brand);
}
.page-title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(32px, 4.4vw, 44px);
  line-height: 1.05;
  color: var(--text-1);
  letter-spacing: -0.025em;
  font-variation-settings: "opsz" 144, "SOFT" 20;
  margin: 0;
}
.page-title__accent { color: var(--brand); }
.page-lede {
  color: var(--text-2);
  font-size: 15px;
  max-width: 62ch;
  margin-top: var(--sp-4);
  line-height: 1.6;
}
.page-lede code {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text-1);
  background: var(--surface-2);
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
}

/* ─── Section ─────────────────────────────────────────────────────────────*/
.section {
  margin-top: var(--sp-10);
}
.section + .section { border-top: 1px solid var(--line); padding-top: var(--sp-10); }
.section__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-4);
  margin-bottom: var(--sp-6);
}
.section__title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.015em;
  color: var(--text-1);
  font-variation-settings: "opsz" 60, "SOFT" 20;
}
.section__title-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-3);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-left: var(--sp-3);
}
.section__lede {
  color: var(--text-2);
  font-size: 14px;
  max-width: 60ch;
  margin-top: var(--sp-2);
}

/* ─── Cards ───────────────────────────────────────────────────────────────*/
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: var(--sp-6);
  transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}
.card--hover:hover {
  border-color: var(--line-2);
  box-shadow: var(--shadow-md);
}
.card--accent { border-left: 3px solid var(--brand); }
.card__title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 500;
  margin-bottom: var(--sp-2);
  letter-spacing: -0.01em;
}
.card__desc {
  color: var(--text-2);
  font-size: 13.5px;
  line-height: 1.6;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--sp-4);
}

/* ─── Buttons ─────────────────────────────────────────────────────────────*/
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  background: var(--brand);
  color: #fff;
  border: 1px solid var(--brand);
  padding: 10px var(--sp-5);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out),
              color var(--dur-fast) var(--ease-out),
              transform var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out);
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover:not(:disabled) {
  background: var(--brand-dark);
  border-color: var(--brand-dark);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.btn:active:not(:disabled) { transform: translateY(0); box-shadow: var(--shadow-sm); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn .material-icons-outlined { font-size: 16px; }

.btn--secondary {
  background: var(--surface);
  color: var(--text-1);
  border-color: var(--line-2);
}
.btn--secondary:hover:not(:disabled) {
  background: var(--surface);
  color: var(--text-1);
  border-color: var(--text-1);
  transform: translateY(-1px);
}

.btn--ghost {
  background: transparent;
  color: var(--text-2);
  border-color: transparent;
}
.btn--ghost:hover:not(:disabled) {
  background: var(--surface-2);
  color: var(--text-1);
  border-color: transparent;
  transform: none;
  box-shadow: none;
}

.btn--danger {
  background: transparent;
  color: var(--err);
  border-color: var(--err);
}
.btn--danger:hover:not(:disabled) {
  background: var(--err);
  color: #fff;
  border-color: var(--err);
}

.btn--sm {
  padding: 6px 12px;
  font-size: 12px;
}
.btn--lg {
  padding: 13px var(--sp-6);
  font-size: 14px;
}

.btn-group { display: inline-flex; gap: var(--sp-2); }

/* ─── Pills / Status badges ───────────────────────────────────────────────*/
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 3px 10px 3px 8px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-pill);
  color: var(--text-2);
  font-weight: 600;
  background: var(--surface);
  line-height: 1.4;
}
.pill__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-3);
  flex-shrink: 0;
}
.pill--ok, .pill--active {
  color: var(--ok);
  border-color: var(--brand-line);
  background: var(--brand-soft);
}
.pill--ok .pill__dot, .pill--active .pill__dot {
  background: var(--brand);
}
.pill--active .pill__dot { animation: pulse 1.6s ease-in-out infinite; }
.pill--warn, .pill--paused {
  color: var(--warn);
  border-color: rgba(202,138,4,0.30);
  background: var(--warn-soft);
}
.pill--warn .pill__dot, .pill--paused .pill__dot { background: var(--warn); }
.pill--err, .pill--deleted {
  color: var(--err);
  border-color: rgba(220,38,38,0.30);
  background: var(--err-soft);
}
.pill--err .pill__dot, .pill--deleted .pill__dot { background: var(--err); }
.pill--draft {
  color: var(--text-3);
}
.pill--draft .pill__dot { background: var(--text-3); }
.pill--done {
  color: var(--text-2);
  border-color: var(--line-2);
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.25); }
}

/* ─── Forms ───────────────────────────────────────────────────────────────*/
.field { display: flex; flex-direction: column; }
.field + .field { margin-top: var(--sp-5); }

.field__label {
  font-family: var(--font-sans);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-1);
  margin-bottom: var(--sp-2);
  display: flex;
  align-items: baseline;
  gap: var(--sp-2);
}
.field__label .optional {
  font-weight: 400;
  font-size: 11.5px;
  color: var(--text-3);
}
.field__hint {
  font-family: var(--font-sans);
  font-size: 12px;
  color: var(--text-3);
  margin-top: var(--sp-2);
  line-height: 1.5;
}
.field__hint code {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-2);
  background: var(--surface-2);
  padding: 1px 5px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
}
.field__error {
  font-family: var(--font-sans);
  font-size: 12px;
  color: var(--err);
  margin-top: var(--sp-2);
}

input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="url"], input[type="search"], input[type="datetime-local"], input[type="date"],
select, textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line-2);
  color: var(--text-1);
  font-family: var(--font-sans);
  font-size: 13.5px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}
input::placeholder, textarea::placeholder { color: var(--text-3); }
textarea { min-height: 100px; line-height: 1.55; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
input:disabled, select:disabled, textarea:disabled {
  background: var(--surface-2);
  color: var(--text-3);
  cursor: not-allowed;
}

select {
  appearance: none;
  cursor: pointer;
  padding-right: 38px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path fill='none' stroke='%23737373' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' d='M3 5l3 3 3-3'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
}
[data-theme="dark"] select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path fill='none' stroke='%23a3a3a3' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' d='M3 5l3 3 3-3'/></svg>");
}

input[type="file"] {
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--text-2);
  padding: 8px;
  border: 1px dashed var(--line-2);
  background: var(--surface-2);
}
input[type="file"]::file-selector-button {
  background: var(--graphite);
  color: var(--text-inverse);
  border: 0;
  border-radius: var(--radius-sm);
  padding: 7px 14px;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  margin-right: var(--sp-3);
}
[data-theme="dark"] input[type="file"]::file-selector-button {
  background: var(--text-1);
  color: var(--bg);
}

/* radio + checkbox visual */
.radio-list { display: flex; flex-direction: column; gap: var(--sp-2); }
.radio-list--row { flex-direction: row; flex-wrap: wrap; }
.radio {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 10px 14px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out);
  font-size: 13.5px;
  background: var(--surface);
}
.radio:hover { border-color: var(--line-3); }
.radio input { accent-color: var(--brand); width: auto; margin: 0; }
.radio:has(input:checked) {
  border-color: var(--brand);
  background: var(--brand-soft);
}

.field-row {
  display: grid;
  gap: var(--sp-5);
  /* minmax(0, …) is the standard guard against content with a tall implicit
     min-width (datetime-local, file inputs) forcing siblings to collapse to
     near-zero width. Without it Chrome can shrink a <select> to ~10px. */
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}
.field-row > .field + .field { margin-top: 0; }
.field-row > .field { min-width: 0; }
.field-row--cols-1 { grid-template-columns: minmax(0, 1fr); }
.field-row--cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 720px) {
  .field-row, .field-row--cols-3 { grid-template-columns: minmax(0, 1fr); }
}

/* ─── Tables ──────────────────────────────────────────────────────────────*/
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  overflow: hidden;
}
table.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}
table.table thead th {
  text-align: left;
  padding: var(--sp-3) var(--sp-5);
  background: var(--surface-2);
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-2);
  font-weight: 600;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.table tbody td {
  padding: var(--sp-3) var(--sp-5);
  border-bottom: 1px solid var(--line);
  color: var(--text-1);
  vertical-align: middle;
}
table.table tbody tr:last-child td { border-bottom: 0; }
table.table tbody tr.is-clickable { cursor: pointer; transition: background var(--dur-fast) var(--ease-out); }
table.table tbody tr.is-clickable:hover { background: var(--surface-2); }
table.table tbody tr.is-clickable:hover td .row-chevron { opacity: 1; transform: translateX(4px); }
table.table td a {
  color: var(--text-1);
  text-decoration: none;
  font-weight: 500;
}
table.table td a:hover { color: var(--brand); }
table.table .col-id {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-3);
  width: 60px;
}
table.table .col-time {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-2);
  white-space: nowrap;
}
.row-chevron {
  display: inline-flex;
  opacity: 0;
  color: var(--text-3);
  transition: opacity var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}
.row-chevron .material-icons-outlined { font-size: 16px; }
.col-actions { width: 1%; white-space: nowrap; text-align: right; }

/* Empty row */
.table-empty {
  text-align: center;
  padding: var(--sp-12) var(--sp-6);
  color: var(--text-3);
  font-size: 14px;
}
.table-empty__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  margin-bottom: var(--sp-3);
}
.table-empty__icon .material-icons-outlined { font-size: 24px; color: var(--text-3); }
.table-empty__cta { margin-top: var(--sp-5); }

/* ─── Stats / KPIs ────────────────────────────────────────────────────────*/
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: var(--sp-4);
  margin-bottom: var(--sp-8);
}
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: var(--sp-5);
}
.stat__label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-3);
  font-weight: 600;
  margin-bottom: var(--sp-2);
}
.stat__value {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 500;
  letter-spacing: -0.025em;
  color: var(--text-1);
  line-height: 1;
  font-variant-numeric: tabular-nums;
  font-variation-settings: "opsz" 96;
}
.stat__sub {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-2);
  margin-top: var(--sp-2);
}
.stat__sub--up { color: var(--ok); }
.stat__sub--down { color: var(--err); }

/* ─── Definition list (detail meta) ───────────────────────────────────────*/
dl.dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: var(--sp-2) var(--sp-5);
  margin: 0;
  font-size: 13.5px;
}
dl.dl dt {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-3);
  font-weight: 600;
  padding-top: 3px;
}
dl.dl dd {
  margin: 0;
  color: var(--text-1);
  word-break: break-word;
}
dl.dl dd.dd--mono { font-family: var(--font-mono); font-size: 12.5px; }

/* ─── Detail spread (magazine) ────────────────────────────────────────────*/
.detail-spread {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: var(--sp-12);
  margin-top: var(--sp-6);
}
.detail-spread__aside {
  border-right: 1px solid var(--line);
  padding-right: var(--sp-8);
}
.detail-spread__aside-section + .detail-spread__aside-section {
  margin-top: var(--sp-6);
  padding-top: var(--sp-6);
  border-top: 1px solid var(--line);
}
.detail-spread__actions {
  display: flex;
  gap: var(--sp-2);
  flex-wrap: wrap;
  margin-top: var(--sp-6);
  padding-top: var(--sp-6);
  border-top: 1px solid var(--line);
}
@media (max-width: 920px) {
  .detail-spread { grid-template-columns: 1fr; gap: var(--sp-6); }
  .detail-spread__aside {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding-right: 0;
    padding-bottom: var(--sp-6);
  }
}

/* ─── Code blocks ─────────────────────────────────────────────────────────*/
pre, .code {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: var(--sp-4) var(--sp-5);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.7;
  color: var(--text-1);
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
  position: relative;
  margin: 0;
}
pre.is-accent, .code.is-accent { border-left: 3px solid var(--brand); }
pre.is-ok      { border-left: 3px solid var(--ok); }
pre.is-err     { border-left: 3px solid var(--err); color: var(--err); }
pre.is-warn    { border-left: 3px solid var(--warn); }
pre.is-empty {
  color: var(--text-3);
  background: transparent;
  border-style: dashed;
}

.copy-btn {
  position: absolute;
  top: var(--sp-2);
  right: var(--sp-2);
  background: var(--surface-2);
  color: var(--text-2);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  font-weight: 600;
  transition: color var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.copy-btn:hover { color: var(--brand); border-color: var(--brand-line); }
.copy-btn.is-copied { color: var(--brand); border-color: var(--brand-line); background: var(--brand-soft); }
.copy-btn .material-icons-outlined { font-size: 12px; }

/* ─── Render canvas ───────────────────────────────────────────────────────*/
.canvas {
  background: var(--surface);
  border: 1px dashed var(--line-2);
  border-radius: var(--radius-md);
  padding: var(--sp-8) var(--sp-5) var(--sp-4);
  position: relative;
  min-height: 220px;
}
.canvas::before {
  content: "Preview";
  position: absolute;
  top: var(--sp-2);
  left: var(--sp-3);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  color: var(--text-3);
  font-weight: 600;
  text-transform: uppercase;
}
.canvas iframe, .canvas img, .canvas video {
  display: block;
  max-width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: var(--radius-sm);
  margin: 0 auto;
}
.canvas iframe { width: 100%; height: 340px; }
.canvas-empty {
  color: var(--text-3);
  font-size: 13px;
  padding: var(--sp-12) 0 var(--sp-8);
  text-align: center;
}

/* ─── Empty states (large) ────────────────────────────────────────────────*/
.empty {
  text-align: center;
  padding: var(--sp-16) var(--sp-6);
  border: 1px dashed var(--line-2);
  border-radius: var(--radius-md);
  background: var(--surface);
}
.empty__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  background: var(--surface-2);
  border-radius: var(--radius-pill);
  margin-bottom: var(--sp-4);
}
.empty__icon .material-icons-outlined {
  font-size: 28px;
  color: var(--text-3);
}
.empty__title {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--text-1);
  margin-bottom: var(--sp-2);
}
.empty__desc {
  color: var(--text-2);
  font-size: 14px;
  max-width: 38ch;
  margin: 0 auto var(--sp-5);
  line-height: 1.6;
}

/* ─── Wizard step (kept for ads_wizard.html) ──────────────────────────────*/
.step {
  border-top: 1px solid var(--line);
  padding: var(--sp-8) 0;
}
.step:first-child { border-top: 0; padding-top: var(--sp-4); }
.step__head {
  display: flex;
  align-items: baseline;
  gap: var(--sp-5);
  margin-bottom: var(--sp-5);
}
.step__num {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 400;
  color: var(--text-3);
  letter-spacing: -0.04em;
  width: 48px;
  flex-shrink: 0;
  font-variation-settings: "opsz" 144;
  line-height: 1;
}
.step__title {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 500;
  color: var(--text-1);
  flex: 1;
  letter-spacing: -0.015em;
  font-variation-settings: "opsz" 60;
}
.step__title-sub {
  color: var(--text-2);
  font-weight: 400;
  margin-left: var(--sp-2);
}

/* ─── Searchable parent-entity combo (used by /new forms + wizard) ───────*/
.combo { position: relative; }
.combo__menu {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: 0 12px 32px -8px rgba(0,0,0,0.18), 0 2px 4px rgba(0,0,0,0.06);
  max-height: 320px; overflow-y: auto; z-index: 20; display: none;
  padding: 4px 0;
}
[data-theme="dark"] .combo__menu {
  box-shadow: 0 16px 40px -10px rgba(0,0,0,0.6), 0 2px 4px rgba(0,0,0,0.4);
}
.combo__menu.is-open { display: block; }

.combo__item {
  padding: 10px 14px;
  margin: 0 4px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13.5px;
  display: grid;
  grid-template-columns: 24px 1fr auto;
  gap: var(--sp-3);
  align-items: center;
  transition: background 120ms ease, color 120ms ease;
}
.combo__item-icon {
  width: 24px; height: 24px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--brand-soft);
  color: var(--brand);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}
.combo__item-icon .material-icons-outlined { font-size: 14px; }
.combo__item-text {
  display: flex; flex-direction: column; min-width: 0;
}
.combo__item-label {
  color: var(--text-1);
  font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.combo__item-meta {
  font-size: 11px;
  color: var(--text-3);
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
  margin-top: 1px;
}
.combo__item-id {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-3);
  flex-shrink: 0;
}
.combo__item:hover,
.combo__item.is-focused {
  background: var(--brand-soft);
}
.combo__item.is-focused .combo__item-label { color: var(--brand); }

.combo__item-empty {
  padding: 18px;
  color: var(--text-3);
  font-size: 12.5px;
  font-style: italic;
  text-align: center;
}

.combo__create {
  display: grid;
  grid-template-columns: 24px 1fr auto;
  gap: var(--sp-3);
  align-items: center;
  padding: 12px 14px;
  margin: 4px 4px 0;
  border-radius: var(--radius-sm);
  font-size: 13px;
  background: var(--brand-soft);
  color: var(--text-1);
  font-weight: 500;
  cursor: pointer;
  border-top: 1px dashed var(--brand-line);
  transition: background 120ms ease;
}
.combo__create:hover, .combo__create.is-focused {
  background: rgba(0, 172, 105, 0.16);
}
.combo__create-icon {
  width: 24px; height: 24px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--brand);
  color: #fff;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}
.combo__create-icon .material-icons-outlined { font-size: 16px; }
.combo__create-text strong { color: var(--brand); }
.combo__create-hint {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 2px 8px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.combo__selected {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 8px 8px 12px;
  margin-top: 0;
  background: var(--brand-soft);
  border: 1px solid var(--brand-line);
  border-radius: var(--radius-md);
  font-size: 13.5px;
  color: var(--text-1);
  animation: comboSelectedIn 240ms cubic-bezier(.2,.7,.2,1) both;
}
@keyframes comboSelectedIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.combo__selected-text { display: inline-flex; align-items: center; gap: 8px; }
.combo__selected button {
  background: var(--surface); border: 1px solid var(--line-2);
  cursor: pointer; color: var(--text-2);
  display: inline-flex; align-items: center; justify-content: center;
  padding: 4px; border-radius: var(--radius-sm);
  transition: color 120ms ease, border-color 120ms ease;
}
.combo__selected button:hover { color: var(--err); border-color: var(--err); }

/* Inline-create panel — visually attached to the search input above it,
   not a separate floating block. Hard-merge with no top margin + a
   matching top border so it reads as "the input expanded downward". */
.inline-create {
  margin-top: -1px;            /* overlap the input's bottom border */
  padding: var(--sp-4);
  background: var(--surface-2);
  border: 1px solid var(--brand-line);
  border-top: 1px dashed var(--brand-line);
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  display: none;
  animation: inlineCreateIn 220ms cubic-bezier(.2,.7,.2,1) both;
}
.inline-create.is-open { display: block; }
@keyframes inlineCreateIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}
/* When the inline-create is open, square the search input's bottom corners
   and tint its border so the two read as a single connected unit. */
.combo:has(.inline-create.is-open) > [data-combo-search] {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  border-color: var(--brand-line);
}
/* Tighten label→input distance inside inline-create — labels stick to
   their own input, not to the field below them. */
.inline-create .field {
  margin-bottom: 0;
}
.inline-create .field + .field,
.inline-create .field-row {
  margin-top: var(--sp-3);
}
.inline-create .field__label {
  margin-bottom: 4px;
}
/* "Criar e usar" + "Cancelar" buttons sit visually attached at the bottom
   of the inline panel, separated by a thin divider from the inputs above. */
.inline-create .u-flex {
  margin-top: var(--sp-4);
  padding-top: var(--sp-3);
  border-top: 1px dashed var(--line);
}

/* ─── Tag selector / radio cards (creative kind etc.) ─────────────────────*/
.choice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--sp-3);
}
.choice {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--sp-2);
  padding: var(--sp-4) var(--sp-5);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-md);
  cursor: pointer;
  background: var(--surface);
  transition: border-color var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out);
}
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice__icon {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.choice__title { font-weight: 600; font-size: 14px; }
.choice__desc { font-size: 12px; color: var(--text-3); }
.choice:has(input:checked) {
  border-color: var(--brand);
  background: var(--brand-soft);
}
.choice:has(input:checked) .choice__icon { background: var(--brand); color: #fff; }

/* ─── Toast ───────────────────────────────────────────────────────────────*/
.toast {
  position: fixed;
  bottom: var(--sp-6);
  right: var(--sp-6);
  background: var(--graphite);
  color: var(--text-inverse);
  padding: 10px var(--sp-4);
  border-radius: var(--radius-md);
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  z-index: 100;
  animation: toastIn 220ms var(--ease-out);
}
[data-theme="dark"] .toast { background: var(--text-1); color: var(--bg); }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ─── Utils ───────────────────────────────────────────────────────────────*/
.u-mono   { font-family: var(--font-mono); }
.u-faint  { color: var(--text-3); }
.u-dim    { color: var(--text-2); }
.u-accent { color: var(--brand); }
.u-right  { text-align: right; }
.u-center { text-align: center; }
.u-flex   { display: flex; }
.u-gap-2  { gap: var(--sp-2); }
.u-gap-3  { gap: var(--sp-3); }
.u-gap-4  { gap: var(--sp-4); }
.u-mt-4   { margin-top: var(--sp-4); }
.u-mt-6   { margin-top: var(--sp-6); }
.u-mt-8   { margin-top: var(--sp-8); }
.u-mb-2   { margin-bottom: var(--sp-2); }
.u-mb-4   { margin-bottom: var(--sp-4); }
.u-mb-6   { margin-bottom: var(--sp-6); }

.u-truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.u-hidden { display: none !important; }

/* ═══════════════════════════════════════════════════════════════════════════
   LEGACY COMPAT — keep templates not yet ported readable.
   New code should use the BEM-style classes above. These aliases let detail
   pages, wizard, dashboard, tools, etc. inherit tokens until refactored.
   ═══════════════════════════════════════════════════════════════════════════ */

/* Old eyebrow */
.page-eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--brand);
  font-weight: 600;
  margin-bottom: var(--sp-3);
  display: inline-flex;
  align-items: center;
  gap: var(--sp-3);
}
.page-eyebrow::before {
  content: "";
  width: 20px;
  height: 1px;
  background: var(--brand);
}

/* Old page title accent */
.page-title .accent { color: var(--brand); }

/* Old page-meta (right-aligned page metadata) */
.page-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-3);
  text-align: right;
  line-height: 1.8;
  flex-shrink: 0;
}
.page-meta span {
  color: var(--text-1);
  font-family: var(--font-display);
  font-size: 16px;
  letter-spacing: -0.01em;
  text-transform: none;
}

/* Old field-label / field-hint */
label.field-label, .field-label {
  display: block;
  font-family: var(--font-sans);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-1);
  margin-bottom: var(--sp-2);
}
label.field-label .optional, .field-label .optional {
  font-weight: 400;
  color: var(--text-3);
  margin-left: 4px;
}
.field-hint {
  font-size: 12px;
  color: var(--text-3);
  margin-top: var(--sp-2);
  line-height: 1.5;
}
.field-hint code {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-2);
  background: var(--surface-2);
  padding: 1px 5px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
}

/* Old btn modifiers (is-ghost, is-danger) */
.btn.is-ghost {
  background: transparent;
  color: var(--text-2);
  border-color: transparent;
}
.btn.is-ghost:hover:not(:disabled) {
  background: var(--surface-2);
  color: var(--text-1);
  border-color: transparent;
  transform: none;
  box-shadow: none;
}
.btn.is-danger {
  background: transparent;
  color: var(--err);
  border-color: var(--err);
}
.btn.is-danger:hover:not(:disabled) {
  background: var(--err);
  color: #fff;
  border-color: var(--err);
}

/* Old data table → emulate .table appearance for unmodified usages */
table.data {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}
table.data th {
  text-align: left;
  padding: var(--sp-3) var(--sp-5);
  background: var(--surface-2);
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-2);
  font-weight: 600;
  border-bottom: 1px solid var(--line);
}
table.data td {
  padding: var(--sp-3) var(--sp-5);
  border-bottom: 1px solid var(--line);
  color: var(--text-1);
}
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr.is-clickable { cursor: pointer; }
table.data tbody tr.is-clickable:hover { background: var(--surface-2); }
table.data td a { color: var(--text-1); text-decoration: none; font-weight: 500; }
table.data td a:hover { color: var(--brand); }

/* Old tag-id / tag-status */
.tag-id {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-3);
}
.tag-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 3px 10px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-pill);
  color: var(--text-2);
  font-weight: 600;
  background: var(--surface);
}
.tag-status.is-active {
  color: var(--ok);
  border-color: var(--brand-line);
  background: var(--brand-soft);
}
.tag-status.is-paused {
  color: var(--warn);
  border-color: rgba(202,138,4,0.30);
  background: var(--warn-soft);
}
.tag-status.is-draft {
  color: var(--text-3);
}
.tag-status.is-done {
  color: var(--text-2);
  border-color: var(--line-2);
}
.tag-status.is-deleted {
  color: var(--err);
  border-color: rgba(220,38,38,0.30);
  background: var(--err-soft);
}

/* Old wizard step internals */
.step-head {
  display: flex;
  align-items: baseline;
  gap: var(--sp-5);
  margin-bottom: var(--sp-5);
}
.step-num {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 400;
  color: var(--text-3);
  letter-spacing: -0.04em;
  width: 48px;
  flex-shrink: 0;
  line-height: 1;
}
.step-title {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 500;
  color: var(--text-1);
  flex: 1;
  letter-spacing: -0.015em;
}
.step-title .sub {
  color: var(--text-2);
  font-weight: 400;
  margin-left: var(--sp-2);
}

/* Old pill variants (is-pending, is-ok, is-err, is-active) */
.pill.is-pending { color: var(--text-2); }
.pill.is-active, .pill.is-ok {
  color: var(--ok);
  border-color: var(--brand-line);
  background: var(--brand-soft);
}
.pill.is-active .dot, .pill.is-ok .dot { background: var(--brand); }
.pill.is-active .dot { animation: pulse 1.6s ease-in-out infinite; }
.pill.is-err {
  color: var(--err);
  border-color: rgba(220,38,38,0.30);
  background: var(--err-soft);
}
.pill.is-err .dot { background: var(--err); }
.pill .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-3);
  flex-shrink: 0;
}

/* Detail-spread aliases */
.detail-aside {
  border-right: 1px solid var(--line);
  padding-right: var(--sp-8);
}
.detail-aside dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: var(--sp-2) var(--sp-4);
  margin: 0;
  font-size: 13.5px;
}
.detail-aside dt {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-3);
  font-weight: 600;
  padding-top: 3px;
}
.detail-aside dd {
  margin: 0;
  color: var(--text-1);
  font-family: var(--font-mono);
  font-size: 12.5px;
  word-break: break-word;
}
.detail-aside dd.is-prose { font-family: var(--font-sans); font-size: 13.5px; }
.aside-section {
  margin-top: var(--sp-6);
  padding-top: var(--sp-6);
  border-top: 1px solid var(--line);
}
.aside-section-label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-3);
  font-weight: 600;
  margin-bottom: var(--sp-3);
}
.detail-actions {
  display: flex;
  gap: var(--sp-2);
  flex-wrap: wrap;
  margin-top: var(--sp-6);
  padding-top: var(--sp-6);
  border-top: 1px solid var(--line);
}
@media (max-width: 920px) {
  .detail-aside { border-right: 0; border-bottom: 1px solid var(--line); padding-right: 0; padding-bottom: var(--sp-6); }
}

/* Old stats row */
.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--sp-4);
  padding: var(--sp-5) 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.stat-cell {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stat-label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-3);
  font-weight: 600;
}
.stat-num {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 500;
  line-height: 1;
  color: var(--text-1);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.025em;
}
.stat-num.is-accent { color: var(--brand); }
.stat-sub {
  font-family: var(--font-sans);
  font-size: 11.5px;
  color: var(--text-2);
}

/* 7-day bar chart (used by _ads_metrics) */
.bar-chart {
  margin-top: var(--sp-4);
  padding: var(--sp-5) 0 var(--sp-2);
  border-bottom: 1px solid var(--line);
}
.bar-chart-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: var(--sp-3);
  height: 120px;
  align-items: end;
}
.bar-day {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  position: relative;
}
.bar-fill {
  background: var(--brand);
  min-height: 1px;
  transition: opacity var(--dur-fast) var(--ease-out);
  border-radius: 2px 2px 0 0;
}
.bar-fill.is-empty {
  background: var(--line-2);
  height: 1px !important;
  opacity: 0.6;
}
.bar-day:hover .bar-fill { opacity: 0.7; }
.bar-day:hover .bar-value { opacity: 1; }
.bar-value {
  position: absolute;
  top: -22px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-1);
  opacity: 0;
  transition: opacity var(--dur-fast) var(--ease-out);
  white-space: nowrap;
  pointer-events: none;
}
.bar-labels {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: var(--sp-3);
  margin-top: var(--sp-2);
}
.bar-label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-3);
  text-align: center;
  letter-spacing: 0.04em;
}

/* Related-empty link card */
.related-empty {
  padding: var(--sp-4) 0;
  color: var(--text-2);
  font-size: 13.5px;
  border-top: 1px solid var(--line);
}
.related-empty a { color: var(--text-1); border-bottom: 1px solid var(--line-2); padding-bottom: 1px; }
.related-empty a:hover { color: var(--brand); border-color: var(--brand); }

/* Render canvas (old; new is .canvas — keep for ads_zone_test) */
.render-canvas {
  background: var(--surface);
  border: 1px dashed var(--line-2);
  border-radius: var(--radius-md);
  padding: var(--sp-8) var(--sp-5) var(--sp-4);
  position: relative;
  min-height: 220px;
}
.render-canvas::before {
  content: "Preview";
  position: absolute;
  top: var(--sp-2);
  left: var(--sp-3);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  color: var(--text-3);
  font-weight: 600;
  text-transform: uppercase;
}
.render-canvas iframe {
  display: block;
  width: 100%;
  height: 340px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: var(--radius-sm);
}
.render-canvas .canvas-empty {
  color: var(--text-3);
  font-size: 13px;
  padding: var(--sp-12) 0 var(--sp-8);
  text-align: center;
}

/* Result grid (old detail pages — financial-table style) */
.result-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--sp-3) var(--sp-8);
  padding: var(--sp-5) var(--sp-6);
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--brand);
  font-size: 13.5px;
  border-radius: var(--radius-sm);
  margin: 0;
}
.result-grid dt {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-3);
  font-weight: 600;
  align-self: center;
}
.result-grid dd {
  margin: 0;
  font-family: var(--font-mono);
  color: var(--text-1);
  align-self: center;
  word-break: break-word;
}
.result-grid dd .big {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 500;
  color: var(--brand);
  letter-spacing: -0.02em;
}

/* Footnote */
.footnote {
  color: var(--text-3);
  font-size: 11.5px;
  margin-top: var(--sp-4);
  line-height: 1.7;
}

/* Old form select arrow already covered by global select style — no extra needed.
   Old .copy-btn alias already kept its name. */

/* ═══════════════════════════════════════════════════════════════════════
   Filter panel (admin list pages) + filter chips
   ═══════════════════════════════════════════════════════════════════════ */
.filter-panel { margin: var(--sp-5) 0 var(--sp-6); }
.filter-panel__bar {
  display: flex; gap: var(--sp-3); align-items: stretch;
  flex-wrap: nowrap;
}
.filter-panel__search {
  flex: 1 1 auto; max-width: 480px; min-width: 0;
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 0 var(--sp-4); height: 40px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg);
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.filter-panel__search:focus-within {
  border-color: var(--brand-line);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.filter-panel__search > .material-icons-outlined {
  flex-shrink: 0;
  font-size: 18px;
  color: var(--text-2);
  line-height: 1;
}
.filter-panel__search input {
  flex: 1 1 auto; min-width: 0; height: 100%;
  border: 0; outline: 0; background: transparent;
  font: inherit; color: var(--text-1);
}
.filter-panel__toggle {
  display: inline-flex; align-items: center; gap: 8px;
  height: 40px; padding: 0 var(--sp-4);
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--text-1); font: inherit; cursor: pointer;
  white-space: nowrap;
  transition: border-color 120ms ease, background 120ms ease, color 120ms ease;
}
.filter-panel__toggle:hover {
  border-color: var(--brand-line); color: var(--brand);
}
.filter-panel__toggle[aria-expanded="true"] {
  border-color: var(--brand-line); background: var(--brand-soft); color: var(--brand);
}
.filter-panel__count {
  font-size: 11px; font-weight: 600; color: var(--brand);
  padding: 2px 8px; border-radius: 999px; background: var(--brand-soft);
}
.filter-panel__chips { display: flex; gap: var(--sp-2); flex-wrap: wrap; margin-top: var(--sp-3); }
.filter-panel__chips:empty { margin: 0; }
.filter-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px; border: 1px solid var(--brand-line);
  border-radius: 999px; background: var(--brand-soft); color: var(--brand);
  font-size: 12px; cursor: pointer; font: inherit;
  transition: background 120ms ease, color 120ms ease;
}
.filter-chip:hover { background: var(--brand); color: #fff; }
.filter-chip strong { font-weight: 600; }
.filter-panel__body {
  margin-top: var(--sp-3); padding: var(--sp-5);
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px;
}
.filter-panel__grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--sp-4);
}
.filter-panel__grid .field__label {
  display: block; font-size: 11px; color: var(--text-2);
  text-transform: uppercase; letter-spacing: .08em; margin-bottom: 6px;
}
.filter-panel__grid input,
.filter-panel__grid select {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px;
  background: var(--bg); color: var(--text-1); font: inherit;
  transition: border-color 120ms ease;
}
.filter-panel__grid input:focus,
.filter-panel__grid select:focus {
  outline: 0; border-color: var(--brand-line);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

/* ═══════════════════════════════════════════════════════════════════════
   Command palette (⌘K)
   ═══════════════════════════════════════════════════════════════════════ */
.palette[open] {
  border: 0; padding: 0; background: transparent;
  max-width: min(720px, 92vw); width: 100%;
  margin: 12vh auto auto;
}
.palette::backdrop {
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(4px);
}
.palette__form {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 32px 80px rgba(0,0,0,0.4);
  overflow: hidden;
}
.palette__input-row {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--line);
}
.palette__input-row > .material-icons-outlined {
  flex-shrink: 0;
  font-size: 20px;
  color: var(--text-2);
}
.palette__input-row input {
  flex: 1; min-width: 0; border: 0; outline: 0; background: transparent;
  font: inherit; font-size: 16px; color: var(--text-1);
}
.palette__input-row input::placeholder {
  color: var(--text-2);
}
.palette__kbd {
  flex-shrink: 0;
  font: 11px var(--font-mono); padding: 3px 8px;
  border: 1px solid var(--line); border-radius: 4px;
  background: var(--surface-2); color: var(--text-2);
}
.palette__results { max-height: 60vh; overflow-y: auto; }
.palette__hint {
  padding: var(--sp-8) var(--sp-6); text-align: center;
  color: var(--text-2); font-size: 13px; line-height: 1.6;
}
.palette__group { padding: var(--sp-2) 0; border-bottom: 1px solid var(--line); }
.palette__group:last-child { border-bottom: 0; }
.palette__group-head {
  padding: var(--sp-2) var(--sp-5) var(--sp-1);
  font-size: 10px; font-weight: 600; color: var(--text-2);
  text-transform: uppercase; letter-spacing: .12em;
}
.palette__row {
  display: flex; align-items: center; gap: var(--sp-3); width: 100%;
  padding: var(--sp-3) var(--sp-5);
  border: 0; background: transparent; cursor: pointer;
  font: inherit; text-align: left; color: var(--text-1);
  transition: background 60ms ease;
}
.palette__row:hover, .palette__row.is-focused {
  background: var(--brand-soft);
}
.palette__row.is-focused .palette__row-name { color: var(--brand); }
.palette__row-icon {
  flex-shrink: 0; width: 28px; height: 28px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 6px; background: var(--surface-2);
  color: var(--text-2);
}
.palette__row-icon .material-icons-outlined { font-size: 16px; }
.palette__row-text {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; gap: 2px;
  overflow: hidden;
}
.palette__row-name {
  font-weight: 500; font-size: 14px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.palette__row-meta {
  font-size: 11px; color: var(--text-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.palette__row-id {
  flex-shrink: 0;
  font: 11px var(--font-mono); color: var(--text-2);
  padding: 2px 8px; border-radius: 4px; background: var(--surface-2);
}

.palette-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; border: 1px solid var(--line); border-radius: 6px;
  background: var(--bg); color: var(--text-2); font-size: 11px; cursor: pointer;
  font: inherit;
}
.palette-chip:hover { color: var(--brand); border-color: var(--brand-line); background: var(--brand-soft); }
.palette-chip kbd { font: 10px var(--font-mono); }
