/* Services Aldenor — hoja de estilos
   Tokens: superficie fría de laboratorio, tinta azul pizarra, acento petróleo,
   ámbar solo para "hoy". El color fuerte vive en los estados. */

:root {
  --bg: #EEF1F3;
  --surface: #FFFFFF;
  --surface-2: #F6F8F9;
  --ink: #16212B;
  --ink-2: #4A5A68;
  --ink-3: #7D8B97;
  --rule: #D5DCE2;
  --rule-2: #E6EAEE;
  --accent: #0B5D6B;
  --accent-ink: #FFFFFF;
  --accent-soft: #DCEDEF;
  --today: #E8A317;
  --danger: #A3343A;
  --focus: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent);
  --r-sm: 4px;
  --r: 7px;
  --side: 212px;
  --font: "Atkinson Hyperlegible Next", "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0F1519; --surface: #172026; --surface-2: #1C262D; --ink: #E4EAEE; --ink-2: #A9B6C0; --ink-3: #7A8892;
    --rule: #2C3943; --rule-2: #24303A; --accent: #3BA7B8; --accent-ink: #06191C; --accent-soft: #163840;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0F1519; --surface: #172026; --surface-2: #1C262D; --ink: #E4EAEE; --ink-2: #A9B6C0; --ink-3: #7A8892;
  --rule: #2C3943; --rule-2: #24303A; --accent: #3BA7B8; --accent-ink: #06191C; --accent-soft: #163840;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 15px/1.45 var(--font);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.2; font-weight: 700; }
h1 { font-size: 1.6rem; letter-spacing: -0.01em; }
h2 { font-size: 1.05rem; }
a { color: var(--accent); }
code, pre { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .85em; }
pre.code { background: var(--surface-2); border: 1px solid var(--rule); padding: 10px 12px; border-radius: var(--r-sm); overflow-x: auto; }
small, .small { font-size: .82rem; }
.muted { color: var(--ink-2); }
.num { font-weight: 700; letter-spacing: .01em; white-space: nowrap; }
.mono-ish { font-variant-numeric: tabular-nums slashed-zero; letter-spacing: .02em; }
.nowrap { white-space: nowrap; }
.r { text-align: right; }
.hint, .bar-hint { color: var(--ink-3); font-size: .82rem; margin: 6px 0 0; }
.loading, .empty { color: var(--ink-3); padding: 18px 4px; }
:focus-visible { outline: none; box-shadow: var(--focus); }
[hidden] { display: none !important; }
.boot { padding: 40px; color: var(--ink-3); }

/* ── Controles ─────────────────────────────────────────────── */
input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea {
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-sm);
  padding: 7px 9px; min-width: 0; width: 100%;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: var(--focus); outline: none; }
