:root {
  --bg: #f6f8fa; --panel: #ffffff; --ink: #1f2328; --muted: #57606a;
  --line: #d8dee4; --brand: #1f6feb; --brand-soft: #ddf4ff;
  --green: #1a7f37; --amber: #9a6700; --red: #cf222e; --violet: #8250df;
  --radius: 10px; --shadow: 0 1px 3px rgba(31,35,40,.08), 0 6px 18px rgba(31,35,40,.05);
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- layout ---------- */
.layout { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar {
  background: #0d1117; color: #c9d1d9; padding: 18px 12px; position: sticky; top: 0;
  height: 100vh; overflow-y: auto;
}
.sidebar .brand {
  color: #fff; font-weight: 700; font-size: 15px; padding: 6px 10px 16px;
  display: flex; align-items: center; gap: 8px; letter-spacing: .2px;
}
.sidebar nav a {
  display: flex; align-items: center; gap: 9px; color: #c9d1d9; padding: 9px 10px;
  border-radius: 7px; margin-bottom: 2px; font-size: 13.5px;
}
.sidebar nav a:hover { background: #161b22; color: #fff; text-decoration: none; }
.sidebar nav a.active { background: var(--brand); color: #fff; font-weight: 600; }
.sidebar .sep { height: 1px; background: #21262d; margin: 12px 6px; }
.sidebar .foot { font-size: 11.5px; color: #6e7681; padding: 10px; }

.main { padding: 22px 26px 60px; max-width: 1400px; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; margin-bottom: 20px; flex-wrap: wrap;
}
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 12px; }
.sub { color: var(--muted); font-size: 13px; margin-top: 3px; }

/* ---------- cards ---------- */
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow); margin-bottom: 18px;
}
.card h2 { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.grid { display: grid; gap: 14px; }
.grid.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.c4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1000px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { height: auto; position: static; }
  .grid.c3, .grid.c4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 620px) { .grid.c2, .grid.c3, .grid.c4 { grid-template-columns: 1fr; } }

.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow); }
.stat .label { color: var(--muted); font-size: 12px; text-transform: uppercase;
  letter-spacing: .4px; }
.stat .value { font-size: 26px; font-weight: 700; margin-top: 4px; }
.stat.warn .value { color: var(--red); }
.stat.ok .value { color: var(--green); }
.stat.info .value { color: var(--brand); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--line);
  vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase;
  letter-spacing: .3px; white-space: nowrap; }
tbody tr:hover { background: #f6f8fa; }
td.num, th.num { text-align: right; white-space: nowrap; }
.empty { color: var(--muted); padding: 26px; text-align: center; }

/* ---------- badges ---------- */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11.5px;
  font-weight: 600; border: 1px solid transparent; white-space: nowrap;
}
.badge.gray { background: #eaeef2; color: #57606a; }
.badge.blue { background: var(--brand-soft); color: #0969da; }
.badge.green { background: #dafbe1; color: var(--green); }
.badge.amber { background: #fff8c5; color: var(--amber); }
.badge.red { background: #ffebe9; color: var(--red); }
.badge.violet { background: #fbefff; color: var(--violet); }

/* ---------- progress ---------- */
.bar { height: 7px; background: #eaeef2; border-radius: 999px; overflow: hidden;
  min-width: 90px; }
.bar > i { display: block; height: 100%; background: var(--brand); border-radius: 999px; }
.bar.ok > i { background: var(--green); }
.bar.warn > i { background: #d29922; }
.bar.bad > i { background: var(--red); }

/* ---------- forms ---------- */
form .row { margin-bottom: 13px; }
label { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted);
  margin-bottom: 5px; }
input[type=text], input[type=password], input[type=date], input[type=time],
input[type=number], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 7px;
  font: inherit; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(31,111,235,.12);
}
textarea { min-height: 84px; resize: vertical; }
.inline { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.inline .row { flex: 1 1 150px; margin-bottom: 0; }
.check { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--ink); }
.check input { width: auto; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px;
  border-radius: 7px; border: 1px solid var(--line); background: #fff; color: var(--ink);
  font: inherit; font-weight: 600; font-size: 13px; cursor: pointer;
}
.btn:hover { background: #f3f4f6; text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: #1a5fd0; }
.btn.danger { background: #fff; border-color: #ffc1bc; color: var(--red); }
.btn.danger:hover { background: #ffebe9; }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- misc ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px;
  flex-wrap: wrap; }
.tabs a { padding: 8px 13px; border-bottom: 2px solid transparent; color: var(--muted);
  font-weight: 600; font-size: 13.5px; }
.tabs a.active { color: var(--ink); border-bottom-color: var(--brand); }
.tabs a:hover { text-decoration: none; color: var(--ink); }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 13.5px;
  border: 1px solid; }
.flash.ok { background: #dafbe1; border-color: #aceebb; color: var(--green); }
.flash.err { background: #ffebe9; border-color: #ffc1bc; color: var(--red); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 6px 14px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: linear-gradient(160deg, #0d1117 0%, #161b22 100%); }
.login-card { background: #fff; border-radius: 14px; padding: 30px; width: 100%;
  max-width: 370px; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.login-card h1 { font-size: 19px; margin-bottom: 4px; }
.login-card .sub { margin-bottom: 20px; }
