:root {
  /* Modern dark UI tokens */
  color-scheme: dark;
  --bg: #050507;
  --panel: rgba(10, 10, 12, .88);
  --panel-2: rgba(7, 7, 10, .92);
  --surface-section: rgba(16, 16, 21, .60);
  --surface-section-2: rgba(20, 20, 26, .78);
  --surface-card: rgba(18, 18, 23, .90);
  --surface-card-2: rgba(24, 24, 30, .94);
  --surface-inset: rgba(255, 255, 255, .035);
  --surface-chip: rgba(255, 255, 255, .07);
  --border: rgba(255, 255, 255, .08);
  --border-2: rgba(255, 255, 255, .14);
  --text: #f3f4f6;
  --muted: rgba(255, 255, 255, .64);
  --accent: #d6b26a;
  --accent-2: #f1d18a;
  --accent-rgb: 214, 178, 106;
  --chart-muted: rgba(255, 255, 255, .09);
  --link: var(--accent);
  --ok: #4fa38a;
  --warn: #c3a25a;
  --err: #c06b7f;
  --notice: var(--accent-2);

  --radius-lg: 18px;
  --radius-md: 14px;
  --radius-sm: 12px;

  --shadow-sm: 0 1px 0 rgba(255,255,255,.04), 0 12px 34px rgba(0,0,0,.45);
  --shadow-lg: 0 1px 0 rgba(255,255,255,.04), 0 26px 78px rgba(0,0,0,.70);
  --ring: 0 0 0 4px rgba(var(--accent-rgb), .18);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background:
    radial-gradient(900px 700px at 18% 10%, rgba(var(--accent-rgb), .10), transparent 60%),
    radial-gradient(900px 700px at 85% 0%, rgba(255, 255, 255, .045), transparent 55%),
    var(--bg);
  color: var(--text);
  margin: 0;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; }
.num { text-align: right; }

.content-inner { width: 100%; max-width: 1180px; margin: 0 auto; }

.container { max-width: 980px; margin: 0 auto; padding: 24px; }
.header { margin-bottom: 16px; }

.app { display: flex; min-height: 100vh; }

/* Auth */
.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 48px 18px;
}
.auth-card { width: min(520px, 100%); }
.auth-card .page-header { margin-bottom: 14px; }
.auth-card .page-header h1 { margin: 0; font-size: 24px; letter-spacing: .01em; }
.auth-card .page-header p { margin: 6px 0 0; }
.row-actions { display:flex; gap: 10px; align-items: center; margin-top: 14px; }

.sidebar {
  width: 280px;
  padding: 18px 14px;
  border-right: 1px solid var(--border);
  background:
    radial-gradient(900px 700px at 20% -10%, rgba(var(--accent-rgb), .10), transparent 55%),
    linear-gradient(180deg, rgba(5, 5, 7, .92), rgba(5, 5, 7, .84));
  backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.brand { margin-bottom: 16px; }
.brand-link { display: inline-block; font-weight: 900; color: var(--text); font-size: 18px; letter-spacing: .01em; }
.brand-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow: auto; padding-bottom: 10px; }
.nav-section { margin: 12px 8px 6px; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.nav-item {
  padding: 10px 10px;
  border-radius: var(--radius-sm);
  color: var(--text);
  border: 1px solid transparent;
  transition: background .15s ease, border-color .15s ease, transform .15s ease;
}
.nav-item:hover { background: rgba(255,255,255,.04); text-decoration: none; }
.nav-item:active { transform: translateY(1px); }
.nav-item.active { background: rgba(var(--accent-rgb), .10); border-color: rgba(var(--accent-rgb), .22); }

.main { flex: 1; min-width: 0; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: rgba(5, 5, 7, .66);
  backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 10;
}
.crumbs { display: flex; align-items: center; gap: 10px; }
.crumb-sep { color: var(--muted); }
.crumb-current { color: var(--text); font-weight: 600; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

.content { padding: 22px 22px 28px; }

.page-header { margin-bottom: 12px; }
.page-header h1 { margin: 0 0 4px; font-size: 24px; letter-spacing: .01em; }
.page-header p { margin: 0; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
}
.card h2 { margin: 0 0 10px; font-size: 16px; }
.card-title-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; }

.card .card {
  background: var(--panel-2);
  border-color: var(--border-2);
  box-shadow: none;
}

.alert {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-2);
  background: rgba(255, 255, 255, .03);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.04);
  margin-bottom: 12px;
}
.alert p { margin: 0; }
.alert .badge { margin: 0; }
.alert.error { border-color: rgba(192, 107, 127, .35); background: rgba(192, 107, 127, .10); }
.alert.ok { border-color: rgba(79, 163, 138, .30); background: rgba(79, 163, 138, .10); }
.alert.notice { border-color: rgba(var(--accent-rgb), .30); background: rgba(var(--accent-rgb), .08); }

