:root {
  --bg: #f3f5f7;
  --panel: #ffffff;
  --sidebar: #101a24;
  --sidebar-soft: #1a2836;
  --text: #1f2933;
  --muted: #66727f;
  --line: #e2e8ee;
  --accent: #0f766e;
  --accent-soft: #e6f4f2;
  --warn: #b45309;
  --warn-soft: #fdf3e3;
  --danger: #b91c1c;
  --danger-soft: #fdecec;
  --ok: #15803d;
  --ok-soft: #e9f7ee;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 8px 24px rgba(16, 24, 40, .04);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.45;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.layout { display: flex; min-height: 100vh; }

/* ── Sidebar ─────────────────────────────────────────── */
.sidebar {
  width: 248px; flex: 0 0 248px; background: var(--sidebar); color: #dbe4ec;
  display: flex; flex-direction: column; padding: 20px 14px; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 10px 18px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px; background: linear-gradient(135deg, #14b8a6, #0f766e);
  display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 16px;
}
.brand-name { font-weight: 700; color: #fff; font-size: 15px; line-height: 1.1; }
.brand-sub { font-size: 11px; color: #8fa1b3; }
.nav { display: flex; flex-direction: column; gap: 3px; margin-top: 6px; }
.nav-label { font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: #71869a; padding: 14px 10px 6px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px;
  color: #c3cfda; font-weight: 500; font-size: 13.5px;
}
.nav a:hover { background: var(--sidebar-soft); text-decoration: none; color: #fff; }
.nav a.active { background: #0f766e; color: #fff; }
.nav svg { width: 17px; height: 17px; opacity: .9; }
.sidebar-foot { margin-top: auto; padding: 10px; font-size: 11px; color: #71869a; }
.sidebar-foot .chip { display: inline-block; padding: 3px 8px; border-radius: 999px; background: var(--sidebar-soft); color: #a9bccd; margin-bottom: 6px; }

/* ── Main ────────────────────────────────────────────── */
.main { flex: 1; min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 18px 28px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.page-title { font-size: 20px; font-weight: 700; margin: 0; }
.page-sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.userbox { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 700; }
.content { padding: 24px 28px 40px; max-width: 1440px; }

/* ── Badges & banners ───────────────────────────────── */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.badge-demo { background: var(--warn-soft); color: var(--warn); border: 1px solid #f2d6a8; }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-muted { background: #eef2f5; color: var(--muted); }
.badge-live { background: var(--accent-soft); color: var(--accent); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.demo-banner {
  display: flex; align-items: center; gap: 10px; background: var(--warn-soft); color: #7c4a03;
  border: 1px solid #f2d6a8; border-radius: 10px; padding: 10px 14px; margin-bottom: 18px; font-size: 13px;
}
.demo-banner strong { color: #7c4a03; }
.flash { border-radius: 10px; padding: 11px 14px; margin-bottom: 16px; font-size: 13px; }
.flash-ok { background: var(--ok-soft); color: #14532d; border: 1px solid #bfe6cc; }
.flash-err { background: var(--danger-soft); color: #7f1d1d; border: 1px solid #f3c6c6; }
.flash-info { background: #eef4fb; color: #1e3a5f; border: 1px solid #cfe0f2; }

/* ── Cards & grids ───────────────────────────────────── */
.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { padding: 16px 18px 0; display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.card-title { font-size: 14.5px; font-weight: 700; margin: 0; }
.card-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.card-body { padding: 16px 18px 18px; }
.kpi .label { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.kpi .value { font-size: 26px; font-weight: 750; margin-top: 6px; letter-spacing: -.02em; }
.kpi .hint { color: var(--muted); font-size: 12px; margin-top: 4px; }

/* ── Tables ──────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th { text-align: left; color: var(--muted); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .03em; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; background: #fafbfc; }
table.data td { padding: 11px 12px; border-bottom: 1px solid #eef2f5; vertical-align: top; }
table.data tr:last-child td { border-bottom: none; }
table.data tr:hover td { background: #fafcfd; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }

/* ── Forms ───────────────────────────────────────────── */
label { display: block; font-size: 12.5px; font-weight: 600; color: #374151; margin-bottom: 5px; }
input[type=text], input[type=password], input[type=number], input[type=date], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid #cfd8e1; border-radius: 8px; font: inherit;
  background: #fff; color: var(--text); outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(15, 118, 110, .12); }
textarea { min-height: 74px; resize: vertical; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-actions { margin-top: 14px; display: flex; gap: 10px; align-items: center; }
.hint { color: var(--muted); font-size: 12px; }
.btn {
  display: inline-flex; align-items: center; gap: 7px; padding: 9px 15px; border-radius: 8px;
  border: 1px solid transparent; background: var(--accent); color: #fff; font-weight: 600; font-size: 13px; cursor: pointer;
}
.btn:hover { background: #0b5f58; text-decoration: none; }
.btn-secondary { background: #fff; color: var(--text); border-color: #cfd8e1; }
.btn-secondary:hover { background: #f6f8fa; }
.btn-danger { background: #fff; color: var(--danger); border-color: #f0c4c4; }
.btn-danger:hover { background: var(--danger-soft); }
.btn-sm { padding: 6px 11px; font-size: 12px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
details.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
details.panel > summary { cursor: pointer; padding: 15px 18px; font-weight: 700; list-style: none; display: flex; justify-content: space-between; }
details.panel > summary::-webkit-details-marker { display: none; }
details.panel > summary::after { content: "+"; color: var(--muted); font-weight: 600; }
details.panel[open] > summary::after { content: "–"; }
details.panel .panel-body { padding: 0 18px 18px; }

/* ── Chart ───────────────────────────────────────────── */
.chart { display: flex; align-items: flex-end; gap: 3px; height: 150px; padding-top: 8px; }
.chart .bar { flex: 1; background: linear-gradient(180deg, #2dd4bf, #0f766e); border-radius: 2px 2px 0 0; min-height: 2px; opacity: .85; }
.chart .bar:hover { opacity: 1; }
.chart-axis { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; margin-top: 6px; }

/* ── Misc ────────────────────────────────────────────── */
.section-title { font-size: 15px; font-weight: 700; margin: 26px 0 12px; }
.section-title:first-child { margin-top: 0; }
.cluster-list { display: flex; flex-wrap: wrap; gap: 8px; }
.cluster { padding: 6px 11px; border-radius: 8px; background: #fff; border: 1px solid var(--line); font-size: 12.5px; color: var(--text); }
.cluster.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.status-row { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px dashed var(--line); font-size: 13px; }
.status-row:last-child { border-bottom: none; }
.status-row .k { color: var(--muted); }
.status-row .v { font-weight: 600; text-align: right; }
.empty { padding: 26px; text-align: center; color: var(--muted); font-size: 13px; }
.notice { background: #eef4fb; border: 1px solid #cfe0f2; color: #1e3a5f; border-radius: 10px; padding: 12px 14px; font-size: 13px; }
.notice-warn { background: var(--warn-soft); border-color: #f2d6a8; color: #7c4a03; }
.code-inline { background: #eef2f5; border-radius: 5px; padding: 1px 5px; font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
.two-col { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; align-items: start; }

/* ── Login ───────────────────────────────────────────── */
.login-wrap { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(1200px 600px at 20% 0%, #14313a 0%, #0b1319 55%, #070d12 100%); padding: 24px; }
.login-card { width: 100%; max-width: 400px; background: #fff; border-radius: 16px; padding: 30px; box-shadow: 0 30px 80px rgba(0,0,0,.35); }
.login-brand { display: flex; align-items: center; gap: 11px; margin-bottom: 22px; }
.login-title { font-size: 19px; font-weight: 750; margin: 0; }
.login-sub { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.login-form { display: grid; gap: 14px; }
.login-foot { margin-top: 18px; color: var(--muted); font-size: 11.5px; text-align: center; }

@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two-col { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .sidebar { display: none; }
  .grid-3, .grid-2, .form-grid { grid-template-columns: 1fr; }
  .content { padding: 18px; }
  .topbar { padding: 14px 18px; }
}
