/* ===========================================================================
   TaxFetch design system.

   Everything is driven by the custom properties in :root. Dark mode is a
   second set of the same names under [data-theme="dark"], so no component
   rule below ever needs to know which theme is active — a component that
   hardcodes a hex value is a bug.

   Layers, in order: tokens -> reset -> primitives -> layout -> components.
   =========================================================================== */

:root {
  /* Brand + accents */
  --brand-50:  #EEF2FF;
  --brand-100: #E0E7FF;
  --brand-200: #C7D2FE;
  --brand-400: #818CF8;
  --brand-500: #6366F1;
  --brand-600: #4F46E5;
  --brand-700: #4338CA;

  /* Surfaces */
  --bg:          #F8FAFC;
  --bg-subtle:   #F1F5F9;
  --surface:     #FFFFFF;
  --surface-2:   #F8FAFC;
  --surface-3:   #F1F5F9;
  --overlay:     rgba(15, 23, 42, 0.45);

  /* Text */
  --text:        #0F172A;
  --text-2:      #334155;
  --muted:       #64748B;
  --muted-2:     #94A3B8;
  --on-brand:    #FFFFFF;

  /* Lines */
  --border:      #E2E8F0;
  --border-2:    #CBD5E1;
  --ring:        rgba(99, 102, 241, 0.35);

  /* Semantic */
  --ok:        #16A34A;
  --ok-bg:     #DCFCE7;
  --ok-text:   #14532D;
  --warn:      #D97706;
  --warn-bg:   #FEF3C7;
  --warn-text: #78350F;
  --err:       #DC2626;
  --err-bg:    #FEE2E2;
  --err-text:  #7F1D1D;
  --info:      #0284C7;
  --info-bg:   #E0F2FE;
  --info-text: #0C4A6E;

  /* Sidebar (its own scale so it stays dark in light mode) */
  --side-bg:      #0F172A;
  --side-bg-2:    #1E293B;
  --side-text:    #CBD5E1;
  --side-text-2:  #64748B;
  --side-active:  #FFFFFF;
  --side-border:  rgba(255, 255, 255, 0.07);

  /* Geometry */
  --r-sm: 6px;
  --r:    9px;
  --r-lg: 14px;
  --r-xl: 20px;
  --sidebar-w: 244px;
  --sidebar-w-collapsed: 64px;
  --topbar-h: 56px;

  /* Elevation */
  --sh-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --sh:    0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04);
  --sh-md: 0 4px 12px rgba(15, 23, 42, 0.08), 0 2px 4px rgba(15, 23, 42, 0.04);
  --sh-lg: 0 12px 32px rgba(15, 23, 42, 0.12), 0 4px 8px rgba(15, 23, 42, 0.06);
  --sh-xl: 0 24px 60px rgba(15, 23, 42, 0.18);

  --font: "Inter var", Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "Cascadia Code", Menlo, Consolas, monospace;

  --t-fast: 120ms cubic-bezier(0.4, 0, 0.2, 1);
  --t:      200ms cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
  --bg:        #0B1120;
  --bg-subtle: #0F172A;
  --surface:   #131C2E;
  --surface-2: #1A2436;
  --surface-3: #212D42;
  --overlay:   rgba(2, 6, 23, 0.7);

  --text:    #F1F5F9;
  --text-2:  #CBD5E1;
  --muted:   #94A3B8;
  --muted-2: #64748B;

  --border:   #253048;
  --border-2: #33415C;
  --ring:     rgba(129, 140, 248, 0.4);

  --ok-bg:     rgba(22, 163, 74, 0.16);
  --ok-text:   #86EFAC;
  --warn-bg:   rgba(217, 119, 6, 0.16);
  --warn-text: #FCD34D;
  --err-bg:    rgba(220, 38, 38, 0.16);
  --err-text:  #FCA5A5;
  --info-bg:   rgba(2, 132, 199, 0.16);
  --info-text: #7DD3FC;

  --side-bg:     #0A101F;
  --side-bg-2:   #131C2E;
  --side-border: rgba(255, 255, 255, 0.06);

  --sh-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --sh:    0 1px 3px rgba(0, 0, 0, 0.4);
  --sh-md: 0 4px 12px rgba(0, 0, 0, 0.45);
  --sh-lg: 0 12px 32px rgba(0, 0, 0, 0.5);
  --sh-xl: 0 24px 60px rgba(0, 0, 0, 0.6);
}

/* --------------------------------------------------------------------- reset */

*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-variant-numeric: tabular-nums;
}

/* Theme flips must not animate every element on the page at once. */
body.theme-switching, body.theme-switching * { transition: none !important; }

a { color: var(--brand-600); text-decoration: none; }
a:hover { text-decoration: underline; }
[data-theme="dark"] a { color: var(--brand-400); }

svg { display: block; flex-shrink: 0; }
img { max-width: 100%; }

::selection { background: var(--brand-200); color: var(--brand-700); }
[data-theme="dark"] ::selection { background: var(--brand-700); color: #fff; }

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

/* Slim scrollbars everywhere; the default Windows bar eats 17px of a
   240px-wide sidebar. */
* { scrollbar-width: thin; scrollbar-color: var(--border-2) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 99px; border: 2px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--muted-2); background-clip: content-box; }

.hidden { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

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

/* ---------------------------------------------------------------- primitives */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font-family: inherit; font-size: 13px; font-weight: 600; line-height: 1;
  padding: 0 14px; height: 36px; border-radius: var(--r);
  border: 1px solid transparent; background: none; color: var(--text);
  cursor: pointer; white-space: nowrap; user-select: none;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast);
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn svg { width: 15px; height: 15px; }

