:root {
  --bg: #0b1220;
  --bg-elev: #121a2b;
  --bg-soft: #182338;
  --border: #24314a;
  --text: #e8eefc;
  --muted: #93a0b8;
  --accent: #5b9dff;
  --accent-2: #3dd6c6;
  --warn: #f0b429;
  --danger: #ff6b7a;
  --in: #3dd6c6;
  --out: #5b9dff;
  --unknown: #93a0b8;
  --radius: 12px;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  background: radial-gradient(1200px 600px at 10% -10%, #1a2744 0%, transparent 55%),
              radial-gradient(900px 500px at 100% 0%, #132a33 0%, transparent 50%),
              var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.45;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.shell { max-width: 1180px; margin: 0 auto; padding: 1.25rem 1.25rem 3rem; }

.topbar {
  display: flex; flex-wrap: wrap; gap: 1rem; align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  padding: 0.85rem 1rem;
  background: rgba(18, 26, 43, 0.85);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow);
}
.brand { display: flex; flex-direction: column; gap: 0.15rem; }
.brand strong { font-size: 1.05rem; letter-spacing: 0.02em; }
.brand span { color: var(--muted); font-size: 0.82rem; }
.nav { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.nav a {
  color: var(--muted);
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  text-decoration: none;
  font-size: 0.9rem;
  border: 1px solid transparent;
}
.nav a:hover { color: var(--text); background: var(--bg-soft); }
.nav a.active {
  color: var(--text);
  background: linear-gradient(135deg, #1e3a5f, #1a3d45);
  border-color: var(--border);
}
.nav-user {
  color: var(--muted);
  font-size: 0.82rem;
  padding: 0.4rem 0.5rem;
  max-width: 160px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.biz-switch select {
  background: var(--bg-soft, #182338);
  color: var(--text, #e8eefc);
  border: 1px solid var(--border, #24314a);
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  font-size: 0.85rem;
  max-width: 180px;
}
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); border: 0;
}
.biz-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.85rem;
  margin-top: 1rem;
}
.biz-card {
  display: block;
  padding: 1rem 1.1rem;
  border-radius: 14px;
  border: 1px solid var(--border, #24314a);
  background: var(--bg-soft, #182338);
  color: inherit;
  text-decoration: none;
  transition: transform .15s ease, border-color .15s ease;
  border-top: 3px solid var(--biz, #5b9dff);
}
.biz-card:hover {
  transform: translateY(-2px);
  border-color: var(--biz, #5b9dff);
  text-decoration: none;
  color: inherit;
}
.biz-card h3 { margin: 0.35rem 0 0.25rem; font-size: 1.1rem; }
.biz-card p { margin: 0; font-size: 0.88rem; min-height: 2.4em; }
.biz-top { display: flex; justify-content: space-between; align-items: center; }
.biz-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--biz, #5b9dff);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--biz) 25%, transparent);
}
.biz-stats {
  display: flex; flex-direction: column; gap: 0.15rem;
  margin-top: 0.75rem; font-size: 0.78rem; color: var(--muted);
}
.biz-id { margin-top: 0.5rem; font-size: 0.72rem; }

.banner {
  display: flex; gap: 0.75rem; align-items: flex-start;
  padding: 0.75rem 1rem;
  margin-bottom: 1.25rem;
  border-radius: var(--radius);
  border: 1px solid #2f4a3a;
  background: linear-gradient(90deg, rgba(61, 214, 198, 0.1), transparent);
  color: #c9f5ef;
  font-size: 0.9rem;
}
.banner code { font-family: var(--mono); font-size: 0.82rem; color: #9fe8df; }

.grid { display: grid; gap: 1rem; }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.grid.two { grid-template-columns: 1.4fr 1fr; }
@media (max-width: 860px) { .grid.two { grid-template-columns: 1fr; } }

.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow);
}
.card h2, .card h3 {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.01em;
}
.card h2 { font-size: 1.05rem; }

.stat .label { color: var(--muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; }
.stat .value { font-size: 1.55rem; font-weight: 700; margin-top: 0.2rem; }
.stat .sub { color: var(--muted); font-size: 0.8rem; margin-top: 0.15rem; }

.pill {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.pill.in { color: var(--in); border-color: rgba(61, 214, 198, 0.35); }
.pill.out { color: var(--out); border-color: rgba(91, 157, 255, 0.35); }
.pill.unknown { color: var(--unknown); }
.pill.attach { color: var(--warn); border-color: rgba(240, 180, 41, 0.35); }

.bars { display: flex; flex-direction: column; gap: 0.45rem; }
.bar-row { display: grid; grid-template-columns: 72px 1fr 40px; gap: 0.5rem; align-items: center; font-size: 0.85rem; }
.bar-row .label { color: var(--muted); font-family: var(--mono); font-size: 0.78rem; }
.bar-row .track {
  height: 10px; border-radius: 999px; background: var(--bg-soft); overflow: hidden;
  border: 1px solid var(--border);
}
.bar-row .fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  border-radius: 999px;
  min-width: 2px;
}
.bar-row .n { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }

table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 0.55rem 0.45rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; }
tr:hover td { background: rgba(255,255,255,0.02); }
td.subject { max-width: 420px; }
td.subject a { color: var(--text); font-weight: 500; }
td.subject a:hover { color: var(--accent); }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 0.82rem; }
.truncate { max-width: 280px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.filters {
  display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: end;
  margin-bottom: 1rem;
}
.filters label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.78rem; color: var(--muted); }
.filters input, .filters select {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 0.45rem 0.65rem;
  min-width: 160px;
  font: inherit;
}
.filters input:focus, .filters select:focus {
  outline: 2px solid rgba(91, 157, 255, 0.35);
  border-color: var(--accent);
}
.btn {
  appearance: none; border: 1px solid var(--border);
  background: linear-gradient(135deg, #1e3a5f, #1a3d45);
  color: var(--text);
  border-radius: 8px;
  padding: 0.5rem 0.9rem;
  font: inherit;
  cursor: pointer;
}
.btn:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }

.pager {
  display: flex; gap: 0.75rem; align-items: center; justify-content: space-between;
  margin-top: 1rem; color: var(--muted); font-size: 0.9rem;
}
.pager .links { display: flex; gap: 0.5rem; }

.detail-head { margin-bottom: 1rem; }
.detail-head h1 {
  margin: 0.35rem 0 0.5rem;
  font-size: 1.35rem;
  line-height: 1.3;
  font-weight: 650;
}
.meta-row { display: flex; flex-wrap: wrap; gap: 0.4rem 0.75rem; color: var(--muted); font-size: 0.88rem; }
.meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
  margin: 1rem 0;
}
.meta-grid .item { background: var(--bg-soft); border: 1px solid var(--border); border-radius: 10px; padding: 0.65rem 0.75rem; }
.meta-grid .k { color: var(--muted); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; }
.meta-grid .v { margin-top: 0.2rem; font-family: var(--mono); font-size: 0.82rem; word-break: break-all; }

.body-box {
  white-space: pre-wrap;
  word-break: break-word;
  background: #0a101c;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  font-family: var(--mono);
  font-size: 0.86rem;
  line-height: 1.55;
  max-height: 70vh;
  overflow: auto;
}
.pii-tags { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.5rem; }
.pii-tags span {
  font-size: 0.75rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: rgba(240, 180, 41, 0.12);
  border: 1px solid rgba(240, 180, 41, 0.3);
  color: #f5d98a;
  font-family: var(--mono);
}

.thread-list { list-style: none; margin: 0; padding: 0; }
.thread-list li {
  border-bottom: 1px solid var(--border);
  padding: 0.55rem 0;
}
.thread-list li:last-child { border-bottom: 0; }
.thread-list a { color: var(--text); font-weight: 500; }
.status-ok { color: var(--accent-2); }
.status-fail { color: var(--danger); }
.status-partial { color: var(--warn); }

.footer {
  margin-top: 2rem;
  color: var(--muted);
  font-size: 0.8rem;
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}
.footer code { font-family: var(--mono); font-size: 0.75rem; }

.empty {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--muted);
}

/* Message understanding cards */
.msg-cards { display: flex; flex-direction: column; gap: 0.75rem; }
.msg-cards.compact .msg-card { padding: 0.7rem 0.8rem; }
.msg-card {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.85rem 1rem;
}
.msg-card-top {
  display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center;
  margin-bottom: 0.35rem;
}
.msg-title {
  margin: 0.15rem 0 0.35rem;
  font-size: 1.02rem;
  font-weight: 650;
  line-height: 1.3;
}
.msg-title a { color: var(--text); text-decoration: none; }
.msg-title a:hover { color: var(--accent); }
.msg-about {
  margin: 0 0 0.35rem;
  color: #c5d4f0;
  font-size: 0.95rem;
  line-height: 1.4;
}
.msg-blurb {
  margin: 0 0 0.4rem;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.4;
}
.msg-card-foot {
  display: flex; justify-content: space-between; gap: 1rem;
  align-items: center; margin-top: 0.45rem; font-size: 0.8rem;
}
.kw-row { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.kw {
  font-size: 0.72rem;
  font-family: var(--mono);
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  background: rgba(91, 157, 255, 0.1);
  border: 1px solid rgba(91, 157, 255, 0.25);
  color: #a8c8ff;
}
.pill.cat {
  color: #e8eefc;
  border-color: rgba(255,255,255,0.12);
  background: #24314a;
  text-transform: none;
  letter-spacing: 0.02em;
  font-weight: 600;
}
.pill.cat-payments { background: rgba(61, 214, 198, 0.15); color: #7aefe3; border-color: rgba(61,214,198,0.35); }
.pill.cat-timesheet { background: rgba(240, 180, 41, 0.15); color: #f5d98a; border-color: rgba(240,180,41,0.35); }
.pill.cat-tickets { background: rgba(91, 157, 255, 0.15); color: #a8c8ff; border-color: rgba(91,157,255,0.35); }
.pill.cat-security { background: rgba(255, 107, 122, 0.15); color: #ffb0b8; border-color: rgba(255,107,122,0.35); }
.pill.cat-promo, .pill.cat-promo_swag { background: rgba(196, 120, 255, 0.15); color: #e0b8ff; border-color: rgba(196,120,255,0.35); }
.pill.cat-training { background: rgba(61, 214, 198, 0.12); color: #9fe8df; }
.pill.cat-project, .pill.cat-fabrication { background: rgba(91, 157, 255, 0.12); color: #bcd4ff; }
.pill.signal {
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
  color: var(--muted);
  background: transparent;
}

.about-hero {
  margin: 0.75rem 0 1rem;
  padding: 0.9rem 1rem;
  border-radius: 12px;
  border: 1px solid rgba(61, 214, 198, 0.28);
  background: linear-gradient(135deg, rgba(61, 214, 198, 0.1), rgba(91, 157, 255, 0.06));
}
.about-kicker {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #9fe8df;
  font-weight: 700;
  margin-bottom: 0.35rem;
}
.about-lead {
  margin: 0;
  font-size: 1.12rem;
  font-weight: 650;
  line-height: 1.35;
  color: var(--text);
}
.about-blurb {
  margin: 0.45rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.time-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 0.5rem 0 1rem;
}
.time-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--muted);
  font-size: 0.85rem;
  text-decoration: none;
}
.time-chip:hover {
  color: var(--text);
  border-color: var(--accent);
  text-decoration: none;
}
.time-chip.active {
  color: var(--text);
  background: linear-gradient(135deg, #1e3a5f, #1a3d45);
  border-color: rgba(91, 157, 255, 0.45);
}
.chip-count {
  font-family: var(--mono);
  font-size: 0.75rem;
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.25);
  color: #c5d4f0;
}
.rel-time { color: var(--accent-2); font-weight: 500; }

/* AI Admin automation dashboard */
.auto-cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
}
.auto-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.auto-cta {
  border-color: rgba(61, 214, 198, 0.28);
  background: linear-gradient(135deg, rgba(61, 214, 198, 0.08), rgba(91, 157, 255, 0.05));
}
.policy-row { grid-template-columns: minmax(140px, 1.2fr) 1fr 48px; }
.policy-label { font-size: 0.82rem; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.policy-meta {
  display: flex; flex-wrap: wrap; gap: 0.4rem 0.65rem; align-items: center;
  margin: -0.15rem 0 0.65rem 0; padding-left: 0.1rem; font-size: 0.82rem;
}
.fill-no_reply_triage { background: linear-gradient(90deg, #5a6a84, #7a8aa4); }
.fill-full_auto_send { background: linear-gradient(90deg, #2f9e8f, #3dd6c6); }
.fill-semi_auto { background: linear-gradient(90deg, #3d6fbf, #5b9dff); }
.fill-draft_approve_send { background: linear-gradient(90deg, #c4891a, #f0b429); }
.fill-human_only { background: linear-gradient(90deg, #c44a56, #ff6b7a); }

.tier-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.85rem;
  margin-top: 0.75rem;
}
.tier-col {
  border-radius: 10px;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  background: var(--bg-soft);
}
.tier-col h3 { margin: 0 0 0.5rem; font-size: 0.95rem; }
.tier-col ul { margin: 0; padding-left: 1.1rem; color: var(--muted); font-size: 0.88rem; line-height: 1.45; }
.tier-col li { margin-bottom: 0.35rem; }
.tier-col.tier-auto { border-color: rgba(61, 214, 198, 0.35); }
.tier-col.tier-approve { border-color: rgba(240, 180, 41, 0.35); }
.tier-col.tier-human { border-color: rgba(255, 107, 122, 0.35); }

.playbook-step {
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border);
}
.playbook-step:last-child { border-bottom: 0; }
.playbook-title {
  display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center;
  justify-content: space-between;
}
.caveat-list {
  margin: 0.85rem 0 0;
  padding-left: 1.1rem;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.45;
}

.tier-card {
  margin-top: 0.75rem;
  padding: 0.85rem 1rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
}
.tier-head {
  display: flex; flex-wrap: wrap; gap: 0.5rem;
  justify-content: space-between; align-items: center;
}
.tier-card .track { height: 8px; border-radius: 999px; background: #0a101c; border: 1px solid var(--border); overflow: hidden; }
.fill-tier-auto, .fill-tier-auto { background: linear-gradient(90deg, #2f9e8f, #3dd6c6); }
.fill-tier-semi { background: linear-gradient(90deg, #3d6fbf, #5b9dff); }
.fill-tier-approve { background: linear-gradient(90deg, #c4891a, #f0b429); }
.fill-tier-danger { background: linear-gradient(90deg, #c44a56, #ff6b7a); }
.fill-tier-muted, .fill-tier-system { background: linear-gradient(90deg, #5a6a84, #93a0b8); }
.sample-list {
  margin: 0.55rem 0 0;
  padding-left: 1.1rem;
  font-size: 0.86rem;
}
.sample-list li { margin-bottom: 0.4rem; }