input.bound { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 40%, var(--rule)); }
input[type="checkbox"] { width: auto; accent-color: var(--accent); }
.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  border: 1px solid var(--rule); background: var(--surface); border-radius: var(--r-sm);
  padding: 7px 14px; cursor: pointer; font-weight: 600; white-space: nowrap; text-decoration: none; color: var(--ink);
}
.btn:hover { border-color: var(--ink-3); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.small { padding: 4px 10px; font-size: .85rem; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: default; }
.danger-text { color: var(--danger); }
.icon-btn { padding: 4px 10px; font-size: 1.3rem; line-height: 1; }
.link { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
button.icon { background: none; border: 0; font-size: 1.4rem; line-height: 1; color: var(--ink-3); cursor: pointer; padding: 2px 6px; border-radius: var(--r-sm); }
button.icon:hover { color: var(--ink); background: var(--surface-2); }
kbd { font: 600 .72rem var(--font); border: 1px solid color-mix(in srgb, currentColor 40%, transparent); border-radius: 3px; padding: 0 5px; opacity: .8; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > span { font-size: .8rem; color: var(--ink-2); font-weight: 600; }
.field.end { justify-content: flex-end; }
.req { color: var(--danger); font-weight: 700; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--rule); background: var(--surface);
  border-radius: 999px; padding: 3px 11px; cursor: pointer; font-size: .86rem; font-weight: 600;
}
.chip.on, .chip:has(input:checked) { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.pill {
  display: inline-block; font-size: .76rem; font-weight: 700; padding: 1px 8px; border-radius: 999px; white-space: nowrap;
  color: var(--c); background: color-mix(in srgb, var(--c) 13%, transparent); border: 1px solid color-mix(in srgb, var(--c) 30%, transparent);
}
.seg { display: inline-flex; border: 1px solid var(--rule); border-radius: var(--r-sm); overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 5px 12px; cursor: pointer; font-weight: 600; font-size: .86rem; }
.seg button + button { border-left: 1px solid var(--rule); }
.seg button.on { background: var(--ink); color: var(--surface); }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: .86rem; color: var(--ink-2); white-space: nowrap; }
.switch { position: relative; display: inline-block; width: 38px; height: 22px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--rule); border-radius: 999px; cursor: pointer; transition: background .15s; }
.switch span::before { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform .15s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::before { transform: translateX(16px); }
.switch input:focus-visible + span { box-shadow: var(--focus); }

/* ── Acceso ────────────────────────────────────────────────── */
.gate { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.gate-card {
  width: min(400px, 100%); background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r);
  padding: 28px; display: flex; flex-direction: column; gap: 14px;
}
.gate-card h1 { font-size: 1.35rem; }
.form-error { color: var(--danger); margin: 0; min-height: 1.2em; font-size: .9rem; }
.demo-note { font-size: .84rem; background: var(--surface-2); border: 1px dashed var(--rule); padding: 10px 12px; border-radius: var(--r-sm); color: var(--ink-2); }
.demo-note .link { display: block; margin-top: 6px; }
.brand-lock { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand-lock .mark {
  width: 34px; height: 34px; border-radius: 8px; background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; font-weight: 700; font-size: 1.1rem;
}
.brand-lock strong { display: block; font-size: 1rem; }
.brand-lock small { color: var(--ink-3); }

/* ── Estructura ────────────────────────────────────────────── */
#shell { display: grid; grid-template-columns: var(--side) minmax(0, 1fr); grid-template-rows: auto 1fr; min-height: 100vh; }
.side {
  grid-row: 1 / 3; position: sticky; top: 0; height: 100vh; background: var(--surface); border-right: 1px solid var(--rule);
  display: flex; flex-direction: column; padding: 16px 10px; gap: 22px;
}
.side .brand-lock { padding: 0 8px; }
#nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
#nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r-sm);
  color: var(--ink-2); text-decoration: none; font-weight: 600;
}
#nav a svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
#nav a:hover { background: var(--surface-2); color: var(--ink); }
#nav a.on { background: var(--accent-soft); color: var(--accent); }
#userbox { border-top: 1px solid var(--rule-2); padding: 12px 8px 0; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.me { display: flex; gap: 10px; align-items: center; }
.me strong { display: block; font-size: .9rem; }
.me small { color: var(--ink-3); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--ink); color: var(--surface); display: grid; place-items: center; font-weight: 700; flex: none; }
.top {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px;
  padding: 10px 24px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--rule-2);
}
.searchwrap { position: relative; flex: 1; max-width: 520px; }
.searchwrap input { background: var(--surface); }
.gresults:not(:empty) {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; background: var(--surface); border: 1px solid var(--rule);
  border-radius: var(--r); box-shadow: 0 12px 30px -10px rgb(10 30 40 / .3); padding: 6px; z-index: 50; max-height: 70vh; overflow: auto;
}
.gresults h4 { font-size: .75rem; color: var(--ink-3); padding: 6px 8px 2px; font-weight: 600; }
.gresults a { display: flex; gap: 8px; align-items: baseline; padding: 7px 8px; border-radius: var(--r-sm); color: var(--ink); text-decoration: none; flex-wrap: wrap; }
.gresults a:hover, .gresults a:focus { background: var(--accent-soft); box-shadow: none; }
.gresults small { color: var(--ink-3); }
.top .new { margin-left: auto; }
.top .new span { font-size: 1.2rem; line-height: 1; }
main#view { padding: 22px 24px 60px; min-width: 0; outline: none; }
.page-head { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }
.page-head .resumen, .count-label { color: var(--ink-3); margin: 0; font-size: .9rem; }
.inline-select {
  width: auto; display: inline-block; font: inherit; font-weight: 700; color: var(--accent); background: transparent;
  border: 0; border-bottom: 2px dashed color-mix(in srgb, var(--accent) 45%, transparent); border-radius: 0; padding: 0 4px; cursor: pointer;
}
.inline-select:focus { box-shadow: none; border-bottom-style: solid; }
.empty-page { text-align: center; padding: 60px 20px; display: grid; gap: 14px; justify-items: center; }

