/* ============================================================
   Summon AI Email Intake - dark operations cockpit
   Class names are a contract with assets/js/ai-intake.js.
   ============================================================ */
:root {
  --ai-bg: #0a0a0b;
  --ai-bg-deep: #060607;
  --ai-surface: #161618;
  --ai-surface-muted: #1b1b1e;
  --ai-surface-strong: #212121;
  --ai-hover: rgba(255, 255, 255, 0.045);
  --ai-track: rgba(255, 255, 255, 0.06);

  --ai-border: rgba(255, 255, 255, 0.08);
  --ai-border-light: rgba(255, 255, 255, 0.045);
  --ai-border-hover: rgba(255, 255, 255, 0.16);

  --ai-text-strong: #ffffff;
  --ai-text: #eeeeee;
  --ai-text-muted: #b5b5b5;
  --ai-text-faint: #7c7c80;

  --ai-brand: #7c8aff;
  --ai-brand-strong: #9aa4ff;
  --ai-brand-bg: rgba(124, 138, 255, 0.12);
  --ai-brand-ring: rgba(124, 138, 255, 0.34);

  --ai-blue: #5b9dff;   --ai-blue-bg: rgba(91, 157, 255, 0.13);
  --ai-green: #3fcf6b;  --ai-green-bg: rgba(63, 207, 107, 0.13);
  --ai-amber: #f0b429;  --ai-amber-bg: rgba(240, 180, 41, 0.13);
  --ai-red: #ff6a6a;    --ai-red-bg: rgba(255, 106, 106, 0.13);
  --ai-teal: #2dd4bf;   --ai-teal-bg: rgba(45, 212, 191, 0.13);
  --ai-purple: #b39bff; --ai-purple-bg: rgba(179, 155, 255, 0.13);
  --ai-gray: #9a9aa0;   --ai-gray-bg: rgba(255, 255, 255, 0.06);

  --ai-font: 'SF Pro Display', 'SF Pro Text', -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, system-ui, sans-serif;
  --ai-mono: 'SF Mono', 'JetBrains Mono', ui-monospace, Menlo, Consolas, monospace;

  --ai-radius: 7px;
  --ai-radius-sm: 5px;
  --ai-radius-lg: 9px;
  --ai-radius-xl: 12px;
  --ai-ease: cubic-bezier(0.32, 0.72, 0, 1);
  --ai-shadow: 0 20px 48px -24px rgba(0, 0, 0, 0.85), 0 8px 20px -16px rgba(0, 0, 0, 0.7);
  --ai-shadow-soft: 0 1px 2px rgba(0, 0, 0, 0.4), 0 1px 3px rgba(0, 0, 0, 0.28);
  --ai-shadow-card: 0 14px 38px -24px rgba(0, 0, 0, 0.9), 0 6px 18px -16px rgba(0, 0, 0, 0.82);
}

html, body.ai-root { margin: 0; padding: 0; }
body.ai-root {
  font-family: var(--ai-font);
  font-size: 14px;
  line-height: 1.5;
  letter-spacing: -0.008em;
  color: var(--ai-text);
  background: var(--ai-bg);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
.ai-root *, .ai-root *::before, .ai-root *::after { box-sizing: border-box; }
.ai-root ::selection { background: rgba(124, 138, 255, 0.22); }
.ai-root a { color: var(--ai-brand); text-decoration: none; }
.ai-root ::-webkit-scrollbar { width: 10px; height: 10px; }
.ai-root ::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.18); border-radius: 6px; border: 3px solid var(--ai-bg); }
.ai-root ::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.28); }
.ai-root ::-webkit-scrollbar-track { background: transparent; }

.ai-root :focus-visible {
  outline: 2px solid var(--ai-brand);
  outline-offset: 2px;
  border-radius: var(--ai-radius-sm);
}

