/* ===========================================================================
   TURO OS — Sistema de diseño
   ---------------------------------------------------------------------------
   Dirección: consola de operaciones. Rejilla estricta, jerarquía por escala
   tipográfica, profundidad por capas de superficie y borde — no por sombras
   grandes. Es una herramienta de trabajo diario con mucho número en pantalla,
   así que la legibilidad de las cifras manda sobre la decoración.

   Decisión clave: TODO número de dinero usa numerales tabulares. Sin eso las
   columnas de una tabla contable no alinean y el ojo no puede comparar.
   =========================================================================== */

/* ── Tokens ──────────────────────────────────────────────────────────────── */
:root {
  /* Superficies: papel cálido, no blanco puro — menos fatiga en jornada larga */
  --paper:        #faf9f7;
  --surface:      #ffffff;
  --surface-2:    #f4f2ef;
  --surface-3:    #eceae6;
  --overlay:      rgba(23, 21, 18, 0.45);

  /* Tinta */
  --ink:          #171512;
  --ink-2:        #4a453e;
  --ink-3:        #7a736a;
  --ink-4:        #a9a196;

  /* Bordes */
  --line:         #e2ded8;
  --line-strong:  #cfc9c0;

  /* Acento: ámbar industrial. Un solo acento, usado con intención. */
  --accent:       #b45309;
  --accent-hover: #92400e;
  --accent-soft:  #fef3e2;
  --accent-line:  #f0d5ab;

  /* Semánticos: en contabilidad el color ES información, no decoración */
  --income:       #15803d;
  --income-soft:  #eaf6ee;
  --expense:      #b91c1c;
  --expense-soft: #fdeceb;
  --warn:         #a16207;
  --warn-soft:    #fdf6e3;
  --info:         #1d4ed8;
  --info-soft:    #eef2ff;
  --neutral-soft: #f1efec;

  /* Tipografía */
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
             "Helvetica Neue", Arial, sans-serif;
  --font-num: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono",
              Consolas, "Liberation Mono", monospace;

  --t-micro: 0.6875rem;   /* 11px — etiquetas de columna, metadatos */
  --t-small: 0.8125rem;   /* 13px — texto secundario, celdas densas */
  --t-body:  0.875rem;    /* 14px — cuerpo de la interfaz */
  --t-lead:  1rem;
  --t-h3:    1.125rem;
  --t-h2:    1.5rem;
  --t-h1:    1.875rem;
  --t-mega:  2.5rem;      /* cifras principales del tablero */

  /* Ritmo: escala de 4px, no padding uniforme en todo */
  --s1: 0.25rem;  --s2: 0.5rem;   --s3: 0.75rem;  --s4: 1rem;
  --s5: 1.5rem;   --s6: 2rem;     --s7: 3rem;     --s8: 4rem;

  --r-sm: 3px;  --r-md: 5px;  --r-lg: 8px;  --r-pill: 999px;

  --shadow-1: 0 1px 2px rgba(23, 21, 18, 0.06);
  --shadow-2: 0 2px 8px rgba(23, 21, 18, 0.08);
  --shadow-3: 0 12px 32px rgba(23, 21, 18, 0.14);

  --dur: 140ms;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);

  --sidebar-w: 232px;
  --topbar-h: 56px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ── Reset ───────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-ui);
  font-size: var(--t-body);
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}

img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ── Estructura de la aplicación ─────────────────────────────────────────── */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* Barra lateral ----------------------------------------------------------- */
.sidebar {
  background: var(--ink);
  color: var(--surface-2);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s4) var(--s4);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar__mark {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  background: var(--accent);
  color: #fff;
  border-radius: var(--r-md);
  font-weight: 700;
  font-size: var(--t-small);
  letter-spacing: -0.02em;
  flex-shrink: 0;
}

.sidebar__name {
  font-weight: 650;
  letter-spacing: -0.01em;
  color: #fff;
  line-height: 1.1;
}
.sidebar__tag {
  display: block;
  font-size: var(--t-micro);
  color: var(--ink-4);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 500;
}

