/* ---------- Tokens ---------- */
:root {
  --bg: #0b0f17;
  --surface: #131826;
  --surface-2: #1a2030;
  --surface-3: #232a3d;
  --border: #252c3d;
  --border-strong: #323a52;
  --text: #e8ecf3;
  --text-dim: #aab2c5;
  --text-muted: #6c7691;
  --accent: oklch(0.68 0.14 255);
  --accent-soft: oklch(0.68 0.14 255 / 0.14);
  --accent-border: oklch(0.68 0.14 255 / 0.45);
  --accent-text: oklch(0.85 0.08 255);
  --success: oklch(0.72 0.14 155);
  --success-soft: oklch(0.72 0.14 155 / 0.14);
  --danger: oklch(0.68 0.18 25);
  --danger-soft: oklch(0.68 0.18 25 / 0.14);
  --warn: oklch(0.78 0.14 80);
  --warn-soft: oklch(0.78 0.14 80 / 0.14);
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 0 rgba(255,255,255,0.03) inset, 0 1px 2px rgba(0,0,0,0.3);
  --shadow: 0 8px 24px -8px rgba(0,0,0,0.5);
  --font-sans: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans KR", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.005em;
}
button { font-family: inherit; }
input, textarea, select { font-family: inherit; color: inherit; }

