:root {
  /* Base layers (semi-transparent over gradient bg) */
  --bg: #0a0d13;
  --bg-2: rgba(255, 255, 255, 0.025);
  --bg-3: rgba(255, 255, 255, 0.05);
  --surface-hover: rgba(255, 255, 255, 0.07);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);

  /* Text */
  --text: #eef2f7;
  --muted: #8a93a3;
  --muted-2: #6b7280;

  /* Accent — violet (warmer than blue, distinctive) */
  --accent: #a78bfa;
  --accent-2: #8b5cf6;
  --accent-glow: rgba(167, 139, 250, 0.28);

  /* Domain colors */
  --user: #5eead4;          /* teal */
  --user-bg: rgba(94, 234, 212, 0.08);
  --user-border: rgba(94, 234, 212, 0.2);
  --assistant: var(--accent);
  --tool: #f97316;          /* orange */
  --tool-bg: rgba(249, 115, 22, 0.06);
  --result: #34d399;        /* green */
  --warn: #f87171;
  --thinking: #c084fc;
  --code-bg: #0a0d13;

  /* Fonts — Geist for sans (modern technical, distinct from Inter/Roboto/system).
     JetBrains Mono for code & IDs. */
  --font-sans: 'Geist', -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Helvetica, Arial, sans-serif;
  --font-mono: 'Geist Mono', 'JetBrains Mono', ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  /* Shadow */
  --shadow-md: 0 8px 24px -8px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 20px 60px -20px rgba(0, 0, 0, 0.6), 0 8px 24px -12px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 15px/1.55 var(--font-sans);
  color: var(--text);
  background: radial-gradient(ellipse at top, #131822 0%, #0a0d13 60%) fixed;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  background: rgba(10, 13, 19, 0.7);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  z-index: 10;
}
.topbar-zone {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.topbar-zone.topbar-right { margin-left: auto; }
.nav-group {
  display: inline-flex;
  gap: 2px;
  margin-left: 4px;
  padding-left: 12px;
  border-left: 1px solid var(--border);
}

/* Hamburger button — only shown on mobile */
.hamburger {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.hamburger:hover { background: var(--bg-2); color: var(--text); }
.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.01em;
  color: var(--text);
  margin-right: 4px;
}
.brand::before {
  content: '';
  display: inline-block;
  width: 18px;
  height: 18px;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--accent), #f97316);
  box-shadow: 0 4px 12px -2px var(--accent-glow);
  transition: background 0.3s, box-shadow 0.3s;
}
/* S4 — system-state dot: color the brand square by overall health.
   Driven by data-overall on <html> from system-state.js. */
