/* ============================================================
   log-stream UI — Fluent 2 design tokens
   Default is light (Teams default). Dark via [data-theme="dark"]
   on <html>, set by base.html from prefers-color-scheme OR
   Teams SDK getContext().theme (hooked in Stage B).
   ============================================================ */

:root {
  /* ---- Fluent brand (Communication Blue) ---- */
  --brand-10: #061724;
  --brand-20: #082338;
  --brand-30: #0a2e4a;
  --brand-40: #0c3b5e;
  --brand-50: #0e4775;
  --brand-60: #0f548c;
  --brand-70: #115ea3;
  --brand-80: #0f6cbd;  /* primary */
  --brand-90: #2886de;
  --brand-100: #479ef5;
  --brand-110: #62abf5;
  --brand-120: #77b7f7;
  --brand-130: #96c6fa;
  --brand-140: #b4d6fa;
  --brand-150: #cfe4fa;
  --brand-160: #ebf3fc;

  /* ---- Semantic ---- */
  --success: #107c10;
  --success-bg: #dff6dd;
  --success-border: #9fd89f;
  --danger: #c4314b;
  --danger-bg: #fde7e9;
  --danger-border: #eeacb2;
  --warning: #9d5d00;
  --warning-bg: #fff4ce;
  --warning-border: #fbd089;

  /* ---- Radii ---- */
  --r-sm: 2px;
  --r-md: 4px;
  --r-lg: 6px;
  --r-xl: 8px;
  --r-circular: 9999px;

  /* ---- Spacing ---- */
  --s-xxs: 2px;
  --s-xs: 4px;
  --s-s:  8px;
  --s-m:  12px;
  --s-l:  16px;
  --s-xl: 20px;
  --s-xxl: 24px;

  /* ---- Shadows (Fluent depth) ---- */
  --depth-2: 0 0 2px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.14);
  --depth-4: 0 0 2px rgba(0,0,0,0.12), 0 2px 4px rgba(0,0,0,0.14);
  --depth-8: 0 0 2px rgba(0,0,0,0.12), 0 4px 8px rgba(0,0,0,0.14);
  --depth-16: 0 0 2px rgba(0,0,0,0.12), 0 8px 16px rgba(0,0,0,0.14);

  /* ---- Type ---- */
  --font-family: "Segoe UI", "Segoe UI Web (West European)",
                 -apple-system, BlinkMacSystemFont, "Helvetica Neue",
                 "Hiragino Sans", "Yu Gothic UI", "Meiryo", sans-serif;
  --font-mono: "Cascadia Mono", "Cascadia Code", ui-monospace,
               "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --fs-100: 10px; --fs-200: 12px; --fs-300: 14px;
  --fs-400: 16px; --fs-500: 20px; --fs-600: 24px;
  --lh-300: 20px; --lh-400: 22px; --lh-500: 28px;

  /* ---- Light neutrals (default) ---- */
  --bg: #ffffff;
  --bg-alt: #faf9f8;
  --panel: #ffffff;
  --panel-alt: #f5f5f5;
  --panel-hover: #f0f0f0;
  --input-bg: #ffffff;
  --border: #e1dfdd;
  --border-strong: #bdbdbd;
  --text: #242424;
  --text-secondary: #616161;
  --text-muted: #8a8886;
  --text-disabled: #bdbdbd;
  --accent: var(--brand-80);
  --accent-hover: var(--brand-70);
  --accent-text: #ffffff;
  --link: var(--brand-70);
  --link-hover: var(--brand-60);
  --code-bg: #f5f5f5;
  --row-hover: #f5f5f5;
  --scrim: rgba(0,0,0,0.4);
}

