/* Dashboard Hermes — estilos propios, sin build step. */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #d9dde3;
  --text: #1b2430;
  --muted: #66727f;
  --brand: #1f6feb;
  --brand-dark: #1554b8;
  --ok: #17794c;
  --ok-bg: #d9f2e4;
  --warn: #8a5a00;
  --warn-bg: #fdf0d0;
  --bad: #b3261e;
  --bad-bg: #fbdedc;
  --info: #10559a;
  --info-bg: #dbeafe;
  --purple: #5b3fb5;
  --purple-bg: #e7e0fb;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 12px rgba(16, 24, 40, .05);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161c;
    --surface: #1a1f27;
    --surface-2: #222834;
    --border: #303845;
    --text: #e7ecf2;
    --muted: #98a3b1;
    --brand: #5b9bff;
    --brand-dark: #3d7fe0;
    --ok: #6ee7ad;
    --ok-bg: #123a2a;
    --warn: #f0c274;
    --warn-bg: #3d2f10;
    --bad: #ff9a92;
    --bad-bg: #45191a;
    --info: #93c5fd;
    --info-bg: #14304f;
    --purple: #c4b1ff;
    --purple-bg: #2b2350;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

a { color: var(--brand); }

/* ---------- Layout ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.marca {
  font-weight: 700;
  letter-spacing: -.01em;
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--text);
}

.marca .punto {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--brand);
}

.cuenta-chip {
  font-size: 12px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
}

nav.principal {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  flex: 1;
}

nav.principal a {
  padding: 7px 12px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--muted);
  white-space: nowrap;
  font-weight: 500;
}

nav.principal a:hover { background: var(--surface-2); color: var(--text); }
nav.principal a.activo { background: var(--brand); color: #fff; }

.sesion { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); }

main {
  max-width: 1240px;
  margin: 0 auto;
  padding: 20px 16px 64px;
}

h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: -.02em; }
h2 { font-size: 17px; margin: 0 0 12px; }
.sub { color: var(--muted); margin: 0 0 20px; font-size: 14px; }

.encabezado {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 18px;
}

/* ---------- Tarjetas ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

.grid-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}

.kpi .etiqueta { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.kpi .valor { font-size: 26px; font-weight: 700; letter-spacing: -.02em; margin-top: 4px; }
.kpi .detalle { font-size: 12px; color: var(--muted); margin-top: 2px; }

.pila { display: flex; flex-direction: column; gap: 16px; }

/* ---------- Formularios ---------- */
label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }

input, select, textarea, button {
  font: inherit;
  color: var(--text);
}

input[type=text], input[type=password], input[type=number], input[type=search], select, textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--brand);
  outline-offset: -1px;
  border-color: var(--brand);
}

textarea { min-height: 64px; resize: vertical; }

