:root {
  --bg: #f7f8f5;
  --surface: #ffffff;
  --surface-2: #eef1ec;
  --ink: #1c2320;
  --ink-soft: #55605a;
  --ink-faint: #838d84;
  --border: #e1e5dc;
  --accent: #1fae66;
  --accent-strong: #14804a;
  --accent-tint: #e3f5ea;
  --warn: #c17d12;
  --warn-tint: #fbf0dc;
  --bad: #d94438;
  --bad-tint: #fbe4e1;
  --ok: #21c45d;
  --ok-tint: #e1f7e9;
  --shadow: 0 1px 2px rgba(20, 30, 24, 0.04), 0 12px 28px -14px rgba(20, 30, 24, 0.16);
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-pill: 999px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14170f;
    --surface: #1a1e16;
    --surface-2: #22271c;
    --ink: #eceae1;
    --ink-soft: #c2c4b6;
    --ink-faint: #8c9080;
    --border: #32362a;
    --accent: #4fd888;
    --accent-strong: #7fe4a8;
    --accent-tint: #1c3527;
    --warn: #e3ac5c;
    --warn-tint: #332818;
    --bad: #ef8074;
    --bad-tint: #3a201a;
    --ok: #4fd888;
    --ok-tint: #1a3324;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 28px -14px rgba(0, 0, 0, 0.6);
  }
}

* { box-sizing: border-box; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Public Sans", -apple-system, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.55;
  margin: 0;
}

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

h1, h2, h3 {
  font-family: "Newsreader", Georgia, serif;
  font-weight: 500;
  margin: 0 0 0.4rem;
}

/* Estructura de la app: sidebar fija + cabecera + contenido */
.app-shell {
  display: grid;
  grid-template-columns: 248px 1fr;
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1.4rem 1rem;
  gap: 1.6rem;
}

.sidebar .brand {
  font-family: "Newsreader", Georgia, serif;
  font-weight: 500;
  font-size: 1.15rem;
  padding: 0 0.6rem;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.6rem 0.9rem;
  border-radius: var(--radius-pill);
  color: var(--ink-soft);
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none;
}
.sidebar-link svg { flex: none; width: 1.15rem; height: 1.15rem; }
.sidebar-link:hover { background: var(--surface-2); color: var(--ink); }
.sidebar-link.active { background: var(--accent); color: #fdfdfb; }

.sidebar-user {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.7rem 0.6rem;
  border-top: 1px solid var(--border);
}
.sidebar-user .nombre {
  font-size: 0.86rem;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-user .salir {
  margin-left: auto;
  flex: none;
  color: var(--ink-faint);
}
.sidebar-user .salir:hover { color: var(--bad); }

.avatar {
  flex: none;
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 50%;
  background: var(--accent-tint);
  color: var(--accent-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Public Sans", sans-serif;
  font-weight: 600;
  font-size: 0.8rem;
}

.app-content {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topheader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.8rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.topheader .center {
  font-size: 0.9rem;
  color: var(--ink-soft);
}

@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    flex-direction: row;
    align-items: center;
    padding: 0.8rem 1rem;
    border-right: none;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    gap: 1rem;
  }
  .sidebar .brand { padding: 0; }
  .sidebar-nav { flex-direction: row; }
  .sidebar-link span { display: none; }
  .sidebar-user { margin-top: 0; border-top: none; padding: 0; }
  .sidebar-user .nombre { display: none; }
}

main {
  max-width: min(1500px, 100%);
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
}

.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.2rem;
  box-shadow: var(--shadow);
}

.auth-card .eyebrow {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.5rem;
}

label {
  display: block;
  font-size: 0.85rem;
  color: var(--ink-soft);
  margin: 1rem 0 0.35rem;
}

input[type="email"],
input[type="password"],
input[type="text"] {
  width: 100%;
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--bg);
  color: var(--ink);
  font-size: 0.95rem;
  font-family: inherit;
}
input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

input[type="date"],
input[type="time"],
input[type="file"],
select,
textarea {
  width: 100%;
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--bg);
  color: var(--ink);
  font-size: 0.95rem;
  font-family: inherit;
}
textarea { resize: vertical; }
select:focus, textarea:focus, input[type="date"]:focus, input[type="time"]:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.6rem;
  box-shadow: var(--shadow);
  max-width: 560px;
}

.radio-group { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 0.4rem; }
.radio-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.92rem;
  color: var(--ink);
  font-weight: 400;
  margin: 0;
}
.radio-option input { width: auto; }

.field-error {
  color: var(--bad);
  font-size: 0.82rem;
  margin-top: 0.3rem;
}

