:root {
  --bg: #eef3fb;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --ink: #101827;
  --muted: #64748b;
  --line: #dfe8f6;
  --brand: #d7a63c;
  --brand-dark: #9b7425;
  --accent: #e23d2e;
  --ok: #157347;
  --warn: #9a6700;
  --side-a: #070b12;
  --side-b: #171f2b;
  --logo-glow: rgba(245, 196, 83, .28);
  --button-bg: #ffffff;
  --input-bg: #ffffff;
  --sidebar-link: #d8dee6;
  --sidebar-link-hover: #ffffff;
  --status-bg: #eef2f6;
  --shadow: 0 18px 52px rgba(15, 23, 42, .08);
}

[data-theme="dark"] {
  --bg: #09111e;
  --panel: #111b2a;
  --panel-soft: #0d1624;
  --ink: #f5f7fb;
  --muted: #a9b6c8;
  --line: #26364c;
  --brand: #89aefc;
  --brand-dark: #6389df;
  --accent: #ff6b5c;
  --ok: #5ed39a;
  --warn: #ffd166;
  --side-a: #070b12;
  --side-b: #0d1624;
  --logo-glow: rgba(137, 174, 252, .24);
  --button-bg: #0c1422;
  --input-bg: #0c1422;
  --sidebar-link: #cfd7e4;
  --sidebar-link-hover: #ffffff;
  --status-bg: #0a1321;
  --shadow: 0 18px 52px rgba(0, 0, 0, .26);
}

[data-theme="logo"] {
  --bg: #090d14;
  --panel: #101722;
  --panel-soft: #151f2d;
  --ink: #fff7e8;
  --muted: #c0ad88;
  --line: #2b3442;
  --brand: #f2bd4b;
  --brand-dark: #c98c2e;
  --accent: #d9342b;
  --ok: #3cc783;
  --warn: #f2bd4b;
  --side-a: #05070b;
  --side-b: #111827;
  --logo-glow: rgba(242, 189, 75, .38);
  --button-bg: #121b28;
  --input-bg: #0d1420;
  --sidebar-link: #e7d6b0;
  --sidebar-link-hover: #fff7e8;
  --status-bg: #09111e;
  --shadow: 0 22px 64px rgba(0, 0, 0, .38);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: var(--bg);
  color: var(--ink);
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.login-body {
  display: grid;
  grid-template-columns: 1fr;
  place-items: center;
  padding: 24px;
  background: radial-gradient(circle at 50% 0%, rgba(215, 166, 60, .22), transparent 34%), var(--bg);
}

[data-theme="dark"] .login-body {
  background: radial-gradient(circle at 50% 0%, rgba(137, 174, 252, .16), transparent 34%), var(--bg);
}

[data-theme="logo"] .login-body {
  background:
    radial-gradient(circle at 50% 0%, rgba(242, 189, 75, .18), transparent 34%),
    radial-gradient(circle at 15% 15%, rgba(217, 52, 43, .13), transparent 28%),
    var(--bg);
}

.login-panel {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 26px;
  box-shadow: var(--shadow);
}

.login-brand { color: var(--ink); margin-bottom: 18px; }
.login-theme { justify-content: flex-end; margin-bottom: 18px; }

.sidebar {
  background: linear-gradient(180deg, var(--side-a), var(--side-b));
  color: white;
  padding: 22px 16px;
}

.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }

.brand-logo {
  width: 54px;
  height: 54px;
  object-fit: cover;
  border-radius: 10px;
  box-shadow: 0 0 28px var(--logo-glow);
  flex: 0 0 auto;
}

.brand small { display: block; color: var(--muted); margin-top: 3px; }

nav { display: grid; gap: 6px; }

nav a {
  color: var(--sidebar-link);
  text-decoration: none;
  padding: 11px 12px;
  border-radius: 6px;
  font-weight: 600;
}

nav a.active,
nav a:hover {
  background: rgba(215, 166, 60, .18);
  color: var(--sidebar-link-hover);
}