.campos {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.campo-ancho { grid-column: 1 / -1; }

.acciones { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
  color: var(--text);
}

.btn:hover { background: var(--surface-2); }
.btn-primario { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primario:hover { background: var(--brand-dark); }
.btn-peligro { color: var(--bad); border-color: var(--bad); background: transparent; }
.btn-peligro:hover { background: var(--bad-bg); }
.btn-mini { padding: 4px 9px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Filtros ---------- */
.filtros {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end;
  margin-bottom: 14px;
}
.filtros .campo { min-width: 150px; flex: 1 1 150px; }
.filtros .campo-corto { flex: 0 0 auto; min-width: 120px; }

/* ---------- Tablas ---------- */
.tabla-scroll { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--border);
  background: var(--surface-2); white-space: nowrap; position: sticky; top: 0;
}
tbody td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }
td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.acciones-col { white-space: nowrap; }
.principal-celda { font-weight: 600; }
.secundario { color: var(--muted); font-size: 12px; }

.vacio { padding: 32px 16px; text-align: center; color: var(--muted); }

/* ---------- Estados ---------- */
.pill {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.estado-gris   { background: var(--surface-2); color: var(--muted); }
.estado-azul   { background: var(--info-bg); color: var(--info); }
.estado-morado { background: var(--purple-bg); color: var(--purple); }
.estado-ambar  { background: var(--warn-bg); color: var(--warn); }
.estado-verde  { background: var(--ok-bg); color: var(--ok); }
.estado-rojo   { background: var(--bad-bg); color: var(--bad); }

select.estado-select {
  width: auto; min-width: 128px; padding: 4px 8px; font-size: 12px; font-weight: 600;
  border-radius: 999px;
}

/* ---------- Avisos ---------- */
.aviso {
  padding: 10px 14px; border-radius: 8px; font-size: 14px; margin-bottom: 14px;
  border: 1px solid transparent;
}
.aviso-ok   { background: var(--ok-bg); color: var(--ok); border-color: var(--ok); }
.aviso-error{ background: var(--bad-bg); color: var(--bad); border-color: var(--bad); }
.aviso-info { background: var(--info-bg); color: var(--info); border-color: var(--info); }
.credencial { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; word-break: break-all; }

/* ---------- Itinerario ---------- */
.mes-bloque { margin-bottom: 26px; }
.mes-cabecera {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 12px; flex-wrap: wrap; margin-bottom: 10px;
  padding-bottom: 6px; border-bottom: 2px solid var(--border);
}
.mes-cabecera h2 { margin: 0; }
.mes-totales { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }

.dias { display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: 12px; }
.dia-card { padding: 14px; }
.dia-card.pasado { opacity: .55; }
.dia-card h3 { margin: 0 0 8px; font-size: 15px; }
.dia-lead { padding: 8px 0; border-top: 1px dashed var(--border); }
.dia-lead:first-of-type { border-top: none; }
.dia-lead .fila { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.dia-totales {
  margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--border);
  display: flex; justify-content: space-between; font-size: 13px; font-variant-numeric: tabular-nums;
}

/* ---------- Agenda ---------- */
.agenda-cabecera {
  display: flex; justify-content: space-between; align-items: center;
  gap: 10px; flex-wrap: wrap; margin-bottom: 10px;
}
.agenda-totales { font-size: 14px; display: flex; align-items: center; gap: 8px; }

.latido {
  width: 8px; height: 8px; border-radius: 50%; background: var(--ok);
  display: inline-block; animation: latir 2.5s ease-in-out infinite;
}
@keyframes latir { 0%, 100% { opacity: .25; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .latido { animation: none; opacity: .7; } }

.grilla {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

.slot {
  display: grid;
  grid-template-columns: 68px 1fr;
  gap: 12px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  align-items: start;
}
.slot:last-child { border-bottom: none; }
.slot-pasado { opacity: .5; }
.slot-lleno { background: var(--surface-2); }

.slot-hora {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--muted);
  font-size: 13px;
  padding-top: 6px;
}

.slot-contenido { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.slot-nota { padding: 6px 0; font-size: 12px; }

.slot-libre {
  width: 100%;
  text-align: left;
  padding: 7px 10px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
}
.slot-libre:hover { border-color: var(--brand); color: var(--brand); background: var(--surface-2); }

.cita {
  border-left: 3px solid currentColor;
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--surface-2);
}
.cita .secundario, .cita .cita-pie { color: var(--muted); }
.cita-fila { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.cita-pie {
  display: flex; justify-content: space-between; align-items: center;
  gap: 8px; flex-wrap: wrap; margin-top: 6px; font-size: 12px;
}

.origen { display: inline-flex; align-items: center; gap: 5px; }
.origen::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--muted);
}
.origen-bot::before { background: var(--brand); }
.origen-panel::before { background: var(--ok); }

.check {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 13px; font-weight: 500; color: var(--text); margin: 0;
}
.check input { width: auto; }

/* ---------- Modal ---------- */
dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 0;
  width: min(680px, 94vw);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
}
dialog::backdrop { background: rgba(10, 14, 20, .55); }
dialog .modal-cuerpo { padding: 18px; }
dialog h2 { margin-top: 0; }

/* ---------- Toast ---------- */
#toasts {
  position: fixed; right: 16px; bottom: 16px; z-index: 60;
  display: flex; flex-direction: column; gap: 8px; max-width: min(420px, 92vw);
}
.toast {
  padding: 11px 14px; border-radius: 8px; box-shadow: var(--shadow);
  font-size: 14px; border: 1px solid transparent; background: var(--surface);
}
.toast-ok    { background: var(--ok-bg); color: var(--ok); border-color: var(--ok); }
.toast-error { background: var(--bad-bg); color: var(--bad); border-color: var(--bad); }

/* ---------- Login ---------- */
.login-wrap { min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.login-card { width: min(400px, 100%); padding: 26px; }
.login-card h1 { font-size: 20px; }
.login-card .campo { margin-bottom: 14px; }
.login-card .btn { width: 100%; justify-content: center; }
.privacidad { font-size: 12px; color: var(--muted); margin-top: 16px; line-height: 1.45; }

/* ---------- Utilidades ---------- */
.htmx-request .spinner-inline { display: inline; }
.spinner-inline { display: none; font-size: 12px; color: var(--muted); }
.solo-escritorio { display: table-cell; }

@media (max-width: 820px) {
  .solo-escritorio { display: none; }
  .topbar-inner { padding: 8px 12px; gap: 8px; }
  nav.principal { order: 3; flex: 1 0 100%; }
  .sesion { margin-left: auto; font-size: 12px; gap: 6px; }
  .encabezado { margin-bottom: 12px; }
  .filtros .campo { flex: 1 1 100%; }
  .filtros .campo-corto { flex: 1 1 45%; min-width: 0; }
  main { padding: 14px 12px 56px; }
  h1 { font-size: 19px; }
}