.table-wrap { overflow: auto; border-radius: var(--radius-md); border: 1px solid var(--border); box-shadow: inset 0 1px 0 rgba(255,255,255,.04); }
.table {
  width: 100%;
  border-collapse: collapse;
  min-width: 860px;
}
.table.compact { min-width: 720px; }
.table th, .table td { padding: 12px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table thead th {
  text-align: left;
  font-size: 12px;
  color: var(--muted);
  font-weight: 800;
  letter-spacing: .02em;
  background: rgba(255,255,255,.03);
  position: sticky;
  top: 0;
  z-index: 1;
}
.table tbody tr:nth-child(odd) td { background: rgba(255,255,255,.012); }
.table tr:hover td { background: rgba(255,255,255,.03); }
.table td.actions { white-space: nowrap; }
.table tr.highlight td { background: rgba(var(--accent-rgb), .07); }
.table tr.highlight:hover td { background: rgba(var(--accent-rgb), .10); }
.table .checkbox { margin: 0; }

.project-title a { color: var(--text); font-weight: 600; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-2);
  background: rgba(255,255,255,.035);
  color: var(--text);
  cursor: pointer;
  font-weight: 800;
  transition: transform .15s ease, background .15s ease, border-color .15s ease, filter .15s ease;
}
.btn:hover { background: rgba(255,255,255,.055); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: linear-gradient(180deg, rgba(var(--accent-rgb), .40), rgba(var(--accent-rgb), .18));
  border-color: rgba(var(--accent-rgb), .30);
  box-shadow: 0 14px 40px rgba(var(--accent-rgb), .10);
}
.btn.primary:hover { filter: brightness(1.06) saturate(1.08); }
.btn.danger { background: rgba(192, 107, 127, .12); border-color: rgba(192, 107, 127, .35); }
.btn.danger:hover { background: rgba(192, 107, 127, .18); }

button.btn { appearance: none; }
form.inline { display: inline; }

input, select {
  width: 100%;
  padding: 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-2);
  background: var(--panel-2);
  color: var(--text);
}
input::placeholder { color: rgba(255, 255, 255, .40); }
input:focus, select:focus { outline: none; box-shadow: var(--ring); border-color: rgba(var(--accent-rgb), .30); }
.btn:focus-visible, .icon-btn:focus-visible { outline: none; box-shadow: var(--ring); }

input[type="checkbox"], input[type="radio"] {
  width: auto;
  padding: 0;
  accent-color: var(--accent);
}

label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); }

.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.filters .grow { flex: 1; min-width: 220px; }

.row { margin-top: 12px; }
.radios { display: flex; gap: 14px; flex-wrap: wrap; margin: 8px 0; }
.radio, .checkbox { display: flex; gap: 8px; align-items: center; margin: 6px 0; color: var(--text); font-size: 14px; }
.radio input, .checkbox input { width: auto; }
.checkbox.sub { margin-left: 18px; font-size: 13px; color: var(--muted); }
.checkbox.sub input:not([disabled]) { opacity: 0.9; }

.modules-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 10px; }
.module-card { border: 1px solid var(--border-2); background: var(--panel-2); border-radius: 12px; padding: 12px; }
.module-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.module-title { display: flex; flex-direction: column; gap: 4px; }
.module-name { font-size: 14px; font-weight: 800; color: var(--text); }
.module-body { margin-top: 10px; }
.module-divider { height: 1px; background: var(--border-2); margin: 10px 0; }

@media (max-width: 900px) {
  .modules-grid { grid-template-columns: 1fr; }
}

pre {
  white-space: pre-wrap;
  word-wrap: break-word;
  background: var(--panel-2);
  border: 1px solid var(--border-2);
  padding: 12px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
}

