:root {
  --bg: #0e0e10;
  --sidebar: #121214;
  --panel: #18181b;
  --panel-2: #1f1f23;
  --line: #2a2a2f;
  --fg: #ececee;
  --muted: #8b8b93;
  --accent: #8b7cf6;
  --accent-fg: #ffffff;
  --ok: #3fb984;
  --warn: #e3b341;
  --bad: #f2555a;
  --run: #7c8cf8;
  --radius: 10px;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f7f7f8;
    --sidebar: #fbfbfc;
    --panel: #ffffff;
    --panel-2: #f3f3f5;
    --line: #e4e4e8;
    --fg: #18181b;
    --muted: #6b6b74;
    --accent: #6d5ce8;
    --ok: #1f8a5b;
    --warn: #a86d00;
    --bad: #d1343a;
    --run: #4f5fe0;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font: 14px/1.5 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--fg); background: var(--bg); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2 { margin: 0; font-weight: 600; }
h1 { font-size: 15px; }
h2 { font-size: 15px; }
pre { white-space: pre-wrap; word-break: break-word; margin: 0; font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; }
code { font: 12.5px ui-monospace, SFMono-Regular, Menlo, monospace; }

.shell { display: flex; min-height: 100vh; }
.sidebar { width: 220px; flex: none; background: var(--sidebar); border-right: 1px solid var(--line); padding: 14px 10px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--fg); font-weight: 600; padding: 4px 8px 14px; }
.brand:hover { text-decoration: none; }
.logo { display: block; width: 24px; height: 24px; flex: none; }
.logo.big { width: 44px; height: 44px; margin-bottom: 12px; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 6px; color: var(--fg); }
.sidebar nav a:hover { background: var(--panel-2); text-decoration: none; }
.sidebar nav a.active { background: var(--panel-2); }
.ico { width: 14px; text-align: center; color: var(--muted); }
.whoami { margin-top: auto; padding: 8px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 2px; overflow: hidden; }
.whoami span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.content { flex: 1; min-width: 0; }
.topbar { height: 48px; display: flex; align-items: center; padding: 0 24px; border-bottom: 1px solid var(--line); }
main { padding: 20px 24px 48px; max-width: 1280px; }
main.bare { max-width: none; }
section { margin-bottom: 28px; }
.section-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 10px; }
.push-right { margin-left: auto; }
.nowrap, td.pills { white-space: nowrap; }
a.title { color: var(--fg); font-weight: 600; }
.stats { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 24px; }
.stat { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); color: var(--muted); font-size: 13px; }
.stat b { color: var(--fg); font-weight: 600; }
a.stat:hover { text-decoration: none; border-color: var(--accent); }
.blocks { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 0 16px; }
.hint, .muted { color: var(--muted); }
.small { font-size: 12px; }
.strong { font-weight: 600; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 28px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; min-width: 0; }
.card-label { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.card-value { font-size: 26px; font-weight: 600; margin: 6px 0 2px; }
.card-value.tiny { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-value a { color: var(--fg); }
.card-sub { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.running, .dot.queued { background: var(--run); }
.dot.ok, .dot.succeeded { background: var(--ok); }
.dot.warn { background: var(--warn); }
.dot.bad, .dot.failed { background: var(--bad); }
.dot-link { display: inline-flex; padding: 4px 3px; }
.dot-link .dot { width: 9px; height: 9px; }
.dot-link:hover .dot { box-shadow: 0 0 0 2px var(--line); }

.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel-2); color: var(--muted); font-weight: 500; vertical-align: middle; }
.pill.v-healthy { color: var(--ok); }
.pill.v-degraded { color: var(--warn); }
.pill.v-critical, .pill.failed { color: var(--bad); }
.pill.running, .pill.queued { color: var(--run); }

.table { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
th { font-weight: 500; color: var(--muted); font-size: 12.5px; background: var(--panel-2); }
td.when { white-space: nowrap; color: var(--muted); width: 1%; }
td.summary { color: var(--muted); width: 100%; max-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
td.num, th.num { text-align: right; white-space: nowrap; }
td.empty { color: var(--muted); text-align: center; padding: 28px; }
td.near { color: var(--warn); font-weight: 600; }
td.key { width: 1%; }
.refused { color: var(--bad); }
tfoot td { border-top: 1px solid var(--line); background: var(--panel-2); font-weight: 600; }
tr.idle td { color: var(--muted); font-weight: 400; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--panel-2); }

button, .button { font: inherit; font-weight: 500; padding: 6px 14px; border-radius: 7px; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-fg); cursor: pointer; display: inline-block; }
button:hover, .button:hover { filter: brightness(1.08); text-decoration: none; }
button.secondary { background: transparent; color: var(--fg); border-color: var(--line); }
button.secondary:hover { background: var(--panel-2); }
button.link { border: 0; background: none; color: var(--muted); padding: 0; text-align: left; font-weight: 400; }
button.link:hover { color: var(--fg); }
textarea { font: inherit; width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 7px; background: var(--bg); color: var(--fg); resize: vertical; }
textarea:focus { outline: 1px solid var(--accent); border-color: var(--accent); }

.notices { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.notices.banner { margin-bottom: 28px; }
.notice { display: flex; align-items: flex-start; gap: 12px; background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--warn); border-radius: var(--radius); padding: 10px 14px; }
.notice.ended { background: transparent; border-left-color: var(--line); color: var(--muted); }
.notice-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.notice-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.notice button { padding: 3px 12px; font-size: 13px; }
.add-notice summary { cursor: pointer; color: var(--accent); font-size: 13px; width: max-content; }
.add-notice form { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; margin-top: 8px; max-width: 640px; }

.skills { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.skill { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.skill-desc { margin: 0; color: var(--muted); font-size: 13px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.skill button { align-self: flex-start; }

.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-bottom: 14px; }
.chip-group { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 11px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); color: var(--muted); font-size: 13px; }
.chip:hover { color: var(--fg); text-decoration: none; }
.chip.active { color: var(--fg); background: var(--panel-2); border-color: var(--accent); }
.filter-form { display: flex; flex-wrap: wrap; gap: 6px; margin-left: auto; }
.filter-form button { padding: 3px 12px; font-size: 13px; }
select { font: inherit; font-size: 13px; padding: 3px 8px; border: 1px solid var(--line); border-radius: 7px; background: var(--panel); color: var(--fg); }
select.active { border-color: var(--accent); }

.run-title { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.run-title h2 { font-size: 18px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 16px; }
.markdown { line-height: 1.6; overflow-wrap: anywhere; }
.markdown > :first-child { margin-top: 0; }
.markdown > :last-child { margin-bottom: 0; }
.markdown h1, .markdown h2, .markdown h3, .markdown h4 { font-size: 14px; font-weight: 600; margin: 16px 0 6px; }
.markdown h1, .markdown h2 { font-size: 15px; }
.markdown p { margin: 6px 0; }
.markdown ul, .markdown ol { margin: 6px 0; padding-left: 22px; }
.markdown li { margin: 2px 0; }
.markdown code { background: var(--panel-2); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; font-size: 12.5px; }
.markdown pre { background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; overflow-x: auto; margin: 8px 0; }
.markdown pre code { background: none; border: 0; padding: 0; }
.markdown table { width: auto; border: 1px solid var(--line); border-radius: 6px; margin: 8px 0; font-size: 13px; }
.markdown th, .markdown td { padding: 5px 10px; }
.markdown blockquote { margin: 8px 0; padding-left: 12px; border-left: 3px solid var(--line); color: var(--muted); }
.markdown a { overflow-wrap: anywhere; }
.panel.error { border-color: var(--bad); color: var(--bad); }
details.panel summary { cursor: pointer; color: var(--muted); }
details.panel pre { margin-top: 10px; }

.transcript { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.event { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; }
.event.text { border-left: 3px solid var(--accent); }
.event.tool, .event.result { padding: 5px 12px; background: transparent; }
.event .note { color: var(--muted); font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; }
.event.denied .note { color: var(--warn); }
.event summary { cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.event .tool { font-weight: 600; margin-right: 6px; }
.event code { color: var(--muted); }
.event.is-error { border-color: var(--bad); }
.event.result pre { margin-top: 6px; max-height: 400px; overflow: auto; color: var(--muted); }

.login { max-width: 360px; margin: 18vh auto; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 16px; }
.login h1 { font-size: 22px; }

@media (max-width: 800px) {
  .shell { flex-direction: column; }
  .sidebar { width: auto; height: auto; position: static; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 8px 12px; }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; }
  .filter-form { margin-left: 0; width: 100%; }
  .filter-form select { flex: 1; min-width: 0; }
  .whoami { display: none; }
  .brand { padding: 4px 8px; }
  main { padding: 16px; }
  .topbar { padding: 0 16px; }
  td.summary, .wide-only { display: none; }
  td.pills, td.strong.nowrap { white-space: normal; }
  th, td { padding: 9px 10px; }
  .section-head { flex-wrap: wrap; }
  .section-head .hint { order: 1; flex-basis: 100%; }
  a.title { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
}
