/* =============================================================================
   AUSTIN ML APP — Hoja de estilos
   Réplica visual de Jolt: sidebar oscuro fijo, columna de listas, panel derecho.
   Optimizado para tablet en landscape (1024–1366 px). Soporta modo oscuro.
   ============================================================================= */

:root {
  /* Paleta de marca extraída del logotipo oficial Austin Restaurant Manager */
  --brand-green:    #18442B;
  --brand-green-dk: #0E2A1B;
  --brand-red:      #7F1B23;

  --sb-bg:        var(--brand-green-dk);
  --sb-bg-active: #ffffff;
  --sb-fg:        #EAF1EC;
  --sb-fg-active: var(--brand-green);
  --sb-w:         152px;

  --bg:        #ffffff;
  --bg-alt:    #EEF1EE;
  --panel:     #ffffff;
  --fg:        #16211A;
  --fg-soft:   #667A6E;
  --line:      #DFE5E0;

  --blue:      var(--brand-green);
  --blue-dk:   var(--brand-green-dk);
  --green:     #1E7A45;
  --red:       var(--brand-red);
  --amber:     #B87503;

  --radius:    10px;
  --tap:       56px;
  --shadow:    0 2px 12px rgba(14,42,27,.14);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  /* Áreas seguras: notch, isla dinámica, barra de gestos, esquinas redondeadas */
  --sat: env(safe-area-inset-top, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
}

[data-theme="dark"] {
  --sb-bg:        #0A1710;
  --sb-bg-active: #172C20;
  --sb-fg:        #DCE7DF;
  --sb-fg-active: #ffffff;

  --bg:      #121A15;
  --bg-alt:  #0C120E;
  --panel:   #18211B;
  --fg:      #E9F0EB;
  --fg-soft: #93A69A;
  --line:    #26332B;
  --shadow:  0 2px 14px rgba(0,0,0,.6);
  --green:   #35A15E;
  --red:     #C4444F;
  --amber:   #E0A32B;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/*
 * El atributo [hidden] manda sobre cualquier display de clase.
 * Sin esto, reglas como `.alert-bar { display:flex }` ganaban por especificidad
 * al `display:none` del navegador y los elementos "ocultos" seguían visibles:
 * la barra de alertas no se cerraba y el mensaje "Seleccione una lista" se
 * quedaba encima del detalle empujándolo hacia abajo.
 */
[hidden] { display: none !important; }

html, body {
  margin: 0; height: 100%; overflow: hidden;
  font-family: var(--font); color: var(--fg); background: var(--bg-alt);
  -webkit-user-select: none; user-select: none;
  overscroll-behavior: none;
  text-size-adjust: 100%; -webkit-text-size-adjust: 100%;
}

button { font-family: inherit; cursor: pointer; border: 0; background: none; color: inherit; }
svg { width: 30px; height: 30px; fill: currentColor; }

/* ------------------------------- LAYOUT ---------------------------------- */

.app { display: flex; height: 100vh; height: 100dvh; }

/* ------------------------------- SIDEBAR --------------------------------- */

.sidebar {
  width: calc(var(--sb-w) + var(--sal));
  flex: 0 0 calc(var(--sb-w) + var(--sal));
  padding-left: var(--sal);
  padding-bottom: var(--sab);
  background: var(--sb-bg); color: var(--sb-fg);
  display: flex; flex-direction: column; align-items: stretch;
  overflow-y: auto; overscroll-behavior: contain;
  scrollbar-width: none;
}
.sidebar::-webkit-scrollbar { display: none; }

.sb-burger {
  min-height: 74px; padding-top: var(--sat);
  background: rgba(0,0,0,.28);
  display: flex; flex-direction: column; justify-content: center;
  align-items: center; gap: 6px;
}
.sb-burger span { width: 34px; height: 3px; background: #fff; border-radius: 2px; }

.sb-item {
  min-height: 100px; padding: 12px 4px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  color: var(--sb-fg); font-size: 13px; font-weight: 600;
  transition: background .12s ease;
}
.sb-item em { font-style: normal; }
.sb-item:active { background: rgba(255,255,255,.08); }
.sb-item.is-active { background: var(--sb-bg-active); color: var(--sb-fg-active); }
.sb-item[hidden] { display: none; }

.sb-brand {
  margin-top: auto; padding: 20px 10px calc(24px + var(--sab));
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  color: rgba(234,241,236,.72); font-size: 15px; font-weight: 600; letter-spacing: .04em;
}
.sb-brand img {
  width: 48px; height: 48px; border-radius: 12px; background: #fff;
  padding: 4px; object-fit: contain; box-shadow: 0 2px 8px rgba(0,0,0,.3);
}

/* -------------------------------- MAIN ----------------------------------- */

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--bg); }

.topbar {
  min-height: calc(74px + var(--sat)); flex: 0 0 auto; background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: var(--sat) calc(18px + var(--sar)) 0 18px; gap: 12px;
}
.tb-date { display: flex; align-items: center; gap: 10px; font-size: 15px; line-height: 1.15; }
.tb-cloud { width: 34px; height: 34px; color: var(--fg-soft); }
.tb-sync { text-align: center; color: var(--fg-soft); font-size: 15px; }
.tb-sync.is-ok  { color: var(--green); }
.tb-sync.is-err { color: var(--red); }
.tb-right { display: flex; align-items: center; justify-content: flex-end; gap: 10px; }

.btn-lang, .btn-theme {
  width: 42px; height: 42px; border-radius: 50%;
  border: 1px solid var(--line); font-size: 14px; font-weight: 700; color: var(--fg-soft);
}
.btn-session {
  min-height: 44px; padding: 4px 20px; border-radius: 22px;
  border: 1px solid var(--line); color: var(--blue); font-size: 17px; font-weight: 600;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.btn-session small { font-size: 12px; color: var(--fg-soft); font-weight: 500; }
.avatar {
  width: 46px; height: 46px; border-radius: 50%; background: #9e9e9e; color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 16px;
}

/* ----------------------------- ALERT BAR --------------------------------- */

.alert-bar {
  background: var(--red); color: #fff; padding: 10px 18px;
  display: flex; align-items: center; gap: 10px; font-size: 15px; font-weight: 600;
  animation: pulseBar 1.6s ease-in-out infinite;
}
@keyframes pulseBar { 0%,100% { filter: brightness(1); } 50% { filter: brightness(1.18); } }
.alert-bar b { font-size: 20px; }
.alert-bar button {
  margin-left: auto; background: rgba(255,255,255,.2); color: #fff;
  padding: 7px 16px; border-radius: 16px; font-weight: 600;
}
.alert-bar .alert-x { margin-left: 0; background: none; padding: 6px 10px; }

/* ------------------------------ CONTENIDO -------------------------------- */

.content { flex: 1; display: flex; min-height: 0; }

.col-lists {
  width: 484px; flex: 0 0 484px; background: var(--panel);
  border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0;
}
.col-head { display: flex; align-items: center; gap: 12px; padding: 20px 22px 14px; }
.col-head h1 { margin: 0; font-size: 30px; font-weight: 600; }
.col-head .back { font-size: 28px; color: var(--fg); padding: 0 4px; }

.list-scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; border-top: 1px solid var(--line); }

/* Fila de checklist */
.lrow {
  width: 100%; padding: 18px 22px; border-bottom: 1px solid var(--line);
  display: grid; grid-template-columns: 1fr auto auto; align-items: center;
  gap: 12px; text-align: left;
}
.lrow:active { background: rgba(0,0,0,.04); }
.lrow.is-sel { background: var(--blue); color: #fff; }
.lrow.is-sel .lrow-sub { color: rgba(255,255,255,.85); }
.lrow-t { font-size: 21px; font-weight: 600; line-height: 1.2; }
.lrow-sub { font-size: 16px; color: var(--fg-soft); margin-top: 4px; }
.lrow-count { font-size: 17px; font-weight: 500; }
.lrow-dot {
  width: 26px; height: 26px; border-radius: 50%;
  border: 3px solid #9e9e9e; background: transparent;
}
.lrow-dot.is-full { background: #9e9e9e; box-shadow: inset 0 0 0 4px var(--panel); }
.lrow.is-sel .lrow-dot { border-color: #fff; }
.lrow.is-sel .lrow-dot.is-full { background: #fff; box-shadow: inset 0 0 0 4px var(--blue); }
.lrow.is-late .lrow-t::after {
  content: '●'; color: var(--red); font-size: 14px; margin-left: 8px; vertical-align: middle;
}
.lrow-nav { font-size: 24px; color: var(--fg-soft); }

/* ------------------------------- DETALLE --------------------------------- */

.col-detail {
  flex: 1; min-width: 0; background: var(--bg-alt); overflow-y: auto;
  padding-right: var(--sar); -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
}
[data-theme="dark"] .col-detail { background: var(--bg-alt); }

.empty { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 40px; }
.empty h2 { font-size: 34px; margin: 0 0 12px; }
.empty p { font-size: 21px; color: var(--fg-soft); margin: 0; max-width: 26ch; }

.detail-head {
  background: var(--panel); padding: 16px 22px; display: flex; gap: 14px; align-items: center;
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5;
}
.dh-bar { width: 6px; height: 40px; background: var(--blue); border-radius: 3px; flex: 0 0 6px; }
.detail-head b { display: block; font-size: 21px; }
.detail-head small { display: block; font-size: 15px; color: var(--fg-soft); margin-top: 2px; }

.detail-meta {
  background: var(--panel); border-bottom: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(3, 1fr); padding: 14px 22px; gap: 10px;
}
.detail-meta > div { display: flex; align-items: center; gap: 8px; font-size: 15px; color: var(--fg-soft); }
.detail-meta svg { width: 26px; height: 26px; }
.detail-meta b { color: var(--fg); font-size: 17px; }

.tasks { padding: 0 0 calc(96px + var(--sab)); }

/* Tarjeta de tarea */
.task {
  background: var(--panel); border-bottom: 1px solid var(--line); padding: 18px 22px 0;
}
.task-top { display: flex; gap: 12px; align-items: flex-start; }
.task-txt { flex: 1; font-size: 19px; line-height: 1.35; }
.task-kebab { color: var(--fg-soft); font-size: 22px; padding: 0 6px; line-height: 1; }

.task-thumb {
  display: block; max-width: 60%; max-height: 190px; border-radius: 10px;
  margin: 14px auto 0; object-fit: cover;
}

.task-ctrl { display: flex; justify-content: flex-end; align-items: center; gap: 10px; padding: 14px 0 16px; }

.chk {
  width: 62px; height: 62px; border-radius: 50%; background: #ececec;
  display: flex; align-items: center; justify-content: center;
  font-size: 30px; color: #4a4a4a; transition: transform .1s ease, background .15s ease;
}
[data-theme="dark"] .chk { background: #2b2e35; color: #cfd3da; }
.chk:active { transform: scale(.92); }
.chk.is-done { background: var(--green); color: #fff; }
.chk.is-cam::after { content: '📷'; font-size: 24px; }

.yn { display: flex; gap: 10px; }
.yn button {
  min-width: 92px; height: 58px; border-radius: 8px; background: #ececec;
  font-size: 22px; font-weight: 600; color: #4a4a4a;
}
[data-theme="dark"] .yn button { background: #2b2e35; color: #cfd3da; }
.yn button.is-on[data-v="YES"] { background: var(--green); color: #fff; }
.yn button.is-on[data-v="NO"]  { background: var(--red);   color: #fff; }

.task-sign {
  display: flex; align-items: stretch; margin: 0 -22px; font-size: 15px; color: #fff;
}
.task-sign i { background: var(--blue-dk); padding: 8px 12px; font-style: normal; font-weight: 700; }
.task-sign span { background: var(--blue); padding: 8px 14px; flex: 0 1 auto; }

.task-cor {
  margin-top: 12px; padding: 10px 14px; border-radius: 8px;
  background: rgba(249,171,0,.14); border-left: 4px solid var(--amber);
  font-size: 16px; line-height: 1.4;
}
.task-cor b { color: var(--amber); }
.task.is-corrective { box-shadow: inset 5px 0 0 var(--amber); }

.task.is-overdue { box-shadow: inset 5px 0 0 var(--red); }
.task.is-overdue .task-txt::before {
  content: '⚠ '; color: var(--red); font-weight: 700;
}

.fab {
  position: fixed; left: calc(var(--sb-w) + var(--sal) + 26px);
  bottom: calc(26px + var(--sab)); z-index: 20;
  width: 68px; height: 68px; border-radius: 50%; background: var(--blue); color: #fff;
  font-size: 36px; box-shadow: var(--shadow);
}

/* ------------------------------- MODALES --------------------------------- */

.modal {
  position: fixed; inset: 0; background: rgba(14,42,27,.48);
  display: flex; align-items: center; justify-content: center; z-index: 400;
  padding: calc(20px + var(--sat)) calc(20px + var(--sar))
           calc(20px + var(--sab)) calc(20px + var(--sal));
  backdrop-filter: blur(2px);
}
.modal[hidden] { display: none; }

.sheet {
  width: 100%; max-width: 660px; max-height: 100%; overflow: hidden;
  background: var(--panel); border-radius: 16px; box-shadow: var(--shadow);
  display: flex; flex-direction: column;
}
.sheet-wide { max-width: 860px; }

.sheet-head {
  display: grid; grid-template-columns: 48px 1fr 48px; align-items: center;
  padding: 18px 16px; font-size: 24px; font-weight: 600; text-align: center;
  border-bottom: 1px solid var(--line);
}
.sheet-head .ic { font-size: 24px; color: var(--fg); }

/* Buscador de usuario: abre el teclado nativo del dispositivo */
.search-wrap {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px; border-bottom: 1px solid var(--line); flex: 0 0 auto;
}
.search-ic { width: 24px; height: 24px; color: var(--fg-soft); flex: 0 0 24px; }
.search-wrap input {
  flex: 1; min-width: 0; height: 54px; border: 0; outline: none;
  font-family: inherit; font-size: 21px; background: transparent; color: var(--fg);
  -webkit-user-select: text; user-select: text;
}
.search-wrap input::placeholder { color: var(--fg-soft); }
.search-wrap input::-webkit-search-cancel-button { display: none; }
.search-x {
  width: 38px; height: 38px; border-radius: 50%; background: var(--bg-alt);
  color: var(--fg-soft); font-size: 15px; flex: 0 0 38px;
}

.user-list { overflow-y: auto; -webkit-overflow-scrolling: touch; min-height: 120px; }
.user-list button {
  width: 100%; padding: 18px 22px; text-align: left; font-size: 21px;
  border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 14px;
}
.user-list button:active { background: rgba(0,0,0,.05); }
.user-list .ini {
  width: 46px; height: 46px; border-radius: 50%; flex: 0 0 46px;
  background: var(--brand-green); color: #fff; font-size: 16px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.user-list .nm { flex: 1; min-width: 0; }
.user-list .nm b { display: block; font-weight: 600; }
.user-list small { color: var(--fg-soft); font-size: 15px; }
.user-list .none { padding: 28px 22px; color: var(--fg-soft); font-size: 17px; text-align: center; }

/* Pad numérico */
.sheet-pin { max-width: 560px; }
.pin-dots { display: flex; justify-content: center; gap: 22px; padding: 26px 0 10px; }
.pin-dots i {
  width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--fg-soft);
  display: block; transition: background .12s ease;
}
.pin-dots i.on { background: var(--fg); border-color: var(--fg); }
.pin-dots.err i { border-color: var(--red); animation: shake .32s; }
@keyframes shake {
  0%,100% { transform: translateX(0); } 25% { transform: translateX(-7px); } 75% { transform: translateX(7px); }
}
.pin-hint { text-align: center; color: var(--fg-soft); letter-spacing: .1em; font-size: 15px; padding-bottom: 18px; }
.pin-hint.err { color: var(--red); letter-spacing: 0; }

.keypad { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--line); }
.keypad button {
  height: 108px; font-size: 36px; font-weight: 300; color: var(--fg-soft);
  border-right: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
.keypad button:active { background: rgba(0,0,0,.06); }
.keypad .soft { font-size: 24px; display: flex; flex-direction: column; gap: 4px; background: rgba(0,0,0,.02); }
.keypad .soft em { font-style: normal; font-size: 14px; }

/* Foto */
.sheet-photo { max-width: 620px; }
.photo-body { padding: 18px 22px; display: flex; flex-direction: column; gap: 14px; align-items: center; }
.photo-body img { max-width: 100%; max-height: 44vh; border-radius: 10px; display: none; }
.photo-body img.on { display: block; }
.photo-info { margin: 0; font-size: 14px; color: var(--fg-soft); }
.photo-body textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 10px;
  font-family: inherit; font-size: 16px; background: var(--bg); color: var(--fg); resize: none;
  -webkit-user-select: text; user-select: text;
}
.photo-actions { display: flex; gap: 12px; padding: 0 22px 22px; }
.btn-primary, .btn-ghost {
  flex: 1; height: 56px; border-radius: 10px; font-size: 18px; font-weight: 600;
}
.btn-primary { background: var(--blue); color: #fff; }
.btn-ghost   { background: var(--bg-alt); color: var(--fg); }

/* Personal */
.people-body { overflow-y: auto; padding: 6px 0; }
.prow {
  display: grid; grid-template-columns: 1fr auto auto; gap: 12px; align-items: center;
  padding: 16px 22px; border-bottom: 1px solid var(--line); font-size: 18px;
}
.prow small { display: block; color: var(--fg-soft); font-size: 14px; }
.prow button { padding: 10px 14px; border-radius: 8px; background: var(--bg-alt); font-size: 15px; font-weight: 600; }
.prow .danger { color: var(--red); }

.people-form { padding: 18px 22px 22px; display: flex; flex-direction: column; gap: 12px; border-top: 1px solid var(--line); }
.people-form input, .people-form select {
  height: 54px; border: 1px solid var(--line); border-radius: 8px; padding: 0 12px;
  font-size: 17px; font-family: inherit; background: var(--bg); color: var(--fg);
  -webkit-user-select: text; user-select: text;
}
.pf-actions { display: flex; gap: 12px; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: calc(34px + var(--sab)); transform: translateX(-50%);
  background: #222; color: #fff; padding: 14px 24px; border-radius: 26px;
  font-size: 16px; z-index: 500; box-shadow: var(--shadow); max-width: 82vw; text-align: center;
}
.toast.err { background: var(--red); }
.toast.ok  { background: var(--green); }

/* ------------------------------ RESPONSIVE ------------------------------- */

/* Tablet landscape estrecha */
@media (max-width: 1240px) { .col-lists { width: 400px; flex-basis: 400px; } }

/* Tablet en vertical y móviles: una sola columna con panel deslizante */
@media (max-width: 1024px) {
  :root { --sb-w: 96px; }
  .sb-item { min-height: 84px; font-size: 11px; gap: 4px; }
  .sb-item svg { width: 26px; height: 26px; }
  .sb-brand img { width: 38px; height: 38px; }
  .sb-brand span { font-size: 12px; }
  .content { position: relative; }
  .col-lists { width: 100%; flex-basis: 100%; border-right: 0; }
  .col-detail {
    position: absolute; inset: 0; transform: translateX(100%);
    transition: transform .22s ease; z-index: 4; padding-right: 0;
  }
  body.show-detail .col-detail { transform: translateX(0); }
  .detail-meta { grid-template-columns: 1fr; gap: 6px; }
  .col-head h1 { font-size: 26px; }
  .lrow-t { font-size: 19px; }
  .fab { left: auto; right: calc(24px + var(--sar)); }
}

/* --------------------------------- TELÉFONO ------------------------------ */
/*
 * En pantallas angostas la barra superior no puede llevar fecha + sede +
 * sincronización + 5 botones: se atropellan. Se reduce a lo imprescindible
 * (restaurante, refrescar, sesión) y idioma/tema se consultan desde Ajustes.
 */
@media (max-width: 700px) {
  :root { --sb-w: 76px; }

  .sb-item { min-height: 66px; font-size: 9.5px; gap: 3px; padding: 8px 1px; line-height: 1.1; }
  .sb-item svg { width: 22px; height: 22px; }
  .sb-item em { display: block; text-align: center; word-break: break-word; }
  .sb-burger { min-height: 56px; }
  .sb-burger span { width: 26px; }
  .sb-brand { padding: 12px 6px calc(14px + var(--sab)); }
  .sb-brand img { width: 34px; height: 34px; }
  .sb-brand span { display: none; }

  /*
   * Dos filas: arriba el restaurante (que puede ser largo) con las acciones;
   * abajo fecha, hora y estado de sincronización. Antes competían en una sola
   * fila y se encimaban o se truncaban a "NDO M...".
   */
  .topbar {
    grid-template-columns: 1fr auto;
    grid-template-areas: "mid right" "date date";
    align-items: center;
    min-height: calc(54px + var(--sat));
    padding: var(--sat) calc(10px + var(--sar)) 4px 10px;
    gap: 2px 8px;
  }
  .tb-date {
    grid-area: date; display: flex; align-items: baseline; gap: 6px;
    font-size: 11px; line-height: 1.2; color: var(--fg-soft); white-space: nowrap;
  }
  .tb-date .tb-cloud { display: none; }
  .tb-date > div { display: flex; align-items: baseline; gap: 6px; }
  .tb-date br { display: none; }
  .tb-date .clock { font-size: 12px; }
  .tb-mid  { grid-area: mid; align-items: flex-start; min-width: 0; gap: 0; }
  .tb-right{ grid-area: right; gap: 6px; }

  .tb-sede {
    max-width: 100%; font-size: 14px; padding: 2px 0; background: transparent;
    font-weight: 700; text-align: left;
  }
  .tb-sync { display: none; }        /* el estado va en la fila de la fecha */

  .topbar .btn-lang, .topbar .btn-theme { display: none; }   /* viven en Ajustes */
  .btn-refresh { width: 38px; height: 38px; }
  .btn-refresh svg { width: 19px; height: 19px; }
  .btn-session {
    min-height: 38px; padding: 2px 12px; font-size: 13px; border-radius: 19px;
    max-width: 96px; text-align: center; line-height: 1.1;
  }
  .btn-session small { font-size: 10px; }
  .avatar { width: 38px; height: 38px; font-size: 13px; }

  .alert-bar { font-size: 13px; padding: 8px 12px; gap: 8px; }
  .alert-bar b { font-size: 17px; }
  .alert-bar button { padding: 6px 12px; font-size: 13px; }

  .col-head { padding: 14px 16px 10px; }
  .col-head h1 { font-size: 24px; }
  .lrow { padding: 14px 16px; gap: 8px; }
  .lrow-t { font-size: 17px; }
  .lrow-sub, .lrow-count { font-size: 13px; }
  .lrow-dot { width: 22px; height: 22px; border-width: 2px; }

  .detail-head { padding: 12px 16px; }
  .detail-head b { font-size: 17px; }
  .detail-meta { grid-template-columns: repeat(3, 1fr); padding: 10px 16px; gap: 6px; }
  .detail-meta > div { flex-direction: column; align-items: flex-start; gap: 0; font-size: 11px; }
  .detail-meta svg { display: none; }
  .detail-meta b { font-size: 14px; }

  .task { padding: 14px 16px 0; }
  .task-txt { font-size: 16px; }
  .task-sign { margin: 0 -16px; font-size: 12px; }
  .task-sign i { padding: 6px 9px; }
  .task-sign span { padding: 6px 10px; }
  .task-thumb { max-width: 100%; max-height: 150px; }
  .chk { width: 52px; height: 52px; font-size: 25px; }
  .cam { width: 46px; height: 46px; }
  .yn button { min-width: 74px; height: 50px; font-size: 18px; }

  .empty h2 { font-size: 22px; } .empty p { font-size: 15px; }
  .keypad button { height: 74px; font-size: 28px; }
  .sheet-head { font-size: 18px; padding: 14px 10px; }
  .fab { width: 56px; height: 56px; font-size: 30px; }
}

/* Pantallas bajas en horizontal (teléfono acostado): compacta alturas */
@media (max-height: 480px) {
  .keypad button { height: 62px; font-size: 26px; }
  .pin-dots { padding: 14px 0 6px; }
  .alpha button { height: 58px; }
  .sb-item { min-height: 60px; }
}

/* Respeto por accesibilidad del sistema */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* ============================================================================
   PANTALLA DE INICIO DE SESIÓN
   ========================================================================= */

.login {
  position: fixed; inset: 0; z-index: 200; display: flex;
  align-items: center; justify-content: center;
  padding: calc(20px + var(--sat)) calc(20px + var(--sar))
           calc(20px + var(--sab)) calc(20px + var(--sal));
  background: linear-gradient(160deg, var(--brand-green) 0%, var(--brand-green-dk) 62%, #071009 100%);
}
.login[hidden] { display: none; }

.login-card {
  width: 100%; max-width: 520px; max-height: 100%;
  background: var(--panel); border-radius: 20px; box-shadow: 0 18px 48px rgba(0,0,0,.34);
  display: flex; flex-direction: column; overflow: hidden;
  padding: 26px 0 0;
}
.login-logo {
  width: 190px; max-width: 62%; height: auto; object-fit: contain;
  margin: 4px auto 6px; display: block;
}
.login-sub { margin: 6px 24px 10px; text-align: center; color: var(--fg-soft); font-size: 16px; }
.login-card .search-wrap { margin: 6px 10px 0; border-bottom: 1px solid var(--line); }
.login-card .user-list { flex: 1; min-height: 140px; max-height: 46vh; }
.login-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 22px calc(18px + var(--sab)); border-top: 1px solid var(--line);
  color: var(--fg-soft); font-size: 14px;
}

/* ============================================================================
   SELECCIÓN DE RESTAURANTE (Gerente / Desarrollador)
   ========================================================================= */

.sedes {
  position: fixed; inset: 0; z-index: 190; overflow-y: auto; background: var(--bg-alt);
  padding-bottom: calc(24px + var(--sab));
}
.sedes[hidden] { display: none; }

.sedes-head {
  display: flex; align-items: center; gap: 14px; background: var(--brand-green-dk); color: #fff;
  padding: calc(16px + var(--sat)) calc(20px + var(--sar)) 16px calc(20px + var(--sal));
  position: sticky; top: 0; z-index: 2;
}
.sedes-head img { width: 44px; height: 44px; border-radius: 10px; background: #fff; padding: 3px; object-fit: contain; }
.sedes-head b { display: block; font-size: 19px; }
.sedes-head small { display: block; font-size: 13px; opacity: .78; margin-top: 2px; }
.sedes-head .btn-ghost { margin-left: auto; }
.btn-ghost.sm { flex: 0 0 auto; height: 42px; padding: 0 16px; font-size: 15px; background: rgba(255,255,255,.16); color: #fff; }

.sede-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 18px; padding: 22px calc(20px + var(--sar)) 22px calc(20px + var(--sal));
}
.sede-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  padding: 20px 18px 18px; display: flex; flex-direction: column; align-items: center;
  gap: 12px; text-align: center; box-shadow: var(--shadow);
  transition: transform .12s ease, box-shadow .12s ease;
}
.sede-card:active { transform: scale(.98); }
.sede-card img {
  width: 100%; max-width: 190px; height: 130px; object-fit: contain; background: #fff;
  border-radius: 12px; padding: 8px;
}
.sede-card b { font-size: 18px; line-height: 1.25; }
.sede-card small { color: var(--fg-soft); font-size: 14px; }
.sede-card .go {
  margin-top: 4px; width: 100%; height: 46px; border-radius: 10px;
  background: var(--brand-green); color: #fff; font-size: 16px; font-weight: 600;
}
.sede-card.add { justify-content: center; border-style: dashed; color: var(--fg-soft); min-height: 260px; }
.sede-card.add .plus { font-size: 42px; line-height: 1; }

/* Restaurante activo en la barra superior */
.tb-mid { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 0; }
.tb-sede {
  max-width: 100%; padding: 4px 12px; border-radius: 14px; background: var(--bg-alt);
  color: var(--fg); font-size: 14px; font-weight: 700; letter-spacing: .02em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tb-sede[hidden] { display: none; }



.login-actions { display: flex; gap: 10px; }
.sedes-head .btn-lang, .sedes-head .btn-theme { margin-left: auto; }
.sedes-head .btn-lang + .btn-theme, .sedes-head .btn-theme + .btn-lang { margin-left: 0; }
.btn-theme.on-dark, .btn-lang.on-dark {
  border-color: rgba(255,255,255,.34); color: #fff; background: rgba(255,255,255,.12);
}

/* El shell de la aplicación no debe verse detrás del login ni del selector
   de restaurante: se oculta por completo hasta que la sesión está resuelta. */
body.pre-auth .app { display: none; }

/* Formulario de acceso: nombre exacto, sin autocompletado ni directorio */
.login-form { display: flex; flex-direction: column; gap: 10px; padding: 4px 24px 18px; }
.login-form label {
  font-size: 13px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--fg-soft);
}
.login-form input {
  height: 58px; border: 1px solid var(--line); border-radius: 12px; padding: 0 14px;
  font-family: inherit; font-size: 19px; background: var(--bg); color: var(--fg);
  -webkit-user-select: text; user-select: text;
}
.login-form input:focus { outline: none; border-color: var(--brand-green); }
.login-form .btn-primary { height: 56px; }

/* ---------------------- ACTUALIZAR / SINCRONIZAR ------------------------- */

.btn-refresh {
  width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--line);
  color: var(--fg-soft); display: flex; align-items: center; justify-content: center;
}
.btn-refresh svg { width: 22px; height: 22px; }
.btn-refresh:active { background: var(--bg-alt); }
body.is-syncing .btn-refresh svg { animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.tb-sync { cursor: pointer; }
body.is-syncing .tb-sync { opacity: .55; }

.update-bar {
  background: var(--brand-green); color: #fff; padding: 10px 18px;
  display: flex; align-items: center; gap: 10px; font-size: 15px; font-weight: 600;
}
.update-bar[hidden] { display: none; }
.update-bar svg { width: 22px; height: 22px; flex: 0 0 22px; }
.update-bar button {
  margin-left: auto; background: #fff; color: var(--brand-green);
  padding: 8px 18px; border-radius: 16px; font-weight: 700; font-size: 15px;
}



/* Botón de cámara presente en todas las tareas */
.cam {
  width: 54px; height: 54px; border-radius: 50%; background: var(--bg-alt);
  color: var(--fg-soft); display: flex; align-items: center; justify-content: center;
  flex: 0 0 auto;
}
.cam svg { width: 24px; height: 24px; }
.cam:active { transform: scale(.94); }
[data-theme="dark"] .cam { background: #2b2e35; color: #cfd3da; }

/* La marca hecha invita a tocarla de nuevo para revertir */
.chk.is-done { position: relative; }
.chk.is-done::after {
  content: ''; position: absolute; inset: -4px; border-radius: 50%;
  border: 2px dashed transparent;
}
.chk.is-done:active::after { border-color: var(--fg-soft); }

/* ============================================================================
   SECCIONES DEL MENÚ (Inicio, Biblioteca, Bitácora, Reportes, Personal, Ajustes)
   ========================================================================= */

.view {
  flex: 1; min-height: 0; overflow-y: auto; background: var(--bg-alt);
  padding: 20px calc(20px + var(--sar)) calc(28px + var(--sab)) 20px;
  -webkit-overflow-scrolling: touch;
}
.view[hidden] { display: none; }
.content[hidden] { display: none; }

.view h1 { margin: 0 0 4px; font-size: 26px; font-weight: 600; }
.view .lead { margin: 0 0 18px; color: var(--fg-soft); font-size: 15px; }

.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 16px 18px; margin-bottom: 14px; box-shadow: var(--shadow);
}
.card h2 { margin: 0 0 10px; font-size: 17px; font-weight: 600; }
.card .row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.card .row:last-child { border-bottom: 0; }
.card .row .g { flex: 1; min-width: 0; }
.card .row b { display: block; font-size: 16px; }
.card .row small { color: var(--fg-soft); font-size: 13px; }

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 16px; text-align: center;
}
.kpi b { display: block; font-size: 30px; font-weight: 700; line-height: 1.1; }
.kpi span { font-size: 13px; color: var(--fg-soft); }
.kpi.bad b { color: var(--red); }
.kpi.good b { color: var(--green); }

.bar { height: 10px; background: var(--bg-alt); border-radius: 6px; overflow: hidden; margin-top: 8px; }
.bar i { display: block; height: 100%; background: var(--green); border-radius: 6px; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--fg-soft); }
.field input, .field select, .field textarea {
  min-height: 52px; border: 1px solid var(--line); border-radius: 10px; padding: 12px;
  font-family: inherit; font-size: 16px; background: var(--bg); color: var(--fg);
  -webkit-user-select: text; user-select: text;
}
.field textarea { min-height: 96px; resize: vertical; }

.seg { display: flex; gap: 8px; flex-wrap: wrap; }
.seg button {
  flex: 1; min-width: 110px; height: 48px; border-radius: 10px;
  background: var(--bg-alt); color: var(--fg); font-size: 15px; font-weight: 600;
  border: 1px solid var(--line);
}
.seg button.on { background: var(--brand-green); color: #fff; border-color: var(--brand-green); }

.doc-row a { color: var(--brand-green); font-weight: 600; text-decoration: none; }
.empty-note { color: var(--fg-soft); font-size: 15px; padding: 14px 0; }

@media (max-width: 700px) {
  .view { padding: 14px 14px calc(24px + var(--sab)); }
  .view h1 { font-size: 21px; }
  .kpi b { font-size: 24px; }
}

/* Reloj del restaurante bajo la fecha */
.clock { font-weight: 700; color: var(--brand-green); letter-spacing: .02em; }
[data-theme="dark"] .clock { color: #7FBF95; }

/* Botón principal del acceso: objetivo táctil amplio */
.login-form .btn-primary {
  height: 64px; font-size: 19px; letter-spacing: .01em; border-radius: 14px;
  box-shadow: 0 4px 14px rgba(24,68,43,.28);
}
.login-form .btn-primary:active { transform: scale(.985); }

/* El aviso de bloqueo solo aparece en el último minuto */
.btn-session small:empty { display: none; }
.btn-session small { color: var(--red); font-weight: 700; }

/* Confirmación explícita del PIN + estado de carga visible */
.pin-foot { padding: 14px 18px calc(18px + var(--sab)); border-top: 1px solid var(--line); }
.pin-foot .btn-primary {
  width: 100%; height: 62px; font-size: 19px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center; gap: 10px;
}
.pin-foot .btn-primary[disabled] { opacity: .42; }
.pin-foot em { font-style: normal; }

.spin {
  width: 20px; height: 20px; border-radius: 50%; flex: 0 0 20px;
  border: 2.5px solid rgba(255,255,255,.35); border-top-color: #fff;
  animation: spin .7s linear infinite;
}
.spin[hidden] { display: none; }

/* Con la sesión en curso el teclado se bloquea para no duplicar el envío */
.sheet-pin.is-busy .keypad { pointer-events: none; opacity: .5; }

/* Alerta: objetivos táctiles amplios y por encima de cualquier capa */
.alert-bar { position: relative; z-index: 30; }
.alert-bar button { min-height: 40px; min-width: 44px; position: relative; z-index: 31; }
.alert-bar .alert-x { font-size: 20px; padding: 8px 12px; }

/* Tarea señalada desde la alerta */
.task.is-focus { animation: focusPulse 1.8s ease-out 1; }
@keyframes focusPulse {
  0%, 100% { background: var(--panel); }
  25%, 60% { background: rgba(184,117,3,.16); }
}

@media (max-width: 700px) {
  .alert-bar button { min-height: 44px; padding: 8px 14px; }
  .alert-bar .alert-x { min-width: 48px; font-size: 22px; }
}

/* ============================================================================
   BOTONES: texto centrado en altura y alturas que no colapsan
   ------------------------------------------------------------------------
   `.btn-primary { flex: 1 }` dentro de un contenedor en columna hacía que la
   base fuera 0 y el botón quedara delgadísimo (el caso de "Continuar").
   Ahora los botones no encogen por defecto y solo se reparten el ancho donde
   están en fila.
   ========================================================================= */

button {
  display: inline-flex; align-items: center; justify-content: center;
  line-height: 1.2; text-align: center;
}

.btn-primary, .btn-ghost {
  flex: 0 0 auto; height: auto; min-height: 58px; padding: 14px 20px;
}
.photo-actions .btn-primary, .photo-actions .btn-ghost,
.pf-actions .btn-primary,   .pf-actions .btn-ghost { flex: 1 1 0; }

.btn-ghost.sm { min-height: 42px; padding: 8px 16px; }

.login-form .btn-primary { min-height: 68px; font-size: 19px; margin-top: 4px; }
.pin-foot .btn-primary   { min-height: 64px; }
.view .btn-primary       { width: 100%; }

/* Selector de idioma en la pantalla de acceso */
.login-foot { flex-wrap: wrap; gap: 10px; }
.seg-sm { flex: 1; gap: 6px; }
.seg-sm button {
  flex: 1 1 0; min-width: 0; height: 46px; min-height: 46px; font-size: 14px;
  padding: 0 8px; border-radius: 9px;
}
.seg-sm .btn-theme {
  flex: 0 0 46px; width: 46px; height: 46px; min-height: 46px; border-radius: 50%;
  font-size: 15px; padding: 0;
}
#loginSede:empty { display: none; }

/* ============================================================================
   VISOR DE EVIDENCIA, MINIATURAS Y AJUSTES FINOS DE ALINEACIÓN
   ========================================================================= */

/* Todo lo que parece botón se centra en altura, aunque no sea <button> */
.sede-card .go, .task-sign i, .task-sign span, .kpi, .lrow-count {
  display: flex; align-items: center; justify-content: center;
}
.sede-card .go { min-height: 50px; }
.task-sign i, .task-sign span { justify-content: flex-start; }

/* La tarea que exige foto lo indica en el propio botón de marcar */
.chk.needs-photo::before {
  content: ''; position: absolute; top: -2px; right: -2px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--amber); border: 2px solid var(--panel);
}
.chk { position: relative; }

/* Miniatura pulsable */
.thumb-wrap {
  display: block; position: relative; margin: 14px auto 0; padding: 0;
  max-width: 60%; border-radius: 10px; overflow: hidden; line-height: 0;
}
.thumb-wrap .task-thumb { margin: 0; max-width: 100%; display: block; }
.thumb-zoom {
  position: absolute; right: 8px; bottom: 8px; width: 34px; height: 34px;
  border-radius: 50%; background: rgba(0,0,0,.62); color: #fff; font-size: 16px;
  display: flex; align-items: center; justify-content: center; line-height: 1;
}

/* Visor a pantalla completa */
.viewer { background: rgba(0,0,0,.9); padding: 0; }
.viewer-box {
  width: 100%; height: 100%; display: flex; flex-direction: column;
  padding: calc(10px + var(--sat)) calc(10px + var(--sar))
           calc(10px + var(--sab)) calc(10px + var(--sal));
}
.viewer-head {
  display: flex; align-items: center; gap: 12px; color: #fff;
  padding: 6px 8px 12px; flex: 0 0 auto;
}
.viewer-head b { flex: 1; min-width: 0; font-size: 15px; font-weight: 600; }
.viewer-head .ic { color: #fff; font-size: 24px; width: 46px; height: 46px; border-radius: 50%; background: rgba(255,255,255,.14); }
.viewer img {
  flex: 1; min-height: 0; width: 100%; object-fit: contain; border-radius: 8px;
}

@media (max-width: 700px) {
  .thumb-wrap { max-width: 100%; }
}

@media (max-width: 700px) {
  .tb-date .sync-inline { display: inline; }
  .tb-date .sync-inline.is-ok  { color: var(--green); font-weight: 600; }
  .tb-date .sync-inline.is-err { color: var(--red);   font-weight: 600; }
}
.sync-inline { display: none; }