.sidebar__nav { padding: var(--s4) var(--s2); flex: 1; }

.nav__section {
  font-size: var(--t-micro);
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: #6b635a;
  font-weight: 600;
  padding: var(--s4) var(--s3) var(--s2);
}
.nav__section:first-child { padding-top: 0; }

.nav__link {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: 7px var(--s3);
  border-radius: var(--r-md);
  color: #c9c2b8;
  font-size: var(--t-small);
  font-weight: 500;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.nav__link:hover { background: rgba(255, 255, 255, 0.06); color: #fff; text-decoration: none; }
.nav__link.is-active { background: var(--accent); color: #fff; }
.nav__link.is-active .nav__icon { opacity: 1; }

.nav__icon { width: 16px; height: 16px; opacity: 0.6; flex-shrink: 0; }

.nav__count {
  margin-left: auto;
  font-size: var(--t-micro);
  font-family: var(--font-num);
  background: rgba(255, 255, 255, 0.12);
  padding: 1px 6px;
  border-radius: var(--r-pill);
}
.nav__count--alert { background: var(--expense); color: #fff; }

.sidebar__foot {
  padding: var(--s3) var(--s4);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: var(--t-micro);
  color: #6b635a;
}

/* Área principal ---------------------------------------------------------- */
.main { display: flex; flex-direction: column; min-width: 0; }

.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: var(--s4);
  padding: 0 var(--s5);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar__title { font-size: var(--t-lead); font-weight: 620; letter-spacing: -0.015em; }
.topbar__right { margin-left: auto; display: flex; align-items: center; gap: var(--s3); }

.user-chip {
  display: flex; align-items: center; gap: var(--s2);
  padding: var(--s1) var(--s2) var(--s1) var(--s1);
  border-radius: var(--r-pill);
  background: var(--surface-2);
  font-size: var(--t-small);
}
.user-chip__avatar {
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: grid; place-items: center;
  font-size: var(--t-micro); font-weight: 700;
}
.user-chip__rol {
  font-size: var(--t-micro); color: var(--ink-3);
  text-transform: uppercase; letter-spacing: 0.05em;
}

.content { padding: var(--s5); flex: 1; max-width: 1560px; width: 100%; }

/* ── Encabezado de página ────────────────────────────────────────────────── */
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--s4);
  margin-bottom: var(--s5);
  flex-wrap: wrap;
}
.page-head__title { font-size: var(--t-h2); font-weight: 650; letter-spacing: -0.025em; }
.page-head__sub { color: var(--ink-3); font-size: var(--t-small); margin-top: 2px; }
.page-head__actions { display: flex; gap: var(--s2); }

/* ── Botones ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  padding: 7px 14px;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  font-size: var(--t-small);
  font-weight: 550;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease),
              color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-hover); }

.btn--secondary { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.btn--secondary:hover { background: var(--surface-2); border-color: var(--ink-4); }

.btn--ghost { background: transparent; color: var(--ink-2); }
.btn--ghost:hover { background: var(--surface-2); color: var(--ink); }

.btn--danger { background: var(--expense); color: #fff; }
.btn--danger:hover { background: #991b1b; }

.btn--sm { padding: 4px 10px; font-size: var(--t-micro); }
.btn--block { width: 100%; }

/* ── Superficies ─────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
}
.card__head {
  padding: var(--s3) var(--s4);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
}
.card__title { font-size: var(--t-body); font-weight: 600; letter-spacing: -0.01em; }
.card__body { padding: var(--s4); }
.card__body--flush { padding: 0; }
.card__foot {
  padding: var(--s3) var(--s4);
  border-top: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
}

/* ── Rejillas ────────────────────────────────────────────────────────────── */
.grid { display: grid; gap: var(--s4); }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid--sidebar { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }

@media (max-width: 1100px) {
  .grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid--sidebar { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .grid--2, .grid--3, .grid--4 { grid-template-columns: 1fr; }
}

/* ── Indicadores (KPI) ───────────────────────────────────────────────────── */
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--s4);
  position: relative;
  overflow: hidden;
}
/* Filo de color a la izquierda: identifica la métrica sin gritar */
.stat::before {
  content: ''; position: absolute; inset: 0 auto 0 0; width: 3px;
  background: var(--line-strong);
}
.stat--income::before  { background: var(--income); }
.stat--expense::before { background: var(--expense); }
.stat--accent::before  { background: var(--accent); }
.stat--info::before    { background: var(--info); }

.stat__label {
  font-size: var(--t-micro);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ink-3);
  font-weight: 600;
}
.stat__value {
  font-family: var(--font-num);
  font-size: var(--t-mega);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.035em;
  line-height: 1.05;
  margin-top: var(--s2);
  font-weight: 600;
}
.stat__value--sm { font-size: var(--t-h2); }
.stat__meta { font-size: var(--t-small); color: var(--ink-3); margin-top: var(--s1); }