.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; margin-left: 8px; border: 1px solid var(--border-2); }
.pill.queued { background: rgba(195, 162, 90, .12); border-color: rgba(195, 162, 90, .22); }
.pill.running { background: rgba(var(--accent-rgb), .12); border-color: rgba(var(--accent-rgb), .22); }
.pill.cancel_requested { background: rgba(251, 191, 36, .10); border-color: rgba(251, 191, 36, .22); }
.pill.done { background: rgba(79, 163, 138, .12); border-color: rgba(79, 163, 138, .22); }
.pill.failed { background: rgba(192, 107, 127, .12); border-color: rgba(192, 107, 127, .22); }
.pill.canceled { background: rgba(255,255,255,.05); border-color: rgba(255,255,255,.14); color: rgba(255,255,255,.72); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border-2);
  font-size: 12px;
  font-weight: 700;
  text-transform: none;
  background: var(--surface-chip);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.04);
}
.badge.sm { padding: 2px 8px; font-size: 11px; font-weight: 700; }
.badge.ok { background: rgba(79, 163, 138, .24); border-color: rgba(79, 163, 138, .40); color: #edf8f4; }
.badge.warning { background: rgba(195, 162, 90, .24); border-color: rgba(195, 162, 90, .40); color: #fbf4df; }
.badge.notice { background: rgba(var(--accent-rgb), .24); border-color: rgba(var(--accent-rgb), .40); color: #fff5dd; }
.badge.error { background: rgba(192, 107, 127, .24); border-color: rgba(192, 107, 127, .36); color: #fff0f4; }
.badge.error, .badge.warning, .badge.notice { text-transform: lowercase; }
.badge.error { }
.badge.warning { }
.badge.notice { }

.delta { font-weight: 800; }
.delta.up { color: var(--err); }
.delta.down { color: var(--ok); }

.health-inline { display: flex; align-items: center; gap: 10px; }
.mini-bar { width: 70px; height: 8px; border-radius: 999px; background: rgba(255,255,255,.07); overflow: hidden; border: 1px solid var(--border); --hc: var(--notice); }
.mini-bar.ok { --hc: var(--ok); }
.mini-bar.warning { --hc: var(--warn); }
.mini-bar.error { --hc: var(--err); }
.mini-bar::after { content: ""; display: block; height: 100%; width: calc(var(--p) * 1%); background: var(--hc); opacity: .8; }
@supports (background: color-mix(in srgb, white, black)) {
  .mini-bar::after {
    opacity: 1;
    background: linear-gradient(
      90deg,
      color-mix(in srgb, var(--hc) 35%, transparent),
      color-mix(in srgb, var(--hc) 80%, transparent)
    );
  }
}

.issues-inline { display: flex; align-items: center; gap: 8px; }
.dot { width: 10px; height: 10px; border-radius: 999px; display: inline-block; }
.dot.error { background: var(--err); }
.dot.warning { background: var(--warn); }
.dot.notice { background: var(--notice); }

.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }

/* Assistant (premium) */
.assistant-dock {
  position: fixed;
  left: 18px;
  bottom: 18px;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  max-width: calc(100vw - 36px);
}

.assistant-launcher {
  appearance: none;
  border: 1px solid var(--border-2);
  background: rgba(10, 10, 12, .88);
  color: var(--text);
  border-radius: 999px;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(14px);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
}
.assistant-launcher:hover { background: rgba(10, 10, 12, .94); }
.assistant-launcher:active { transform: translateY(1px); }

.assistant-launcher-icon,
.assistant-head-icon {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  border: 1px solid rgba(var(--accent-rgb), .28);
  background:
    radial-gradient(120% 120% at 30% 25%, rgba(var(--accent-rgb), .25), rgba(var(--accent-rgb), 0) 55%),
    linear-gradient(180deg, rgba(255,255,255,.06), rgba(0,0,0,.10));
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}
.assistant-icon-img { width: 26px; height: 26px; display: block; }

.assistant-launcher-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  line-height: 1.15;
}
.assistant-launcher-title { font-weight: 800; font-size: 13px; }
.assistant-launcher-sub { font-size: 12px; color: var(--muted); }

.assistant-fab-dot {
  margin-left: 6px;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: rgba(255,255,255,.12);
  border: 1px solid var(--border);
  flex: 0 0 auto;
}
.assistant-fab-dot.ok { background: rgba(79, 163, 138, .65); border-color: rgba(79, 163, 138, .35); }
.assistant-fab-dot.err { background: rgba(192, 107, 127, .6); border-color: rgba(192, 107, 127, .35); }

.assistant-panel {
  position: absolute;
  left: 0;
  bottom: calc(100% + 12px);
  width: 390px;
  max-width: calc(100vw - 36px);
  max-height: min(75vh, 560px);
  background: rgba(10, 10, 12, .94);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  backdrop-filter: blur(16px);
  opacity: 0;
  transform: translateY(10px) scale(.98);
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}
.assistant-dock.assistant-open .assistant-panel {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

.assistant-head {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 12px;
  border-bottom: 1px solid var(--border);
  background: rgba(0,0,0,.14);
}
.assistant-head-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.assistant-head-text { min-width: 0; }
.assistant-title { font-weight: 900; font-size: 14px; letter-spacing: .01em; }
.assistant-meta { color: var(--muted); font-size: 12px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.assistant-head-actions { display: inline-flex; align-items: center; gap: 8px; }

.assistant-clear,
.assistant-close {
  appearance: none;
  border: 1px solid var(--border-2);
  background: rgba(255,255,255,.03);
  color: var(--text);
  border-radius: 12px;
  width: 36px;
  height: 36px;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.assistant-clear:hover,
.assistant-close:hover { background: rgba(255,255,255,.06); }
.assistant-clear:active,
.assistant-close:active { transform: translateY(1px); }
.assistant-clear svg { width: 18px; height: 18px; opacity: .9; }
.assistant-close svg { width: 18px; height: 18px; }

.assistant-hero {
  position: absolute;
  left: -24px;
  bottom: -30px;
  width: 180px;
  opacity: .14;
  pointer-events: none;
  filter: saturate(1.05) contrast(1.05);
}
.assistant-hero-img { width: 100%; height: auto; display: block; }

.assistant-messages {
  position: relative;
  z-index: 1;
  padding: 14px 14px 10px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1 1 auto;
}
.assistant-msg { display: flex; flex-direction: column; gap: 6px; max-width: 100%; }
.assistant-msg.user { align-items: flex-end; }
.assistant-msg.assistant { align-items: flex-start; }
.assistant-msg .assistant-role { display: none; }
.assistant-msg .assistant-bubble {
  white-space: pre-wrap;
  word-break: break-word;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.04);
  color: var(--text);
  font-size: 13px;
  line-height: 1.4;
  max-width: 84%;
}
.assistant-msg.user .assistant-bubble {
  background: linear-gradient(180deg, rgba(var(--accent-rgb), .20), rgba(var(--accent-rgb), .10));
  border-color: rgba(var(--accent-rgb), .32);
}
.assistant-msg.error .assistant-bubble {
  background: linear-gradient(180deg, rgba(192,107,127,.18), rgba(192,107,127,.10));
  border-color: rgba(192,107,127,.35);
}

.assistant-form {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 10px;
  padding: 12px 12px 14px;
  border-top: 1px solid var(--border);
  background: rgba(0,0,0,.14);
}
.assistant-input { flex: 1; border-radius: 14px; height: 44px; padding: 0 12px; }
.assistant-send {
  flex: 0 0 auto;
  appearance: none;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  border: 1px solid rgba(var(--accent-rgb), .34);
  background: linear-gradient(180deg, rgba(var(--accent-rgb), .46), rgba(var(--accent-rgb), .20));
  color: var(--text);
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
}
.assistant-send svg { width: 18px; height: 18px; }
.assistant-send:hover { filter: brightness(1.06); }
.assistant-send:disabled { opacity: .55; cursor: not-allowed; }
.assistant-foot { position: relative; z-index: 1; padding: 0 12px 12px; }

@media (prefers-reduced-motion: reduce) {
  .assistant-panel { transition: none; }
}

@media (max-width: 740px) {
  .assistant-dock { left: 10px; right: 10px; bottom: 10px; max-width: none; }
  .assistant-launcher { width: 100%; justify-content: space-between; }
  .assistant-panel { width: auto; left: 0; right: 0; }
  .assistant-launcher-sub { display: none; }
  .assistant-hero { display: none; }
}
.span-all { grid-column: 1 / -1; }

.card-title-actions { display: inline-flex; align-items: center; gap: 10px; }
.pill-select { display: inline-flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 999px; border: 1px solid var(--border-2); background: rgba(255,255,255,.03); }
.pill-select label { font-size: 12px; color: var(--muted); margin: 0; }
.pill-select select { height: 30px; padding: 0 10px; border-radius: 999px; }
.kpi-list { display: grid; gap: 8px; margin-top: 10px; }
.kpi-row { display: grid; grid-template-columns: 120px 1fr auto; gap: 10px; align-items: center; }
.kpi-label { color: var(--muted); font-size: 12px; }
.kpi-bar { height: 10px; border-radius: 999px; background: rgba(255,255,255,.06); overflow: hidden; border: 1px solid var(--border-2); }
.kpi-bar > div { height: 100%; width: calc(var(--p) * 1%); background: linear-gradient(90deg, rgba(var(--accent-rgb), .22), rgba(var(--accent-rgb), .55)); }
.kpi-bar.ok > div { background: linear-gradient(90deg, rgba(79, 163, 138, .25), rgba(79, 163, 138, .65)); }
.kpi-bar.warn > div { background: linear-gradient(90deg, rgba(195, 162, 90, .25), rgba(195, 162, 90, .65)); }
.search-source-summary { margin-top: 4px; }
.ts-widget { margin-top: 14px; }
.ts-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0;
  border: 1px solid var(--border);
  border-bottom: 0;
  border-radius: 20px 20px 0 0;
  overflow: hidden;
  background: rgba(255,255,255,.02);
}
.ts-metric {
  --ts-color: 214, 178, 106;
  appearance: none;
  border: 0;
  border-right: 1px solid var(--border);
  background: rgba(255,255,255,.02);
  color: var(--text);
  min-height: 116px;
  padding: 18px 18px 16px;
  display: grid;
  grid-template-columns: 22px 1fr;
  grid-template-areas:
    "check label"
    "value value";
  gap: 10px 10px;
  text-align: left;
  cursor: pointer;
  transition: background .15s ease, box-shadow .15s ease, transform .15s ease;
}
.ts-metric:last-child { border-right: 0; }
.ts-metric:hover { background: rgba(255,255,255,.04); }
.ts-metric:active { transform: translateY(1px); }
.ts-metric-check {
  grid-area: check;
  width: 20px;
  height: 20px;
  border-radius: 4px;
  border: 1px solid rgba(255,255,255,.18);
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 900;
  color: transparent;
  background: rgba(255,255,255,.03);
}
.ts-metric-label {
  grid-area: label;
  align-self: center;
  color: rgba(255,255,255,.86);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .01em;
}
.ts-metric-value {
  grid-area: value;
  display: block;
  font-size: 38px;
  line-height: 1;
  font-weight: 300;
  letter-spacing: -.03em;
  color: rgba(255,255,255,.94);
}
.ts-metric[data-metric="clicks"] { --ts-color: 111, 143, 242; }
.ts-metric[data-metric="impressions"] { --ts-color: 115, 82, 217; }
.ts-metric[data-metric="ctr"] { --ts-color: 95, 169, 154; }
.ts-metric[data-metric="position"] { --ts-color: 184, 148, 84; }
.ts-metric.active {
  background: linear-gradient(180deg, rgba(var(--ts-color), .34), rgba(var(--ts-color), .22));
  box-shadow: inset 0 -1px 0 rgba(255,255,255,.05);
}
.ts-metric.active .ts-metric-check {
  color: rgba(255,255,255,.95);
  background: rgba(255,255,255,.14);
  border-color: rgba(255,255,255,.22);
}
.ts-chart {
  height: 250px;
  border-radius: 0 0 20px 20px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.02);
  overflow: hidden;
  position: relative;
}
.ts-canvas { width: 100%; height: 100%; display: block; }
.ts-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}
.ts-empty[hidden] { display: none; }
.ts-meta { margin-top: 8px; }
.search-mini {
  margin-top: 14px;
  padding: 12px;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,.06);
  background: rgba(255,255,255,.012);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.04);
}
.search-mini-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.search-mini .tab-buttons { margin: 0; gap: 6px; }
.search-mini .tab-btn { padding: 7px 10px; border-radius: 999px; }
.search-mini .table { min-width: 620px; }
.search-mini-meta { margin-top: 8px; }
.issue-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chip { display: inline-flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 999px; border: 1px solid var(--border-2); background: rgba(255,255,255,.03); color: var(--text); text-decoration: none; font-size: 13px; }
.chip:hover { background: rgba(255,255,255,.06); }
.chip .dot { width: 8px; height: 8px; }