.btn-primary { background: var(--brand-600); color: var(--on-brand); box-shadow: var(--sh-sm); }
.btn-primary:hover:not(:disabled) { background: var(--brand-700); }
.btn-outline { background: var(--surface); border-color: var(--border); color: var(--text-2); }
.btn-outline:hover:not(:disabled) { background: var(--surface-3); border-color: var(--border-2); color: var(--text); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-3); color: var(--text); }
.btn-danger { background: var(--err); color: #fff; }
.btn-danger:hover:not(:disabled) { filter: brightness(0.92); }
.btn-danger-soft { background: var(--err-bg); color: var(--err-text); }
.btn-danger-soft:hover:not(:disabled) { background: var(--err); color: #fff; }

.btn-sm { height: 30px; font-size: 12px; padding: 0 10px; gap: 5px; }
.btn-sm svg { width: 13px; height: 13px; }
.btn-lg { height: 42px; font-size: 14px; padding: 0 20px; }
.btn-icon { width: 36px; padding: 0; }
.btn-icon.btn-sm { width: 30px; }
.btn-block { width: 100%; }

/* Form controls */
.input, input[type="text"], input[type="email"], input[type="password"],
input[type="date"], input[type="search"], input[type="number"], select, textarea {
  font-family: inherit; font-size: 13.5px; width: 100%;
  height: 38px; padding: 0 11px;
  border: 1px solid var(--border); border-radius: var(--r);
  background: var(--surface); color: var(--text);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
textarea { height: auto; min-height: 76px; padding: 9px 11px; resize: vertical; line-height: 1.5; }
select {
  appearance: none; padding-right: 32px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center;
}
input::placeholder, textarea::placeholder { color: var(--muted-2); }
input:hover:not(:disabled), select:hover:not(:disabled), textarea:hover { border-color: var(--border-2); }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand-500); box-shadow: 0 0 0 3px var(--ring);
}
input:disabled, select:disabled, textarea:disabled { background: var(--surface-3); color: var(--muted); cursor: not-allowed; }
/* The native calendar glyph is near-invisible on a dark surface. */
[data-theme="dark"] input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(0.75); }

.field { margin-bottom: 14px; }
.field label, .label {
  display: block; font-size: 12px; font-weight: 600; color: var(--text-2);
  margin-bottom: 6px; letter-spacing: 0.005em;
}
.field .hint { font-size: 11.5px; color: var(--muted); margin-top: 5px; }
.field .optional { font-weight: 400; color: var(--muted-2); }
.field.invalid input, .field.invalid select, .field.invalid textarea { border-color: var(--err); }
.field.invalid input:focus, .field.invalid select:focus { box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.2); }
.field .error {
  display: none; font-size: 11.5px; color: var(--err); margin-top: 5px;
  align-items: center; gap: 4px;
}
.field.invalid .error { display: flex; }
.field.valid input { border-color: var(--ok); }
.field .field-note { font-size: 11.5px; color: var(--info); margin-top: 5px; }

.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 860px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

/* Checkbox / radio: native controls can't be styled consistently, so the
   input is hidden and .cb-box draws the visible control. */
.check {
  display: flex; align-items: flex-start; gap: 9px; padding: 6px 0;
  font-size: 13.5px; cursor: pointer; user-select: none; color: var(--text-2);
}
.check input { position: absolute; opacity: 0; width: 0; height: 0; }
.cb-box {
  width: 17px; height: 17px; flex-shrink: 0; margin-top: 1px;
  border: 1.5px solid var(--border-2); border-radius: 5px; background: var(--surface);
  display: grid; place-items: center;
  transition: all var(--t-fast);
}
.check input[type="radio"] ~ .cb-box { border-radius: 50%; }
.cb-box::after {
  content: ""; width: 9px; height: 9px;
  background: var(--on-brand); transform: scale(0);
  transition: transform var(--t-fast);
  clip-path: polygon(14% 44%, 0 65%, 40% 100%, 100% 16%, 82% 0%, 37% 62%);
}
.check input[type="radio"] ~ .cb-box::after { clip-path: none; border-radius: 50%; width: 7px; height: 7px; }
.check input:checked ~ .cb-box { background: var(--brand-600); border-color: var(--brand-600); }
.check input:checked ~ .cb-box::after { transform: scale(1); }
.check input:focus-visible ~ .cb-box { box-shadow: 0 0 0 3px var(--ring); }
.check:hover .cb-box { border-color: var(--brand-500); }
.check input:disabled ~ .cb-box { opacity: 0.45; }
.check input:disabled ~ .cb-text { opacity: 0.5; }
.cb-text small { display: block; color: var(--muted); font-size: 11.5px; margin-top: 1px; }

/* Toggle switch */
.switch { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; }
.switch-track {
  width: 34px; height: 19px; border-radius: 99px; background: var(--border-2);
  padding: 2px; transition: background var(--t-fast); flex-shrink: 0;
}
.switch-thumb {
  width: 15px; height: 15px; border-radius: 50%; background: #fff;
  box-shadow: var(--sh-sm); transition: transform var(--t-fast);
}
.switch input:checked ~ .switch-track { background: var(--brand-600); }
.switch input:checked ~ .switch-track .switch-thumb { transform: translateX(15px); }

/* Badges */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 99px;
  font-size: 11px; font-weight: 600; line-height: 1.6; white-space: nowrap;
  background: var(--surface-3); color: var(--muted);
}
.badge-ok   { background: var(--ok-bg);   color: var(--ok-text); }
.badge-warn { background: var(--warn-bg); color: var(--warn-text); }
.badge-err  { background: var(--err-bg);  color: var(--err-text); }
.badge-info { background: var(--info-bg); color: var(--info-text); }
.badge-brand{ background: var(--brand-50); color: var(--brand-700); }
[data-theme="dark"] .badge-brand { background: rgba(99,102,241,0.18); color: var(--brand-400); }
.badge-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.badge-dot.pulse { animation: dot-pulse 1.4s ease-in-out infinite; }
@keyframes dot-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 1px 7px; border-radius: var(--r-sm); font-size: 11px; font-weight: 500;
  background: var(--surface-3); color: var(--text-2); border: 1px solid var(--border);
}
.tag button { background: none; border: none; cursor: pointer; color: var(--muted); font-size: 13px; line-height: 1; padding: 0; }
.tag button:hover { color: var(--err); }

