/* Korix GTM UI. Light and dark themes follow the system setting. */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --surface-3: #f1f3f6;
  --border: #e5e7eb;
  --border-strong: #d4d8df;
  --text: #0f172a;
  --text-2: #475467;
  --muted: #7a8699;

  --brand: #2563eb;
  --brand-hover: #1d4ed8;
  --brand-soft: #eef4ff;
  --brand-ring: rgb(37 99 235 / 0.28);

  --ok: #067647;
  --ok-bg: #ecfdf3;
  --ok-dot: #17b26a;
  --warn: #b54708;
  --warn-bg: #fffaeb;
  --warn-dot: #f79009;
  --err: #b42318;
  --err-bg: #fef3f2;
  --err-dot: #f04438;
  --run: #1d4ed8;
  --run-bg: #eff4ff;
  --run-dot: #2e90fa;
  --idle: #475467;
  --idle-bg: #f2f4f7;
  --idle-dot: #98a2b3;

  --side-bg: var(--surface);
  --side-text: var(--text-2);
  --side-text-strong: var(--text);
  --side-hover: var(--surface-3);
  --side-active: var(--brand-soft);
  --side-border: var(--border);

  --shadow-sm: 0 1px 2px rgb(16 24 40 / 0.05);
  --shadow-md: 0 4px 12px -2px rgb(16 24 40 / 0.08), 0 2px 4px -2px rgb(16 24 40 / 0.04);
  --shadow-lg: 0 24px 48px -12px rgb(16 24 40 / 0.22);

  --radius: 12px;
  --radius-sm: 8px;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);

  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a0e15;
    --surface: #111722;
    --surface-2: #151c29;
    --surface-3: #1a2231;
    --border: #222c3c;
    --border-strong: #2e3a4d;
    --text: #e6eaf0;
    --text-2: #b4bdcb;
    --muted: #7d8a9e;

    --brand: #4f8cff;
    --brand-hover: #6b9dff;
    --brand-soft: rgb(79 140 255 / 0.12);
    --brand-ring: rgb(79 140 255 / 0.35);

    --ok: #47cd89;
    --ok-bg: rgb(23 178 106 / 0.12);
    --warn: #fdb022;
    --warn-bg: rgb(247 144 9 / 0.12);
    --err: #f97066;
    --err-bg: rgb(240 68 56 / 0.12);
    --run: #84adff;
    --run-bg: rgb(46 144 250 / 0.13);
    --idle: #a3adbd;
    --idle-bg: rgb(152 162 179 / 0.12);

    --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.3);
    --shadow-md: 0 4px 12px -2px rgb(0 0 0 / 0.4);
    --shadow-lg: 0 24px 48px -12px rgb(0 0 0 / 0.6);

    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
/* No rubber-band bounce on the page: it drags the sticky sidebar along and shows the grey --bg above/below it.
   Vertical only, so the horizontal swipe back/forward gesture still works. */
html { overscroll-behavior-y: none; }
body { margin: 0; min-height: 100vh; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, p { margin: 0; }
code { font-family: var(--mono); font-size: 0.92em; background: var(--surface-3); padding: 1px 5px; border-radius: 4px; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.hidden { display: none !important; }

.icon {
  width: 16px; height: 16px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}

:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px; }

/* ------------------------------------------------------------------ layout */

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

/* Icons sit on one 32px-centred column (sidebar padding + item padding), so collapsing to the 64px rail only
   narrows the sidebar and clips the labels; nothing moves. */
.sidebar {
  position: sticky; top: 0; z-index: 20; height: 100vh;
  flex: none; width: 248px;
  display: flex; flex-direction: column; gap: 4px;
  padding: 18px 14px 14px;
  background: var(--side-bg); color: var(--side-text);
  border-right: 1px solid var(--side-border);
  transition: width 0.22s var(--ease);
}
.sidebar-head { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-bottom: 18px; }
.brand { display: flex; align-items: center; gap: 11px; min-width: 0; padding: 4px 2px; color: var(--side-text-strong); }
.brand:hover { text-decoration: none; }
.brand-logo { width: 32px; height: 32px; flex: none; border-radius: 8px; }
.brand-text { display: flex; flex-direction: column; min-width: 0; overflow: hidden; font-weight: 700; font-size: 15px; letter-spacing: -0.01em; line-height: 1.15; }
.brand-text span { font-weight: 500; font-size: 12px; color: var(--muted); letter-spacing: 0.01em; }
.side-toggle { position: relative; flex: none; color: var(--muted); transition: opacity 0.15s var(--ease), background 0.15s var(--ease), color 0.15s var(--ease); }
.side-toggle:hover { background: var(--side-hover); color: var(--side-text-strong); }
.brand-logo { transition: opacity 0.15s var(--ease); }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); padding: 6px 10px; white-space: nowrap; overflow: hidden; }
.nav a, .nav-export {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 8px;
  color: var(--side-text); font-weight: 500; white-space: nowrap;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}
