:root {
  --bg: #f3f6fb;
  --panel: #ffffff;
  --ink: #0b1630;
  --muted: #6b778c;
  --line: #dfe6f1;
  --nav: #0f1a2b;
  --accent: #ff6b3d;
  --blue: #348ff2;
  --green: #1c9b71;
  --red: #df3f46;
  --orange: #f2a30f;
  --shadow: 0 20px 50px rgba(15, 26, 43, .12);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 20% 20%, rgba(255, 107, 61, .18), transparent 32%),
    radial-gradient(circle at 80% 10%, rgba(52, 143, 242, .16), transparent 28%),
    var(--bg);
}
.login-card {
  width: min(480px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
  padding: 34px;
}
.login-card h1 { margin: 24px 0 8px; font-size: 34px; }
.login-card p { color: var(--muted); line-height: 1.55; }
.login-card form { display: grid; gap: 14px; margin: 22px 0; }
.login-card label { display: grid; gap: 7px; color: #40506a; font-weight: 650; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  padding: 13px 14px;
  color: var(--ink);
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(52, 143, 242, .14); }
.brand-row { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  background: linear-gradient(135deg, #ff7b36, #ee442f);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 26px;
  font-weight: 900;
}
.brand-row strong { display: block; font-size: 18px; }
.brand-row span { display: block; color: #8b98ad; font-size: 13px; margin-top: 3px; }
.primary, .ghost {
  border: 0;
  border-radius: 14px;
  padding: 13px 18px;
  font-weight: 800;
}
.primary { background: var(--accent); color: #fff; }
.full { width: 100%; }
.ghost { background: #fff; border: 1px solid var(--line); color: var(--ink); }
.ghost.danger { color: var(--red); }
.form-error {
  background: #fff1f2;
  color: var(--red);
  border: 1px solid #ffd4d8;
  padding: 12px;
  border-radius: 14px;
}
.muted { color: var(--muted); }

.shell { min-height: 100vh; display: grid; grid-template-columns: 320px 1fr; }
.sidebar {
  background: var(--nav);
  color: #fff;
  padding: 28px 20px;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 28px;
}
.sidebar .brand-row span { color: #a9b8cf; }
.sidebar nav { display: grid; gap: 8px; }
.nav-item {
  border: 0;
  border-radius: 16px;
  padding: 17px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  color: #c8d4e6;
  background: transparent;
  text-align: left;
  font-size: 17px;
}
.nav-item.active { background: #18263a; color: #fff; box-shadow: inset 4px 0 0 var(--accent); }
.nav-item span { flex: 1; }
.nav-item b {
  min-width: 28px;
  height: 28px;
  border-radius: 999px;
  background: #263a56;
  display: grid;
  place-items: center;
  font-size: 13px;
}
.sidebar-foot {
  margin-top: auto;
  border-top: 1px solid rgba(255,255,255,.12);
  padding-top: 22px;
  color: #b9c7dc;
  display: grid;
  gap: 7px;
}
.sidebar-foot strong { color: #fff; font-size: 18px; }

main { min-width: 0; }
.topbar {
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  padding: 28px 44px;
  display: flex;
  justify-content: space-between;
  gap: 24px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: .12em;
  font-size: 13px;
  font-weight: 900;
}
h1, h2, h3 { margin: 0; }
.topbar h1 { font-size: clamp(26px, 3vw, 42px); }
.top-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: flex-end; }
.search {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  min-width: 360px;
}
.search input { border: 0; padding-left: 0; box-shadow: none; }
#app, #loading { padding: 34px 44px; }
.state-card, .empty {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 22px;
  color: var(--muted);
}
.hero {
  background: #1c314b;
  color: #fff;
  border-radius: 26px;
  padding: 30px 36px;
  display: flex;
  justify-content: space-between;
  gap: 22px;
  box-shadow: var(--shadow);
}
.hero small { color: #bed0e7; }
.hero strong { font-size: clamp(28px, 4vw, 42px); white-space: nowrap; }
.grid { display: grid; gap: 22px; }
.kpi-grid { grid-template-columns: repeat(4, minmax(180px, 1fr)); margin: 24px 0; }
.two-col { grid-template-columns: minmax(0, 2fr) minmax(320px, 1fr); }
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: 0 8px 28px rgba(15,26,43,.06);
  padding: 24px;
}
.kpi-card {
  border-top: 5px solid var(--green);
  min-height: 140px;
  display: grid;
  align-content: center;
  gap: 10px;
}
.kpi-card.red { border-top-color: var(--red); }
.kpi-card.orange { border-top-color: var(--orange); }
.kpi-card.blue { border-top-color: var(--blue); }
.kpi-card span, .subtle { color: var(--muted); }
.kpi-card strong { font-size: 32px; }
.delta-pos { color: var(--green); }
.delta-neg { color: var(--red); }
.toolbar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.toolbar select, .toolbar input { max-width: 260px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 14px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: #66738a; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
td strong { font-weight: 900; }
.progress {
  height: 8px;
  background: #e9eef7;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 7px;
}
.progress span { display: block; height: 100%; background: var(--green); }
.progress.low span { background: var(--red); }
.progress.mid span { background: var(--orange); }
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  background: #edf4ff;
  color: #2266b7;
  padding: 6px 10px;
  font-weight: 800;
  font-size: 12px;
}
.badge.red { background: #fff1f2; color: var(--red); }
.badge.green { background: #eaf8f2; color: var(--green); }
.badge.orange { background: #fff7e1; color: #a86800; }
.list { display: grid; gap: 14px; }
.item {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  background: #fff;
}
.item.clickable { cursor: pointer; transition: .16s ease; }
.item.clickable:hover { transform: translateY(-2px); box-shadow: 0 12px 30px rgba(15,26,43,.09); }
.item-head { display: flex; justify-content: space-between; gap: 18px; }
.item h3 { font-size: 18px; line-height: 1.35; }
.item p { color: var(--muted); line-height: 1.45; margin: 8px 0 0; }
.metrics-line { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.metrics-line span { color: #42516a; background: #f4f7fb; border-radius: 999px; padding: 6px 10px; font-size: 13px; }
.manager-cards { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.manager-card h3 { margin-bottom: 8px; }
.mini-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 16px; }
.mini {
  background: #f6f8fc;
  border-radius: 14px;
  padding: 12px;
}
.mini span { display: block; color: var(--muted); font-size: 12px; }
.mini strong { display: block; margin-top: 4px; }
.route-split { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); }
.status-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); display: inline-block; }
.status-dot.ok { background: var(--green); }
.status-dot.warn { background: var(--orange); }
.status-dot.bad { background: var(--red); }
.task-check { display: flex; align-items: center; gap: 10px; }
.task-check input { width: auto; }
textarea { min-height: 74px; resize: vertical; }
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 12, 24, .56);
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 28px;
}
.modal {
  width: min(1120px, 100%);
  max-height: 90vh;
  overflow: auto;
  background: #fff;
  border-radius: 26px;
  box-shadow: var(--shadow);
  padding: 28px;
  position: relative;
}
.modal-close {
  position: sticky;
  top: 0;
  margin-left: auto;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 14px;
  background: #eef3fb;
  font-size: 28px;
}
.detail-grid { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); margin: 18px 0; }
.nowrap { white-space: nowrap; }

@media (max-width: 1100px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; }
  .sidebar nav { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
  .topbar, .hero { flex-direction: column; }
  .search { min-width: 100%; }
  .kpi-grid, .two-col, .route-split { grid-template-columns: 1fr; }
}

@media (max-width: 680px) {
  .topbar, #app, #loading { padding: 22px; }
  .sidebar { padding: 22px; }
  .hero { padding: 24px; }
  table { display: block; overflow-x: auto; }
}
