:root {
  --bg: #f7f8fa;
  --surface: #eef1f4;
  --elevated: #ffffff;
  --variant: #e8ebf0;
  --ink: #1a1f2c;
  --muted: #5c6570;
  --outline: #e3e6ec;
  --primary: #1b4f8a;
  --secondary: #0f2744;
  --success: #1b7a4a;
  --error: #b42318;
  --warning: #9a6700;
  --header: #0f2744;
  --cta: #1b4f8a;
  --radius: 4px;
  --shadow: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html, body, button, input, select, textarea {
  font-family: "Montserrat", system-ui, sans-serif;
}
body {
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  font-weight: 400;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.auth-split {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: #fff;
}
.auth-hero {
  background: var(--header);
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 48px 56px 32px;
  border-right: 1px solid rgba(255, 255, 255, 0.12);
}
.auth-hero-inner {
  max-width: 440px;
  margin-top: 18vh;
}
.auth-logo {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 28px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
  display: inline-block;
}
.auth-hero-title {
  font-size: 26px;
  line-height: 1.35;
  font-weight: 500;
  margin: 0 0 12px;
}
.auth-hero-lede {
  margin: 0;
  color: rgba(255, 255, 255, 0.7);
  font-size: 14px;
  font-weight: 400;
}
.auth-hero-copy {
  margin-top: auto;
  color: rgba(255, 255, 255, 0.45);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.02em;
}
.auth-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  background: #fff;
}
.auth-panel-inner {
  width: 100%;
  max-width: 360px;
}
.auth-heading {
  margin: 0 0 8px;
  font-size: 22px;
  font-weight: 600;
  text-align: left;
}
.auth-sub {
  text-align: left;
  color: var(--muted);
  margin: 0 0 28px;
  font-size: 13px;
}
.auth-form .field label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--ink);
}
.auth-form .input,
.auth-panel input[type="email"],
.auth-panel input[type="password"] {
  background: #fff;
  border: 1px solid var(--outline);
  border-radius: var(--radius);
  padding: 11px 12px;
}
.auth-form .input:focus,
.auth-panel input:focus {
  outline: none;
  border-color: var(--primary);
}
.btn-auth {
  width: 100%;
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-top: 8px;
  background: var(--primary);
  font-weight: 600;
}
.auth-foot {
  text-align: left;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 13px;
}
.auth-foot a { font-weight: 600; }

.brand-mark {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #fff;
}

@media (max-width: 900px) {
  .auth-split { grid-template-columns: 1fr; }
  .auth-hero { min-height: auto; padding: 28px 24px 24px; border-right: 0; border-bottom: 1px solid rgba(255,255,255,0.12); }
  .auth-hero-inner { margin-top: 8px; }
  .auth-hero-title { font-size: 20px; }
}