.delta { font-family: var(--font-num); font-weight: 600; font-variant-numeric: tabular-nums; }
.delta--up   { color: var(--income); }
.delta--down { color: var(--expense); }

/* ── Tablas: se leen como un libro contable ──────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--r-lg);
}

.table { width: 100%; border-collapse: collapse; font-size: var(--t-small); }

.table thead th {
  text-align: left;
  font-size: var(--t-micro);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ink-3);
  font-weight: 600;
  padding: var(--s3) var(--s3);
  border-bottom: 1px solid var(--line-strong);
  background: var(--surface-2);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}

.table tbody td {
  padding: var(--s3);
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background var(--dur) var(--ease); }
.table tbody tr:hover { background: var(--accent-soft); }

.table tfoot td {
  padding: var(--s3);
  border-top: 2px solid var(--line-strong);
  font-weight: 650;
  background: var(--surface-2);
}

/* Todo número va a la derecha y en numerales tabulares. Sin esto las
   columnas de dinero no alinean y no se pueden comparar de un vistazo. */
.num {
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}
.num--income  { color: var(--income); }
.num--expense { color: var(--expense); }
.num--muted   { color: var(--ink-3); }
.num--strong  { font-weight: 650; }

.cell-main { font-weight: 550; color: var(--ink); }
.cell-sub  { font-size: var(--t-micro); color: var(--ink-3); margin-top: 1px; }
.col-actions { width: 1%; white-space: nowrap; text-align: right; }