kbd {
  font-family: var(--font); font-size: 10.5px; font-weight: 600;
  padding: 2px 5px; min-width: 19px; text-align: center; display: inline-block;
  border: 1px solid var(--border-2); border-bottom-width: 2px; border-radius: 5px;
  background: var(--surface); color: var(--muted);
}

/* Cards */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--sh-sm);
  margin-bottom: 16px; overflow: hidden;
}
/* A card containing a dropdown (the client combobox) must not clip it, and
   must paint above the cards that follow it in the document — otherwise the
   list is both cut off at the card edge and hidden behind the next card. */
.card.popover-host { overflow: visible; position: relative; z-index: 5; }
.card-head {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.card-head h3 { font-size: 13.5px; font-weight: 650; letter-spacing: -0.005em; }
.card-head .sub { font-size: 12px; color: var(--muted); font-weight: 400; margin-top: 2px; }
.card-head .spacer { flex: 1; }
.card-body { padding: 18px; }
.card-body.flush { padding: 0; }
.card-foot { padding: 12px 18px; border-top: 1px solid var(--border); background: var(--surface-2); display: flex; align-items: center; gap: 10px; }

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

.auth-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(ellipse 700px 420px at 50% -8%, var(--brand-100), transparent 65%),
    var(--bg);
}
[data-theme="dark"] .auth-wrap {
  background: radial-gradient(ellipse 700px 420px at 50% -8%, rgba(99,102,241,0.18), transparent 65%), var(--bg);
}
.auth-card {
  width: 100%; max-width: 400px; text-align: center;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-xl); box-shadow: var(--sh-lg); padding: 36px 32px;
}
.brand { display: inline-flex; align-items: center; gap: 9px; font-weight: 750; font-size: 20px; letter-spacing: -0.02em; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
  color: #fff; font-size: 14px; font-weight: 800; letter-spacing: -0.03em;
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.35);
}
.brand-text b { font-weight: 750; }
.brand-text span { color: var(--brand-600); }
[data-theme="dark"] .brand-text span { color: var(--brand-400); }
.auth-sub { color: var(--muted); font-size: 13.5px; margin: 10px 0 26px; }
.google-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; height: 44px; border: 1px solid var(--border); border-radius: var(--r);
  background: var(--surface); color: var(--text); font-weight: 600; font-size: 14px;
  cursor: pointer; transition: all var(--t-fast); font-family: inherit;
}
.google-btn:hover { background: var(--surface-3); border-color: var(--border-2); box-shadow: var(--sh-sm); }
.auth-foot { margin-top: 24px; font-size: 11.5px; color: var(--muted-2); line-height: 1.6; }

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