.hint {
  font-size: 0.85rem;
  color: var(--ink-faint);
  margin: 0.5rem 0 0;
}

button, .btn {
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  padding: 0.65rem 1.1rem;
  border-radius: 7px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fdfdfb;
  cursor: pointer;
}
button:hover, .btn:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn-ghost {
  background: transparent;
  color: var(--ink-soft);
  border-color: var(--border);
}
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }

.error-msg {
  background: var(--bad-tint);
  color: var(--bad);
  border-radius: 7px;
  padding: 0.6rem 0.8rem;
  font-size: 0.87rem;
  margin-top: 1rem;
}

.success-msg {
  background: var(--ok-tint);
  color: var(--ok);
  border-radius: 7px;
  padding: 0.6rem 0.8rem;
  font-size: 0.87rem;
  margin-bottom: 1.2rem;
}

.empty-state {
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 2.5rem 1.5rem;
  text-align: center;
  color: var(--ink-faint);
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  background: var(--surface);
}
table { border-collapse: collapse; width: 100%; }
thead th {
  text-align: left;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-faint);
  padding: 0.75rem 0.9rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
tbody td {
  padding: 0.8rem 0.9rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
  color: var(--ink-soft);
}
tbody tr:last-child td { border-bottom: none; }
tbody td:last-child { white-space: nowrap; }
tbody td form { display: inline-block; margin: 0; }

.badge {
  display: inline-block;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.7rem;
  padding: 0.15rem 0.55rem;
  border-radius: 5px;
}
.badge-enviada, .badge-en_revision { background: var(--warn-tint); color: var(--warn); }
.badge-pendiente_justificante { background: var(--bad-tint); color: var(--bad); }
.badge-concedida, .badge-aprobada { background: var(--ok-tint); color: var(--ok); }
.badge-rechazada { background: var(--bad-tint); color: var(--bad); }
.badge-pendiente { background: var(--surface-2); color: var(--ink-faint); }
.badge-cancelada { background: var(--surface-2); color: var(--ink-faint); }

button.btn-approve { background: var(--ok); border-color: var(--ok); }
button.btn-approve:hover { filter: brightness(0.92); }
button.btn-reject { background: var(--bad); border-color: var(--bad); }
button.btn-reject:hover { filter: brightness(0.92); }

/* Dashboard */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.9rem;
  margin-top: 1.5rem;
}
.stat-tile {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.2rem;
  box-shadow: var(--shadow);
  color: inherit;
  text-decoration: none;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
a.stat-tile:hover, a.stat-tile:focus-visible {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg, var(--shadow));
  border-color: var(--accent);
}
.stat-tile .value {
  font-family: "Newsreader", Georgia, serif;
  font-size: 1.9rem;
  font-weight: 500;
  line-height: 1.1;
}
.stat-tile .label { font-size: 0.8rem; color: var(--ink-soft); margin-top: 0.3rem; }
.stat-tile.warn { border-color: var(--warn); background: var(--warn-tint); }
.stat-tile.warn .value { color: var(--warn); }
.stat-tile.bad { border-color: var(--bad); background: var(--bad-tint); }
.stat-tile.bad .value { color: var(--bad); }
.stat-tile.ok .value { color: var(--ok); }

.dash-section { margin-top: 2.6rem; }
.dash-section h2 { font-size: 1.15rem; }
.dash-section .section-sub { font-size: 0.85rem; color: var(--ink-soft); margin-top: -0.15rem; }
.dash-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}
@media (max-width: 720px) {
  .dash-grid { grid-template-columns: 1fr; }
}

.bar-row { display: flex; align-items: center; gap: 0.75rem; margin: 0.55rem 0; font-size: 0.86rem; }
.bar-row .bar-label {
  width: 200px;
  flex: none;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bar-track { flex: 1; height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 4px; }
.bar-fill.warn { background: var(--warn); }
.bar-fill.bad { background: var(--bad); }
.bar-row .bar-value {
  width: 40px;
  flex: none;
  text-align: right;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.78rem;
  color: var(--ink-faint);
}

.progress-track { height: 10px; background: var(--surface-2); border-radius: 5px; overflow: hidden; margin-top: 0.35rem; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 5px; }
.progress-fill.warn { background: var(--warn); }
.progress-fill.bad { background: var(--bad); }

.trend-chart { display: flex; align-items: flex-end; gap: 0.45rem; height: 130px; margin-top: 1.2rem; }
.trend-bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.trend-bar .count { font-size: 0.7rem; color: var(--ink-faint); font-family: "IBM Plex Mono", monospace; margin-bottom: 0.25rem; }
.trend-bar .bar { width: 100%; max-width: 30px; background: var(--accent); border-radius: 4px 4px 0 0; min-height: 3px; }
.trend-bar .mes { font-size: 0.68rem; color: var(--ink-faint); margin-top: 0.35rem; text-transform: uppercase; }

.worker-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.6rem 0; border-bottom: 1px solid var(--border); font-size: 0.88rem; }
.worker-row:last-child { border-bottom: none; }
.worker-row .nombre { color: var(--ink); }
.worker-row .detalle { color: var(--ink-faint); font-size: 0.78rem; }

