:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #172033;
  --muted: #718096;
  --line: #e4e8ef;
  --dark: #172131;
  --dark-2: #223044;
  --blue: #1389cf;
  --green: #61a83f;
  --amber: #f08a18;
  --red: #cf3c31;
  --shadow: 0 10px 28px rgba(22, 32, 51, .08);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.45 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}
a { color: inherit; text-decoration: none; }
h1 { margin: 0; font-size: 26px; font-weight: 650; letter-spacing: 0; }
p { margin: 6px 0 0; color: var(--muted); }

.shell { min-height: 100vh; display: flex; }
.sidebar {
  width: 230px;
  flex: 0 0 230px;
  background: var(--dark);
  color: #b7c1cf;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { padding: 18px 20px 16px; border-bottom: 1px solid rgba(255,255,255,.06); }
.brand-title { color: #fff; font-size: 20px; font-weight: 800; }
.brand-title span { color: #51a9e8; }
.brand-sub { margin-top: 2px; color: #718096; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
nav { padding: 14px 10px; }
.nav-link {
  display: block;
  padding: 10px 12px;
  border-radius: 7px;
  color: #b7c1cf;
  font-weight: 600;
  margin-bottom: 3px;
}
.nav-link:hover { background: var(--dark-2); color: #fff; }
.nav-link.active { background: #2b405b; color: #fff; border-left: 3px solid var(--amber); }
.logout { margin-top: auto; padding: 14px 20px; border-top: 1px solid rgba(255,255,255,.06); }
.logout .user { color: #fff; font-weight: 700; margin-bottom: 4px; }
.logout button { border: 0; padding: 0; background: none; color: #718096; cursor: pointer; }

.main { min-width: 0; flex: 1; }
.topbar {
  height: 48px;
  background: #202020;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
}
.crumb { color: #9aa3ad; font-size: 12px; }
.live { color: #b7c1cf; font-size: 12px; }
.content { padding: 24px; max-width: 1420px; }

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
}
.head-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.back { display: inline-block; color: var(--blue); font-weight: 700; margin-bottom: 8px; }

.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)); gap: 14px; margin-bottom: 16px; }
.kpi {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  box-shadow: var(--shadow);
  border-top: 4px solid var(--blue);
}
.kpi:nth-child(2) { border-top-color: var(--green); }
.kpi:nth-child(3) { border-top-color: var(--amber); }
.kpi:nth-child(4) { border-top-color: var(--red); }
.kpi-label { color: var(--muted); text-transform: uppercase; font-size: 11px; font-weight: 800; letter-spacing: .06em; }
.kpi-value { font-size: 28px; font-weight: 800; margin-top: 4px; }
.kpi-note { color: var(--muted); font-size: 12px; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  overflow: hidden;
}
.card-head {
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  font-weight: 800;
  color: #2b3a50;
  background: #fbfcfe;
}
.pad { padding: 16px; }
.toolbar { padding: 12px; }
.filters { display: flex; gap: 10px; align-items: center; }
.filters input { flex: 1; }

.two-col { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(320px, .95fr); gap: 16px; }
.form-grid {
  padding: 16px;
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 12px;
  align-items: end;
}
.form-grid.compact { border-top: 1px solid var(--line); grid-template-columns: repeat(2, minmax(160px, 1fr)); }
.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  color: #536176;
  font-weight: 700;
  font-size: 12px;
}
.wide { grid-column: 1 / -1; }
.input {
  width: 100%;
  border: 1px solid #d7dde7;
  background: #fff;
  color: var(--ink);
  border-radius: 6px;
  min-height: 38px;
  padding: 8px 10px;
  font: inherit;
}
textarea.input { resize: vertical; }
.input:focus { outline: 3px solid rgba(19, 137, 207, .13); border-color: var(--blue); }

.btn {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 8px 14px;
  font-weight: 800;
  cursor: pointer;
}
.btn.primary { background: var(--blue); color: #fff; }
.btn.primary:hover { background: #0e74b0; }
.btn.ghost { background: #fff; border-color: var(--line); color: #24506d; }
.btn.ghost:hover { background: #f2f7fb; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 800px; }
th, td { border-bottom: 1px solid var(--line); padding: 11px 12px; text-align: left; vertical-align: top; }
th {
  color: #6b778b;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
  background: #fbfcfe;
}
tr:hover td { background: #f9fbfe; }
.link { color: #126c9f; font-weight: 800; }
.muted { color: var(--muted); }
.small { font-size: 12px; margin-top: 2px; }
.hint-cell { max-width: 360px; color: #46566d; }
.empty { text-align: center; color: var(--muted); padding: 28px; }

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}
.b-blue { color: #0c628f; background: #dff2ff; }
.b-slate { color: #4b5563; background: #eef1f4; }
.b-amber { color: #94520a; background: #fff0dc; }
.b-green { color: #1d6b3b; background: #def4e7; }
.b-red { color: #9d1f18; background: #ffe1de; }
.b-dark { color: #ffffff; background: #374151; }

.hints { margin: 0; padding-left: 18px; color: #344257; }
.hints li + li { margin-top: 10px; }

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #162235 0%, #26384e 60%, #f4f6f8 60%);
}
.login-card {
  width: min(380px, calc(100vw - 32px));
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 28px 80px rgba(0,0,0,.22);
  padding: 26px;
  display: grid;
  gap: 14px;
}
.login-logo { font-size: 24px; color: var(--ink); font-weight: 900; }
.login-logo span { color: var(--blue); }
.login-card h1 { font-size: 22px; }
.login-card label { display: grid; gap: 6px; color: var(--muted); font-weight: 700; font-size: 12px; }
.error { background: #ffe1de; color: #9d1f18; padding: 10px 12px; border-radius: 6px; font-weight: 700; }

@media (max-width: 980px) {
  .shell { display: block; }
  .sidebar { width: 100%; height: auto; position: static; display: block; }
  nav { display: flex; gap: 6px; overflow-x: auto; padding: 10px; }
  .nav-link { white-space: nowrap; margin: 0; }
  .logout { display: none; }
  .topbar { height: auto; min-height: 52px; gap: 10px; flex-wrap: wrap; padding: 10px 14px; }
  .content { padding: 16px 12px; }
  .kpi-grid, .two-col, .form-grid { grid-template-columns: 1fr; }
  .filters { flex-direction: column; align-items: stretch; }
  .page-head { flex-direction: column; }
  table { min-width: 720px; }
}