/* Sidebar */
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--side-bg); color: var(--side-text);
  display: flex; flex-direction: column;
  position: fixed; inset: 0 auto 0 0; z-index: 60;
  border-right: 1px solid var(--side-border);
  transition: width var(--t), transform var(--t);
}
body.sidebar-collapsed .sidebar { width: var(--sidebar-w-collapsed); }
.sidebar-head {
  display: flex; align-items: center; gap: 10px; height: var(--topbar-h);
  padding: 0 16px; border-bottom: 1px solid var(--side-border); flex-shrink: 0;
}
.sidebar-head .brand-text { color: #fff; font-size: 16px; white-space: nowrap; }
.sidebar-head .brand-text span { color: var(--brand-400); }
body.sidebar-collapsed .sidebar-head { padding: 0 17px; }
body.sidebar-collapsed .sidebar-head .brand-text { display: none; }

.nav { flex: 1; padding: 12px 10px; overflow-y: auto; overflow-x: hidden; }
.nav-group { margin-bottom: 4px; }
.nav-group-label {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--side-text-2); padding: 12px 10px 6px; white-space: nowrap;
}
body.sidebar-collapsed .nav-group-label { opacity: 0; height: 12px; padding: 0; overflow: hidden; }
.nav-item {
  display: flex; align-items: center; gap: 11px; width: 100%;
  padding: 8px 10px; margin-bottom: 1px; border: none; border-radius: var(--r);
  background: none; color: var(--side-text); font-family: inherit;
  font-size: 13.5px; font-weight: 500; text-align: left; cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
  position: relative;
}
.nav-item svg { width: 17px; height: 17px; opacity: 0.85; }
.nav-item .nav-label { flex: 1; white-space: nowrap; overflow: hidden; }
.nav-item:hover { background: var(--side-bg-2); color: #fff; }
.nav-item.active { background: var(--brand-600); color: #fff; font-weight: 600; box-shadow: 0 2px 8px rgba(79,70,229,0.3); }
.nav-item.active svg { opacity: 1; }
.nav-count {
  font-size: 10.5px; font-weight: 700; padding: 1px 6px; border-radius: 99px;
  background: rgba(255,255,255,0.12); color: var(--side-text);
}
.nav-item.active .nav-count { background: rgba(255,255,255,0.25); color: #fff; }
body.sidebar-collapsed .nav-item { justify-content: center; padding: 9px 0; }
body.sidebar-collapsed .nav-item .nav-label,
body.sidebar-collapsed .nav-count { display: none; }
/* Collapsed rail still needs to say what each icon is. */
body.sidebar-collapsed .nav-item::after {
  content: attr(data-tip); position: absolute; left: calc(100% + 10px); top: 50%;
  transform: translateY(-50%); background: var(--side-bg-2); color: #fff;
  padding: 5px 10px; border-radius: var(--r-sm); font-size: 12px; font-weight: 500;
  white-space: nowrap; box-shadow: var(--sh-md); pointer-events: none;
  opacity: 0; transition: opacity var(--t-fast); z-index: 80;
}
body.sidebar-collapsed .nav-item:hover::after { opacity: 1; }

.sidebar-foot { padding: 10px; border-top: 1px solid var(--side-border); flex-shrink: 0; }
.user-chip {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px; border: none; border-radius: var(--r); background: none;
  color: var(--side-text); cursor: pointer; font-family: inherit; text-align: left;
  transition: background var(--t-fast);
}
.user-chip:hover { background: var(--side-bg-2); }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center; font-size: 12px; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
  overflow: hidden; object-fit: cover;
}
.user-chip .who { flex: 1; min-width: 0; }
.user-chip .who b { display: block; font-size: 12.5px; font-weight: 600; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip .who small { display: block; font-size: 11px; color: var(--side-text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
body.sidebar-collapsed .user-chip { justify-content: center; }
body.sidebar-collapsed .user-chip .who, body.sidebar-collapsed .user-chip .chev { display: none; }

/* Main column */
.main-col {
  flex: 1; min-width: 0; margin-left: var(--sidebar-w);
  display: flex; flex-direction: column;
  transition: margin-left var(--t);
}
body.sidebar-collapsed .main-col { margin-left: var(--sidebar-w-collapsed); }

.topbar {
  position: sticky; top: 0; z-index: 40; height: var(--topbar-h); flex-shrink: 0;
  display: flex; align-items: center; gap: 10px; padding: 0 20px;
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.crumbs { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted); min-width: 0; }
.crumbs b { color: var(--text); font-weight: 650; }
.crumbs .sep { color: var(--muted-2); }
.topbar .spacer { flex: 1; }

.omni {
  display: flex; align-items: center; gap: 8px;
  height: 32px; padding: 0 9px 0 11px; min-width: 210px;
  border: 1px solid var(--border); border-radius: var(--r);
  background: var(--surface-2); color: var(--muted);
  font-family: inherit; font-size: 13px; cursor: pointer;
  transition: all var(--t-fast);
}
.omni:hover { border-color: var(--border-2); background: var(--surface); box-shadow: var(--sh-sm); }
.omni .omni-label { flex: 1; text-align: left; }
@media (max-width: 720px) { .omni .omni-label, .omni kbd { display: none; } .omni { min-width: 0; width: 32px; padding: 0; justify-content: center; } }

.main {
  flex: 1; padding: 24px 24px 96px;
  width: 100%; max-width: 1320px; margin: 0 auto;
}
.main.wide { max-width: none; }
@media (max-width: 720px) { .main { padding: 16px 14px 96px; } }

.page-head { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head .titles { flex: 1; min-width: 200px; }
.page-title { font-size: 21px; font-weight: 700; letter-spacing: -0.02em; }
.page-sub { color: var(--muted); font-size: 13px; margin-top: 3px; max-width: 72ch; }
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* Mobile: sidebar becomes an overlay drawer. */
.scrim {
  position: fixed; inset: 0; background: var(--overlay); z-index: 55;
  opacity: 0; pointer-events: none; transition: opacity var(--t);
  backdrop-filter: blur(2px);
}
.scrim.open { opacity: 1; pointer-events: auto; }
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); width: var(--sidebar-w); box-shadow: var(--sh-xl); }
  body.sidebar-open .sidebar { transform: translateX(0); }
  body.sidebar-collapsed .sidebar { width: var(--sidebar-w); }
  .main-col, body.sidebar-collapsed .main-col { margin-left: 0; }
  body.sidebar-collapsed .nav-item { justify-content: flex-start; padding: 8px 10px; }
  body.sidebar-collapsed .nav-item .nav-label, body.sidebar-collapsed .nav-count { display: block; }
  body.sidebar-collapsed .nav-item::after { display: none; }
  body.sidebar-collapsed .sidebar-head .brand-text { display: block; }
  body.sidebar-collapsed .nav-group-label { opacity: 1; height: auto; padding: 12px 10px 6px; }
  body.sidebar-collapsed .user-chip { justify-content: flex-start; }
  body.sidebar-collapsed .user-chip .who { display: block; }
}
@media (min-width: 901px) { .menu-btn { display: none; } }

/* --------------------------------------------------------------- components */

/* Stat tiles */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 16px 18px; box-shadow: var(--sh-sm); position: relative; overflow: hidden;
  transition: box-shadow var(--t-fast), transform var(--t-fast);
}
.stat.clickable { cursor: pointer; }
.stat.clickable:hover { box-shadow: var(--sh-md); transform: translateY(-1px); }
.stat-label { font-size: 11.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; display: flex; align-items: center; gap: 6px; }
.stat-label svg { width: 13px; height: 13px; }
.stat-value { font-size: 27px; font-weight: 700; letter-spacing: -0.03em; margin-top: 8px; line-height: 1.1; }
.stat-value small { font-size: 14px; font-weight: 600; color: var(--muted); letter-spacing: 0; }
.stat-meta { font-size: 12px; color: var(--muted); margin-top: 5px; display: flex; align-items: center; gap: 5px; }
.stat-meta .up { color: var(--ok); font-weight: 600; }
.stat-meta .down { color: var(--err); font-weight: 600; }
.stat-spark { position: absolute; right: 0; bottom: 0; left: 0; height: 34px; opacity: 0.5; pointer-events: none; }

/* Progress bar */
.bar { height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--brand-600); border-radius: 99px; transition: width var(--t); }
.bar.ok > i { background: var(--ok); }
.bar.warn > i { background: var(--warn); }
.bar.err > i { background: var(--err); }

/* Toolbar above tables */
.toolbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 12px 16px; border-bottom: 1px solid var(--border); background: var(--surface-2);
}
.toolbar .spacer { flex: 1; }
.search-box { position: relative; flex: 1; min-width: 180px; max-width: 340px; }
.search-box svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--muted-2); pointer-events: none; }
.search-box input { padding-left: 32px; height: 34px; font-size: 13px; }
.search-box .clear {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  border: none; background: none; color: var(--muted); cursor: pointer;
  width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 15px; line-height: 1;
}
.search-box .clear:hover { background: var(--surface-3); color: var(--text); }
.toolbar select, .toolbar .input { height: 34px; font-size: 13px; width: auto; min-width: 120px; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: left; font-size: 11px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.05em;
  padding: 10px 14px; background: var(--surface-2);
  border-bottom: 1px solid var(--border); white-space: nowrap;
  position: sticky; top: 0; z-index: 2;
}
thead th.sortable { cursor: pointer; user-select: none; }
thead th.sortable:hover { color: var(--text); background: var(--surface-3); }
thead th .sort-ind { display: inline-block; width: 12px; margin-left: 3px; opacity: 0.45; }
thead th.sorted .sort-ind { opacity: 1; color: var(--brand-600); }
tbody td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr { transition: background var(--t-fast); }
tbody tr:hover { background: var(--surface-2); }
tbody tr.selected { background: var(--brand-50); }
[data-theme="dark"] tbody tr.selected { background: rgba(99, 102, 241, 0.12); }
tbody tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.actions { text-align: right; white-space: nowrap; }
td.actions .btn { margin-left: 4px; }
.cell-strong { font-weight: 600; color: var(--text); }
.cell-sub { font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.cell-mono { font-family: var(--mono); font-size: 12px; letter-spacing: -0.01em; }
.col-check { width: 38px; }
.col-check input { width: auto; height: auto; }
.row-link { cursor: pointer; }

/* Pagination */
.pager {
  display: flex; align-items: center; gap: 10px; padding: 11px 16px;
  border-top: 1px solid var(--border); background: var(--surface-2); font-size: 12.5px; color: var(--muted);
  flex-wrap: wrap;
}
.pager .spacer { flex: 1; }
.pager select { height: 30px; font-size: 12px; width: auto; min-width: 68px; }

/* Empty + skeleton states */
.empty { padding: 48px 24px; text-align: center; color: var(--muted); }
.empty-icon {
  width: 46px; height: 46px; margin: 0 auto 14px; border-radius: 50%;
  display: grid; place-items: center; background: var(--surface-3); color: var(--muted-2);
}
.empty-icon svg { width: 22px; height: 22px; }
.empty h4 { font-size: 14.5px; font-weight: 650; color: var(--text); margin-bottom: 5px; }
.empty p { font-size: 13px; max-width: 44ch; margin: 0 auto 16px; line-height: 1.6; }

.skel { background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 50%, var(--surface-3) 75%); background-size: 200% 100%; animation: skel 1.3s ease-in-out infinite; border-radius: var(--r-sm); }
@keyframes skel { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.skel-line { height: 11px; margin: 4px 0; }

/* Toasts */
.toasts {
  position: fixed; right: 18px; bottom: 18px; z-index: 300;
  display: flex; flex-direction: column-reverse; gap: 9px; pointer-events: none;
  max-width: min(400px, calc(100vw - 36px));
}
.toast {
  display: flex; align-items: flex-start; gap: 10px; pointer-events: auto;
  padding: 12px 14px; border-radius: var(--r); background: var(--surface);
  border: 1px solid var(--border); border-left: 3px solid var(--muted);
  box-shadow: var(--sh-lg); font-size: 13px; color: var(--text);
  animation: toast-in 0.24s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
.toast.out { animation: toast-out 0.18s ease forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateX(20px) scale(0.96); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateX(20px) scale(0.96); } }
.toast-icon { width: 17px; height: 17px; flex-shrink: 0; margin-top: 1px; }
.toast-body { flex: 1; min-width: 0; }
.toast-body b { display: block; font-weight: 650; margin-bottom: 2px; }
.toast-body span { color: var(--muted); font-size: 12.5px; word-wrap: break-word; }
.toast-close { border: none; background: none; color: var(--muted-2); cursor: pointer; font-size: 16px; line-height: 1; padding: 0 2px; }
.toast-close:hover { color: var(--text); }
.toast.success { border-left-color: var(--ok); } .toast.success .toast-icon { color: var(--ok); }
.toast.error   { border-left-color: var(--err); } .toast.error .toast-icon { color: var(--err); }
.toast.warn    { border-left-color: var(--warn); } .toast.warn .toast-icon { color: var(--warn); }
.toast.info    { border-left-color: var(--info); } .toast.info .toast-icon { color: var(--info); }

/* Modal */
.modal-scrim {
  position: fixed; inset: 0; z-index: 200; background: var(--overlay);
  display: grid; place-items: center; padding: 20px;
  backdrop-filter: blur(3px); animation: fade-in 0.16s ease;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: 100%; max-width: 480px; max-height: calc(100vh - 40px);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-xl); box-shadow: var(--sh-xl);
  display: flex; flex-direction: column; overflow: hidden;
  animation: modal-in 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.15);
}
@keyframes modal-in { from { opacity: 0; transform: translateY(14px) scale(0.97); } to { opacity: 1; transform: none; } }
.modal.lg { max-width: 720px; }
.modal.xl { max-width: 960px; }
.modal-head { display: flex; align-items: flex-start; gap: 12px; padding: 18px 20px 14px; }
.modal-head h3 { font-size: 15.5px; font-weight: 680; letter-spacing: -0.01em; flex: 1; }
.modal-head p { font-size: 13px; color: var(--muted); margin-top: 4px; line-height: 1.55; }
.modal-icon { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; }
.modal-icon svg { width: 17px; height: 17px; }
.modal-icon.danger { background: var(--err-bg); color: var(--err); }
.modal-icon.warn { background: var(--warn-bg); color: var(--warn); }
.modal-icon.info { background: var(--info-bg); color: var(--info); }
.modal-body { padding: 0 20px 4px; overflow-y: auto; flex: 1; }
.modal-foot { display: flex; gap: 9px; justify-content: flex-end; padding: 16px 20px; margin-top: 12px; border-top: 1px solid var(--border); background: var(--surface-2); }
.modal-close { border: none; background: none; color: var(--muted); cursor: pointer; font-size: 20px; line-height: 1; padding: 2px 4px; border-radius: var(--r-sm); }
.modal-close:hover { background: var(--surface-3); color: var(--text); }

