/* Panel del taller. Criterios de diseño, en orden de importancia:
   1. Se usa DE PIE, con guantes y a veces con sol de frente → objetivos táctiles grandes
      (mínimo 48px), contraste alto, tipografía gorda. Nada de iconos sin etiqueta.
   2. Sustituye la ORDEN DE TRABAJO EN PAPEL: la lista de cortes tiene que leerse de un vistazo
      y salir bien impresa. Por eso hay un @media print de verdad, no un adorno.
   3. Estado de conexión SIEMPRE visible: si el trabajador no sabe que está offline, no confía. */

:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --ink: #0f172a;
  --ink-soft: #475569;
  --line: #cbd5e1;
  --accent: #0f4c81;
  --accent-ink: #ffffff;
  --ok: #15803d;
  --warn: #b45309;
  --danger: #b91c1c;
  --radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1220;
    --surface: #16202f;
    --ink: #e8eef7;
    --ink-soft: #9fb0c6;
    --line: #2b3a4f;
    --accent: #4c9be8;
    --accent-ink: #06121f;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
  padding-bottom: env(safe-area-inset-bottom);
}

.hidden { display: none !important; }
.view { padding: 16px; max-width: 900px; margin: 0 auto; }
.sub { color: var(--ink-soft); font-size: 14px; margin: 2px 0 0; }
h1, h2, h3 { margin: 0 0 4px; line-height: 1.2; }

/* barras de estado */
.bar {
  position: sticky; top: 0; z-index: 20;
  padding: 10px 16px; font-weight: 600; font-size: 15px;
  background: var(--warn); color: #fff; text-align: center;
}
.bar-pending { background: var(--accent); color: var(--accent-ink); }

.top {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 14px;
}
.top-actions { display: flex; gap: 8px; }

/* botones — 48px mínimo, se usan con guantes */
.btn {
  min-height: 48px; padding: 12px 18px;
  font: inherit; font-weight: 600;
  border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--surface); color: var(--ink);
  cursor: pointer;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn-ghost { background: transparent; }
.btn-lg { width: 100%; font-size: 18px; margin-top: 18px; }

/* listas */
.list { display: grid; gap: 12px; }

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px;
  cursor: pointer;
}
.card h3 { font-size: 19px; }
.card-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }

.chip {
  display: inline-block; padding: 6px 12px; border-radius: 999px;
  font-size: 14px; font-weight: 700; white-space: nowrap;
  background: var(--bg); border: 1px solid var(--line); color: var(--ink-soft);
}
.chip-stage { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.chip-done { background: var(--ok); color: #fff; border-color: transparent; }
.chip-blocked { background: var(--danger); color: #fff; border-color: transparent; }
.chip-pending { background: transparent; }

.progress { height: 8px; background: var(--bg); border-radius: 999px; overflow: hidden; margin-top: 10px; border: 1px solid var(--line); }
.progress > i { display: block; height: 100%; background: var(--ok); }

/* login */
.login-card {
  max-width: 380px; margin: 12vh auto 0; padding: 28px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
label { display: block; margin: 16px 0 6px; font-weight: 600; font-size: 15px; }
input, select {
  width: 100%; min-height: 48px; padding: 12px 14px; font: inherit;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--bg); color: var(--ink);
}
.error { color: var(--danger); font-weight: 600; margin-top: 12px; }

/* cortes — la tabla es el corazón del panel */
.cuts { width: 100%; border-collapse: collapse; margin-top: 10px; }
.cuts th, .cuts td { padding: 10px 8px; border-bottom: 1px solid var(--line); text-align: left; }
.cuts th { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-soft); }
.cuts td.num { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 19px; }
.scroll-x { overflow-x: auto; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }

/* diálogos */
dialog {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--ink);
  padding: 22px; width: min(440px, 92vw);
}
dialog::backdrop { background: rgba(0,0,0,.5); }
.dlg-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }
.stage-options { display: grid; gap: 10px; margin-top: 12px; }
.stage-options .btn { width: 100%; text-align: left; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 14px 20px;
  border-radius: var(--radius); font-weight: 600; z-index: 50; max-width: 90vw;
}

.empty { text-align: center; color: var(--ink-soft); padding: 40px 20px; }

/* IMPRESIÓN — así se genera el PDF sin conexión: no se descarga ningún binario ni se empaqueta
   una librería, lo arma el navegador con los datos que ya están en el dispositivo. */
@media print {
  .bar, .top, .btn, dialog, .toast, #view-login, #view-projects, #view-project { display: none !important; }
  body { background: #fff; color: #000; font-size: 12pt; }
  .view { padding: 0; max-width: none; }
  .panel { border: none; padding: 0; }
  .cuts th, .cuts td { border-bottom: 1px solid #999; }
  .cuts td.num { font-size: 14pt; }
  .chip { border: 1px solid #000; background: #fff !important; color: #000 !important; }
}