/* ── Barra de alta rápida (fila de planilla) ───────────────── */
.quickbar {
  display: grid; grid-template-columns: 120px minmax(160px, 1.4fr) minmax(110px, 1fr) minmax(110px, 1fr) 120px minmax(150px, 1.5fr) auto;
  background: var(--surface); border: 1px solid var(--rule); border-left: 4px solid var(--accent); border-radius: var(--r);
  overflow: hidden;
}
.qcell { display: flex; flex-direction: column; border-right: 1px solid var(--rule-2); min-width: 0; }
.qcell > span { font-size: .72rem; font-weight: 600; color: var(--ink-3); padding: 6px 10px 0; }
.qcell input, .qcell select { border: 0; border-radius: 0; padding: 2px 10px 8px; background: transparent; box-shadow: none; }
.qcell:focus-within { background: var(--accent-soft); }
.qcell:focus-within > span { color: var(--accent); }
.qcell input.bound { background: transparent; color: var(--accent); font-weight: 600; }
.qactions { display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 2px; padding: 6px 12px; }

/* ── Secciones por estado ──────────────────────────────────── */
.secciones { display: flex; flex-direction: column; gap: 14px; margin-top: 18px; }
.sec { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r); overflow: hidden; }
.sec-head {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px; cursor: pointer; user-select: none;
  font-size: .98rem; border-left: 4px solid var(--c);
}
.sec-head:hover { background: var(--surface-2); }
.sec-head .count {
  margin-left: 2px; min-width: 24px; text-align: center; font-size: .78rem; padding: 1px 7px; border-radius: 999px;
  background: color-mix(in srgb, var(--c) 15%, transparent); color: var(--c); font-weight: 700;
}
.chev { width: 9px; height: 9px; border-right: 2px solid var(--ink-3); border-bottom: 2px solid var(--ink-3); transform: rotate(45deg); margin: -3px 2px 0; transition: transform .15s; }
.sec.col .chev { transform: rotate(-45deg); margin-top: 0; }
.sec.vacia .sec-head { color: var(--ink-3); }
.sec-empty { margin: 0; padding: 4px 18px 14px; color: var(--ink-3); font-size: .88rem; }
.sec .tablewrap { border-top: 1px solid var(--rule-2); }
.more-link { display: block; padding: 8px 14px; font-size: .86rem; border-top: 1px solid var(--rule-2); }

/* ── Tablas ────────────────────────────────────────────────── */
.tablewrap { overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; font-size: .9rem; }
.grid th { text-align: left; font-weight: 600; color: var(--ink-2); font-size: .78rem; padding: 8px 10px; background: var(--surface-2); border-bottom: 1px solid var(--rule); white-space: nowrap; }
.grid td { padding: 7px 10px; border-bottom: 1px solid var(--rule-2); vertical-align: middle; }
.grid tbody tr[data-n], .grid tbody tr[data-id] { cursor: pointer; }
.grid tbody tr[data-n]:hover, .grid tbody tr[data-id]:hover { background: var(--surface-2); }
.grid.compact td { padding: 6px 10px; }
.grid .clip { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.c-num { width: 1%; }
.c-est { width: 1%; }
.est-sel {
  width: auto; padding: 2px 6px; font-size: .8rem; font-weight: 700; border-radius: 999px;
  color: var(--c, var(--ink-2)); border-color: color-mix(in srgb, var(--c, var(--ink-3)) 35%, transparent);
  background: color-mix(in srgb, var(--c, var(--ink-3)) 10%, var(--surface));
}
.cell-in { border-color: transparent; background: transparent; padding: 4px 6px; }
.cell-in:hover { border-color: var(--rule); }
tr.inactivo td { opacity: .55; }

/* Lista tipo planilla */
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.filters > select { width: auto; }
.filters > input[type="search"] { flex: 1; min-width: 220px; }
.sheetwrap { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r); overflow: auto; max-height: calc(100vh - 220px); }
table.sheet { font-size: .86rem; }
.sheet th { position: sticky; top: 0; z-index: 2; }
.sheet td { border-right: 1px solid var(--rule-2); white-space: nowrap; }
.sheet td.clip { max-width: 200px; }
.sheet td.c-num { color: var(--accent); cursor: pointer; position: sticky; left: 0; background: var(--surface); z-index: 1; box-shadow: 1px 0 0 var(--rule); }
.sheet th.c-num { position: sticky; left: 0; z-index: 3; }
.sheet tfoot td.c-num { z-index: 3; }
.sheet tr.month td { position: sticky; left: 0; }
.sheet td.c-num:hover { text-decoration: underline; }
.sheet td.ed { cursor: text; }
.sheet td.ed:hover { background: var(--surface-2); }
.sheet tr.month td { background: var(--bg); font-weight: 700; color: var(--ink-2); font-size: .8rem; padding: 10px 10px 6px; border-right: 0; }
.sheet tr.month td::first-letter { text-transform: uppercase; }
.sheet tr.flash td { animation: flash 2.2s ease-out; }
@keyframes flash { from { background: color-mix(in srgb, var(--today) 35%, transparent); } }
.sheet tfoot td { position: sticky; bottom: 0; background: var(--surface); border-top: 2px solid var(--accent); padding: 4px; z-index: 2; }
.sheet tfoot input, .sheet tfoot select { padding: 5px 6px; font-size: .85rem; min-width: 90px; }
.sheet tfoot td:nth-child(4) input { min-width: 170px; }
.sheet .auto { font-size: .75rem; color: var(--accent); font-weight: 700; padding: 0 6px; }
.cell-edit { padding: 3px 5px; font-size: .86rem; min-width: 120px; }