.nav a:hover, .nav-export:hover { background: var(--side-hover); color: var(--side-text-strong); text-decoration: none; }
.nav a.active { background: var(--side-active); color: var(--brand); }
.nav a.active::before { content: ''; position: absolute; left: -14px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--brand); }
.nav a .icon { opacity: 0.85; }
.nav a.active .icon { opacity: 1; }
.nav-text { min-width: 0; overflow: hidden; }
.nav-count { margin-left: auto; min-width: 20px; padding: 0 6px; border-radius: 999px; font-size: 11px; line-height: 18px; text-align: center; font-weight: 600; background: var(--surface-3); color: var(--text-2); }
.nav-count:empty { display: none; }
.nav-count.warn { background: var(--warn-bg); color: var(--warn); }
.nav-count.err { background: var(--err-bg); color: var(--err); }
.nav-count.run { background: var(--run-bg); color: var(--run); }

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; padding-top: 14px; border-top: 1px solid var(--side-border); }
.nav-chip { margin-left: auto; font-size: 10px; font-weight: 700; letter-spacing: 0.06em; padding: 1px 6px; border-radius: 4px; border: 1px solid var(--border-strong); color: var(--muted); }
.live { display: flex; align-items: center; gap: 8px; padding: 2px 10px 2px 14px; font-size: 12px; color: var(--side-text); }
.user { display: flex; align-items: center; gap: 10px; min-height: 28px; font-size: 12px; color: var(--side-text); }
#user-button { display: flex; justify-content: center; width: 36px; flex: none; }
#live-text, .user span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--idle-dot); flex: none; }
.live.on .live-dot { background: var(--ok-dot); box-shadow: 0 0 0 0 rgb(23 178 106 / 0.6); animation: pulse 2s infinite; }
.live.off .live-dot { background: var(--err-dot); }

.brand-text, .nav-label, .nav-text, .nav-chip, #live-text, #user-email { transition: opacity 0.15s var(--ease); }

