:root {
  --bg: #f4f6f9; --card: #fff; --text: #1d2433; --muted: #6b7280; --line: #e3e7ee;
  --primary: #2563eb; --primary-d: #1d4ed8; --ok: #16a34a; --warn: #d97706; --bad: #dc2626; --info: #0891b2;
  --radius: 10px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.1);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font: 14px/1.45 -apple-system, "Segoe UI", Roboto, Inter, Arial, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

header.top { background: #111827; color: #e5e7eb; display: flex; align-items: center; gap: 18px; padding: 0 20px; height: 52px; position: sticky; top: 0; z-index: 20; }
header.top .brand { font-weight: 700; color: #fff; letter-spacing: .2px; }
header.top nav a { color: #cbd5e1; padding: 16px 4px; display: inline-block; margin-right: 12px; border-bottom: 2px solid transparent; }
header.top nav a.active, header.top nav a:hover { color: #fff; border-color: var(--primary); text-decoration: none; }
header.top .status { margin-left: auto; display: flex; gap: 14px; font-size: 12.5px; color: #cbd5e1; align-items: center; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #6b7280; margin-right: 5px; vertical-align: middle; }
.dot.ok { background: var(--ok); } .dot.bad { background: var(--bad); } .dot.warn { background: var(--warn); }
.badge-mock { background: var(--warn); color: #111; padding: 2px 8px; border-radius: 999px; font-weight: 600; font-size: 11px; }

main { max-width: 1280px; margin: 0 auto; padding: 22px 20px 60px; }
h1 { font-size: 22px; margin: 0 0 16px; } h2 { font-size: 16px; margin: 0 0 12px; } h3 { font-size: 14px; margin: 14px 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; margin-bottom: 16px; }
.grid { display: grid; gap: 14px; }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); } .grid.cols-3 { grid-template-columns: repeat(3, 1fr); } .grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) { .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 600px) { .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; } header.top nav { display: none; } }

.stat { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 14px; }
.stat .v { font-size: 22px; font-weight: 700; } .stat .l { color: var(--muted); font-size: 12px; }

button, .btn { font: inherit; border: 1px solid var(--line); background: #fff; color: var(--text); padding: 7px 12px; border-radius: 8px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
button:hover, .btn:hover { background: #f8fafc; text-decoration: none; }
button.primary { background: var(--primary); border-color: var(--primary); color: #fff; } button.primary:hover { background: var(--primary-d); }
button.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
button.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
button.sm { padding: 4px 8px; font-size: 12.5px; }
button:disabled { opacity: .5; cursor: default; }

input, select, textarea { font: inherit; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--text); width: 100%; }
textarea { min-height: 90px; resize: vertical; } textarea.tall { min-height: 320px; font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
label { display: block; font-size: 12.5px; color: var(--muted); margin: 10px 0 4px; }
label.inline { display: inline-flex; align-items: center; gap: 6px; margin: 6px 12px 0 0; color: var(--text); } label.inline input { width: auto; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.field { margin-bottom: 4px; }

table { width: 100%; border-collapse: collapse; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: #f8fafc; font-weight: 600; font-size: 12.5px; color: var(--muted); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tr.clickable { cursor: pointer; } tr.clickable:hover td { background: #f8fafc; }
.nowrap { white-space: nowrap; }
.muted { color: var(--muted); } .small { font-size: 12px; }
.right { text-align: right; }

.tag { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: #e5e7eb; color: #374151; white-space: nowrap; }
.tag.ok { background: #dcfce7; color: #166534; } .tag.bad { background: #fee2e2; color: #991b1b; } .tag.warn { background: #fef3c7; color: #92400e; }
.tag.info { background: #e0f2fe; color: #075985; } .tag.live { background: #ede9fe; color: #5b21b6; animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { opacity: .55; } }

.progress { height: 8px; background: #e5e7eb; border-radius: 999px; overflow: hidden; }
.progress > div { height: 100%; background: var(--primary); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.tabs button { border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none; padding: 8px 12px; color: var(--muted); }
.tabs button.active { color: var(--text); border-color: var(--primary); font-weight: 600; }
.tab { display: none; } .tab.active { display: block; }

.banner { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 14px; }
.banner.bad { background: #fee2e2; color: #7f1d1d; } .banner.warn { background: #fef3c7; color: #78350f; } .banner.info { background: #e0f2fe; color: #0c4a6e; }

#toasts { position: fixed; right: 16px; bottom: 16px; z-index: 50; display: flex; flex-direction: column; gap: 8px; }
.toast { background: #111827; color: #fff; padding: 10px 14px; border-radius: 8px; box-shadow: var(--shadow); max-width: 380px; }
.toast.bad { background: var(--bad); } .toast.ok { background: var(--ok); }

.modal-bg { position: fixed; inset: 0; background: rgba(17,24,39,.45); display: none; align-items: center; justify-content: center; z-index: 40; }
.modal-bg.open { display: flex; }
.modal { background: #fff; border-radius: 12px; padding: 20px 22px; width: min(720px, 94vw); max-height: 92vh; overflow: auto; }

.dialog { display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 78%; padding: 8px 12px; border-radius: 12px; line-height: 1.4; }
.msg.user { align-self: flex-end; background: #dbeafe; border-bottom-right-radius: 3px; }
.msg.assistant { align-self: flex-start; background: #f1f5f9; border-bottom-left-radius: 3px; }
.msg .who { font-size: 11px; color: var(--muted); margin-bottom: 2px; }

.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { display: grid; grid-template-columns: 70px 110px 1fr; gap: 10px; padding: 5px 0; border-bottom: 1px dashed var(--line); font-size: 12.5px; }
.timeline .t { color: var(--muted); font-variant-numeric: tabular-nums; }
.kv { display: grid; grid-template-columns: 180px 1fr; gap: 6px 12px; }
.kv .k { color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: #eef2ff; color: #3730a3; padding: 3px 9px; border-radius: 999px; font-size: 12px; display: inline-flex; gap: 6px; align-items: center; }
.chip b { cursor: pointer; }
pre.code { background: #0f172a; color: #e2e8f0; padding: 12px; border-radius: 8px; overflow: auto; font-size: 12px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar input, .toolbar select { width: auto; }
.pager { display: flex; gap: 8px; align-items: center; margin-top: 10px; color: var(--muted); font-size: 12.5px; }
.login { max-width: 360px; margin: 12vh auto; }
.days { display: flex; gap: 6px; } .days label { margin: 0; }
.days span { display: inline-block; padding: 5px 9px; border: 1px solid var(--line); border-radius: 6px; cursor: pointer; user-select: none; }
.days input { display: none; } .days input:checked + span { background: var(--primary); color: #fff; border-color: var(--primary); }
.eta { font-size: 12.5px; color: var(--muted); }