/* ── Ficha de service ──────────────────────────────────────── */
.svc-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.back { font-size: .86rem; text-decoration: none; color: var(--ink-3); }
.back::before { content: "‹ "; }
.svc-num { font-size: 2.2rem; letter-spacing: .01em; margin-top: 2px; color: var(--ink); }
.svc-num::after { content: ""; display: block; height: 4px; width: 56px; background: var(--c, var(--accent)); margin-top: 6px; border-radius: 2px; }
.head-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.saved { color: var(--accent); font-size: .85rem; font-weight: 600; opacity: 0; transition: opacity .2s; }
.saved.on { opacity: 1; }
.estado-seg { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 18px; }
.estado-seg button {
  border: 1px solid var(--rule); background: var(--surface); border-radius: 999px; padding: 5px 12px; cursor: pointer;
  font-weight: 600; font-size: .85rem; color: var(--ink-2); display: inline-flex; align-items: center; gap: 7px;
}
.estado-seg button::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.estado-seg button:hover { border-color: var(--c); }
.estado-seg button.on { background: var(--c); border-color: var(--c); color: #fff; }
.estado-seg button.on::before { background: #fff; }
.svc-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.card { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r); padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; }
.card.wide { margin-bottom: 16px; }
.card > .btn { align-self: flex-start; }
.card h2 { font-size: .95rem; color: var(--ink-2); }
.eq-meta { display: flex; gap: 6px; align-items: baseline; font-size: .85rem; color: var(--ink-3); }
.eq-meta output { color: var(--ink); font-weight: 600; }
.eq-meta a { margin-left: auto; }
table.mat td { padding: 3px 4px; }
table.mat input { padding: 5px 7px; font-size: .88rem; }
table.mat td:first-child { min-width: 150px; }
table.mat td:nth-child(2) { min-width: 220px; }
table.mat td:nth-child(4), table.mat td:nth-child(5) { width: 100px; }
table.mat .tot { width: 110px; font-weight: 600; }
.presu-foot { display: flex; gap: 24px; align-items: flex-end; flex-wrap: wrap; justify-content: space-between; }
.presu-foot .grid3 { flex: 1; min-width: 300px; }
.totales { min-width: 260px; display: grid; gap: 4px; }
.totales div { display: flex; justify-content: space-between; gap: 18px; font-size: .92rem; }
.totales span { color: var(--ink-2); }
.totales .grand { border-top: 2px solid var(--ink); padding-top: 6px; font-size: 1.05rem; }

/* ── Ficha de equipo ───────────────────────────────────────── */
.eq-title { font-size: 1.9rem; margin-top: 2px; }
.eq-sub { margin: 4px 0 0; }
.hist { margin-top: 8px; }
.timeline { display: flex; flex-direction: column; gap: 0; border-left: 2px solid var(--rule); margin-left: 8px; }
.tl-item { display: grid; grid-template-columns: 120px 1fr; gap: 16px; padding: 12px 0 12px 20px; position: relative; }
.tl-item::before { content: ""; position: absolute; left: -7px; top: 18px; width: 12px; height: 12px; border-radius: 50%; background: var(--c); border: 2px solid var(--bg); }
.tl-date { color: var(--ink-2); font-weight: 600; font-size: .88rem; padding-top: 3px; }
.tl-body { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r); padding: 12px 14px; }
.tl-body h3 { font-size: 1rem; display: flex; gap: 10px; align-items: center; margin-bottom: 6px; }
.tl-body h3 a { text-decoration: none; }
.tl-body p { margin: 4px 0; }
.tl-mat { margin: 6px 0; padding-left: 18px; font-size: .88rem; }

