:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1e222b;
  --line: #2a2f3a;
  --text: #e8eaf0;
  --muted: #98a0b3;
  --accent: #b58cff;
  --accent-2: #7ee0c0;
  --danger: #ff6b81;
  --warn: #ffbf5c;
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: radial-gradient(1200px 600px at 10% -10%, #1c1730 0%, var(--bg) 55%);
  color: var(--text);
  font: 15px/1.5 "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12.5px; color: #c9d2e6; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px; border-bottom: 1px solid var(--line);
  background: rgba(15, 17, 21, 0.85); backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 700; font-size: 18px; letter-spacing: 0.3px; color: var(--text); }
.brand span { color: var(--accent); font-weight: 500; font-size: 13px; text-transform: uppercase; letter-spacing: 1.4px; }
.topbar-right { display: flex; gap: 16px; align-items: center; }
.who { color: var(--muted); font-size: 13px; }

.layout { display: grid; grid-template-columns: 210px 1fr; min-height: calc(100vh - 61px); }
.sidebar { border-right: 1px solid var(--line); padding: 18px 12px; display: flex; flex-direction: column; gap: 2px; }
.sidebar a {
  color: var(--muted); padding: 9px 12px; border-radius: 9px; font-size: 14px; text-decoration: none;
}
.sidebar a:hover { background: var(--panel-2); color: var(--text); }
.sidebar a.active { background: linear-gradient(90deg, rgba(181,140,255,.18), transparent); color: var(--text); box-shadow: inset 2px 0 0 var(--accent); }
.content { padding: 26px 30px 60px; max-width: 1280px; }

h1 { font-size: 24px; margin: 0 0 4px; letter-spacing: -0.2px; }
h2 { font-size: 15px; margin: 0 0 12px; color: #cdd3e3; font-weight: 600; letter-spacing: 0.2px; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.muted { color: var(--muted); }
.sub { color: var(--muted); font-size: 12px; }
.hint { color: var(--muted); font-size: 12px; margin: 4px 0 0; }

.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cards { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 16px; }
.grid.form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .span2 { grid-column: span 2; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 18px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.stat .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.8px; }
.stat .value { font-size: 26px; font-weight: 650; margin: 6px 0 2px; }
.stat .value.small { font-size: 18px; }

label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: #c3cad9; }
label.check { flex-direction: row; align-items: center; gap: 8px; }
input[type="text"], input[type="password"], input[type="number"], input[type="url"],
input[type="search"], input[type="file"], select, textarea {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  border-radius: 9px; padding: 9px 11px; font-size: 14px; font-family: inherit; width: 100%;
}
textarea { resize: vertical; font-family: ui-monospace, monospace; font-size: 12.5px; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(181,140,255,.45); outline-offset: 1px; border-color: var(--accent); }
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); }

.btn {
  display: inline-block; border: 1px solid var(--line); background: var(--panel-2);
  color: var(--text); border-radius: 9px; padding: 9px 14px; font-size: 13.5px;
  cursor: pointer; font-family: inherit; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: #252a35; text-decoration: none; }
.btn.primary { background: linear-gradient(180deg, #8f63e8, #7a4fd6); border-color: #8f63e8; color: #fff; }
.btn.danger { background: rgba(255,107,129,.12); border-color: rgba(255,107,129,.5); color: #ffb3c0; }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 10px; font-size: 12.5px; }
.row-actions { display: flex; gap: 8px; align-items: center; flex-wrap: nowrap; }
.row-actions.wrap { flex-wrap: wrap; }
.row-actions input { min-width: 110px; }
form.inline, .inline { display: inline; }
.stack { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }

.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; color: var(--muted); font-weight: 500; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.7px; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.table td { padding: 10px; border-bottom: 1px solid rgba(42,47,58,.6); vertical-align: top; }
.table tr:last-child td { border-bottom: none; }
.table tr.selected { background: rgba(181,140,255,.06); }
.table tr.retired { opacity: 0.55; }

.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; border: 1px solid var(--line); color: var(--muted); }
.pill.healthy, .pill.ok { color: var(--accent-2); border-color: rgba(126,224,192,.4); background: rgba(126,224,192,.08); }
.pill.error, .pill.critical { color: #ffb3c0; border-color: rgba(255,107,129,.45); background: rgba(255,107,129,.1); }
.pill.warning, .pill.degraded, .pill.rate_limited, .pill.open_circuit { color: var(--warn); border-color: rgba(255,191,92,.4); background: rgba(255,191,92,.08); }
.pill.unknown, .pill.disabled, .pill.configuration_error { color: var(--muted); }
.pill.healthy { font-weight: 600; }

.flash { border-radius: 10px; padding: 11px 14px; margin-bottom: 16px; font-size: 13.5px; background: rgba(126,224,192,.09); border: 1px solid rgba(126,224,192,.35); color: #bff3e5; }
.flash.error { background: rgba(255,107,129,.1); border-color: rgba(255,107,129,.4); color: #ffc2cd; }
.flash.warn { background: rgba(255,191,92,.09); border-color: rgba(255,191,92,.4); color: #ffe0ad; }
.notice { background: var(--panel-2); border: 1px dashed var(--line); border-radius: 10px; padding: 12px 14px; margin-bottom: 16px; color: var(--muted); font-size: 13px; }

.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 14px; }
.auth-card h1 { margin: 0; }

.facts { display: grid; grid-template-columns: 150px 1fr; gap: 6px 12px; font-size: 13.5px; margin: 0 0 14px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }

.transcript { display: flex; flex-direction: column; gap: 12px; max-height: 560px; overflow-y: auto; padding-right: 6px; }
.msg { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: var(--panel-2); }
.msg.user { border-left: 3px solid var(--accent); }
.msg.assistant { border-left: 3px solid var(--accent-2); }
.msg .meta { font-size: 11px; color: var(--muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.6px; }
.msg .body { white-space: pre-wrap; word-break: break-word; font-size: 13.5px; }

.plain { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; font-size: 13.5px; }
.breadcrumb { margin-bottom: 14px; font-size: 13px; color: var(--muted); }
.pager { display: flex; gap: 6px; margin-top: 14px; }
.pager a { padding: 4px 9px; border: 1px solid var(--line); border-radius: 7px; font-size: 12.5px; color: var(--muted); }
.pager a.current { color: var(--text); border-color: var(--accent); }
.log { background: #0b0d11; border: 1px solid var(--line); border-radius: 10px; padding: 14px; max-height: 620px; overflow: auto; font-size: 12px; line-height: 1.55; white-space: pre-wrap; word-break: break-all; }
.filters { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
.filters input, .filters select { width: auto; min-width: 180px; }
.tier-row { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; border-bottom: 1px solid rgba(42,47,58,.6); padding: 10px 0; }
.tier-row:last-child { border-bottom: none; }
.tier-row label { width: 110px; }
.tier-row strong { min-width: 80px; }
.filters, .tier-row, .row-actions { margin-bottom: 4px; }

@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; overflow-x: auto; border-right: none; border-bottom: 1px solid var(--line); padding: 10px; }
  .grid.cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.two { grid-template-columns: 1fr; }
  .grid.form-grid { grid-template-columns: 1fr; }
  .form-grid .span2 { grid-column: span 1; }
  .content { padding: 18px 16px 50px; }
  .facts { grid-template-columns: 1fr; }
}
@media (max-width: 620px) {
  .grid.cards { grid-template-columns: 1fr; }
  .filters input, .filters select { min-width: 100%; }
  .row-actions { flex-wrap: wrap; }
}