/* Desktop: the toggle shrinks the sidebar to an icon rail (remembered in localStorage). Below 860px it is a drawer instead. */
@media (min-width: 861px) {
  body.nav-collapsed .sidebar { width: 64px; }
  body.nav-collapsed :is(.brand-text, .nav-label, .nav-text, .nav-chip, #live-text, #user-email) { opacity: 0; }
  body.nav-collapsed .nav-chip, body.nav-collapsed .nav-count:not(.warn, .err, .run) { display: none; }
  /* Counts that need attention stay visible as a badge on the icon. */
  body.nav-collapsed .nav-count { position: absolute; top: 1px; left: 19px; min-width: 16px; padding: 0 4px; font-size: 10px; line-height: 16px; color: #fff; box-shadow: 0 0 0 2px var(--side-bg); }
  body.nav-collapsed .nav-count.warn { background: var(--warn-dot); }
  body.nav-collapsed .nav-count.err { background: var(--err-dot); }
  body.nav-collapsed .nav-count.run { background: var(--run-dot); }
  /* The rail has no room beside the logo, so the toggle sits on top of it and swaps in on hover or focus. */
  body.nav-collapsed .side-toggle { position: absolute; top: 4px; left: 2px; opacity: 0; }
  body.nav-collapsed .sidebar-head:hover .side-toggle, body.nav-collapsed .side-toggle:focus-visible { opacity: 1; }
  body.nav-collapsed .sidebar-head:is(:hover, :has(.side-toggle:focus-visible)) .brand-logo { opacity: 0; }
  .topbar .menu-btn { display: none; }
  body.nav-collapsed .sidebar [data-tip]:is(:hover, :focus-visible)::after,
  .side-toggle:is(:hover, :focus-visible)::after {
    content: attr(data-tip);
    position: absolute; left: calc(100% + 16px); top: 50%; transform: translateY(-50%);
    padding: 5px 9px; border-radius: 6px;
    font-size: 12px; font-weight: 500; white-space: nowrap;
    color: var(--surface); background: var(--text); box-shadow: var(--shadow-md);
    pointer-events: none; animation: fade-in 0.12s var(--ease);
  }
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 14px;
  padding: 16px 32px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar-title { min-width: 0; flex: 1; }
.topbar-title h1 { font-size: 20px; font-weight: 650; letter-spacing: -0.015em; }
.topbar-title p { color: var(--muted); font-size: 13px; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; gap: 8px; flex: none; }
.topbar .menu-btn { margin-left: -6px; }

.content { padding: 24px 32px 64px; max-width: 1400px; width: 100%; }
.view { display: none; flex-direction: column; gap: 20px; animation: fade-in 0.2s var(--ease); }
.view.active { display: flex; }
.view > div:empty { display: none; }

.scrim { display: none; }

/* ------------------------------------------------------------------ buttons */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 14px;
  font: inherit; font-weight: 550; white-space: nowrap;
  color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease), color 0.15s var(--ease), transform 0.1s var(--ease);
}
.btn:hover { background: var(--surface-2); border-color: var(--muted); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled='true'] { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn.primary { color: #fff; background: var(--brand); border-color: var(--brand); box-shadow: 0 1px 2px rgb(16 24 40 / 0.1), inset 0 1px 0 rgb(255 255 255 / 0.12); }
.btn.primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
.btn.danger { color: var(--err); }
.btn.danger:hover { background: var(--err-bg); border-color: var(--err); }
.btn.danger-solid { color: #fff; background: #d92d20; border-color: #d92d20; }
.btn.danger-solid:hover { background: #b42318; border-color: #b42318; }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; gap: 6px; }
.btn.sm .icon { width: 14px; height: 14px; }
.btn.busy { pointer-events: none; opacity: 0.7; }
.btn.busy .icon { display: none; }
.btn.busy::before { content: ''; width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin 0.7s linear infinite; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 32px; height: 32px; padding: 0;
  color: var(--text-2); background: transparent;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s var(--ease), color 0.15s var(--ease), border-color 0.15s var(--ease);
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.icon-btn:disabled { opacity: 0.35; cursor: not-allowed; background: transparent; }
.icon-btn.danger:hover { background: var(--err-bg); color: var(--err); }
.icon-btn.bordered { border-color: var(--border-strong); background: var(--surface); box-shadow: var(--shadow-sm); }

/* ------------------------------------------------------------------ pills, bars, avatars */

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  height: 22px; padding: 0 9px 0 8px;
  border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap;
  color: var(--idle); background: var(--idle-bg);
}
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--idle-dot); flex: none; }
.pill.ok { color: var(--ok); background: var(--ok-bg); }
.pill.ok::before { background: var(--ok-dot); }
.pill.warn { color: var(--warn); background: var(--warn-bg); }
.pill.warn::before { background: var(--warn-dot); }
.pill.err { color: var(--err); background: var(--err-bg); }
.pill.err::before { background: var(--err-dot); }
.pill.run { color: var(--run); background: var(--run-bg); }
.pill.run::before { background: var(--run-dot); animation: pulse-run 1.6s infinite; }
.pill.review { color: var(--brand); background: var(--brand-soft); }
.pill.review::before { background: var(--brand); }
.pill.plain::before { display: none; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

.bar { position: relative; height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.bar > span { position: absolute; inset: 0 auto 0 0; border-radius: inherit; background: var(--brand); transition: width 0.6s var(--ease); }
.bar.ok > span { background: var(--ok-dot); }
.bar.warn > span { background: var(--warn-dot); }
.bar.err > span { background: var(--err-dot); }
.bar.indeterminate > span { width: 30% !important; animation: slide 1.4s var(--ease) infinite; }

.avatar {
  position: relative; display: inline-grid; place-items: center; flex: none;
  width: 36px; height: 36px; border-radius: 50%; overflow: hidden;
  font-size: 13px; font-weight: 650; letter-spacing: 0.02em;
  color: hsl(var(--h) 45% 32%); background: hsl(var(--h) 75% 92%);
}
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.avatar.sm { width: 30px; height: 30px; font-size: 11px; }
.avatar.lg { width: 44px; height: 44px; font-size: 15px; }
@media (prefers-color-scheme: dark) {
  .avatar { color: hsl(var(--h) 80% 82%); background: hsl(var(--h) 35% 22%); }
}

/* ------------------------------------------------------------------ panels & cards */

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.panel-head h2 { font-size: 14px; font-weight: 650; }
.panel-link { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 550; }
.panel-link .icon { width: 14px; height: 14px; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.stat { position: relative; padding: 18px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.stat-top { display: flex; align-items: center; justify-content: space-between; color: var(--text-2); font-size: 13px; font-weight: 550; }
.stat-icon { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; color: var(--brand); background: var(--brand-soft); }
.stat-icon.ok { color: var(--ok); background: var(--ok-bg); }
.stat-icon.warn { color: var(--warn); background: var(--warn-bg); }
.stat-icon.violet { color: #7a5af8; background: rgb(122 90 248 / 0.1); }
.stat-value { margin-top: 10px; font-size: 28px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat-value small { font-size: 15px; font-weight: 600; color: var(--muted); letter-spacing: 0; }
.stat-sub { margin-top: 2px; font-size: 12.5px; color: var(--muted); }
.stat .bar { margin-top: 10px; }

.ov-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 20px; }

.list-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 18px; border-bottom: 1px solid var(--border);
  color: inherit;
  transition: background 0.12s var(--ease);
}
.list-row:last-child { border-bottom: 0; }
a.list-row:hover { background: var(--surface-2); text-decoration: none; }
.list-main { min-width: 0; flex: 1; }
.list-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-sub { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-side { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; min-width: 120px; }
.list-side .bar { width: 120px; }
.num { font-variant-numeric: tabular-nums; font-size: 12.5px; color: var(--text-2); }
.num strong { color: var(--text); }

.alert {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-radius: var(--radius);
  border: 1px solid color-mix(in srgb, var(--warn-dot) 35%, transparent);
  background: var(--warn-bg); color: var(--text);
}
.alert + .alert { margin-top: 8px; }
.alert > .icon { color: var(--warn); width: 18px; height: 18px; }
.alert.err { border-color: color-mix(in srgb, var(--err-dot) 35%, transparent); background: var(--err-bg); }
.alert.err > .icon { color: var(--err); }
.alert.review { border-color: color-mix(in srgb, var(--brand) 30%, transparent); background: var(--brand-soft); }
.alert.review > .icon { color: var(--brand); }
.alert + .table-wrap { margin-top: 12px; }
.alert-text { flex: 1; min-width: 0; }
.alert-text strong { font-weight: 650; }
.alert-text p { color: var(--text-2); font-size: 13px; }

/* Getting started */
.start { padding: 24px; background: linear-gradient(135deg, var(--brand-soft), var(--surface) 60%); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.start h2 { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }
.start > p { color: var(--text-2); margin-top: 4px; }
.steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-top: 18px; }
.step { display: flex; flex-direction: column; gap: 6px; padding: 16px; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--border); }
.step-n { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; font-size: 12px; font-weight: 700; color: var(--brand); background: var(--brand-soft); }
.step.done .step-n { color: #fff; background: var(--ok-dot); }
.step h3 { font-size: 14px; font-weight: 650; margin-top: 4px; }
.step p { color: var(--muted); font-size: 13px; flex: 1; }
.step .btn { align-self: flex-start; margin-top: 6px; }

/* Empty states */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: 48px 24px; color: var(--muted); }
.empty-icon { display: grid; place-items: center; width: 48px; height: 48px; margin-bottom: 6px; border-radius: 14px; color: var(--brand); background: var(--brand-soft); }
.empty-icon .icon { width: 22px; height: 22px; }
.empty h3 { font-size: 15px; font-weight: 650; color: var(--text); }
.empty p { max-width: 380px; font-size: 13px; }
.empty .btn { margin-top: 10px; }
.empty.compact { padding: 28px 18px; }
.panel-empty { background: var(--surface); border: 1px dashed var(--border-strong); border-radius: var(--radius); }

/* ------------------------------------------------------------------ accounts */

.account-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; align-items: start; }
.account-grid > .panel-empty { grid-column: 1 / -1; }
.account {
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s var(--ease), border-color 0.2s var(--ease);
}
.account:hover { box-shadow: var(--shadow-md); }
.account.attention { border-color: color-mix(in srgb, var(--warn-dot) 55%, var(--border)); }
.account-head { display: flex; align-items: center; gap: 12px; padding: 16px 16px 12px; }
.account-name { min-width: 0; flex: 1; }
.account-name strong { display: block; font-size: 15px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account-name span { display: block; color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account-status { padding: 0 16px 12px; }
.account-msg { margin-top: 8px; font-size: 12.5px; color: var(--text-2); }
.usage { margin: 0 16px; padding: 12px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); }
.usage-top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; font-size: 12.5px; color: var(--text-2); }
.usage-top strong { font-size: 13px; color: var(--text); font-variant-numeric: tabular-nums; }
.meta { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; padding: 14px 16px; }
.meta div { display: flex; align-items: center; gap: 7px; min-width: 0; font-size: 12.5px; color: var(--text-2); }
.meta div span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meta .icon { width: 14px; height: 14px; color: var(--muted); }
.meta .warn, .meta .warn .icon { color: var(--warn); }
.meta .wide { grid-column: 1 / -1; }
.account-foot { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }
.account-foot .spacer { flex: 1; }

.inline-form { display: flex; flex-direction: column; gap: 8px; margin: 0 16px 12px; padding: 12px; border-radius: var(--radius-sm); background: var(--brand-soft); border: 1px solid color-mix(in srgb, var(--brand) 25%, transparent); }
.inline-form-title { display: flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 650; color: var(--brand); }
.inline-form-row { display: flex; gap: 8px; }
.inline-form-row input { flex: 1; min-width: 0; }
.inline-form .actions { display: flex; gap: 8px; }

/* Dropdown menu */
.menu { position: relative; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-pop {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 20;
  min-width: 200px; padding: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg);
  animation: pop 0.12s var(--ease);
}
.menu-pop button, .menu-pop a {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 10px; border: 0; border-radius: 6px;
  font: inherit; text-align: left; color: var(--text); background: transparent; cursor: pointer;
}
.menu-pop button:hover:not(:disabled), .menu-pop a:hover { background: var(--surface-3); text-decoration: none; }
.menu-pop button:disabled { opacity: 0.4; cursor: not-allowed; }
.menu-pop button .icon { color: var(--muted); }
.menu-pop button.danger { color: var(--err); }
.menu-pop button.danger .icon { color: var(--err); }
.menu-pop hr { margin: 4px 2px; border: 0; border-top: 1px solid var(--border); }

/* A menu that picks one of a list, opened from a field-like button. */
.picker > summary {
  display: flex; align-items: center; gap: 10px;
  height: 36px; min-width: 260px; max-width: 420px; padding: 0 10px 0 12px;
  color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); box-shadow: var(--shadow-sm);
  cursor: pointer; transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.picker > summary:hover { border-color: var(--muted); }
.picker > summary:focus-visible, .picker[open] > summary { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring); }
.picker > summary > span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker > summary .icon { width: 15px; height: 15px; color: var(--muted); transform: rotate(90deg); transition: transform 0.15s var(--ease); }
.picker[open] > summary .icon { transform: rotate(-90deg); }
.picker .menu-pop { left: 0; right: auto; min-width: 100%; max-width: 420px; max-height: min(360px, 60vh); overflow-y: auto; }
.picker .menu-pop a > span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker .menu-pop a small { flex: none; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.picker .menu-pop a[aria-current] { font-weight: 600; color: var(--brand); background: var(--brand-soft); }

/* ------------------------------------------------------------------ tables */

.toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.segmented { display: inline-flex; padding: 3px; gap: 2px; border-radius: 10px; background: var(--surface-3); border: 1px solid var(--border); }
.segmented button {
  display: inline-flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 12px; border: 0; border-radius: 7px;
  font: inherit; font-weight: 550; font-size: 13px; color: var(--text-2); background: transparent; cursor: pointer;
}
.segmented button:hover { color: var(--text); }
.segmented button.on { color: var(--text); background: var(--surface); box-shadow: var(--shadow-sm); }
.segmented button span { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
th { position: sticky; top: 0; font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); background: var(--surface-2); white-space: nowrap; }
tbody tr { transition: background 0.12s var(--ease); }
tbody tr:hover { background: var(--surface-2); }
tr[data-href] { cursor: pointer; }
td.nowrap { white-space: nowrap; }
td.account-cell { min-width: 150px; }
td.right, th.right { text-align: right; }
.row-actions { display: flex; justify-content: flex-end; gap: 2px; }
.cell-title { font-weight: 600; }
.cell-sub { color: var(--muted); font-size: 12.5px; }
.cell-url { max-width: 300px; font-family: var(--mono); font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cell-msg { max-width: 360px; margin-top: 4px; font-size: 12.5px; color: var(--text-2); }
.progress-cell { min-width: 170px; }
.progress-cell .bar { margin: 6px 0 4px; }
.person { display: flex; align-items: center; gap: 12px; min-width: 220px; }
.person > div { min-width: 0; }
.person > div > strong { display: block; font-weight: 600; }
.person > div > span { display: block; color: var(--muted); font-size: 12.5px; max-width: 320px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.with-icon { display: inline-flex; align-items: center; gap: 6px; }
.with-icon .icon { width: 14px; height: 14px; color: var(--muted); }
.degree { display: inline-grid; place-items: center; min-width: 30px; height: 22px; padding: 0 6px; border-radius: 6px; font-size: 11.5px; font-weight: 650; color: var(--text-2); background: var(--surface-3); }
.links { display: flex; gap: 2px; justify-content: flex-end; }
.links .icon-btn .icon { width: 15px; height: 15px; }
/* A deleted lead, on its job's page. */
tr.deleted td:not(.check):not(:last-child) { opacity: 0.55; }
tr.deleted .person > div > strong { display: flex; align-items: center; gap: 8px; }

/* A job's page: its status and progress, then what it searches for. */
.job-facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)) auto; gap: 16px 24px; align-items: start; padding: 16px 18px; }
.fact { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.fact .bar { margin-top: 4px; }
.fact-label { font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.job-search { display: flex; flex-direction: column; gap: 8px; padding: 14px 18px 16px; border-top: 1px solid var(--border); font-size: 13px; }
.job-search dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px 16px; margin: 0; }
.job-search dt { color: var(--muted); }
.job-search dd { margin: 0; }
.job-search dd s { color: var(--err); }
.job-search dd.warn { grid-column: 1 / -1; color: var(--warn); }
.job-search a { display: inline-flex; align-items: center; gap: 4px; align-self: flex-start; font-weight: 500; }
.job-search a .icon { width: 14px; height: 14px; }

.search-field input {
  height: 36px; font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); box-shadow: var(--shadow-sm);
}
.search-field { position: relative; flex: 1; max-width: 420px; min-width: 220px; }
.search-field .icon { position: absolute; left: 11px; top: 10px; color: var(--muted); }
.search-field input { width: 100%; padding: 0 12px 0 34px; }

.table-note { padding: 10px 16px; font-size: 12.5px; color: var(--muted); border-top: 1px solid var(--border); background: var(--surface-2); }
.table-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.pager { display: flex; align-items: center; gap: 10px; }
.pager span { font-variant-numeric: tabular-nums; }
.table-wrap.busy { opacity: 0.55; transition: opacity 0.15s var(--ease); }

/* The leads tables' checkboxes (the whole cell is the hit area), and the bar acting on the ticked leads. */
th.check, td.check { width: 1%; padding: 0; }
.check label { display: flex; align-items: center; padding: 12px 2px 12px 16px; cursor: pointer; user-select: none; }
.check input { width: 16px; height: 16px; margin: 0; accent-color: var(--brand); cursor: pointer; }
tbody tr.selected, tbody tr.selected:hover { background: var(--brand-soft); }
/* Sticks to the bottom of the screen while the table scrolls by, then rests below it (never over the pager). */
.bulk-bar {
  position: sticky; bottom: 20px; z-index: 30;
  display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 8px;
  width: fit-content; max-width: 100%; margin: 12px auto 0; padding: 8px 8px 8px 16px;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius); box-shadow: var(--shadow-lg);
}
.bulk-count { margin-right: 6px; font-weight: 600; white-space: nowrap; }
.bulk-count small { font-size: inherit; font-weight: 400; color: var(--muted); }

/* ------------------------------------------------------------------ recent activity */

.event { display: flex; align-items: flex-start; gap: 12px; padding: 11px 18px; border-bottom: 1px solid var(--border); }
.event:last-child { border-bottom: 0; }
.event-icon { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 8px; flex: none; color: var(--idle); background: var(--idle-bg); }
.event-icon .icon { width: 14px; height: 14px; }
.event.warn .event-icon { color: var(--warn); background: var(--warn-bg); }
.event.error .event-icon { color: var(--err); background: var(--err-bg); }
.event-body { flex: 1; min-width: 0; padding-top: 3px; }
.event-msg { word-break: break-word; }
.event.error .event-msg { color: var(--err); }
.event-refs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 5px; }
.ref { display: inline-flex; align-items: center; gap: 5px; height: 20px; padding: 0 7px; border-radius: 5px; font-size: 11.5px; font-weight: 550; color: var(--text-2); background: var(--surface-3); }
a.ref:hover { color: var(--brand); text-decoration: none; }
.ref .icon { width: 12px; height: 12px; }
.event time { flex: none; padding-top: 4px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ------------------------------------------------------------------ modals */

.modal {
  width: min(640px, calc(100vw - 32px)); max-height: calc(100vh - 48px);
  padding: 0; border: 1px solid var(--border); border-radius: 16px;
  color: var(--text); background: var(--surface); box-shadow: var(--shadow-lg);
}
.modal-sm { width: min(440px, calc(100vw - 32px)); }
.modal-lg { width: min(1180px, calc(100vw - 32px)); }
.modal[open] { animation: modal-in 0.18s var(--ease); }
.modal::backdrop { background: rgb(10 14 21 / 0.5); backdrop-filter: blur(3px); animation: fade-in 0.18s var(--ease); }
.modal form { display: flex; flex-direction: column; max-height: calc(100vh - 50px); }
.modal-head { display: flex; align-items: flex-start; gap: 14px; padding: 20px 20px 16px; border-bottom: 1px solid var(--border); }
.modal-head > div:nth-child(2) { flex: 1; }
.modal-head h2, .confirm h2 { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; }
.modal-head p, .confirm p { color: var(--muted); font-size: 13px; margin-top: 2px; }
.modal-icon { display: grid; place-items: center; width: 40px; height: 40px; flex: none; border-radius: 11px; color: var(--brand); background: var(--brand-soft); }
.modal-icon .icon { width: 19px; height: 19px; }
.modal-icon.danger { color: var(--err); background: var(--err-bg); }
.modal-body { display: flex; flex-direction: column; gap: 16px; padding: 20px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 16px 16px; }
.confirm { flex-direction: row; gap: 14px; }

.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.field-grid.three { grid-template-columns: 1.4fr 1fr 0.8fr; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--text); }
.field small { font-size: 12px; font-weight: 400; color: var(--muted); }
.field input, .field select, .field textarea, .inline-form input, .inline-form textarea {
  width: 100%; padding: 8px 11px;
  font: inherit; font-weight: 400; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.field input, .field select, .inline-form input { height: 38px; }
.field textarea, textarea.mono { resize: vertical; }
.mono { font-family: var(--mono) !important; font-size: 12px !important; }
.field input::placeholder, .field textarea::placeholder, .inline-form input::placeholder, .inline-form textarea::placeholder, .search-field input::placeholder { color: var(--muted); opacity: 0.8; }
.field input:focus, .field select:focus, .field textarea:focus, .inline-form input:focus, .inline-form textarea:focus, .search-field input:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring);
}

.note { display: flex; gap: 10px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); font-size: 12.5px; color: var(--text-2); }
.note .icon { margin-top: 1px; color: var(--muted); }

.builder { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.builder summary { display: flex; align-items: center; gap: 8px; padding: 10px 12px; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--brand); list-style: none; }
.builder summary::-webkit-details-marker { display: none; }
.builder-body { display: flex; flex-direction: column; gap: 12px; padding: 4px 12px 12px; }
.builder-body .btn { align-self: flex-start; }

.stack { display: flex; flex-direction: column; gap: 16px; }

/* A job's search in the jobs list: one line per filter, label then values. */
.job-query { min-width: 240px; max-width: 440px; margin-top: 6px; font-size: 12.5px; line-height: 18px; }
.job-query dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 3px 12px; margin: 0; }
.job-query dt { color: var(--muted); }
.job-query dd { margin: 0; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.job-query.open dd { white-space: normal; }
.job-query dd s { color: var(--err); }
.job-query dd.warn { grid-column: 1 / -1; color: var(--warn); }
.job-query-foot { display: flex; align-items: center; gap: 16px; margin-top: 6px; }
.job-query-foot > * {
  display: inline-flex; align-items: center; gap: 4px; padding: 0;
  font: inherit; font-weight: 500; color: var(--text-2); background: none; border: 0; cursor: pointer;
}
.job-query-foot > :hover { color: var(--brand); text-decoration: none; }
.job-query-foot button { color: var(--brand); }
.job-query-foot .icon { width: 14px; height: 14px; }
.job-query-foot button .icon { transform: rotate(90deg); transition: transform 0.15s var(--ease); }
.job-query.open .job-query-foot button .icon { transform: rotate(-90deg); }


/* ------------------------------------------------------------------ toasts */

.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; pointer-events: none; }
.toast {
  display: flex; align-items: flex-start; gap: 10px;
  max-width: 420px; padding: 12px 14px;
  color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg);
  pointer-events: auto; animation: toast-in 0.22s var(--ease);
}
.toast .icon { margin-top: 1px; color: var(--ok-dot); }
.toast.err .icon { color: var(--err-dot); }
.toast.out { opacity: 0; transform: translateY(6px); transition: opacity 0.2s, transform 0.2s; }

