/* Green Ice · Planta — tablero de turno. Tonos de agua fría y acero; estado en semáforo. */
:root {
  --bg: #f3f6f7;
  --panel: #ffffff;
  --panel-2: #eaf1f3;
  --fg: #12232a;
  --muted: #5a6f77;
  --line: #d5e0e4;
  --accent: #0e6f86;
  --accent-ink: #ffffff;
  --brand: #0e3b4a;
  --ok: #1d7a4c;
  --warn: #a8670b;
  --bad: #b3261e;
  --ok-bg: #e3f3ea;
  --warn-bg: #fbf0dc;
  --bad-bg: #fbe5e3;
  --s1: #0e6f86; --s2: #3aa6b9; --s3: #7a8f2b; --s4: #b0832a;
  --font: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'Cascadia Mono', Consolas, monospace;
  --r: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c171b; --panel: #122228; --panel-2: #172c33; --fg: #e3eef1; --muted: #93aab2; --line: #24404a;
    --accent: #4cc1d6; --accent-ink: #062027; --brand: #0a2a34;
    --ok: #5fcf93; --warn: #e8b04f; --bad: #ff8a80; --ok-bg: #12301f; --warn-bg: #33270f; --bad-bg: #3a1714;
    --s1: #4cc1d6; --s2: #8ee0ec; --s3: #b6cc5a; --s4: #e0b25a;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--fg); font: 15px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.num, td.n, .mono { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); }

/* barra superior */
.top { position: sticky; top: 0; z-index: 20; background: var(--brand); color: #e8f6f9; padding: env(safe-area-inset-top, 0) max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left)); }
.top .row { display: flex; align-items: center; gap: 12px; min-height: 52px; max-width: 1280px; margin: 0 auto; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; letter-spacing: .01em; white-space: nowrap; }
.brand svg { flex: none; }
.brand small { font-weight: 400; opacity: .7; }
.nav { display: flex; gap: 2px; margin-left: 8px; overflow-x: auto; scrollbar-width: none; }
.nav a { color: #cfe7ee; text-decoration: none; padding: 8px 12px; border-radius: 8px; white-space: nowrap; font-size: 14px; }
.nav a[aria-current="page"] { background: rgba(255,255,255,.14); color: #fff; }
.nav a:hover { background: rgba(255,255,255,.08); }
.who { margin-left: auto; display: flex; align-items: center; gap: 8px; font-size: 13px; white-space: nowrap; }
.who a { color: #cfe7ee; display: inline-flex; align-items: center; min-height: 44px; padding: 0 8px; }
.rolpill { border: 1px solid rgba(255,255,255,.3); border-radius: 99px; padding: 1px 8px; font-size: 12px; }

/* navegación inferior en celular */
.bnav { display: none; }
@media (max-width: 760px) {
  .nav { display: none; }
  .who .nm { display: none; }
  .bnav { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--panel); border-top: 1px solid var(--line);
    padding: 4px max(8px, env(safe-area-inset-left)) calc(4px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-right)); justify-content: space-around; }
  .bnav a { flex: 1; text-align: center; text-decoration: none; color: var(--muted); font-size: 11px; padding: 6px 2px; min-height: 48px; border-radius: 8px; }
  .bnav a b { display: block; font-size: 18px; line-height: 1.1; font-weight: 500; }
  .bnav a[aria-current="page"] { color: var(--accent); background: var(--panel-2); }
  main { padding-bottom: 84px !important; }
}

main { max-width: 1280px; margin: 0 auto; padding-block: 20px 40px; padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); display: grid; gap: 18px; }
h1 { font-size: 22px; font-weight: 600; margin: 0; text-wrap: balance; }
h2 { font-size: 16px; font-weight: 600; margin: 0; }
h3 { font-size: 14px; font-weight: 600; margin: 0; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.head { display: flex; flex-wrap: wrap; align-items: end; gap: 10px 16px; justify-content: space-between; }
.head .ctl { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.live { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.live i { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); display: inline-block; }
.live.off i { background: var(--muted); }
@media (prefers-reduced-motion: no-preference) { .live:not(.off) i { animation: pulse 2s infinite; } }
@keyframes pulse { 50% { opacity: .35; } }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; display: grid; gap: 12px; align-content: start; min-width: 0; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); }
.tiles { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr)); }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; display: grid; gap: 2px; }
.tile .k { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.tile .v { font-size: 26px; font-weight: 500; font-variant-numeric: tabular-nums; line-height: 1.2; }
.tile .v small { font-size: 14px; color: var(--muted); font-weight: 400; }
.tile .d { font-size: 12px; color: var(--muted); }

.maqs { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); }
.maq { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; display: grid; gap: 8px; border-left: 4px solid var(--line); }
.maq.ok { border-left-color: var(--ok); } .maq.warn { border-left-color: var(--warn); } .maq.bad { border-left-color: var(--bad); }
.maq .t { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.maq .kg { font-size: 24px; font-weight: 500; font-variant-numeric: tabular-nums; }
.bar { height: 8px; background: var(--panel-2); border-radius: 4px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; font-size: 13px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }

.alerts { display: grid; gap: 6px; }
.al { display: flex; gap: 10px; align-items: flex-start; padding: 8px 12px; border-radius: 8px; font-size: 14px; }
.al::before { content: ""; width: 8px; height: 8px; border-radius: 50%; margin-top: 7px; flex: none; }
.al.critico { background: var(--bad-bg); } .al.critico::before { background: var(--bad); }
.al.aviso { background: var(--warn-bg); } .al.aviso::before { background: var(--warn); }
.al.info { background: var(--panel-2); } .al.info::before { background: var(--accent); }

.pill { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 99px; background: var(--panel-2); color: var(--muted); white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok); } .pill.warn { background: var(--warn-bg); color: var(--warn); } .pill.bad { background: var(--bad-bg); color: var(--bad); }