@media (max-width: 900px) {
  .ts-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .ts-metrics { grid-template-columns: 1fr; border-radius: 16px 16px 0 0; }
  .ts-metric { min-height: 96px; border-right: 0; border-bottom: 1px solid var(--border); }
  .ts-metric:last-child { border-bottom: 0; }
  .ts-chart { height: 220px; }
}

.settings-section { margin-top: 16px; }
.settings-section-head { margin: 18px 0 10px; }
.settings-section-title { font-size: 11px; color: rgba(241, 209, 138, .92); text-transform: uppercase; letter-spacing: .08em; }

.setting-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.setting-actions { display: inline-flex; align-items: center; gap: 8px; }
.setting-title { margin: 0; font-size: 16px; color: #f2ead8; letter-spacing: .01em; }
.setting-kv { margin-top: 10px; }
.setting-note { margin: 10px 0 0; }
.oauth-project-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}
.oauth-project-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: rgba(255,255,255,.02);
}
.oauth-project-title {
  font-weight: 800;
  font-size: 15px;
  color: #f5efe1;
}
.setting-card h3 { color: rgba(241, 209, 138, .94); letter-spacing: .01em; }
.oauth-project-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.oauth-checklist {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}
.oauth-check-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255,255,255,.02);
}

.icon-btn {
  appearance: none;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  border: 1px solid var(--border-2);
  background: rgba(255,255,255,.03);
  color: var(--muted);
  cursor: pointer;
  display: grid;
  place-items: center;
  font-weight: 900;
  line-height: 1;
  transition: background .15s ease, color .15s ease, transform .15s ease, border-color .15s ease;
}
.icon-btn:hover { background: rgba(255,255,255,.06); color: var(--text); }
.icon-btn:active { transform: translateY(1px); }

