/* =========================================================================
   Luxe Clean — Panel del negocio. Hoja de estilo PROPIA y autocontenida.
   -------------------------------------------------------------------------
   IMPORTANTE: el panel NO carga styles.css. Esa hoja es la de la app del
   cliente, cuyo diseño está aprobado y no se toca (regla de oro #1). Al vivir
   aparte, es imposible que un cambio de aquí afecte a index.html.

   Diseño móvil primero: el dueño usa esto casi siempre desde el celular.
     · móvil      -> barra inferior de pestañas (pulgar), una columna
     · tablet     -> rejilla de 2 columnas
     · escritorio -> menú lateral fijo + rejilla fluida

   Los colores de texto y de las marcas de gráfica NO se eligieron a ojo: se
   calculó su contraste WCAG. Los valores que van comentados con su ratio son
   los que pasaron. No los cambies sin recalcular.
   ========================================================================= */

:root {
  /* --- Marca --- */
  --navy:        #0a1f44;
  --navy-2:      #102a63;
  --navy-deep:   #071634;
  --lime:        #9fe015;   /* relleno de marca; NUNCA como texto ni barra sobre claro */
  --lime-bright: #b6f53a;   /* 12.47:1 sobre navy -> sólo sobre navy */
  --lime-ink:    #4e7a06;   /* lima legible sobre claro: 4.55:1 sobre pista */
  --lime-tint:   #f2fadf;

  /* --- Superficies --- */
  --bg:          #eef2f8;
  --surface:     #ffffff;
  --surface-2:   #f7fafd;
  --line:        #e6ecf4;
  --line-2:      #d3dcea;

  /* --- Tinta --- */
  --ink:         #0f2138;   /* 16.22:1 sobre blanco */
  --ink-soft:    #33475f;
  --muted:       #5c6b7e;   /* 5.44 blanco / 5.19 surface-2 / 4.84 bg — pasa en los tres */

  /* --- Estado (los 5 pares pasan 4.5:1) --- */
  --ok:          #15803d;  --ok-bg:    #dcfce7;
  --warn:        #92600a;  --warn-bg:  #fef3c7;
  --info:        #1d4ed8;  --info-bg:  #dbeafe;
  --proc:        #6d28d9;  --proc-bg:  #ede9fe;
  --danger:      #b91c1c;  --danger-bg:#fee2e2;

  /* --- Gráficas: una sola serie => un solo color --- */
  --mark:        #4e7a06;   /* relleno de barras/medidores: 4.55:1 sobre la pista */
  --mark-soft:   #8fae5c;   /* mismo tono, paso claro: días que no son hoy */
  --track:       #e8edf4;   /* pista de los medidores (barras horizontales) */
  /* Pista de la gráfica de columnas: casi imperceptible a propósito. Con una
     pista oscura, las 7 columnas grises pesaban más que los datos y el gráfico
     se leía como "7 barras grises" en vez de "4 días con ingresos". */
  --track-col:   #f1f4f9;

  --r:           18px;
  --r-sm:        12px;
  --r-lg:        24px;

  /* Sombras en capas: una hairline de contacto + una difusa. Suaves a propósito;
     el peso visual lo llevan los datos, no los contenedores. */
  --shadow:      0 1px 2px rgba(15,33,56,.05), 0 2px 8px rgba(15,33,56,.04);
  --shadow-md:   0 1px 2px rgba(15,33,56,.06), 0 8px 24px rgba(15,33,56,.07);
  --shadow-lg:   0 16px 48px rgba(15,33,56,.18);

  --font:        "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  --bar-h:       64px;
  --top-h:       58px;
}

/* ---------------------------------------------------------------- reset -- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
  line-height: 1.5;
  overflow-x: hidden;
}
img { max-width: 100%; display: block; }
button { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
p { margin: 0; }
.hidden { display: none !important; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }

/* Foco visible y consistente. NUNCA se anula con outline:none: hacerlo deja a
   quien navega con teclado sin saber dónde está parado. */
:where(button, a, input, select, textarea):focus-visible {
  outline: 2px solid var(--navy-2);
  outline-offset: 2px;
  border-radius: 6px;
}
/* Sobre las superficies navy (barra superior y menú lateral) un anillo navy es
   invisible: se navegaba a ciegas. Ahí el anillo va en lima, que sí destaca. */
.appbar :where(button, a):focus-visible,
.admin-side :where(button, a):focus-visible {
  outline: 2px solid var(--lime-bright);
  outline-offset: 3px;
}

/* ------------------------------------------------------------- appbar --- */
.appbar {
  position: sticky; top: 0; z-index: 30;
  height: var(--top-h);
  display: flex; align-items: center; gap: 10px;
  padding: 0 16px;
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
  background: var(--navy);
  color: #fff;
  box-shadow: 0 1px 0 rgba(255,255,255,.06) inset;
}
.appbar .logo { height: 30px; width: auto; }
.appbar .tag-panel {
  font-size: .66rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase;
  color: #9fb4d4; padding-top: 2px;   /* 7.70:1 sobre navy */
}
.bar-link {
  border: 1px solid rgba(255,255,255,.24); background: rgba(255,255,255,.08);
  color: #fff; border-radius: 999px; padding: 8px 16px; font-weight: 700;
  font-size: .84rem; cursor: pointer; transition: background .15s ease;
}
.bar-link:hover { background: rgba(255,255,255,.18); }

