@font-face { font-family: 'Archivo'; src: url('fuentes/archivo.woff2') format('woff2'); font-weight: 700 900; font-display: swap; }
@font-face { font-family: 'Inter'; src: url('fuentes/inter.woff2') format('woff2'); font-weight: 400 700; font-display: swap; }
:root {
  --bg: #f8fafc;              /* colores de la marca: azul noche y grises azulados */
  --card: #ffffff;
  --text: #1E293B;
  --muted: #475569;
  --line: #e2e8f0;
  --brand: #172554;
  --brand-ink: #ffffff;
  --brand-soft: #e8eefa;
  --title: #172554;
  --ok: #1d4ed8;               /* estado bueno en azul de la marca, no en verde */
  --ok-soft: #dbeafe;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --bad: #b91c1c;
  --bad-soft: #fee2e2;
  --idle: #475569;
  --idle-soft: #e2e8f0;
  --radius: 14px;
  --shadow: 0 1px 2px rgb(0 0 0 / .05), 0 4px 16px rgb(0 0 0 / .04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1120; --card: #131d33; --text: #e2e8f0; --muted: #94a3b8; --line: #1f2a44;
    --brand: #60A5FA; --brand-ink: #0b1120; --brand-soft: #16233f; --title: #eef2ff;
    --ok: #60A5FA; --ok-soft: #16233f; --warn: #fbbf24; --warn-soft: #3a2c0b;
    --bad: #f87171; --bad-soft: #3b1414; --idle: #a5b4c3; --idle-soft: #232c35;
    --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b1120; --card: #131d33; --text: #e2e8f0; --muted: #94a3b8; --line: #1f2a44;
  --brand: #60A5FA; --brand-ink: #0b1120; --brand-soft: #16233f; --title: #eef2ff;
  --ok: #60A5FA; --ok-soft: #16233f; --warn: #fbbf24; --warn-soft: #3a2c0b;
  --bad: #f87171; --bad-soft: #3b1414; --idle: #a5b4c3; --idle-soft: #232c35;
  --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.45 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
a { color: var(--brand); }
h1, h2 { font-family: Archivo, Inter, system-ui, sans-serif; color: var(--title); }
h1 { font-size: 1.6rem; font-weight: 800; margin: .2rem 0 1rem; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; font-weight: 700; margin: 1.6rem 0 .6rem; }
p { margin: .4rem 0; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.center { text-align: center; }
[hidden] { display: none !important; }

.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; gap: 8px; align-items: center; font-weight: 700; color: var(--text); text-decoration: none; }
.brand img.logo { height: 24px; width: auto; }
.brand .logo-oscuro { display: none; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .brand .logo-claro { display: none; } :root:not([data-theme="light"]) .brand .logo-oscuro { display: block; } }
:root[data-theme="dark"] .brand .logo-claro { display: none; }
:root[data-theme="dark"] .brand .logo-oscuro { display: block; }
main { max-width: 640px; margin: 0 auto; padding: 16px; }

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 5; display: flex; justify-content: space-around;
  background: var(--card); border-top: 1px solid var(--line); padding: 6px 0 calc(6px + env(safe-area-inset-bottom));
}
.tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: .75rem;
  color: var(--muted); text-decoration: none; padding: 4px 0;
}
.tabbar a.on { color: var(--brand); font-weight: 600; }
.tabbar svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; margin-bottom: 12px;
}
a.card { display: block; color: inherit; text-decoration: none; }
a.card:active { transform: scale(.99); }
.row { display: flex; align-items: center; gap: 12px; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.row > h1, .row > h2 { margin-bottom: .6rem; }
.row:has(> h2) { align-items: baseline; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px;
  font-size: .8rem; font-weight: 600; white-space: nowrap;
}
.chip::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.chip.listening { color: var(--ok); background: var(--ok-soft); }
.chip.sleeping { color: var(--idle); background: var(--idle-soft); }
.chip.offline { color: var(--bad); background: var(--bad-soft); }
.chip.never { color: var(--warn); background: var(--warn-soft); }

.battery { display: inline-flex; align-items: center; gap: 6px; font-size: .875rem; color: var(--muted); }
.battery i { position: relative; width: 26px; height: 13px; border: 2px solid currentColor; border-radius: 3px; }
.battery i::after { content: ""; position: absolute; right: -5px; top: 2px; width: 3px; height: 5px; background: currentColor; border-radius: 0 1px 1px 0; }
.battery b { position: absolute; inset: 1px; right: auto; border-radius: 1px; background: var(--ok); }
.battery.low b { background: var(--bad); }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line); border-radius: 12px; overflow: hidden; }
.stats div { background: var(--card); padding: 10px 12px; }
.stats dt { font-size: .75rem; color: var(--muted); }
.stats dd { margin: 2px 0 0; font-weight: 600; overflow-wrap: anywhere; }

button, .btn {
  font: inherit; border: 0; border-radius: 12px; padding: 12px 16px; cursor: pointer;
  background: var(--brand-soft); color: var(--brand); font-weight: 600; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px;
}
button.primary, .btn.primary { background: var(--brand); color: var(--brand-ink); }
button.danger { background: var(--bad-soft); color: var(--bad); }
button.block, .btn.block { width: 100%; }
button.link { background: none; padding: 4px 8px; min-height: 0; color: var(--muted); font-weight: 500; }
button:disabled { opacity: .45; cursor: not-allowed; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 45%, transparent); outline-offset: 2px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-row > * { flex: 1; }