/* ── Distintivos de estado ───────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  font-size: var(--t-micro);
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
  background: var(--neutral-soft);
  color: var(--ink-2);
}
.badge::before {
  content: ''; width: 5px; height: 5px; border-radius: 50%;
  background: currentColor; flex-shrink: 0;
}
.badge--sin-punto::before { display: none; }

.badge--ok       { background: var(--income-soft);  color: var(--income); }
.badge--warn     { background: var(--warn-soft);    color: var(--warn); }
.badge--danger   { background: var(--expense-soft); color: var(--expense); }
.badge--info     { background: var(--info-soft);    color: var(--info); }
.badge--accent   { background: var(--accent-soft);  color: var(--accent); }
.badge--neutral  { background: var(--neutral-soft); color: var(--ink-3); }

/* ── Formularios ─────────────────────────────────────────────────────────── */
.form-grid { display: grid; gap: var(--s4); grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field--full { grid-column: 1 / -1; }
@media (max-width: 720px) {
  .form-grid, .form-grid--3 { grid-template-columns: 1fr; }
}

.fieldset {
  border: none; padding: 0; margin: 0 0 var(--s6);
}
.fieldset__legend {
  font-size: var(--t-micro);
  text-transform: uppercase;
  letter-spacing: 0.09em;
  font-weight: 650;
  color: var(--ink-3);
  padding: 0 0 var(--s3);
  margin-bottom: var(--s4);
  border-bottom: 1px solid var(--line);
  width: 100%;
}

.field { display: flex; flex-direction: column; gap: 5px; }
.field__label { font-size: var(--t-small); font-weight: 550; color: var(--ink-2); }
.field__hint  { font-size: var(--t-micro); color: var(--ink-3); }
.field__error { font-size: var(--t-micro); color: var(--expense); font-weight: 550; }
.field__req   { color: var(--accent); }

.input, .select, .textarea {
  width: 100%;
  padding: 7px 10px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  font-size: var(--t-small);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.input:hover, .select:hover, .textarea:hover { border-color: var(--ink-4); }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.input[aria-invalid="true"], .select[aria-invalid="true"] {
  border-color: var(--expense);
  background: var(--expense-soft);
}
.input:disabled, .select:disabled { background: var(--surface-2); color: var(--ink-3); }

.textarea { min-height: 80px; resize: vertical; }
.input--num { font-family: var(--font-num); font-variant-numeric: tabular-nums; text-align: right; }

/* Campo de dinero con el símbolo dentro del control */
.input-money { position: relative; }
.input-money::before {
  content: '$';
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  color: var(--ink-3); font-family: var(--font-num); font-size: var(--t-small);
  pointer-events: none;
}
.input-money .input { padding-left: 22px; font-family: var(--font-num); text-align: right; }

.check { display: flex; align-items: center; gap: var(--s2); font-size: var(--t-small); cursor: pointer; }
.check input { width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; }

.form-actions {
  display: flex; gap: var(--s2); justify-content: flex-end;
  padding-top: var(--s4); border-top: 1px solid var(--line); margin-top: var(--s5);
}

/* ── Avisos ──────────────────────────────────────────────────────────────── */
.flash-stack {
  position: fixed; top: calc(var(--topbar-h) + var(--s3)); right: var(--s5);
  z-index: 60; display: flex; flex-direction: column; gap: var(--s2);
  max-width: 380px;
}
.flash {
  display: flex; align-items: flex-start; gap: var(--s3);
  padding: var(--s3) var(--s4);
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow-3);
  font-size: var(--t-small);
  animation: flash-in 220ms var(--ease);
}
@keyframes flash-in { from { opacity: 0; transform: translateX(12px); } }
.flash--success { border-left: 3px solid var(--income);  }
.flash--error   { border-left: 3px solid var(--expense); }
.flash--warning { border-left: 3px solid var(--warn);    }
.flash--info    { border-left: 3px solid var(--info);    }
.flash__close {
  margin-left: auto; background: none; border: none; cursor: pointer;
  color: var(--ink-3); padding: 0 2px; line-height: 1;
}

.notice {
  padding: var(--s3) var(--s4);
  border-radius: var(--r-md);
  font-size: var(--t-small);
  border: 1px solid var(--line);
  background: var(--surface-2);
}
.notice--warn   { background: var(--warn-soft);    border-color: #eedfae; color: #7c4a03; }
.notice--danger { background: var(--expense-soft); border-color: #f5c6c4; color: #8f1513; }
.notice--info   { background: var(--info-soft);    border-color: #ccd6fb; color: #1e3a8a; }

/* ── Estado vacío ────────────────────────────────────────────────────────── */
.empty { padding: var(--s8) var(--s5); text-align: center; }
.empty__title { font-size: var(--t-lead); font-weight: 600; margin-bottom: var(--s2); }
.empty__text  { color: var(--ink-3); font-size: var(--t-small); max-width: 46ch; margin: 0 auto var(--s4); }

/* ── Pantalla de acceso ──────────────────────────────────────────────────── */
.login {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--paper);
}
.login__aside {
  background: var(--ink);
  color: #fff;
  padding: var(--s8) var(--s7);
  display: flex; flex-direction: column; justify-content: space-between;
  position: relative;
  overflow: hidden;
}
/* Rejilla técnica de fondo: textura sin ruido, coherente con la dirección */
.login__aside::after {
  content: '';
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.035) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(ellipse at 30% 20%, #000 10%, transparent 72%);
  pointer-events: none;
}
.login__aside > * { position: relative; z-index: 1; }
.login__headline {
  font-size: var(--t-mega);
  font-weight: 650;
  letter-spacing: -0.035em;
  line-height: 1.08;
  max-width: 16ch;
}
.login__lede { color: #9c948a; margin-top: var(--s4); max-width: 40ch; }
.login__stats { display: flex; gap: var(--s6); margin-top: var(--s6); }
.login__stat-label {
  font-size: var(--t-micro); text-transform: uppercase; letter-spacing: 0.08em; color: #6b635a;
}
.login__stat-value {
  font-family: var(--font-num); font-size: var(--t-h3); font-weight: 600; color: #fff;
}

.login__panel { display: grid; place-items: center; padding: var(--s5); }
.login__form { width: 100%; max-width: 360px; }
.login__title { font-size: var(--t-h2); font-weight: 650; letter-spacing: -0.025em; }
.login__sub { color: var(--ink-3); font-size: var(--t-small); margin: var(--s2) 0 var(--s6); }

@media (max-width: 900px) {
  .login { grid-template-columns: 1fr; }
  .login__aside { display: none; }
}

/* ── Adaptable ───────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w);
    transform: translateX(-100%);
    transition: transform 200ms var(--ease);
    z-index: 50;
  }
  .sidebar.is-open { transform: translateX(0); }
  .content { padding: var(--s4); }
  .flash-stack { right: var(--s3); left: var(--s3); max-width: none; }
}

.sidebar-toggle { display: none; }
@media (max-width: 900px) {
  .sidebar-toggle {
    display: grid; place-items: center;
    width: 34px; height: 34px;
    border: 1px solid var(--line-strong); border-radius: var(--r-md);
    background: var(--surface); cursor: pointer;
  }
  .scrim {
    position: fixed; inset: 0; background: var(--overlay); z-index: 40;
  }
}

/* ── Utilidades ──────────────────────────────────────────────────────────── */
.stack   { display: flex; flex-direction: column; }
.stack-2 { gap: var(--s2); } .stack-3 { gap: var(--s3); }
.stack-4 { gap: var(--s4); } .stack-5 { gap: var(--s5); }
.row     { display: flex; align-items: center; gap: var(--s2); }
.row-3   { display: flex; align-items: center; gap: var(--s3); }
.row--wrap { flex-wrap: wrap; }
.push    { margin-left: auto; }
.muted   { color: var(--ink-3); }
.small   { font-size: var(--t-small); }
.micro   { font-size: var(--t-micro); }
.strong  { font-weight: 650; }
.mono    { font-family: var(--font-num); font-variant-numeric: tabular-nums; }
.mt-4 { margin-top: var(--s4); } .mt-5 { margin-top: var(--s5); }
.mb-4 { margin-bottom: var(--s4); } .mb-5 { margin-bottom: var(--s5); }
.text-right { text-align: right; }
.nowrap { white-space: nowrap; }

/* ── Gráficas (SVG renderado en el servidor) ─────────────────────────────── */
.chart svg { width: 100%; height: auto; overflow: visible; }
.chart__legend {
  display: flex; gap: var(--s4); justify-content: center;
  margin-top: var(--s3); font-size: var(--t-micro); color: var(--ink-3);
}
.chart__key { display: inline-flex; align-items: center; gap: 5px; }
.chart__key i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }

/* Barra de progreso fina, para utilización y payback */
.meter {
  height: 5px; background: var(--surface-3); border-radius: var(--r-pill);
  overflow: hidden; min-width: 60px;
}
.meter__fill { height: 100%; background: var(--accent); border-radius: var(--r-pill); }
.meter__fill--ok   { background: var(--income); }
.meter__fill--warn { background: var(--warn); }
.meter__fill--bad  { background: var(--expense); }

/* Selector de período */
.segmented {
  display: inline-flex; background: var(--surface-2);
  border: 1px solid var(--line); border-radius: var(--r-md); padding: 2px;
}
.segmented a {
  padding: 4px 10px; border-radius: var(--r-sm); font-size: var(--t-micro);
  font-weight: 600; color: var(--ink-3); white-space: nowrap;
}
.segmented a:hover { color: var(--ink); text-decoration: none; }
.segmented a.is-active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }

/* Lista compacta para "qué pasa hoy" */
.tasklist { display: flex; flex-direction: column; }
.tasklist__item {
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s3) var(--s4); border-bottom: 1px solid var(--line);
}
.tasklist__item:last-child { border-bottom: none; }
.tasklist__item:hover { background: var(--surface-2); }
.tasklist__when {
  font-family: var(--font-num); font-size: var(--t-micro); color: var(--ink-3);
  min-width: 62px; text-align: right;
}

/* ── Calendario tipo Gantt ───────────────────────────────────────────────── */
/* Filas de vehículos y columnas de días. Se usa CSS Grid y no una tabla
   porque una renta abarca varios días, y `grid-column: inicio / span n`
   expresa exactamente eso. */
.gantt-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.gantt { min-width: 900px; }

.gantt__row {
  display: grid;
  grid-template-columns: 172px 1fr;
  border-bottom: 1px solid var(--line);
}
.gantt__row:last-child { border-bottom: none; }
.gantt__row:hover .gantt__label { background: var(--surface-2); }

.gantt__row--head { position: sticky; top: 0; z-index: 3; background: var(--surface); }

.gantt__label {
  padding: var(--s2) var(--s3);
  border-right: 1px solid var(--line-strong);
  background: var(--surface);
  position: sticky;
  left: 0;
  z-index: 2;
  min-width: 0;
}
.gantt__label--head {
  font-size: var(--t-micro);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ink-3);
  font-weight: 600;
  background: var(--surface-2);
  display: flex;
  align-items: center;
}