/* -------------------------------------------------------------- login --- */
.login-wrap { display: grid; place-items: center; min-height: calc(100dvh - var(--top-h)); padding: 24px; }
.login-card {
  width: 100%; max-width: 390px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow-md); padding: 32px 28px;
}
.login-card h2 { font-size: 1.3rem; font-weight: 800; letter-spacing: -.02em; }
.login-badge {
  width: 54px; height: 54px; border-radius: 16px; display: grid; place-items: center;
  background: linear-gradient(155deg, var(--navy-2), var(--navy-deep)); margin-bottom: 18px;
}
.login-badge svg { width: 26px; height: 26px; color: var(--lime-bright); }

.field { margin-bottom: 15px; }
.field label { display: block; font-size: .8rem; font-weight: 700; color: var(--ink-soft); margin-bottom: 7px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 12px 14px; font: inherit;
  border: 1.5px solid var(--line-2); border-radius: var(--r-sm);
  background: var(--surface); color: var(--ink);
  transition: border-color .15s ease;
}
/* Se acota a los campos de texto: si esta regla alcanzara a las casillas, su
   outline:none las dejaba sin ninguna señal de foco al tabular. */
.field input:not([type=checkbox]):focus, .field select:focus, .field textarea:focus {
  border-color: var(--navy-2);
}
.field .err { display: none; color: var(--danger); font-size: .8rem; margin-top: 6px; font-weight: 600; }
.field.invalid input { border-color: var(--danger); background: #fff8f8; }
.field.invalid .err { display: block; }
.hint { color: var(--muted); font-weight: 500; }

.btn {
  border: none; border-radius: var(--r-sm); padding: 13px 20px;
  font-weight: 800; font-size: .92rem; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: background .15s ease, transform .1s ease;
}
.btn:disabled { opacity: .55; cursor: default; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn-primary { background: var(--lime); color: #14260a; }
.btn-primary:hover:not(:disabled) { background: var(--lime-bright); }
.btn-line { background: var(--surface); color: var(--ink-soft); border: 1.5px solid var(--line-2); }
.btn-line:hover { background: var(--surface-2); }
.btn-block { width: 100%; }

/* ------------------------------------------------------------- layout --- */
.shell { min-height: 100dvh; }
.admin-side { display: none; }
.admin-main {
  padding: 18px 16px;
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
  padding-bottom: calc(var(--bar-h) + 28px + env(safe-area-inset-bottom));
}
.view-head { margin-bottom: 18px; }
.view-head h2 { font-size: 1.45rem; font-weight: 800; letter-spacing: -.03em; }
.view-head p { font-size: .86rem; color: var(--muted); margin-top: 3px; }

/* -------------------------------------------- barra inferior (móvil) ---- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  height: calc(var(--bar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: flex; align-items: stretch;
  background: rgba(255,255,255,.97);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.tab {
  flex: 1; border: none; background: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  color: var(--muted); font-size: .68rem; font-weight: 700; padding: 0;
}
.tab svg { width: 22px; height: 22px; }
.tab.active { color: var(--lime-ink); }
.tab-fab { flex: 0 0 auto; padding: 0 16px; display: grid; place-items: center; }
.tab-fab button {
  width: 52px; height: 52px; border-radius: 17px; border: none; cursor: pointer;
  background: var(--lime); color: #14260a; display: grid; place-items: center;
  box-shadow: 0 6px 18px rgba(159,224,21,.45);
  transition: transform .12s ease;
}
.tab-fab button:active { transform: scale(.94); }
.tab-fab svg { width: 24px; height: 24px; }

/* ------------------------------------------------------ tarjetas stat --- */
/* Contrato de la tarjeta: etiqueta arriba (con su icono), valor grande, y un
   apunte de contexto debajo. La etiqueta primero: dice QUÉ se está mirando
   antes de soltar el número. */
/* En móvil las tres cifras van en UNA fila compacta. Antes ocupaban 218 px en
   dos filas de tarjetas grandes y, sumadas al resto de la cabecera, dejaban la
   primera cita a 554 px: el dueño abría su agenda y veía UNA sola cita sin
   desplazarse. Lo que importa aquí son las citas, no los contadores. */
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.stat {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: 11px 10px; box-shadow: var(--shadow);
}
.stat-top { display: flex; align-items: center; gap: 9px; margin-bottom: 4px; }
/* En móvil el icono se oculta: no cabe en un tercio de pantalla y no aporta
   nada que la etiqueta no diga. Reaparece a partir de 640px (ver más abajo).
   OJO: el display va aquí, en la MISMA regla; ponerlo en una regla aparte antes
   de ésta no servía de nada (misma especificidad, ganaba la última). */
.stat .ico {
  width: 30px; height: 30px; border-radius: 9px; display: none; place-items: center;
  flex: none; background: var(--surface-2); color: var(--navy-2);
}
.stat .ico svg { width: 16px; height: 16px; }
.stat .ico.lime  { background: var(--lime-tint); color: var(--lime-ink); }
.stat .ico.warn  { background: var(--warn-bg);   color: var(--warn); }
.stat .ico.ok    { background: var(--ok-bg);     color: var(--ok); }
.stat .ico.info  { background: var(--info-bg);   color: var(--info); }
/* .72rem = 11.5px es el suelo que se fijó tras medir: por debajo de ~11px el
   texto secundario se vuelve difícil de leer en un celular a pleno sol, que es
   justo donde se usa esto. */
.stat .l { font-size: .72rem; color: var(--muted); font-weight: 700; line-height: 1.25; }
/* Cifras proporcionales (no tabular): en tamaño grande, tabular-nums deja
   los números sueltos y desalineados a la vista. */
.stat .n { font-size: 1.35rem; font-weight: 800; letter-spacing: -.035em; line-height: 1.1; }
.stat .sub { font-size: .68rem; color: var(--muted); margin-top: 3px; }

/* ------------------------------------------------------------ filtros --- */
/* Una sola fila de filtros arriba, nunca dentro de una tarjeta de datos. */
.toolbar {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 12px; box-shadow: var(--shadow); margin-bottom: 18px;
}
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
/* Todo lo que se toca con el dedo mide ≥44px: el dueño usa esto en la calle,
   con una mano y a veces con los dedos mojados. */
.filters input[type=date], .filters select {
  flex: 1 1 132px; min-width: 0; min-height: 44px; padding: 9px 14px; font: inherit; font-size: .87rem;
  border: 1.5px solid var(--line-2); border-radius: 999px; background: var(--surface); color: var(--ink);
}
.chip {
  border: 1.5px solid var(--line-2); background: var(--surface); color: var(--ink-soft);
  border-radius: 999px; padding: 8px 17px; min-height: 44px; font-weight: 700; font-size: .84rem;
  cursor: pointer; white-space: nowrap;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.chip:hover { background: var(--surface-2); }
.chip.active { background: var(--navy); color: #fff; border-color: var(--navy); }
.chip.icon-only { padding: 8px 13px; }
#btn-new-booking { display: none; }

/* ------------------------------------------------------ lista de citas -- */
#list { display: grid; gap: 13px; }
.date-head {
  font-weight: 800; font-size: .78rem; color: var(--muted); text-transform: uppercase;
  letter-spacing: .08em; margin: 10px 2px 0;
}
#list .date-head:first-child { margin-top: 0; }

/* Tarjeta en columna: cabecera arriba, cuerpo elástico y pie SIEMPRE abajo.
   Así todas las tarjetas de una misma fila miden igual y los botones quedan
   alineados entre sí, en vez de "bailar" según cuántos datos traiga cada cita. */
.bk {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--shadow); overflow: hidden;
  display: flex; flex-direction: column;
  transition: box-shadow .2s ease, transform .2s ease, border-color .2s ease;
  position: relative;
}
.bk:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); border-color: var(--line-2); }
.bk-body { flex: 1; }                     /* empuja el pie al fondo */
/* Suelo de altura para que una cita sin extras ni fotos no quede achaparrada
   al lado de otra completa. */
.bk { min-height: 330px; }

/* Filo de color según el estado: identifica la cita de un vistazo sin gritar. */
.bk::before {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 3px;
  background: var(--line-2);
}
.bk.e-pendiente::before  { background: var(--warn); }
.bk.e-asignada::before   { background: var(--info); }
.bk.e-en_proceso::before { background: var(--proc); }
.bk.e-completada::before { background: var(--ok); }
.bk.e-cancelada::before  { background: var(--danger); }

/* Mismo padding que el cuerpo y el pie: con 19px la cabecera iba 3px más
   adentro y el borde izquierdo del contenido no cuadraba. El filo de color de
   3px vive dentro de ese padding, así que no hace falta compensarlo. */
.bk-top {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.bk-time {
  background: var(--navy); color: #fff; border-radius: 12px; padding: 8px 12px;
  font-weight: 800; font-size: .95rem; letter-spacing: -.02em; flex: none;
}
.bk-folio { font-weight: 800; font-size: .82rem; color: var(--ink-soft); letter-spacing: .03em; }
/* Red de seguridad: la cabecera nunca crece más de dos renglones, pase lo que
   pase con el texto. El detalle del vehículo vive en el cuerpo de la tarjeta. */
.bk-veh {
  font-size: .78rem; color: var(--muted); margin-top: 1px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; overflow-wrap: anywhere;
}

.pill {
  font-size: .7rem; font-weight: 800; padding: 5px 11px; border-radius: 999px;
  white-space: nowrap; flex: none;
}
.pill.pendiente  { background: var(--warn-bg);  color: var(--warn); }
.pill.asignada   { background: var(--info-bg);  color: var(--info); }
.pill.en_proceso { background: var(--proc-bg);  color: var(--proc); }
.pill.completada { background: var(--ok-bg);    color: var(--ok); }
.pill.cancelada  { background: var(--danger-bg);color: var(--danger); }

/* Columna FLEX, no grid. Con grid + flex:1 el navegador repartía el espacio
   sobrante entre las filas (align-content por defecto = stretch): la tarjeta
   más corta de cada fila quedaba con ~37 px de aire bajo CADA dato mientras su
   vecina se veía compacta. En flex-column las filas conservan su alto natural
   y el sobrante se va al hueco de antes del Total, que se ancla abajo. */
.bk-body { padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; gap: 11px; align-items: flex-start; }
.row .ri { width: 17px; height: 17px; flex: none; color: var(--muted); margin-top: 2px; }
/* En versalitas cuesta más leer, así que esta no baja de .72rem. */
.row .rk { font-size: .72rem; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .07em; line-height: 1.3; }
.row .rv { font-weight: 600; font-size: .9rem; word-break: break-word; line-height: 1.35; }
.row .rv a { color: var(--navy-2); font-weight: 700; text-decoration: none; }
.row .rv a:hover { text-decoration: underline; }

.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.tag {
  background: var(--lime-tint); color: var(--lime-ink); border-radius: 7px;
  padding: 3px 9px; font-size: .74rem; font-weight: 800;
}

.bk-photos { display: flex; gap: 8px; flex-wrap: wrap; }
.bk-photos .foto {
  width: 60px; height: 60px; border-radius: 12px; overflow: hidden; padding: 0;
  border: 1px solid var(--line); display: block; cursor: zoom-in; background: none;
  position: relative; transition: transform .15s ease, box-shadow .15s ease;
}
.bk-photos .foto:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.bk-photos img { width: 100%; height: 100%; object-fit: cover; display: block; }

.bk-total {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  padding-top: 13px; border-top: 1px solid var(--line);
  margin-top: auto;      /* el Total queda anclado al fondo del cuerpo */
}
.bk-total .tl { font-size: .72rem; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .07em; }
.bk-total .tv { font-size: 1.35rem; font-weight: 800; letter-spacing: -.035em; }

.bk-foot { padding: 13px 16px; background: var(--surface-2); border-top: 1px solid var(--line); display: grid; gap: 10px; }
.bk-links { display: flex; gap: 8px; flex-wrap: wrap; }
.icon-link {
  display: inline-flex; align-items: center; gap: 6px; text-decoration: none;
  font-weight: 800; font-size: .82rem; padding: 9px 13px; min-height: 44px; border-radius: 11px;
  flex: 1 1 auto; justify-content: center; transition: filter .15s ease;
}
.icon-link:hover { filter: brightness(.95); }
.icon-link svg { width: 15px; height: 15px; }
.icon-link.wa   { background: #128c4a; color: #fff; }
.icon-link.call { background: var(--navy); color: #fff; }
.icon-link.map  { background: var(--lime-tint); color: var(--lime-ink); }
.bk-selects { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.bk-selects select {
  width: 100%; min-width: 0; min-height: 44px; padding: 9px 11px; font: inherit; font-size: .84rem;
  font-weight: 600; border: 1.5px solid var(--line-2); border-radius: 11px;
  background: var(--surface); color: var(--ink);
}

/* --------------------------------------------------------- ingresos ----- */
.seg { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }
#view-ingresos .stat-row { grid-template-columns: repeat(2, 1fr); }

/* La cifra que encabeza la vista: exactamente UNA por pantalla. */
.money-hero {
  background: linear-gradient(155deg, var(--navy-2), var(--navy-deep));
  border-radius: var(--r-lg); padding: 24px; color: #fff; margin-bottom: 13px;
  box-shadow: var(--shadow-md);
}
.money-hero .l { font-size: .74rem; color: #9fb4d4; font-weight: 700; text-transform: uppercase; letter-spacing: .09em; }
.money-hero .n { font-size: 2.5rem; font-weight: 800; letter-spacing: -.045em; color: var(--lime-bright); margin-top: 6px; line-height: 1.02; }
.money-hero .sub { font-size: .83rem; color: #c4d6f0; margin-top: 8px; }

.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--shadow); padding: 17px; margin-bottom: 13px;
}
.panel h3 { font-size: .95rem; font-weight: 800; margin-bottom: 14px; letter-spacing: -.01em; }
.panel h3 .h-sub { font-size: .74rem; font-weight: 600; color: var(--muted); display: block; margin-top: 3px; letter-spacing: 0; }

/* Medidores: una sola serie por panel => un solo color de relleno. La pista es
   un paso claro del mismo tono, no un gris ajeno. */
.brk { display: grid; gap: 13px; }
.brk-row .brk-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 6px; }
.brk-row .bl { font-size: .85rem; font-weight: 700; }
.brk-row .bn { font-size: .88rem; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.brk-row .bc { font-size: .72rem; color: var(--muted); font-weight: 600; margin-top: 5px; }
.bar { height: 8px; border-radius: 999px; background: var(--track); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 999px; background: var(--mark); transition: width .35s ease; }

/* Gráfica de columnas de 7 días — CSS puro, sin librerías.
   align-items:stretch es OBLIGATORIO: con flex-end las columnas no se estiran,
   quedan de alto automático y las barras colapsan a 3px (pasó, se corrigió). */
.spark { display: flex; align-items: stretch; gap: 7px; height: 128px; margin-top: 2px; }
.spark-col {
  flex: 1; min-width: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: flex-end; gap: 6px;
}
.spark-bar {
  width: 100%; max-width: 26px;              /* marca fina: nunca llena el hueco */
  margin: 0 auto; flex: 1; min-height: 0;
  background: var(--track-col); border-radius: 5px 5px 2px 2px;
  display: flex; align-items: flex-end; overflow: hidden;
}
.spark-bar > i {
  display: block; width: 100%; min-height: 3px;
  background: var(--mark-soft);
  border-radius: 5px 5px 0 0;                /* extremo redondeado, recto en la base */
  transition: height .35s ease;
}
.spark-col.is-today .spark-bar > i { background: var(--mark); }
.spark-lab { font-size: .68rem; color: var(--muted); font-weight: 700; text-transform: capitalize; }
.spark-col.is-today .spark-lab { color: var(--ink); }
.spark-val { font-size: .66rem; color: var(--ink-soft); font-weight: 800; font-variant-numeric: tabular-nums; }
/* Espacio de ancho cero: reserva el renglón aunque el día no tenga importe, para
   que las 7 pistas midan exactamente igual y las barras sean comparables. */
.spark-val::after { content: "\200b"; }

/* -------------------------------------------------------- calendario ---- */
/* Vista para bloquear horarios (emergencias, feriados). Mes a la vista +
   panel del día elegido con sus 6 turnos. En móvil van apilados; en
   escritorio, lado a lado. */
.cal-wrap { display: grid; gap: 13px; }
.cal-wrap .panel { margin-bottom: 0; }
/* En móvil el panel afloja su padding lateral para que las 7 celdas ronden
   los 44px de ancho (el mínimo táctil que usa todo el panel). */
.cal-panel { padding: 16px 10px 14px; }

.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; padding: 0 4px; }
.cal-mes { font-size: 1rem; font-weight: 800; letter-spacing: -.01em; }
.cal-nav {
  width: 44px; height: 44px; border-radius: 12px; border: 1.5px solid var(--line-2);
  background: var(--surface); color: var(--ink-soft); cursor: pointer; flex: none;
  display: grid; place-items: center; transition: background .15s ease;
}
.cal-nav:hover:not(:disabled) { background: var(--surface-2); }
.cal-nav:disabled { opacity: .35; cursor: default; }
.cal-nav svg { width: 18px; height: 18px; }

.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
/* El spinner de carga inicial vive DENTRO de la rejilla: sin esto quedaba
   encajonado en la primera de las 7 columnas (~40px) en vez de centrado. */
.cal-grid .center-load { grid-column: 1 / -1; }
.cal-dow {
  text-align: center; font-size: .66rem; font-weight: 800; color: var(--muted);
  text-transform: uppercase; letter-spacing: .05em; padding: 3px 0 7px;
}
.cal-cell {
  min-height: 46px; border-radius: 10px; border: 1px solid transparent;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; padding: 4px 1px; background: transparent;
}
.cal-cell .num { font-size: .86rem; font-weight: 700; line-height: 1; }
button.cal-cell {
  cursor: pointer; background: var(--surface); border-color: var(--line);
  transition: border-color .15s ease, background .15s ease;
}
button.cal-cell:hover { border-color: var(--line-2); background: var(--surface-2); }
.cal-cell.fuera { visibility: hidden; }              /* hueco antes del día 1 */
.cal-cell.cerrado { background: var(--bg); }
.cal-cell.cerrado .num, .cal-cell.pasado .num, .cal-cell.fuera-rango .num {
  color: var(--muted); font-weight: 600;
}
/* Día completamente bloqueado: se nota desde el mes, sin abrir el día. */
button.cal-cell.dia-bloq { background: var(--danger-bg); border-color: #f3c6c6; }
button.cal-cell.dia-bloq .num { color: var(--danger); }
/* La marca de HOY va en .cal-cell (no solo en button): cuando hoy es lunes la
   celda se pinta como <div> cerrado y el dueño se quedaba sin referencia de en
   qué día está parado — o sea, uno de cada siete días. */
.cal-cell.hoy { box-shadow: inset 0 0 0 1.5px var(--lime-ink); }
button.cal-cell.sel { background: var(--navy); border-color: var(--navy); }
button.cal-cell.sel .num { color: #fff; font-weight: 800; }
button.cal-cell.sel .ind-cita { background: var(--lime-bright); }
button.cal-cell.sel .ind-bloq { background: #ff9d9d; }

.cal-inds { display: flex; gap: 3px; min-height: 5px; }
.ind { width: 5px; height: 5px; border-radius: 50%; display: inline-block; flex: none; }
.ind-cita { background: var(--mark); }
.ind-bloq { background: var(--danger); }
.ind-cerrado { background: var(--line-2); }

.cal-leyenda {
  display: flex; gap: 14px; flex-wrap: wrap; margin-top: 13px; padding: 0 4px;
  font-size: .72rem; color: var(--muted); font-weight: 600;
}
.cal-leyenda span { display: inline-flex; align-items: center; gap: 6px; }
.cal-leyenda .ind { width: 7px; height: 7px; }
/* El borde de la muestra "Cerrado" va en --muted (5.44:1): con --line-2 daba
   1.38:1 sobre el panel blanco y la muestra era invisible (WCAG 1.4.11 pide
   3:1 en indicadores no textuales). El relleno claro sí es fiel a la celda. */
.cal-leyenda .ind-cerrado { border-radius: 3px; background: var(--bg); border: 1.5px solid var(--muted); }

/* --- Panel del día --- */
.cal-dia { display: flex; flex-direction: column; }
.cal-dia-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  flex-wrap: wrap; margin-bottom: 12px;
}
.cal-dia-head h3 { margin-bottom: 0; }
.btn-dia {
  border: 1.5px solid #e8a3a3; background: var(--surface); color: var(--danger);
  border-radius: 999px; padding: 8px 16px; min-height: 44px; font-weight: 800;
  font-size: .8rem; cursor: pointer; flex: none; white-space: nowrap;
  transition: background .15s ease;
}
.btn-dia:hover:not(:disabled) { background: var(--danger-bg); }
.btn-dia.abrir { border-color: #9ed3b1; color: var(--ok); }
.btn-dia.abrir:hover:not(:disabled) { background: var(--ok-bg); }
.btn-dia:disabled, .btn-turno:disabled { opacity: .55; cursor: default; }

.turnos { display: grid; gap: 8px; }
.turno {
  display: flex; align-items: center; gap: 10px; min-height: 56px;
  border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px;
  background: var(--surface);
}
.turno-hora {
  font-weight: 800; font-size: .85rem; background: var(--navy); color: #fff;
  border-radius: 9px; padding: 7px 9px; flex: none; font-variant-numeric: tabular-nums;
}
.turno-estado { flex: 1; min-width: 0; font-size: .84rem; font-weight: 600; color: var(--ink-soft); overflow-wrap: anywhere; line-height: 1.35; }
.turno.libre .turno-estado { color: var(--ok); font-weight: 700; }
.turno.ocupado .turno-hora { background: var(--info); }
.turno.bloq { background: var(--danger-bg); border-color: #f3c6c6; }
.turno.bloq .turno-hora { background: var(--danger); }
.turno.bloq .turno-estado { color: var(--danger); font-weight: 700; }
.turno.pasado { opacity: .6; }
.turno.pasado .turno-estado { color: var(--muted); }
.mini-bloq {
  display: inline-block; background: var(--danger-bg); color: var(--danger);
  border-radius: 6px; padding: 1px 7px; font-size: .7rem; font-weight: 800; margin-left: 4px;
}
.turno.bloq .mini-bloq { background: #fff; }

.btn-turno {
  border: 1.5px solid var(--line-2); background: var(--surface); color: var(--ink-soft);
  border-radius: 999px; padding: 7px 14px; min-height: 44px; font-weight: 700;
  font-size: .78rem; cursor: pointer; flex: none; white-space: nowrap;
  transition: background .15s ease, border-color .15s ease;
}
/* En pantallas muy angostas la fila se parte: el botón baja a su renglón y el
   texto de la cita deja de estrujarse en ~80px. OJO: flex-wrap solo no basta —
   con flex:1 + min-width:0 el texto se comprime en lugar de saltar; el
   min-width del estado es lo que obliga al botón a bajar. */
@media (max-width: 359px) {
  .turno { flex-wrap: wrap; }
  .turno .turno-estado { min-width: 150px; }
  .turno .btn-turno { margin-left: auto; }
}
.btn-turno:hover:not(:disabled) { background: var(--surface-2); }
.btn-turno.des, .btn-turno.cancelar { border-color: #e8a3a3; color: var(--danger); background: var(--surface); }
.btn-turno.des:hover:not(:disabled), .btn-turno.cancelar:hover:not(:disabled) { background: #fff5f5; }

.cal-nota {
  margin-top: auto; padding-top: 14px; font-size: .78rem; color: var(--muted);
  line-height: 1.5;
}

/* --------------------------------------------------------- utilidades -- */
.empty { text-align: center; color: var(--muted); padding: 46px 20px; font-size: .9rem; }
.empty .big { font-size: 2.1rem; display: block; margin-bottom: 10px; }
.center-load { display: grid; place-items: center; padding: 48px 0; }
.spinner {
  width: 26px; height: 26px; border-radius: 50%;
  border: 3px solid var(--line-2); border-top-color: var(--navy-2);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 2s; }
  .bar > i, .spark-bar > i, .btn, .chip, .bk { transition: none; }
}

.banner {
  border-radius: var(--r-sm); padding: 12px 14px; font-size: .85rem; font-weight: 600;
  margin-bottom: 14px; background: var(--info-bg); color: var(--info);
}
.banner.warn { background: var(--warn-bg); color: var(--warn); }

/* ------------------------------------------------------------- modal ---- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 60; background: rgba(10,31,68,.55);
  display: flex; align-items: flex-end; justify-content: center;
}
.modal {
  background: var(--surface); width: 100%; max-width: 540px; max-height: 92dvh;
  overflow-y: auto; border-radius: 24px 24px 0 0; box-shadow: var(--shadow-lg);
  padding-bottom: env(safe-area-inset-bottom);
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 16px 18px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: var(--surface); z-index: 2;
}
.modal-head h3 { font-size: 1.05rem; font-weight: 800; letter-spacing: -.02em; }
.modal-x { border: none; background: none; font-size: 1.8rem; line-height: 1; cursor: pointer; color: var(--muted); padding: 0 6px; }
.modal-body { padding: 18px; }
.modal-foot {
  display: flex; gap: 10px; padding: 15px 18px; border-top: 1px solid var(--line);
  position: sticky; bottom: 0; background: var(--surface);
}
.modal-foot .btn { flex: 1; }
.nb-extra { display: flex; align-items: center; gap: 11px; padding: 9px 0; font-weight: 600; font-size: .9rem; cursor: pointer; }
.nb-extra input { width: 19px; height: 19px; accent-color: var(--lime-ink); flex: none; }
#nb-total { background: var(--lime-tint); color: var(--lime-ink); font-weight: 800; }

/* --------------------------------------------------- confirmación ------ */
/* Se reutiliza el modal, pero centrado y compacto: es una pregunta, no un
   formulario. El botón seguro va primero y se lleva el foco. */
.modal.conf {
  max-width: 400px; border-radius: var(--r-lg); padding: 26px 24px 22px;
  text-align: center;
}
@media (max-width: 639px) {
  #conf-modal { align-items: center; padding: 20px; }
  .modal.conf { border-radius: var(--r-lg); }
}
.conf-icono {
  width: 52px; height: 52px; border-radius: 16px; margin: 0 auto 15px;
  display: grid; place-items: center;
  background: var(--danger-bg); color: var(--danger);
}
.conf-icono svg { width: 26px; height: 26px; }
.modal.conf h3 { font-size: 1.12rem; font-weight: 800; letter-spacing: -.02em; }
.modal.conf p { font-size: .88rem; color: var(--muted); margin-top: 9px; line-height: 1.5; }
.conf-botones { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 22px; }
/* En pantallas estrechas "Sí, cancelar la cita" no cabe en media columna y se
   partía en 2-3 renglones (y estiraba al botón de al lado). Apilados: cada uno
   a todo el ancho, con la opción SEGURA arriba, que es el orden del DOM. */
@media (max-width: 430px) {
  .conf-botones { grid-template-columns: 1fr; }
}
.btn-peligro { background: var(--danger); color: #fff; }
.btn-peligro:hover:not(:disabled) { background: #a01818; }

/* ------------------------------------------------------------- visor --- */
/* Las fotos se ven DENTRO del panel: salir a otra pestaña hacía perder el sitio
   en la agenda. Fondo oscuro para que la foto mande, y navegación con flechas. */
.visor {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(6, 16, 34, .93);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  animation: visor-in .18s ease;
}
@keyframes visor-in { from { opacity: 0 } to { opacity: 1 } }
.visor img {
  max-width: min(100%, 1100px); max-height: 84dvh;
  border-radius: var(--r); object-fit: contain;
  box-shadow: 0 24px 70px rgba(0,0,0,.55);
}
/* Aviso cuando la foto no carga: mejor decirlo que dejar una pantalla negra. */
.visor-fallo {
  display: grid; place-items: center; gap: 8px; text-align: center;
  color: #c4d6f0; padding: 42px 26px;
  background: rgba(255,255,255,.06); border-radius: var(--r);
  max-width: 340px;
}
.visor-fallo svg { width: 42px; height: 42px; opacity: .75; }
.visor-fallo b { color: #fff; font-size: .98rem; }
.visor-fallo span { font-size: .84rem; }

.visor-x, .visor-nav {
  position: absolute; border: none; cursor: pointer;
  background: rgba(255,255,255,.13); color: #fff;
  border-radius: 999px; display: grid; place-items: center;
  width: 46px; height: 46px; transition: background .15s ease;
}
.visor-x:hover, .visor-nav:hover { background: rgba(255,255,255,.26); }
.visor-x svg, .visor-nav svg { width: 22px; height: 22px; }
.visor-x { top: max(14px, env(safe-area-inset-top)); right: 14px; }
.visor-cuenta {
  color: #cddcf2; font-size: .82rem; font-weight: 700;
  background: rgba(0,0,0,.42); padding: 7px 14px; border-radius: 999px;
  font-variant-numeric: tabular-nums;
}

/* MÓVIL: la foto ocupa todo el ancho, así que los controles van DEBAJO. Puestos
   a los lados se montaban encima del coche, que es justo lo que se quiere ver. */
.visor {
  flex-direction: column; gap: 16px;
}
.visor-nav, .visor-cuenta { position: static; transform: none; }
.visor-controles {
  display: flex; align-items: center; gap: 18px;
}

@media (min-width: 640px) {
  /* En pantallas anchas sobra sitio a los lados de la foto: flechas laterales,
     que es lo natural en un visor, sin tapar nada. */
  .visor { flex-direction: row; }
  .visor-controles { position: absolute; inset: 0; pointer-events: none; justify-content: space-between; padding: 0 12px; gap: 0; }
  .visor-controles .visor-nav { pointer-events: auto; }
  .visor-cuenta {
    position: absolute; bottom: max(18px, env(safe-area-inset-bottom));
    left: 50%; transform: translateX(-50%);
  }
}
@media (prefers-reduced-motion: reduce) { .visor { animation: none; } }

/* ------------------------------------------------------------- toast ---- */
.toast-wrap { position: fixed; left: 0; right: 0; bottom: calc(var(--bar-h) + 18px + env(safe-area-inset-bottom)); z-index: 80; display: grid; place-items: center; pointer-events: none; }
.toast {
  background: var(--navy); color: #fff; padding: 13px 20px; border-radius: 13px;
  font-weight: 700; font-size: .87rem; box-shadow: var(--shadow-lg);
  opacity: 0; transform: translateY(12px); transition: .22s ease; max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: none; }
.toast.error { background: var(--danger); }

/* =========================================================================
   TABLET  (≥ 640px)
   ========================================================================= */
@media (min-width: 640px) {
  /* A partir de tablet sí hay sitio para las tarjetas completas, con su icono. */
  .stat-row { gap: 11px; margin-bottom: 18px; }
  .stat { padding: 16px; border-radius: var(--r); }
  .stat .ico { display: grid; }
  .stat-top { margin-bottom: 10px; }
  .stat .l { font-size: .78rem; }
  .stat .n { font-size: 1.75rem; }
  .stat .sub { font-size: .74rem; margin-top: 5px; }
  /* align-items:stretch (antes era 'start') iguala la altura de las tarjetas que
     comparten fila; como el cuerpo es elástico, los botones quedan alineados
     entre ellas. Los encabezados de fecha van solos en su fila, así que
     conservan su altura natural. */
  #list { grid-template-columns: repeat(2, 1fr); align-items: stretch; }
  #list .date-head { grid-column: 1 / -1; }
  /* Con más ancho, el calendario recupera el padding normal del panel. */
  .cal-panel { padding: 17px; }
  .cal-grid { gap: 5px; }
  .cal-cell { min-height: 54px; }
  .cal-cell .num { font-size: .92rem; }
  .admin-main { padding: 24px; padding-bottom: calc(var(--bar-h) + 32px + env(safe-area-inset-bottom)); }
  .modal-overlay { align-items: center; padding: 24px; }
  .modal { border-radius: var(--r-lg); }
  .seg { flex-wrap: nowrap; }
  .spark { height: 150px; }
}

/* =========================================================================
   ESCRITORIO  (≥ 1000px) — menú lateral, sin barra inferior
   ========================================================================= */
@media (min-width: 1000px) {
  .tabbar { display: none; }
  .shell { display: grid; grid-template-columns: 250px 1fr; align-items: start; }
  .appbar { grid-column: 1 / -1; position: sticky; }

  .admin-side {
    display: flex; flex-direction: column; gap: 4px;
    position: sticky; top: var(--top-h);
    height: calc(100dvh - var(--top-h));
    background: linear-gradient(180deg, var(--navy), var(--navy-deep));
    padding: 20px 14px; color: #fff;
  }
  .admin-side nav { display: flex; flex-direction: column; gap: 4px; }
  .side-cap {
    font-size: .63rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase;
    color: #8ba3c4; padding: 8px 14px 8px;
  }
  .side-item {
    display: flex; align-items: center; gap: 12px; width: 100%; border: none; background: none;
    text-align: left; padding: 12px 14px; border-radius: 12px; font-weight: 700;
    color: #c4d6f0; cursor: pointer; font-size: .92rem;      /* 11.01:1 sobre navy */
    transition: background .15s ease, color .15s ease;
  }
  .side-item svg { width: 19px; height: 19px; flex: none; }
  .side-item:hover:not(:disabled) { background: rgba(255,255,255,.08); color: #fff; }
  .side-item.active { background: rgba(159,224,21,.16); color: var(--lime-bright); box-shadow: inset 3px 0 0 var(--lime); }
  .side-item:disabled { opacity: .4; cursor: default; }
  .side-foot { margin-top: auto; }

  .admin-main { padding: 28px 32px 48px; max-width: 1500px; }
  /* Con ratón se apunta fino: los controles pueden ser más compactos. */
  .chip, .filters input[type=date], .filters select, .icon-link, .bk-selects select { min-height: 38px; }
  .view-head { margin-bottom: 22px; }
  .view-head h2 { font-size: 1.75rem; }
  .stat { padding: 19px; }
  .stat .n { font-size: 2.1rem; }
  #btn-new-booking { display: inline-flex; margin-left: auto; }
  #list { grid-template-columns: repeat(auto-fill, minmax(350px, 1fr)); gap: 16px; }
  .toast-wrap { bottom: 28px; }
  .money-hero { padding: 28px; margin-bottom: 0; }
  .money-hero .n { font-size: 2.9rem; }
  /* La cifra principal y las dos tarjetas comparten fila: si el hero va solo a
     todo el ancho, queda un bloque navy enorme con un número perdido en medio. */
  .ing-top { display: grid; grid-template-columns: 1.5fr 1fr 1fr; gap: 13px; align-items: stretch; margin-bottom: 13px; }
  #view-ingresos .stat-row { display: contents; }
  /* stretch, no start: los paneles de una misma fila deben medir igual, igual
     que las tarjetas de la agenda. Con 'start' quedaban desparejos (220 px
     contra 432 px en la fila de abajo) y se veía descuidado. */
  .ingresos-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; align-items: stretch; }
  .ingresos-grid .panel { margin-bottom: 0; }
  .ingresos-grid .wide { grid-column: 1 / -1; }
  .spark { height: 158px; }
  .panel { padding: 20px; }
  /* Calendario y panel del día lado a lado, a la misma altura (stretch, como
     el resto de paneles emparejados). Con ratón, controles más compactos. */
  .cal-wrap { grid-template-columns: minmax(360px, 1.05fr) 1fr; align-items: stretch; }
  .cal-panel { padding: 20px; }
  .cal-nav { width: 38px; height: 38px; }
  .btn-dia, .btn-turno { min-height: 38px; }
  .turno { min-height: 52px; padding: 8px 12px; }
}

@media (min-width: 1500px) {
  #list { grid-template-columns: repeat(auto-fill, minmax(385px, 1fr)); }
}