.help-steps, .help-links { margin: 0; padding-left: 18px; }
.help-steps li, .help-links li { margin: 0 0 6px; }
.help-steps li:last-child, .help-links li:last-child { margin-bottom: 0; }

.setting-details { margin-top: 12px; }
.setting-details summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
  padding: 8px 10px;
  border: 1px solid var(--border-2);
  border-radius: 999px;
  background: rgba(255,255,255,.025);
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  font-weight: 800;
  font-size: 13px;
}
.setting-details summary::-webkit-details-marker { display: none; }
.setting-details summary::after { content: "▾"; color: var(--muted); }
.setting-details[open] summary { background: rgba(var(--accent-rgb), .10); border-color: rgba(var(--accent-rgb), .26); }
.setting-details[open] summary::after { content: "▴"; }

.setting-form { margin-top: 12px; }

.modal-actions.between { justify-content: space-between; }

@media (max-width: 820px) {
  .oauth-project-item {
    align-items: flex-start;
    flex-direction: column;
  }
  .oauth-project-actions {
    width: 100%;
    justify-content: flex-start;
  }
}

.chart-row { display: flex; gap: 16px; align-items: center; }
.legend { display: flex; flex-direction: column; gap: 8px; }
.legend-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.legend-swatch { width: 10px; height: 10px; border-radius: 2px; background: var(--sw); display: inline-block; margin-right: 8px; }

