:root {
  --bg: #eef4f7;
  --panel: #ffffff;
  --ink: #1f2a30;
  --muted: #66737c;
  --line: #d6e0e5;
  --line-strong: #becbd2;
  --brand: #164a86;
  --brand-dark: #0f3562;
  --accent: #b3332e;
  --warning: #f2b632;
  --orange: #d86636;
  --nav: #164a86;
  --nav-dark: #0f3562;
  --danger: #a12622;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", Arial, Helvetica, sans-serif;
  font-size: 14px;
}

.login-page, .setup {
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card, .panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: 0 1px 3px rgba(31, 42, 48, 0.08);
}

.auth-card {
  width: min(420px, 100%);
  padding: 28px;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 232px;
  padding: 0;
  background: var(--nav);
  color: white;
  border-right: 1px solid #16242b;
}

.sidebar strong {
  display: flex;
  align-items: center;
  min-height: 56px;
  padding: 0 18px;
  background: var(--brand-dark);
  border-bottom: 1px solid rgba(255,255,255,.08);
  font-size: 17px;
}
.sidebar strong img {
  width: 38px;
  height: 38px;
  object-fit: contain;
  margin-right: 10px;
  background: white;
  border-radius: 4px;
  padding: 3px;
}

.auth-logo {
  display: block;
  width: 92px;
  height: auto;
  margin: 0 auto 14px;
}
.sidebar nav { display: grid; padding: 12px 0; }
.sidebar a {
  color: #d8e1e6;
  text-decoration: none;
  padding: 12px 18px;
  border-left: 3px solid transparent;
  font-size: 14px;
}
.sidebar a.active, .sidebar a:hover {
  background: var(--nav-dark);
  border-left-color: var(--accent);
  color: white;
}

.main {
  margin-left: 232px;
  padding: 0 20px 24px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  min-height: 64px;
  margin: 0 -20px 18px;
  padding: 0 20px;
  background: white;
  border-bottom: 1px solid var(--line);
}
.topbar h1 {
  margin: 0 0 2px;
  font-size: 26px;
  font-weight: 400;
  letter-spacing: 0;
}
.topbar span, .muted { color: var(--muted); }

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.metrics article {
  background: white;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 14px 16px;
  min-height: 94px;
  position: relative;
  overflow: hidden;
}
.metrics article::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 4px;
  background: var(--brand);
}
.metrics article:nth-child(2)::after { background: var(--accent); }
.metrics article:nth-child(3)::after { background: var(--warning); }
.metrics article:nth-child(4)::after { background: var(--orange); }
.metrics span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}
.metrics strong {
  display: block;
  margin-top: 10px;
  font-size: 30px;
  line-height: 1;
  font-weight: 400;
}

.grid.two {
  display: grid;
  grid-template-columns: minmax(320px, 410px) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.panel { padding: 0; overflow: hidden; }
.panel h2 {
  margin: 0;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfd;
  font-size: 16px;
  font-weight: 500;
}
.panel > .actions,
.panel > p,
.panel > .table-wrap,
.panel > .muted {
  margin: 16px;
}

form { display: grid; gap: 11px; }
form.panel {
  padding: 0 16px 16px;
}
form.panel h2 {
  margin: 0 -16px 4px;
}
label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  padding: 9px 10px;
  font: inherit;
  color: var(--ink);
  background: white;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(22, 74, 134, .18);
  border-color: var(--brand);
}
textarea { min-height: 82px; resize: vertical; }

button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 18px;
  background: var(--brand);
  color: white;
  padding: 9px 16px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  min-height: 36px;
}
.secondary {
  background: white;
  color: var(--ink);
  border: 1px solid var(--line-strong);
}
.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.error {
  background: #fff1f0;
  border: 1px solid #f1b4b0;
  color: var(--danger);
  border-radius: 6px;
  padding: 10px 12px;
}

.report-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
  padding: 18px 20px;
  border: 1px solid #c7d6df;
  border-radius: 6px;
  background:
    linear-gradient(90deg, rgba(22, 74, 134, .96), rgba(15, 53, 98, .92)),
    #164a86;
  color: white;
  box-shadow: 0 1px 3px rgba(31, 42, 48, .1);
}

.report-hero > div {
  display: flex;
  align-items: center;
  gap: 14px;
}

.report-hero img {
  width: 58px;
  height: 58px;
  object-fit: contain;
  padding: 5px;
  border-radius: 6px;
  background: white;
}

