:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --line: #dbe0e5;
  --text: #17202a;
  --muted: #66717d;
  --green: #087f5b;
  --green-soft: #e6f5ef;
  --amber: #9a6700;
  --amber-soft: #fff4d6;
  --red: #b42318;
  --red-soft: #feeceb;
  --blue: #2457a7;
  --shadow: 0 10px 30px rgba(23, 32, 42, .08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 14px; letter-spacing: 0; }
button, input, select { font: inherit; letter-spacing: 0; }
button { min-height: 36px; border: 1px solid var(--line); border-radius: 6px; padding: 0 13px; background: var(--surface); color: var(--text); cursor: pointer; }
button:hover { border-color: #aeb7c0; background: #f8fafb; }
button:disabled { cursor: not-allowed; opacity: .5; }
button.primary { border-color: var(--green); background: var(--green); color: white; font-weight: 650; }
button.primary:hover { background: #066c4d; }
button.danger { color: var(--red); }
.quiet { background: transparent; }
.icon-button { width: 36px; padding: 0; font-size: 18px; }
.topbar { position: sticky; top: 0; z-index: 10; height: 64px; display: flex; align-items: center; justify-content: space-between; padding: 0 28px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.96); backdrop-filter: blur(10px); }
.brand, .top-actions { display: flex; align-items: center; gap: 10px; }
.brand > div { display: flex; flex-direction: column; gap: 1px; }
.brand span { color: var(--muted); font-size: 12px; }
.brand-mark { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 8px; background: #17202a; color: white; font-weight: 800; }
.brand-mark.small { width: 34px; height: 34px; font-size: 12px; }
.workspace { width: min(1440px, calc(100% - 40px)); margin: 24px auto 60px; }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--line); background: var(--surface); }
.metrics > div { min-width: 0; padding: 18px 20px; border-right: 1px solid var(--line); }
.metrics > div:last-child { border-right: 0; }
.metrics span { display: block; color: var(--muted); font-size: 12px; }
.metrics strong { display: block; margin-top: 5px; font-size: 25px; }
.panel { margin-top: 20px; padding: 0; border-top: 1px solid var(--line); background: var(--surface); }
.section-heading { min-height: 76px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 15px 20px; border-bottom: 1px solid var(--line); }
.section-heading.compact { min-height: 68px; }
h1, h2, p { margin: 0; }
h2 { font-size: 16px; }
.section-heading p { margin-top: 4px; color: var(--muted); font-size: 12px; }
.split { display: grid; grid-template-columns: minmax(300px, .7fr) minmax(500px, 1.3fr); }
.section-block + .section-block { border-left: 1px solid var(--line); }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { height: 48px; padding: 8px 14px; border-bottom: 1px solid #edf0f2; text-align: left; white-space: nowrap; }
th { height: 38px; color: var(--muted); background: #fafbfc; font-size: 11px; text-transform: uppercase; }
td strong { display: block; }
td small { color: var(--muted); }
.actions { display: flex; gap: 6px; }
.actions button { min-height: 30px; padding: 0 9px; font-size: 12px; }
.status { display: inline-flex; align-items: center; min-height: 24px; border-radius: 999px; padding: 2px 9px; font-size: 12px; font-weight: 650; white-space: nowrap; }
.status.ok { background: var(--green-soft); color: var(--green); }
.status.warn { background: var(--amber-soft); color: var(--amber); }
.status.bad { background: var(--red-soft); color: var(--red); }
.status.neutral { background: #edf0f2; color: #4d5965; }
.agent-list, .event-list { padding: 0 18px; }
.agent-row, .event-row { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; min-height: 58px; border-bottom: 1px solid #edf0f2; }
.agent-row:last-child, .event-row:last-child { border-bottom: 0; }
.agent-row small, .event-row small { display: block; margin-top: 3px; color: var(--muted); }
.event-row code { color: var(--muted); font-size: 11px; white-space: normal; word-break: break-word; }
.muted { color: var(--muted); }
dialog { width: min(680px, calc(100% - 28px)); border: 0; border-radius: 8px; padding: 0; box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(23, 32, 42, .48); }
dialog form { padding: 22px; }
.result-detail { padding: 22px; }
.dialog-heading { display: flex; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.dialog-heading p { margin-top: 4px; color: var(--muted); font-size: 12px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
label { display: grid; gap: 6px; color: #46515c; font-size: 12px; font-weight: 650; }
input, select { width: 100%; min-height: 40px; border: 1px solid #bdc5cd; border-radius: 6px; padding: 8px 10px; background: white; color: var(--text); }
input:focus, select:focus { outline: 2px solid rgba(8,127,91,.22); border-color: var(--green); }
.wide { grid-column: 1 / -1; }
.toggle { align-self: end; display: flex; align-items: center; gap: 9px; min-height: 40px; }
.toggle input { width: 18px; min-height: 18px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; }
.form-error { color: var(--red); margin-top: 12px; }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 30; max-width: min(420px, calc(100% - 44px)); padding: 12px 15px; border-radius: 6px; background: #17202a; color: white; box-shadow: var(--shadow); }
.login-page { min-height: 100vh; display: grid; place-items: center; background: #e9edf0; }
.login-shell { width: min(380px, calc(100% - 32px)); padding: 30px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); box-shadow: var(--shadow); }
.login-shell h1 { margin-top: 20px; font-size: 23px; }
.login-shell > p { margin-top: 5px; }
.login-form { display: grid; gap: 16px; margin-top: 25px; }
.login-form button { margin-top: 4px; }
@media (max-width: 900px) {
  .metrics { grid-template-columns: 1fr 1fr; }
  .metrics > div:nth-child(2) { border-right: 0; }
  .metrics > div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .split { grid-template-columns: 1fr; }
  .section-block + .section-block { border-left: 0; border-top: 1px solid var(--line); }
}
@media (max-width: 640px) {
  .topbar { height: auto; min-height: 64px; padding: 10px 14px; align-items: flex-start; }
  .brand > div span, #sync-state { display: none; }
  .top-actions { gap: 5px; }
  .workspace { width: 100%; margin-top: 12px; }
  .metrics, .panel { border-left: 0; border-right: 0; }
  .section-heading { align-items: flex-start; }
  .form-grid { grid-template-columns: 1fr; }
  .wide { grid-column: auto; }
}