/* ------------------------------------------------------------------ motion */

@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgb(23 178 106 / 0.55); } 70% { box-shadow: 0 0 0 7px rgb(23 178 106 / 0); } 100% { box-shadow: 0 0 0 0 rgb(23 178 106 / 0); } }
@keyframes pulse-run { 50% { opacity: 0.35; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(340%); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(4px) scale(0.98); } }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* ------------------------------------------------------------------ responsive */

@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ov-grid { grid-template-columns: minmax(0, 1fr); }
  .job-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .job-facts .row-actions { grid-column: 1 / -1; justify-content: flex-start; }
}

@media (max-width: 860px) {
  .sidebar { position: fixed; z-index: 50; left: 0; width: 264px; transform: translateX(-100%); transition: transform 0.22s var(--ease); }
  body.nav-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; z-index: 40; background: rgb(10 14 21 / 0.45); }
  .topbar { padding: 12px 16px; }
  .topbar-actions .btn .label { display: none; }
  .topbar-actions .btn { padding: 0 10px; }
  .content { padding: 16px 16px 48px; }
  .steps { grid-template-columns: minmax(0, 1fr); }
  .field-grid, .field-grid.three { grid-template-columns: minmax(0, 1fr); }
  .account-grid { grid-template-columns: minmax(0, 1fr); }
  .list-side { min-width: 0; }
  .list-side .bar { width: 80px; }
  .picker, .picker > summary, .picker .menu-pop { width: 100%; min-width: 0; max-width: none; }
  .search-field { max-width: none; }
}