.open-btn {
  width: 100%; min-height: 72px; font-size: 1.15rem; border-radius: 18px;
  background: var(--brand); color: var(--brand-ink);
}

label { display: block; font-size: .875rem; font-weight: 600; margin: 12px 0 4px; }
input, select, textarea {
  font: inherit; width: 100%; padding: 11px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text); min-height: 46px;
}
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 500; margin: 14px 0 4px; }
.check input { width: 22px; height: 22px; min-height: 0; accent-color: var(--brand); }
.hint { font-size: .8rem; color: var(--muted); margin-top: 4px; }
.error { color: var(--bad); font-size: .9rem; margin-top: 8px; }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; }
/* Listas largas (reservas, actividad): se desplazan dentro de su tarjeta para que la página no se haga eterna */
.list.scroll { max-height: 21rem; overflow-y: auto; overscroll-behavior: contain; margin-right: -8px; padding-right: 8px; }
.date-badge {
  flex: none; width: 50px; text-align: center; border-radius: 10px; background: var(--brand-soft); color: var(--brand); padding: 4px 0;
  line-height: 1.1;
}
.date-badge b { display: block; font-size: 1.2rem; }
.date-badge span { font-size: .7rem; text-transform: uppercase; font-weight: 600; }
.tag { font-size: .7rem; font-weight: 600; text-transform: uppercase; color: var(--muted); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; }

.card.status { display: flex; gap: 12px; align-items: flex-start; }
.card.status p { margin: 2px 0 0; }
.status-icon {
  flex: none; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  font-weight: 700; font-size: 1rem; line-height: 1;
}
.status.ok .status-icon { background: var(--ok-soft); color: var(--ok); }
.status.idle .status-icon { background: var(--idle-soft); color: var(--idle); }
.status.warn .status-icon { background: var(--warn-soft); color: var(--warn); }
.status.bad .status-icon { background: var(--bad-soft); color: var(--bad); }
.status.bad, .status.warn { border-color: transparent; }
.status.bad { background: var(--bad-soft); }
.status.warn { background: var(--warn-soft); }
.card.warn { background: var(--warn-soft); border-color: transparent; color: var(--text); }
.card.warn b { color: var(--warn); }

.seg { display: flex; gap: 8px; margin: 12px 0 4px; }
.seg label { flex: 1; margin: 0; display: flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line); border-radius: 10px; padding: 10px; font-weight: 500; cursor: pointer; }
.seg label:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }
.seg input { accent-color: var(--brand); }
input[type=range] { padding: 0; min-height: 36px; accent-color: var(--brand); background: none; border: 0; }
.meter { position: relative; height: 22px; border-radius: 11px; background: var(--bg); border: 1px solid var(--line); overflow: hidden; margin: 10px 0 6px; }
.meter-fill { height: 100%; width: 0; background: var(--idle); transition: width .3s; }
.meter-fill.over { background: var(--ok); }
.meter-mark { position: absolute; top: -2px; bottom: -2px; width: 3px; background: var(--bad); transform: translateX(-1px); }

.empty { text-align: center; padding: 28px 12px; color: var(--muted); }

details.card summary { cursor: pointer; font-weight: 600; list-style: none; display: flex; justify-content: space-between; }
details.card summary::after { content: "›"; transform: rotate(90deg); transition: transform .15s; }
details.card[open] summary::after { transform: rotate(-90deg); }

.steps { display: flex; gap: 6px; margin-bottom: 16px; }
.steps span { flex: 1; height: 4px; border-radius: 4px; background: var(--line); }
.steps span.on { background: var(--brand); }
.code-big {
  font: 700 2.4rem/1 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: .15em; text-align: center;
  padding: 18px; background: var(--brand-soft); color: var(--brand); border-radius: var(--radius); margin: 12px 0;
}
ol.howto { padding-left: 1.2rem; }
ol.howto li { margin: 8px 0; }
.spinner { width: 18px; height: 18px; border: 3px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

pre, code.key {
  font: .82rem/1.5 ui-monospace, "SF Mono", Menlo, monospace; background: var(--bg); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; overflow-x: auto; white-space: pre; margin: 6px 0;
}
code.key { display: block; white-space: normal; word-break: break-all; }

dialog {
  border: 0; border-radius: 18px 18px 0 0; padding: 0; width: 100%; max-width: 640px; margin: auto auto 0;
  background: var(--card); color: var(--text); max-height: 92vh;
}
@media (min-width: 700px) { dialog { border-radius: 18px; margin: auto; } }
dialog::backdrop { background: rgb(0 0 0 / .4); }
dialog form { padding: 20px 16px calc(16px + env(safe-area-inset-bottom)); }
dialog h2 { margin-top: 0; }

#toast {
  position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: .9rem;
  opacity: 0; pointer-events: none; transition: .2s; max-width: calc(100% - 32px); z-index: 20;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Días de la semana en el formulario de invitados */
.seg.dias { gap: 4px; }
.seg.dias label { padding: 8px 0; min-width: 0; }
.seg.dias input { position: absolute; opacity: 0; pointer-events: none; }
a.btn { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
