:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --sidebar: #111827;
  --text: #172033;
  --muted: #738097;
  --line: #e7ebf1;
  --accent: #2463eb;
  --accent-soft: #eaf1ff;
  --success: #14865b;
  --warning: #d58a16;
  --danger: #c63d4f;
  --shadow: 0 12px 32px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

button, input { font: inherit; }

.layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 255px 1fr;
}

.layout[hidden],
.login-screen[hidden] {
  display: none;
}

.sidebar {
  background: var(--sidebar);
  color: #fff;
  padding: 28px 18px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 36px;
  padding: 0 8px;
}

.brand-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  background: #fff;
  color: var(--sidebar);
  font-weight: 800;
}

.brand strong { display: block; font-size: 15px; }
.brand span { color: #8e9aad; font-size: 12px; }

nav { display: grid; gap: 8px; }

.nav-item {
  border: 0;
  color: #aeb7c7;
  background: transparent;
  text-align: left;
  padding: 12px 14px;
  border-radius: 10px;
  cursor: pointer;
}

.nav-item:hover, .nav-item.active {
  background: rgba(255,255,255,.09);
  color: #fff;
}

.sidebar-footer {
  margin-top: auto;
  display: flex;
  gap: 9px;
  align-items: center;
  color: #aeb7c7;
  font-size: 12px;
  padding: 10px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 4px rgba(34,197,94,.12);
}

.main {
  padding: 32px 38px 48px;
  min-width: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  margin-bottom: 28px;
}

.eyebrow, .panel-kicker {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .12em;
}

h1, h2 { margin: 0; }
h1 { font-size: 29px; letter-spacing: -.04em; }
h2 { font-size: 18px; }

.btn {
  border: 0;
  border-radius: 10px;
  padding: 10px 15px;
  cursor: pointer;
}

.btn.secondary {
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.section { display: none; }
.section.active { display: block; }

.cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

.card, .panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.card {
  padding: 20px;
}

.card span, .card small {
  display: block;
  color: var(--muted);
}

.card span { font-size: 13px; }
.card strong {
  display: block;
  margin: 10px 0 5px;
  font-size: 28px;
  letter-spacing: -.04em;
}
.card small { font-size: 11px; }

.grid-two {
  display: grid;
  grid-template-columns: 1.5fr .9fr;
  gap: 18px;
}

.panel {
  overflow: hidden;
}

.panel-header {
  padding: 20px 22px 14px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.filters {
  display: flex;
  gap: 8px;
}

input {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 9px;
  padding: 9px 11px;
  outline: none;
}

input:focus { border-color: #a9c1ff; box-shadow: 0 0 0 3px #edf3ff; }

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

table {
  border-collapse: collapse;
  width: 100%;
  min-width: 680px;
}

th, td {
  padding: 13px 18px;
  border-top: 1px solid var(--line);
  text-align: left;
  font-size: 13px;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .05em;
  background: #fbfcfe;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 11px;
  font-weight: 700;
}

.badge.carmen { color: #1d6d4b; background: #e8f7f0; }
.badge.caupolican { color: #795307; background: #fff5db; }
.badge.alemania { color: #7f2f3b; background: #fdecee; }

.money-positive { color: var(--success); font-weight: 700; }

.route-stats {
  padding: 8px 22px 24px;
  display: grid;
  gap: 16px;
}

.route-stat-row {
  display: grid;
  gap: 7px;
}

.route-stat-head {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
}

.progress {
  height: 8px;
  background: #eef1f5;
  border-radius: 99px;
  overflow: hidden;
}

.progress > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.goal-progress {
  width: 130px;
}

.empty {
  color: var(--muted);
  text-align: center;
  padding: 24px !important;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  background: #111827;
  color: #fff;
  padding: 11px 15px;
  border-radius: 10px;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: .2s;
  font-size: 13px;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: var(--bg);
  padding: 16px;
}

.login-card {
  width: 100%;
  max-width: 340px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 28px 26px;
  display: grid;
  gap: 10px;
  text-align: center;
}

.login-card .brand-icon {
  margin: 0 auto 6px;
  background: var(--sidebar);
  color: #fff;
}

.login-card h1 {
  font-size: 20px;
}

.login-card .muted {
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 8px;
}

.login-card label {
  text-align: left;
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

.login-card input {
  width: 100%;
}

.btn.primary {
  background: var(--accent);
  color: #fff;
  margin-top: 10px;
}

.login-error {
  color: var(--danger);
  font-size: 12px;
  min-height: 16px;
  margin: 0;
}

.logout-btn {
  margin-left: auto;
  border: 0;
  background: transparent;
  color: #aeb7c7;
  cursor: pointer;
  font-size: 12px;
  text-decoration: underline;
}

.logout-btn:hover {
  color: #fff;
}

.admin-form {
  padding: 4px 22px 22px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.admin-form input[type="text"],
.admin-form input[type="password"] {
  flex: 1;
  min-width: 180px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

.checkbox-label input {
  width: auto;
}

.admin-form + .login-error {
  padding: 0 22px 14px;
}

select {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 9px;
  padding: 9px 11px;
  outline: none;
}

.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  padding: 4px 22px 0;
  gap: 6px;
}

.calendar-weekdays span {
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  padding: 8px 22px 22px;
}

.calendar-day {
  min-height: 72px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 6px;
  font-size: 12px;
  color: var(--muted);
}

.calendar-day.empty {
  border: 0;
  background: transparent;
}

.calendar-day.has-jornadas {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.calendar-day .day-number {
  font-weight: 700;
  color: var(--text);
}

.calendar-day .day-badge {
  display: inline-block;
  margin-top: 6px;
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 700;
}

@media (max-width: 640px) {
  .calendar-day { min-height: 52px; font-size: 11px; }
}

.btn.link {
  background: transparent;
  border: 0;
  color: var(--accent);
  padding: 0;
  cursor: pointer;
  font-size: 13px;
  text-decoration: underline;
}

@media (max-width: 1050px) {
  .cards { grid-template-columns: repeat(2, 1fr); }
  .grid-two { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    height: auto;
    position: static;
    padding: 16px;
  }
  .brand { margin-bottom: 14px; }
  nav { grid-template-columns: repeat(4, 1fr); overflow-x: auto; }
  .nav-item { text-align: center; white-space: nowrap; }
  .sidebar-footer { display: none; }
  .main { padding: 22px 15px 36px; }
  .cards { grid-template-columns: 1fr; }
  .topbar { align-items: flex-end; }
  .responsive { align-items: flex-start; flex-direction: column; }
  .filters { width: 100%; flex-direction: column; }
  .filters input { width: 100%; }
}