/* Slide-over drawer */
.drawer-scrim { position: fixed; inset: 0; z-index: 190; background: var(--overlay); animation: fade-in 0.16s ease; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 195;
  width: min(560px, 100vw); background: var(--surface);
  border-left: 1px solid var(--border); box-shadow: var(--sh-xl);
  display: flex; flex-direction: column;
  animation: drawer-in 0.26s cubic-bezier(0.2, 0.9, 0.3, 1);
}
@keyframes drawer-in { from { transform: translateX(100%); } to { transform: none; } }
.drawer-head { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.drawer-head h3 { font-size: 15.5px; font-weight: 680; flex: 1; letter-spacing: -0.01em; }
.drawer-body { flex: 1; overflow-y: auto; padding: 20px; }
.drawer-foot { padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-2); display: flex; gap: 9px; justify-content: flex-end; flex-shrink: 0; }

/* Definition list used by every detail view */
.dl { display: grid; grid-template-columns: 148px 1fr; gap: 0; font-size: 13px; }
.dl dt { color: var(--muted); padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 12.5px; }
.dl dd { padding: 8px 0; border-bottom: 1px solid var(--border); word-break: break-word; }
.dl dt:last-of-type, .dl dd:last-of-type { border-bottom: none; }
@media (max-width: 560px) { .dl { grid-template-columns: 1fr; } .dl dt { border-bottom: none; padding-bottom: 0; } }