/* Billing pill in nav */
.billing-pill {
  display: flex; align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12.5px;
  height: 30px;
  overflow: hidden;
  transition: border-color 120ms;
}
.billing-pill:hover { border-color: var(--border-strong); }
.billing-pill.byok {
  padding: 0 12px;
  gap: 7px;
  cursor: pointer;
  color: var(--text-dim);
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.billing-pill.byok:hover { color: var(--text); }
.billing-pill.byok .icon { color: var(--text-muted); }

.billing-pill.tokens { background: var(--accent-soft); border-color: var(--accent-border); }
.bp-balance {
  display: flex; align-items: center; gap: 6px;
  padding: 0 4px 0 12px;
  height: 100%;
  background: none; border: none;
  color: var(--accent-text);
  cursor: pointer;
  font-family: inherit;
  font-size: 12.5px;
}
.bp-balance .icon { color: var(--accent-text); }
.bp-balance:hover { color: oklch(0.92 0.05 255); }
.bp-num { font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; margin-left: 2px; }
.bp-label { color: var(--text-dim); font-size: 12px; margin-left: 1px; }
.bp-add {
  width: 28px; height: 28px;
  margin: 0 1px 0 4px;
  border-radius: 999px;
  border: none;
  background: var(--accent);
  color: #0b0f17;
  display: grid; place-items: center;
  cursor: pointer;
  transition: background 120ms;
}
.bp-add:hover { background: oklch(0.78 0.14 255); }
.bp-add .icon { color: #0b0f17; stroke-width: 2.5; }

/* Background grain ---------- */
.bg-grid {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image:
    radial-gradient(circle at 20% 0%, oklch(0.68 0.14 255 / 0.08), transparent 50%),
    radial-gradient(circle at 80% 100%, oklch(0.6 0.1 280 / 0.06), transparent 50%);
}

/* ---------- Layout ---------- */
.app { position: relative; min-height: 100vh; display: flex; flex-direction: column; z-index: 1; }
.page { flex: 1; max-width: 1200px; width: 100%; margin: 0 auto; padding: 32px 28px 72px; }
.page-narrow { max-width: 880px; }

/* ---------- Top Nav ---------- */
.topnav {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in oklab, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.topnav-inner {
  max-width: 1200px; margin: 0 auto;
  padding: 0 28px;
  height: 56px;
  display: flex; align-items: center; gap: 16px;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 600; font-size: 15px; letter-spacing: -0.01em;
  color: var(--text);
}
.brand-mark {
  width: 22px; height: 22px; border-radius: 6px;
  background: linear-gradient(135deg, oklch(0.68 0.14 255), oklch(0.6 0.18 290));
  display: grid; place-items: center;
  color: white; font-weight: 700; font-size: 11px;
  box-shadow: 0 1px 0 rgba(255,255,255,0.2) inset, 0 4px 12px -4px oklch(0.68 0.14 255 / 0.5);
}
.nav-links { display: flex; gap: 4px; }
.nav-link {
  padding: 7px 12px;
  border-radius: 7px;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  background: none; border: none;
  transition: background 120ms, color 120ms;
  display: inline-flex; align-items: center; gap: 6px;
}
.nav-link .nav-pill {
  display: inline-grid; place-items: center;
  min-width: 18px; height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent); color: #0b0f17;
  font-size: 10.5px; font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.nav-link:hover { color: var(--text); background: var(--surface-2); }
.nav-link.active { color: var(--text); background: var(--surface-2); }
.nav-spacer { flex: 1; }

/* ---------- User panel ---------- */
.user-panel { position: relative; }
.user-trigger {
  display: flex; align-items: center; gap: 9px;
  padding: 5px 10px 5px 5px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  transition: background 120ms;
}
.user-trigger:hover { background: var(--surface-3); }
.avatar {
  width: 24px; height: 24px; border-radius: 50%;
  background: linear-gradient(135deg, oklch(0.7 0.14 30), oklch(0.65 0.16 350));
  display: grid; place-items: center;
  color: white; font-weight: 600; font-size: 11px;
}
.user-menu {
  position: absolute; top: calc(100% + 6px); right: 0;
  min-width: 220px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 6px;
  z-index: 50;
}
.user-menu-header {
  padding: 10px 10px 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}
.user-menu-header .name { font-weight: 600; font-size: 13.5px; }
.user-menu-header .email { color: var(--text-muted); font-size: 12px; margin-top: 2px; }
.menu-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border-radius: 7px;
  background: none; border: none;
  color: var(--text-dim);
  font-size: 13px;
  cursor: pointer;
  text-align: left;
}
.menu-item:hover { background: var(--surface-3); color: var(--text); }
.menu-item.danger { color: oklch(0.78 0.15 25); }
.menu-item.danger:hover { background: var(--danger-soft); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 120ms, border-color 120ms, transform 80ms;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-3); border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary {
  background: var(--accent);
  border-color: oklch(0.68 0.14 255 / 0.6);
  color: #0b0f17;
  font-weight: 600;
}
.btn.primary:hover { background: oklch(0.74 0.14 255); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { color: oklch(0.78 0.15 25); border-color: oklch(0.55 0.15 25 / 0.4); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.sm { padding: 6px 10px; font-size: 12.5px; border-radius: 7px; }
.btn.lg { padding: 12px 20px; font-size: 14px; }
.btn.block { width: 100%; }
.btn .icon { width: 14px; height: 14px; flex: 0 0 14px; }

/* ---------- Inputs ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12.5px; font-weight: 500; color: var(--text-dim); }
.field .hint { font-size: 12px; color: var(--text-muted); }
.input, .textarea, .select {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13.5px;
  color: var(--text);
  outline: none;
  transition: border-color 120ms, box-shadow 120ms;
  width: 100%;
}
.input:focus, .textarea:focus, .select:focus {
  border-color: var(--accent-border);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.textarea { resize: vertical; min-height: 120px; line-height: 1.6; font-family: var(--font-sans); }
.textarea.mono { font-family: var(--font-mono); font-size: 13px; }
.input.mono { font-family: var(--font-mono); }
.select { appearance: none; padding-right: 32px; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238a93a6' stroke-width='2'><polyline points='6 9 12 15 18 9'/></svg>"); background-repeat: no-repeat; background-position: right 10px center; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.card-pad { padding: 20px 22px; }
.card-header {
  padding: 16px 22px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.card-title { font-weight: 600; font-size: 14.5px; }
.card-sub { color: var(--text-muted); font-size: 12.5px; margin-top: 2px; }

/* ---------- Headings ---------- */
.h1 { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; }
.h2 { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
.eyebrow { font-size: 11.5px; font-weight: 600; color: var(--text-muted); letter-spacing: 0.06em; text-transform: uppercase; }
.muted { color: var(--text-muted); }
.dim { color: var(--text-dim); }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 500;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-dim);
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.success { color: oklch(0.82 0.14 155); background: var(--success-soft); border-color: oklch(0.55 0.14 155 / 0.4); }
.badge.warn { color: oklch(0.85 0.13 80); background: var(--warn-soft); border-color: oklch(0.6 0.13 80 / 0.4); }
.badge.danger { color: oklch(0.82 0.15 25); background: var(--danger-soft); border-color: oklch(0.55 0.15 25 / 0.4); }
.badge.accent { color: var(--accent-text); background: var(--accent-soft); border-color: var(--accent-border); }

/* ---------- Misc ---------- */
.row { display: flex; align-items: center; gap: 10px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.divider { height: 1px; background: var(--border); border: none; margin: 0; }
.kbd {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface-2);
  color: var(--text-dim);
}

/* ---------- Page header ---------- */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.page-header .sub { color: var(--text-muted); font-size: 13.5px; margin-top: 4px; }

/* ---------- Login ---------- */
.login-shell {
  min-height: 100vh;
  display: grid; place-items: center;
  padding: 24px;
}
.login-card {
  width: 100%; max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
}
.login-brand {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 24px;
}
.tabs {
  display: grid; grid-template-columns: 1fr 1fr;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 3px;
  margin-bottom: 22px;
}
.tab {
  padding: 8px 12px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: none;
  color: var(--text-dim);
}
.tab.active { background: var(--surface-3); color: var(--text); box-shadow: 0 1px 0 rgba(255,255,255,0.03) inset; }
.oauth-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.divider-or { display: flex; align-items: center; gap: 12px; margin: 18px 0; color: var(--text-muted); font-size: 11.5px; }
.divider-or::before, .divider-or::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* ---------- Run page ---------- */
.run-hero {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px 32px;
  display: flex; flex-direction: column; align-items: center; gap: 18px;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.run-hero::before {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(circle at 50% 0%, oklch(0.68 0.14 255 / 0.12), transparent 60%);
  pointer-events: none;
}
.run-button {
  position: relative;
  padding: 16px 44px;
  border-radius: 12px;
  background: var(--accent);
  border: 1px solid oklch(0.74 0.14 255 / 0.6);
  color: #0b0f17;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 10px;
  box-shadow: 0 8px 24px -8px oklch(0.68 0.14 255 / 0.6), 0 1px 0 rgba(255,255,255,0.25) inset;
  transition: transform 80ms, background 120ms;
}
.run-button:hover { background: oklch(0.74 0.14 255); }
.run-button:active { transform: translateY(1px); }
.run-button[disabled] { background: var(--surface-3); color: var(--text-muted); cursor: not-allowed; box-shadow: none; border-color: var(--border); }
.run-stats { display: flex; gap: 28px; color: var(--text-muted); font-size: 12.5px; }
.run-stats .stat strong { color: var(--text); font-weight: 600; }

/* Run pipeline stage pills */
.stages {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin-bottom: 12px;
}
.stage {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 12.5px; font-weight: 500;
  transition: background 160ms, border-color 160ms, color 160ms;
}
.stage .pip {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  flex: 0 0 7px;
  transition: background 160ms, box-shadow 160ms;
}
.stage.done {
  border-color: oklch(0.55 0.12 155 / 0.5);
  background: oklch(0.55 0.12 155 / 0.12);
  color: oklch(0.85 0.13 155);
}
.stage.done .pip { background: oklch(0.78 0.14 155); }
.stage.active {
  border-color: var(--accent-border);
  background: var(--accent-soft);
  color: var(--accent-text);
}
.stage.active .pip {
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
  animation: stage-pulse 1.4s ease-in-out infinite;
}
.stage.failed {
  border-color: oklch(0.55 0.15 25 / 0.5);
  background: oklch(0.55 0.15 25 / 0.12);
  color: oklch(0.85 0.13 25);
}
.stage.failed .pip { background: oklch(0.78 0.16 25); }
@keyframes stage-pulse {
  0%, 100% { box-shadow: 0 0 0 0 var(--accent-soft); }
  50% { box-shadow: 0 0 0 6px transparent; }
}

.run-counters .ctr {
  display: inline-flex; align-items: baseline; gap: 5px;
  color: var(--text-muted);
}
.run-counters .ctr strong {
  color: var(--text); font-weight: 600;
  font-variant-numeric: tabular-nums;
}

[hidden] { display: none !important; }

.error-banner {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 16px;
  background: var(--danger-soft);
  border: 1px solid oklch(0.55 0.15 25 / 0.4);
  border-radius: 10px;
  color: oklch(0.88 0.1 25);
  font-size: 13px;
  margin-bottom: 20px;
}
.error-banner .x { margin-left: auto; opacity: 0.6; cursor: pointer; background: none; border: none; color: inherit; }
.error-banner .x:hover { opacity: 1; }

/* ---------- Run history table ---------- */
.runlist { display: flex; flex-direction: column; }
.runrow {
  display: grid;
  grid-template-columns: 180px 1fr 1fr 1fr 90px;
  gap: 16px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--border);
  align-items: center;
  font-size: 13px;
  cursor: pointer;
  transition: background 120ms;
}
.runrow:last-child { border-bottom: none; }
.runrow:hover { background: var(--surface-2); }
.runrow.head {
  background: var(--surface-2);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: default;
  padding: 10px 22px;
}
.runrow.head:hover { background: var(--surface-2); }
.runrow .ts { color: var(--text-dim); font-variant-numeric: tabular-nums; font-family: var(--font-mono); font-size: 12.5px; }
.runrow .count { font-variant-numeric: tabular-nums; }
.runrow .arrow { color: var(--text-muted); justify-self: end; }

/* ---------- Applications ---------- */
.app-toolbar {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 16px;
}
.pager {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 4px;
}
.pager-btn {
  width: 30px; height: 28px;
  border-radius: 6px;
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  display: grid; place-items: center;
}
.pager-btn:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.pager-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.pager-pos {
  font-size: 12.5px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  padding: 0 8px;
  font-family: var(--font-mono);
}
.app-progress {
  flex: 1;
  height: 4px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
}
.app-progress > div {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 240ms ease;
}

/* split layout */
.app-split { display: grid; grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr); gap: 16px; align-items: start; }
.app-stack { display: grid; grid-template-rows: auto 1fr; gap: 16px; }

/* listing card */
.listing {
  padding: 22px 24px;
  display: flex; flex-direction: column; gap: 14px;
}
.listing .top { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; }
.listing-title { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.3; }
.listing-meta { color: var(--text-dim); font-size: 13px; display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 4px; }
.listing-meta .sep { color: var(--text-muted); }
.listing-section { display: flex; flex-direction: column; gap: 6px; }
.listing-section h4 { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); margin: 0; font-weight: 600; }
.listing-desc { color: var(--text-dim); font-size: 13px; line-height: 1.65; }
.listing-tags { display: flex; flex-wrap: wrap; gap: 6px; }

/* editor */
.editor-wrap { display: flex; flex-direction: column; }
.editor-tabs {
  display: flex; gap: 2px;
  padding: 8px 8px 0;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.editor-tab {
  padding: 8px 14px;
  font-size: 12.5px;
  font-weight: 500;
  background: none;
  border: none;
  color: var(--text-muted);
  border-radius: 7px 7px 0 0;
  cursor: pointer;
  position: relative;
  bottom: -1px;
}
.editor-tab.active { color: var(--text); border-bottom: 2px solid var(--accent); }
.editor-tab:hover:not(.active) { color: var(--text-dim); }
.editor-actions {
  margin-left: auto; display: flex; gap: 6px; padding: 6px 10px 6px 0;
  align-self: center;
}
.editor-body { padding: 0; }
.editor-textarea {
  width: 100%;
  min-height: 460px;
  border: none;
  background: transparent;
  padding: 24px 28px;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
  outline: none;
  resize: vertical;
  font-family: var(--font-sans);
}
.editor-textarea.korean { font-family: "Noto Sans KR", var(--font-sans); }
.editor-footer {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  font-size: 12px;
  color: var(--text-muted);
}

.action-bar {
  display: flex; gap: 8px; align-items: center;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-top: 16px;
}
.action-bar .spacer { flex: 1; }

/* placeholder svg */
.ph-image {
  background-color: var(--surface-2);
  background-image: repeating-linear-gradient(135deg, transparent 0 8px, rgba(255,255,255,0.025) 8px 9px);
  border: 1px dashed var(--border-strong);
  border-radius: 8px;
  display: grid; place-items: center;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 11px;
}

/* ---------- Settings ---------- */
.settings-grid { display: grid; grid-template-columns: 220px 1fr; gap: 32px; align-items: start; }
.settings-nav { display: flex; flex-direction: column; gap: 2px; position: sticky; top: 80px; }
.settings-nav button {
  text-align: left;
  padding: 8px 12px;
  border-radius: 7px;
  border: none;
  background: none;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}
.settings-nav button:hover { color: var(--text); background: var(--surface-2); }
.settings-nav button.active { background: var(--surface-2); color: var(--text); }
.settings-section + .settings-section { margin-top: 18px; }
.settings-row {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 24px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  align-items: center;
}
.settings-row:last-child { border-bottom: none; }
.settings-row .label { font-weight: 500; font-size: 13.5px; }
.settings-row .desc { color: var(--text-muted); font-size: 12.5px; margin-top: 4px; line-height: 1.5; }
.settings-row .control { justify-self: stretch; }

/* search criteria list */
.crit-row {
  padding: 14px 18px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  display: flex; align-items: center; gap: 14px;
}
.crit-row + .crit-row { margin-top: 8px; }
.crit-row .name { font-weight: 500; font-size: 13.5px; }
.crit-row .meta { color: var(--text-muted); font-size: 12px; margin-top: 2px; font-family: var(--font-mono); }
.crit-row .actions { margin-left: auto; display: flex; gap: 6px; }

/* dialog */
.dialog-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(8, 11, 18, 0.6);
  backdrop-filter: blur(4px);
  display: grid; place-items: center;
  padding: 24px;
}
.dialog {
  width: 100%; max-width: 460px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: 0 20px 50px -12px rgba(0,0,0,0.6);
}
.dialog h3 { margin: 0 0 8px; font-size: 16px; font-weight: 600; }
.dialog p { margin: 0 0 16px; color: var(--text-dim); font-size: 13px; line-height: 1.6; }
.dialog ul { margin: 0 0 16px; padding-left: 20px; color: var(--text-dim); font-size: 13px; }
.dialog ul li { margin-bottom: 4px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

/* billing */
.balance-card {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 20px;
  padding: 18px 20px;
  background: linear-gradient(135deg, var(--accent-soft), transparent 70%);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius);
}
.balance-num { display: flex; align-items: baseline; gap: 8px; }
.balance-num .num { font-size: 36px; font-weight: 600; letter-spacing: -0.02em; color: var(--text); font-variant-numeric: tabular-nums; }
.balance-num .unit { font-size: 14px; color: var(--text-dim); }

.billing-mode-group { display: flex; flex-direction: column; gap: 8px; }
.billing-mode {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-2);
  cursor: pointer;
  transition: border-color 120ms, background 120ms;
}
.billing-mode:hover { border-color: var(--border-strong); }
.billing-mode.active { border-color: var(--accent-border); background: var(--accent-soft); }
.billing-mode input { margin-top: 3px; accent-color: var(--accent); }
.billing-mode .bm-title { font-size: 13.5px; font-weight: 500; color: var(--text); }
.billing-mode .bm-desc { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.pkg-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.pkg {
  position: relative;
  padding: 18px 18px 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex; flex-direction: column; gap: 6px;
}
.pkg .btn { margin-top: auto; }
.pkg.popular { border-color: var(--accent-border); background: linear-gradient(180deg, var(--accent-soft), var(--surface-2) 60%); }
.pkg-ribbon {
  position: absolute; top: -9px; right: 14px;
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
  background: var(--accent); color: #0b0f17;
  padding: 3px 8px; border-radius: 4px;
}
.pkg-name { font-size: 12px; font-weight: 600; color: var(--text-muted); letter-spacing: 0.06em; text-transform: uppercase; }
.pkg-tokens { font-size: 24px; font-weight: 600; letter-spacing: -0.015em; color: var(--text); font-variant-numeric: tabular-nums; }
.pkg-tokens span { font-size: 13px; color: var(--text-muted); font-weight: 400; margin-left: 4px; letter-spacing: 0; }
.pkg-price { font-size: 18px; font-weight: 600; color: var(--text); margin-top: 2px; }
.pkg-price span { font-size: 12px; font-weight: 400; }
.pkg-rate { font-size: 11.5px; margin-bottom: 10px; min-height: 16px; }

/* Token activity */
.activity-table {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface-2);
}
.activity-row {
  display: grid;
  grid-template-columns: 150px 1fr 90px 100px;
  gap: 16px;
  padding: 12px 16px;
  align-items: center;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.activity-row:last-of-type { border-bottom: none; }
.activity-row.head {
  background: var(--surface);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 9px 16px;
}
.activity-row .ts { color: var(--text-dim); font-family: var(--font-mono); font-size: 12px; font-variant-numeric: tabular-nums; }
.activity-row .a-desc { color: var(--text); font-weight: 500; font-size: 13px; }
.activity-row .a-meta { color: var(--text-muted); font-size: 11.5px; margin-top: 2px; }
.activity-row .right { text-align: right; }
.activity-row .delta { font-family: var(--font-mono); font-size: 13px; font-weight: 500; font-variant-numeric: tabular-nums; }
.activity-row .delta.pos { color: oklch(0.82 0.14 155); }
.activity-row .delta.neg { color: var(--text-dim); }
.activity-row .bal { font-family: var(--font-mono); font-size: 13px; color: var(--text); font-variant-numeric: tabular-nums; }
.activity-footer {
  padding: 12px 16px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex; justify-content: center; align-items: center;
  font-size: 12px;
}

.activity-empty {
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 36px 24px;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  text-align: center;
  background: var(--surface-2);
}
.activity-empty-icon {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-text);
  display: grid; place-items: center;
  margin-bottom: 4px;
}
.activity-empty-title { font-size: 14px; font-weight: 600; color: var(--text); }
.activity-empty-desc { font-size: 12.5px; color: var(--text-muted); max-width: 380px; line-height: 1.55; margin-bottom: 10px; }

/* Run estimate */
.run-estimate {
  display: inline-flex; flex-direction: column; gap: 4px;
  padding: 10px 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: left;
  min-width: 280px;
}
.run-estimate.insufficient {
  border-color: oklch(0.6 0.13 80 / 0.5);
  background: linear-gradient(180deg, oklch(0.6 0.13 80 / 0.08), var(--surface-2) 70%);
}
.run-estimate-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.run-estimate .est-value {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 14px; color: var(--text);
  font-variant-numeric: tabular-nums;
}
.run-estimate .est-value .icon { color: var(--accent-text); }
.run-estimate.insufficient .est-value strong { color: oklch(0.85 0.13 80); }

/* Toasts */
.toast-stack {
  position: fixed; bottom: 20px; right: 20px;
  z-index: 200;
  display: flex; flex-direction: column; gap: 10px;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 12px 28px -10px rgba(0,0,0,0.6), 0 1px 0 rgba(255,255,255,0.04) inset;
  min-width: 320px; max-width: 420px;
  animation: toast-in 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.toast-icon {
  width: 26px; height: 26px;
  border-radius: 7px;
  display: grid; place-items: center;
  flex: 0 0 26px;
  margin-top: 1px;
}
.toast-body { flex: 1; min-width: 0; }
.toast-title { font-size: 13.5px; font-weight: 600; color: var(--text); }
.toast-message { font-size: 12.5px; color: var(--text-dim); margin-top: 3px; line-height: 1.5; }
.toast-close {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted);
  padding: 4px; margin: -4px -4px -4px 0;
  border-radius: 4px;
}
.toast-close:hover { background: var(--surface-2); color: var(--text); }
.toast-success {
  border-color: oklch(0.55 0.14 155 / 0.5);
  background: linear-gradient(180deg, oklch(0.55 0.14 155 / 0.08), var(--surface) 60%);
}
.toast-success .toast-icon { background: oklch(0.55 0.14 155 / 0.18); color: oklch(0.84 0.14 155); }
.toast-info .toast-icon { background: var(--surface-2); color: var(--text-dim); }
.toast-danger {
  border-color: oklch(0.55 0.15 25 / 0.5);
  background: linear-gradient(180deg, oklch(0.55 0.15 25 / 0.08), var(--surface) 60%);
}
.toast-danger .toast-icon { background: oklch(0.55 0.15 25 / 0.18); color: oklch(0.85 0.15 25); }

/* applied stamp */
.applied-stamp {
  position: absolute; top: 16px; right: 16px;
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.08em;
  color: oklch(0.78 0.14 155);
  border: 1.5px solid oklch(0.78 0.14 155 / 0.5);
  padding: 4px 8px;
  border-radius: 4px;
  text-transform: uppercase;
  transform: rotate(-3deg);
  background: oklch(0.78 0.14 155 / 0.08);
}

/* utility */
.flex { display: flex; }
.between { justify-content: space-between; }
.center { align-items: center; }
.gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; } .mb-16 { margin-bottom: 16px; } .mb-24 { margin-bottom: 24px; }

/* tabs (applications variant) */
.tabbed-tabs {
  display: flex; gap: 2px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 8px 8px 0;
}
.tabbed-tabs .editor-tab { font-size: 13px; padding: 9px 16px; }

/* hide scrollbar styling */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 999px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }
