/* SPEED Admin · app del iPhone (pantalla de inicio). Estructura iOS + paleta SPEED. */
:root {
  --bg: #050F1E; --bg2: #061629; --surface: #0B2440; --surface2: #0D3158; --line: rgba(90,166,234,.16);
  --orange: #E67E22; --orange2: #F6A552; --blue: #1A5F9E; --blue2: #5AA6EA;
  --text: #F5F8FC; --muted: #9DB2CC; --red: #FF6B66; --green: #2FD08F; --yellow: #FFC93C;
  --font: -apple-system, "SF Pro Text", Inter, system-ui, sans-serif;
  --st: env(safe-area-inset-top, 0px); --sb: env(safe-area-inset-bottom, 0px);
  --tab: 56px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.4 var(--font); height: 100%;
  -webkit-text-size-adjust: 100%; overscroll-behavior: none; }
body { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
input, .code, code { -webkit-user-select: text; user-select: text; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.center { text-align: center; }
h1 { font-size: 34px; font-weight: 800; letter-spacing: -.8px; margin: 0; line-height: 1.15; }
h2 { font-size: 22px; font-weight: 800; letter-spacing: -.4px; margin: 0 0 4px; }
h3 { margin: 0 0 12px; font-size: 16px; font-weight: 700; }
h3 .sub { color: var(--muted); font-weight: 500; font-size: 13px; }
code { font: 12px ui-monospace, "SF Mono", Menlo, monospace; color: var(--orange2); }

/* ---------- pantallas sueltas (instalar, login) ---------- */
.screen { min-height: 100%; padding: calc(var(--st) + 24px) 20px calc(var(--sb) + 24px);
  background: radial-gradient(900px 520px at 50% -10%, #0D3158 0%, var(--bg) 62%); }
.center-screen { display: grid; place-items: center; }
.install-card, .login-card { width: min(420px, 100%); display: grid; gap: 14px; text-align: center; }
.app-icon { width: 92px; height: 92px; border-radius: 22px; justify-self: center; box-shadow: 0 10px 40px rgba(230,126,34,.35); }
.slogan { color: var(--orange2); font-weight: 700; margin: -6px 0 8px; }
.steps { list-style: none; padding: 16px; margin: 6px 0; display: grid; gap: 16px; text-align: left;
  background: rgba(11,36,64,.85); border: 1px solid var(--line); border-radius: 20px; }
.steps li { display: grid; grid-template-columns: 30px 1fr 30px; align-items: center; gap: 12px; }
.steps .n { width: 30px; height: 30px; border-radius: 50%; background: var(--orange); display: grid; place-items: center; font-weight: 800; }
.steps svg, .tabbar svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.link { background: none; border: 0; color: var(--muted); font: 600 14px var(--font); padding: 10px; }
.error { color: var(--red); min-height: 1.3em; margin: 0; }

/* ---------- campos agrupados (estilo Ajustes de iOS) ---------- */
.group { background: var(--surface); border-radius: 14px; overflow: hidden; margin-bottom: 14px; text-align: left; }
.field { display: flex; align-items: center; gap: 12px; padding: 0 16px; min-height: 50px; }
.field + .field { border-top: 1px solid var(--line); }
.field span { width: 120px; flex: none; font-weight: 600; font-size: 15px; }
.field input { flex: 1; min-width: 0; background: none; border: 0; color: var(--text); font: 16px var(--font); outline: none; padding: 14px 0; text-align: right; }
.field input::placeholder { color: #5D7593; }

/* ---------- botones ---------- */
.btn { border: 0; background: var(--surface2); color: var(--text); font: 700 16px var(--font); padding: 14px 20px;
  border-radius: 14px; transition: transform .1s, opacity .2s; }
.btn:active { transform: scale(.97); opacity: .85; }
.btn.primary { background: var(--orange); color: #fff; box-shadow: 0 6px 24px rgba(230,126,34,.35); }
.btn.danger { background: rgba(255,107,102,.14); color: var(--red); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; }
.btn-row { display: flex; gap: 10px; } .btn-row .btn { flex: 1; }

/* ---------- estructura de la app ---------- */
#app { height: 100%; }
main { height: 100%; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior-y: contain;
  padding: calc(var(--st) + 14px) 16px calc(var(--tab) + var(--sb) + 28px);
  background: linear-gradient(180deg, #0D3158 0, var(--bg) 300px) no-repeat, var(--bg); }
main > section { max-width: 680px; margin: 0 auto; }
.large-title { padding: 8px 4px 14px; }
.large-title p { margin: 4px 0 0; font-size: 14px; }
.row-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.pad { padding: 0 4px; margin: -8px 0 14px; font-size: 14px; }

.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: flex; justify-content: space-around;
  padding: 6px 4px calc(var(--sb) + 4px); background: rgba(5,15,30,.94); border-top: 1px solid var(--line);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px); }
.tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 2px 0;
  color: #6C84A3; font-size: 10.5px; font-weight: 600; cursor: pointer; }
.tabbar a.active { color: var(--orange); }

/* ---------- tarjetas y métricas ---------- */
.card { background: var(--surface); border-radius: 18px; padding: 16px; margin-bottom: 14px; min-width: 0; }
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.kpi { background: var(--surface); border-radius: 18px; padding: 14px; }
.kpi:first-child { grid-column: 1 / -1; background: linear-gradient(135deg, #12406E, var(--surface)); }
.kpi .v { font-size: 28px; font-weight: 800; letter-spacing: -.6px; } .kpi .l { color: var(--muted); font-size: 12.5px; font-weight: 600; }
.kpi .d { font-size: 12px; font-weight: 700; } .up { color: var(--green); } .down { color: var(--red); }
.seg { display: flex; background: var(--surface); border-radius: 10px; padding: 3px; margin-bottom: 14px; }
.seg button { flex: 1; border: 0; background: none; color: var(--muted); font: 600 14px var(--font); padding: 8px; border-radius: 8px; }
.seg button.on { background: var(--surface2); color: var(--text); box-shadow: 0 2px 8px rgba(0,0,0,.3); }
.chart { height: 190px; } .chart.short { height: 130px; } .chart svg { width: 100%; height: 100%; display: block; }
.chart text { fill: var(--muted); font: 600 11px var(--font); }
.mini-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; font-size: 12px; }
.mini-stats b { display: block; font-size: 20px; }

.meter { background: var(--surface); border-radius: 18px; padding: 16px; margin-bottom: 10px; }
.meter .top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.meter .name { font-weight: 700; } .meter .val { font-weight: 800; font-size: 22px; }
.bar { height: 12px; background: rgba(255,255,255,.08); border-radius: 999px; overflow: hidden; }
.bar > span { display: block; height: 100%; width: 0; border-radius: 999px; transition: width .6s ease;
  background: linear-gradient(90deg, var(--blue2), var(--orange)); }
.bar.warn > span { background: linear-gradient(90deg, var(--orange), var(--yellow)); }
.bar.crit > span { background: linear-gradient(90deg, var(--orange), var(--red)); box-shadow: 0 0 14px var(--red); }
.meter .lim { color: var(--muted); font-size: 13px; margin-top: 8px; display: flex; justify-content: space-between; gap: 10px; }
.meter .lim b { color: var(--text); }
.net { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.net div { background: var(--bg2); border-radius: 14px; padding: 14px; } .net b { font-size: 22px; font-weight: 800; display: block; }
.pill { padding: 6px 12px; border-radius: 999px; font-weight: 700; font-size: 13px; background: var(--surface); white-space: nowrap; }
.pill.ok { color: var(--green); } .pill.bad { color: var(--red); }

/* ---------- listas ---------- */
.search { width: 100%; margin: 0 0 14px; background: var(--surface); border: 0; color: var(--text); border-radius: 12px;
  padding: 11px 14px; font: 16px var(--font); outline: none; -webkit-appearance: none; }
.list-head { font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; margin: 22px 16px 8px; }
.list { list-style: none; margin: 0 0 14px; padding: 0; background: var(--surface); border-radius: 14px; overflow: hidden; }
.list:empty { display: none; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; min-height: 48px; }
.row + .row { border-top: 1px solid var(--line); }
.row .main { flex: 1; min-width: 0; }
.row .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .s { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .r { color: var(--muted); font-size: 14px; text-align: right; flex: none; }
.row.tap, .row.action { cursor: pointer; } .row.tap:active, .row.action:active { background: var(--surface2); }
.row.tap::after { content: "›"; color: #5D7593; font-size: 22px; margin-left: 2px; }
.row.action { color: var(--orange2); font-weight: 600; justify-content: center; }
.row.action.danger { color: var(--red); }
.avatar { width: 38px; height: 38px; flex: none; border-radius: 50%; display: grid; place-items: center; font-weight: 800;
  background: linear-gradient(135deg, var(--orange2), var(--orange)); color: #fff; }
.tag { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: rgba(255,255,255,.08); }
.tag.on { color: var(--green); } .tag.off { color: var(--red); } .tag.admin { color: var(--orange2); }
.empty { padding: 18px 16px; color: var(--muted); text-align: center; }
.foot { color: var(--muted); font-size: 12.5px; margin: -6px 16px 14px; }

.code-reveal { margin-top: 14px; text-align: center; box-shadow: 0 0 0 1px var(--orange), 0 0 30px rgba(230,126,34,.25); }
.code { font: 800 24px/1.2 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: 1px; color: var(--orange2); margin: 8px 0 16px; word-break: break-all; }

/* ---------- hoja inferior ---------- */
.sheet-backdrop { position: fixed; inset: 0; z-index: 10; background: rgba(0,4,10,.55); display: flex; align-items: flex-end; justify-content: center;
  animation: fade .2s ease; }
.sheet { position: relative; width: min(680px, 100%); max-height: 92%; overflow-y: auto; background: var(--bg2);
  border-radius: 22px 22px 0 0; padding: 10px 16px calc(var(--sb) + 22px); animation: up .28s cubic-bezier(.2,.9,.3,1); }
.grabber { width: 38px; height: 5px; border-radius: 3px; background: rgba(255,255,255,.25); margin: 0 auto 14px; }
.sheet-close { position: absolute; top: 12px; right: 12px; background: none; border: 0; color: var(--orange2); font: 600 16px var(--font); padding: 6px; }
.sheet h2 { padding-right: 70px; }
.sheet > div > .muted { margin: 0 0 16px; font-size: 14px; }
.sheet form { margin-bottom: 16px; }
.note { color: var(--green); font-size: 13px; word-break: break-all; -webkit-user-select: text; user-select: text; }
@keyframes up { from { transform: translateY(100%); } to { transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.toast { position: fixed; left: 50%; top: calc(var(--st) + 10px); transform: translate(-50%, -140%); z-index: 20;
  background: var(--text); color: var(--bg); font-weight: 700; font-size: 15px; padding: 12px 20px; border-radius: 999px;
  transition: transform .3s; max-width: calc(100% - 32px); pointer-events: none; text-align: center; }
.toast.show { transform: translate(-50%, 0); } .toast.err { background: var(--red); color: #fff; }

/* En pantallas grandes (ordenador) se ve igual, centrado */
@media (min-width: 760px) { .kpis { grid-template-columns: repeat(3, 1fr); } .kpi:first-child { grid-column: auto; } }
.row .btn { padding: 8px 14px; font-size: 14px; border-radius: 10px; flex: none; }

.switch { width: 51px; height: 31px; appearance: none; -webkit-appearance: none; background: #39516E; border-radius: 999px; position: relative;
  transition: background .2s; flex: none; margin: 0; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; transition: transform .2s; }
.switch:checked { background: var(--green); } .switch:checked::after { transform: translateX(20px); }
select { background: var(--surface2); color: var(--text); border: 0; border-radius: 8px; padding: 6px 8px; font: 15px var(--font); }
.field input[type=file] { text-align: left; font-size: 13px; }
.log { white-space: pre-wrap; word-break: break-word; background: #000a16; border-radius: 12px; padding: 12px; font: 11.5px/1.45 ui-monospace, Menlo, monospace;
  color: var(--muted); max-height: 60vh; overflow: auto; -webkit-user-select: text; user-select: text; }

.tabbar a { position: relative; }
.tabbar .dot { position: absolute; top: 0; left: calc(50% + 8px); width: 9px; height: 9px; border-radius: 50%; background: var(--orange); }
.ticket-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.ticket-actions input { flex: 1 1 100%; min-width: 0; }
.ticket-actions input[name=days] { flex: 0 0 90px; }
.row.col { flex-direction: column; align-items: stretch; }
.ticket-actions .btn { flex: 1; }

/* ======================================================================
   Piel PIXEL ART (igual que la app): letra Pixelify, cielo con estrellas,
   marcos de 2 px con esquinas escalonadas y sombras duras sin desenfoque.
   ====================================================================== */
@font-face { font-family: "Pixelify"; src: url(pixelify-400.ttf) format("truetype"); font-weight: 400 600; font-display: swap; }
@font-face { font-family: "Pixelify"; src: url(pixelify-700.ttf) format("truetype"); font-weight: 700 900; font-display: swap; }
:root {
  --font: "Pixelify", -apple-system, system-ui, sans-serif;
  --bg: #060E1C; --surface: #0D1B30; --surface2: #13284A; --frame: #2A4C7A; --frame-hi: #3B6AA5; --shadow: #02060D;
  /* marco pixel: 4 sombras de 2 px dejan las esquinas «mordidas»; la quinta es la sombra dura */
  --px: 0 -2px 0 0 var(--frame), 0 2px 0 0 var(--frame), -2px 0 0 0 var(--frame), 2px 0 0 0 var(--frame), 4px 4px 0 0 var(--shadow);
  --px-hi: 0 -2px 0 0 var(--frame-hi), 0 2px 0 0 var(--frame-hi), -2px 0 0 0 var(--frame-hi), 2px 0 0 0 var(--frame-hi), 4px 4px 0 0 var(--shadow);
}
*, *::before, *::after { border-radius: 0 !important; font-variant-ligatures: none; }
html, body { -webkit-font-smoothing: none; font-smooth: never; }
body { background: var(--bg) url(/app-assets/px-stars.svg?v=2) repeat; background-size: 400px 400px; }
.screen { background: url(/app-assets/px-stars.svg?v=2) repeat, linear-gradient(#13305A 0 40px, #0F2747 40px 80px, #0B1D38 80px 120px, var(--bg) 120px);
  background-size: 400px 400px, auto; }
h1, h2 { letter-spacing: .5px; text-shadow: 2px 2px 0 var(--shadow); }
h1 { font-weight: 700; } h2, .list-head { font-weight: 700; }
.card, .meter, .group, .list, .steps, .install-card .steps { border: 0; box-shadow: var(--px); }
.list, .group { overflow: visible; }
.btn { box-shadow: var(--px-hi); transition: transform .06s steps(2), box-shadow .06s steps(2); }
.btn:active { transform: translate(4px, 4px); box-shadow: 0 -2px 0 0 var(--frame-hi), 0 2px 0 0 var(--frame-hi), -2px 0 0 0 var(--frame-hi), 2px 0 0 0 var(--frame-hi); }
.btn.primary { --frame-hi: #F6A552; box-shadow: var(--px-hi); }
.btn.danger { --frame-hi: #7A2228; box-shadow: var(--px-hi); }
.pill { box-shadow: 0 -2px 0 0 currentColor, 0 2px 0 0 currentColor, -2px 0 0 0 currentColor, 2px 0 0 0 currentColor; }
.bar { background: #13284A; box-shadow: 0 -2px 0 0 var(--frame), 0 2px 0 0 var(--frame), -2px 0 0 0 var(--frame), 2px 0 0 0 var(--frame); }
/* barras de uso en bloques, como una barra de vida */
.bar > span { transition: width .6s steps(10); -webkit-mask: repeating-linear-gradient(90deg, #000 0 10px, transparent 10px 12px);
  mask: repeating-linear-gradient(90deg, #000 0 10px, transparent 10px 12px); }
.chart svg, svg.chart { shape-rendering: crispEdges; }
.chart polyline, .chart path { stroke-linejoin: miter; stroke-linecap: square; }
.tabbar { box-shadow: 0 -2px 0 0 var(--frame); }
.app-icon { box-shadow: var(--px); image-rendering: pixelated; }
input, select, textarea { font-family: var(--font); }
@media (prefers-reduced-motion: reduce) { .btn, .bar > span { transition: none; } }
audio.listen { width: 100%; margin-top: 8px; height: 36px; }
.ticket-actions select { flex: 1 1 100%; min-width: 0; }
#theme-list .check { color: var(--orange); font-weight: 700; }
#theme-list .selected .t { color: var(--orange2); }
.brand .logo-img { width: 40px; height: 40px; border-radius: 9px; image-rendering: pixelated; vertical-align: middle; margin-right: 10px; }

/* avisos y confirmaciones propios (pixel) */
.toast { position: fixed; left: 12px; right: 12px; top: auto !important; bottom: calc(var(--sb) + var(--tab) + 14px); transform: translateY(160%) !important;
  z-index: 30; display: flex; align-items: center; gap: 10px; padding: 14px 36px 14px 14px; text-align: left; background: var(--surface2); color: var(--text);
  box-shadow: var(--px-hi); font: 600 15px var(--font); transition: transform .18s steps(4); max-width: 520px; margin: 0 auto; }
.toast:not(.show) { visibility: hidden; transition: transform .18s steps(4), visibility 0s .18s; }
.toast.show { transform: translateY(0) !important; visibility: visible; }
.toast.err { --frame-hi: var(--red); background: var(--surface2); color: var(--text); }
.toast .toast-msg { flex: 1; min-width: 0; }
.toast .toast-ok { padding: 8px 14px; font-size: 14px; flex: none; }
.toast-x { position: absolute; right: 6px; top: 2px; background: none; border: 0; color: var(--muted); font: 700 13px var(--font); padding: 4px; }
.ask-back { position: fixed; inset: 0; z-index: 40; background: rgba(2,6,13,.72); display: grid; place-items: center; padding: 20px; }
.ask { position: relative; width: min(420px, 100%); background: var(--surface); box-shadow: var(--px-hi); padding: 22px 18px 18px; }
.ask-msg { margin: 0 0 16px; padding-right: 18px; white-space: pre-line; line-height: 1.45; }
.btn.danger-solid { background: var(--red); color: #fff; --frame-hi: #7A2228; box-shadow: var(--px-hi); }