@media (max-width: 520px) {
  .topbar-actions .btn.secondary-action { display: none; }
  .stats { gap: 10px; }
  .stat { padding: 14px; }
  .stat-value { font-size: 24px; }
  .meta { grid-template-columns: minmax(0, 1fr); }
}

/* Live view of a job's browser */
.screen { position: relative; display: grid; place-items: center; min-height: 360px; overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.screen img { display: none; width: 100%; height: auto; max-height: calc(100vh - 230px); object-fit: contain; }
.screen.on img { display: block; }
.screen.on .screen-msg { display: none; }
.screen-msg { max-width: 420px; padding: 24px; text-align: center; color: var(--muted); font-size: 13px; }
.screen-msg strong { display: block; margin-bottom: 4px; color: var(--text); font-size: 14px; }
.screen.interactive { cursor: pointer; outline: none; user-select: none; }
.screen.interactive:focus-visible, .screen.interactive:focus { box-shadow: 0 0 0 3px var(--brand-ring); }
.screen-click { position: absolute; width: 22px; height: 22px; margin: -11px 0 0 -11px; border-radius: 50%; pointer-events: none; background: var(--brand-ring); animation: screen-click 0.5s ease-out forwards; }
@keyframes screen-click { from { transform: scale(0.4); opacity: 1; } to { transform: scale(1.6); opacity: 0; } }
.screen-cta { display: block; margin-top: 12px; }
.screen-hint { display: flex; gap: 8px; align-items: flex-start; margin: 10px 0 4px; color: var(--muted); font-size: 12.5px; }
.screen-hint[hidden] { display: none; }
.screen-hint .icon { flex: none; margin-top: 1px; }
.screen-url { min-height: 16px; font-family: var(--mono); font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Sign-in and sign-up page (sign-in.html): Clerk's component, centered under the logo */
.auth { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 24px; min-height: 100vh; padding: 32px 16px; }
.auth-brand { display: flex; align-items: center; gap: 11px; font-weight: 700; font-size: 17px; letter-spacing: -0.01em; color: var(--text); }
.auth-brand svg { width: 36px; height: 36px; border-radius: 9px; box-shadow: 0 6px 16px -4px rgb(59 130 246 / 0.55); }
.auth-status { color: var(--muted); font-size: 13px; text-align: center; }
.auth-status.err { color: var(--err); }
