/* TCV Agent Operations — enterprise dashboard. Tokens first; light by default, dark via prefers-color-scheme. */
:root {
  --bg: #f4f6f9; --surface: #ffffff; --surface-2: #f8fafc; --border: #e2e8f0; --border-strong: #cbd5e1;
  --text: #0f172a; --text-2: #475569; --muted: #64748b;
  --brand: #0b5c4d; --brand-2: #0e7a66; --brand-ink: #ffffff; --side: #0b1f2a; --side-text: #cbd5e1; --side-active: #13394a;
  --ok: #15803d; --ok-bg: #dcfce7; --warn: #a16207; --warn-bg: #fef3c7; --bad: #b91c1c; --bad-bg: #fee2e2;
  --info: #1d4ed8; --info-bg: #dbeafe; --neutral: #475569; --neutral-bg: #e2e8f0; --violet: #6d28d9; --violet-bg: #ede9fe;
  --focus: #0e7a66; --radius: 8px; --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .08);
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1220; --surface: #111a2b; --surface-2: #0f1726; --border: #1f2a3d; --border-strong: #2c3a52;
    --text: #e2e8f0; --text-2: #b6c2d3; --muted: #8a99ad; --side: #070d17; --side-active: #13283a;
    --ok: #4ade80; --ok-bg: #12321f; --warn: #fbbf24; --warn-bg: #3a2c0b; --bad: #f87171; --bad-bg: #3b1515;
    --info: #93c5fd; --info-bg: #13274a; --neutral: #b6c2d3; --neutral-bg: #1f2a3d; --violet: #c4b5fd; --violet-bg: #2a1f4a;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 var(--font); }
a { color: var(--brand-2); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
.muted { color: var(--muted); } .small { font-size: 12px; } .mono { font-family: var(--mono); font-size: 12px; }
.nowrap { white-space: nowrap; }

/* login */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 28px; box-shadow: var(--shadow); display: grid; gap: 14px; }
label { display: grid; gap: 6px; font-weight: 600; color: var(--text-2); font-size: 13px; }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 6px; padding: 8px 10px; min-height: 36px; }
textarea { resize: vertical; }
.form-error { color: var(--bad); margin: 0; font-weight: 600; }

/* shell */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100%; }
.sidebar { background: var(--side); color: var(--side-text); display: flex; flex-direction: column; padding: 16px 12px;
  position: sticky; top: 0; height: 100vh; }