.donut {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: conic-gradient(var(--c1) calc(var(--p) * 1%), var(--c2) 0);
  position: relative;
  flex: 0 0 auto;
  border: 1px solid var(--border);
}
.donut::before {
  content: "";
  position: absolute;
  inset: 18px;
  border-radius: 50%;
  background: var(--panel);
  border: 1px solid var(--border);
}
.donut-center { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 10px; }
.donut-value { font-size: 22px; font-weight: 800; }

.gauge {
  --p: 50;
  --c1: var(--ok);
  --c2: var(--chart-muted);
  width: 100%;
  max-width: 280px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: conic-gradient(var(--c1) calc(var(--p) * 1%), var(--c2) 0);
  position: relative;
  margin: 10px 0 8px;
  border: 1px solid var(--border);
}
.gauge::before {
  content: "";
  position: absolute;
  inset: 22px;
  border-radius: 50%;
  background: var(--panel);
  border: 1px solid var(--border);
}
.gauge-inner { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; }
.gauge-value { font-size: 44px; font-weight: 900; line-height: 1; }

.bars { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 70px 1fr 50px; align-items: center; gap: 10px; }
.bar-label { color: var(--muted); font-size: 12px; }
.bar { height: 10px; border-radius: 999px; background: rgba(255,255,255,.07); overflow: hidden; border: 1px solid var(--border); }
.bar-fill { height: 100%; width: min(100%, calc(var(--p) * 1%)); border-radius: 999px; }
.bar-fill.error { background: var(--err); }
.bar-fill.warning { background: var(--warn); }
.bar-fill.notice { background: var(--notice); }