/* Donut de estados */
.donut-block { display: flex; align-items: center; gap: 2rem; flex-wrap: wrap; margin-top: 1.2rem; }
.donut-block svg { flex: none; }
.donut-total {
  font-family: "Newsreader", Georgia, serif;
  font-size: 1.7rem;
  fill: var(--ink);
}
.donut-total-label { font-size: 0.62rem; fill: var(--ink-faint); font-family: "Public Sans", sans-serif; }
.legend-list { display: flex; flex-direction: column; gap: 0.7rem; font-size: 0.88rem; min-width: 180px; }
.legend-row { display: flex; align-items: center; gap: 0.55rem; }
.legend-dot { width: 0.7rem; height: 0.7rem; border-radius: 50%; flex: none; }
.legend-row .legend-label { color: var(--ink-soft); flex: 1; }
.legend-row .legend-value { font-family: "IBM Plex Mono", monospace; font-size: 0.8rem; color: var(--ink-faint); }

/* Gauges circulares de la bolsa de 20h */
.gauge-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(108px, 1fr));
  gap: 1.2rem;
  margin-top: 1.2rem;
}
.gauge-item { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 0.4rem; }
.gauge-ring-bg { stroke: var(--surface-2); fill: none; }
.gauge-ring-fill { fill: none; stroke-linecap: round; }
.gauge-wrap { position: relative; width: 84px; height: 84px; }
.gauge-wrap .gauge-label-center {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-family: "IBM Plex Mono", monospace; font-size: 0.82rem; color: var(--ink);
}
.gauge-item .nombre { font-size: 0.8rem; color: var(--ink-soft); max-width: 108px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gauge-item .no-computable { font-size: 0.68rem; color: var(--ink-faint); }

/* Línea de tendencia */
.linechart-wrap { margin-top: 1.2rem; overflow-x: auto; }
.linechart-wrap svg { width: 100%; min-width: 480px; height: auto; display: block; }
.linechart-grid { stroke: var(--border); stroke-width: 1; }
.linechart-area { fill: var(--accent-tint); }
.linechart-line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.linechart-dot { fill: var(--accent); }
.linechart-dot.actual { fill: var(--surface); stroke: var(--accent); stroke-width: 2; }
.linechart-label { font-family: "IBM Plex Mono", monospace; font-size: 8px; fill: var(--ink-faint); }
.linechart-value { font-family: "IBM Plex Mono", monospace; font-size: 8px; fill: var(--ink-soft); }

/* Asistente conversacional de IA */
.chat-log { display: flex; flex-direction: column; gap: 1rem; margin: 1.5rem 0; }
.chat-empty { color: var(--ink-faint); font-size: 0.9rem; }
.chat-msg {
  max-width: 80%;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.92rem;
  line-height: 1.5;
}
.chat-msg.usuario { align-self: flex-end; background: var(--accent); color: #fdfdfb; border-bottom-right-radius: 4px; }
.chat-msg.asistente { align-self: flex-start; background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.chat-citas { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.7rem; }
.chat-citas .btn { font-size: 0.82rem; padding: 0.45rem 0.8rem; }
.chat-form { display: flex; gap: 0.6rem; align-items: flex-end; margin-top: 1rem; }
.chat-form textarea { flex: 1; margin: 0; }

/* Barras horizontales de ranking, más visuales que .bar-row */
.rank-row { display: flex; align-items: center; gap: 0.75rem; margin: 0.6rem 0; font-size: 0.86rem; }
.rank-row .rank-label { width: 190px; flex: none; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank-row .rank-track { flex: 1; height: 12px; background: var(--surface-2); border-radius: 6px; overflow: hidden; }
.rank-row .rank-fill { height: 100%; background: var(--accent); border-radius: 6px; }
.rank-row .rank-meta { width: 168px; flex: none; text-align: right; font-size: 0.78rem; color: var(--ink-faint); }