.gantt__track {
  display: grid;
  grid-template-columns: repeat(var(--dias), minmax(26px, 1fr));
  grid-auto-rows: 24px;
  position: relative;
  align-content: center;
  padding: 3px 0;
  min-height: 34px;
}

.gantt__day {
  grid-row: 1;
  text-align: center;
  padding: 4px 0;
  font-size: var(--t-micro);
  border-right: 1px solid var(--line);
  background: var(--surface-2);
}
.gantt__dow  { display: block; color: var(--ink-4); font-size: 9px; line-height: 1; }
.gantt__dnum { display: block; color: var(--ink-2); font-family: var(--font-num); line-height: 1.3; }

.gantt__cell {
  grid-row: 1 / -1;
  border-right: 1px solid var(--line);
}
.gantt__day.is-finde, .gantt__cell.is-finde { background: var(--surface-2); }
.gantt__day.is-hoy,  .gantt__cell.is-hoy {
  background: var(--accent-soft);
  box-shadow: inset 2px 0 0 var(--accent);
}

/* Barras de renta */
.gantt__bar {
  grid-row: 1;
  display: flex;
  align-items: center;
  gap: 3px;
  margin: 1px 2px;
  padding: 0 7px;
  height: 22px;
  border-radius: var(--r-sm);
  font-size: var(--t-micro);
  font-weight: 600;
  color: #fff;
  overflow: hidden;
  white-space: nowrap;
  z-index: 1;
  transition: filter var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.gantt__bar:hover { filter: brightness(1.12); text-decoration: none; transform: translateY(-1px); }
.gantt__bar-text { overflow: hidden; text-overflow: ellipsis; }
.gantt__cont { opacity: 0.7; font-weight: 700; }

.gantt__bar--curso      { background: var(--info); }
.gantt__bar--reservada  { background: var(--accent); }
.gantt__bar--completada { background: var(--income); }
.gantt__bar--taller {
  background: repeating-linear-gradient(
    45deg, var(--warn), var(--warn) 6px, #b8780c 6px, #b8780c 12px
  );
  opacity: 0.9;
}

/* Cuando hay dos rentas el mismo día, la segunda baja a otra línea */
.gantt__track > .gantt__bar:nth-of-type(n+2) { grid-row: auto; }

@media (max-width: 900px) {
  .gantt__row { grid-template-columns: 132px 1fr; }
  .gantt__label { padding: var(--s2); }
}