[data-theme="dark"] {
  --bg: #1f1f1f;
  --bg-alt: #141414;
  --panel: #292929;
  --panel-alt: #242424;
  --panel-hover: #333333;
  --input-bg: #1f1f1f;
  --border: #3d3d3d;
  --border-strong: #666666;
  --text: #ffffff;
  --text-secondary: #d1d1d1;
  --text-muted: #adadad;
  --text-disabled: #5c5c5c;
  --accent: var(--brand-100);
  --accent-hover: var(--brand-120);
  --accent-text: #0b0b0b;
  --link: var(--brand-100);
  --link-hover: var(--brand-120);
  --code-bg: #141414;
  --row-hover: #2e2e2e;
  --success-bg: #0a2e0a;
  --success-border: #154d15;
  --danger-bg: #3b1219;
  --danger-border: #6b1e2a;
  --warning-bg: #3b2c0a;
  --warning-border: #6b4e15;
  --depth-2: 0 0 2px rgba(0,0,0,0.24), 0 1px 2px rgba(0,0,0,0.28);
  --depth-4: 0 0 2px rgba(0,0,0,0.24), 0 2px 4px rgba(0,0,0,0.28);
  --depth-8: 0 0 2px rgba(0,0,0,0.24), 0 4px 8px rgba(0,0,0,0.28);
}

[data-theme="contrast"] {
  --bg: #000000;
  --panel: #000000;
  --panel-alt: #000000;
  --border: #ffffff;
  --border-strong: #ffffff;
  --text: #ffffff;
  --text-secondary: #ffffff;
  --text-muted: #ffffff;
  --accent: #ffff00;
  --accent-hover: #ffff00;
  --accent-text: #000000;
  --link: #ffff00;
  --input-bg: #000000;
  --code-bg: #000000;
}

/* ============================================================
   Base
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg); color: var(--text);
  font-family: var(--font-family);
  font-size: var(--fs-300);
  line-height: var(--lh-400);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--link);
  text-decoration: none;
  border-radius: var(--r-sm);
}
a:hover { color: var(--link-hover); text-decoration: underline; }
a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

code {
  font-family: var(--font-mono);
  font-size: 0.92em;
  background: var(--code-bg);
  padding: 1px 6px;
  border-radius: var(--r-sm);
  color: var(--text);
}
small { color: var(--text-secondary); font-size: var(--fs-200); }

h1 { font-size: var(--fs-500); font-weight: 600; margin: 0 0 var(--s-m); color: var(--text); }
h2 { font-size: var(--fs-400); font-weight: 600; margin: var(--s-xl) 0 var(--s-s); color: var(--text); }
h3 { font-size: var(--fs-300); font-weight: 600; margin: var(--s-l) 0 var(--s-xs); color: var(--text); }

/* ============================================================
   Shell (header / main / footer)
   ============================================================ */
header {
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  padding: 0 var(--s-xl);
  display: flex; align-items: center; gap: var(--s-xxl);
  height: 48px;
  box-shadow: var(--depth-2);
  position: sticky; top: 0; z-index: 10;
}
.brand {
  font-weight: 600; font-size: var(--fs-400);
  color: var(--accent);
  letter-spacing: -0.01em;
  display: flex; align-items: center; gap: var(--s-s);
}
.brand::before {
  content: ""; width: 20px; height: 20px; border-radius: var(--r-md);
  background: linear-gradient(135deg, var(--brand-80), var(--brand-100));
  display: inline-block;
}
nav { display: flex; gap: var(--s-xs); }
nav a {
  color: var(--text-secondary);
  padding: 6px 12px;
  border-radius: var(--r-md);
  font-weight: 600; font-size: var(--fs-300);
  text-decoration: none;
  transition: background 0.1s, color 0.1s;
}
nav a:hover { background: var(--panel-hover); color: var(--text); text-decoration: none; }
nav a.active { background: var(--brand-160); color: var(--brand-70); }
[data-theme="dark"] nav a.active { background: rgba(71,158,245,0.16); color: var(--brand-100); }

main { padding: var(--s-xl); max-width: 1600px; margin: 0 auto; }
footer {
  padding: var(--s-m) var(--s-xl);
  color: var(--text-muted); font-size: var(--fs-200);
  border-top: 1px solid var(--border);
  margin-top: var(--s-xxl);
  text-align: center;
}

/* ============================================================
   Cards / panels (Fluent "Card")
   ============================================================ */
.card, .filters, .tl-form, .case-form, .alias-form, .corr,
.admin section, .case .meta pre {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s-l);
  box-shadow: var(--depth-2);
}

/* ============================================================
   Inputs (Fluent Input / Textarea / Select / Combobox)
   ============================================================ */