.progress-row { display: flex; align-items: baseline; gap: 8px; margin-top: 10px; }
.progress { height: 10px; border-radius: 999px; background: rgba(255,255,255,.07); overflow: hidden; border: 1px solid var(--border); margin-top: 8px; }
.progress-fill {
  height: 100%;
  width: calc(var(--p) * 1%);
  max-width: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(var(--accent-rgb), .18), rgba(var(--accent-rgb), .46));
  transition: width .65s ease;
  will-change: width;
}
.progress.slim { height: 6px; margin-top: 0; }

.crawl-meter { margin-top: 10px; }
.crawl-meter-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.crawl-meter-title { font-weight: 900; }
.crawl-meter-count { font-size: 18px; font-weight: 900; }

.progress.crawl { background: rgba(255,255,255,.06); border-color: rgba(255,255,255,.08); }
.progress.crawl .progress-fill {
  background: var(--ok);
}

.log-line { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.logs-details summary { cursor: pointer; }
.logs-details pre { max-height: 280px; overflow: auto; }

.history { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 8px; align-items: end; }
.history-bar { display: block; padding: 10px 8px; border-radius: 12px; border: 1px solid var(--border); background: rgba(255,255,255,.02); }
.history-bar:hover { background: rgba(255,255,255,.04); text-decoration: none; }
.history-bar-fill { height: 70px; border-radius: 10px; background: linear-gradient(180deg, rgba(var(--accent-rgb), .10), rgba(var(--accent-rgb), .03)); width: 100%; position: relative; overflow: hidden; }
.history-bar-fill::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: calc(var(--p) * 1%); background: linear-gradient(180deg, rgba(var(--accent-rgb), .42), rgba(var(--accent-rgb), .08)); }
.history-bar-label { margin-top: 8px; font-weight: 800; text-align: center; }
.history-bar-ts { margin-top: 4px; text-align: center; }

.row-crawl { margin-top: 8px; max-width: 220px; }
.row-crawl-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.row-crawl .pill { padding: 2px 8px; font-size: 11px; }

.job-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.job-chip { display: inline-flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; background: rgba(255,255,255,.02); }
.job-chip:hover { background: rgba(255,255,255,.04); text-decoration: none; }

.kv { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.kv.one { grid-template-columns: 1fr; }
.kv-item { padding: 10px; border: 1px solid var(--border); border-radius: 12px; background: rgba(255,255,255,.02); }
.kv-item > span { display: block; font-size: 12px; margin-bottom: 6px; }

.app-surfaces {
  --app-panel: linear-gradient(180deg, rgba(16, 16, 20, .84), rgba(9, 9, 12, .95));
  --app-card: linear-gradient(180deg, rgba(22, 22, 28, .90), rgba(13, 13, 17, .97));
  --app-inset: linear-gradient(180deg, rgba(255, 255, 255, .045), rgba(255, 255, 255, .024));
  --app-section: linear-gradient(180deg, rgba(20, 20, 25, .70), rgba(11, 11, 15, .48));
}

.app-surfaces .page-header h1 {
  color: #f4e6c2;
}

.app-surfaces > .card,
.app-surfaces > section.card {
  background: var(--app-panel);
  border-color: rgba(255, 255, 255, .075);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .025), var(--shadow-sm);
}

.app-surfaces .grid > .card,
.app-surfaces .grid > section.card,
.app-surfaces .modules-grid > .module-card,
.app-surfaces .setting-card {
  background: var(--app-card);
  border-color: rgba(255, 255, 255, .08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .03), var(--shadow-sm);
}

.app-surfaces .table-wrap,
.app-surfaces .kv-item,
.app-surfaces .job-chip,
.app-surfaces .oauth-project-item,
.app-surfaces .oauth-check-item,
.app-surfaces .gsc-list,
.app-surfaces .module-card,
.app-surfaces .setting-details summary,
.app-surfaces pre {
  background: var(--app-inset);
  border-color: rgba(255, 255, 255, .08);
}

.app-surfaces .card h2,
.app-surfaces .setting-title,
.app-surfaces .setting-card h3,
.app-surfaces .module-name {
  color: #f1dbab;
}