.page-title { margin: 0 0 6px; font-size: 20px; font-weight: 600; }
.lede { color: var(--muted); margin: 0 0 20px; font-size: 13px; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 6px; }
.input, select.input, textarea.input, input[type="text"], input[type="email"], input[type="password"], input[type="date"], input[type="file"], select {
  width: 100%;
  border: 1px solid var(--outline);
  background: #fff;
  border-radius: var(--radius);
  padding: 10px 12px;
  font: inherit;
  color: var(--ink);
}
input[type="checkbox"] { width: auto; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: var(--radius);
  padding: 9px 14px;
  font: inherit;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { text-decoration: none; background: #163f6e; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-cta { background: var(--cta); color: #fff; }
.btn-ghost { background: transparent; color: var(--secondary); border: 1px solid var(--outline); }
.btn-ghost:hover { background: var(--surface); }
.btn-danger { background: var(--error); color: #fff; }
.btn-sm { padding: 6px 10px; font-size: 12px; width: auto; }

.errors, .errorlist { color: var(--error); font-size: 13px; padding: 0; margin: 0 0 12px; list-style: none; }
.messages { list-style: none; padding: 0; margin: 0 0 16px; }
.messages li { padding: 10px 12px; border-radius: var(--radius); margin-bottom: 8px; font-size: 13px; border: 1px solid var(--outline); }
.messages .success { background: #e4f5ea; color: var(--success); }
.messages .error { background: #fde8e6; color: var(--error); }
.messages .info { background: #eef3f8; color: var(--secondary); }

.app {
  display: grid;
  grid-template-columns: 228px 1fr;
  min-height: 100vh;
  background: var(--bg);
}
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--header);
  color: #fff;
  padding: 28px 18px 20px;
}
.sidebar .brand-mark {
  font-size: 13px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}
.sidebar nav { margin-top: 22px; display: flex; flex-direction: column; gap: 2px; }
.sidebar a {
  color: rgba(255, 255, 255, 0.72);
  padding: 9px 12px;
  border-radius: var(--radius);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  border-left: 2px solid transparent;
}
.sidebar a.active {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border-left-color: #fff;
}
.sidebar a:hover { background: rgba(255,255,255,0.08); color: #fff; text-decoration: none; }
.sidebar .btn-ghost { color: #fff; border-color: rgba(255,255,255,0.28); }
.sidebar .btn-ghost:hover { background: rgba(255,255,255,0.08); }
.sidebar .user {
  margin-top: auto;
  padding-top: 24px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.55);
  font-weight: 500;
}
.main { padding: 28px 36px 48px; }
.topbar { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.period-chips { display: flex; gap: 6px; }
.chip {
  display: inline-flex;
  align-items: center;
  padding: 7px 12px;
  border-radius: var(--radius);
  background: #fff;
  border: 1px solid var(--outline);
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
}
.chip:hover { text-decoration: none; border-color: var(--primary); }
.chip.active { background: var(--header); color: #fff; border-color: var(--header); }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 20px; }
.kpi {
  background: var(--elevated);
  border: 1px solid var(--outline);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.kpi .label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
.kpi .value { font-size: 26px; font-weight: 600; margin-top: 8px; }
.kpi .delta { font-size: 12px; font-weight: 500; margin-top: 6px; }
.delta-up { color: var(--success); }
.delta-down { color: var(--error); }
.delta-flat { color: var(--muted); }

.card {
  background: var(--elevated);
  border: 1px solid var(--outline);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 16px;
}
.card h2 { margin: 0 0 14px; font-size: 14px; font-weight: 600; letter-spacing: 0.02em; }
.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; }
.filters .field { min-width: 140px; flex: 1; margin-bottom: 0; }
.filters .field-search { flex: 2; min-width: 200px; }
.table-wrap { overflow: auto; max-height: min(70vh, 720px); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--outline); }
th {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  position: sticky;
  top: 0;
  background: var(--elevated);
  z-index: 1;
}
tbody tr:hover { background: #f4f6f8; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 2px; font-size: 11px; font-weight: 600; }
.badge-ok { background: #e4f5ea; color: var(--success); }
.badge-off { background: var(--variant); color: var(--muted); }
.badge-warn { background: #eef3f8; color: var(--secondary); }
.muted { color: var(--muted); }
.row-actions { display: flex; gap: 8px; }
.split { display: grid; grid-template-columns: 1.2fr 0.8fr; gap: 16px; }
.layout-stack { display: flex; flex-direction: column; gap: 16px; }
.layout-stack .card { margin-bottom: 0; }
.tools-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.pagination { display: flex; gap: 8px; margin-top: 16px; align-items: center; }
audio { width: 100%; margin-top: 8px; }
.empty-state {
  text-align: center;
  padding: 36px 16px;
  color: var(--muted);
}
.empty-state p { margin: 0 0 12px; }
.charts-grid { display: grid; grid-template-columns: 1.4fr 0.8fr; gap: 16px; }
.chart-box { position: relative; height: 260px; }
.rank-link { font-weight: 600; }

@media (max-width: 960px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; display: flex; flex-direction: row; flex-wrap: wrap; gap: 16px; align-items: center; }
  .sidebar nav { flex-direction: row; margin-top: 0; flex-wrap: wrap; }
  .sidebar .brand-mark { border-bottom: 0; padding-bottom: 0; }
  .sidebar .user { margin-top: 0; padding-top: 0; }
  .kpis, .split, .charts-grid, .tools-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  .kpis, .split, .charts-grid, .tools-grid { grid-template-columns: 1fr; }
  .main { padding: 16px; }
}
