:root{
  --bg:#0d0d0d; --surface:#141414; --surface-2:#1c1c1c; --surface-3:#222020;
  --text:#f0ece0; --muted:#8a857d; --muted-2:#55524d;
  --yellow:#ffc501; --yellow-dim:#b08a00;
  --ok:#34d399; --ok-dim:#7fe0bb; --err:#ff5757; --err-dim:rgba(255,87,87,.5);
  --stroke:color-mix(in srgb,#ffc501 18%,transparent);
  --stroke-soft:rgba(255,255,255,.07);
  --font-body:'Space Grotesk',system-ui,sans-serif;
  --font-head:'Allerta Stencil','Space Grotesk',sans-serif;
  --font-mono:ui-monospace,'JetBrains Mono','SF Mono',monospace;
  --b:2px; --r:2px;
}
*{box-sizing:border-box;}
html,body{margin:0;height:100%;}
body{
  font-family:var(--font-body); color:var(--text);
  -webkit-font-smoothing:antialiased;
  background:
    radial-gradient(1200px 700px at 50% -10%, rgba(255,197,1,.05), transparent 60%),
    #0a0a0a;
  min-height:100vh; display:flex; flex-direction:column; align-items:center; justify-content:center;
  gap:22px; padding:32px;
}
.stagewrap{ display:flex; flex-direction:column; align-items:center; gap:20px; }
.phone{
  width:392px; height:812px; background:#000; border:1px solid #2a2a2a; border-radius:46px;
  padding:11px; box-shadow:0 24px 60px -18px rgba(0,0,0,.8), 0 0 0 1px rgba(255,255,255,.02) inset; flex:none;
}
.screen{ position:relative; width:100%; height:100%; border-radius:36px; overflow:hidden; background:var(--bg); }

.estiba{
  position:absolute; inset:0; background:var(--bg); color:var(--text);
  font-family:var(--font-body); font-size:15px; line-height:1.5; letter-spacing:.01em;
  display:flex; flex-direction:column; overflow:hidden;
}
.estiba::before{
  content:''; position:absolute; inset:0; pointer-events:none; z-index:0; opacity:.03;
  background-image:url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size:180px 180px;
}
.estiba>*{ position:relative; z-index:1; }

/* status bar */
.sbar{ height:46px; flex-shrink:0; display:flex; align-items:flex-end; justify-content:space-between; padding:0 26px 7px; font-size:14px; font-weight:600; letter-spacing:.02em; font-variant-numeric:tabular-nums; }
.sbar-right{ display:flex; align-items:center; gap:7px; }
.sig{ display:flex; align-items:flex-end; gap:2px; height:11px; }
.sig i{ width:3px; background:var(--text); border-radius:1px; }
.sig i:nth-child(1){ height:4px; } .sig i:nth-child(2){ height:6px; } .sig i:nth-child(3){ height:8px; } .sig i:nth-child(4){ height:11px; }
.wifi{ width:15px; height:11px; position:relative; }
.wifi::before{ content:''; position:absolute; inset:0; border-radius:50% 50% 0 0; border:2px solid var(--text); border-bottom:none; clip-path:polygon(50% 40%,0 0,100% 0); }
.wifi::after{ content:''; position:absolute; left:6px; bottom:0; width:3px; height:3px; border-radius:50%; background:var(--text); }
.batt{ width:24px; height:12px; border:1.5px solid var(--text); border-radius:3px; position:relative; padding:1.5px; }
.batt::after{ content:''; position:absolute; right:-3px; top:3px; width:2px; height:4px; background:var(--text); border-radius:0 1px 1px 0; }
.batt i{ display:block; height:100%; width:78%; background:var(--text); border-radius:1px; }

/* ===== STAGE LAYERS ===== */
.layer{ position:absolute; inset:0; display:flex; flex-direction:column; opacity:0; visibility:hidden; transition:opacity .5s ease, visibility .5s; z-index:1; transform-origin:center center; }
.layer.show{ opacity:1; visibility:visible; }
/* zoom-through-the-centre transition */
.layer.zoom-out{ visibility:visible; opacity:1; z-index:3; animation:zthruOut .7s cubic-bezier(.55,0,.45,1) forwards; }
.layer.zoom-in{ visibility:visible; z-index:2; animation:zthruIn .7s cubic-bezier(.2,.6,.3,1) forwards; }
@keyframes zthruOut{ 0%{ transform:scale(1); opacity:1; } 100%{ transform:scale(5); opacity:0; } }
@keyframes zthruIn{ 0%{ transform:scale(.3); opacity:0; } 55%{ opacity:1; } 100%{ transform:scale(1); opacity:1; } }
.layer.show .arranque-box{ animation:apop .5s cubic-bezier(.34,1.4,.64,1); }
@keyframes apop{ 0%{ transform:scale(.82); opacity:.3; } 100%{ transform:scale(1); opacity:1; } }

/* ---- LOGIN ---- */
.login-body{ flex:1; display:flex; align-items:center; justify-content:center; padding:30px 26px; }
.login-card{
  width:100%; background:var(--surface); border:var(--b) solid var(--yellow);
  box-shadow:-5px 5px 0 0 var(--yellow); padding:30px 24px 26px;
  transform-origin:center center; transition:transform .85s cubic-bezier(.7,0,.2,1), opacity .7s ease;
}
.login-card.shake{ animation:shake .42s cubic-bezier(.36,.07,.19,.97); }
@keyframes shake{ 10%,90%{transform:translateX(-2px);} 20%,80%{transform:translateX(4px);} 30%,50%,70%{transform:translateX(-7px);} 40%,60%{transform:translateX(7px);} }
.login-brand-title{ font-family:var(--font-body); font-weight:700; font-size:30px; letter-spacing:.04em; color:var(--text); margin-bottom:4px; }
.login-brand-sub{ font-size:10px; font-weight:700; letter-spacing:.32em; text-transform:uppercase; color:var(--yellow); margin-bottom:26px; }
.field{ margin-bottom:16px; }
.field-label{ display:block; font-size:10px; font-weight:700; letter-spacing:.2em; text-transform:uppercase; color:var(--muted); margin-bottom:7px; }
.field-input{
  width:100%; height:48px; background:var(--bg); border:var(--b) solid var(--stroke-soft); border-radius:var(--r);
  color:var(--text); font-family:var(--font-mono); font-size:16px; letter-spacing:.12em; padding:0 14px; outline:none;
  transition:border-color .15s ease;
}
.field-input::placeholder{ color:var(--muted-2); letter-spacing:.12em; }
.field-input:focus{ border-color:var(--yellow); }
.field.error .field-input{ border-color:var(--err); }
.field-err{ min-height:16px; margin:-6px 0 10px; font-size:11px; font-weight:600; letter-spacing:.02em; color:var(--err); }
.remember{ display:flex; align-items:center; gap:9px; margin:4px 0 22px; font-size:12px; color:var(--muted); letter-spacing:.02em; cursor:pointer; user-select:none; }
.check-box{ width:18px; height:18px; border:var(--b) solid var(--stroke-soft); border-radius:var(--r); display:flex; align-items:center; justify-content:center; background:var(--yellow); flex-shrink:0; transition:background .15s ease, border-color .15s ease; }
.check-box.off{ background:transparent; border-color:var(--stroke-soft); }
.check-box.off svg{ opacity:0; }
.btn-primary{
  width:100%; min-height:52px; background:var(--yellow); color:#0d0d0d; border:2px solid #000; border-radius:var(--r);
  box-shadow:4px 4px 0 0 #000; font-size:13px; font-weight:700; letter-spacing:.24em; text-transform:uppercase; cursor:pointer;
  display:flex; align-items:center; justify-content:center; gap:9px;
  transition:transform .08s ease, box-shadow .08s ease;
}
.btn-primary:active{ transform:translate(2px,2px); box-shadow:2px 2px 0 0 #000; }
.btn-primary[disabled]{ cursor:default; opacity:.92; }
.btn-primary .spin{ width:15px; height:15px; border:2px solid rgba(0,0,0,.35); border-top-color:#0d0d0d; border-radius:50%; animation:rot .7s linear infinite; display:none; }
.btn-primary.loading .spin{ display:block; }
@keyframes rot{ to{ transform:rotate(360deg); } }

/* shrink animation applied to login-card */
.login-card.collapsing{ transform:scale(.18) translateY(-160px); opacity:0; }

/* split-flap heading */
.login-head{ display:flex; justify-content:center; min-height:34px; margin-bottom:24px; font-family:var(--font-mono); font-weight:700; font-size:26px; letter-spacing:.06em; color:var(--text); }
.arranque-box{
  background:var(--surface); border:var(--b) solid var(--yellow); box-shadow:-5px 5px 0 0 var(--yellow);
  padding:26px 30px 24px; display:flex; flex-direction:column; align-items:center;
}
.flap{ display:flex; justify-content:center; gap:2px; min-height:34px; margin-bottom:24px; font-family:var(--font-mono); font-weight:700; font-size:26px; letter-spacing:.04em; color:var(--text); }
.flap-ch{ display:inline-block; min-width:.64em; text-align:center; }
.flap-ch.cycling{ color:var(--yellow); }
.flap-ch.settle{ animation:flip .26s cubic-bezier(.3,.9,.4,1); }
@keyframes flip{ 0%{ transform:rotateX(-82deg); opacity:.4; } 100%{ transform:none; opacity:1; } }

/* ---- SPLASH (arranque) ---- */
.loader-phrase{ display:inline-flex; align-items:center; gap:9px; font-size:13px; color:var(--text); letter-spacing:.02em; min-height:20px; opacity:0; }
.layer.show .loader-phrase{ animation:fin .5s ease .55s forwards; }
.loader-phrase::before{ content:''; width:9px; height:9px; border-radius:50%; background:var(--yellow); box-shadow:0 0 8px rgba(255,197,1,.85); animation:ping 1.1s ease-in-out infinite; flex-shrink:0; }
.bar-track{ width:184px; height:3px; background:var(--surface-2); border-radius:2px; margin-top:18px; overflow:hidden; position:relative; opacity:0; }
.layer.show .bar-track{ animation:fin .5s ease .55s forwards; }
.bar-fill{ position:absolute; top:0; bottom:0; width:38%; background:var(--yellow); border-radius:2px; animation:slide 1.5s ease-in-out infinite; }
@keyframes slide{ 0%{left:-40%;} 100%{left:100%;} }
@keyframes fin{ to{ opacity:1; } }
@keyframes ping{ 0%,100%{opacity:1;} 50%{opacity:.45;} }

/* ---- TOPBAR (shared by sync + index) ---- */
/* padding-top respeta el area segura del iPhone (notch/status bar) con
   viewport-fit=cover, igual que index; en escritorio env() es 0. */
.topbar{ display:flex; align-items:center; gap:8px; padding:calc(11px + env(safe-area-inset-top, 0px)) 14px 11px; background:rgba(13,13,13,.94); border-bottom:var(--b) solid var(--stroke); flex-shrink:0; }
.brand-mark{ font-family:var(--font-body); font-weight:700; font-size:14px; letter-spacing:.26em; color:var(--yellow); text-transform:uppercase; margin-right:auto; white-space:nowrap; line-height:1; }
.actions{ display:flex; align-items:center; gap:7px; }
.btn-icon{ flex:0 0 auto; position:relative; display:inline-flex; align-items:center; justify-content:center; width:36px; height:36px; background:var(--surface-2); border:var(--b) solid var(--stroke-soft); border-radius:var(--r); color:var(--muted); cursor:pointer; transition:border-color .15s ease, color .15s ease; }
.btn-icon:hover{ border-color:var(--yellow); color:var(--text); }
.btn-icon.danger:hover{ border-color:var(--err); color:var(--err); }
.btn-icon svg{ width:16px; height:16px; }
.btn-icon.spinning svg{ animation:rot .8s linear infinite; }
.btn-icon .badge{ position:absolute; top:-4px; right:-4px; min-width:14px; height:14px; padding:0 3px; display:flex; align-items:center; justify-content:center; background:var(--yellow); color:#0d0d0d; font-size:8.5px; font-weight:700; border-radius:7px; border:1.5px solid var(--bg); line-height:1; font-variant-numeric:tabular-nums; }

.conn-line{ display:flex; align-items:center; gap:8px; padding:7px 16px; flex-shrink:0; background:var(--surface); border-bottom:1px solid var(--stroke-soft); font-size:10.5px; font-weight:600; letter-spacing:.14em; text-transform:uppercase; color:var(--muted); font-variant-numeric:tabular-nums; }
.conn-line .when{ margin-left:auto; color:var(--muted-2); letter-spacing:.1em; }
.conn-line.warn{ background:rgba(255,197,1,.05); color:var(--yellow-dim); }
.cdot{ width:7px; height:7px; border-radius:50%; flex-shrink:0; background:var(--ok); box-shadow:0 0 8px rgba(52,211,153,.85); animation:cpulse 2.2s ease-in-out infinite; }
.cdot.warn{ background:var(--yellow); box-shadow:0 0 10px 1px rgba(255,197,1,.95); animation:cpulseW 1.6s ease-in-out infinite; }
@keyframes cpulse{ 0%,100%{box-shadow:0 0 8px 0 rgba(52,211,153,.85),0 0 0 0 rgba(52,211,153,.5);} 50%{box-shadow:0 0 10px 1px rgba(52,211,153,1),0 0 0 5px rgba(52,211,153,0);} }
@keyframes cpulseW{ 0%,100%{box-shadow:0 0 10px 1px rgba(255,197,1,.95),0 0 0 0 rgba(255,197,1,.6);} 50%{box-shadow:0 0 14px 3px rgba(255,197,1,1),0 0 0 6px rgba(255,197,1,0);} }

.body{ flex:1; padding:20px 14px 24px; overflow:hidden; }

/* skeleton */
.sk{ position:relative; overflow:hidden; border-radius:var(--r); background:linear-gradient(90deg,var(--surface-2) 0%,#3a3530 45%,#46403a 50%,#3a3530 55%,var(--surface-2) 100%); background-size:200% 100%; animation:shimmer 1.3s ease-in-out infinite; }
@keyframes shimmer{ 0%{background-position:200% 0;} 100%{background-position:-200% 0;} }
.wait-msg{ margin:2px 0 20px; padding:12px 14px; border:1px solid var(--stroke-soft); border-radius:var(--r); background:var(--surface-2); font-size:11px; color:var(--muted); }
.wait-badge{ display:inline-flex; align-items:center; gap:5px; color:var(--yellow); font-size:9px; font-weight:700; letter-spacing:.18em; text-transform:uppercase; margin-bottom:5px; }
.wait-badge::before{ content:''; width:6px; height:6px; border-radius:50%; background:currentColor; animation:ping 1.2s ease-in-out infinite; }
.wait-body{ display:block; line-height:1.45; }

/* censo (turnos por especialidad) */
.censo-block{ margin-bottom:12px; }
.censo-head{ display:flex; align-items:center; justify-content:space-between; padding:0 2px 9px; }
.censo-esp{ font-size:12px; font-weight:700; letter-spacing:.2em; text-transform:uppercase; color:var(--text); display:flex; align-items:center; gap:8px; }
.censo-esp::before{ content:''; width:5px; height:5px; background:var(--yellow); border-radius:50%; flex-shrink:0; }
.censo-total{ font-size:10px; font-weight:700; letter-spacing:.16em; text-transform:uppercase; color:var(--muted); font-variant-numeric:tabular-nums; }
.censo-total b{ color:var(--text); margin-left:5px; }
.censo-grid{ display:grid; grid-template-columns:repeat(4,1fr); gap:7px; }
.censo-cell{ position:relative; background:var(--surface); border:var(--b) solid var(--stroke-soft); border-radius:var(--r); padding:9px 5px 11px; text-align:center; overflow:hidden; box-shadow:3px 3px 0 0 #000; }
.censo-cell::after{ content:''; position:absolute; left:0; top:0; bottom:0; width:3px; background:var(--yellow); }
.censo-k{ font-size:8px; font-weight:700; letter-spacing:.08em; text-transform:uppercase; color:var(--muted); margin-bottom:5px; white-space:nowrap; }
.censo-v{ font-size:25px; font-weight:700; color:var(--yellow); font-variant-numeric:tabular-nums; line-height:1; letter-spacing:-.02em; }
.censo-sub{ font-size:7.5px; font-weight:700; letter-spacing:.06em; text-transform:uppercase; color:var(--muted-2); margin-top:4px; }
.sk-name{ height:9px; width:60%; margin:1px auto 10px; } .sk-num{ height:26px; width:54%; margin:0 auto; }
.censo-cell.sk-cell::after{ background:var(--muted-2); }
.censo-esp.sk-esp::before{ background:var(--muted-2); }

/* parte card */
.parte-card{ position:relative; background:var(--surface); border:var(--b) solid var(--yellow); margin:4px 0 20px; overflow:hidden; box-shadow:-4px 4px 0 0 var(--yellow); }
.parte-head{ background:var(--surface-2); padding:11px 18px; border-bottom:var(--b) solid var(--stroke); display:flex; align-items:center; justify-content:space-between; gap:10px; }
.parte-head-date{ font-size:12px; font-weight:600; letter-spacing:.18em; text-transform:uppercase; color:var(--text); }
.parte-pill{ display:inline-flex; align-items:center; gap:4px; background:var(--yellow); color:#000; padding:4px 10px; border-radius:var(--r); font-size:10.5px; font-weight:700; letter-spacing:.16em; text-transform:uppercase; white-space:nowrap; }
.op-hero{ padding:22px 0 20px; text-align:center; }
.op-line1{ font-family:var(--font-head); font-size:30px; letter-spacing:.04em; text-transform:uppercase; color:var(--text); line-height:1.1; margin-bottom:8px; white-space:nowrap; overflow:hidden; }
.op-line1 .sep{ color:var(--muted-2); margin:0 7px; font-weight:300; }
.op-line1 .op-vessel{ color:var(--muted); }
.op-line2{ font-size:17px; font-weight:600; letter-spacing:.14em; text-transform:uppercase; color:var(--text); }
.op-line2 .sep{ color:var(--muted-2); margin:0 8px; } .op-line2 .esp{ color:var(--yellow); }
.colla-head{ background:var(--surface-2); padding:8px 18px; font-size:11px; letter-spacing:.24em; text-transform:uppercase; color:var(--text); font-weight:700; border-top:1px solid var(--stroke-soft); display:flex; align-items:center; justify-content:space-between; }

/* desplegables */
.drop-row{ display:flex; align-items:center; justify-content:space-between; width:100%; padding:12px 14px; margin:0 0 16px; background:var(--surface); border:var(--b) solid var(--stroke-soft); border-radius:var(--r); color:var(--text); font-size:11px; font-weight:700; letter-spacing:.18em; text-transform:uppercase; cursor:pointer; box-shadow:3px 3px 0 0 #000; transition:border-color .15s ease; }
.drop-row:hover{ border-color:var(--yellow); }
.drop-row .chev{ width:16px; height:16px; color:var(--muted); flex-shrink:0; transition:transform .25s ease; }
.drop-row.open .chev{ transform:rotate(90deg); }

/* colla crew lists */
.crew-group{ border-bottom:1px solid var(--stroke-soft); padding:11px 16px; }
.crew-group:last-child{ border-bottom:none; }
.crew-esp{ font-size:10px; font-weight:700; letter-spacing:.2em; text-transform:uppercase; color:var(--muted); padding-bottom:7px; display:flex; align-items:center; gap:7px; }
.crew-esp::before{ content:''; width:4px; height:4px; background:var(--muted-2); border-radius:50%; flex-shrink:0; }
.crew-list{ display:grid; gap:2px; }
.crew-item{ display:flex; align-items:center; gap:8px; padding:6px 9px; border-radius:var(--r); font-size:12.5px; font-weight:600; color:var(--text); line-height:1.3; border:1px solid transparent; }
.crew-item .cid{ color:inherit; font-variant-numeric:tabular-nums; flex-shrink:0; }
.crew-item.app{ color:var(--ok-dim); }
.crew-item.me{ background:rgba(52,211,153,.12); border-color:rgba(52,211,153,.4); color:var(--ok); }
.crew-tag{ margin-left:auto; font-size:9px; font-weight:700; letter-spacing:.14em; color:var(--ok); border:1px solid rgba(52,211,153,.45); border-radius:var(--r); padding:1px 5px; flex-shrink:0; }

/* máquinas de patio */
.maquinas{ border-top:var(--b) solid var(--stroke); background:var(--surface-2); }
.maquinas-summary{ display:flex; align-items:center; justify-content:space-between; padding:11px 16px; font-size:11px; font-weight:700; letter-spacing:.18em; text-transform:uppercase; color:var(--yellow); cursor:pointer; }
.maquinas-summary .chev{ width:15px; height:15px; }

/* index content reveal */
.reveal{ opacity:0; transform:translateY(10px); }
.layer.show .reveal{ animation:rise .55s cubic-bezier(.2,.7,.3,1) forwards; }
.layer.show .reveal.d1{ animation-delay:.05s; } .layer.show .reveal.d2{ animation-delay:.15s; }
@keyframes rise{ to{ opacity:1; transform:none; } }

@media (prefers-reduced-motion:reduce){ *{ animation-duration:.001s !important; } }
