/* =========================================================
   Servicios Sanitarios · faena Los Bronces / Las Tórtolas
   Tokens: grafito + niebla andina + crisocola (mineral de cobre)
   ========================================================= */
:root {
  --ink: #18212b;
  --ink-2: #263240;
  --ink-3: #3a4757;
  --paper: #edf1f0;
  --surface: #ffffff;
  --line: #d6dedc;
  --line-2: #e6ecea;
  --muted: #5d6a75;
  --accent: #12756b;
  --accent-ink: #0b534c;
  --accent-wash: #dcefeb;
  --hivis: #f2c230;

  --ok: #2e9a68;
  --warn: #e0a100;
  --bad: #d2452f;
  --na: #7c8792;
  --none: #4f7cac;

  --display: "Archivo", "Arial Narrow", sans-serif;
  --body: "Archivo", system-ui, sans-serif;
  --mono: "Martian Mono", ui-monospace, Consolas, monospace;

  --r: 10px;
  --shadow: 0 1px 0 rgba(24, 33, 43, .04), 0 6px 18px -8px rgba(24, 33, 43, .18);
  --sidebar: 236px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--body);
  font-variation-settings: "wdth" 100;
  background: var(--paper);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-ink); text-decoration: underline; text-underline-offset: 3px; }
button, input, select { font: inherit; color: inherit; }
img { max-width: 100%; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Placa de código: tipografía expandida de identificación de equipos */
.plate {
  font-family: var(--display);
  font-variation-settings: "wdth" 125;
  font-weight: 800;
  letter-spacing: .01em;
  text-transform: uppercase;
  line-height: 1;
}
.mono { font-family: var(--mono); font-size: .86em; letter-spacing: -.01em; }
.muted { color: var(--muted); }
.center { text-align: center; }

/* ---------- Controles ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: var(--surface);
  padding: 8px 14px; border-radius: 8px; cursor: pointer; font-weight: 600;
  transition: border-color .15s, background .15s, color .15s;
}
.btn:hover { border-color: var(--ink-3); text-decoration: none; color: var(--ink); }
.btn-primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn-primary:hover { background: var(--ink-2); color: #fff; }
.btn:disabled { opacity: .5; cursor: default; }
.input, select.input {
  border: 1px solid var(--line); background: var(--surface);
  padding: 8px 10px; border-radius: 8px; min-width: 0;
}
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-wash); }
label.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 600; }

/* ---------- Estructura ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar); background: var(--ink); color: #c9d3dc;
  display: flex; flex-direction: column;
  position: fixed; inset: 0 auto 0 0; z-index: 1100; transition: transform .2s;
}
.sidebar .brand { padding: 22px 20px 20px; }
.sidebar .brand b { display: block; color: #fff; font-size: 15px; }
.sidebar .brand b .plate { font-size: 17px; display: block; margin-bottom: 4px; color: #fff; }
.sidebar .brand span { font-size: 12px; color: #8d9aa6; }
.nav { list-style: none; padding: 6px 10px; flex: 1; }
.nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; border-radius: 7px; color: #b9c4ce; font-weight: 500;
  border-left: 3px solid transparent;
}
.nav a:hover { background: var(--ink-2); color: #fff; text-decoration: none; }
.nav a.active { background: var(--ink-2); color: #fff; border-left-color: var(--accent); }
.nav svg { width: 18px; height: 18px; flex: none; opacity: .9; }
.sidebar .foot { padding: 14px 16px 16px; border-top: 1px solid var(--ink-2); font-size: 12px; }
.sidebar .foot .user { color: #fff; font-weight: 600; margin-bottom: 8px; word-break: break-all; }
.sidebar .foot .btn { width: 100%; background: transparent; color: #c9d3dc; border-color: var(--ink-3); }
.sidebar .foot .btn:hover { background: var(--ink-2); color: #fff; }
.sync { margin-top: 10px; color: #8d9aa6; font-family: var(--mono); font-size: 10.5px; line-height: 1.6; }

.main { flex: 1; margin-left: var(--sidebar); min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: none; align-items: center; gap: 12px; padding: 10px 16px;
  background: var(--ink); color: #fff; position: sticky; top: 0; z-index: 1000;
}
.topbar button { background: none; border: 0; color: #fff; cursor: pointer; padding: 4px; }
.content { padding: 26px 28px 32px; flex: 1; min-width: 0; animation: rise .25s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(4px); } }
.backdrop { display: none; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px 20px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { font-size: 24px; font-weight: 700; letter-spacing: -.01em; line-height: 1.15; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.page-head h1 .plate { font-size: 28px; }
.page-head p { color: var(--muted); margin-top: 4px; }
.crumb { font-size: 13px; font-weight: 600; display: inline-block; margin-bottom: 6px; }

@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); }
  body.menu-open .sidebar { transform: none; }
  body.menu-open .backdrop { display: block; position: fixed; inset: 0; background: rgba(24, 33, 43, .5); z-index: 1050; }
  .main { margin-left: 0; }
  .topbar { display: flex; }
  .content { padding: 18px 16px 24px; }
}

/* ---------- Tarjetas ---------- */
.card { background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow); border: 1px solid var(--line-2); }
.card-pad { padding: 16px 18px; }
.card h2 { font-size: 13px; font-weight: 700; margin-bottom: 12px; color: var(--ink); }

