/* ═══════════════════════════════════════════════════════════════════════
   CIERRE IDC v4 — TEMA (espejo de apps/mobile/lib/src/app.dart)
   Tokens 1:1 con el ThemeData de la APK Flutter. Móvil-first (marco phone).
   ═══════════════════════════════════════════════════════════════════════ */
:root {
  /* colores base (app.dart) */
  --bg:        #080B10;   /* background */
  --panel:     #111821;   /* panel / cards */
  --panel-2:   #151D28;   /* chip bg / elevated */
  --line:      #293241;   /* borders */
  --text:      #F8FAFC;
  --muted:     #9FB0C6;
  --green:     #22C55E;   /* success / OK */
  --info:      #38BDF8;   /* secondary */
  --warn:      #F59E0B;   /* ámbar */
  --error:     #EF4444;
  --intel:     #A78BFA;   /* morado inteligencia */
  --gold:      #E4B968;   /* dorado ESAV91 (acento marca) */
  --gold-deep: #D4AF37;

  /* semáforo TR / gates */
  --sem-green: var(--green);
  --sem-amber: var(--warn);
  --sem-red:   var(--error);

  /* radios / sombras / espaciado */
  --r-sm: 8px; --r-md: 12px; --r-lg: 18px; --r-pill: 999px;
  --pad: 16px;
  --shadow: 0 10px 40px rgba(0,0,0,.45);
  --font: 'Inter', -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: 'JetBrains Mono', 'SF Mono', Consolas, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background:
    radial-gradient(1200px 600px at 50% -10%, #0e1621 0%, #05070b 60%) fixed;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  display: flex; align-items: center; justify-content: center;
  gap: 24px; padding: 24px; min-height: 100%;
}

/* ── marco de teléfono ── */
.phone {
  width: 412px; max-width: 100%;
  height: 860px; max-height: calc(100vh - 48px);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 34px;
  box-shadow: var(--shadow), 0 0 0 10px #05070b, 0 0 0 11px #1b2430;
  overflow: hidden;
  display: flex; flex-direction: column;
  position: relative;
}
.phone__notch {
  position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 150px; height: 26px; background: #05070b;
  border-radius: 0 0 16px 16px; z-index: 40;
}

/* ── header del ticket ── */
.hdr {
  padding: 34px 16px 12px; border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #0c1320, var(--bg));
  flex: 0 0 auto;
}
.hdr__top { display: flex; align-items: center; justify-content: space-between; }
.hdr__ticket { font-weight: 700; font-size: 15px; letter-spacing: .2px; }
.hdr__meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.hdr__clock {
  font-family: var(--mono); font-size: 13px; color: var(--gold);
  background: var(--panel-2); border: 1px solid var(--line);
  padding: 4px 10px; border-radius: var(--r-pill);
}

/* ── stepper (progreso derivado de gates) ── */
.stepper { display: flex; gap: 6px; padding: 12px 16px 4px; flex: 0 0 auto; }
.step { flex: 1; display: flex; flex-direction: column; gap: 6px; align-items: center; }
.step__bar { height: 4px; width: 100%; border-radius: 999px; background: var(--line); transition: background .25s; }
.step.is-done  .step__bar { background: var(--green); }
.step.is-cur   .step__bar { background: var(--gold); }
.step__label { font-size: 10px; color: var(--muted); text-align: center; line-height: 1.1; }
.step.is-cur  .step__label { color: var(--gold); font-weight: 600; }
.step.is-done .step__label { color: var(--text); }

/* ── cuerpo (mount de un módulo por pantalla) ── */
.body { flex: 1 1 auto; overflow-y: auto; overflow-x: hidden; padding: 12px 16px 20px; }
.body::-webkit-scrollbar { width: 6px; }
.body::-webkit-scrollbar-thumb { background: var(--line); border-radius: 999px; }

/* ── footer nav ── */
.nav { flex: 0 0 auto; display: flex; gap: 10px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--panel); }
.nav .spacer { flex: 1; }

/* ═══ componentes reutilizables (que los módulos deben usar) ═══ */
.m-title { font-size: 17px; font-weight: 700; margin: 2px 0 2px; }
.m-sub   { font-size: 12.5px; color: var(--muted); margin-bottom: 14px; line-height: 1.4; }

