/* Pulse Copier owner admin - visual system.

   Every value here is the prototype's: its two themes (dark by default, light
   under the corner button), its radii, shadows, sizes and spacings. The
   token names are the client PWA's (web/styles.css), so both panels read as
   one family; where the prototype and the PWA give a token two values, the
   prototype's is used, and tests/test_web_admin_static.py tells one from the
   other. Urbanist is self-hosted (fonts/): no external fonts, images or scripts, so
   the page keeps working under style-src 'self' font-src 'self'.

   The prototype's glows are kept as they are: a blurred band of the state
   color at the foot of the hero, and the spectrum behind the login brand.
   What sits on the hero's glow is regular text, or rests on an opaque sheet
   (the form card), so it keeps its contrast: no secondary text is placed
   there. */

/* Urbanist, the prototype's typeface, served from this same origin (OFL licence in
   fonts/OFL.txt): no third party is contacted. Falls back to the system stack. */
@font-face {
  font-family: "Urbanist";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("fonts/urbanist-latin-wght.woff2") format("woff2");
}

:root {
  color-scheme: dark;
  --bg-img: none;
  --bg: #0b0b0d;
  --surface: rgba(255, 255, 255, .04);
  --surface-2: rgba(255, 255, 255, .08);
  --field: rgba(255, 255, 255, .04);
  --sheet: #1a1a1e;
  --head: #141416;
  --hover: rgba(255, 255, 255, .035);
  --bar: rgba(11, 11, 13, .92);
  --text: #f2f2f4;
  --muted: #8a8a93;
  --line: rgba(255, 255, 255, .08);
  --line-2: rgba(255, 255, 255, .34);
  --ok: #22f08a;
  --ok-bg: rgba(34, 240, 138, .14);
  --warn: #ffb21e;
  --warn-bg: rgba(255, 178, 30, .14);
  --bad: #ff4d5e;
  --bad-bg: rgba(255, 77, 94, .12);
  --info: #7fb6ff;
  --info-bg: rgba(127, 182, 255, .14);
  --neutral: #b4b4bc;
  --neutral-bg: rgba(255, 255, 255, .08);
  --primary: #f4f4f5;
  --on-primary: #0b0b0d;
  --on-danger: #0b0b0d;
  --scrim: rgba(0, 0, 0, .6);
  --focus: #9fb4ff;
  --vio: #c39bff;
  --vio-bg: rgba(168, 85, 247, .16);
  --glow: .5;
  --spectrum: linear-gradient(90deg, #ff3b3b, #ff9f1c, #ffe14d, #3ddc84, #2d9cff, #8b5cf6);
  --r-control: 18px;
  --r-card: 24px;
  --r-hero: 30px;
  --font: "Urbanist", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg-img:
    radial-gradient(1100px 620px at 0% 0%, rgba(34, 240, 138, .18), transparent 60%),
    radial-gradient(900px 620px at 100% 0%, rgba(139, 92, 246, .18), transparent 60%),
    radial-gradient(1000px 700px at 100% 100%, rgba(45, 156, 255, .16), transparent 60%),
    radial-gradient(900px 600px at 0% 100%, rgba(255, 159, 28, .14), transparent 60%);
  --bg: #f2f2ef;
  --surface: rgba(255, 255, 255, .72);
  --surface-2: rgba(11, 11, 13, .06);
  --field: rgba(255, 255, 255, .85);
  --sheet: #ffffff;
  --head: rgba(250, 250, 248, .94);
  --hover: rgba(255, 255, 255, .5);
  --bar: rgba(255, 255, 255, .8);
  --text: #0b0b0d;
  --muted: #6b6b72;
  --line: rgba(0, 0, 0, .09);
  --line-2: rgba(0, 0, 0, .3);
  --ok: #0e6b40;
  --ok-bg: rgba(14, 107, 64, .1);
  --warn: #8a5a12;
  /* The prototype's tint here (rgba(138, 90, 18, .12)) puts that amber at
     4.49:1, a hair under AA: the PWA's tint is kept, to the eye the same. */
  --warn-bg: rgba(183, 121, 31, .12);
  --bad: #b32a20;
  --bad-bg: rgba(179, 42, 32, .1);
  --info: #2556c4;
  --info-bg: rgba(37, 86, 196, .1);
  --neutral: #55555c;
  --neutral-bg: rgba(0, 0, 0, .06);
  --primary: #0b0b0d;
  --on-primary: #ffffff;
  --on-danger: #ffffff;
  --scrim: rgba(11, 11, 13, .35);
  --focus: #2556c4;
  --vio: #6d28d9;
  --vio-bg: rgba(109, 40, 217, .1);
  --glow: .45;
}

/* ------------------------------------------------------------- base */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
body {
  margin: 0; min-height: 100vh; min-height: 100dvh; display: flex;
  background: var(--bg); background-image: var(--bg-img); color: var(--text);
  font: 400 16px/1.45 var(--font); font-variant-numeric: tabular-nums;
}
:root:not([data-theme="light"]) body { -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4, p, ul { margin: 0; }
[hidden] { display: none !important; }
.ico {
  width: 22px; height: 22px; display: block; flex: none; fill: none;
  stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.tile .ico { width: 20px; height: 20px; }
.hero-tile .ico { width: 26px; height: 26px; stroke-width: 2.2; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
main:focus,
[tabindex="-1"]:focus,
[tabindex="-1"]:focus-visible { outline: none; }
.sr {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%);
  white-space: nowrap;
}
.skip {
  position: absolute; top: -100px; left: 16px; z-index: 60; padding: 12px 16px;
  border-radius: 999px; background: var(--primary); color: var(--on-primary);
  font-weight: 600; text-decoration: none;
}
.skip:focus { top: calc(8px + env(safe-area-inset-top)); }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; overflow-wrap: anywhere; }
.muted { color: var(--muted); font-size: 14px; line-height: 1.45; }

main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.view { flex: 1; display: flex; flex-direction: column; }

/* ------------------------------------------------------------ buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 18px; border: 1px solid var(--line-2);
  border-radius: 999px; background: transparent; color: var(--text);
  font: inherit; font-size: 14px; font-weight: 600; text-align: center; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn.danger { background: transparent; border-color: var(--bad); color: var(--bad); }
.btn.pill { min-height: 52px; padding: 12px 28px; font-size: 16px; }
.btn.sm { min-height: 36px; padding: 6px 14px; }
.btn.block { display: flex; width: 100%; }
.btn[disabled] { opacity: .4; cursor: progress; }
.btn[aria-disabled=true] { opacity: .35; cursor: default; }
@media (hover: hover) {
  .btn.primary:hover:not([disabled]) { opacity: .88; }
  .btn:not(.primary):not(.danger):hover { background: var(--surface-2); }
}
.row { display: flex; flex-wrap: wrap; gap: 10px; }

/* -------------------------------------------------------------- forms */
form { display: flex; flex-direction: column; gap: 12px; }
#events-filter { max-width: 480px; }
.field { display: flex; flex-direction: column; gap: 8px; }
label { font-size: 13px; color: var(--muted); }
input[type=text], input[type=email], input[type=password], select {
  width: 100%; height: 52px; padding: 0 18px; border: 1px solid var(--line);
  border-radius: 16px; background: var(--field); color: var(--text);
  font: inherit; font-size: 16px;
}
input::placeholder { color: var(--muted); opacity: 1; }
select {
  height: 40px; padding: 0 38px 0 14px; border-color: var(--line-2);
  border-radius: var(--r-control); font-size: 14px;
}
select option { color: #0b0b0d; background: #fff; }
#ks-reason { height: 56px; border-radius: var(--r-control); }
#events-kind { height: 48px; padding: 0 16px; border-radius: var(--r-control); font-size: 15px; }
.select-wrap { position: relative; display: flex; }
.select-wrap select { appearance: none; -webkit-appearance: none; }
.select-wrap::after {
  content: ""; position: absolute; top: 15.75px; right: 18.5px; width: 5px; height: 5px;
  border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted);
  transform: rotate(45deg); pointer-events: none;
}
.hint { font-size: 13px; line-height: 1.4; color: var(--muted); }

/* A verification code is one field, stretched over the row and transparent;
   the six boxes under it show what the field holds, one character each, and
   the next one to be filled is marked (both are drawn by app.js). */
.otp { position: relative; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; }
.otp-boxes { display: contents; }
.otp-box {
  height: 64px; border-radius: 16px; border: 1px solid var(--line); background: var(--field);
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; font-weight: 500; line-height: 1;
}
.otp-box.next { border-color: var(--line-2); }
.otp:focus-within .otp-box.next { box-shadow: inset 0 0 0 2px var(--focus); }
input.otp-input {
  position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; padding: 0; border: 0;
  border-radius: 0; background: transparent; opacity: 0; font-size: 16px; cursor: text;
}
#form-ks .otp { gap: 8px; }
#form-ks .otp-box { height: 52px; font-size: 22px; }

/* --------------------------------------------------------------- alerts */
/* A message in the page: the tint of its kind, its color, and a dot. */
.error {
  display: flex; align-items: flex-start; gap: 10px; padding: 12px 16px; border-radius: 14px;
  background: var(--bad-bg); color: var(--bad); font-size: 15px; line-height: 1.4;
}
.error::before { content: ""; flex: none; width: 8px; height: 8px; border-radius: 50%; background: currentColor; margin-top: 6px; }
.notice {
  display: flex; flex-direction: column; gap: 10px; padding: 12px 16px; border-radius: 14px;
  background: var(--warn-bg); color: var(--warn); font-size: 15px; line-height: 1.4;
}
.notice p { display: flex; align-items: flex-start; gap: 10px; }
.notice p::before { content: ""; flex: none; width: 8px; height: 8px; border-radius: 50%; background: currentColor; margin-top: 6px; }
.notice .btn { align-self: flex-start; border-color: var(--line-2); color: var(--text); }

/* ------------------------------------------------- badges and metrics */
span.pill {
  display: inline-flex; align-items: center; gap: 8px; min-height: 28px; padding: 0 12px;
  border-radius: 999px; font-size: 13px; font-weight: 600; white-space: nowrap;
  color: var(--neutral); background: var(--neutral-bg);
}
span.pill::before { content: ""; flex: none; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
span.pill.ok { color: var(--ok); background: var(--ok-bg); }
span.pill.warn { color: var(--warn); background: var(--warn-bg); }
span.pill.bad { color: var(--bad); background: var(--bad-bg); }
.tag {
  height: 22px; padding: 0 8px; border-radius: 999px; border: 1px solid var(--line-2);
  display: inline-flex; align-items: center; flex: none; font-size: 11px; font-weight: 600;
  color: var(--muted);
}
.tile {
  width: 40px; height: 40px; border-radius: 14px; display: flex; align-items: center;
  justify-content: center; flex: none; color: #fff;
}
.tile-clients { background: linear-gradient(135deg, #22f08a, #14b8a6); box-shadow: 0 6px 18px rgba(34, 240, 138, .3); }
.tile-accounts { background: linear-gradient(135deg, #2d9cff, #8b5cf6); box-shadow: 0 6px 18px rgba(77, 124, 255, .35); }
.tile-executors { background: linear-gradient(135deg, #8b5cf6, #ec4899); box-shadow: 0 6px 18px rgba(168, 85, 247, .35); }
.tile-alerts { background: linear-gradient(135deg, #ffe14d, #ff9f1c); color: #1a1200; box-shadow: 0 6px 18px rgba(255, 170, 30, .3); }
.metric-value.negative { color: var(--bad); }

/* A pill switch: a button with role="switch" and aria-checked. No view of the
   panel flips one (the kill switch asks for a reason, a code and a confirm),
   so the component is here for the day one does. */
.switch {
  position: relative; flex: none; width: 52px; height: 32px; padding: 0;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface-2);
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.switch::before {
  content: ""; position: absolute; top: 2px; left: 2px; width: 26px; height: 26px;
  border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .3);
}
.switch[aria-checked="true"] { border-color: transparent; background: var(--ok); }
.switch[aria-checked="true"]::before { top: 3px; left: 23px; }

/* ------------------------------------------------------ layout: side */
.side {
  flex: none; position: sticky; top: 0; align-self: flex-start; width: 248px;
  height: 100vh; height: 100dvh; display: flex; flex-direction: column; gap: 4px;
  padding: 24px 14px 18px; border-right: 1px solid var(--line); overflow: auto;
}
#bar .brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 24px; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 14px; background: var(--surface-2);
  border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; flex: none;
}
.brand-name { font-size: 18px; font-weight: 600; letter-spacing: .16em; }
.brand-tag {
  height: 26px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--line);
  display: inline-flex; align-items: center; font-size: 12px; color: var(--muted);
}
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item, .side-btn, .sheet-item {
  display: flex; align-items: center; gap: 12px; height: 44px; padding: 0 12px;
  border: 0; border-radius: 14px; background: transparent; color: var(--muted);
  font: inherit; font-size: 15px; font-weight: 500; text-align: left; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.nav-item span, .side-btn span, .sheet-item span { flex: 1; min-width: 0; }
.nav-item .ico, .side-btn .ico, .sheet-item .ico { width: 20px; height: 20px; stroke-width: 1.8; }
.nav-item[aria-current="page"], .nav-item.open, .sheet-item[aria-current="page"] {
  background: var(--surface-2); color: var(--text);
}
@media (hover: hover) {
  .nav-item:hover, .side-btn:hover, .sheet-item:hover { background: var(--surface-2); color: var(--text); }
}
.nav-more, .more-sheet { display: none; }
.side-foot { margin-top: auto; padding-top: 12px; display: flex; flex-direction: column; gap: 2px; }
#btn-logout { color: var(--muted); }

/* -------------------------------------------------- layout: content */
#view-dashboard { width: 100%; max-width: 1200px; margin: 0 auto; padding: 40px 40px 72px; gap: 24px; }
.dash-head { display: flex; justify-content: flex-end; min-height: 19px; }
.updated {
  display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted);
}
.updated:not(:empty)::before { content: ""; flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--muted); }
.page { display: flex; flex-direction: column; gap: 24px; }
.page-head { display: flex; flex-direction: column; gap: 6px; min-width: 0; padding-top: 4px; }
.page-head h3 { font-size: 40px; font-weight: 300; line-height: 1.05; letter-spacing: -.01em; overflow-wrap: anywhere; }
.page-sub { font-size: 15px; line-height: 1.45; color: var(--muted); text-wrap: pretty; }
.toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.toolbar .field { flex: 0 1 280px; }
#page-senales > .btn, #page-salud > .btn { align-self: flex-start; }
.pager { justify-content: space-between; }

/* ------------------------------------------------------------ hero */
.hero {
  --state-glow: var(--line-2);
  position: relative; overflow: hidden; display: flex; flex-wrap: wrap; align-items: flex-end;
  justify-content: space-between; gap: 24px; padding: 30px 32px 38px;
  border-radius: var(--r-hero); background: var(--surface); border: 1px solid var(--line);
}
/* The state's glow: the same gradient blurred at the foot of the card, and
   the strip along its edge. Unknown (neither on nor off): a gray strip. */
.hero::before {
  content: ""; position: absolute; left: -10%; right: -10%; bottom: -130px; height: 180px;
  background: var(--state-glow); filter: blur(60px); opacity: var(--glow); pointer-events: none;
}
.hero::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 5px; background: var(--state-glow); }
.hero.off { --state-glow: linear-gradient(90deg, #22f08a, #00d1ff, #3b82f6, #a855f7); }
.hero.off.late { --state-glow: linear-gradient(90deg, #ff6a00, #ffb21e, #ffe14d, #ff6a00); }
.hero.on { --state-glow: linear-gradient(90deg, #ff2d55, #ff4d5e, #c026d3); }
.hero-state { position: relative; flex: 1 1 360px; min-width: 0; display: flex; flex-direction: column; gap: 18px; }
.eyebrow { font-size: 14px; color: var(--muted); }
.hero-line { display: flex; flex-wrap: wrap; align-items: center; gap: 14px 16px; }
.hero-tile {
  width: 56px; height: 56px; border-radius: 18px; display: flex; align-items: center;
  justify-content: center; flex: none; color: var(--muted); background: var(--surface-2);
}
.hero.off .hero-tile { color: var(--ok); background: var(--ok-bg); box-shadow: 0 0 28px var(--ok-bg); }
.hero.on .hero-tile { color: var(--bad); background: var(--bad-bg); box-shadow: 0 0 28px var(--bad-bg); }
.hero-word { font-size: 64px; font-weight: 300; line-height: 1; letter-spacing: -.02em; }
.hero-badges { display: flex; flex-wrap: wrap; gap: 8px; }
.hero-badges:empty { display: none; }
.hero-badges .pill { min-height: 30px; }
.ks-state { font-size: 16px; font-weight: 600; line-height: 1.35; text-wrap: pretty; }
/* The time of the last change is a value, not a secondary line: it is the
   lowest text of the column, right over the glow. */
#ks-updated { font-size: 16px; line-height: 1.35; text-wrap: pretty; }
#ks-updated:empty { display: none; }
/* On an opaque sheet: the glow shows around the form, never under its text. */
#form-ks {
  position: relative; flex: 0 1 340px; min-width: min(100%, 280px); gap: 12px; padding: 18px 20px;
  border-radius: var(--r-card); background: var(--sheet); border: 1px solid var(--line);
}
#form-ks h4 { font-size: 16px; font-weight: 500; line-height: 1.3; }
#form-ks .btn { margin-top: 4px; min-height: 56px; padding: 12px 28px; font-size: 16px; }

/* ---------------------------------------------------------- metrics */
.metrics {
  list-style: none; margin: 0; padding: 0; display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px;
}
.metric {
  display: flex; flex-direction: column; gap: 14px; min-width: 0; padding: 18px 20px;
  border-radius: var(--r-card); background: var(--surface); border: 1px solid var(--line);
}
.metric-head { display: flex; align-items: center; gap: 12px; }
.metric-label { flex: 1; min-width: 0; font-size: 14px; line-height: 1.2; color: var(--muted); }
.metric-value { font-size: 44px; font-weight: 300; line-height: 1; }
.metric-sub { font-size: 13px; line-height: 1.4; color: var(--muted); }
.metric-sub:empty { display: none; }
.lists { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; align-items: start; }

/* ------------------------------------------- panels, cards, tables */
.panel {
  display: flex; flex-direction: column; gap: 2px; padding: 18px 20px 8px;
  border-radius: var(--r-card); background: var(--surface); border: 1px solid var(--line);
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-bottom: 10px; }
.panel-head h4 { font-size: 18px; font-weight: 500; line-height: 1.3; }
.rows { list-style: none; margin: 0; padding: 0; }
.rows > li {
  display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line);
}
#recent-executions > li { padding: 10px 0; }
.rows .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.rows .t { font-size: 15px; font-weight: 600; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rows .t.normal { font-weight: 400; }
.rows .t.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 14px; }
.rows .s { font-size: 12px; line-height: 1.3; color: var(--muted); overflow-wrap: anywhere; }
.rows .when { flex: none; font-size: 13px; color: var(--muted); }
.rows .pill { min-height: 26px; padding: 0 10px; }
.panel > .empty { border: 0; padding: 24px 0 28px; }

.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.cards.health { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.card {
  display: flex; flex-direction: column; gap: 6px; padding: 18px 20px;
  border-radius: var(--r-card); background: var(--surface); border: 1px solid var(--line);
  overflow-wrap: anywhere;
}
.card .t { font-size: 18px; font-weight: 500; line-height: 1.25; }
.card .s { font-size: 15px; line-height: 1.45; color: var(--muted); }
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; }
.card-head .t { flex: 1 1 auto; min-width: 0; }
.error-text { color: var(--bad); }
.alert-card .t { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.alert-card .pill { min-height: 26px; padding: 0 10px; }
.cards.health .card { gap: 16px; }
.cards.health .card .t { font-size: 20px; font-weight: 600; }
.cards.health .card .s { font-size: 14px; }
.cards.health .pill { min-height: 28px; }
.event-payload-toggle { align-self: flex-start; min-height: 36px; padding: 6px 14px; }

.table-wrap {
  overflow: hidden; overflow: clip; border-radius: var(--r-card);
  background: var(--surface); border: 1px solid var(--line);
}
.table-wrap:has(tbody:empty) { display: none; }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th {
  position: sticky; top: 0; z-index: 2; height: 44px; padding: 0 20px; text-align: left;
  background: var(--head); border-bottom: 1px solid var(--line); color: var(--muted);
  font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; white-space: nowrap;
}
td { height: 64px; padding: 14px 20px; border-top: 1px solid var(--line); vertical-align: middle; min-width: 0; overflow-wrap: anywhere; }
tbody tr:first-child td { border-top: 0; }
td .cell-line { display: flex; align-items: center; gap: 10px; min-width: 0; }
td .sub { display: block; margin-top: 2px; font-size: 13px; line-height: 1.3; color: var(--muted); }
td .sub.bad { color: var(--bad); font-weight: 600; }
td.bad { color: var(--bad); font-weight: 600; }
td .row { flex-wrap: nowrap; }
td .row .select-wrap, td .row select { flex: 1 1 auto; }
td .row .btn { flex: none; min-height: 40px; padding: 8px 16px; }
td.num { text-align: right; }
@media (hover: hover) {
  .table-wrap tbody tr:hover { background: var(--hover); }
}
.table-wrap tr.stale td, .table-wrap tr.stale:hover td { background: var(--bad-bg); }

.empty {
  padding: 56px 24px; border-radius: var(--r-card); background: var(--surface);
  border: 1px solid var(--line); text-align: center; font-size: 20px; font-weight: 500;
  line-height: 1.25; text-wrap: balance;
}

/* -------------------------------------------- confirmations, toast */
.confirm {
  position: fixed; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center;
  padding: 24px; background: var(--scrim);
}
.confirm-card {
  width: 100%; max-width: 480px; display: flex; flex-direction: column; gap: 18px;
  padding: 28px 24px 24px; border-radius: var(--r-hero); background: var(--sheet);
  border: 1px solid var(--line);
}
.confirm-card p { font-size: 26px; font-weight: 300; line-height: 1.15; text-wrap: pretty; }
.confirm .row { display: grid; grid-template-columns: 1fr 1fr; flex-wrap: nowrap; }
.confirm .row .btn { min-height: 52px; font-size: 16px; }
.confirm .row .btn.danger { background: var(--bad); border-color: transparent; color: var(--on-danger); }
/* The dot carries the color of what the toast says: done (ok), refused (bad)
   or only worth knowing (info); it glows like the prototype's. */
.toast {
  --tone: var(--muted);
  position: fixed; right: 24px; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 50;
  display: flex; align-items: center; gap: 12px; max-width: min(420px, calc(100vw - 32px));
  padding: 14px 18px; border-radius: 18px; background: var(--sheet); border: 1px solid var(--line);
  box-shadow: 0 20px 50px rgba(0, 0, 0, .35); color: var(--text); font-size: 15px; line-height: 1.4;
}
.toast::before {
  content: ""; flex: none; width: 8px; height: 8px; border-radius: 50%;
  background: var(--tone); box-shadow: 0 0 12px var(--tone);
}
.toast.ok { --tone: var(--ok); }
.toast.bad { --tone: var(--bad); }
.toast.info { --tone: var(--info); }

/* ------------------------------------------------------- skeletons */
.skeleton { display: flex; flex-direction: column; gap: 12px; }
.skeleton:not([hidden]) + .table-wrap, .skeleton:not([hidden]) + .cards { display: none; }
.sk-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.sk { display: block; border-radius: var(--r-card); background: var(--surface-2); }
.sk-row { height: 64px; border-radius: 18px; }
.sk-card { height: 150px; }

/* ------------------------------------------------------------ login */
.login {
  position: relative; overflow: hidden; display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 16px; padding: 16px;
}
.brand-side {
  position: relative; overflow: hidden; display: flex; flex-direction: column;
  justify-content: space-between; padding: 40px; border-radius: 28px;
  background: var(--surface); border: 1px solid var(--line);
}
.brand-side::before {
  content: ""; position: absolute; left: -10%; right: -10%; bottom: -160px; height: 320px;
  background: var(--spectrum); filter: blur(70px); opacity: var(--glow); pointer-events: none;
}
.brand-side::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 6px; background: var(--spectrum); }
.brand-side > * { position: relative; }
.brand-side .brand { display: flex; align-items: center; gap: 12px; }
.brand-side .brand-mark { width: 44px; height: 44px; border-radius: 15px; }
.brand-side .brand-name { font-size: 20px; }
.brand-headline {
  font-size: clamp(40px, 5vw, 64px); font-weight: 300; line-height: 1; letter-spacing: -.02em;
  padding-bottom: 40px; overflow-wrap: anywhere;
}
.brand-mobile { display: none; }
.login-body {
  position: relative; display: flex; flex-direction: column; justify-content: center; gap: 22px;
  padding: 40px 0;
}
.login-body > * { width: 100%; max-width: 420px; margin-left: auto; margin-right: auto; }
.login-body form { gap: 22px; }
.display { font-size: 40px; font-weight: 300; line-height: 1.05; letter-spacing: -.01em; }

/* ----------------------------------------------------------- motion */
@media (prefers-reduced-motion: no-preference) {
  .btn, .nav-item, .side-btn, .sheet-item, .switch {
    transition: background-color .2s, border-color .2s, color .2s, opacity .2s, transform .12s;
  }
  .btn:active { transform: scale(.98); }
  .btn[disabled] { animation: pulse 1.2s ease-in-out infinite; }
  .sk { animation: sk 1.4s ease-in-out infinite; }
  .updated:not(:empty)::before { animation: blink 2s infinite; }
}
@keyframes pulse { 0%, 100% { opacity: .4 } 50% { opacity: .8 } }
@keyframes sk { 0%, 100% { opacity: .45 } 50% { opacity: 1 } }
@keyframes blink { 0%, 100% { opacity: 1 } 50% { opacity: .35 } }

/* ------------------------------------------------- narrow and mobile */
/* Below 1250px a table no longer fits its columns and becomes a list of
   cards. The column name of each cell is read from data-label (set by app.js). */
@media (max-width: 1249px) {
  .table-wrap { overflow: visible; border: 0; background: none; border-radius: 0; }
  .table-wrap table, .table-wrap tbody { display: block; }
  .table-wrap thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .table-wrap tr {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px 16px;
    align-items: start; padding: 16px; margin-bottom: 10px;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card);
  }
  .table-wrap tbody tr:last-child { margin-bottom: 0; }
  .table-wrap td { display: block; height: auto; border: 0; padding: 0; }
  .table-wrap td::before {
    content: attr(data-label); display: block; margin-bottom: 4px; font-size: 12px; color: var(--muted);
  }
  .table-wrap td:first-child, .table-wrap td:last-child { grid-column: 1 / -1; }
  .table-wrap td:first-child::before, .table-wrap td:last-child::before { content: none; }
  .table-wrap tbody tr:hover td, .table-wrap tbody tr.stale td, .table-wrap tr.stale:hover td { background: none; }
  @media (hover: hover) {
    .table-wrap tbody tr:hover { background: var(--hover); }
  }
  .table-wrap tr.stale { border-color: var(--bad); }
  .table-wrap td .row { flex-wrap: wrap; }
  .table-wrap td .row .select-wrap, .table-wrap td .row select { flex: 1 1 160px; }
  .table-wrap td .row .btn { flex: 1 1 0; }
}

@media (max-width: 959px) {
  .login { grid-template-columns: minmax(0, 1fr); padding: 0; }
  .login::before {
    content: ""; position: absolute; top: -120px; left: -60px; right: -60px; height: 340px;
    background: var(--spectrum); filter: blur(90px); opacity: var(--glow); pointer-events: none;
  }
  .brand-side { display: none; }
  .brand-mobile { display: flex; align-items: center; gap: 10px; padding-bottom: 18px; }
  .brand-mobile .brand-tag { height: 28px; font-size: 12px; }
  .login-body { justify-content: flex-start; padding: calc(44px + env(safe-area-inset-top)) 24px 28px; }
  /* The sidebar leaves too little for four numbers across. */
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 759px) {
  body { display: block; }
  /* The sidebar becomes a top bar, a bottom tab bar and the "Más" sheet. */
  .side { position: static; width: auto; height: auto; padding: 0; border: 0; overflow: visible; display: contents; }
  #bar .brand {
    position: fixed; top: 0; left: 0; right: 0; z-index: 30; height: calc(60px + env(safe-area-inset-top));
    align-items: center; gap: 10px; padding: env(safe-area-inset-top) 12px 0 16px;
    background: var(--bar); backdrop-filter: blur(14px); border-bottom: 1px solid var(--line);
  }
  #bar .brand-mark { width: 34px; height: 34px; border: 0; border-radius: 12px; }
  #bar .brand-mark .ico { width: 18px; height: 18px; }
  #bar .brand-name { flex: 1; font-size: 16px; }
  #bar .brand-tag { height: 28px; }
  .side-foot { display: none; }
  .nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid;
    grid-template-columns: repeat(5, 1fr); height: calc(78px + env(safe-area-inset-bottom));
    padding: 6px 4px calc(14px + env(safe-area-inset-bottom));
    background: var(--bar); backdrop-filter: blur(14px); border-top: 1px solid var(--line);
  }
  .nav-item {
    flex-direction: column; justify-content: center; gap: 4px; height: auto; padding: 0;
    border-radius: 0; font-size: 11px; text-align: center;
  }
  .nav-item span { flex: none; }
  /* The icon sits in a pill: filled on the tab that is on screen, and again
     under the pointer. */
  .nav-item .ico { width: 52px; height: 30px; padding: 4.5px 15.5px; border-radius: 999px; }
  .nav-item[data-view="clientes"], .nav-item[data-view="ejecuciones"],
  .nav-item[data-view="salud"], .nav-item[data-view="eventos"] { display: none; }
  .nav-item[aria-current="page"], .nav-item.open { background: transparent; }
  .nav-item[aria-current="page"] .ico, .nav-item.open .ico { background: var(--surface-2); }
  @media (hover: hover) {
    .nav-item:hover { background: transparent; color: var(--text); }
    .nav-item:hover .ico { background: var(--surface-2); }
  }
  .nav-more { display: flex; }
  .more-sheet {
    position: fixed; left: 10px; right: 10px; bottom: calc(88px + env(safe-area-inset-bottom)); z-index: 35;
    display: flex; flex-direction: column; gap: 2px; padding: 22px 12px 12px;
    border-radius: var(--r-hero); background: var(--sheet); border: 1px solid var(--line);
    box-shadow: 0 20px 50px rgba(0, 0, 0, .35);
  }
  .more-sheet::before {
    content: ""; position: absolute; top: 10px; left: 50%; width: 40px; height: 4px; margin-left: -20px;
    border-radius: 2px; background: var(--line-2);
  }
  .sheet-item { height: 52px; padding: 0 14px; border-radius: 16px; gap: 14px; font-size: 16px; }

  #view-dashboard {
    padding: calc(20px + 60px + env(safe-area-inset-top)) 16px calc(32px + 78px + env(safe-area-inset-bottom));
    gap: 12px;
  }
  .page-head h3 { font-size: 32px; }
  .hero { padding: 22px 20px 30px; }
  .hero-word { font-size: 44px; }
  #form-ks { flex: 1 1 100%; }
  .lists { grid-template-columns: minmax(0, 1fr); }
  .confirm { align-items: flex-end; padding: 10px; }
  .confirm .row { grid-template-columns: 1fr; }
  .toast { left: 16px; right: 16px; bottom: auto; top: calc(72px + env(safe-area-inset-top)); max-width: none; }
  .rows .when { display: none; }
}

@media (max-width: 360px) {
  #view-dashboard { padding-left: 12px; padding-right: 12px; }
  .login-body { padding-left: 20px; padding-right: 20px; }
  .metric { padding: 14px; }
  .metric-value { font-size: 36px; }
}

/* ----------------------------------------------- theme button (corner) */
.theme-btn {
  position: fixed; right: 20px; bottom: 20px; z-index: 30; width: 44px; height: 44px;
  padding: 0; display: grid; place-items: center; border-radius: 50%; cursor: pointer;
  border: 1px solid var(--line-2); background: var(--sheet); color: var(--text);
  box-shadow: 0 6px 20px rgba(0, 0, 0, .25);
}
.theme-btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
.theme-btn .theme-sun { display: none; }
:root[data-theme="light"] .theme-btn .theme-sun { display: block; }
:root[data-theme="light"] .theme-btn .theme-moon { display: none; }
@media (max-width: 759px) {
  .theme-btn { bottom: calc(88px + env(safe-area-inset-bottom)); right: 14px; }
}

/* ------------------------------------------------ lists as glass cards */
/* Every list is a stack of cards, as in the prototype: a translucent sheet with
   a soft shadow, the fields of a row side by side under their small labels. */
:root { --shadow: 0 14px 34px rgba(0, 0, 0, .38), inset 0 1px 0 rgba(255, 255, 255, .05); }
:root[data-theme="light"] { --shadow: 0 12px 32px rgba(40, 40, 80, .09), inset 0 1px 0 rgba(255, 255, 255, .8); }
.card, .panel, .metric, .empty, .table-wrap tbody tr {
  box-shadow: var(--shadow); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
}

.table-wrap { overflow: visible; background: none; border: 0; border-radius: 0; }
.table-wrap table, .table-wrap tbody { display: block; }
.table-wrap thead { display: none; }
.table-wrap tbody { display: grid; gap: 14px; }
.table-wrap tbody tr {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 16px 24px;
  align-items: start; padding: 20px 24px; border-radius: var(--r-card);
  background: var(--surface); border: 1px solid var(--line);
}
.table-wrap td {
  display: block; height: auto; min-width: 0; padding: 0; border: 0;
}
.table-wrap td::before {
  content: attr(data-label); display: block; margin-bottom: 6px; font-size: 13px; color: var(--muted);
}
.table-wrap tbody tr:first-child td { border-top: 0; }
.table-wrap tr.stale, .table-wrap tr.stale td { background: var(--bad-bg); }
#accounts-body td:first-child, #accounts-body td:last-child,
#executions-body td:first-child, #signals-list td:first-child { grid-column: 1 / -1; }
#accounts-body td:first-child::before, #accounts-body td:last-child::before,
#executions-body td:first-child::before, #signals-list td:first-child::before { display: none; }
#accounts-body td:last-child .btn { width: 100%; min-height: 48px; border-radius: 999px; }
#accounts-body td:first-child .cell-line span:first-child { font-size: 20px; font-weight: 600; }
.mono, .mono-strong { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.mono-strong { font-size: 16px; font-weight: 600; }
td.mono { font-size: 13px; color: var(--muted); }
.stack { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stack .sub { margin-top: 0; }
td .cell-line .tile { width: 34px; height: 34px; border-radius: 11px; }

/* ------------------------------------------------- search and pills */
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.filters .search {
  position: relative; flex: 1 1 280px; min-width: 0; display: flex; align-items: center;
}
.filters .search .ico { position: absolute; left: 18px; width: 20px; height: 20px; color: var(--muted); pointer-events: none; }
.filters .search input {
  width: 100%; height: 52px; padding: 0 20px 0 48px; border-radius: 999px; color: var(--text);
  background: var(--field); border: 1px solid var(--line); font: inherit; font-size: 16px;
  box-shadow: var(--shadow);
}
.filters .search input:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.pills { display: flex; flex-wrap: wrap; gap: 10px; }
.pill-btn {
  display: inline-flex; align-items: center; gap: 8px; height: 42px; padding: 0 18px; border-radius: 999px;
  border: 1px solid var(--line-2); background: var(--field); color: var(--text); cursor: pointer;
  font: inherit; font-size: 15px; font-weight: 600; box-shadow: var(--shadow);
}
.pill-btn[aria-pressed="true"] { background: var(--primary); color: var(--on-primary); border-color: transparent; }
.pill-btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.ok { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.dot.warn { background: var(--warn); box-shadow: 0 0 8px var(--warn); }
.dot.bad { background: var(--bad); box-shadow: 0 0 8px var(--bad); }
.pill > .dot { width: 7px; height: 7px; }

/* ---------------------------------------------------- alerts, events */
.alert-card { flex-direction: row; align-items: flex-start; gap: 16px; }
.alert-card > .tile { width: 44px; height: 44px; border-radius: 14px; }
.alert-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.event-card { gap: 14px; }
.event-card .when { font-size: 14px; color: var(--muted); }
.event-meta { display: grid; grid-template-columns: minmax(120px, 160px) minmax(0, 1fr); gap: 16px 24px; align-items: start; }
.event-field { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; min-width: 0; }
.event-field .cell-line .tile { width: 34px; height: 34px; border-radius: 11px; }

/* --------------------------------------------------------- health bars */
.beat { display: flex; flex-direction: column; gap: 8px; }
.beat-top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 0; }
.beat-age { font-size: 15px; font-weight: 600; color: var(--text); }
.beat-age.bad { color: var(--bad); }
.bar { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.fill { display: block; height: 100%; width: 0; border-radius: 999px; background: var(--ok); }
.fill.bad { background: var(--bad); }
.fill[data-w="1"] { width: 10%; } .fill[data-w="2"] { width: 20%; } .fill[data-w="3"] { width: 30%; }
.fill[data-w="4"] { width: 40%; } .fill[data-w="5"] { width: 50%; } .fill[data-w="6"] { width: 60%; }
.fill[data-w="7"] { width: 70%; } .fill[data-w="8"] { width: 80%; } .fill[data-w="9"] { width: 90%; }
.fill[data-w="10"] { width: 100%; }
.beat-scale { display: flex; justify-content: space-between; margin: 0; font-size: 12px; color: var(--muted); }
.cards.health .card { gap: 20px; }
@media (max-width: 759px) {
  .event-meta { grid-template-columns: minmax(0, 1fr); }
  .table-wrap tbody tr { padding: 16px 18px; }
}
.event-field .cell-line { display: flex; align-items: center; gap: 10px; min-width: 0; }
.nav-badge {
  flex: none; min-width: 22px; height: 22px; margin-left: auto; padding: 0 7px; border-radius: 999px;
  display: grid; place-items: center; font-size: 12px; font-weight: 700; color: var(--bad); background: var(--bad-bg);
}
.nav-badge[hidden] { display: none; }