input, select, textarea, button {
  font-family: inherit; font-size: var(--fs-300);
}
input[type="text"], input[type="search"], input[type="number"],
input[type="date"], input[type="email"], input[type="password"],
select, textarea {
  width: 100%;
  padding: 5px 10px;
  min-height: 32px;
  background: var(--input-bg);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-bottom: 1px solid var(--text-secondary);
  border-radius: var(--r-md);
  transition: border-color 0.1s;
}
input:hover, select:hover, textarea:hover {
  border-color: var(--text-secondary);
  border-bottom-color: var(--text);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--border-strong);
  border-bottom: 2px solid var(--accent);
  padding-bottom: 4px;
}
textarea {
  font-family: var(--font-mono);
  font-size: var(--fs-200);
  resize: vertical;
  min-height: 60px;
  line-height: 1.5;
}
input::placeholder, textarea::placeholder { color: var(--text-muted); }
input[type="checkbox"] {
  width: 16px; height: 16px; min-height: auto;
  accent-color: var(--accent);
  margin: 0 var(--s-xs) 0 0;
}

label {
  display: block;
  margin-bottom: var(--s-s);
  font-size: var(--fs-200);
  color: var(--text-secondary);
  font-weight: 600;
}
label input, label select, label textarea { margin-top: 4px; }

fieldset { border: none; padding: 0; margin: 0 0 var(--s-l); }
legend {
  font-weight: 600;
  color: var(--text-secondary);
  font-size: var(--fs-200);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--s-s);
  padding: 0;
}

/* ============================================================
   Buttons (Fluent Button)
   ============================================================ */
button, .btn {
  font-family: inherit;
  font-size: var(--fs-300);
  font-weight: 600;
  padding: 5px 12px;
  min-height: 32px;
  border-radius: var(--r-md);
  border: 1px solid var(--border-strong);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s, color 0.1s;
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px;
  text-decoration: none;
  white-space: nowrap;
}
button:hover, .btn:hover {
  background: var(--panel-hover);
  border-color: var(--text-secondary);
  text-decoration: none;
}
button:active, .btn:active { background: var(--panel-alt); }
button[disabled], button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  background: var(--panel);
  color: var(--text-disabled);
  border-color: var(--border);
}

button.primary, .btn.primary {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
}
button.primary:hover, .btn.primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: var(--accent-text);
}
button.primary:disabled { background: var(--border); border-color: var(--border); color: var(--text-disabled); }

button.danger, .btn.danger {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: var(--danger-border);
}
button.danger:hover, .btn.danger:hover {
  background: var(--danger);
  color: #ffffff;
  border-color: var(--danger);
}

button.subtle {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
}
button.subtle:hover { background: var(--panel-hover); border-color: transparent; color: var(--text); }

/* ============================================================
   Search page layout
   ============================================================ */
.layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: var(--s-l);
  align-items: flex-start;
}
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
}
.filters fieldset { margin: 0 0 var(--s-l); }
.filters fieldset:last-of-type { margin-bottom: var(--s-m); }
.filters label { margin-bottom: var(--s-s); }

.filter-row {
  display: grid;
  grid-template-columns: 1fr 96px 1fr 28px;
  gap: var(--s-xs);
  margin-bottom: var(--s-xs);
}
.filter-row button {
  padding: 0;
  min-height: 32px;
  background: transparent;
  border: none;
  color: var(--text-muted);
}
.filter-row button:hover { color: var(--danger); background: transparent; }

/* ============================================================
   Results table (Fluent DataGrid vibe)
   ============================================================ */
.results { min-height: 220px; }
.stats {
  padding: 10px var(--s-m);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  font-size: var(--fs-200);
  color: var(--text-secondary);
  display: flex; align-items: center; gap: var(--s-s);
  flex-wrap: wrap;
}
.stats strong { color: var(--text); font-weight: 600; }
.stats .export {
  margin-left: auto;
  color: var(--accent);
  font-weight: 600;
}
.stats .export:hover { text-decoration: underline; }

.table-scroll {
  max-height: calc(100vh - 260px);
  overflow: auto;
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--r-lg) var(--r-lg);
  background: var(--panel);
}
.results-table {
  border-collapse: collapse;
  width: 100%;
  font-size: var(--fs-200);
}
.results-table thead {
  position: sticky; top: 0; z-index: 1;
  background: var(--panel-alt);
}
.results-table th {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  font-weight: 600;
  white-space: nowrap;
  font-size: var(--fs-200);
}
.results-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  max-width: 480px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.results-table tbody tr:hover td { background: var(--row-hover); }