.report-hero span {
  display: block;
  margin-bottom: 3px;
  color: #d9e8f6;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.report-hero h2 {
  margin: 0;
  font-size: 25px;
  font-weight: 500;
}

.report-hero p {
  max-width: 380px;
  margin: 0;
  color: #edf4fb;
  line-height: 1.4;
}

.report-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.report-kpis article {
  position: relative;
  min-height: 104px;
  padding: 15px 16px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  box-shadow: 0 1px 3px rgba(31, 42, 48, .08);
}

.report-kpis article::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: var(--brand);
}

.report-kpis article:nth-child(2)::before { background: var(--accent); }
.report-kpis article:nth-child(3)::before { background: var(--warning); }
.report-kpis article:nth-child(4)::before { background: var(--orange); }
.report-kpis span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.report-kpis strong {
  display: block;
  margin-top: 9px;
  color: var(--ink);
  font-size: 26px;
  font-weight: 500;
  line-height: 1;
}

.report-kpis small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
}

.report-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.report-panel {
  min-height: 285px;
}

.bar-report {
  display: grid;
  gap: 13px;
  margin: 16px;
}

.bar-row {
  display: grid;
  gap: 7px;
}

.bar-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.bar-meta strong {
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}

.bar-meta span {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.bar-track {
  height: 12px;
  overflow: hidden;
  border-radius: 99px;
  background: #e8eef2;
}

.bar-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--brand);
}

.bar-fill.tone-1 { background: var(--accent); }
.bar-fill.tone-2 { background: var(--warning); }
.bar-fill.tone-3 { background: var(--orange); }

.empty-chart .bar-fill {
  opacity: .28;
}

.empty-chart .bar-meta strong,
.empty-chart .bar-meta span {
  color: #8a969d;
}

.export-panel {
  margin-bottom: 14px;
}

.export-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 16px;
}

.export-card {
  display: grid;
  gap: 5px;
  min-height: 78px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  border-top: 4px solid var(--brand);
  color: var(--ink);
  background: #fbfcfd;
  text-decoration: none;
}

.export-card:nth-child(2) { border-top-color: var(--accent); }
.export-card:nth-child(3) { border-top-color: var(--warning); }
.export-card:nth-child(4) { border-top-color: var(--orange); }
.export-card:hover {
  background: #f3f8fb;
  border-color: var(--line-strong);
}

.export-card strong {
  font-size: 15px;
}

.export-card span {
  color: var(--muted);
  font-size: 12px;
}

.report-schedules {
  margin-top: 14px;
}

.line-items {
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 10px;
  margin: 0;
}

.line-items legend {
  padding: 0 5px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.item-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 80px 110px 36px;
  gap: 8px;
  margin-bottom: 8px;
}

.line-item-list {
  display: grid;
  gap: 8px;
}

.icon-button {
  min-height: 36px;
  width: 36px;
  padding: 0;
  border-radius: 50%;
  background: #eef3f6;
  color: var(--accent);
  font-size: 18px;
  line-height: 1;
}

.line-items .add-line {
  width: fit-content;
  margin-top: 2px;
}

.management-panel {
  margin-bottom: 14px;
  border-top: 4px solid var(--brand);
}

.access-panel {
  border-top: 4px solid var(--accent);
}

.access-list {
  display: grid;
  gap: 10px;
  margin: 16px;
}

.access-list article {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fbfcfd;
}

.access-list strong {
  color: var(--brand);
}

.access-list span {
  color: var(--muted);
  line-height: 1.35;
}

.table-wrap { overflow: auto; max-height: 620px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td {
  border-bottom: 1px solid var(--line);
  padding: 10px 8px;
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}
th {
  position: sticky;
  top: 0;
  background: #f5f8fa;
  color: #2c3940;
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
}
tbody tr:hover {
  background: #f7fbfd;
}
td {
  color: #34424a;
}

@media (max-width: 900px) {
  .sidebar {
    position: static;
    width: auto;
  }
  .main { margin-left: 0; padding: 16px; }
  .metrics, .grid.two, .report-kpis, .report-grid, .export-actions { grid-template-columns: 1fr; }
  .report-hero { align-items: flex-start; flex-direction: column; }
  .item-row { grid-template-columns: 1fr; }
  .icon-button { width: 100%; border-radius: 18px; }
  .topbar { align-items: flex-start; }
}
