:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e5eaf2;
  --blue: #2563eb;
  --blue-soft: #dbeafe;
  --violet: #7c3aed;
  --violet-soft: #ede9fe;
  --green: #16a34a;
  --green-soft: #dcfce7;
  --amber: #d97706;
  --amber-soft: #fef3c7;
  --red: #dc2626;
  --red-soft: #fee2e2;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 8px 24px rgba(15, 23, 42, .06);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 24px; font-weight: 800; margin: 0; letter-spacing: -.02em; }
h2 { font-size: 16px; font-weight: 700; margin: 0 0 14px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; text-align: right; }

/* layout */
.layout { display: flex; min-height: 100vh; }
.side {
  width: 248px; flex-shrink: 0; background: #0f172a; color: #cbd5e1; padding: 22px 14px;
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 22px; color: #fff; }
.brand-logo {
  width: 38px; height: 38px; border-radius: 11px; background: var(--blue); display: grid; place-items: center;
  font-weight: 800; font-size: 18px; color: #fff;
}
.brand b { display: block; font-size: 16px; }
.brand span { font-size: 12px; color: #94a3b8; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px;
  color: #cbd5e1; font-weight: 500; margin-bottom: 2px;
}
.nav a:hover { background: rgba(255, 255, 255, .06); text-decoration: none; color: #fff; }
.nav a.on { background: var(--blue); color: #fff; }
.nav .ico { width: 20px; text-align: center; }
.nav .badge { margin-left: auto; background: var(--amber); color: #fff; border-radius: 99px; padding: 0 8px; font-size: 12px; }
.side-foot { margin-top: auto; padding: 10px 12px; font-size: 12px; }
.side-foot a { color: #94a3b8; }
.main { flex: 1; min-width: 0; padding: 28px 32px 60px; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }

/* blocks */
.card { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 20px; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush > h2 { padding: 18px 20px 0; }
.grid { display: grid; gap: 16px; }
.kpis { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); margin-bottom: 20px; }
.kpi { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 18px 16px; position: relative; overflow: hidden; }
.kpi .label { color: var(--muted); font-weight: 500; font-size: 13px; padding-right: 22px; position: relative; z-index: 1; }
.kpi .value { font-size: 28px; font-weight: 800; letter-spacing: -.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: 12px; color: var(--muted); }
.kpi::after { content: ""; position: absolute; right: -26px; top: -26px; width: 56px; height: 56px; border-radius: 50%; background: var(--c, var(--blue-soft)); opacity: .9; }
.kpi.blue { --c: var(--blue-soft); }
.kpi.violet { --c: var(--violet-soft); }
.kpi.green { --c: var(--green-soft); }
.kpi.amber { --c: var(--amber-soft); }
.two { grid-template-columns: 2fr 1fr; }
.half { grid-template-columns: 1fr 1fr; }

/* tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: #f8fafc; white-space: nowrap; }
th a { color: inherit; }
th a.on { color: var(--blue); }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #f8fbff; }
.person { display: flex; align-items: center; gap: 10px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--blue-soft); color: var(--blue); display: grid; place-items: center; font-weight: 700; flex-shrink: 0; object-fit: cover; }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; background: #f1f5f9; padding: 2px 7px; border-radius: 6px; font-size: 12px; }

/* pills */
.pill { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill.green { background: var(--green-soft); color: var(--green); }
.pill.amber { background: var(--amber-soft); color: var(--amber); }
.pill.red { background: var(--red-soft); color: var(--red); }
.pill.blue { background: var(--blue-soft); color: var(--blue); }
.pill.gray { background: #f1f5f9; color: var(--muted); }
.plus { color: var(--green); font-weight: 600; }
.minus { color: var(--red); font-weight: 600; }

/* forms */
input, select, textarea {
  font: inherit; color: var(--ink); background: #fff; border: 1px solid #d6dde8; border-radius: 10px;
  padding: 9px 12px; width: 100%; outline: none; transition: border .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37, 99, 235, .15); }
textarea { min-height: 110px; resize: vertical; }
label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; }
.field { margin-bottom: 16px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.check input { width: auto; }
.btn {
  display: inline-flex; align-items: center; gap: 6px; border: 0; border-radius: 10px; padding: 9px 16px;
  font: inherit; font-weight: 600; cursor: pointer; background: var(--blue); color: #fff; white-space: nowrap;
}
.btn:hover { filter: brightness(1.07); text-decoration: none; }
.btn.ghost { background: #eef2f7; color: var(--ink); }
.btn.green { background: var(--green); }
.btn.red { background: var(--red); }
.btn.sm { padding: 6px 11px; font-size: 13px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row > input, .row > select { width: auto; flex: 1; min-width: 140px; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tabs a { padding: 7px 14px; border-radius: 99px; background: #fff; color: var(--ink); box-shadow: var(--shadow); font-weight: 500; }
.tabs a.on { background: var(--blue); color: #fff; }
.tabs a:hover { text-decoration: none; }

.flash { padding: 12px 16px; border-radius: 12px; margin-bottom: 18px; font-weight: 500; }
.flash.ok { background: var(--green-soft); color: #166534; }
.flash.err { background: var(--red-soft); color: #991b1b; }

.progress { height: 8px; border-radius: 99px; background: #e2e8f0; overflow: hidden; min-width: 120px; }
.progress > i { display: block; height: 100%; background: var(--blue); border-radius: 99px; }

.list-kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 18px; }
.list-kv dt { color: var(--muted); }
.list-kv dd { margin: 0; font-weight: 600; }
.copy { display: flex; gap: 8px; }
.copy input { font-family: ui-monospace, Menlo, monospace; font-size: 13px; }
pre.json { background: #0f172a; color: #e2e8f0; border-radius: 10px; padding: 12px; font-size: 12px; max-height: 260px; overflow: auto; white-space: pre-wrap; word-break: break-all; margin: 8px 0 0; }
details summary { cursor: pointer; color: var(--blue); }
.pager { display: flex; gap: 6px; padding: 14px 20px; }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.chart-box { position: relative; height: 300px; }

/* login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: radial-gradient(circle at 80% 0%, #dbeafe, transparent 50%), radial-gradient(circle at 0% 100%, #ede9fe, transparent 45%), var(--bg); }
.login { width: 100%; max-width: 380px; background: #fff; border-radius: 22px; box-shadow: var(--shadow); padding: 32px; }
.login .brand { color: var(--ink); padding: 0 0 22px; }
.login .brand span { color: var(--muted); }

@media (max-width: 1000px) {
  .two, .half { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .layout { display: block; }
  .side { position: static; width: auto; height: auto; padding: 12px 16px; }
  .brand { padding: 0 0 10px; }
  .nav { display: flex; gap: 4px; overflow-x: auto; padding-bottom: 4px; }
  .nav a { white-space: nowrap; margin: 0; }
  .side-foot { display: none; }
  .main { padding: 18px 16px 40px; }
  h1 { font-size: 20px; }
}