.app-surfaces .settings-section {
  margin-top: 22px;
  padding: 18px;
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, .05);
  background: var(--app-section);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .025);
}

.app-surfaces .settings-section-head {
  margin: 0 0 16px;
  padding: 0 2px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, .05);
}

.app-surfaces .settings-section-title {
  color: #d9bc7d;
}

.account-connections-page {
  --account-panel: linear-gradient(180deg, rgba(18, 18, 22, .88), rgba(10, 10, 13, .94));
  --account-setting-card: linear-gradient(180deg, var(--surface-card-2), rgba(14, 14, 18, .97));
  --account-row: linear-gradient(180deg, rgba(255, 255, 255, .05), rgba(255, 255, 255, .022));
  --account-kv: rgba(255, 255, 255, .04);
  --account-section: linear-gradient(180deg, var(--surface-section-2), rgba(10, 10, 13, .55));
}

.account-connections-page > .card {
  background: var(--account-panel);
  border-color: rgba(255, 255, 255, .07);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .025), var(--shadow-sm);
}

.account-connections-page .settings-section {
  margin-top: 22px;
  padding: 18px;
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, .05);
  background: var(--account-section);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .025);
}

.account-connections-page .settings-section-head {
  margin: 0 0 16px;
  padding: 0 2px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, .05);
}

.account-connections-page .settings-section-title {
  color: #d9bc7d;
}

.account-connections-page .setting-card {
  background: var(--account-setting-card);
  border-color: rgba(255, 255, 255, .075);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .03), var(--shadow-sm);
}

.account-connections-page .setting-title,
.account-connections-page .setting-card h3 {
  color: #f3ddb0;
}

.account-connections-page .oauth-project-item,
.account-connections-page .oauth-check-item,
.account-connections-page .job-chip,
.account-connections-page .gsc-list {
  background: var(--account-row);
  border-color: rgba(255, 255, 255, .08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .025);
}

.account-connections-page .kv-item,
.account-connections-page .setting-details summary {
  background: var(--account-kv);
  border-color: rgba(255, 255, 255, .08);
}

.account-connections-page .badge {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .07), 0 6px 18px rgba(0, 0, 0, .18);
}

.examples { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; }

dialog.modal {
  border: 1px solid var(--border-2);
  background: var(--panel);
  color: var(--text);
  border-radius: 14px;
  padding: 0;
  width: min(760px, calc(100vw - 48px));
}
dialog.modal::backdrop { background: rgba(0, 0, 0, .55); }
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.modal-head h2 { margin: 0; font-size: 16px; }
.modal-body { padding: 16px; }
.modal-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-top: 14px; }

.tab-buttons { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0; }
.tab-btn {
  appearance: none;
  border: 1px solid var(--border-2);
  background: rgba(255,255,255,.03);
  color: var(--text);
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 700;
  font-size: 13px;
}
.tab-btn:hover { background: rgba(255,255,255,.06); }
.tab-btn.active { background: rgba(var(--accent-rgb), .11); border-color: rgba(var(--accent-rgb), .22); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.gsc-toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.gsc-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 340px;
  overflow: auto;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255,255,255,.02);
}
.gsc-list .checkbox { justify-content: flex-start; gap: 10px; }
.gsc-selectall { padding-bottom: 8px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }

.top-action-details {
  margin-top: 12px;
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(255, 255, 255, .035), rgba(255, 255, 255, .018));
  overflow: hidden;
}

.top-action-details summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 800;
  color: #f1dbab;
}

.top-action-details summary::-webkit-details-marker {
  display: none;
}

.top-action-details summary::after {
  content: "▾";
  color: var(--muted);
  flex: 0 0 auto;
}

.top-action-details[open] summary {
  background: rgba(var(--accent-rgb), .08);
  border-bottom: 1px solid rgba(255, 255, 255, .06);
}

.top-action-details[open] summary::after {
  content: "▴";
}

.top-action-toggle-open {
  display: none;
}

.top-action-details[open] .top-action-toggle-closed {
  display: none;
}

.top-action-details[open] .top-action-toggle-open {
  display: inline;
}

.top-action-details-body {
  padding: 12px;
}

.top-action-copy {
  margin: 0;
}

.top-action-label {
  margin-top: 12px;
  font-weight: 800;
}

@media (max-width: 980px) {
  .sidebar { display: none; }
  .grid { grid-template-columns: 1fr; }
  .grid.two { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
  .history { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}