.main { padding: 24px; min-width: 0; }

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 20px;
}

.topbar-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

h1 { margin: 0; font-size: 28px; letter-spacing: 0; }
h2 { margin: 0 0 14px; font-size: 18px; letter-spacing: 0; }
p { color: var(--muted); }
.topbar p { margin: 5px 0 0; }

.button,
button {
  border: 1px solid var(--line);
  background: var(--button-bg);
  color: var(--ink);
  border-radius: 6px;
  padding: 10px 14px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
}

.button.primary,
button.primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #161007;
}

.button.primary:hover,
button.primary:hover { background: var(--brand-dark); }

.theme-switch {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.theme-switch button {
  min-height: 34px;
  padding: 7px 10px;
  border: 0;
  background: transparent;
  color: var(--muted);
}

.theme-switch button.active {
  background: var(--brand);
  color: #161007;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .12);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}

.panel-head { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin-bottom: 12px; }
.actions-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.actions-row form { margin: 0; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(140px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpis article { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 18px; box-shadow: var(--shadow); }
.kpis span { color: var(--muted); display: block; margin-bottom: 8px; }
.kpis strong { font-size: 30px; }
.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; }
td small { display: block; color: var(--muted); margin-top: 2px; }
a { color: var(--brand); font-weight: 700; }

.status {
  display: inline-block;
  padding: 5px 8px;
  border-radius: 999px;
  background: var(--status-bg);
  font-size: 12px;
  font-weight: 700;
}

.status.em-rota { background: #fff4cc; color: var(--warn); }
.status.finalizada { background: #dff5e8; color: var(--ok); }
.status.vencida { background: #fee4e2; color: var(--accent); }
.status.atencao { background: #fff4cc; color: var(--warn); }
.status.ok { background: #dff5e8; color: var(--ok); }

.muted { color: var(--muted); font-size: 13px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(220px, 1fr)); gap: 14px; }
.form-grid.compact { grid-template-columns: repeat(4, minmax(160px, 1fr)); }
.wide { grid-column: 1 / -1; }

label { display: grid; gap: 6px; color: var(--muted); font-weight: 700; font-size: 13px; }

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 11px;
  font: inherit;
  background: var(--input-bg);
  color: var(--ink);
}

textarea { resize: vertical; min-height: 80px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; }
.stop-picker { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }

.stop-picker-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  background: var(--panel-soft);
  border-bottom: 1px solid var(--line);
}

.stop-picker-head span { color: var(--muted); font-size: 13px; }
.stop-list { max-height: 360px; overflow: auto; display: grid; }

.stop-option {
  grid-template-columns: 24px 1fr 88px;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  font-weight: 400;
}

.stop-option input[type="checkbox"] { width: 18px; height: 18px; }
.stop-option small { display: block; color: var(--muted); margin-top: 3px; }
.order-input { min-width: 70px; }
.split { display: grid; grid-template-columns: 1.1fr .9fr; gap: 18px; }
.grid-panels { display: grid; grid-template-columns: repeat(2, minmax(260px, 1fr)); gap: 18px; }
.stack { display: grid; gap: 12px; }
.details { display: grid; grid-template-columns: 150px 1fr; gap: 10px 14px; margin: 0; }
.details dt { color: var(--muted); font-weight: 700; }
.details dd { margin: 0; }
.route-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.route-grid span { border: 1px solid var(--line); border-radius: 6px; padding: 12px; color: var(--muted); }
.route-grid strong { display: block; color: var(--ink); margin-top: 5px; }
.route-text { color: var(--ink); margin-top: 0; }
.empty { color: var(--muted); text-align: center; padding: 20px; }
.flash { padding: 12px 14px; border-radius: 6px; margin-bottom: 12px; font-weight: 700; }
.flash.success { background: #dff5e8; color: var(--ok); }

@media (max-width: 900px) {
  body { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  .kpis, .split, .grid-panels, .form-grid, .form-grid.compact, .route-grid { grid-template-columns: 1fr; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .topbar-actions { justify-content: flex-start; }
}