/* ── Calendario ────────────────────────────────────────────── */
.cal-head { justify-content: space-between; align-items: center; }
.cal-nav { display: flex; align-items: center; gap: 6px; }
.cal-title { font-size: 1.5rem; margin-left: 10px; }
.cal-title::first-letter { text-transform: uppercase; }
.cal-tools { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.cal-layout { display: grid; grid-template-columns: minmax(0, 1fr) 250px; gap: 16px; align-items: start; }
.cal.mes { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r); overflow: hidden; }
.cal-dow { display: grid; grid-template-columns: repeat(7, 1fr); background: var(--surface-2); border-bottom: 1px solid var(--rule); }
.cal-dow div { padding: 6px 8px; font-size: .78rem; font-weight: 600; color: var(--ink-2); }
.cal-week { position: relative; min-height: calc(30px + var(--lanes) * 24px + 12px); border-bottom: 1px solid var(--rule-2); }
.cal-week:last-child { border-bottom: 0; }
.cal-days { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(7, 1fr); }
.cal-day { border-right: 1px solid var(--rule-2); padding: 4px 7px; }
.cal-day:last-child { border-right: 0; }
.cal-day.finde { background: color-mix(in srgb, var(--surface-2) 70%, transparent); }
.cal-day.fuera .dnum { color: var(--ink-3); opacity: .6; }
.cal-day.over { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); }
.dnum { font-size: .82rem; font-weight: 600; color: var(--ink-2); }
.cal-day.hoy .dnum { background: var(--today); color: #241800; border-radius: 999px; padding: 1px 7px; }
.cal-bars {
  position: absolute; left: 0; right: 0; top: 28px; display: grid; grid-template-columns: repeat(7, 1fr);
  grid-auto-rows: 22px; row-gap: 2px; pointer-events: none; padding: 0 3px;
}
.bar {
  pointer-events: auto; position: relative; margin: 0 2px; border-radius: 5px; padding: 0 8px; font-size: .78rem; line-height: 22px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: grab;
  background: color-mix(in srgb, var(--c) 16%, var(--surface)); color: var(--ink); border-left: 3px solid var(--c);
}
.bar:hover { background: color-mix(in srgb, var(--c) 26%, var(--surface)); }
.bar .num { color: var(--c); }
.bar.ci { border-top-left-radius: 0; border-bottom-left-radius: 0; margin-left: 0; border-left-style: dashed; }
.bar.cd { border-top-right-radius: 0; border-bottom-right-radius: 0; margin-right: 0; }
.bar .grip { position: absolute; right: 0; top: 0; bottom: 0; width: 8px; cursor: ew-resize; }
.bar .grip:hover { background: color-mix(in srgb, var(--c) 45%, transparent); }
.cal.dragging .bar { pointer-events: none; opacity: .6; }
.cal-side { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r); padding: 14px; position: sticky; top: 70px; max-height: calc(100vh - 90px); overflow: auto; }
.cal-side h2 { display: flex; align-items: center; gap: 8px; font-size: .95rem; }
.cal-side .count { font-size: .75rem; background: var(--surface-2); padding: 1px 7px; border-radius: 999px; color: var(--ink-2); }
.side-list { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.side-item { border: 1px solid var(--rule); border-left: 3px solid var(--c); border-radius: var(--r-sm); padding: 6px 9px; cursor: grab; display: grid; font-size: .85rem; background: var(--surface); }
.side-item:hover { border-color: var(--ink-3); border-left-color: var(--c); }
.side-item small { color: var(--ink-3); }
.side-item .num { font-size: .78rem; color: var(--c); }
.cal-side input[type="search"] { margin-top: 10px; }
.side-item { gap: 2px; }
.si-top { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.si-top .pill { font-size: .68rem; padding: 0 6px; }
.si-fecha { display: flex; align-items: center; gap: 6px; margin-top: 4px; font-size: .75rem; color: var(--ink-3); cursor: default; }
.si-fecha input { padding: 2px 6px; font-size: .8rem; }
.cal-day { cursor: pointer; }
.cal-day:hover { background: color-mix(in srgb, var(--accent-soft) 45%, transparent); }
.cal-day:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }
.pick-dia { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 10px; }
.pick-dia .hint { margin: 0; }
.pick-list { display: flex; flex-direction: column; gap: 4px; max-height: 52vh; overflow: auto; }
.pick {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; gap: 12px; align-items: center; text-align: left;
  border: 1px solid var(--rule-2); border-left: 3px solid var(--c); background: var(--surface); border-radius: var(--r-sm);
  padding: 8px 10px; cursor: pointer; font: inherit; color: var(--ink);
}
.pick:hover, .pick:focus-visible { background: var(--accent-soft); border-color: var(--accent); border-left-color: var(--c); }
.pick .num { color: var(--c); }
.pk-main { display: flex; flex-direction: column; min-width: 0; }
.pk-main small { color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pk-fecha { color: var(--ink-2); white-space: nowrap; }
@media (max-width: 560px) { .pick { grid-template-columns: auto 1fr; } .pick .pill, .pk-fecha { grid-column: 2; justify-self: start; } }
.bar .vn { color: var(--ink-2); font-weight: 600; }
.cal.copiando .cal-day.over { box-shadow: inset 0 0 0 2px var(--today); background: color-mix(in srgb, var(--today) 14%, transparent); }
.rango-resumen { margin: 0; font-size: .88rem; color: var(--accent); font-weight: 600; }
.dup-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: .88rem; color: var(--ink-2); border-top: 1px solid var(--rule-2); padding-top: 12px; }
.dup-row input { width: auto; }
.vis-editor { display: flex; flex-direction: column; gap: 8px; }
.vis-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.vis-total { font-weight: 700; }
table.visitas td:nth-child(1), table.visitas td:nth-child(2) { width: 170px; }
table.visitas td:nth-child(3) { width: 90px; }
table.visitas td:nth-child(3) input { text-align: right; }
.cal.agenda { display: flex; flex-direction: column; gap: 12px; }
.ag-day h3 { font-size: .9rem; color: var(--ink-2); margin-bottom: 6px; }
.ag-day.hoy h3 { color: var(--ink); }
.ag-day.hoy h3::after { content: " · hoy"; color: var(--today); }
.ag-item { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--rule); border-left: 3px solid var(--c); border-radius: var(--r-sm); padding: 8px 10px; margin-bottom: 6px; text-decoration: none; color: var(--ink); }
.ag-item small { color: var(--ink-3); }