.hint {
  color: var(--text-secondary);
  padding: var(--s-xl);
  text-align: center;
  font-size: var(--fs-300);
}

/* ============================================================
   MessageBar (error / success)
   ============================================================ */
.err, .ok {
  padding: 10px 14px;
  border-radius: var(--r-md);
  margin: 0 0 var(--s-m);
  font-size: var(--fs-300);
  display: flex; align-items: center; gap: var(--s-s);
  border: 1px solid;
}
.err { background: var(--danger-bg); border-color: var(--danger-border); color: var(--danger); }
.err::before { content: "⊗"; font-weight: 700; }
.ok { background: var(--success-bg); border-color: var(--success-border); color: var(--success); }
.ok::before { content: "✓"; font-weight: 700; }

/* ============================================================
   SQL panel
   ============================================================ */
.sql {
  margin-top: var(--s-m);
  padding: var(--s-s) var(--s-m);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.sql summary { cursor: pointer; color: var(--text-secondary); font-size: var(--fs-200); font-weight: 600; }
.sql summary:hover { color: var(--text); }
.sql pre {
  margin: var(--s-s) 0 0;
  padding: var(--s-m);
  background: var(--code-bg);
  color: var(--text);
  font-size: var(--fs-200);
  font-family: var(--font-mono);
  overflow-x: auto;
  border-radius: var(--r-md);
  line-height: 1.5;
}

/* ============================================================
   HTMX
   ============================================================ */
.htmx-indicator {
  opacity: 0;
  transition: opacity 0.2s;
  display: inline-block;
  margin-left: var(--s-s);
}
.htmx-request .htmx-indicator { opacity: 1; }

/* ============================================================
   Timeline
   ============================================================ */
.timeline h1 .mode {
  font-size: var(--fs-200);
  background: var(--brand-160);
  color: var(--brand-70);
  padding: 2px 10px;
  border-radius: var(--r-circular);
  margin-left: var(--s-s);
  vertical-align: middle;
  font-weight: 600;
}
[data-theme="dark"] .timeline h1 .mode { background: rgba(71,158,245,0.16); color: var(--brand-100); }
.timeline h1 .mode.forensic {
  background: var(--danger-bg); color: var(--danger);
}

.tl-form {
  margin-bottom: var(--s-l);
  display: flex; flex-direction: column; gap: var(--s-m);
}
.tl-form .row {
  display: flex;
  gap: var(--s-m);
  align-items: flex-end;
  flex-wrap: wrap;
}
.tl-form .row > label { flex: 0 0 auto; margin: 0; }
.tl-form label.check {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: var(--s-xs);
  color: var(--text);
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  font-size: var(--fs-300);
}
.tl-form button { height: 32px; }

.tl-list {
  list-style: none; padding: 0; margin: 0;
  border-left: 2px solid var(--border);
  margin-left: 6px;
}
.tl-item {
  position: relative;
  padding: 10px var(--s-m) 10px var(--s-l);
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
.tl-item:hover { background: var(--row-hover); }
.tl-item::before {
  content: "";
  position: absolute;
  left: -7px; top: 16px;
  width: 10px; height: 10px;
  background: var(--accent);
  border-radius: 50%;
  border: 2px solid var(--bg);
}
.tl-item time {
  display: inline-block;
  width: 230px;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  font-size: var(--fs-200);
  font-family: var(--font-mono);
}

/* Badges / chips */
.tl-item .lt {
  display: inline-block;
  min-width: 96px;
  padding: 2px 10px;
  margin-right: var(--s-s);
  background: var(--brand-160);
  color: var(--brand-70);
  border-radius: var(--r-circular);
  font-size: var(--fs-100);
  font-weight: 600;
  text-align: center;
}
[data-theme="dark"] .tl-item .lt { background: rgba(71,158,245,0.16); color: var(--brand-100); }
.lt-proxy .lt         { background: #dff6dd; color: #0e700e; }
.lt-vpn .lt           { background: #fce8f5; color: #a3267a; }
.lt-lanscope .lt      { background: #deecf9; color: #115ea3; }
.lt-syslog .lt        { background: #fff4ce; color: #9d5d00; }
.lt-file_server .lt   { background: #d5edef; color: #0e6266; }
.lt-print_server .lt  { background: #fde7e9; color: #a02533; }
.lt-face_recognition .lt { background: #efe4f5; color: #6a278a; }
.lt-ad .lt            { background: #fce4d6; color: #8e3a0b; }
[data-theme="dark"] .lt-proxy .lt        { background: rgba(16,124,16,0.2); color: #6ab86a; }
[data-theme="dark"] .lt-vpn .lt          { background: rgba(163,38,122,0.2); color: #e07ed3; }
[data-theme="dark"] .lt-lanscope .lt     { background: rgba(71,158,245,0.16); color: var(--brand-100); }
[data-theme="dark"] .lt-syslog .lt       { background: rgba(157,93,0,0.25); color: #e0bf7e; }
[data-theme="dark"] .lt-file_server .lt  { background: rgba(14,98,102,0.3); color: #7ee0e0; }
[data-theme="dark"] .lt-print_server .lt { background: rgba(160,37,51,0.25); color: #e07e7e; }
[data-theme="dark"] .lt-face_recognition .lt { background: rgba(106,39,138,0.3); color: #bf7ee0; }
[data-theme="dark"] .lt-ad .lt           { background: rgba(142,58,11,0.3); color: #e0a07e; }

.tl-item .flag {
  display: inline-block;
  padding: 1px 8px;
  margin-right: var(--s-xxs);
  border-radius: var(--r-circular);
  font-size: var(--fs-100);
  font-weight: 600;
}
.flag-failed   { background: var(--danger-bg); color: var(--danger); }
.flag-usb      { background: var(--warning-bg); color: var(--warning); }
.flag-large    { background: var(--brand-160); color: var(--brand-70); }
.flag-after    { background: #efe4f5; color: #6a278a; }
.flag-weekend  { background: var(--success-bg); color: var(--success); }
[data-theme="dark"] .flag-large { background: rgba(71,158,245,0.16); color: var(--brand-100); }
[data-theme="dark"] .flag-after { background: rgba(106,39,138,0.3); color: #bf7ee0; }

.tl-item .risk {
  display: inline-block;
  padding: 1px 8px;
  margin-right: var(--s-xxs);
  border-radius: var(--r-circular);
  font-size: var(--fs-200);
  font-weight: 700;
  background: var(--danger-bg);
  color: var(--danger);
}
.r-0 { display: none; }
.r-1 { background: var(--warning-bg); color: var(--warning); }
.r-2 { background: var(--danger-bg); color: var(--danger); }
.r-3 { background: #b30000; color: #ffffff; }
.r-4 { background: #8b0000; color: #ffffff; }

.tl-item .summary { font-size: var(--fs-300); color: var(--text); }

.tl-item .ctx {
  margin-left: var(--s-s);
  font-size: var(--fs-200);
  color: var(--accent);
  text-decoration: none;
  border: 1px solid var(--accent);
  padding: 1px 8px;
  border-radius: var(--r-circular);
}
.tl-item .ctx:hover { background: var(--accent); color: var(--accent-text); text-decoration: none; }

.tl-item .addcase { display: inline-block; margin-left: var(--s-s); }
.tl-item .addcase select {
  font-size: var(--fs-200);
  padding: 2px 8px;
  min-height: 24px;
  width: auto;
  display: inline-block;
}
.tl-item .addcase button {
  font-size: var(--fs-200);
  padding: 2px 10px;
  min-height: 24px;
  background: var(--accent);
  color: var(--accent-text);
  border: none;
}
.tl-item .addcase button[disabled] {
  background: var(--border); color: var(--text-disabled);
}

.tl-item details { margin-top: var(--s-xs); margin-left: 240px; }
.tl-item details summary {
  font-size: var(--fs-200); color: var(--text-secondary); cursor: pointer;
}
.tl-item details summary:hover { color: var(--text); }
.tl-item .raw {
  background: var(--code-bg);
  padding: var(--s-m);
  margin-top: var(--s-xs);
  border-radius: var(--r-md);
  font-size: var(--fs-200);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  line-height: 1.6;
}
.tl-item .raw b { color: var(--text); font-weight: 600; }
.tl-item .raw div { margin-bottom: 2px; }

.corr { margin-bottom: var(--s-m); padding: var(--s-m); }
.corr h3 { margin: 0 0 var(--s-s); color: var(--accent); font-size: var(--fs-300); }
.corr ul { margin: 0; padding-left: var(--s-l); font-size: var(--fs-200); }
.corr li { margin-bottom: var(--s-xs); }
.corr li .lt {
  display: inline-block;
  background: var(--brand-160);
  color: var(--brand-70);
  padding: 0 8px;
  margin-left: var(--s-xs);
  border-radius: var(--r-circular);
  font-size: var(--fs-100);
}

/* ============================================================
   Cases
   ============================================================ */
.cases h2, .case h2, .admin h2, .aliases h2 {
  color: var(--text);
  border-bottom: 1px solid var(--border);
  padding-bottom: var(--s-xs);
}
.case-form, .alias-form {
  display: flex; flex-direction: column; gap: var(--s-m);
  max-width: 780px;
}
.case-form .row, .alias-form .row { display: flex; gap: var(--s-m); }
.case-form .row > label, .alias-form .row > label { flex: 1; margin: 0; }

.case-table, .alias-table, .ev-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-200);
  margin-top: var(--s-s);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.case-table th, .alias-table th, .ev-table th {
  padding: 10px 12px;
  background: var(--panel-alt);
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  font-weight: 600;
  text-align: left;
}
.case-table td, .alias-table td, .ev-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.case-table tr:last-child td,
.alias-table tr:last-child td,
.ev-table tr:last-child td { border-bottom: none; }
.case-table tr:hover td,
.alias-table tr:hover td,
.ev-table tr:hover td { background: var(--row-hover); }
.case-table a { color: var(--link); font-weight: 600; }
.case-table code, .alias-table code {
  margin-right: var(--s-xs);
  color: var(--text);
}

.state-open      { color: var(--success); font-weight: 600; }
.state-closed    { color: var(--text-muted); font-weight: 600; }
.state-ENABLED   { color: var(--success); font-weight: 600; }
.state-DISABLED  { color: var(--text-muted); font-weight: 600; }
.state-Submitted, .state-InProgress { color: var(--accent); font-weight: 600; }
.state-Completed { color: var(--success); font-weight: 600; }
.state-Failed, .state-Stopped { color: var(--danger); font-weight: 600; }

.case h1 .cid {
  font-family: var(--font-mono);
  font-size: var(--fs-200);
  color: var(--text-muted);
  margin-left: var(--s-s);
  font-weight: 400;
}
.case .actions {
  margin: var(--s-m) 0 var(--s-l);
  display: flex; gap: var(--s-s); flex-wrap: wrap;
}
.case .meta { margin-top: var(--s-xxl); color: var(--text-secondary); font-size: var(--fs-200); }
.case .meta pre {
  background: var(--code-bg);
  font-family: var(--font-mono);
  font-size: var(--fs-200);
  padding: var(--s-m);
  border-radius: var(--r-md);
  box-shadow: none;
}

/* ============================================================
   Admin
   ============================================================ */
.admin section { margin: var(--s-xl) 0; }
.settings, .jobs {
  width: 100%;
  border-collapse: collapse;
  margin-top: var(--s-s);
  font-size: var(--fs-300);
}
.settings th, .jobs th, .settings td, .jobs td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}
.settings th, .jobs th {
  background: var(--panel-alt);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: var(--fs-200);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.settings input[type=number], .settings input[type=text] {
  width: 240px;
}
.settings .muted { color: var(--text-secondary); max-width: 380px; font-size: var(--fs-200); }

/* ============================================================
   Teams tab embed tweaks (applied via body.in-teams)
   ============================================================ */
body.in-teams header {
  /* Teams already has its own app chrome; compact our header */
  height: 40px;
  padding: 0 var(--s-l);
  box-shadow: none;
  border-bottom: 1px solid var(--border);
}
body.in-teams main { padding: var(--s-m) var(--s-l); }
body.in-teams footer { padding: var(--s-s) var(--s-l); margin-top: var(--s-m); }
body.in-teams .brand { font-size: var(--fs-300); }
body.in-teams nav a { font-size: var(--fs-200); padding: 4px 10px; }

/* ============================================================
   Utilities
   ============================================================ */
.muted { color: var(--text-muted); }
.mono { font-family: var(--font-mono); }
.hidden { display: none !important; }