.brand { display: flex; gap: 10px; align-items: center; padding: 4px 8px 18px; }
.brand strong { display: block; color: #fff; font-size: 15px; }
.brand small { display: block; color: var(--side-text); opacity: .8; font-size: 12px; }
.brand-lg strong { color: var(--text); font-size: 18px; } .brand-lg small { color: var(--muted); }
.brand-mark { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 8px; background: var(--brand);
  color: #fff; font-weight: 800; letter-spacing: .5px; font-size: 13px; }
nav { display: grid; gap: 2px; }
nav a { color: var(--side-text); padding: 9px 12px; border-radius: 6px; display: flex; justify-content: space-between;
  align-items: center; font-weight: 500; }
nav a:hover { background: var(--side-active); text-decoration: none; color: #fff; }
nav a.active { background: var(--side-active); color: #fff; box-shadow: inset 3px 0 0 var(--brand-2); }
.nav-count { background: var(--warn); color: #111; border-radius: 10px; padding: 0 7px; font-size: 11px; font-weight: 700; }
.sidebar-foot { margin-top: auto; padding: 8px; color: var(--side-text); opacity: .7; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 12px 24px; background: var(--surface);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
.topbar h1 { font-size: 18px; margin: 0; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.user { font-weight: 600; color: var(--text-2); }
.refresh-state { font-size: 12px; color: var(--muted); }
.refresh-state.stale { color: var(--warn); font-weight: 600; }
.refresh-state.error { color: var(--bad); font-weight: 600; }
.menu-btn { display: none; }
.view { padding: 20px 24px 40px; display: grid; gap: 18px; align-content: start; }

/* buttons */
.btn { font: inherit; border-radius: 6px; padding: 7px 12px; border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--text); cursor: pointer; min-height: 34px; font-weight: 600; }
.btn:hover { border-color: var(--brand-2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn-primary:hover { background: var(--brand-2); }
.btn-danger { color: var(--bad); border-color: var(--bad); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--border); }
.btn-sm { padding: 3px 9px; min-height: 28px; font-size: 12px; }

/* cards & panels */
.cards { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px;
  box-shadow: var(--shadow); display: grid; gap: 4px; }
a.card { color: inherit; text-decoration: none; }
a.card:hover { border-color: var(--brand-2); text-decoration: none; }
.card .label { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
.card .value { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.card .hint { font-size: 12px; color: var(--muted); }
.card.tone-bad .value { color: var(--bad); } .card.tone-warn .value { color: var(--warn); }
.card.tone-ok .value { color: var(--ok); } .card.tone-info .value { color: var(--info); }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  min-width: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px;
  border-bottom: 1px solid var(--border); }
.panel-head h2 { font-size: 14px; margin: 0; }
.panel-body { padding: 12px 16px; }
.panel-body.flush { padding: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.span-2 { grid-column: span 2; }

/* tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); background: var(--surface-2);
  position: sticky; top: 0; font-weight: 700; }
tbody tr:hover { background: var(--surface-2); }
tbody tr.clickable { cursor: pointer; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.truncate { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* status pills */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px; font-size: 12px;
  font-weight: 600; white-space: nowrap; background: var(--neutral-bg); color: var(--neutral); }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.ok { background: var(--ok-bg); color: var(--ok); } .pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--bad-bg); color: var(--bad); } .pill.info { background: var(--info-bg); color: var(--info); }
.pill.violet { background: var(--violet-bg); color: var(--violet); }
.tag { display: inline-block; padding: 1px 7px; border-radius: 4px; background: var(--surface-2); border: 1px solid var(--border);
  font-size: 11px; color: var(--text-2); font-weight: 600; }

/* lists, timelines */
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 10px 16px; border-bottom: 1px solid var(--border); display: grid; gap: 3px; }
.list li:last-child { border-bottom: 0; }
.list .row { display: flex; gap: 8px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.sev { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 6px; }
.sev.high, .sev.critical { background: var(--bad); } .sev.medium, .sev.warning { background: var(--warn); }
.sev.low, .sev.info { background: var(--info); }
.timeline { list-style: none; margin: 0; padding: 0 0 0 18px; border-left: 2px solid var(--border); display: grid; gap: 12px; }
.timeline li { position: relative; }
.timeline li::before { content: ""; position: absolute; left: -24px; top: 4px; width: 10px; height: 10px; border-radius: 50%;
  background: var(--ok); border: 2px solid var(--surface); }
.timeline li.fail::before { background: var(--bad); } .timeline li.neutral::before { background: var(--muted); }
.timeline .t-head { display: flex; gap: 8px; flex-wrap: wrap; align-items: baseline; }
.kv { display: grid; grid-template-columns: 180px 1fr; gap: 6px 14px; margin: 0; }
.kv dt { color: var(--muted); font-weight: 600; } .kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 2px 9px; border-radius: 999px; border: 1px solid var(--border-strong); font-size: 12px; background: var(--surface-2); }
.chip.on { border-color: var(--brand-2); color: var(--brand-2); font-weight: 600; }
pre.json { margin: 0; padding: 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px;
  max-height: 360px; overflow: auto; font: 12px/1.5 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; }
details > summary { cursor: pointer; color: var(--brand-2); font-weight: 600; margin: 4px 0; }

/* filters */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.filters label { font-size: 12px; } .filters input, .filters select { min-height: 32px; padding: 5px 8px; }
.filters .grow { flex: 1; min-width: 200px; }
.check { display: flex; flex-direction: row; align-items: center; gap: 6px; font-weight: 600; }
.check input { min-height: auto; }
.pager { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; gap: 10px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); padding: 0 16px; }
.tabs button { background: none; border: 0; padding: 10px 12px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer;
  border-bottom: 2px solid transparent; }
.tabs button.active { color: var(--brand-2); border-bottom-color: var(--brand-2); }

/* states */
.state { padding: 28px 16px; text-align: center; color: var(--muted); }
.state strong { display: block; color: var(--text-2); margin-bottom: 4px; }
.state.error { color: var(--bad); }
.banner { padding: 10px 14px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text-2); }
.banner.warn { background: var(--warn-bg); border-color: transparent; color: var(--warn); }
.banner.bad { background: var(--bad-bg); border-color: transparent; color: var(--bad); }
.banner.info { background: var(--info-bg); border-color: transparent; color: var(--info); }
.skeleton { height: 14px; border-radius: 4px; background: linear-gradient(90deg, var(--surface-2), var(--border), var(--surface-2));
  background-size: 200% 100%; animation: shimmer 1.2s infinite; margin: 10px 16px; }
@keyframes shimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }

.dialog { border: 1px solid var(--border); border-radius: 10px; padding: 20px; width: min(460px, calc(100vw - 32px));
  background: var(--surface); color: var(--text); box-shadow: 0 10px 30px rgba(0, 0, 0, .25); }
.dialog::backdrop { background: rgba(15, 23, 42, .45); }
.dialog h2 { margin: 0 0 6px; font-size: 16px; }
.dialog form { display: grid; gap: 12px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* responsive: tablet and below */
@media (max-width: 1280px) { .cards { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 1100px) { .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 1024px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 250px; z-index: 20; transform: translateX(-100%); transition: transform .2s; }
  .shell.nav-open .sidebar { transform: none; }
  .menu-btn { display: inline-flex; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; } .span-2 { grid-column: auto; }
  .kv { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .view { padding: 14px 16px 32px; } .topbar { padding: 10px 16px; }
  .user, .refresh-state { display: none; }
}