/* ---------- Barra de estados (inicio) ---------- */
.status-strip { padding: 16px 18px 14px; margin-bottom: 16px; }
.strip-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.strip-top b { font-size: 15px; }
.strip-top .mono { color: var(--muted); }
.strip-bar { display: flex; height: 14px; border-radius: 4px; overflow: hidden; gap: 2px; background: var(--line-2); }
.strip-bar span { display: block; min-width: 3px; transition: opacity .15s; }
.strip-keys { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.strip-key {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px;
  padding: 4px 12px 4px 8px; cursor: pointer; font-size: 13px; font-weight: 500;
}
.strip-key b { font-family: var(--mono); font-size: 12px; font-weight: 600; }
.strip-key:hover { border-color: var(--ink-3); }
.strip-key[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.strip-key.dim { opacity: .45; }
.strip-age { margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--line); color: var(--muted); font-size: 13px; display: flex; gap: 6px 18px; flex-wrap: wrap; }
.strip-age strong { color: var(--ink); font-family: var(--mono); font-size: 12px; }

/* ---------- Mapas ---------- */
.map-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 16px; }
.map { height: calc(100vh - 290px); min-height: 440px; border-radius: var(--r); box-shadow: var(--shadow); z-index: 0; background: #cfd8d6; }
.map.small { height: 300px; min-height: 0; }
.side { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.side .list { max-height: calc(100vh - 640px); min-height: 180px; overflow: auto; margin: 0 -18px -16px; border-top: 1px solid var(--line-2); }
.side .list button {
  display: flex; width: 100%; align-items: center; gap: 10px;
  padding: 9px 18px; border: 0; background: none; text-align: left; cursor: pointer;
  border-bottom: 1px solid var(--line-2);
}
.side .list button:hover { background: #f5f8f7; }
.side .list .plate { font-size: 13px; display: block; margin-bottom: 2px; }
.side .list small { color: var(--muted); }
.side .list .t { color: var(--muted); font-family: var(--mono); font-size: 10.5px; margin-left: auto; white-space: nowrap; }
.tabs { display: flex; gap: 4px; margin: -4px 0 12px; }
.tabs button { border: 0; background: none; padding: 5px 10px; border-radius: 6px; cursor: pointer; font-weight: 600; color: var(--muted); font-size: 13px; }
.tabs button[aria-selected="true"] { background: var(--accent-wash); color: var(--accent-ink); }
@media (max-width: 1100px) {
  .map-wrap { grid-template-columns: 1fr; }
  .map { height: 62vh; }
  .side .list { max-height: 360px; }
}

.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 16px; }
.filters .grow { flex: 1; min-width: 160px; }
.filters .count { font-family: var(--mono); font-size: 11.5px; color: var(--muted); align-self: center; }

.legend { background: rgba(255, 255, 255, .94); padding: 9px 11px; border-radius: 8px; box-shadow: var(--shadow); font-size: 11.5px; line-height: 1.75; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 7px; vertical-align: -1px; }
.legend hr { border: 0; border-top: 1px dashed var(--line); margin: 5px 0; }
.legend svg { vertical-align: -3px; margin-right: 5px; }
@media (max-width: 600px) { .legend .ages { display: none; } }

/* =========================================================
   Ficha de servicio (tooltip del mapa) — elemento distintivo:
   etiqueta perforada como las que se cuelgan en terreno
   ========================================================= */
.leaflet-tooltip.visit-tip { padding: 0; border: 0; background: transparent; box-shadow: none; }
.leaflet-tooltip.visit-tip::before { display: none; }
.tag {
  width: 268px; white-space: normal; font-size: 12px; color: var(--ink);
  background: var(--surface); border-radius: 12px 12px 6px 6px;
  box-shadow: 0 14px 34px -10px rgba(24, 33, 43, .45), 0 0 0 1px rgba(24, 33, 43, .08);
  position: relative; overflow: hidden;
}
.tag-head { position: relative; padding: 14px 16px 14px 40px; color: #fff; background: var(--tag, var(--none)); display: grid; grid-template-columns: 1fr auto; align-items: center; column-gap: 10px; }
.tag-head .when { grid-column: 1 / -1; }
/* perforación para el amarre */
.tag-head::before {
  content: ""; position: absolute; left: 14px; top: 50%; width: 13px; height: 13px; margin-top: -6.5px;
  border-radius: 50%; background: var(--paper); box-shadow: inset 0 1px 2px rgba(0, 0, 0, .35);
}
.tag-head .plate { font-size: 21px; display: block; }
.tag-head .when { font-family: var(--mono); font-size: 10.5px; opacity: .92; margin-top: 5px; display: block; }
.tag-head .state { grid-row: 1; grid-column: 2; justify-self: end; font-size: 10px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; background: rgba(0, 0, 0, .18); padding: 3px 7px; border-radius: 4px; }
/* línea de corte con muescas */
.tag-cut { height: 0; border-top: 2px dashed var(--line); margin: 0 10px; position: relative; }
.tag-cut::before, .tag-cut::after { content: ""; position: absolute; top: -8px; width: 14px; height: 14px; border-radius: 50%; background: var(--paper); }
.tag-cut::before { left: -18px; }
.tag-cut::after { right: -18px; }
.tag-body { padding: 10px 16px 14px; }
.tag-row { display: flex; justify-content: space-between; gap: 10px; padding: 3px 0; }
.tag-row span { color: var(--muted); }
.tag-row strong { text-align: right; font-weight: 600; }
.tag-checks { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin: 8px 0 2px; }
.tag-checks div { border: 1px solid var(--line); border-radius: 6px; padding: 5px 4px; text-align: center; font-size: 10.5px; color: var(--muted); }
.tag-checks b { display: block; font-size: 14px; line-height: 1.2; color: var(--ink); }
.tag-checks .si { border-color: var(--ok); background: #e8f5ee; }
.tag-checks .si b { color: var(--ok); }
.tag-checks .no b { color: var(--bad); }
.tag-legend { font-size: 10px; color: var(--muted); margin-top: 2px; }
.tag img { display: block; width: 100%; height: 124px; object-fit: cover; border-radius: 6px; margin-top: 10px; background: var(--line-2); }

/* ---------- Estados ---------- */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 8px; border-radius: 5px; font-size: 12px; font-weight: 700; background: var(--line-2); color: var(--ink-3); white-space: nowrap; font-family: var(--body); letter-spacing: 0; text-transform: none; }
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip.Bueno { background: #e3f3ea; color: #1e7a50; }
.chip.Regular { background: #fbf0cf; color: #8a6300; }
.chip.Malo { background: #f9e1dc; color: #a8321f; }
.chip.na { background: #e8ebee; color: #56616b; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }

/* ---------- Tablas ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line-2); white-space: nowrap; }
th { font-size: 11px; color: var(--muted); font-weight: 700; letter-spacing: .04em; text-transform: uppercase; background: #f6f8f8; position: sticky; top: 0; }
td.when { font-family: var(--mono); font-size: 12px; }
td .plate { font-size: 13px; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: #f5f8f7; }
td.wrap { white-space: normal; min-width: 160px; }
.checks { font-family: var(--mono); font-size: 12px; letter-spacing: .08em; }
.checks .si { color: var(--ok); }
.checks .no { color: var(--bad); }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; flex-wrap: wrap; color: var(--muted); font-size: 13px; }

/* ---------- Baños ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.bano-card { padding: 14px; display: flex; gap: 14px; align-items: center; cursor: pointer; transition: border-color .15s, transform .15s; border-left: 4px solid var(--tag, var(--na)); }
.bano-card:hover { border-color: var(--line); border-left-color: var(--tag, var(--na)); transform: translateY(-1px); }
.bano-card img, .bano-card .noqr { width: 64px; height: 64px; flex: none; image-rendering: pixelated; }
.bano-card .noqr { display: grid; place-items: center; background: var(--paper); color: var(--muted); font-size: 10px; text-align: center; border-radius: 6px; line-height: 1.2; padding: 4px; }
.bano-card .plate { display: block; font-size: 15px; margin-bottom: 6px; }
.bano-card small { color: var(--muted); display: block; margin-top: 6px; font-family: var(--mono); font-size: 10.5px; }

/* ---------- Detalle ---------- */
.detail { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
@media (max-width: 1000px) { .detail { grid-template-columns: 1fr; } }
.kv { display: grid; grid-template-columns: minmax(130px, 38%) 1fr; }
.kv > div { padding: 9px 0; border-bottom: 1px solid var(--line-2); }
.kv .k { color: var(--muted); padding-right: 12px; }
.kv .sec { grid-column: 1 / -1; font-weight: 700; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--accent-ink); padding-top: 20px; border-bottom-color: var(--line); }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.photos a { display: block; }
.photos img { width: 100%; height: 160px; object-fit: cover; border-radius: 8px; background: var(--line-2); }
.photos figcaption { font-size: 12px; color: var(--muted); margin-top: 5px; }
.qr-big { display: block; width: 200px; margin: 0 auto 12px; image-rendering: pixelated; }
.qr-url { margin-top: 12px; font-size: 11px; word-break: break-all; color: var(--muted); }

.empty, .loading { padding: 40px 16px; text-align: center; color: var(--muted); }
.error { background: #f9e1dc; color: #8f2a19; padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; border-left: 4px solid var(--bad); }
.spinner { width: 26px; height: 26px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; margin: 0 auto 10px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Login ---------- */
.login-page { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(360px, .9fr); background: var(--ink); }
.login-art { position: relative; overflow: hidden; padding: 48px; display: flex; flex-direction: column; justify-content: flex-end; color: #fff; }
.login-art svg.contours { position: absolute; inset: 0; width: 100%; height: 100%; }
.login-art .plate { position: relative; font-size: clamp(40px, 6vw, 76px); line-height: .95; }
.login-art .plate em { font-style: normal; color: var(--accent); display: block; }
.login-art p { position: relative; color: #9fadb9; margin-top: 16px; max-width: 420px; font-size: 15px; }
.login-side { background: var(--paper); display: grid; place-items: center; padding: 32px 20px; }
.login-box { width: 100%; max-width: 360px; }
.login-box h1 { font-size: 22px; margin-bottom: 6px; }
.login-box > p { color: var(--muted); margin-bottom: 24px; }
.login-box form { display: flex; flex-direction: column; gap: 14px; }
.login-box .input { padding: 11px 12px; font-size: 15px; }
.login-box .btn { padding: 12px; font-size: 15px; margin-top: 4px; }
.login-box .host { font-family: var(--mono); font-size: 12px; color: var(--ink); }
@media (max-width: 820px) {
  .login-page { grid-template-columns: 1fr; }
  .login-art { padding: 32px 24px; min-height: 220px; }
}

/* ---------- Vista pública (QR) ---------- */
.public { max-width: 520px; margin: 0 auto; padding: 18px 16px 28px; }
.public .tag { width: 100%; font-size: 14px; border-radius: 16px 16px 10px 10px; }
.public .tag-head { padding: 22px 20px 20px 52px; }
.public .tag-head::before { left: 20px; width: 18px; height: 18px; margin-top: -9px; }
.public .tag-head .plate { font-size: 34px; }
.public .tag-head .when { font-size: 12px; margin-top: 8px; }
.public .tag-head .state { font-size: 11px; }
.public .tag-body { padding: 14px 20px 20px; }
.public .tag-checks div { font-size: 12px; padding: 8px 4px; }
.public .tag-checks b { font-size: 18px; }
.public .map { height: 240px; min-height: 0; border-radius: 10px; box-shadow: none; margin: 14px 0 4px; }
.public .photo { width: 100%; max-height: 320px; object-fit: cover; border-radius: 10px; margin-top: 14px; }
.public .foot { font-family: var(--mono); font-size: 10.5px; color: var(--muted); margin-top: 14px; }
.public .btn { width: 100%; margin-top: 14px; padding: 12px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  .main { margin: 0; }
}
.last-card .tag { width: 100%; box-shadow: 0 0 0 1px rgba(24, 33, 43, .1); }
.last-card .tag-cut::before, .last-card .tag-cut::after { background: var(--surface); box-shadow: inset 0 0 0 1px rgba(24, 33, 43, .1); }

/* =========================================================
   Programación: agenda y mantenedor de puntos
   ========================================================= */
.nav-group { margin: 16px 12px 6px; font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: #6f7d89; list-style: none; }

.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; margin-bottom: 16px; }
.day { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 10px 12px 12px; border-radius: var(--r); border: 1px solid var(--line-2); background: var(--surface); cursor: pointer; text-align: left; box-shadow: var(--shadow); min-width: 0; }
.day:hover { border-color: var(--ink-3); }
.day.sel { border-color: var(--ink); box-shadow: 0 0 0 2px var(--ink) inset; }
.day.today .dname::after { content: " · hoy"; color: var(--accent); }
.day .dname { font-size: 12px; font-weight: 600; color: var(--muted); }
.day .dnum { font-size: 24px; }
.day .dcount { font-size: 12px; color: var(--muted); }
.day .dbar { display: flex; gap: 2px; width: 100%; height: 6px; border-radius: 3px; overflow: hidden; margin-top: 6px; background: var(--line-2); }
.day .dbar span { display: block; min-width: 2px; }
@media (max-width: 760px) { .week { grid-template-columns: repeat(7, minmax(64px, 1fr)); overflow-x: auto; } .day .dcount { display: none; } }

.day-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; border-bottom: 1px solid var(--line-2); }
.day-head h2::first-letter { text-transform: uppercase; }
.route-group { border-bottom: 1px solid var(--line-2); }
.route-title { display: flex; justify-content: space-between; padding: 10px 18px; background: #f6f8f8; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--accent-ink); }
.route-title span { font-family: var(--mono); color: var(--muted); }
.agenda-row { display: flex; gap: 12px; justify-content: space-between; padding: 12px 18px; border-top: 1px solid var(--line-2); cursor: pointer; }
.agenda-row:hover { background: #f5f8f7; }
.ar-main { min-width: 0; }
.ar-main b { display: block; }
.ar-main small { color: var(--muted); display: block; margin-top: 2px; }
.ar-banos { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.ar-state { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: none; }

.pchip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; padding: 3px 9px 3px 7px; border-radius: 5px; background: var(--line-2); white-space: nowrap; }
.pchip i { width: 8px; height: 8px; border-radius: 50%; }
.pchip.realizada { background: #e3f3ea; color: #1e7a50; }
.pchip.parcial { background: #fbf0cf; color: #8a6300; }
.pchip.noRealizada { background: #f9e1dc; color: #a8321f; }
.pchip.pendiente { background: #e3ebf4; color: #335b86; }
.pchip.sinBanos { background: #e8ebee; color: #56616b; }

.bchip { display: inline-block; font-family: var(--mono); font-size: 11px; padding: 2px 7px; border-radius: 4px; border: 1px solid var(--line); color: var(--ink-3); background: var(--surface); white-space: nowrap; }
a.bchip:hover { border-color: var(--ink-3); text-decoration: none; }
.bchip.ok { border-color: #a9dbc0; background: #e8f5ee; color: #1e7a50; }
.bchip.warn { border-color: #f0d68a; background: #fdf6dc; color: #7a5800; font-family: var(--body); font-weight: 600; }
.plan-tag { font-size: 11px; font-weight: 700; color: var(--accent-ink); background: var(--accent-wash); padding: 2px 7px; border-radius: 4px; white-space: nowrap; }
tr.inactive td { opacity: .55; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid h2 { margin-bottom: 0; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }
textarea.input { resize: vertical; font: inherit; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; align-self: end; padding-bottom: 8px; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }
.form-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-danger { color: var(--bad); border-color: #efc2b9; margin-left: auto; }
.btn-danger:hover { background: #f9e1dc; color: #8f2a19; border-color: var(--bad); }
.btn-sm { padding: 5px 10px; font-size: 12px; flex: none; }

.asoc-list, .pick-list { display: flex; flex-direction: column; }
.pick { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line-2); }
.pick-main { flex: 1; min-width: 0; }
.pick-main .plate { font-size: 13px; display: block; margin-bottom: 3px; }
.pick-main small { display: block; color: var(--muted); }
.warn-text { color: #8a6300 !important; }
.add-bano { margin-top: 14px; }
.add-bano .pick-list { margin-top: 6px; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 8px; font-weight: 600; box-shadow: 0 10px 30px -10px rgba(0, 0, 0, .5); z-index: 3000; animation: rise .2s ease-out; }

@media print {
  .agenda-day { display: block; }
  .agenda-row { break-inside: avoid; }
  .page-head p, .filters { display: none; }
}

/* Perfiles: Programación solo para supervisores (el servidor también lo exige) */
body:not([data-perfil="supervisor"]) .solo-supervisor { display: none; }
.sidebar .foot .perfil { display: inline-block; margin-left: 6px; font-size: 10px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: #9fdccf; background: rgba(18, 117, 107, .35); padding: 1px 6px; border-radius: 4px; vertical-align: 1px; }

/* Mantenedores de catálogos */
.cat-add { margin-bottom: 14px; padding-bottom: 14px; border-bottom: 1px solid var(--line-2); }
td.acciones { text-align: right; white-space: nowrap; }
td.acciones .btn + .btn { margin-left: 4px; }
tr.editing td { background: #f6fbfa; }
tr.editing .input { width: 100%; min-width: 140px; }
.btn-danger:disabled { color: var(--muted); border-color: var(--line); background: none; }

/* =========================================================
   Agenda extensa: grilla mensual al estilo del Excel del plan
   ========================================================= */
.xgrid-card { padding: 0; overflow: hidden; }
.xgrid-wrap { overflow: auto; max-height: calc(100vh - 300px); min-height: 320px; }
/* Anchos de las columnas fijas: variables que el usuario ajusta arrastrando el borde del encabezado */
.xgrid { --w1: 92px; --w2: 104px; --w3: 230px; --w4: 46px; border-collapse: separate; border-spacing: 0; font-size: 12px; width: max-content; }
.xgrid th, .xgrid td { padding: 0; height: 24px; border-right: 1px solid var(--line-2); border-bottom: 1px solid var(--line-2); text-align: center; white-space: nowrap; background: var(--surface); }
.xgrid thead th { position: sticky; z-index: 2; background: #f3f6f6; color: var(--ink-3); font-weight: 700; font-size: 11px; }
.xgrid thead .h1 th { top: 0; height: 26px; }
.xgrid thead .h2 th { top: 26px; }
.xgrid thead .h3 th { top: 50px; border-bottom: 2px solid var(--ink-3); }
.xgrid thead .semana { background: var(--ink); color: #fff; letter-spacing: .02em; border-right-color: var(--ink-3); }
.xgrid thead .h1 .c1 { background: var(--accent); color: #fff; font-family: var(--display); font-variation-settings: "wdth" 125; font-size: 15px; font-weight: 800; text-transform: uppercase; text-align: left; padding-left: 12px; }
.xgrid td:not(.fija):not(.tot), .xgrid thead .h2 th, .xgrid thead .h3 th:not(.fija) { width: 28px; min-width: 28px; max-width: 28px; }
/* Columnas fijas a la izquierda (sector, ruta, punto, cantidad) */
.xgrid .fija { position: sticky; z-index: 1; text-align: left; padding: 0 8px; overflow: hidden; text-overflow: ellipsis; }
.xgrid thead .fija { z-index: 3; }
.xgrid .c1 { left: 0; width: var(--w1); min-width: var(--w1); max-width: var(--w1); }
.xgrid .c2 { left: var(--w1); width: var(--w2); min-width: var(--w2); max-width: var(--w2); }
.xgrid .c3 { left: calc(var(--w1) + var(--w2)); width: var(--w3); min-width: var(--w3); max-width: var(--w3); font-weight: 600; cursor: pointer; }
.xgrid .c4 { left: calc(var(--w1) + var(--w2) + var(--w3)); width: var(--w4); min-width: var(--w4); max-width: var(--w4); text-align: center; padding: 0; border-right: 2px solid var(--ink-3); }
.xgrid tbody .c3:hover { color: var(--accent); text-decoration: underline; }
.xgrid .grupo td { background: var(--accent-wash); color: var(--accent-ink); font-weight: 800; font-size: 12px; letter-spacing: .03em; text-transform: uppercase; height: 26px; }
.xgrid .grupo .c1 { max-width: none; overflow: visible; }
.xgrid .grupo span { font-weight: 600; text-transform: none; color: var(--muted); margin-left: 6px; letter-spacing: 0; }
.xgrid .fin { background: #f7f8f8; }
.xgrid thead .fin { background: #e9eeee; }
.xgrid .hoy { background: #fff8db !important; }
.xgrid thead .hoy { background: var(--hivis) !important; color: var(--ink); }
.xgrid .num { font-family: var(--mono); font-size: 11px; }
.xgrid .tot { width: 54px; min-width: 54px; background: #f6f8f8; font-weight: 600; }
.xgrid thead .tot { z-index: 2; }
.xgrid .tot.ok { color: #1e7a50; } .xgrid .tot.warn { color: #8a6300; } .xgrid .tot.bad { color: #a8321f; }
.xgrid tfoot td { background: #f3f6f6; font-weight: 700; color: var(--ink-3); }
.xgrid tfoot .fija { font-family: var(--body); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
.xgrid tbody tr:not(.grupo):hover td { background: #eef6f4; }
.xgrid tbody tr:not(.grupo):hover td.hoy { background: #fff1b8 !important; }

/* Casilla (como el checkbox del Excel) */
.xm { display: inline-grid; place-items: center; width: 17px; height: 17px; border-radius: 3px; font-style: normal; font-size: 11px; font-weight: 800; line-height: 1; vertical-align: middle; cursor: default; }
.xm.realizada { background: var(--ok); color: #fff; }
.xm.parcial { background: var(--warn); color: #fff; }
.xm.noRealizada { background: #fff; border: 1.5px solid var(--bad); color: var(--bad); }
.xm.pendiente { background: #fff; border: 1.5px solid #8a96a1; }
.xm.sinBanos { background: #eef1f2; border: 1.5px dashed #a3aeb7; }
.xleyenda { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; margin-left: auto; font-size: 12px; color: var(--muted); }
.xleyenda span { display: inline-flex; align-items: center; gap: 6px; }

@media print {
  @page { size: landscape; margin: 8mm; }
  .xgrid-wrap { max-height: none; overflow: visible; }
  .xgrid { font-size: 9px; }
  .xgrid thead th, .xgrid .fija { position: static; }
}

/* Agenda extensa: casillas clicables y marcas manuales */
.xgrid td.clic { cursor: pointer; position: relative; }
.xgrid td.clic:empty:hover::before { content: "+"; display: inline-grid; place-items: center; width: 17px; height: 17px; border: 1.5px dashed var(--accent); border-radius: 3px; color: var(--accent); font-weight: 800; font-size: 13px; line-height: 1; vertical-align: middle; }
.xgrid td.clic:hover .xm { outline: 2px solid var(--accent); outline-offset: 1px; }
.xgrid td.guardando { opacity: .4; pointer-events: none; }
.xgrid td.quitada:not(:hover)::before { content: "–"; color: #c3cbd1; font-weight: 700; }
.xm.manual { position: relative; }
.xm.manual::after { content: ""; position: absolute; top: -3px; right: -3px; width: 7px; height: 7px; border-radius: 50%; background: #2563eb; border: 1.5px solid #fff; }
.xgrid tr.inactivo .c3 { color: var(--muted); }
.xgrid tr.inactivo .c3 small { font-weight: 600; font-size: 9px; text-transform: uppercase; background: var(--line-2); padding: 1px 4px; border-radius: 3px; margin-left: 4px; }

/* Borde para redimensionar las columnas fijas */
.xgrid thead .h3 th.fija { position: sticky; }
.xgrid .rz { position: absolute; top: 0; right: 0; width: 8px; height: 100%; cursor: col-resize; z-index: 4; touch-action: none; }
.xgrid .rz::after { content: ""; position: absolute; top: 4px; bottom: 4px; right: 1px; width: 2px; border-radius: 1px; background: transparent; transition: background .15s; }
.xgrid .rz:hover::after, .xgrid .rz.activo::after { background: var(--accent); }
body.redimensionando, body.redimensionando * { cursor: col-resize !important; user-select: none !important; }

/* Cantidad de baños asignados menor a la del plan */
.faltan { color: #8a6300 !important; font-weight: 800; }
.faltan small { font-weight: 500; }

/* Asignar baños */
.asig-resumen { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.asig-wrap { display: grid; grid-template-columns: minmax(300px, 380px) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 1000px) { .asig-wrap { grid-template-columns: 1fr; } }
.asig-lista-card { padding: 0; overflow: hidden; }
.asig-lista { max-height: calc(100vh - 330px); min-height: 240px; overflow: auto; border-top: 1px solid var(--line-2); }
.asig-item { display: flex; width: 100%; gap: 10px; align-items: flex-start; padding: 10px 16px; border: 0; border-bottom: 1px solid var(--line-2); background: none; text-align: left; cursor: pointer; }
.asig-item .dot { margin-top: 5px; }
.asig-item:hover { background: #f5f8f7; }
.asig-item.sel { background: var(--accent-wash); box-shadow: inset 3px 0 0 var(--accent); }
.asig-main { min-width: 0; flex: 1; }
.asig-main .plate { font-size: 13px; display: block; margin-bottom: 3px; }
.asig-main small { display: block; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.asig-main .asig-punto { color: var(--accent-ink); }
.asig-item .t { color: var(--muted); font-family: var(--mono); font-size: 10.5px; white-space: nowrap; }
.asig-acc { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.asig-acc .btn-danger { margin-left: 0; }

/* Asignar baños: «Elegir otro punto» en cascada */
.elegir-filtros { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-bottom: 10px; }
.elegir-filtros .elegir-q { grid-column: 1 / -1; }
@media (max-width: 760px) { .elegir-filtros { grid-template-columns: 1fr 1fr; } }
.elegir-lista { max-height: 420px; overflow: auto; border: 1px solid var(--line-2); border-radius: 8px; }
.elegir-total { padding: 6px 12px; font-size: 12px; color: var(--muted); background: #fafbfb; border-bottom: 1px solid var(--line-2); position: sticky; top: 0; z-index: 2; }
.elegir-grupo { display: flex; justify-content: space-between; padding: 6px 12px; background: var(--accent-wash); color: var(--accent-ink); font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; position: sticky; top: 28px; z-index: 1; }
.elegir-grupo span { color: var(--muted); font-family: var(--mono); }
.elegir-item { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--line-2); }
.elegir-item:hover { background: #f5f8f7; }
.elegir-item.inactivo b { color: var(--muted); }
.elegir-item mark { background: #fff1b8; color: inherit; padding: 0 1px; border-radius: 2px; }

/* Elegir otro punto: fila seleccionable y barra de confirmación */
.elegir-item { cursor: pointer; }
.elegir-item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.elegir-item .radio { width: 16px; height: 16px; border-radius: 50%; border: 2px solid #a3aeb7; flex: none; background: #fff; }
.elegir-item.sel { background: var(--accent-wash); box-shadow: inset 3px 0 0 var(--accent); }
.elegir-item.sel .radio { border-color: var(--accent); background: radial-gradient(circle, var(--accent) 0 4px, #fff 5px); }
.elegido-bar { display: flex; align-items: center; gap: 10px; margin-top: 10px; padding: 10px 12px; border: 1.5px solid var(--accent); border-radius: 8px; background: #f3faf8; position: sticky; bottom: 8px; z-index: 3; box-shadow: var(--shadow); }
.elegido-bar .pick-main b { display: block; font-size: 14px; }
.elegido-bar .pick-main small { display: block; color: var(--muted); }
.elegido-bar[hidden] { display: none; }

/* =========================================================
   Reportes
   ========================================================= */
.rep-tabs { display: flex; flex-wrap: wrap; gap: 10px 22px; margin-bottom: 14px; }
.rep-grupo { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.rep-grupo > span { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-right: 4px; }
.rep-tabs button { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 6px 13px; font-weight: 600; font-size: 13px; cursor: pointer; }
.rep-tabs button:hover { border-color: var(--ink-3); }
.rep-tabs button[aria-selected="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
#repFiltros label[hidden] { display: none; }
.rep-desc { color: var(--muted); margin: 0 0 12px; max-width: 980px; }
.rep-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 16px; }
.rep-kpi { padding: 12px 14px; border-left: 4px solid var(--line); }
.rep-kpi .v { font-size: 24px; font-weight: 800; font-family: var(--display); font-variation-settings: "wdth" 110; line-height: 1.1; }
.rep-kpi .l { color: var(--muted); font-size: 12px; margin-top: 2px; }
.rep-kpi.ok { border-left-color: var(--ok); } .rep-kpi.warn { border-left-color: var(--warn); } .rep-kpi.bad { border-left-color: var(--bad); }
.rep-tabla { margin-bottom: 16px; }
.rep-scroll { max-height: 560px; overflow: auto; }
.rep-t th.num, .rep-t td.num { text-align: right; }
.rep-t td.num { position: relative; font-family: var(--mono); font-size: 12px; min-width: 90px; }
.rep-t td.num span { position: relative; }
.rep-t td.num .dbar { position: absolute; left: 6px; top: 7px; bottom: 7px; max-width: calc(100% - 12px); background: var(--accent-wash); border-radius: 3px; }
.rep-t td.num.ok { color: #1e7a50; font-weight: 700; } .rep-t td.num.warn { color: #8a6300; font-weight: 700; } .rep-t td.num.bad { color: #a8321f; font-weight: 700; }
.rep-t td .plate { font-size: 12px; color: var(--ink); }
.rep-t tbody tr { cursor: default; }
/* Gráficos */
.chart-scroll { overflow-x: auto; }
.chart { display: block; font-family: var(--body); }
.chart .grid { stroke: var(--line-2); stroke-width: 1; }
.chart .ax { fill: var(--muted); font-size: 11px; }
.chart .lbl { fill: var(--ink-3); font-size: 11px; font-weight: 700; }
.chart .seg { cursor: pointer; transition: opacity .15s; }
.chart:hover .seg { opacity: .55; }
.chart .seg:hover { opacity: 1; }
.chart-leyenda { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: -4px 0 8px; font-size: 12px; color: var(--ink-3); }
.chart-leyenda i { display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.chart-par { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 20px; }
.chart-par h3 { font-size: 12px; color: var(--muted); font-weight: 700; margin-bottom: 4px; }
@media (max-width: 1100px) { .chart-par { grid-template-columns: 1fr; } }
.chart-nota { font-size: 12px; margin-top: 6px; }
.chart-tip { position: fixed; z-index: 4000; background: var(--ink); color: #fff; padding: 8px 10px; border-radius: 6px; font-size: 12px; line-height: 1.5; pointer-events: none; box-shadow: 0 8px 24px -8px rgba(0,0,0,.5); max-width: 280px; }
.chart-tip .sw { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; }