@keyframes ai-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
@keyframes ai-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes ai-toast-in { from { transform: translateY(12px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes ai-drawer-in { from { transform: translateX(40px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes ai-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }
@keyframes ai-rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

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

/* ---------------- Shell ---------------- */
.ai-shell { display: flex; min-height: 100dvh; }

.ai-sidebar {
  width: 240px;
  flex: 0 0 240px;
  background: var(--ai-bg);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100dvh;
  padding: 8px;
}
.ai-side-brand { padding: 16px 14px 18px; }
.ai-side-brand strong {
  display: flex; align-items: center; gap: 10px;
  color: var(--ai-text-strong); font-size: 15px; font-weight: 600; letter-spacing: -0.02em;
}
.ai-side-brand strong em { font-style: normal; }
.ai-side-brand strong .ai-brand-mark {
  width: 28px; height: 28px; border-radius: 9px; flex: 0 0 28px;
  background: var(--ai-brand);
  color: #ffffff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; font-style: normal; letter-spacing: 0;
}
.ai-side-brand span.ai-side-org { display: block; margin-top: 3px; margin-left: 38px; color: var(--ai-text-faint); font-size: 12px; }
.ai-side-nav { padding: 4px 6px; flex: 1; overflow-y: auto; }
.ai-side-label {
  padding: 18px 12px 7px;
  font-size: 11px; font-weight: 500; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--ai-text-faint);
}
.ai-side-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; border: 0; background: none; cursor: pointer;
  padding: 9px 12px; margin: 1px 0;
  border-radius: 999px;
  color: var(--ai-text-muted); font: inherit; font-size: 13.5px; font-weight: 500;
  text-align: left;
  transition: background 200ms var(--ai-ease), color 200ms var(--ai-ease);
}
.ai-side-item:hover { background: var(--ai-surface-muted); color: var(--ai-text-strong); }
.ai-side-item.active { background: var(--ai-surface-strong); color: var(--ai-text-strong); font-weight: 600; }
.ai-side-item .ai-side-dot { width: 6px; height: 6px; border-radius: 50%; flex: 0 0 6px; background: #cfd3da; transition: transform 200ms var(--ai-ease); }
.ai-side-item.active .ai-side-dot { transform: scale(1.25); }
.ai-side-item .ai-side-dot.blue { background: var(--ai-blue); }
.ai-side-item .ai-side-dot.amber { background: #dd9a10; }
.ai-side-item .ai-side-dot.red { background: var(--ai-red); }
.ai-side-item .ai-side-dot.green { background: #17a866; }
.ai-side-item .ai-side-dot.teal { background: #14a396; }
.ai-side-count {
  margin-left: auto;
  font-size: 12px; font-weight: 500;
  color: var(--ai-text-faint);
  font-variant-numeric: tabular-nums;
}
.ai-side-item.active .ai-side-count { color: var(--ai-text-strong); font-weight: 600; }
.ai-side-item[disabled] { opacity: 0.45; cursor: default; }
.ai-side-item[disabled]:hover { background: none; color: var(--ai-text-muted); }
.ai-side-hint { margin-left: auto; font-size: 11px; color: var(--ai-text-faint); }
.ai-side-foot { padding: 8px 6px 6px; }
.ai-side-foot a {
  display: block; padding: 8px 12px; border-radius: 999px;
  color: var(--ai-text-muted); font-size: 13px; font-weight: 500;
  transition: background 200ms var(--ai-ease), color 200ms var(--ai-ease);
}
.ai-side-foot a:hover { background: var(--ai-surface-muted); color: var(--ai-text-strong); }

/* ---------------- Main / topbar ---------------- */
.ai-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ai-topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 14px;
  padding: 18px 32px 14px;
  background: rgba(10, 10, 11, 0.82);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
.ai-topbar h1 { margin: 0; font-size: 20px; font-weight: 650; color: var(--ai-text-strong); letter-spacing: -0.025em; }
.ai-topbar .ai-subtitle { margin: 2px 0 0; font-size: 13px; color: var(--ai-text-muted); }
.ai-topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.ai-mode-pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 14px; border-radius: 999px;
  border: 0;
  background: var(--ai-surface-muted);
  font-size: 12.5px; font-weight: 500; color: var(--ai-text-muted);
  white-space: nowrap;
}
.ai-mode-pill .ai-mode-dot { width: 7px; height: 7px; border-radius: 50%; background: #cfd3da; }
.ai-mode-pill.ok { background: var(--ai-green-bg); color: var(--ai-green); }
.ai-mode-pill.ok .ai-mode-dot { background: #17a866; }
.ai-mode-pill.mock { background: var(--ai-amber-bg); color: var(--ai-amber); }
.ai-mode-pill.mock .ai-mode-dot { background: #dd9a10; }
.ai-mode-pill.err { background: var(--ai-red-bg); color: var(--ai-red); }
.ai-mode-pill.err .ai-mode-dot { background: var(--ai-red); animation: ai-pulse 1.6s infinite; }

/* ---------------- Buttons ---------------- */
.ai-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0;
  background: var(--ai-surface-strong);
  color: var(--ai-text-strong);
  font: inherit; font-size: 13px; font-weight: 550;
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 200ms var(--ai-ease), color 200ms var(--ai-ease), transform 120ms var(--ai-ease), opacity 200ms var(--ai-ease);
}
.ai-btn:hover { background: var(--ai-hover); }
.ai-btn:active { transform: scale(0.97); }
.ai-btn:disabled { opacity: 0.45; cursor: default; transform: none; }
.ai-btn.primary { background: var(--ai-brand); color: #ffffff; }
.ai-btn.primary:hover { background: var(--ai-brand-strong); }
.ai-btn.warn { background: var(--ai-amber-bg); color: var(--ai-amber); }
.ai-btn.warn:hover { background: rgba(240, 180, 41, 0.2); }
.ai-btn.good { background: var(--ai-green-bg); color: var(--ai-green); }
.ai-btn.good:hover { background: rgba(63, 207, 107, 0.2); }
.ai-btn.ghost { background: transparent; color: var(--ai-text-muted); }
.ai-btn.ghost:hover { background: var(--ai-surface-muted); color: var(--ai-text-strong); }
.ai-btn.sm { padding: 5px 12px; font-size: 12.5px; }

/* Small round icon button / link (drawer close, open-in-new-tab) */
.ai-iconbtn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; flex: 0 0 34px;
  border: 0; border-radius: 999px;
  background: var(--ai-surface-muted);
  color: var(--ai-text-muted);
  font-size: 15px; line-height: 1; cursor: pointer;
  transition: background 200ms var(--ai-ease), color 200ms var(--ai-ease), transform 120ms var(--ai-ease);
}
.ai-iconbtn:hover { background: var(--ai-surface-strong); color: var(--ai-text-strong); }
.ai-iconbtn:active { transform: scale(0.94); }
.ai-iconbtn svg { width: 15px; height: 15px; }

/* ---------------- Content sections ---------------- */
.ai-content { padding: 10px 32px 64px; display: flex; flex-direction: column; gap: 22px; max-width: 1280px; width: 100%; margin: 0 auto; }

.ai-metrics {
  display: grid;
  grid-template-columns: repeat(6, minmax(130px, 1fr));
  gap: 10px;
}
.ai-metric {
  background: var(--ai-surface);
  border: 1px solid var(--ai-border);
  border-radius: var(--ai-radius-xl);
  padding: 18px 18px 16px;
  min-width: 0;
  cursor: default;
  animation: ai-rise 320ms var(--ai-ease) backwards;
}
.ai-metric:nth-child(2) { animation-delay: 30ms; }
.ai-metric:nth-child(3) { animation-delay: 60ms; }
.ai-metric:nth-child(4) { animation-delay: 90ms; }
.ai-metric:nth-child(5) { animation-delay: 120ms; }
.ai-metric:nth-child(6) { animation-delay: 150ms; }
.ai-metric.clickable { cursor: pointer; transition: background 200ms var(--ai-ease), transform 200ms var(--ai-ease); }
.ai-metric.clickable:hover { background: var(--ai-surface-strong); transform: translateY(-2px); }
.ai-metric-top { display: flex; align-items: center; gap: 8px; }
.ai-metric-icon { display: none; }
.ai-metric-label {
  font-size: 12px; font-weight: 500;
  color: var(--ai-text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ai-metric-value {
  margin-top: 10px;
  font-variant-numeric: tabular-nums;
  font-size: 28px; font-weight: 650; letter-spacing: -0.035em; line-height: 1.05;
  color: var(--ai-text-strong);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ai-metric-value.amber { color: var(--ai-amber); }
.ai-metric-value.red { color: var(--ai-red); }
.ai-metric-value.blue, .ai-metric-value.green, .ai-metric-value.teal, .ai-metric-value.purple { color: var(--ai-text-strong); }
.ai-metric-sub { margin-top: 3px; font-size: 11.5px; color: var(--ai-text-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------------- System status chips ---------------- */
.ai-health { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; }
.ai-health-dot { width: 6px; height: 6px; border-radius: 50%; background: #cfd3da; flex: 0 0 6px; }
.ai-health-dot.green { background: #17a866; }
.ai-health-dot.amber { background: #dd9a10; }
.ai-health-dot.red { background: var(--ai-red); }
.ai-health-dot.blue { background: var(--ai-blue); }
.ai-health {
  background: var(--ai-surface);
  border: 1px solid var(--ai-border);
  border-radius: var(--ai-radius-xl);
  padding: 10px;
}
.ai-sys-chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 13px;
  border-radius: 999px;
  background: var(--ai-surface-muted);
  font-size: 12px; font-weight: 500; color: var(--ai-text-muted);
  white-space: nowrap;
  cursor: default;
  transition: background 200ms var(--ai-ease);
}
.ai-sys-chip:hover { background: var(--ai-surface-strong); }
.ai-sys-chip strong { color: var(--ai-text-strong); font-weight: 550; margin-left: 1px; }

/* ---------------- Signals row ---------------- */
.ai-signals { display: grid; grid-template-columns: repeat(4, minmax(180px, 1fr)); gap: 10px; }
.ai-signal {
  background: var(--ai-surface);
  border: 1px solid var(--ai-border);
  border-radius: var(--ai-radius-xl);
  padding: 16px 18px;
  min-width: 0;
}
.ai-signal h3 {
  margin: 0 0 12px;
  font-size: 12px; font-weight: 550;
  color: var(--ai-text-muted);
}
.ai-signal-empty { font-size: 12.5px; color: var(--ai-text-faint); }

/* Stacked distribution bar + legend */
.ai-dist-bar {
  display: flex; gap: 3px;
  height: 8px; border-radius: 999px; overflow: hidden;
  margin-bottom: 12px;
}
.ai-dist-bar span { display: block; height: 100%; border-radius: 999px; min-width: 4px; transition: width 500ms var(--ai-ease); }
.ai-dist-legend { display: flex; flex-direction: column; gap: 5px; }
.ai-dist-item { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 12.5px; }
.ai-dist-item .d { width: 8px; height: 8px; border-radius: 3px; flex: 0 0 8px; }
.ai-dist-item .n { flex: 1; min-width: 0; color: var(--ai-text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ai-dist-item .v { flex: 0 0 auto; color: var(--ai-text-strong); font-weight: 550; font-variant-numeric: tabular-nums; }

/* Mini column chart */
.ai-trend { display: flex; align-items: flex-end; gap: 8px; height: 108px; padding-top: 4px; }
.ai-trend-col { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 5px; height: 100%; cursor: default; }
.ai-trend-col .v { font-size: 11px; font-weight: 550; color: var(--ai-text-muted); font-variant-numeric: tabular-nums; }
.ai-trend-col .bar {
  width: 100%; max-width: 30px;
  border-radius: 6px;
  background: var(--ai-brand);
  opacity: 0.85;
  transition: opacity 200ms var(--ai-ease), height 500ms var(--ai-ease);
}
.ai-trend-col:hover .bar { opacity: 1; }
.ai-trend-col .bar.has-err { background: linear-gradient(to top, var(--ai-red) 0 3px, var(--ai-brand) 3px); }
.ai-trend-col .lbl { font-size: 10.5px; color: var(--ai-text-faint); font-variant-numeric: tabular-nums; }

/* ---------------- Queue ---------------- */
.ai-queue-card {
  min-width: 0;
  background: var(--ai-surface);
  border: 1px solid var(--ai-border);
  border-radius: var(--ai-radius-xl);
  box-shadow: var(--ai-shadow-soft);
  padding: 16px;
}
.ai-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 9px;
  padding: 0 0 12px;
}
.ai-toolbar-search {
  display: flex; align-items: center; gap: 9px;
  background: var(--ai-surface-muted);
  border: 0;
  border-radius: 999px;
  padding: 0 16px;
  min-width: 220px; flex: 1 1 240px; max-width: 380px;
  height: 40px;
  transition: background 200ms var(--ai-ease), box-shadow 200ms var(--ai-ease);
}
.ai-toolbar-search svg { flex: 0 0 15px; width: 15px; height: 15px; color: var(--ai-text-faint); }
.ai-toolbar-search input {
  flex: 1; min-width: 0; border: 0; background: none; outline: none;
  color: var(--ai-text); font: inherit; font-size: 13.5px;
}
.ai-toolbar-search input::placeholder { color: var(--ai-text-faint); }
.ai-toolbar-search:focus-within { background: var(--ai-surface); box-shadow: 0 0 0 2px var(--ai-brand); }
.ai-select {
  height: 40px;
  background-color: var(--ai-surface-muted);
  border: 0;
  border-radius: 999px;
  color: var(--ai-text);
  font: inherit; font-size: 13px; font-weight: 500;
  padding: 0 34px 0 16px;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%238a919e' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  transition: background-color 200ms var(--ai-ease), box-shadow 200ms var(--ai-ease);
}
.ai-select:hover { background-color: var(--ai-surface-strong); }
.ai-select:focus { outline: none; box-shadow: 0 0 0 2px var(--ai-brand); }
.ai-select option { background: var(--ai-surface); color: var(--ai-text); }
.ai-toolbar-spacer { flex: 1; }

.ai-chips { display: flex; flex-wrap: wrap; gap: 7px; padding: 0 0 16px; }
.ai-chip {
  display: inline-flex; align-items: center; gap: 6px;
  border: 0;
  background: var(--ai-surface-muted);
  color: var(--ai-text-muted);
  font: inherit; font-size: 12.5px; font-weight: 500;
  padding: 6px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 200ms var(--ai-ease), color 200ms var(--ai-ease), transform 120ms var(--ai-ease);
}
.ai-chip:hover { background: var(--ai-surface-strong); color: var(--ai-text-strong); }
.ai-chip:active { transform: scale(0.96); }
.ai-chip.on { background: var(--ai-brand); color: #ffffff; }
.ai-chip .c { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--ai-text-faint); }
.ai-chip.on .c { color: rgba(255, 255, 255, 0.72); }
.ai-chip.empty { opacity: 0.55; }

/* ---------------- Email list ---------------- */
.ai-table-wrap { overflow: visible; }
.ai-list-head {
  display: grid;
  grid-template-columns: minmax(250px, 1.2fr) minmax(220px, 1fr) minmax(300px, 1.4fr) minmax(130px, auto);
  gap: 14px;
  padding: 0 16px 8px;
  color: var(--ai-text-faint);
  font-family: var(--ai-mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.ai-list { display: flex; flex-direction: column; gap: 4px; }

.ai-mail-row {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 14px 16px;
  border-radius: var(--ai-radius-lg);
  cursor: pointer;
  position: relative;
  animation: ai-rise 300ms var(--ai-ease) backwards;
  transition: background 200ms var(--ai-ease), transform 200ms var(--ai-ease);
}
.ai-mail-row:nth-child(-n+12) { animation-delay: calc(var(--i, 0) * 24ms); }
.ai-mail-row:hover { background: var(--ai-surface-muted); }
.ai-mail-row:active { transform: scale(0.997); }
.ai-mail-row.selected { background: var(--ai-brand-bg); }
.ai-mail-row.row-error { background: rgba(255, 106, 106, 0.08); }
.ai-mail-row.row-error:hover { background: var(--ai-red-bg); }
.ai-mail-row.row-john { background: rgba(240, 180, 41, 0.08); }
.ai-mail-row.row-john:hover { background: var(--ai-amber-bg); }

.ai-mail-avatar {
  width: 42px; height: 42px; border-radius: 14px; flex: 0 0 42px;
  background: var(--ai-surface-strong);
  color: var(--ai-text-muted);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13.5px; font-weight: 600; letter-spacing: 0;
  transition: background 200ms var(--ai-ease), color 200ms var(--ai-ease);
}
.ai-mail-row:hover .ai-mail-avatar, .ai-mail-row.selected .ai-mail-avatar { background: var(--ai-brand); color: #ffffff; }
.ai-mail-row.row-error .ai-mail-avatar { background: var(--ai-red-bg); color: var(--ai-red); }
.ai-mail-row.row-error:hover .ai-mail-avatar { background: var(--ai-red); color: #ffffff; }

.ai-mail-main { flex: 1; min-width: 0; }
.ai-mail-top { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.ai-mail-sender { font-size: 14px; font-weight: 600; color: var(--ai-text-strong); letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40%; flex: 0 1 auto; }
.ai-mail-email { font-size: 12px; color: var(--ai-text-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 0 1 auto; }
.ai-mail-time { margin-left: auto; flex: 0 0 auto; font-size: 12px; color: var(--ai-text-faint); font-variant-numeric: tabular-nums; white-space: nowrap; }
.ai-mail-subject {
  margin-top: 2px;
  display: flex; align-items: center; gap: 7px; min-width: 0;
  font-size: 13.5px; font-weight: 500; color: var(--ai-text);
}
.ai-mail-subject .t { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.ai-mail-clip { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 3px; color: var(--ai-text-faint); font-size: 11.5px; }
.ai-mail-clip svg { width: 13px; height: 13px; }
.ai-mail-summary {
  margin-top: 3px;
  font-size: 13px; color: var(--ai-text-muted);
  display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden;
}
.ai-mail-next {
  margin-top: 2px;
  font-size: 12.5px;
  color: var(--ai-text-faint);
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.ai-mail-summary span,
.ai-mail-next span {
  display: inline-block;
  margin-right: 6px;
  font-family: var(--ai-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ai-text-faint);
}
.ai-mail-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px; }

.ai-mail-side { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; flex: 0 0 auto; padding-top: 2px; }
.ai-mail-actions {
  display: flex; align-items: center; gap: 4px;
  opacity: 0;
  transform: translateY(2px);
  transition: opacity 200ms var(--ai-ease), transform 200ms var(--ai-ease);
}
.ai-mail-row:hover .ai-mail-actions,
.ai-mail-row:focus-within .ai-mail-actions { opacity: 1; transform: translateY(0); }
@media (hover: none) { .ai-mail-actions { opacity: 1; transform: none; } }
.ai-mail-actions .ai-btn.sm { background: var(--ai-surface); }
.ai-mail-actions .ai-btn.sm:hover { background: var(--ai-surface-strong); }
.ai-mail-actions .ai-iconbtn { width: 30px; height: 30px; flex-basis: 30px; background: var(--ai-surface); }
.ai-mail-actions .ai-iconbtn:hover { background: var(--ai-surface-strong); }
.ai-mail-row.row-error .ai-mail-actions .ai-btn.sm,
.ai-mail-row.row-error .ai-mail-actions .ai-iconbtn,
.ai-mail-row.row-john .ai-mail-actions .ai-btn.sm,
.ai-mail-row.row-john .ai-mail-actions .ai-iconbtn { background: var(--ai-surface-strong); }

/* Badges - quiet tinted pills */
.ai-badge {
  display: inline-flex; align-items: center;
  font-size: 11.5px; font-weight: 550; letter-spacing: 0;
  padding: 3px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.ai-badge.blue { background: var(--ai-blue-bg); color: var(--ai-blue); }
.ai-badge.green { background: var(--ai-green-bg); color: var(--ai-green); }
.ai-badge.amber { background: var(--ai-amber-bg); color: var(--ai-amber); }
.ai-badge.red { background: var(--ai-red-bg); color: var(--ai-red); }
.ai-badge.teal { background: var(--ai-teal-bg); color: var(--ai-teal); }
.ai-badge.purple { background: var(--ai-gray-bg); color: var(--ai-text-muted); }
.ai-badge.gray { background: var(--ai-gray-bg); color: var(--ai-text-muted); }
.ai-badge.solid-red { background: var(--ai-red); color: #ffffff; }

.ai-draft-pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 550;
  color: var(--ai-green);
  background: var(--ai-green-bg);
  border-radius: 999px;
  padding: 3px 10px;
  white-space: nowrap;
}
.ai-draft-pill.none { color: var(--ai-text-faint); background: var(--ai-gray-bg); }

.ai-conf { display: flex; align-items: center; gap: 8px; min-width: 90px; }
.ai-conf-track { flex: 1; height: 6px; border-radius: 999px; background: var(--ai-track); overflow: hidden; min-width: 44px; }
.ai-conf-fill { height: 100%; border-radius: 999px; }
.ai-conf-fill.hi { background: #17a866; }
.ai-conf-fill.mid { background: #e3a52c; }
.ai-conf-fill.lo { background: #e05c5f; }
.ai-conf-num { font-size: 12px; color: var(--ai-text-muted); font-variant-numeric: tabular-nums; }
.ai-conf-none { font-size: 12px; color: var(--ai-text-faint); }

/* List states */
.ai-empty, .ai-table-error {
  padding: 56px 20px;
  text-align: center;
  color: var(--ai-text-muted);
  font-size: 14px;
  background: var(--ai-surface-muted);
  border-radius: var(--ai-radius-xl);
}
.ai-empty strong, .ai-table-error strong { display: block; color: var(--ai-text-strong); font-weight: 600; font-size: 15px; margin-bottom: 4px; }
.ai-empty span, .ai-table-error span { font-size: 13px; color: var(--ai-text-faint); }
.ai-table-error strong { color: var(--ai-red); }

.ai-skel {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px; border-radius: var(--ai-radius-lg);
}
.ai-skel-avatar { width: 42px; height: 42px; border-radius: 14px; flex: 0 0 42px; }
.ai-skel-lines { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.ai-skel-bar, .ai-skel-avatar {
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.06) 25%, rgba(255, 255, 255, 0.1) 50%, rgba(255, 255, 255, 0.06) 75%);
  background-size: 200% 100%;
  animation: ai-shimmer 1.4s infinite linear;
}
.ai-skel-bar { height: 12px; border-radius: 999px; }

.ai-queue-meta {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 16px 0;
  font-size: 12px; color: var(--ai-text-faint);
}

/* ---------------- Drawer - floating review panel ---------------- */
.ai-drawer-backdrop {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(10, 11, 13, 0.32);
  animation: ai-fade-in 200ms var(--ai-ease);
}
.ai-drawer {
  position: fixed; top: 10px; right: 10px; bottom: 10px; z-index: 81;
  width: min(720px, calc(100vw - 20px));
  background: var(--ai-surface);
  border-radius: var(--ai-radius-xl);
  box-shadow: var(--ai-shadow);
  display: flex; flex-direction: column;
  overflow: hidden;
  animation: ai-drawer-in 280ms var(--ai-ease);
}
.ai-drawer[hidden], .ai-drawer-backdrop[hidden] { display: none; }
.ai-drawer-head {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 22px 22px 16px;
}
.ai-avatar {
  width: 46px; height: 46px; border-radius: 15px; flex: 0 0 46px;
  background: var(--ai-brand); color: #ffffff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 600;
}
.ai-drawer-id { flex: 1; min-width: 0; }
.ai-drawer-name { font-size: 16.5px; font-weight: 650; color: var(--ai-text-strong); letter-spacing: -0.02em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-drawer-sub { font-size: 13px; color: var(--ai-text-muted); margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-drawer-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.ai-drawer-tools { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.ai-drawer-close {
  flex: 0 0 auto;
  border: 0; background: var(--ai-surface-muted); color: var(--ai-text-muted);
  width: 34px; height: 34px; border-radius: 999px;
  font-size: 17px; line-height: 1; cursor: pointer;
  transition: background 200ms var(--ai-ease), color 200ms var(--ai-ease), transform 120ms var(--ai-ease);
}
.ai-drawer-close:hover { background: var(--ai-surface-strong); color: var(--ai-text-strong); }
.ai-drawer-close:active { transform: scale(0.94); }
.ai-drawer-body { flex: 1; overflow-y: auto; padding: 0 22px 24px; display: flex; flex-direction: column; gap: 14px; }
/* Children must not shrink inside the scrollable flex column, or overflowing
   tab content compresses and paints over the draft editor below it. */
.ai-drawer-body > * { flex-shrink: 0; }
.ai-drawer-foot {
  display: flex; align-items: center; gap: 9px; flex-wrap: wrap;
  padding: 14px 22px;
  border-top: 1px solid var(--ai-border-light);
  background: var(--ai-surface);
}
.ai-drawer-foot .ai-note { margin-left: auto; font-size: 11.5px; color: var(--ai-text-faint); }

.ai-error-panel {
  border: 0;
  background: var(--ai-red-bg);
  border-radius: var(--ai-radius-lg);
  padding: 13px 16px;
  color: var(--ai-red);
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-word;
}
.ai-error-panel strong { display: block; margin-bottom: 3px; font-size: 12px; font-weight: 600; }

.ai-draft-note {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--ai-text-muted);
  padding: 8px 14px;
  border: 0;
  border-radius: 999px;
  background: var(--ai-surface-muted);
}
.ai-draft-note::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--ai-brand); flex: 0 0 6px; }

/* Drawer panels - quiet gray fills, no borders */
.ai-panel {
  border: 0;
  border-radius: var(--ai-radius-lg);
  background: var(--ai-surface-muted);
  padding: 16px 18px;
}
.ai-panel h3 { margin: 0 0 12px; font-size: 12px; font-weight: 550; color: var(--ai-text-muted); }
.ai-kv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px 18px; }
.ai-kv .k { font-size: 11.5px; font-weight: 500; color: var(--ai-text-faint); margin-bottom: 2px; }
.ai-kv .v { font-size: 13.5px; color: var(--ai-text); word-break: break-word; }
.ai-kv .v.mono { font-family: var(--ai-mono); font-size: 11.5px; color: var(--ai-text-muted); }
.ai-prose { font-size: 13.5px; color: var(--ai-text); white-space: pre-wrap; word-break: break-word; line-height: 1.6; }
.ai-prose.muted { color: var(--ai-text-muted); }

.ai-flags { display: flex; flex-wrap: wrap; gap: 5px; }
.ai-flag {
  font-family: var(--ai-mono); font-size: 10.5px;
  color: var(--ai-amber);
  background: var(--ai-amber-bg);
  border-radius: 999px; padding: 3px 9px;
}
.ai-flag.danger { color: var(--ai-red); background: var(--ai-red-bg); }
.ai-flag.info { color: var(--ai-gray); background: var(--ai-gray-bg); }
.ai-because {
  margin-top: 12px;
  background: var(--ai-amber-bg);
  border-radius: var(--ai-radius);
  padding: 10px 14px;
  font-size: 12.5px;
  color: var(--ai-text-muted);
}
.ai-because strong { color: var(--ai-amber); font-weight: 600; }
.ai-unsafe-warning {
  border: 0;
  background: var(--ai-red-bg);
  border-radius: var(--ai-radius);
  color: var(--ai-red);
  font-size: 12.5px;
  padding: 9px 14px;
  margin-bottom: 10px;
}

/* Attachment chips (drawer) */
.ai-attachments { display: flex; flex-direction: column; gap: 8px; }
.ai-attachment {
  display: flex; align-items: center; gap: 12px;
  background: var(--ai-surface);
  border-radius: var(--ai-radius);
  padding: 10px 14px;
}
.ai-attachment .ai-attachment-icon {
  width: 36px; height: 36px; border-radius: 11px; flex: 0 0 36px;
  background: var(--ai-brand-bg); color: var(--ai-brand);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
}
.ai-attachment .ai-attachment-name { flex: 1; min-width: 0; font-size: 13px; font-weight: 550; color: var(--ai-text-strong); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-attachment .ai-attachment-meta { flex: 0 0 auto; font-size: 11.5px; color: var(--ai-text-faint); white-space: nowrap; }

/* Tabs - segmented control */
.ai-tabs {
  display: inline-flex; align-self: flex-start; gap: 2px;
  background: var(--ai-surface-muted);
  border-radius: 999px;
  padding: 3px;
  border: 0;
  overflow-x: auto;
  max-width: 100%;
}
.ai-tab {
  border: 0; background: none; cursor: pointer;
  font: inherit; font-size: 12.5px; font-weight: 550;
  color: var(--ai-text-muted);
  padding: 6px 14px;
  border-radius: 999px;
  margin: 0;
  white-space: nowrap;
  transition: background 200ms var(--ai-ease), color 200ms var(--ai-ease);
}
.ai-tab:hover { color: var(--ai-text-strong); }
.ai-tab.active { color: var(--ai-text-strong); background: var(--ai-surface); box-shadow: var(--ai-shadow-soft); }
.ai-tabpanes { min-height: 120px; }
.ai-tabpane[hidden] { display: none; }

/* Draft editor */
.ai-draft-editor textarea {
  width: 100%; min-height: 170px; resize: vertical;
  background: var(--ai-surface);
  border: 0;
  border-radius: var(--ai-radius);
  color: var(--ai-text);
  font: inherit; font-size: 13.5px; line-height: 1.6;
  padding: 13px 15px;
  outline: none;
  transition: box-shadow 200ms var(--ai-ease);
  box-shadow: 0 0 0 1px var(--ai-border);
}
.ai-draft-editor textarea:focus { box-shadow: 0 0 0 2px var(--ai-brand); }
.ai-draft-templates { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.ai-draft-templates .ai-chip { background: var(--ai-surface); }
.ai-draft-templates .ai-chip:hover { background: var(--ai-surface-strong); }
.ai-draft-actions { display: flex; gap: 9px; margin-top: 12px; align-items: center; }

/* Logs timeline */
.ai-timeline { display: flex; flex-direction: column; }
.ai-log { display: flex; gap: 12px; padding: 7px 0; position: relative; }
.ai-log::before {
  content: ""; position: absolute; left: 4px; top: 22px; bottom: -4px;
  width: 1.5px; border-radius: 1px; background: var(--ai-track);
}
.ai-log:last-child::before { display: none; }
.ai-log-dot { width: 9px; height: 9px; border-radius: 50%; margin-top: 5px; flex: 0 0 9px; background: #cfd3da; z-index: 1; box-shadow: 0 0 0 3px var(--ai-surface-muted); }
.ai-log-dot.INFO { background: var(--ai-brand); }
.ai-log-dot.WARNING { background: #dd9a10; }
.ai-log-dot.ERROR { background: var(--ai-red); }
.ai-log-body { min-width: 0; flex: 1; }
.ai-log-top { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.ai-log-event { font-family: var(--ai-mono); font-size: 11px; font-weight: 600; color: var(--ai-text-strong); }
.ai-log-time { font-family: var(--ai-mono); font-size: 10.5px; color: var(--ai-text-faint); }
.ai-log-msg { font-size: 12.5px; color: var(--ai-text-muted); margin-top: 1px; word-break: break-word; }
.ai-log-meta { font-family: var(--ai-mono); font-size: 10.5px; color: var(--ai-text-faint); margin-top: 2px; word-break: break-all; }

/* Collapsible raw body */
.ai-collapse-toggle { margin-bottom: 8px; }
.ai-raw-body {
  font-family: var(--ai-mono); font-size: 11.5px; line-height: 1.55;
  color: var(--ai-text-muted);
  white-space: pre-wrap; word-break: break-word;
  background: var(--ai-surface);
  border: 0;
  border-radius: var(--ai-radius);
  padding: 12px 14px;
  max-height: 420px; overflow-y: auto;
}

/* ---------------- Toasts - dark pills ---------------- */
.ai-toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: 24px; z-index: 100; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.ai-toast {
  background: #111215;
  border: 1px solid var(--ai-border);
  border-radius: 999px;
  box-shadow: var(--ai-shadow-card);
  color: var(--ai-text);
  font-size: 13px; font-weight: 500;
  padding: 10px 20px;
  max-width: min(480px, calc(100vw - 48px));
  animation: ai-toast-in 260ms var(--ai-ease);
  display: flex; align-items: center; gap: 9px;
}
.ai-toast::before { content: ""; width: 7px; height: 7px; border-radius: 50%; flex: 0 0 7px; background: var(--ai-brand); }
.ai-toast.ok::before { background: #2bd583; }
.ai-toast.err::before { background: #ff7b7b; }

/* ---------------- Auth shell ---------------- */
.ai-auth-root {
  min-height: 100vh;
  margin: 0;
  background: var(--ai-bg);
  color: var(--ai-text);
  font-family: var(--ai-font);
}
.ai-auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.ai-auth-panel {
  width: min(420px, 100%);
  background: linear-gradient(180deg, rgba(255,255,255,0.035), rgba(255,255,255,0.018)), var(--ai-surface);
  border: 1px solid var(--ai-border);
  border-radius: var(--ai-radius);
  box-shadow: var(--ai-shadow-card);
  padding: 24px;
}
.ai-auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--ai-border-light);
}
.ai-auth-brand strong {
  display: block;
  color: var(--ai-text-strong);
  font-size: 14px;
  letter-spacing: 0;
}
.ai-auth-brand span:not(.ai-brand-mark) {
  display: block;
  color: var(--ai-text-faint);
  font-size: 12px;
  margin-top: 2px;
}
.ai-auth-heading { margin: 22px 0 18px; }
.ai-auth-heading h1 {
  margin: 0;
  color: var(--ai-text-strong);
  font-size: 24px;
  line-height: 1.15;
  letter-spacing: 0;
}
.ai-auth-heading p {
  margin: 8px 0 0;
  color: var(--ai-text-muted);
  font-size: 13px;
  line-height: 1.45;
}
.ai-auth-alert {
  margin-bottom: 12px;
  border: 1px solid rgba(255, 106, 106, 0.3);
  background: rgba(255, 106, 106, 0.1);
  color: #ffb5b5;
  border-radius: var(--ai-radius);
  padding: 10px 12px;
  font-size: 12.5px;
}
.ai-auth-form {
  display: grid;
  gap: 12px;
}
.ai-auth-form label {
  display: grid;
  gap: 7px;
  color: var(--ai-text-muted);
  font-size: 12px;
  font-weight: 600;
}
.ai-auth-form input {
  height: 39px;
  border: 1px solid var(--ai-border);
  border-radius: var(--ai-radius);
  background: var(--ai-surface-muted);
  color: var(--ai-text-strong);
  font: 13px var(--ai-font);
  padding: 0 11px;
  outline: none;
}
.ai-auth-form input:focus {
  border-color: rgba(124, 138, 255, 0.55);
  box-shadow: 0 0 0 3px rgba(124, 138, 255, 0.12);
}
.ai-auth-form .ai-btn {
  justify-content: center;
  height: 39px;
  margin-top: 4px;
}

/* ---------------- Responsive ---------------- */
@media (max-width: 1400px) {
  .ai-metrics { grid-template-columns: repeat(3, minmax(140px, 1fr)); }
  .ai-signals { grid-template-columns: repeat(2, minmax(180px, 1fr)); }
}
@media (max-width: 1024px) {
  .ai-sidebar { width: 64px; flex-basis: 64px; }
  .ai-sidebar .ai-side-brand span.ai-side-org,
  .ai-sidebar .ai-side-brand strong em,
  .ai-sidebar .ai-side-label,
  .ai-sidebar .ai-side-item span.label,
  .ai-sidebar .ai-side-count,
  .ai-sidebar .ai-side-hint,
  .ai-sidebar .ai-side-foot a span { display: none; }
  .ai-side-item { justify-content: center; padding: 11px 0; }
  .ai-side-foot a { text-align: center; }
  .ai-mail-side { display: none; }
  .ai-mail-row { align-items: center; }
}
@media (max-width: 760px) {
  .ai-shell { flex-direction: column; }
  .ai-sidebar { display: none; }
  .ai-topbar { flex-wrap: wrap; padding: 12px 16px; }
  .ai-content { padding: 8px 16px 40px; }
  .ai-metrics { grid-template-columns: repeat(2, minmax(120px, 1fr)); }
  .ai-signals { grid-template-columns: 1fr; }
  .ai-drawer { top: 8px; right: 8px; bottom: 8px; left: 8px; width: auto; }
  .ai-toolbar-search { max-width: none; }
  .ai-list-head { display: none; }
  .ai-mail-email { display: none; }
}