html[data-overall="ok"]       .brand::before { background: linear-gradient(135deg, #22c55e, #16a34a); box-shadow: 0 4px 12px -2px rgba(34, 197, 94, 0.4); }
html[data-overall="degraded"] .brand::before { background: linear-gradient(135deg, #facc15, #ca8a04); box-shadow: 0 4px 12px -2px rgba(202, 138, 4, 0.45); }
html[data-overall="down"]     .brand::before { background: linear-gradient(135deg, #ef4444, #dc2626); box-shadow: 0 4px 12px -2px rgba(220, 38, 38, 0.55); }
html[data-overall="unknown"]  .brand::before { background: linear-gradient(135deg, #6b7280, #4b5563); box-shadow: none; }

/* S4 — thin top strip when system is non-ok. Visible on every page so the
   alarm follows the user across navigation. */
html[data-overall="degraded"] body::before,
html[data-overall="down"]     body::before {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 3px;
  z-index: 100;
  pointer-events: none;
}
html[data-overall="degraded"] body::before { background: #ca8a04; }
html[data-overall="down"]     body::before { background: #dc2626; box-shadow: 0 0 12px rgba(220, 38, 38, 0.6); }

/* S7 — nav divider between Status / Tools / Config groups. */
.nav-divider {
  display: inline-block;
  width: 1px;
  height: 18px;
  background: var(--border);
  margin: 0 6px;
  flex-shrink: 0;
}
.topbar label {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  font-size: 12px;
  color: var(--muted);
}
.topbar label.check { color: var(--text); }
.topbar label.check input { margin: 0; }

/* Compact mode: hide thinking, collapse tool results, skip session-init pill */
body.compact .thinking { display: none; }
body.compact .tool-result > pre.code { display: none; }
body.compact .tool-result.expanded > pre.code { display: block; }
.tool-result .tr-summary { cursor: pointer; color: var(--muted); font-size: 12px; margin-top: 4px; user-select: none; }
.tool-result .tr-summary:hover { color: var(--text); }
body:not(.compact) .tool-result .tr-summary { display: none; }
body.compact .system-pill.session-init { display: none; }

/* Tool group — pill-style summary, expandable */
details.tool-group {
  margin: 8px 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-2);
  width: fit-content;
  max-width: 100%;
}
details.tool-group[open] { width: auto; }
details.tool-group > summary.tg-summary {
  cursor: pointer;
  list-style: none;
  padding: 8px 16px;
  color: var(--muted);
  font-size: 12px;
  font-family: var(--font-mono);
  user-select: none;
  border-radius: 10px;
}
details.tool-group > summary.tg-summary::-webkit-details-marker { display: none; }
details.tool-group > summary.tg-summary:hover { color: var(--text); background: var(--bg-3); }
details.tool-group[open] > summary.tg-summary { border-bottom: 1px solid var(--border); border-radius: 10px 10px 0 0; }
details.tool-group .tg-body { padding: 10px 14px; }
details.tool-group .tg-body > .tool-use:first-child,
details.tool-group .tg-body > .tool-result:first-child { margin-top: 0; }
details.tool-group .tg-body > .tool-use:last-child,
details.tool-group .tg-body > .tool-result:last-child { margin-bottom: 0; }

.topbar select,
.topbar button {
  background: var(--bg-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px 12px;
  font: 13px var(--font-sans);
  outline: none;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.topbar select { min-width: 200px; }
.topbar button:hover { background: var(--bg-3); border-color: var(--border-strong); }
.topbar select:hover { background: var(--bg-3); }
.status {
  margin-left: auto;
  font-size: 12px;
  color: var(--muted);
  min-width: 90px;
  text-align: right;
}
.status.live { color: #2da44e; }
.status.error { color: var(--warn); }

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 0;
}

.sidebar {
  background: rgba(255, 255, 255, 0.01);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 6px;
  display: flex;
  flex-direction: column;
}
.sidebar-head {
  display: flex;
  justify-content: space-between;
  padding: 10px 12px 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted-2);
  position: sticky;
  top: 0;
  background: transparent;
  z-index: 1;
}
.files { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 2px; }
.files li {
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: background 0.12s;
}
.files li:hover { background: var(--bg-2); }
.files li.active {
  background: var(--surface-hover);
  box-shadow: inset 2px 0 0 var(--accent);
}
.files .file-name {
  font-size: 13px;
  color: var(--text);
  word-break: break-word;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
}
.files .file-meta {
  font-size: 12px;
  color: var(--muted-2);
  display: flex;
  gap: 10px;
}
.files .file-meta span:first-child { font-family: var(--font-mono); }

.main {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.msg-head {
  padding: 16px 24px 12px;
  border-bottom: 1px solid var(--border);
  background: transparent;
}
.msg-title {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.02em;
  margin-bottom: 4px;
  word-break: break-all;
}
.muted { color: var(--muted); font-size: 12px; }

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 22px 20px 28px;
  scroll-behavior: smooth;
  /* Block-level scroll container. Children center via `margin-left/right: auto`
     below — using flex + align-items: center here breaks vertical overflow
     when a single child is taller than the container. */
}
/* Center all conversation entries on the same axis as the floating composer.
   Entries fill the column up to 820px; system pills keep their compact size. */
.messages > .entry,
.messages > details.tool-group,
.messages > .system-pill,
.messages > .hint {
  margin-left: auto;
  margin-right: auto;
}
.messages > .entry,
.messages > details.tool-group {
  max-width: 820px;
}
/* Extra bottom padding only when a floating composer follows. */
.main:has(.composer-wrap) .messages { padding-bottom: 130px; }
.hint {
  color: var(--muted);
  text-align: center;
  margin-top: 60px;
  font-size: 13px;
}

.entry {
  max-width: 820px;
  margin: 0 0 14px 0;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg-2);
  overflow: hidden;
}
.entry-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  background: transparent;
  font-size: 12px;
  border-bottom: 1px solid var(--border);
}
.entry-head .badge {
  font-weight: 600;
  font-size: 10px;
  padding: 4px 8px;
  border-radius: 999px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.b-user { background: var(--user-bg); color: var(--user); border: 1px solid var(--user-border); }
.b-assistant { background: rgba(167, 139, 250, 0.12); color: var(--accent); border: 1px solid rgba(167, 139, 250, 0.24); }
.b-tool { background: var(--tool-bg); color: var(--tool); border: 1px solid rgba(249, 115, 22, 0.24); }
.b-result { background: rgba(52, 211, 153, 0.1); color: var(--result); border: 1px solid rgba(52, 211, 153, 0.24); }
.b-thinking { background: rgba(192, 132, 252, 0.12); color: var(--thinking); border: 1px solid rgba(192, 132, 252, 0.24); }
.b-system { background: var(--bg-3); color: var(--muted); }
.b-error { background: rgba(248, 113, 113, 0.12); color: var(--warn); border: 1px solid rgba(248, 113, 113, 0.24); }
.entry-head .ts { color: var(--muted-2); font-family: var(--font-mono); font-size: 11px; }
.entry-head .spacer { flex: 1; }
.entry-head .model { color: var(--muted-2); font-size: 11px; font-family: var(--font-mono); }

.entry-body { padding: 14px 18px; }
.text-block { word-wrap: break-word; line-height: 1.5; }
.text-block + .text-block { margin-top: 8px; }
.md p { margin: 0 0 8px 0; }
.md p:last-child { margin-bottom: 0; }
.md h1, .md h2, .md h3, .md h4, .md h5, .md h6 {
  margin: 12px 0 6px 0;
  font-weight: 700;
  line-height: 1.25;
}
.md h1 { font-size: 18px; }
.md h2 { font-size: 16px; }
.md h3 { font-size: 14px; }
.md h4, .md h5, .md h6 { font-size: 13px; color: var(--muted); }
.md ul { margin: 4px 0 8px 0; padding-left: 22px; }
.md li { margin: 2px 0; }
.md code {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  font: 13px ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color: #f0d169;
}
.md pre.md-code { margin: 6px 0; max-height: 400px; }
.md a { color: var(--accent); text-decoration: none; }
.md a:hover { text-decoration: underline; }
.md strong { color: #f5f7fa; }
.md em { color: #d6dde6; }

.thinking {
  padding: 10px 14px;
  margin: 8px 0;
  background: rgba(192, 132, 252, 0.05);
  border: 1px solid rgba(192, 132, 252, 0.18);
  border-radius: 10px;
  font-style: italic;
  color: #d6c2ff;
  white-space: pre-wrap;
  font-size: 13px;
}

.tool-use {
  padding: 10px 14px;
  margin: 8px 0;
  background: var(--tool-bg);
  border: 1px solid rgba(249, 115, 22, 0.18);
  border-radius: 10px;
}
.tool-use .tool-name {
  font-weight: 600;
  color: var(--tool);
  margin-bottom: 4px;
  font-family: var(--font-mono);
  font-size: 13px;
}
.tool-result {
  padding: 10px 14px;
  margin: 8px 0;
  background: rgba(52, 211, 153, 0.05);
  border: 1px solid rgba(52, 211, 153, 0.18);
  border-radius: 10px;
}
.tool-result .tr-head {
  font-size: 11px;
  color: var(--result);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}
.tool-result.is-error {
  background: rgba(248, 113, 113, 0.05);
  border-color: rgba(248, 113, 113, 0.22);
}
.tool-result.is-error .tr-head { color: var(--warn); }

pre.code {
  background: var(--code-bg);
  border: 1px solid var(--border);
  padding: 10px 12px;
  border-radius: 10px;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 6px 0;
  font: 12px var(--font-mono);
  color: #cad3df;
  max-height: 360px;
  overflow: auto;
}
details.collapsible > summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 12px;
  padding: 4px 0;
  user-select: none;
}
details.collapsible > summary:hover { color: var(--text); }

.system-pill {
  /* `display: flex` (not inline-flex) so `margin: auto` works for horizontal
     centering within the messages column. `width: max-content` keeps it compact. */
  display: flex;
  align-items: center;
  gap: 6px;
  width: max-content;
  max-width: 100%;
  padding: 4px 12px;
  font-size: 11px;
  color: var(--muted);
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  margin: 8px 0;
}
.system-pill::before {
  content: '';
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--result);
  box-shadow: 0 0 5px var(--result);
}
.system-pill.warn {
  color: var(--warn);
  border-color: rgba(248, 113, 113, 0.3);
  background: rgba(248, 113, 113, 0.06);
}
.system-pill.warn::before { background: var(--warn); box-shadow: 0 0 5px var(--warn); }

/* ---------- Composer (floating card) ---------- */
.composer-wrap {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: 16px 20px 20px;
  background: linear-gradient(to top, #0a0d13 30%, rgba(10, 13, 19, 0.85) 70%, transparent);
  pointer-events: none;
  z-index: 5;
}
.composer {
  pointer-events: auto;
  max-width: 820px;
  margin: 0 auto;
  background: linear-gradient(180deg, rgba(36, 42, 56, 0.85), rgba(26, 32, 44, 0.85));
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  box-shadow: 0 16px 48px -20px rgba(0, 0, 0, 0.7), 0 4px 16px -8px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: border-color 0.18s, box-shadow 0.18s;
}
.composer:focus-within {
  border-color: rgba(110, 168, 254, 0.55);
  box-shadow: 0 16px 48px -20px rgba(0, 0, 0, 0.7), 0 0 0 4px rgba(110, 168, 254, 0.08);
}
.composer textarea {
  display: block;
  width: 100%;
  resize: none;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--text);
  padding: 14px 16px 6px;
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
  min-height: 56px;
  max-height: 240px;
}
.composer textarea::placeholder { color: var(--muted); }

.composer-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px 10px;
}
.composer-hint {
  margin-right: auto;
  font-size: 11px;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.kbd {
  display: inline-block;
  padding: 1px 5px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 4px;
  font: 11px ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color: var(--muted);
  line-height: 1.3;
}
.composer button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 0;
  border-radius: 10px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.08s, box-shadow 0.15s, background 0.15s;
}
.composer button.send-btn {
  background: linear-gradient(135deg, var(--accent), #4f8fef);
  color: white;
  box-shadow: 0 4px 12px -4px rgba(110, 168, 254, 0.4);
}
.composer button.send-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px -4px rgba(110, 168, 254, 0.5);
}
.composer button.send-btn:active { transform: translateY(0); }
.composer button.ghost-btn {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  font-weight: 500;
}
.composer button.ghost-btn:hover:not(:disabled) {
  background: var(--bg-3);
  color: var(--text);
  border-color: var(--border-strong, rgba(255, 255, 255, 0.18));
}
.composer button:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

/* Pad message thread so the floating composer doesn't cover the last entry */
.main { position: relative; }

/* ---------- nav link + schedules page ---------- */
.nav-link {
  color: var(--muted);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  transition: color 0.15s, background 0.15s;
}
.nav-link:hover { color: var(--text); background: var(--bg-3); }
.nav-link.active { color: var(--text); background: var(--surface-hover); }
/* Visited distinction for body content links (not nav — nav uses .active).
   Subtle text-shadow under the link signals "you've been here". */
main a:visited:not(.nav-link):not(.active) {
  color: var(--muted);
  text-decoration-color: var(--muted);
}

.sched-actions { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.sched-actions button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white;
  border: 0;
  padding: 8px 16px;
  border-radius: 10px;
  font: 600 13px var(--font-sans);
  cursor: pointer;
  box-shadow: 0 4px 12px -4px var(--accent-glow);
  transition: transform 0.08s, box-shadow 0.15s;
}
.sched-actions button:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px -4px var(--accent-glow);
}
.sched-actions button:active { transform: translateY(0); }
.sched-actions button.ghost {
  background: var(--bg-2);
  color: var(--muted);
  border: 1px solid var(--border);
  font-weight: 500;
  box-shadow: none;
}
.sched-actions button.ghost:hover {
  background: var(--bg-3);
  color: var(--text);
  border-color: var(--border-strong);
  transform: none;
}
.sched-actions button.danger {
  background: var(--bg-2);
  color: var(--warn);
  border: 1px solid rgba(248, 113, 113, 0.3);
  font-weight: 500;
  box-shadow: none;
}
.sched-actions button.danger:hover {
  background: rgba(248, 113, 113, 0.1);
  transform: none;
}

.sec-h {
  margin: 18px 0 8px;
  font-size: 11px;
  color: var(--muted-2);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

table.runs {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
table.runs th, table.runs td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
table.runs tr:last-child td { border-bottom: 0; }
table.runs th {
  color: var(--muted-2);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: rgba(255, 255, 255, 0.015);
}
table.runs td.result-cell {
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-style: italic;
}
table.runs tr.err { background: rgba(248, 113, 113, 0.04); }
table.runs tr.run-row { cursor: pointer; transition: background 0.12s; }
table.runs tr.run-row:hover { background: var(--bg-3); }
table.runs tr.run-row .caret {
  display: inline-block;
  transition: transform 0.15s;
  color: var(--muted-2);
  font-size: 10px;
  width: 12px;
}
table.runs tr.run-row.expanded .caret { transform: rotate(90deg); color: var(--accent); }
table.runs tr.run-detail-row > td {
  padding: 0;
  background: rgba(0, 0, 0, 0.2);
  border-bottom: 1px solid var(--border);
}
table.runs tr.processed-row { cursor: pointer; transition: background 0.12s; }
table.runs tr.processed-row:hover { background: var(--bg-3); }
table.runs tr.processed-row .caret {
  display: inline-block;
  transition: transform 0.15s;
  color: var(--muted-2);
  font-size: 10px;
  width: 12px;
}
table.runs tr.processed-row.expanded .caret { transform: rotate(90deg); color: var(--accent); }
table.runs tr.processed-detail-row > td {
  padding: 0;
  background: rgba(0, 0, 0, 0.2);
  border-bottom: 1px solid var(--border);
}
.run-detail { padding: 16px 22px; }
.run-detail-meta {
  font-size: 12px;
  margin-bottom: 12px;
  font-family: var(--font-mono);
  color: var(--muted-2);
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.run-detail-meta a { color: var(--accent); text-decoration: none; }
.run-detail-meta a:hover { text-decoration: underline; }
pre.code.is-error {
  border-color: rgba(248, 113, 113, 0.3);
  background: rgba(248, 113, 113, 0.06);
  color: #fecaca;
}

/* Markdown tables (rendered by md.js) */
.md-table-wrap {
  max-width: 100%;
  overflow-x: auto;
  margin: 10px 0;
}
.md-table-wrap > .md-table { margin: 0; }
.md-table {
  border-collapse: separate;
  border-spacing: 0;
  margin: 10px 0;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.md-table th, .md-table td {
  padding: 6px 12px;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}
.md-table tr:last-child td { border-bottom: 0; }
.md-table th:last-child, .md-table td:last-child { border-right: 0; }
.md-table th {
  background: var(--bg-3);
  color: var(--text);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.md-table tr:nth-child(even) td { background: rgba(255, 255, 255, 0.015); }
.tag {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 6px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.tag-ok {
  background: rgba(52, 211, 153, 0.12);
  color: var(--result);
  border: 1px solid rgba(52, 211, 153, 0.25);
}
.tag-err {
  background: rgba(248, 113, 113, 0.12);
  color: var(--warn);
  border: 1px solid rgba(248, 113, 113, 0.25);
}
.tag-running {
  background: rgba(167, 139, 250, 0.14);
  color: var(--accent);
  border: 1px solid rgba(167, 139, 250, 0.30);
  animation: tagPulse 1.4s ease-in-out infinite;
}
@keyframes tagPulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.55; }
}
table.runs tr.run-row.running { cursor: default; }
table.runs tr.run-row.running .caret { color: var(--accent); animation: tagPulse 1.4s ease-in-out infinite; }
/* "cron" pill on sidebar entries — warmer than tag-ok for distinction */
.files .file-name .tag.tag-ok {
  background: rgba(249, 115, 22, 0.12);
  color: var(--tool);
  border: 1px solid rgba(249, 115, 22, 0.25);
}
.tag-tz {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--bg-3);
  color: var(--muted);
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-weight: 500;
}
#cronPreview {
  white-space: pre-wrap;
  font-size: 12px;
  line-height: 1.6;
  color: var(--muted);
  padding: 8px 10px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  font-family: var(--font-mono);
}
#cronPreview.warn {
  color: var(--warn);
  background: rgba(248, 113, 113, 0.05);
  border-color: rgba(248, 113, 113, 0.2);
}
.dot { font-size: 9px; }
.dot-on { color: var(--result); }
.dot-off { color: var(--muted-2); }
.files .file-meta .mono { font-family: var(--font-mono); }
.files .file-meta .warn { color: var(--warn); }
.good { color: var(--result); }

/* Deep-link to /gmail/<msg_id> from anywhere (Jobs page, processed list) */
.msg-id-link {
  color: var(--accent);
  text-decoration: none;
  font-family: var(--font-mono);
  cursor: pointer;
}
.msg-id-link:hover { text-decoration: underline; }

/* Modal */
.modal {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.6);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  animation: modalFade 0.15s ease-out;
}
@keyframes modalFade { from { opacity: 0; } to { opacity: 1; } }
.modal.hidden { display: none; }
.modal-card {
  background: linear-gradient(180deg, rgba(36, 42, 56, 0.95), rgba(20, 25, 35, 0.95));
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  padding: 22px 24px;
  min-width: 480px;
  max-width: 640px;
  box-shadow: var(--shadow-lg);
}
.modal-card h3 {
  margin: 0 0 16px;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.modal-card form { display: flex; flex-direction: column; gap: 12px; }
.modal-card label {
  display: flex; flex-direction: column; gap: 5px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}
.modal-card label.check {
  flex-direction: row; align-items: center; gap: 8px;
  color: var(--text);
  font-weight: normal;
}
.modal-card input[type=text],
.modal-card textarea {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  padding: 8px 12px;
  font: 13px var(--font-mono);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.modal-card input[type=text]:focus,
.modal-card textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.12);
}
.modal-card textarea {
  font: 13px/1.5 var(--font-sans);
  resize: vertical;
}
.modal-card code {
  background: var(--code-bg);
  border: 1px solid var(--border);
  padding: 1px 5px;
  border-radius: 4px;
  font: 12px var(--font-mono);
  color: #f0d169;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}
.modal-actions button {
  padding: 8px 16px;
  border-radius: 10px;
  font: 600 13px var(--font-sans);
  cursor: pointer;
  border: 0;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white;
  box-shadow: 0 4px 12px -4px var(--accent-glow);
  transition: transform 0.08s, box-shadow 0.15s;
}
.modal-actions button:hover { transform: translateY(-1px); box-shadow: 0 6px 16px -4px var(--accent-glow); }
.modal-actions button:active { transform: translateY(0); }
.modal-actions button.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  font-weight: 500;
  box-shadow: none;
}
.modal-actions button.ghost:hover {
  background: var(--bg-2);
  color: var(--text);
  border-color: var(--border-strong);
  transform: none;
}

.hint-inline { padding: 8px 0; }
.status.live { color: var(--accent); }
.status.ok { color: var(--result); }
.status.error { color: var(--warn); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.08); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.16); }

/* ---------- A11y: universal focus ring ---------- */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: inherit;
}
button:focus-visible,
.nav-link:focus-visible,
select:focus-visible,
input[type="checkbox"]:focus-visible {
  outline-offset: 2px;
}
.files li:focus-visible {
  outline-offset: -2px;
  outline-style: solid;
}

/* Nav-link icons + button icons — flex alignment for the new SVGs */
.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.topbar button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* ---------- A11y: reduced motion ---------- */
@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;
  }
}

/* ---------- A11y: touch target sizing ---------- */
@media (pointer: coarse) {
  /* Bump interactive elements to 44px min on touch devices */
  .nav-link, .topbar button:not(.hamburger), .sched-actions button {
    min-height: 40px;
    padding-top: 8px;
    padding-bottom: 8px;
  }
  .hamburger { min-width: 44px; min-height: 44px; }
  .files li { min-height: 48px; padding-top: 12px; padding-bottom: 12px; }
  .composer button { min-height: 40px; }
  /* Modal close/save buttons also bigger */
  .modal-actions button { min-height: 40px; }
}

/* ---------- Mobile responsive ---------- */
@media (max-width: 768px) {
  /* Topbar wraps to a second row at narrow viewports so the nav has its own
     full-width scroll strip and isn't squeezed between brand and controls. */
  .topbar {
    padding: 10px 14px;
    gap: 10px;
    flex-wrap: wrap;
  }
  .topbar-center { display: none; }
  .topbar-right .check, .topbar-right #sessionIdLabel { display: none; }
  .topbar-left {
    flex: 1 1 100%;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 8px;
  }
  .topbar-right {
    flex: 1 1 100%;
    justify-content: flex-end;
  }
  .nav-group {
    padding-left: 0;
    margin-left: 0;
    flex: 1 1 auto;
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
  }
  .nav-link { flex-shrink: 0; }
  .nav-link .nav-label { display: none; }
  .hamburger { display: inline-flex; }

  /* Topbar floats above the drawer so hamburger is always tappable. */
  .topbar { z-index: 30; }

  /* Layout: single column. Sidebar becomes slide-in drawer. */
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(85vw, 320px);
    /* Drawer covers full viewport; topbar (z-index 30) stays visible above
       via its own stacking. Inner content starts below topbar via padding. */
    padding-top: 64px;
    border-right: 1px solid var(--border-strong);
    background: rgba(13, 17, 25, 0.96);
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
    transform: translateX(-100%);
    transition: transform 0.2s ease-out;
    z-index: 20;
    box-shadow: var(--shadow-lg);
  }
  body.sidebar-open .sidebar { transform: translateX(0); }
  body.sidebar-open::after {
    /* Backdrop overlay — covers entire viewport. Topbar (z-index 30) sits
       above it so hamburger remains clickable to close the drawer. */
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 15;
    cursor: pointer;
  }

  /* Composer takes full width on mobile */
  .composer-wrap { padding: 12px 14px 14px; }
  .composer { max-width: 100%; border-radius: 14px; }
  .composer-actions { flex-wrap: wrap; gap: 8px; }
  .composer-hint { width: 100%; order: -1; margin-right: 0; margin-bottom: 4px; }

  /* Messages: less side padding */
  .messages { padding: 18px 14px 120px; }
  .entry { border-radius: 14px; }

  /* Modal: full-width on phone */
  .modal-card { min-width: auto; width: calc(100vw - 32px); max-width: none; padding: 18px; }

  /* Schedule page: action buttons wrap */
  .sched-actions { gap: 6px; }
  .sched-actions button { font-size: 12px; padding: 6px 10px; }
  table.runs { font-size: 11px; }
  table.runs th, table.runs td { padding: 8px; }
  table.runs td.result-cell { max-width: 140px; }
}

/* Smaller phones */
@media (max-width: 480px) {
  /* S3 — Mobile chrome compression. Brand collapses to the dot (no text),
     nav stays on the same row, controls wrap below. Goal: get to data in
     2 rows of chrome max. */
  .brand { font-size: 0; gap: 0; margin-right: 0; }
  .brand::before { width: 16px; height: 16px; }
  .nav-group { gap: 4px; padding-left: 4px; }
  .topbar { padding: 8px 12px; gap: 8px; }
  .topbar-right { gap: 6px; }
  .topbar-right button span { display: none; }  /* icon-only buttons */
}

/* ---------- Freshness chip (CR1) ---------- */
.freshness {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid;
  vertical-align: baseline;
}
.freshness.is-live  { background: rgba(22, 163, 74, 0.10); border-color: rgba(22, 163, 74, 0.35); color: #4ade80; }
.freshness.is-warn  { background: rgba(202, 138, 4, 0.10); border-color: rgba(202, 138, 4, 0.35); color: #fbbf24; }
.freshness.is-stale { background: rgba(220, 38, 38, 0.10); border-color: rgba(220, 38, 38, 0.35); color: #f87171; }

.hero-date { color: var(--text); font-weight: 600; }

/* ---------- Light theme ----------
   Activated via `<html data-theme="light">` (toggled by the theme button).
   Default (no attribute) stays dark to preserve existing look. */
html[data-theme="light"] {
  --bg: #f7f8fa;
  --bg-2: rgba(15, 23, 42, 0.04);
  --bg-3: rgba(15, 23, 42, 0.07);
  --surface-hover: rgba(15, 23, 42, 0.09);
  --border: rgba(15, 23, 42, 0.10);
  --border-strong: rgba(15, 23, 42, 0.18);

  --text: #1a1f2c;
  --muted: #5b6473;
  --muted-2: #7a8493;

  --accent: #7c3aed;
  --accent-2: #6d28d9;
  --accent-glow: rgba(124, 58, 237, 0.22);

  --user: #0d9488;
  --user-bg: rgba(13, 148, 136, 0.10);
  --user-border: rgba(13, 148, 136, 0.28);
  --assistant: var(--accent);
  --tool: #c2410c;
  --tool-bg: rgba(194, 65, 12, 0.08);
  --result: #047857;
  --warn: #b91c1c;
  --thinking: #7e22ce;
  --code-bg: #f1f3f7;

  --shadow-md: 0 8px 24px -10px rgba(15, 23, 42, 0.18);
  --shadow-lg: 0 20px 60px -20px rgba(15, 23, 42, 0.22), 0 8px 24px -12px rgba(15, 23, 42, 0.14);
}

html[data-theme="light"] body {
  background: radial-gradient(ellipse at top, #ffffff 0%, #eef1f6 60%) fixed;
}
html[data-theme="light"] .topbar {
  background: rgba(255, 255, 255, 0.78);
}
html[data-theme="light"] .sidebar {
  background: rgba(15, 23, 42, 0.02);
}
html[data-theme="light"] .composer {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(245, 247, 251, 0.95));
  border-color: rgba(15, 23, 42, 0.14);
}
html[data-theme="light"] .composer-wrap {
  background: linear-gradient(to top, #f7f8fa 30%, rgba(247, 248, 250, 0.85) 70%, transparent);
}
html[data-theme="light"] .composer button.send-btn {
  background: linear-gradient(135deg, var(--accent), #4f8fef);
  color: #fff;
}
html[data-theme="light"] .md code { color: #b45309; }
html[data-theme="light"] .modal {
  background: rgba(15, 23, 42, 0.35);
}
html[data-theme="light"] .modal-card {
  background: linear-gradient(180deg, #ffffff, #f5f7fb);
}
html[data-theme="light"] .modal-card code { color: #b45309; }
html[data-theme="light"] body.sidebar-open .sidebar {
  background: rgba(255, 255, 255, 0.97);
}
html[data-theme="light"] table.runs th { background: rgba(15, 23, 42, 0.03); }
html[data-theme="light"] table.runs tr.run-detail-row > td { background: rgba(15, 23, 42, 0.03); }
html[data-theme="light"] table.runs tr.processed-detail-row > td { background: rgba(15, 23, 42, 0.03); }
html[data-theme="light"] .md-table tr:nth-child(even) td { background: rgba(15, 23, 42, 0.025); }
html[data-theme="light"] pre.code.is-error { color: #7f1d1d; }
html[data-theme="light"] .thinking { color: #5b21b6; }
html[data-theme="light"] .md strong { color: #0f172a; }
html[data-theme="light"] .md em { color: #334155; }
html[data-theme="light"] pre.code { color: #1f2937; }
html[data-theme="light"] ::-webkit-scrollbar-thumb { background: rgba(15, 23, 42, 0.18); }
html[data-theme="light"] ::-webkit-scrollbar-thumb:hover { background: rgba(15, 23, 42, 0.30); }

/* Theme toggle button — icon swaps via CSS so no JS needs to touch innerHTML. */
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: inline-block; }
html[data-theme="light"] .theme-toggle .icon-sun { display: inline-block; }
html[data-theme="light"] .theme-toggle .icon-moon { display: none; }

/* Ensure [hidden] wins over flex display rules */
[hidden] { display: none !important; }

/* ---------- Schedules: system badge + kind form ---------- */
.sys-badge {
  display: inline-block;
  background: #e0e7ff; color: #4338ca;
  font-size: 10px; font-weight: 600;
  padding: 2px 6px; border-radius: 4px;
  margin-left: 6px; text-transform: uppercase;
  vertical-align: middle;
}
html[data-theme="light"] .sys-badge { background: #e0e7ff; color: #4338ca; }
/* Dark mode: invert to indigo-900 bg */
:not(html[data-theme="light"]) .sys-badge { background: rgba(67, 56, 202, 0.25); color: #a5b4fc; }

.radio-group {
  display: flex; gap: 16px; align-items: center;
  padding: 4px 0;
}
.modal-card label.radio {
  flex-direction: row; align-items: center; gap: 6px;
  color: var(--text); font-weight: normal; font-size: 13px;
  cursor: pointer;
}
.modal-card label.radio input[type=radio] { margin: 0; cursor: pointer; }

.modal-card .form-section {
  display: flex; flex-direction: column; gap: 12px;
  padding: 12px; border-radius: 10px;
  background: var(--bg-2); border: 1px solid var(--border);
}
.modal-card select {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  padding: 8px 12px;
  font: 13px var(--font-sans);
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
}
.modal-card select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.12);
}
.modal-card input[type=date] {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  padding: 8px 12px;
  font: 13px var(--font-mono);
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
}
.modal-card input[type=date]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.12);
}
/* View report link in run table */
a.view-report { color: var(--accent); text-decoration: none; font-size: 12px; }
a.view-report:hover { text-decoration: underline; }

/* ======================================================================
   Schedule Run Detail — tabbed inline expand (scoped to .run-detail)
   ====================================================================== */

/* Status pills — OK / WARN / CRITICAL / running */
.run-detail .run-status-badge {
  padding: 4px 10px; border-radius: 4px; font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.run-detail .status-OK       { background: rgba(4, 120, 87, 0.15);  color: #34d399; border: 1px solid rgba(167, 243, 208, 0.3); }
.run-detail .status-WARN     { background: rgba(146, 64, 14, 0.15); color: #fbbf24; border: 1px solid rgba(252, 211, 77, 0.3); }
.run-detail .status-CRITICAL { background: rgba(153, 27, 27, 0.15); color: #f87171; border: 1px solid rgba(252, 165, 165, 0.3); }
.run-detail .status-running  { background: rgba(55, 48, 163, 0.15); color: #a5b4fc; }
.run-detail .status-error    { background: rgba(153, 27, 27, 0.15); color: #f87171; border: 1px solid rgba(252, 165, 165, 0.3); }

/* Run meta header */
.run-detail .run-header-row {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; padding: 10px 14px;
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: 8px; margin-bottom: 8px;
}
.run-detail .run-header-row .run-meta { color: var(--muted); font-size: 12px; }

/* Tabs */
.run-detail .tabs {
  display: flex; gap: 4px; border-bottom: 2px solid var(--border);
  margin: 8px 0 14px;
}
.run-detail .tab {
  padding: 7px 13px; cursor: pointer; font-size: 13px; font-weight: 500;
  color: var(--muted); border-bottom: 2px solid transparent;
  margin-bottom: -2px; user-select: none; border-radius: 4px 4px 0 0;
  transition: color 0.12s;
}
.run-detail .tab:hover { color: var(--text); }
.run-detail .tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* Tab panels */
.run-detail .run-tab-panel { padding: 4px 0 12px; }

/* AI narrative */
.run-detail .narrative-header { font-size: 15px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.run-detail .narrative-summary { font-size: 13px; color: var(--text); margin: 0 0 4px; }
.run-detail .word-count-hint { font-size: 11px; color: var(--muted); margin-bottom: 10px; }
.run-detail .narrative-detail { font-size: 13px; }

/* Legend for baseline chips */
.run-detail .legend {
  display: flex; gap: 14px; font-size: 11px; color: var(--muted); margin-bottom: 8px;
}
.run-detail .legend .swatch {
  display: inline-block; width: 12px; height: 12px; border-radius: 2px;
  vertical-align: middle; margin-right: 4px;
}
.run-detail .swatch-trim  { background: rgba(52, 211, 153, 0.35); }
.run-detail .swatch-raw   { background: rgba(167, 139, 250, 0.25); }
.run-detail .swatch-excl  { background: rgba(248, 113, 113, 0.35); }

/* Steps table */
.run-detail table.steps {
  width: 100%; border-collapse: collapse; font-size: 12px;
}
.run-detail table.steps th,
.run-detail table.steps td {
  padding: 7px 9px; border-bottom: 1px solid var(--border);
  text-align: left; vertical-align: top;
}
.run-detail table.steps th { font-weight: 600; color: var(--muted); font-size: 11px; }
.run-detail table.steps tr.step-row { cursor: pointer; }
.run-detail table.steps tr.step-row:hover { background: var(--bg-2); }
.run-detail table.steps tr.step-row.step-expanded { background: var(--bg-2); }

/* Step status pills */
.run-detail .pill {
  display: inline-block; padding: 2px 7px; border-radius: 10px;
  font-size: 10px; font-weight: 600; text-transform: uppercase;
}
.run-detail .pill-PASS   { background: rgba(4, 120, 87, 0.18);  color: #34d399; }
.run-detail .pill-ALERT  { background: rgba(146, 64, 14, 0.18); color: #fbbf24; }
.run-detail .pill-FAIL   { background: rgba(153, 27, 27, 0.18); color: #f87171; }
.run-detail .pill-OK     { background: rgba(4, 120, 87, 0.18);  color: #34d399; }
.run-detail .pill-ok     { background: rgba(4, 120, 87, 0.18);  color: #34d399; }
.run-detail .pill-alert  { background: rgba(146, 64, 14, 0.18); color: #fbbf24; }
.run-detail .pill-error  { background: rgba(153, 27, 27, 0.18); color: #f87171; }
.run-detail .delta-positive { color: #34d399; }
.run-detail .delta-negative { color: #f87171; }

/* Step detail expand row */
.run-detail tr.step-detail-row td {
  background: var(--bg-3); padding: 12px 16px;
}
.run-detail .step-detail-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
}
.run-detail .step-detail-grid h4 {
  margin: 0 0 6px; font-size: 11px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.5px;
}
.run-detail .baseline-values {
  font-family: var(--font-mono); font-size: 11px; line-height: 1.6;
}
.run-detail .baseline-values .val {
  display: inline-block; padding: 2px 5px; margin: 1px 2px;
  background: rgba(167, 139, 250, 0.15); border-radius: 3px; color: var(--text);
}
.run-detail .baseline-values .val.trimmed {
  background: rgba(52, 211, 153, 0.2); color: #34d399;
}
.run-detail .baseline-values .val.excluded {
  background: rgba(248, 113, 113, 0.15); color: #f87171;
  text-decoration: line-through;
}
.run-detail .why-alert {
  background: rgba(146, 64, 14, 0.12); border-left: 3px solid #fbbf24;
  padding: 8px 12px; border-radius: 4px; font-size: 12px; color: #fcd34d;
  margin-bottom: 10px;
}
.run-detail .why-pass {
  background: rgba(4, 120, 87, 0.12); border-left: 3px solid #34d399;
  padding: 8px 12px; border-radius: 4px; font-size: 12px; color: #6ee7b7;
  margin-bottom: 10px;
}
.run-detail .alert-details ul { margin: 6px 0 0 18px; padding: 0; }
.run-detail .alert-details li { margin-bottom: 2px; font-size: 12px; }

/* Execution log panel */
.run-detail .log-block {
  background: #0d1117; color: #c9d1d9;
  font-family: var(--font-mono); font-size: 11px;
  padding: 12px 14px; border-radius: 6px; border: 1px solid var(--border);
  max-height: 320px; overflow-y: auto; line-height: 1.6;
}
.run-detail .log-block .log-time { color: #6b7280; }
.run-detail .log-block .log-info { color: #58a6ff; }
.run-detail .log-block .log-warning { color: #e3b341; }
.run-detail .log-block .log-warn { color: #e3b341; }
.run-detail .log-block .log-error { color: #f85149; }
.run-detail .log-block .log-critical { color: #f85149; font-weight: bold; }

/* Raw JSON panel */
.run-detail pre.code { max-height: 380px; overflow: auto; }

/* Schedule notifications form section */
.form-section-title { margin: 0 0 8px; font-size: 13px; font-weight: 600; }
.form-row { margin-bottom: 12px; }
.form-row > label:first-child { display: block; font-size: 12px; font-weight: 500; color: var(--muted); margin-bottom: 4px; }
.inline-check { display: inline-flex; gap: 6px; align-items: center; margin-bottom: 6px; font-size: 13px; }
.field-disabled { opacity: 0.6; background: var(--code-bg, #0a0d13); cursor: not-allowed; }
.hint-inline {
  font-size: 11px;
  margin-top: 2px;
  word-break: break-all;
  overflow-wrap: anywhere;
  max-width: 100%;
  /* Cap to 2 lines worst-case; tooltip via title= reveals the rest */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ======================================================================
   Compare findings table (run-detail Findings chi tiết tab)
   ====================================================================== */

.run-detail table.findings {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-top: 12px;
}
.run-detail table.findings th {
  text-align: left;
  padding: 6px 8px;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.run-detail table.findings td {
  padding: 8px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.run-detail table.findings tr.finding-row:hover { background: var(--bg-2); }
.run-detail .finding-title { line-height: 1.4; }
.run-detail .finding-row .small { font-size: 12px; margin-top: 2px; }

/* Severity pills for compare findings — scoped to .run-detail to avoid collision */
.run-detail .pill-P1      { background: rgba(153, 27, 27, 0.22);  color: #fca5a5; }
.run-detail .pill-P2      { background: rgba(146, 64, 14, 0.22);  color: #fcd34d; }
.run-detail .pill-P3      { background: rgba(67, 56, 202, 0.22);  color: #a5b4fc; }
.run-detail .pill-ROUTINE { background: rgba(4, 120, 87, 0.18);   color: #34d399; }
.run-detail .pill-INFO    { background: rgba(255, 255, 255, 0.07); color: var(--muted); }

/* ===================================================================
   Job type tabs (above sidebar in /jobs)
   =================================================================== */
.job-tabs {
  display: flex;
  gap: 2px;
  padding: 8px 12px 0;
  background: var(--surface, var(--bg));
  border-bottom: 1px solid var(--border, rgba(255,255,255,0.08));
  flex-shrink: 0;
}
.job-tab {
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: color 0.15s;
}
.job-tab:hover {
  color: var(--text);
}
.job-tab.active {
  color: var(--accent, #2563eb);
  border-bottom-color: var(--accent, #2563eb);
}
.job-tab .tab-count {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 8px;
  background: rgba(255,255,255,0.06);
  color: var(--muted);
}
.job-tab.active .tab-count {
  background: rgba(37, 99, 235, 0.18);
  color: var(--accent, #2563eb);
}
[data-theme="light"] .job-tabs {
  background: var(--bg);
  border-bottom-color: var(--border, #e5e7eb);
}
[data-theme="light"] .job-tab .tab-count {
  background: #f3f4f6;
  color: #6b7280;
}
[data-theme="light"] .job-tab.active .tab-count {
  background: #dbeafe;
  color: var(--accent, #2563eb);
}

/* ─── Tabbed modal (used by email rule edit) ──────────────────── */
.modal-card-tabbed {
  max-width: 720px;
  max-height: 88vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.modal-card-tabbed h3 { margin-bottom: 8px; }
.modal-tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border, #e5e7eb);
  margin: 0 -24px 14px;
  padding: 0 20px;
}
.modal-tab {
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted, #6b7280);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  transition: color 0.12s, border-color 0.12s;
}
.modal-tab:hover { color: var(--text); }
.modal-tab.active {
  color: var(--accent, #2563eb);
  border-bottom-color: var(--accent, #2563eb);
}
.modal-tab-panel { display: flex; flex-direction: column; gap: 12px; }
.modal-tab-panel[hidden] { display: none; }

/* 2-column form grid */
.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 640px) {
  .form-grid-2 { grid-template-columns: 1fr; }
}

/* Make label-with-checkbox align with select-y siblings in 2-col rows */
.inline-check-aligned {
  align-self: end;
  padding-bottom: 8px;
}
.lbl-strong {
  font-weight: 600;
  color: var(--text, #1f2937);
  font-size: 13px;
}