.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: 14px; margin-bottom: 12px;
}
.card__title { font-size: 13px; font-weight: 600; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.card__title .req { color: var(--error); font-size: 11px; }

label.fld { display: block; font-size: 12px; color: var(--muted); margin: 10px 0 5px; }
.input, select.input, textarea.input {
  width: 100%; background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 11px 12px; font-size: 14px; font-family: var(--font);
}
.input:focus, select.input:focus, textarea.input:focus { outline: none; border-color: var(--gold); }
.input:disabled, select.input:disabled { opacity: .5; }
textarea.input { resize: vertical; min-height: 68px; }

/* botones */
.btn {
  appearance: none; border: 1px solid var(--line); background: var(--panel-2);
  color: var(--text); font-family: var(--font); font-size: 14px; font-weight: 600;
  padding: 12px 16px; border-radius: var(--r-sm); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform .05s, background .15s, border-color .15s;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn--primary { background: var(--gold); color: #080B10; border-color: var(--gold); }
.btn--ghost   { background: transparent; }
.btn--danger  { background: transparent; color: var(--error); border-color: #4a2230; }
.btn--ok      { background: transparent; color: var(--green); border-color: #1f3d2c; }
.btn--block   { width: 100%; }
.btn--sm      { padding: 8px 12px; font-size: 12.5px; }

/* chips / badges */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: var(--r-pill); padding: 5px 11px; font-size: 12px; color: var(--muted);
}
.chip--ok    { color: var(--green);  border-color: #1f3d2c; background: #0f1f16; }
.chip--warn  { color: var(--warn);   border-color: #4a3a12; background: #1e1707; }
.chip--red   { color: var(--error);  border-color: #4a2230; background: #1e0d10; }
.chip--intel { color: var(--intel);  border-color: #322a52; background: #14101f; }
.chip--gold  { color: var(--gold);   border-color: #4a3d1a; background: #1c1707; }
.chip--ro::after { content: '🔒'; font-size: 9px; opacity: .6; } /* read-only (derivado) */

/* semáforo pill (TR) */
.sem { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; }
.sem__dot { width: 9px; height: 9px; border-radius: 50%; }
.sem--verde .sem__dot { background: var(--sem-green); } .sem--verde { color: var(--sem-green); }
.sem--ambar .sem__dot { background: var(--sem-amber); } .sem--ambar { color: var(--sem-amber); }
.sem--rojo  .sem__dot { background: var(--sem-red);   } .sem--rojo  { color: var(--sem-red); }

/* barra de progreso genérica (TR / SLA) */
.bar { height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; }
.bar__fill { height: 100%; border-radius: 999px; transition: width .3s, background .3s; }

/* lista de faltantes de gate */
.missing { list-style: none; font-size: 12px; color: var(--warn); margin-top: 8px; }
.missing li { padding: 3px 0 3px 18px; position: relative; }
.missing li::before { content: '•'; position: absolute; left: 4px; color: var(--warn); }

/* mini KPIs / ventanas */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kpi { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 10px; }
.kpi__k { font-size: 11px; color: var(--muted); } .kpi__v { font-size: 16px; font-weight: 700; margin-top: 2px; }
.kpi__v.mono { font-family: var(--mono); }

/* toggles segmentados (sí/no) */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; }
.seg button { border: none; background: var(--bg); color: var(--muted); padding: 9px 16px; font-size: 13px; cursor: pointer; font-family: var(--font); }
.seg button.on { background: var(--gold); color: #080B10; font-weight: 700; }
.seg button.on-no { background: var(--error); color: #fff; font-weight: 700; }

/* toast */
.toast { position: absolute; left: 50%; bottom: 88px; transform: translateX(-50%); z-index: 60;
  background: #0d1420; border: 1px solid var(--line); color: var(--text);
  padding: 10px 16px; border-radius: var(--r-pill); font-size: 13px; box-shadow: var(--shadow);
  opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }
.toast--ok  { border-color: #1f3d2c; } .toast--err { border-color: #4a2230; }

/* ── panel Diseño (contrato de datos en vivo) ── */
.designbtn {
  position: absolute; top: 34px; right: 14px; z-index: 45;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--intel);
  border-radius: var(--r-pill); padding: 4px 10px; font-size: 11px; cursor: pointer;
}
.designpanel {
  position: absolute; inset: 0; z-index: 50; background: rgba(5,7,11,.96);
  transform: translateY(100%); transition: transform .28s; display: flex; flex-direction: column;
}
.designpanel.open { transform: translateY(0); }
.designpanel__hd { padding: 34px 16px 10px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.designpanel__body { flex: 1; overflow: auto; padding: 14px 16px; }
.designpanel pre { font-family: var(--mono); font-size: 11px; color: #cbd5e1; white-space: pre-wrap; word-break: break-word; }
.dp-sec { color: var(--gold); font-size: 12px; font-weight: 700; margin: 14px 0 6px; }

/* desktop: mostrar plano al lado */
.legend { max-width: 320px; color: var(--muted); font-size: 13px; line-height: 1.55; }
.legend h1 { color: var(--text); font-size: 18px; margin-bottom: 10px; }
.legend code { font-family: var(--mono); color: var(--gold); font-size: 12px; }
/* ── CELULAR / PWA: la app va a PANTALLA COMPLETA (sin marco de teléfono) ── */
@media (max-width: 820px) {
  .legend { display: none; }
  body { padding: 0; gap: 0; align-items: stretch; justify-content: stretch; }
  .phone {
    width: 100vw; max-width: 100vw;
    height: 100vh; height: 100dvh; max-height: none;
    border: none; border-radius: 0;
    box-shadow: none;
  }
  .phone__notch { display: none; }
}
/* Modo instalado (PWA standalone): full-bleed en cualquier tamaño. */
@media (display-mode: standalone) {
  .legend { display: none; }
  body { padding: 0; gap: 0; align-items: stretch; justify-content: stretch; }
  .phone {
    width: 100vw; max-width: 100vw;
    height: 100vh; height: 100dvh; max-height: none;
    border: none; border-radius: 0; box-shadow: none;
  }
  .phone__notch { display: none; }
}
