/* Concepto: libreta de turnos de barbería — azul tinta y rojo de poste, filas de horario como renglones. */
:root {
  --bg: #f3f4f7;
  --surface: #ffffff;
  --surface-2: #eceef3;
  --ink: #151a26;
  --muted: #5d6476;
  --line: #dadee7;
  --accent: #23408e;
  --accent-ink: #ffffff;
  --accent-soft: #e3e8f6;
  --ok: #1c7a45;   --ok-soft: #dff1e6;
  --bad: #b3302a;  --bad-soft: #f8e1df;
  --warn: #9a6a12; --warn-soft: #f7ecd6;
  --f-display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --f-body: "Instrument Sans", "Segoe UI", system-ui, sans-serif;
  --f-mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
  --r: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f121a; --surface: #171b26; --surface-2: #1f2432; --ink: #e7eaf2; --muted: #9aa2b6; --line: #2b3142;
    --accent: #8fa8ff; --accent-ink: #0f121a; --accent-soft: #232c49;
    --ok: #5fd08f; --ok-soft: #173325; --bad: #ff8a80; --bad-soft: #3b1f1d; --warn: #e7b65a; --warn-soft: #382c16;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--f-body); }
img { max-width: 100%; }
[hidden] { display: none !important; }
.shell { max-width: 1080px; margin: 0 auto; padding-block: 20px 64px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); display: grid; gap: 18px; }
.shell.angosto { max-width: 640px; }

h1, h2, h3 { font-family: var(--f-display); letter-spacing: -0.01em; text-wrap: balance; margin: 0; }
.titulo { font-size: clamp(26px, 5vw, 34px); line-height: 1.05; }
h2 { font-size: 22px; }
h3 { font-size: 17px; }
p { margin: 0; }
.sub, .muted { color: var(--muted); }
small.ayuda { color: var(--muted); font-size: 12px; }
.etiqueta { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }

.tarjeta { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 20px; display: grid; gap: 14px; min-width: 0; }
.tarjeta.estrecha { max-width: 440px; width: 100%; margin: 6vh auto 0; }
.seccion { display: grid; gap: 12px; }
/* Las columnas de la cuadrícula no deben estirarse por una tabla ancha (ella se desliza dentro de .tabla-wrap) */
.shell > *, .seccion > *, .tarjeta > *, .paso > * { min-width: 0; }