/* Command palette */
.cmdk-scrim {
  position: fixed; inset: 0; z-index: 250; background: var(--overlay);
  backdrop-filter: blur(4px); padding: 12vh 20px 20px;
  display: flex; justify-content: center; align-items: flex-start;
  animation: fade-in 0.14s ease;
}
@media (max-width: 640px) { .cmdk-scrim { padding: 6vh 12px 12px; } }
.cmdk {
  width: 100%; max-width: 620px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--sh-xl); overflow: hidden; display: flex; flex-direction: column;
  max-height: 70vh; animation: modal-in 0.2s cubic-bezier(0.2, 0.9, 0.3, 1.15);
}
.cmdk-input-wrap { display: flex; align-items: center; gap: 11px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.cmdk-input-wrap svg { width: 17px; height: 17px; color: var(--muted); }
.cmdk-input { border: none !important; background: none !important; box-shadow: none !important; font-size: 15px !important; height: auto !important; padding: 0 !important; flex: 1; }
.cmdk-list { overflow-y: auto; padding: 7px; flex: 1; }
.cmdk-group { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted-2); padding: 9px 10px 5px; }
.cmdk-item {
  display: flex; align-items: center; gap: 11px; width: 100%;
  padding: 9px 10px; border: none; border-radius: var(--r); background: none;
  color: var(--text); font-family: inherit; font-size: 13.5px; text-align: left; cursor: pointer;
}
.cmdk-item svg { width: 16px; height: 16px; color: var(--muted); }
.cmdk-item .ci-main { flex: 1; min-width: 0; }
.cmdk-item .ci-main b { font-weight: 550; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmdk-item .ci-main small { color: var(--muted); font-size: 11.5px; }
.cmdk-item mark { background: var(--brand-100); color: var(--brand-700); border-radius: 3px; padding: 0 1px; }
[data-theme="dark"] .cmdk-item mark { background: rgba(99,102,241,0.3); color: var(--brand-400); }
.cmdk-item.active { background: var(--brand-600); color: #fff; }
.cmdk-item.active svg, .cmdk-item.active .ci-main small { color: rgba(255,255,255,0.8); }
.cmdk-item.active mark { background: rgba(255,255,255,0.25); color: #fff; }
.cmdk-item.active kbd { background: rgba(255,255,255,0.15); border-color: rgba(255,255,255,0.25); color: #fff; }
.cmdk-empty { padding: 34px 20px; text-align: center; color: var(--muted); font-size: 13px; }
.cmdk-foot {
  display: flex; align-items: center; gap: 14px; padding: 9px 14px;
  border-top: 1px solid var(--border); background: var(--surface-2);
  font-size: 11.5px; color: var(--muted);
}
.cmdk-foot span { display: flex; align-items: center; gap: 5px; }

/* Dropdown menu */
.menu {
  position: fixed; z-index: 210; min-width: 190px; padding: 5px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); box-shadow: var(--sh-lg);
  animation: modal-in 0.14s ease;
}
.menu button, .menu a {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 10px; border: none; border-radius: var(--r-sm); background: none;
  color: var(--text); font-family: inherit; font-size: 13px; text-align: left;
  cursor: pointer; text-decoration: none;
}
.menu button:hover, .menu a:hover { background: var(--surface-3); text-decoration: none; }
.menu button svg, .menu a svg { width: 15px; height: 15px; color: var(--muted); }
.menu .sep { height: 1px; background: var(--border); margin: 5px 0; }
.menu .menu-label { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted-2); padding: 7px 10px 4px; }
.menu button.danger { color: var(--err); } .menu button.danger svg { color: var(--err); }
.menu button .check-mark { margin-left: auto; color: var(--brand-600); }

/* Run panel: document picker */
.doc-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; }
.doc-group {
  border: 1px solid var(--border); border-radius: var(--r-lg); padding: 12px 14px;
  background: var(--surface-2); transition: border-color var(--t-fast), background var(--t-fast);
}
.doc-group.has-selection { border-color: var(--brand-400); background: var(--brand-50); }
[data-theme="dark"] .doc-group.has-selection { background: rgba(99,102,241,0.08); border-color: var(--brand-600); }
.doc-group-title {
  font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase;
  letter-spacing: 0.06em; margin-bottom: 7px; display: flex; align-items: center; gap: 6px;
}
.doc-group.has-selection .doc-group-title { color: var(--brand-700); }
[data-theme="dark"] .doc-group.has-selection .doc-group-title { color: var(--brand-400); }

/* Combobox */
.combo { position: relative; }
.combo-results {
  position: absolute; top: calc(100% + 5px); left: 0; right: 0; z-index: 60;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r);
  box-shadow: var(--sh-lg); max-height: min(340px, 45vh); overflow-y: auto; display: none; padding: 5px;
}
.combo-results.open { display: block; }
.combo-option {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  border-radius: var(--r-sm); cursor: pointer; font-size: 13.5px;
}
.combo-option:hover, .combo-option.active { background: var(--brand-600); color: #fff; }
.combo-option .co-main { flex: 1; min-width: 0; }
.combo-option .co-main b { display: block; font-weight: 600; }
.combo-option .co-main small { color: var(--muted); font-size: 11.5px; font-family: var(--mono); }
.combo-option.active .co-main small, .combo-option:hover .co-main small { color: rgba(255,255,255,0.75); }
.combo-option mark { background: var(--brand-100); color: var(--brand-700); border-radius: 3px; }
.combo-option.active mark, .combo-option:hover mark { background: rgba(255,255,255,0.25); color: #fff; }
.combo-empty { padding: 16px 12px; text-align: center; font-size: 13px; color: var(--muted); }

/* Selected-client chips (batch mode) */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px;
  background: var(--surface-3); border: 1px solid var(--border); border-radius: 99px; font-size: 12px;
}
.chip b { font-weight: 600; }
.chip small { color: var(--muted); font-family: var(--mono); font-size: 11px; }
.chip button { border: none; background: none; cursor: pointer; color: var(--muted); font-size: 14px; line-height: 1; padding: 0; }
.chip button:hover { color: var(--err); }

/* Run dock — pinned progress, always visible while a run is in flight */
.dock {
  position: fixed; left: var(--sidebar-w); right: 0; bottom: 0; z-index: 100;
  background: var(--surface); border-top: 1px solid var(--border);
  box-shadow: 0 -8px 28px rgba(15, 23, 42, 0.1);
  animation: dock-in 0.3s cubic-bezier(0.2, 0.9, 0.3, 1);
  transition: left var(--t);
  max-height: 62vh; display: flex; flex-direction: column;
}
body.sidebar-collapsed .dock { left: var(--sidebar-w-collapsed); }
@media (max-width: 900px) { .dock, body.sidebar-collapsed .dock { left: 0; } }
@keyframes dock-in { from { transform: translateY(100%); } to { transform: none; } }
.dock.min .dock-body { display: none; }
.dock-head { display: flex; align-items: center; gap: 12px; padding: 11px 20px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.dock.min .dock-head { border-bottom: none; }
.dock-head .dock-title { font-size: 13.5px; font-weight: 650; display: flex; align-items: center; gap: 8px; }
.dock-head .spacer { flex: 1; }
.dock-body { padding: 16px 20px 18px; overflow-y: auto; }

.steps { display: flex; align-items: center; gap: 4px; }
.step { display: flex; align-items: center; gap: 8px; }
.step-dot {
  width: 25px; height: 25px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center; font-size: 11px; font-weight: 700;
  background: var(--surface-3); color: var(--muted); transition: all var(--t);
}
.step-label { font-size: 12px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.step.active .step-dot { background: var(--brand-600); color: #fff; box-shadow: 0 0 0 4px var(--ring); }
.step.active .step-label { color: var(--text); }
.step.done .step-dot { background: var(--ok); color: #fff; }
.step.done .step-label { color: var(--ok); }
.step-line { flex: 1; height: 2px; background: var(--border); min-width: 12px; border-radius: 99px; }
.step.done + .step-line { background: var(--ok); }
@media (max-width: 720px) { .step-label { display: none; } }

.stage-card { margin-top: 14px; padding: 14px 16px; border-radius: var(--r); background: var(--surface-2); border: 1px solid var(--border); }
.stage-text { font-size: 13.5px; font-weight: 600; display: flex; align-items: center; gap: 9px; }
.stage-tip { font-size: 12.5px; color: var(--muted); margin-top: 6px; min-height: 17px; transition: opacity 0.3s ease; }
.stage-elapsed { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

.milestone {
  margin-top: 14px; padding: 15px 17px; border-radius: var(--r);
  background: var(--ok-bg); border: 1px solid transparent;
  display: flex; align-items: center; gap: 13px;
  animation: modal-in 0.3s ease;
}
.milestone.warn { background: var(--warn-bg); }
.milestone.err { background: var(--err-bg); }
.milestone-icon { width: 32px; height: 32px; border-radius: 50%; background: var(--ok); color: #fff; display: grid; place-items: center; flex-shrink: 0; }
.milestone.warn .milestone-icon { background: var(--warn); }
.milestone.err .milestone-icon { background: var(--err); }
.milestone-body { flex: 1; min-width: 0; }
.milestone-title { font-weight: 680; font-size: 14px; color: var(--text); }
.milestone-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; word-break: break-word; }

/* Batch queue rows inside the dock */
.queue { display: flex; flex-direction: column; gap: 5px; margin-top: 12px; max-height: 240px; overflow-y: auto; }
.queue-row {
  display: flex; align-items: center; gap: 11px; padding: 8px 11px;
  border: 1px solid var(--border); border-radius: var(--r); background: var(--surface-2); font-size: 13px;
}
.queue-row.running { border-color: var(--brand-400); background: var(--brand-50); }
[data-theme="dark"] .queue-row.running { background: rgba(99,102,241,0.1); }
.queue-row.done { opacity: 0.72; }
.queue-row .qn { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 550; }
.queue-row .qs { font-size: 12px; color: var(--muted); }

/* Live view — the automation browser, streamed back as JPEG frames */
.live { margin-top: 14px; }
.live-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; align-items: center; }
.live-tab {
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text-2);
  border-radius: var(--r-sm); padding: 4px 10px; font-family: inherit; font-size: 12px;
  font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}
.live-tab:hover { border-color: var(--border-2); color: var(--text); }
.live-tab.active { background: var(--brand-600); border-color: var(--brand-600); color: #fff; }
.live-tab.closed { opacity: 0.5; }
.live-stage {
  position: relative; background: #0B1120; border: 1px solid var(--border);
  border-radius: var(--r); overflow: hidden; aspect-ratio: 16 / 9;
  display: grid; place-items: center;
}
.live-stage img { width: 100%; height: 100%; object-fit: contain; display: block; }
.live-stage .live-msg { color: var(--muted); font-size: 13px; text-align: center; padding: 20px; }
.live-url {
  font-size: 11px; color: var(--muted); font-family: var(--mono);
  margin-top: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.live-badge {
  position: absolute; top: 8px; left: 8px; z-index: 2;
  background: rgba(15, 23, 42, 0.75); color: #fff; border-radius: 99px;
  padding: 3px 9px; font-size: 11px; font-weight: 600;
  display: flex; align-items: center; gap: 6px; backdrop-filter: blur(4px);
}
.live-badge i { width: 6px; height: 6px; border-radius: 50%; background: #F87171; animation: dot-pulse 1.4s ease-in-out infinite; }

/* Spinner */
.spin { width: 15px; height: 15px; border: 2px solid var(--border-2); border-top-color: var(--brand-600); border-radius: 50%; animation: spin 0.7s linear infinite; flex-shrink: 0; }
.spin.on-brand { border-color: rgba(255,255,255,0.35); border-top-color: #fff; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Logs terminal */
.logs {
  background: #0B1120; color: #CBD5E1; border-radius: var(--r);
  font-family: var(--mono); font-size: 12px; line-height: 1.6;
  padding: 14px 16px; max-height: 62vh; overflow: auto;
  white-space: pre-wrap; word-break: break-word;
}
.logs .lg-err { color: #FCA5A5; }
.logs .lg-warn { color: #FCD34D; }
.logs .lg-ok { color: #86EFAC; }
.logs .lg-time { color: #64748B; }

/* Alerts */
.alert {
  display: flex; align-items: flex-start; gap: 11px; padding: 12px 14px;
  border-radius: var(--r); font-size: 13px; margin-bottom: 14px; line-height: 1.55;
  background: var(--info-bg); color: var(--info-text);
}
.alert svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: 1px; }
.alert.warn { background: var(--warn-bg); color: var(--warn-text); }
.alert.err  { background: var(--err-bg);  color: var(--err-text); }
.alert.ok   { background: var(--ok-bg);   color: var(--ok-text); }
.alert b { font-weight: 680; }
.alert ul { margin: 6px 0 0 16px; }

/* Sparkline / bar chart */
.chart-bars { display: flex; align-items: flex-end; gap: 3px; height: 90px; }
.chart-bars .cb {
  flex: 1; min-width: 2px; background: var(--brand-500); border-radius: 3px 3px 0 0;
  min-height: 2px; position: relative; transition: background var(--t-fast); cursor: default;
}
.chart-bars .cb:hover { background: var(--brand-700); }
.chart-bars .cb.has-fail { background: var(--err); }
.chart-axis { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--muted-2); margin-top: 6px; }

/* Segmented control */
.seg { display: inline-flex; padding: 2px; background: var(--surface-3); border-radius: var(--r); gap: 2px; }
.seg button {
  border: none; background: none; padding: 5px 11px; border-radius: var(--r-sm);
  font-family: inherit; font-size: 12.5px; font-weight: 600; color: var(--muted); cursor: pointer;
  transition: all var(--t-fast);
}
.seg button:hover { color: var(--text); }
.seg button.active { background: var(--surface); color: var(--text); box-shadow: var(--sh-sm); }

/* Scroll pill (standing rule for every scrollable page in this folder) */
.scroll-pill {
  position: fixed; right: 20px; bottom: 20px; z-index: 90;
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--surface); border: 1px solid var(--border); color: var(--muted);
  box-shadow: var(--sh-md); cursor: pointer; display: grid; place-items: center;
  opacity: 0; pointer-events: none; transform: translateY(8px);
  transition: opacity var(--t), transform var(--t), color var(--t-fast), border-color var(--t-fast);
}
.scroll-pill.show { opacity: 1; pointer-events: auto; transform: none; }
.scroll-pill:hover { color: var(--brand-600); border-color: var(--brand-400); }
.scroll-pill svg { width: 18px; height: 18px; transition: transform var(--t); }
.scroll-pill.down svg { transform: rotate(180deg); }
/* Lift clear of the run dock when one is showing. */
body.dock-open .scroll-pill { bottom: 96px; }

/* Import preview */
.import-drop {
  border: 2px dashed var(--border-2); border-radius: var(--r-lg); padding: 30px 20px;
  text-align: center; color: var(--muted); cursor: pointer; transition: all var(--t-fast);
  background: var(--surface-2);
}
.import-drop:hover, .import-drop.over { border-color: var(--brand-500); background: var(--brand-50); color: var(--brand-700); }
[data-theme="dark"] .import-drop:hover, [data-theme="dark"] .import-drop.over { background: rgba(99,102,241,0.08); }
.import-drop svg { width: 26px; height: 26px; margin: 0 auto 10px; }

/* Utility */
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.tight { gap: 6px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-0 { margin-bottom: 0 !important; } .mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; }
.divider { height: 1px; background: var(--border); margin: 16px 0; }