/* ── Modal, combo, toasts ──────────────────────────────────── */
.backdrop { position: fixed; inset: 0; background: rgb(12 22 30 / .45); display: grid; place-items: start center; padding: 8vh 16px 16px; z-index: 100; overflow: auto; }
.modal { width: min(600px, 100%); background: var(--surface); border-radius: var(--r); box-shadow: 0 30px 60px -20px rgb(0 0 0 / .45); animation: pop .14s ease-out; }
.modal.wide { width: min(900px, 100%); }
@keyframes pop { from { transform: translateY(6px); opacity: 0; } }
.modal > header { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--rule-2); }
.modal > header h2 { font-size: 1.1rem; }
.modal form, .modal .confirm { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 14px; }
.modal p { margin: 0; }
.equipo-set { border: 1px solid var(--rule); border-radius: var(--r); padding: 10px 12px 12px; margin: 0; }
.equipo-set legend { font-size: .8rem; font-weight: 600; color: var(--ink-2); padding: 0 4px; }
.equipo-set legend small { font-weight: 400; color: var(--ink-3); }
.mas summary { cursor: pointer; color: var(--accent); font-weight: 600; font-size: .9rem; }
.mas[open] { display: flex; flex-direction: column; gap: 12px; }
.mas[open] summary { margin-bottom: 2px; }
.actions { display: flex; gap: 8px; justify-content: flex-end; align-items: center; flex-wrap: wrap; }
.actions .hint { margin: 0 auto 0 0; }
.actions progress { flex: 1; }
.combo-list {
  position: fixed; z-index: 300; list-style: none; margin: 0; padding: 4px; background: var(--surface); border: 1px solid var(--rule);
  border-radius: var(--r); box-shadow: 0 14px 30px -10px rgb(10 30 40 / .35); max-height: 300px; overflow: auto; max-width: 420px;
}
.combo-list li { padding: 6px 9px; border-radius: var(--r-sm); cursor: pointer; display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.combo-list li small { color: var(--ink-3); white-space: nowrap; }
.combo-list li.hi, .combo-list li:hover { background: var(--accent-soft); }
.combo-list li.nuevo { color: var(--accent); font-weight: 600; border-top: 1px solid var(--rule-2); margin-top: 2px; }
#toasts { position: fixed; bottom: 18px; right: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 400; align-items: flex-end; max-width: calc(100vw - 36px); }
@media (max-width: 820px) { #toasts { bottom: 76px; right: 12px; } }
.toast {
  background: var(--ink); color: var(--surface); padding: 10px 16px; border-radius: var(--r); display: flex; gap: 16px; align-items: center;
  box-shadow: 0 12px 24px -10px rgb(0 0 0 / .4); transition: opacity .3s, transform .3s; font-size: .92rem;
}
.toast.error { background: var(--danger); color: #fff; }
.toast .link { color: inherit; }
.toast.out { opacity: 0; transform: translateY(8px); }

/* Opción «Nuevo» elegida en un campo en cascada */
input.nuevo { border-style: dashed; }
.qcell:has(input.nuevo) > span::after, .newrow td:has(input.nuevo)::before, tr.editing td:has(input.nuevo)::before {
  content: "nuevo"; color: var(--today); font-weight: 700; font-size: .68rem; margin-left: 6px;
}
tr.editing td:has(input.nuevo) { position: relative; }
.newrow td:has(input.nuevo)::before, tr.editing td:has(input.nuevo)::before { position: absolute; top: -2px; right: 8px; margin: 0; }
.combo-list li.nuevo { border-top: 0; border-bottom: 1px solid var(--rule-2); margin: 0 0 2px; }

/* Edición en la lista */
.sheet tr.editing td { background: var(--accent-soft); vertical-align: top; }
.sheet tr.editing td input { min-width: 130px; }
.sheet tr.editing td[data-f="serie"] { display: flex; gap: 4px; align-items: center; }
.row-ok { flex: none; }
.popover {
  position: fixed; z-index: 250; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r);
  box-shadow: 0 14px 30px -10px rgb(10 30 40 / .35); padding: 12px; display: flex; flex-direction: column; gap: 10px; width: min(340px, calc(100vw - 24px));
}
.linklike { background: none; border: 0; padding: 2px 0; cursor: pointer; text-align: left; color: var(--ink); font: inherit; }
.linklike:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
table.contactos td:first-child { min-width: 180px; }
table.contactos td:nth-child(3) { min-width: 200px; }

/* Importación de fichas */
.dropzone {
  display: flex; flex-direction: column; gap: 4px; align-items: center; text-align: center; padding: 26px 16px;
  border: 2px dashed var(--rule); border-radius: var(--r); cursor: pointer; background: var(--surface-2);
}
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.grupos { display: flex; flex-direction: column; gap: 12px; }
.grupo { border: 1px solid var(--rule); border-radius: var(--r); padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; }
.grupo > header { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; align-items: center; }
.grupo.hecho { border-color: color-mix(in srgb, #2E8A57 50%, var(--rule)); }
.grupo.fallo { border-color: var(--danger); }
.eq-line { padding: 8px 0; display: flex; gap: 8px; flex-wrap: wrap; align-items: baseline; }
.fichas-list { margin: 0; padding-left: 18px; display: grid; gap: 4px; font-size: .9rem; }
.tag { font-size: .72rem; font-weight: 700; padding: 1px 7px; border-radius: 999px; white-space: nowrap; }
.tag.ok { background: color-mix(in srgb, #2E8A57 14%, transparent); color: #2E8A57; }
.tag.new { background: color-mix(in srgb, var(--today) 20%, transparent); color: color-mix(in srgb, var(--today) 70%, var(--ink)); }
.aviso { margin: 0; font-size: .86rem; color: var(--ink-2); border-left: 3px solid var(--today); padding-left: 10px; }
.resultado:empty { display: none; }
.resultado { margin: 0; font-weight: 600; }
.grupo.fallo .resultado { color: var(--danger); }

/* Ficha de instalación */
.grid-motivo { display: grid; grid-template-columns: minmax(0, 1fr) 220px; gap: 12px; }
.inst-bloque { display: flex; flex-direction: column; gap: 8px; padding-bottom: 14px; border-bottom: 1px solid var(--rule-2); }
.inst-bloque h3 { font-size: .9rem; color: var(--ink-2); }
.inst-tit { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.doc-row { display: grid; grid-template-columns: 220px minmax(0, 1fr) auto; gap: 12px; align-items: center; }
.doc-row > span:first-child { font-weight: 600; font-size: .92rem; }
.seg.opt button { min-width: 48px; }
.seg.opt button.on { background: var(--accent); color: var(--accent-ink); }
.acc-texto .field { max-width: 420px; }
table.acc td:nth-child(3) { width: 80px; }
table.acc td:nth-child(5) { width: 120px; }
@media (max-width: 720px) { .doc-row, .grid-motivo { grid-template-columns: 1fr; } }

/* Adjuntos */
.adj-zona {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 14px 16px;
  border: 2px dashed var(--rule); border-radius: var(--r); background: var(--surface-2); color: var(--ink-2);
}
.adj-zona.over { border-color: var(--accent); background: var(--accent-soft); }
.adj-zona small { margin-left: auto; }
.solo-movil { display: none; }
@media (pointer: coarse) { .solo-movil { display: inline-flex; } }
.adj-progreso:empty { display: none; }
.adj-progreso { display: flex; flex-direction: column; gap: 6px; }
.adj-subiendo { display: grid; grid-template-columns: minmax(0, 1fr) 160px; gap: 10px; align-items: center; font-size: .86rem; }
.adj-subiendo span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.adj-lista { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px; }
.adj-item { display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; gap: 10px; align-items: center; border: 1px solid var(--rule-2); border-radius: var(--r-sm); padding: 8px; }
.adj-icono {
  width: 52px; height: 52px; border-radius: var(--r-sm); background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center; font-size: .7rem; font-weight: 700; overflow: hidden;
}
.adj-icono.img { background: var(--surface-2); }
.adj-icono img { width: 100%; height: 100%; object-fit: cover; }
.adj-info { display: flex; flex-direction: column; min-width: 0; }
.adj-nombre { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-decoration: none; }
.adj-nombre:hover { text-decoration: underline; }
.adj-info small { color: var(--ink-3); }
.adj-vacio { color: var(--ink-3); font-size: .9rem; grid-column: 1 / -1; }
.adj-mini { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.adj-chip { font-size: .8rem; border: 1px solid var(--rule); border-radius: 999px; padding: 1px 9px; text-decoration: none; max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Formularios en página */
.inline-new { display: flex; gap: 6px; }
.inline-new input { width: 260px; }
.user-new .grid3 { align-items: end; }
.maptable { max-width: 560px; }
.maptable select { width: 100%; }

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .quickbar { grid-template-columns: 1fr 1fr 1fr; }
  .qcell { border-bottom: 1px solid var(--rule-2); }
  .qactions { flex-direction: row; justify-content: flex-start; }
  .cal-layout { grid-template-columns: 1fr; }
  .cal-side { position: static; max-height: none; }
}
@media (max-width: 820px) {
  #shell { grid-template-columns: 1fr; }
  .side {
    position: fixed; bottom: 0; top: auto; left: 0; right: 0; height: auto; z-index: 30; flex-direction: row;
    padding: 4px; border-right: 0; border-top: 1px solid var(--rule); gap: 0;
  }
  .side .brand-lock, #userbox { display: none; }
  #nav { flex-direction: row; justify-content: space-around; }
  #nav a { flex-direction: column; gap: 2px; font-size: .68rem; padding: 6px 4px; flex: 1; text-align: center; }
  #nav a span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  .top { padding: 8px 16px; }
  .top .new kbd, .top .ghost { display: none; }
  main#view { padding: 16px 16px 90px; }
  .svc-grid, .grid3 { grid-template-columns: 1fr 1fr; }
  .quickbar { grid-template-columns: 1fr 1fr; }
  .tl-item { grid-template-columns: 1fr; gap: 6px; }
  .sheetwrap { max-height: calc(100vh - 260px); }
}
@media (max-width: 560px) {
  .svc-grid, .grid3, .grid2, .quickbar { grid-template-columns: 1fr; }
  .top .new { padding: 7px 10px; }
  .svc-num { font-size: 1.7rem; }
  .cal-tools { gap: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ── Impresión: ficha de servicio ──────────────────────────── */
#print-ficha { display: none; }
@media print {
  @page { size: A4; margin: 14mm; }
  body { background: #fff; color: #000; font-size: 11pt; }
  body * { visibility: hidden; }
  #print-ficha, #print-ficha * { visibility: visible; }
  #print-ficha { display: block; position: absolute; left: 0; top: 0; width: 100%; }
  .side, .top { display: none; }
  .pf-head { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 2px solid #000; padding-bottom: 8px; margin-bottom: 10px; }
  .pf-head h1 { font-size: 16pt; }
  .pf-head p { margin: 2px 0 0; font-size: 9pt; }
  .pf-head address { font-style: normal; text-align: right; font-size: 9pt; }
  table.pf { width: 100%; border-collapse: collapse; margin-bottom: 10px; }
  .pf th, .pf td { border: 1px solid #555; padding: 4px 6px; text-align: left; vertical-align: top; font-size: 10pt; }
  .pf th { background: #eee; width: 22%; font-weight: 700; }
  .pf.mat th { width: auto; }
  #print-ficha h3 { font-size: 11pt; margin: 6px 0; }
}