/* Botones */
.btn { font: 600 14px var(--f-body); border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 8px; padding: 9px 14px; cursor: pointer; min-height: 40px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap; }
.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: .55; cursor: progress; }
.btn.primario { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.sutil { background: transparent; }
.btn.peligro, .btn.sutil.peligro { background: var(--bad); border-color: var(--bad); color: var(--surface); }
.btn.icono { width: 40px; padding: 0; font-size: 20px; }
.btn.grande { min-height: 48px; font-size: 16px; width: 100%; }
.marca-ok { color: var(--ok); }
.marca-ok.activo { background: var(--ok); border-color: var(--ok); color: var(--surface); }
.marca-no { color: var(--bad); }
.marca-no.activo { background: var(--bad); border-color: var(--bad); color: var(--surface); }
.enlace { background: none; border: 0; color: var(--accent); font: 600 14px var(--f-body); cursor: pointer; padding: 4px 0; text-align: left; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Formularios */
.campo { display: grid; gap: 4px; min-width: 0; }
.campo label { font-size: 13px; font-weight: 600; color: var(--muted); }
input, select, textarea { font: 15px var(--f-body); color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; width: 100%; min-width: 0; min-height: 40px; }
textarea { resize: vertical; }
input[type="checkbox"] { width: 18px; height: 18px; min-height: 0; accent-color: var(--accent); }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; }
.check input { margin-top: 2px; flex: none; }
.fila-campos { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.error { color: var(--bad); font-size: 14px; min-height: 1em; }
.aviso { background: var(--warn-soft); color: var(--ink); border-radius: 8px; padding: 10px 12px; font-size: 14px; }
.info-box { background: var(--accent-soft); border-radius: 8px; padding: 10px 12px; font-size: 14px; }

/* Aviso de suscripción */
.banda { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; justify-content: space-between; background: var(--warn-soft); border-radius: 12px; padding: 12px 14px; font-size: 14px; }
.banda.mala { background: var(--bad-soft); }
.banda span { flex: 1 1 260px; min-width: 0; }
.pasos { margin: 0; padding-left: 20px; display: grid; gap: 6px; }
.botones.entre { justify-content: space-between; }

/* Barra superior y pestañas */
.barra { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.marca { display: flex; align-items: center; gap: 12px; min-width: 0; }
.nombre-neg { font-family: var(--f-display); font-size: 22px; display: block; line-height: 1.1; overflow-wrap: anywhere; }
.logo { width: 52px; height: 52px; border-radius: 12px; object-fit: cover; background: var(--surface); border: 1px solid var(--line); flex: none; }
.logo.grande { width: 84px; height: 84px; border-radius: 18px; }
.sin-logo { display: grid; place-items: center; font: 700 18px var(--f-display); color: var(--accent-ink); background: var(--accent); border: 0; }
.tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--line); scrollbar-width: none; }
.tab { border: 0; background: none; font: 600 14px var(--f-body); color: var(--muted); padding: 10px 14px; cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.tab[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); }

/* Agenda del día */
.dia-nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.dia-titulo { font-size: 22px; min-width: 0; flex: 1 1 200px; }
.dia-nav-der { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.dia-nav-der input[type="date"] { width: auto; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; display: grid; gap: 2px; }
.tile b { font: 600 22px var(--f-mono); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.tile span { font-size: 12px; color: var(--muted); }
.tile.ok b { color: var(--ok); } .tile.bad b { color: var(--bad); }

.lista-slots { display: grid; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.fila { display: grid; grid-template-columns: 96px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px 14px; border-top: 1px solid var(--line); }
.fila:first-child { border-top: 0; }
.fila .hora { font: 600 14px var(--f-mono); font-variant-numeric: tabular-nums; display: grid; white-space: nowrap; }
.fila .hora small { font-weight: 400; color: var(--muted); font-size: 12px; }
.fila .info { display: grid; gap: 4px; min-width: 0; }
.fila .cliente { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.fila .cliente strong { font-size: 16px; overflow-wrap: anywhere; }
.fila .detalle { display: flex; flex-wrap: wrap; gap: 4px 12px; color: var(--muted); font-size: 14px; }
.fila .tel { font-family: var(--f-mono); user-select: all; }
.fila .acciones { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.fila.libre { background: var(--surface); }
.fila.pasada { opacity: .5; }
.fila.ocupada { border-left: 4px solid var(--accent); }
.fila.est-llego { border-left-color: var(--ok); background: color-mix(in srgb, var(--ok-soft) 45%, var(--surface)); }
.fila.est-no_llego { border-left-color: var(--bad); background: color-mix(in srgb, var(--bad-soft) 45%, var(--surface)); }
.fila.cancelada { grid-template-columns: 96px minmax(0, 1fr); color: var(--muted); text-decoration: line-through; }
.cobro-hecho { grid-column: 2 / -1; display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; background: var(--ok-soft); border-radius: var(--r); padding: 10px 14px; font-size: 14px; }
@media (max-width: 640px) { .cobro-hecho { grid-column: 1 / -1; } }
.btn.chico { min-height: 32px; padding: 4px 10px; font-size: 13px; }
.guardado { color: var(--ok); font-weight: 600; font-size: 14px; min-height: 1.4em; }
.acciones.marcada { align-items: center; gap: 12px; }
.marca-final { font-weight: 700; font-size: 14px; padding: 6px 12px; border-radius: 8px; }
.marca-final.ok { background: var(--ok); color: var(--surface); }
.marca-final.no { background: var(--bad); color: var(--surface); }
.periodos { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.periodo { position: relative; display: grid; gap: 2px; border: 2px solid var(--line); border-radius: 12px; padding: 12px 14px; cursor: pointer; background: var(--surface); }
.periodo input { position: absolute; opacity: 0; pointer-events: none; }
.periodo strong { font-size: 16px; }
.periodo span { font-size: 12px; color: var(--muted); }
.periodo:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.periodo:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.pill { font-size: 11px; font-weight: 600; letter-spacing: .03em; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.pill.libre { background: var(--ok-soft); color: var(--ok); }
.pill.online { background: var(--accent-soft); color: var(--accent); }
.cobro { grid-column: 2 / -1; display: grid; grid-template-columns: 1.2fr .8fr; gap: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 12px; }
.cobro .campo:nth-child(3), .cobro button { grid-column: 1 / -1; }
.cobro button { justify-self: start; }
details.canceladas { border-top: 1px solid var(--line); padding: 10px 14px; }
details.canceladas summary { cursor: pointer; color: var(--muted); font-weight: 600; font-size: 14px; }
.vacio-box { padding: 28px 16px; text-align: center; display: grid; gap: 6px; }

@media (max-width: 640px) {
  .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .tile { padding: 10px; }
  .tile b { font-size: 17px; }
  .tile span { font-size: 11px; }
  .barra .btn.sutil { padding: 6px 10px; min-height: 34px; }
  .fila { grid-template-columns: 88px minmax(0, 1fr); }
  .fila .acciones { grid-column: 1 / -1; justify-content: flex-start; }
  .cobro { grid-column: 1 / -1; grid-template-columns: 1fr; }
}

/* Horario */
.dia-fila { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); align-items: start; }
.dia-fila:first-child { border-top: 0; }
.dia-nombre { display: flex; gap: 10px; align-items: center; font-weight: 600; min-height: 40px; }
.turnos { display: grid; gap: 8px; }
.turno { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.turno input[type="time"] { width: 120px; }
.turno select { width: auto; }
.presets { display: flex; gap: 6px; flex-wrap: wrap; }
.lista-simple { display: grid; gap: 6px; }
.lista-simple > div { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 10px; background: var(--surface-2); border-radius: 8px; }
@media (max-width: 560px) { .dia-fila { grid-template-columns: 1fr; gap: 6px; } }

/* Tablas */
.tabla-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); background: var(--surface-2); }
td.num, th.num { text-align: right; font-family: var(--f-mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }

/* Compartir */
.compartir-fila { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; align-items: center; }
.url { font-family: var(--f-mono); font-size: 13px; background: var(--surface-2); padding: 8px 10px; border-radius: 8px; overflow-wrap: anywhere; user-select: all; }
a.url { display: block; color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.qr-caja { display: grid; gap: 8px; justify-items: center; max-width: 200px; }
.aviso-qr { font-size: 12px; color: var(--muted); text-align: center; }
.qr { background: #ffffff; padding: 10px; border-radius: 10px; width: 180px; }
.qr img, .qr canvas { display: block; width: 160px; height: 160px; }
.botones { display: flex; gap: 8px; flex-wrap: wrap; }
@media (max-width: 560px) { .compartir-fila { grid-template-columns: 1fr; } }

/* Páginas públicas */
.cabecera-pub { display: flex; gap: 14px; align-items: center; }
.cabecera-pub .nombre-neg { font-size: clamp(22px, 5vw, 30px); }
.paso { display: grid; gap: 10px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
.chips.envolver { flex-wrap: wrap; overflow: visible; }
.chip { border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 10px; padding: 8px 12px; font: 500 14px var(--f-body); cursor: pointer; white-space: nowrap; flex: none; }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip.dia { display: grid; gap: 0; text-align: center; min-width: 74px; }
.chip.dia small { font-size: 11px; opacity: .8; }
.horas { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.horas .chip { font-family: var(--f-mono); text-align: center; }
.resumen-cita { font-size: 17px; font-weight: 600; }
.exito { text-align: center; justify-items: center; }
.exito .sello { width: 64px; height: 64px; border-radius: 50%; background: var(--ok); color: var(--surface); display: grid; place-items: center; font-size: 34px; }
.dia-libres { display: grid; gap: 8px; padding: 12px 0; border-top: 1px solid var(--line); }
.dia-libres:first-child { border-top: 0; }

.pie { text-align: center; color: var(--muted); font-size: 12px; }

/* Modal y aviso flotante */
dialog.modal { border: 1px solid var(--line); border-radius: 16px; background: var(--surface); color: var(--ink); padding: 0; width: min(520px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); }
dialog.modal::backdrop { background: rgba(8, 12, 22, .5); }
dialog.modal form, dialog.modal .contenido { padding: 20px; display: grid; gap: 14px; }
.acciones-modal { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(20px + env(safe-area-inset-bottom, 0px)); background: var(--ink); color: var(--bg); padding: 11px 18px; border-radius: 10px; font-weight: 500; z-index: 50; max-width: calc(100vw - 32px); box-shadow: 0 6px 24px rgba(0,0,0,.2); }
@media (prefers-reduced-motion: no-preference) { .chip, .btn { transition: background-color .12s, border-color .12s; } }

/* ¿Ya reservaste? Ver mi cita */
.buscar-cita { margin: 0 0 14px; }
.buscar-cita > .enlace { font-size: 15px; }
.fila-buscar { display: flex; gap: 8px; flex-wrap: wrap; }
.fila-buscar input { flex: 1 1 180px; min-width: 0; }