/* tablas */
.tw { overflow-x: auto; max-width: 100%; }
.tw.tall { max-height: 60vh; overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 500; text-transform: uppercase; letter-spacing: .04em; position: sticky; top: 0; background: var(--panel); }
td.n, th.n { text-align: right; }
tr.click { cursor: pointer; } tr.click:hover td { background: var(--panel-2); }

/* formularios */
form { display: grid; gap: 14px; }
.fields { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 140px), 1fr)); }
.card .tiles.two { grid-template-columns: 1fr 1fr; }
label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
label.wide { grid-column: 1 / -1; }
input, select, textarea { width: 100%; border: 1px solid var(--line); background: var(--bg); border-radius: 8px; padding: 10px 12px; color: var(--fg); min-height: 48px; font-size: 16px; }
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.btns { display: flex; flex-wrap: wrap; gap: 8px; }
.btn { border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 10px 18px; cursor: pointer; min-height: 48px; touch-action: manipulation; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; color: var(--fg); }
.btn.pri { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 500; }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 6px 12px; min-height: 44px; min-width: 44px; font-size: 14px; }
.btn:disabled { opacity: .5; cursor: default; }
.machine-entry { border: 1px solid var(--line); border-radius: var(--r); padding: 12px; display: grid; gap: 10px; background: var(--bg); }
.machine-entry h3 { display: flex; justify-content: space-between; gap: 8px; }
.err { color: var(--bad); font-size: 14px; }
.aviso { background: var(--warn-bg); color: var(--fg); border-radius: 8px; padding: 10px 12px; font-size: 14px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.aviso[hidden] { display: none; }
input[type=checkbox], input[type=radio] { width: 24px; height: 24px; min-height: 24px; padding: 0; accent-color: var(--accent); }
label:has(> input[type=checkbox]) { min-height: 44px; align-content: center; }
.btns .btn.pri { flex: 1 1 220px; justify-content: center; font-size: 16px; }
.secret { font-family: var(--mono); background: var(--panel-2); padding: 10px 12px; border-radius: 8px; word-break: break-all; user-select: all; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: linear-gradient(180deg, var(--brand) 0 38%, var(--bg) 38%); }
.login .card { width: min(100%, 380px); padding: 24px; gap: 16px; }
.login .logo { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 18px; }

/* gráficos */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.chart .grid line { stroke: var(--line); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.tip { position: absolute; pointer-events: none; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; font-size: 12px; box-shadow: 0 6px 20px rgba(0,0,0,.12); white-space: nowrap; z-index: 5; }

#toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(96px + env(safe-area-inset-bottom)); background: var(--fg); color: var(--bg); padding: 10px 16px; border-radius: 8px; z-index: 50; font-size: 14px; max-width: calc(100% - 32px); }
@media (min-width: 761px) { #toast { bottom: 24px; } }
dialog { border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); color: var(--fg); width: min(640px, calc(100% - 24px)); padding: 18px; }
dialog::backdrop { background: rgba(0,0,0,.4); }
