:root {
  --bg: #0b0c0e;
  --panel: rgba(17, 19, 23, .78);
  --panel-solid: #15171b;
  --line: rgba(255, 255, 255, .09);
  --line-2: rgba(255, 255, 255, .16);
  --text: #eceef0;
  --muted: #9aa1a9;
  --faint: #6b727a;
  --accent: #e0483a;
  --accent-2: #f05a4b;
  --ok: #3ccf7a;
  --warn: #f2b134;
  --r: 14px;
  --gap: 16px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 14px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif; overflow: hidden; -webkit-font-smoothing: antialiased; }
canvas#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
button { font: inherit; color: inherit; background: rgba(255,255,255,.06); border: 1px solid var(--line); border-radius: 9px; padding: 7px 10px; cursor: pointer; transition: background .15s, border-color .15s, color .15s; }
button:hover { background: rgba(255,255,255,.12); }
button:focus-visible { outline: 2px solid #7fb2ff; outline-offset: 2px; }
button.primary { background: var(--accent); border-color: transparent; color: #fff; font-weight: 600; }
button.primary:hover { background: var(--accent-2); }
button.icon { width: 32px; height: 32px; padding: 0; display: grid; place-items: center; background: transparent; border-color: transparent; }
button.icon:hover { background: rgba(255,255,255,.1); }
button.icon svg { width: 18px; height: 18px; fill: currentColor; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
button.icon[aria-pressed="false"] { color: var(--faint); }
button.icon[aria-pressed="false"] .on { display: none; }
button.link { background: none; border: 0; padding: 2px 0; color: var(--muted); font-size: 12px; justify-self: center; }
button.link:hover { color: var(--text); }
kbd { font: 10.5px/1 ui-monospace, SFMono-Regular, monospace; padding: 2px 5px; border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 4px; color: var(--muted); background: rgba(255,255,255,.04); }
button.primary kbd { color: #fff; border-color: rgba(255,255,255,.4); background: transparent; }

.panel { position: fixed; z-index: 2; background: var(--panel); backdrop-filter: blur(14px) saturate(1.2); -webkit-backdrop-filter: blur(14px) saturate(1.2); border: 1px solid var(--line); border-radius: var(--r); box-shadow: 0 8px 32px rgba(0,0,0,.35); }

/* marca */
.brand { top: var(--gap); left: var(--gap); display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 10px; }
.logo { width: 30px; height: 30px; border-radius: 8px; border: 2px solid var(--accent); display: grid; place-items: center; font-weight: 800; font-size: 15px; }
.title h1 { margin: 0; font-size: 14.5px; font-weight: 650; letter-spacing: .01em; }
.title p { margin: 0; font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.icons { display: flex; gap: 2px; margin-left: 6px; padding-left: 6px; border-left: 1px solid var(--line); }

/* cronòmetre */
.timer { top: var(--gap); left: 50%; transform: translateX(-50%); padding: 8px 18px 9px; text-align: center; min-width: 220px; }
.t-row { display: flex; align-items: center; justify-content: center; gap: 8px; }
.t-row b { font: 600 24px/1.1 ui-monospace, SFMono-Regular, monospace; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.timer.running .dot { background: var(--accent); animation: pulse 1s infinite; }
.timer.done .dot { background: var(--ok); }
.timer.done b { color: var(--ok); }
@keyframes pulse { 50% { opacity: .3; } }
.t-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.t-meta .rec { color: var(--warn); }
.t-status { font-size: 12px; color: var(--ok); margin-top: 4px; display: none; max-width: 420px; }
.t-status.on { display: block; }

/* accions */
.actions { top: var(--gap); right: var(--gap); width: 280px; padding: 14px; display: grid; gap: 12px; }
.field { display: grid; gap: 6px; }
.field.inline { grid-template-columns: 1fr auto; align-items: center; }
.label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); font-weight: 600; }
.seg { display: flex; padding: 3px; gap: 3px; background: rgba(0,0,0,.28); border: 1px solid var(--line); border-radius: 10px; }
.seg button { flex: 1; border: 0; border-radius: 7px; background: transparent; padding: 6px 4px; font-size: 13px; color: var(--muted); white-space: nowrap; }
.seg button:hover { color: var(--text); background: rgba(255,255,255,.05); }
.seg button.on { background: rgba(255,255,255,.14); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.3); }
.seg.small button { padding: 3px 9px; font-size: 12px; }
.row { display: flex; gap: 6px; }
.row > button { flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 13px; }
#park { padding: 11px; font-size: 14.5px; display: flex; align-items: center; justify-content: center; gap: 8px; }
.plan { margin: -4px 0 0; font-size: 12.5px; color: var(--muted); line-height: 1.45; }
.plan:empty { display: none; }
.plan b { color: var(--text); font-weight: 600; }
hr { border: 0; border-top: 1px solid var(--line); margin: 0; width: 100%; }
.toggle i { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
.toggle.open i { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.toggle.moving i { background: var(--warn); }
.actions .more { display: none; }
.actions.expanded .more { display: grid; }
.mobile-only { display: none !important; }


/* càmeres */
.cams { left: var(--gap); bottom: var(--gap); padding: 6px; display: grid; gap: 4px; }
.cams .seg { background: transparent; border: 0; padding: 0; }
.cams .seg button { font-size: 12.5px; padding: 6px 9px; }
.hint { font-size: 11px; color: var(--faint); text-align: center; }

/* quadre */
.dash { position: fixed; left: 50%; bottom: var(--gap); transform: translateX(-50%); display: flex; gap: 8px; align-items: stretch; z-index: 2; pointer-events: none; }
.dash > div { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); box-shadow: 0 8px 32px rgba(0,0,0,.35); }
.gauge { padding: 8px 16px; display: grid; grid-template-columns: auto 1fr; gap: 4px 16px; align-items: center; min-width: 170px; }
.gear { font: 700 24px/1 ui-monospace, monospace; color: var(--ok); }
.gear.r { color: var(--warn); }
.spd { text-align: right; }
.spd b { font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; }
.spd small { color: var(--muted); margin-left: 3px; font-size: 11px; }
.steer { grid-column: 1 / -1; height: 3px; background: rgba(255,255,255,.12); border-radius: 2px; position: relative; }
.steer::after { content: ""; position: absolute; left: 50%; top: -3px; width: 1px; height: 9px; background: var(--line-2); }
.steer i { position: absolute; top: -3px; width: 9px; height: 9px; border-radius: 50%; background: var(--text); left: calc(50% - 4px); }
.pdc { padding: 8px 12px; width: 96px; display: grid; gap: 3px; align-content: center; }
.pdc span { font-size: 10.5px; color: var(--faint); text-transform: uppercase; letter-spacing: .07em; font-weight: 600; }
.pdc b { font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; }
.pdc i { height: 3px; border-radius: 2px; background: var(--ok); width: 0; transition: width .1s; }
.pdc.warn b { color: var(--warn); } .pdc.warn i { background: var(--warn); }
.pdc.stop b { color: var(--accent); } .pdc.stop i { background: var(--accent); }

.rearcam { position: fixed; z-index: 1; border: 1px solid var(--line-2); border-radius: 12px; pointer-events: none; display: none; box-shadow: 0 8px 32px rgba(0,0,0,.5); }
.rearcam.on { display: block; }
.rearcam span { position: absolute; left: 8px; top: 7px; font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em; font-weight: 600; background: rgba(0,0,0,.55); padding: 3px 7px; border-radius: 5px; color: #ddd; }
.toast { position: fixed; left: 50%; top: 42%; transform: translate(-50%, -50%) scale(.96); z-index: 3; font-size: 26px; font-weight: 750; color: #fff; text-shadow: 0 2px 24px rgba(0,0,0,.8); opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none; text-align: center; }
.toast.on { opacity: 1; transform: translate(-50%, -50%) scale(1); }

/* diàlegs */
dialog { background: var(--panel-solid); color: var(--text); border: 1px solid var(--line-2); border-radius: 16px; padding: 0; max-width: min(720px, calc(100vw - 32px)); box-shadow: 0 24px 80px rgba(0,0,0,.6); }
dialog::backdrop { background: rgba(0,0,0,.5); backdrop-filter: blur(2px); }
.dlg { padding: 18px 20px 20px; display: grid; gap: 14px; }
.dlg header { display: flex; justify-content: space-between; align-items: center; }
.dlg h2 { margin: 0; font-size: 16px; }
.dlg h3 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.dlg h3 small { text-transform: none; letter-spacing: 0; color: var(--faint); font-weight: 500; margin-left: 6px; }
.dlg h3 small.ok { color: var(--ok); }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 7px 12px; font-size: 13px; }
dt { color: var(--text); white-space: nowrap; }
dd { margin: 0; color: var(--muted); }
.note { margin: 0; font-size: 12px; color: var(--faint); }
.dlg .note { margin-top: 10px; }
.grid { display: grid; gap: 8px; }
.grid label { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 13px; }
.grid small { color: var(--faint); margin-left: 4px; }
.grid input[type=number] { width: 84px; font: inherit; color: var(--text); background: rgba(0,0,0,.35); border: 1px solid var(--line-2); border-radius: 7px; padding: 5px 8px; text-align: right; font-variant-numeric: tabular-nums; }
.grid .check { justify-content: flex-start; }
.dlg footer { display: flex; justify-content: flex-end; gap: 8px; }

.touch { display: none; }
@media (pointer: coarse) {
  .touch { display: grid; grid-template-columns: 64px 64px 1fr 64px 64px; gap: 10px; position: fixed; left: var(--gap); right: var(--gap); bottom: 96px; z-index: 2; pointer-events: none; }
  .touch button { height: 64px; font-size: 22px; background: var(--panel); border-color: var(--line-2); touch-action: none; pointer-events: auto; border-radius: 16px; }
  .cams .hint { display: none; }
}
@media (max-width: 1100px) {
  .actions { width: 250px; }
  .cams .seg button { padding: 6px 7px; }
}
@media (max-width: 760px) {
  :root { --gap: 10px; }
  .brand { right: auto; padding: 6px; }
  .title p { display: none; }
  .timer { top: auto; bottom: 178px; min-width: 0; padding: 5px 14px; }
  .t-row b { font-size: 18px; }
  .t-meta { font-size: 11px; }
  .actions { top: 62px; left: var(--gap); right: var(--gap); width: auto; padding: 10px; gap: 8px; }
  .actions hr { display: none; }
  .plan { font-size: 12px; }
  .cams { left: var(--gap); right: var(--gap); bottom: auto; top: 62px; display: none; }
  .actions kbd, .cams .hint { display: none; }
  .mobile-only { display: grid !important; }
  .dash { bottom: var(--gap); gap: 6px; }
  .pdc { width: 78px; padding: 6px 9px; }
  .pdc b { font-size: 14px; }
  .gauge { min-width: 130px; padding: 6px 12px; }
  .gear, .spd b { font-size: 19px; }
  .cols { grid-template-columns: 1fr; }
}
