:root {
  --font: "Outfit", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --radius: 12px;
  --radius-sm: 6px;
  --chip-r: 6px;
  --sidebar: 248px;
  --topbar: 56px;
  --bottom: 64px;
  --ease: 160ms ease;
  --shadow: 0 10px 30px rgba(12, 39, 68, 0.10);
  --map-filter: none;
}

:root[data-theme="light"] {
  --bg: #eef4fb;
  --bg-2: #e3edf7;
  --elev: #ffffff;
  --surface: #ffffff;
  --surface-2: #f3f8fd;
  --line: #cddcea;
  --line-strong: #a9c0d6;
  --text: #0c2744;
  --muted: #4d6780;
  --faint: #7d93a8;
  --accent: #1565c0;
  --accent-2: #0d47a1;
  --accent-fg: #ffffff;
  --accent-soft: #d6e8fa;
  --teal: #0288d1;
  --teal-soft: #d4eefc;
  --ok: #15803d;
  --ok-soft: #dcfce7;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --danger: #be123c;
  --danger-soft: #ffe4e6;
  --info: #0277bd;
  --info-soft: #dbeafe;
  --sidebar-bg: #0b2a4a;
  --sidebar-text: #f4f9ff;
  --sidebar-muted: #9bb4cc;
  --sidebar-active: #7ec8f0;
  --brand-from: #7ec8f0;
  --brand-to: #1565c0;
  --brand-fg: #ffffff;
  --login-glow: rgba(21, 101, 192, 0.22);
  --scrim: rgba(12, 39, 68, 0.45);
  --map-tiles: light;
}

:root[data-theme="dark"] {
  --bg: #071422;
  --bg-2: #0a1a2e;
  --elev: #13263c;
  --surface: #0e1f33;
  --surface-2: #163049;
  --line: #23425f;
  --line-strong: #2f567a;
  --text: #eaf3fb;
  --muted: #8aa3bb;
  --faint: #5e778f;
  --accent: #4db2e8;
  --accent-2: #7ec8f0;
  --accent-fg: #062033;
  --accent-soft: #123552;
  --teal: #7ec8f0;
  --teal-soft: #0e3a58;
  --ok: #4ade80;
  --ok-soft: #14532d;
  --warn: #fbbf24;
  --warn-soft: #422006;
  --danger: #fb7185;
  --danger-soft: #4c0519;
  --info: #7ec8f0;
  --info-soft: #123552;
  --sidebar-bg: #05101c;
  --sidebar-text: #eaf3fb;
  --sidebar-muted: #7d96ad;
  --sidebar-active: #7ec8f0;
  --brand-from: #7ec8f0;
  --brand-to: #1565c0;
  --brand-fg: #ffffff;
  --login-glow: rgba(77, 178, 232, 0.20);
  --scrim: rgba(4, 14, 26, 0.62);
  --map-tiles: dark;
  --shadow: 0 12px 40px rgba(4, 16, 32, 0.45);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
html { color-scheme: dark; }
html[data-theme="light"] { color-scheme: light; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  letter-spacing: 0.01em;
}
button, input, select, textarea { font-family: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
button { cursor: pointer; }
img { max-width: 100%; }

#app { height: 100%; }

/* ——— Login ——— */
.login-screen {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(900px 420px at 80% -10%, var(--login-glow), transparent 60%),
    radial-gradient(700px 360px at 10% 110%, rgba(2, 136, 209, 0.16), transparent 55%),
    var(--bg);
}
.login-card {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 32px 28px 24px;
  box-shadow: var(--shadow);
}
.brand-mark {
  width: 48px; height: 48px;
  border-radius: 14px;
  display: grid; place-items: center;
  background: linear-gradient(145deg, var(--brand-from), var(--brand-to));
  color: var(--brand-fg);
  font-weight: 700;
  letter-spacing: 0.08em;
  margin-bottom: 16px;
}
.login-card h1 { margin: 0; font-size: 28px; letter-spacing: 0.12em; }
.login-card .sub { color: var(--muted); margin: 6px 0 22px; font-size: 14px; }
.login-hints {
  margin-top: 16px;
  font-size: 12px;
  color: var(--muted);
  display: flex; gap: 8px; flex-wrap: wrap;
}
.hint-chip {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--chip-r);
  padding: 4px 8px;
  font-family: var(--mono);
  font-size: 11px;
}

/* ——— App shell ——— */
.app-shell {
  height: 100%;
  display: grid;
  grid-template-columns: var(--sidebar) 1fr;
  grid-template-rows: 1fr;
}
.sidebar {
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid rgba(255,255,255,0.06);
}
.sidebar-brand {
  display: flex; align-items: center; gap: 12px;
  padding: 18px 18px 12px;
}
.sidebar-brand .mark {
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(145deg, var(--brand-from), var(--brand-to));
  color: var(--brand-fg); display: grid; place-items: center;
  font-weight: 700; font-size: 13px;
}
.sidebar-brand strong { display: block; letter-spacing: 0.18em; font-size: 15px; }
.sidebar-brand span { display: block; color: var(--sidebar-muted); font-size: 11px; }
.nav { flex: 1; overflow: auto; padding: 8px 10px 16px; }
.nav a, .nav-btn {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  color: var(--sidebar-muted);
  border: 0; background: transparent;
  width: 100%; text-align: left; font-size: 14px;
}
.nav a:hover, .nav-btn:hover { background: rgba(255,255,255,0.05); color: var(--sidebar-text); }
.nav a.active { background: rgba(126, 200, 240, 0.16); color: var(--sidebar-active); }
.nav svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-group { margin: 4px 0; }
.nav-group-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 10px; border-radius: 8px; color: var(--sidebar-muted);
  cursor: pointer; font-size: 14px; gap: 10px;
}
.nav-group-head:hover { background: rgba(255,255,255,0.05); color: var(--sidebar-text); }
.nav-group-head .left { display: flex; align-items: center; gap: 10px; }
.nav-group-head .chev { transition: transform var(--ease); width: 14px; height: 14px; }
.nav-group.open .chev { transform: rotate(90deg); }
.nav-sub { display: none; padding: 2px 0 6px 12px; }
.nav-group.open .nav-sub { display: block; }
.nav-sub a { padding-left: 28px; font-size: 13px; }
.sidebar-user {
  padding: 12px 14px 16px;
  border-top: 1px solid rgba(255,255,255,0.06);
  display: flex; align-items: center; gap: 10px;
}
.avatar {
  width: 34px; height: 34px; border-radius: 8px;
  background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center; font-weight: 600; font-size: 13px;
}
.sidebar-user .meta { flex: 1; min-width: 0; }
.sidebar-user .meta strong { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user .meta span { color: var(--sidebar-muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--surface);
  display: grid; place-items: center; color: var(--muted);
}
.icon-btn:hover { color: var(--text); border-color: var(--line-strong); }
.sidebar .icon-btn { background: transparent; border-color: rgba(255,255,255,0.1); color: var(--sidebar-muted); }

.main {
  min-width: 0; min-height: 0;
  display: grid;
  grid-template-rows: var(--topbar) 1fr;
  background: var(--bg);
}
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 80%, transparent);
  backdrop-filter: blur(10px);
}
.topbar h2 { margin: 0; font-size: 16px; font-weight: 600; flex: 1; }
.topbar .crumb { color: var(--muted); font-weight: 400; }
.menu-btn { display: none; }
.content {
  min-height: 0;
  overflow: auto;
  padding: 18px;
}
.content.no-pad { padding: 0; overflow: hidden; }

.bottom-nav {
  display: none;
  position: fixed; left: 0; right: 0; bottom: 0;
  height: var(--bottom);
  background: var(--surface);
  border-top: 1px solid var(--line);
  z-index: 30;
  padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; color: var(--muted); font-size: 10px; font-weight: 500;
}
.bottom-nav a.active { color: var(--accent); }
.bottom-nav svg { width: 20px; height: 20px; }

/* ——— Forms / buttons ——— */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field label { font-size: 12px; color: var(--muted); font-weight: 500; }
.field input, .field select, .field textarea,
.input, .select {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  font-size: 14px;
  outline: none;
}
.field textarea { min-height: 80px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus,
.input:focus, .select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent);
}
.row-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row-3 { grid-template-columns: 1fr 1fr 1fr; }
.row-flag { grid-template-columns: minmax(140px, 0.85fr) minmax(0, 1.5fr); align-items: end; }
.field input:not([type="checkbox"]):not([type="color"]), .field select {
  height: 38px;
}
.obs-box {
  display: flex; align-items: center; gap: 8px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 0 8px;
}
.obs-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent);
}
.obs-box input[name="flag_nota"] {
  flex: 1; min-width: 0; height: 36px;
  border: 0; background: transparent; padding: 0 4px; box-shadow: none;
}
.obs-box input[name="flag_nota"]:focus { box-shadow: none; }
.flag-swatch {
  position: relative; width: 22px; height: 22px; flex-shrink: 0;
  border: 1px solid var(--line); border-radius: 4px; overflow: hidden; cursor: pointer;
}
.flag-swatch input[type="color"] {
  position: absolute; inset: -4px; width: calc(100% + 8px); height: calc(100% + 8px);
  padding: 0; border: 0; opacity: 0; cursor: pointer;
}

.form-section {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  padding: 14px 14px 12px;
  margin-bottom: 12px;
}
.form-section:last-child { margin-bottom: 0; }
.form-section-h {
  display: flex; align-items: center; gap: 10px;
  margin: 0 0 12px;
}
.form-section-h h4 {
  margin: 0; font-size: 12px; font-weight: 650;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent);
  white-space: nowrap;
}
.form-section-h i {
  flex: 1; height: 1px; background: var(--line); display: block;
}
.form-section-f {
  display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px;
}
.form-section.is-locked {
  opacity: 0.55; pointer-events: none;
  position: relative;
}
.form-section .lock-hint {
  font-size: 12px; color: var(--muted); margin: 0 0 10px;
}
.coh-box {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  min-height: 96px;
  padding: 8px;
}
.coh-row {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--elev);
  margin-bottom: 6px;
}
.coh-row .nm { font-size: 13px; font-weight: 550; flex: 1; min-width: 0; }
.coh-row .meta { font-size: 11px; color: var(--muted); }
.coh-add {
  width: 100%;
  border: 1px dashed var(--line-strong);
  background: transparent;
  color: var(--muted);
  justify-content: center;
}
.coh-add:hover { border-color: var(--accent); color: var(--accent); }
.coh-search { margin-top: 8px; }
.coh-hits { margin-top: 6px; max-height: 180px; overflow: auto; }
.coh-hit {
  display: flex; align-items: center; gap: 8px;
  width: 100%; text-align: left;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
}
.coh-hit:hover { background: var(--accent-soft); border-color: var(--accent); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent;
  background: var(--surface-2);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 13px; font-weight: 500;
  transition: background var(--ease), transform var(--ease);
}
.btn:hover { filter: brightness(1.05); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--accent-fg); }
.btn-ghost { background: transparent; border-color: var(--line); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-teal { background: var(--teal); color: var(--accent-fg); }
.btn-sm { padding: 5px 8px; font-size: 12px; }
.btn-icon { width: 32px; height: 32px; padding: 0; }

/* ——— Chips (rectangular, not pills) ——— */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  border-radius: var(--chip-r);
  padding: 6px 10px;
  font-size: 12px; font-weight: 500;
}
.chip:hover { border-color: var(--line-strong); color: var(--text); }
.chip.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-2);
}
html[data-theme="dark"] .chip.active { color: var(--accent); }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  border-radius: var(--chip-r);
  padding: 2px 7px;
  font-size: 11px; font-weight: 600;
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--line);
  white-space: nowrap;
}
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge.info { background: var(--info-soft); color: var(--info); border-color: transparent; }
.badge.teal { background: var(--teal-soft); color: var(--teal); border-color: transparent; }

/* ——— Cards / stats ——— */
.grid { display: grid; gap: 14px; }
.stats { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.stat .k { font-size: 12px; color: var(--muted); }
.stat .v { font-size: 26px; font-weight: 650; margin-top: 4px; letter-spacing: -0.03em; }
.stat .hint { font-size: 11px; color: var(--faint); margin-top: 4px; }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.card h3 { margin: 0 0 12px; font-size: 14px; font-weight: 600; }
.panel-head {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-bottom: 12px;
}
.panel-head h3, .panel-head h2 { margin: 0; flex: 1; }
.quick-links { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.quick {
  display: flex; flex-direction: column; gap: 6px;
  padding: 14px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--surface);
  color: var(--text);
}
.quick:hover { border-color: var(--accent); }
.quick span { color: var(--muted); font-size: 12px; }

/* ——— Table ——— */
.table-wrap {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: auto;
  background: var(--surface);
}
table.data {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
table.data th, table.data td {
  padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
table.data .mono { white-space: nowrap; }
table.data th {
  position: sticky; top: 0;
  background: var(--surface-2);
  font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--muted); font-weight: 600; z-index: 1;
}
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: color-mix(in srgb, var(--accent) 6%, transparent); }
.mono { font-family: var(--mono); font-size: 12px; }
.pager {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; margin-top: 10px; font-size: 12px; color: var(--muted);
}
.pager .btns { display: flex; gap: 6px; }

/* ——— Soft flag ——— */
.sflag {
  width: 9px; height: 9px; border-radius: 50%;
  display: inline-block; box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 22%, transparent);
  vertical-align: middle;
}
.pin {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; padding: 0; flex-shrink: 0;
  border-radius: var(--chip-r);
  border: 1px solid var(--line); background: var(--surface-2);
  cursor: pointer; line-height: 0; overflow: visible;
  vertical-align: middle; color: var(--accent);
}
.pin svg { width: 14px; height: 14px; display: block; overflow: visible; }
.pin:hover { border-color: var(--accent); }
.tel-cell { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.tel-toggle.on { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.tel-cell a { color: var(--text); }

/* ——— Dual list ——— */
.dual {
  display: grid;
  grid-template-columns: 1fr 56px 1fr;
  gap: 10px;
  min-height: 0;
  flex: 1;
}
.dual-col {
  display: flex; flex-direction: column; min-height: 0;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); overflow: hidden;
}
.dual-hd {
  padding: 10px 12px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.dual-hd h3 { margin: 0; font-size: 13px; flex: 1; }
.dual-tools { display: flex; gap: 6px; align-items: center; width: 100%; }
.dual-list {
  flex: 1; overflow: auto; padding: 8px; display: flex; flex-direction: column; gap: 6px;
}
.person {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px; align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--elev);
  cursor: grab;
}
.person:active { cursor: grabbing; }
.person.selected { border-color: var(--accent); background: var(--accent-soft); }
.person .nm { font-size: 13px; font-weight: 550; }
.person .meta { font-size: 11px; color: var(--muted); display: flex; gap: 6px; flex-wrap: wrap; }
.dual-mid {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
}
.page-fill {
  height: 100%;
  display: flex; flex-direction: column; min-height: 0;
  padding: 16px 18px 18px;
}
.page-fill .filters-row { margin-bottom: 10px; }
.page-fill .filters-row .chip-group { margin-bottom: 6px; }
.page-fill .filters-row .chip-group:last-child { margin-bottom: 0; }
/* Campo numérico corto (lo usan los parámetros de Cuotas). */
.rapida-n {
  width: 76px;
  padding: 7px 9px;
  font-variant-numeric: tabular-nums;
}

/* ——— Maps ——— */
.map {
  width: 100%; height: 280px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  overflow: hidden; background: var(--surface-2);
  position: relative;
  z-index: 0;
  isolation: isolate;
}
.map-dark .leaflet-tile-pane {
  filter: invert(0.92) hue-rotate(180deg) brightness(0.95) contrast(0.95) saturate(0.55);
}
/* Crédito de OpenStreetMap/CARTO: obligatorio por licencia, pero discreto hasta pasar el mouse. */
.leaflet-container .leaflet-control-attribution {
  font-size: 9px;
  line-height: 1.5;
  padding: 0 5px;
  background: rgba(255, 255, 255, 0.55);
  color: #5b6b7a;
  opacity: 0.6;
  transition: opacity 0.15s;
}
.leaflet-container .leaflet-control-attribution:hover { opacity: 1; }
.leaflet-container .leaflet-control-attribution a { color: inherit; }
.map-dark .leaflet-control-attribution {
  background: rgba(7, 20, 34, 0.55);
  color: #8aa3bb;
}
.map-sm { height: 200px; }
.map-xs { height: 150px; }
.map-lg { height: 100%; min-height: 280px; border-radius: 0; border: 0; }
.map-preview {
  position: fixed; z-index: 80; width: 260px; height: 180px;
  border-radius: 10px; overflow: hidden;
  border: 1px solid var(--line); box-shadow: var(--shadow);
  cursor: pointer;
}
.map-preview-hint {
  position: absolute; left: 10px; right: 10px; bottom: 10px;
  z-index: 500;
  display: flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-fg);
  font-size: 13px; font-weight: 600;
  box-shadow: 0 8px 18px rgba(12, 39, 68, 0.28);
  pointer-events: none;
}
.map-preview-hint svg { width: 15px; height: 15px; flex-shrink: 0; }

.qth-leaflet-popup .leaflet-popup-content-wrapper {
  background: var(--elev);
  color: var(--text);
  border-radius: 14px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 0;
}
.qth-leaflet-popup .leaflet-popup-content {
  margin: 0;
  min-width: 200px;
  line-height: 1.35;
}
.qth-leaflet-popup .leaflet-popup-tip {
  background: var(--elev);
  box-shadow: none;
}
.qth-leaflet-popup .leaflet-popup-close-button {
  top: 10px;
  right: 10px;
  width: 22px;
  height: 22px;
  padding: 0;
  border-radius: 6px;
  color: var(--muted);
  font-size: 18px;
  font-weight: 500;
  line-height: 20px;
  text-align: center;
}
.qth-leaflet-popup .leaflet-popup-close-button:hover {
  background: var(--surface-2);
  color: var(--text);
}
.qth-popup {
  padding: 14px 34px 14px 14px;
}
.qth-popup-kicker {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}
.qth-popup-kicker svg { width: 14px; height: 14px; flex-shrink: 0; }
.qth-popup-pill {
  margin-left: 2px;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.qth-popup-title {
  margin-top: 6px;
  font-size: 16px;
  font-weight: 650;
  letter-spacing: 0.01em;
  line-height: 1.25;
}
.qth-popup-meta {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}
.qth-popup-desc {
  margin-top: 8px;
  font-size: 13px;
  color: var(--text);
  line-height: 1.4;
}
.qth-popup-stat {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 600;
}
.qth-popup-stat svg { width: 14px; height: 14px; flex-shrink: 0; }

/* ——— Modal / toast / tooltip ——— */
#modal-root { position: relative; z-index: 2000; }
.scrim {
  position: fixed; inset: 0; background: var(--scrim);
  display: grid; place-items: center; z-index: 2000; padding: 16px;
}
.modal {
  width: min(720px, 100%);
  max-height: min(92vh, 900px);
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}
.modal.wide { width: min(920px, 100%); }
.modal-h {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px; border-bottom: 1px solid var(--line);
}
.modal-h h3 { margin: 0; flex: 1; font-size: 16px; }
.modal-b { padding: 16px; }
.modal-f {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 12px 16px; border-top: 1px solid var(--line);
}
.toast-root {
  position: fixed; right: 16px; bottom: 16px; z-index: 2100;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  min-width: 240px; max-width: 360px;
  background: var(--elev); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; box-shadow: var(--shadow);
  font-size: 13px;
}
.toast.err { border-color: var(--danger); }
.toast.ok { border-color: var(--ok); }
.tooltip-root {
  position: fixed; z-index: 2200;
  background: var(--elev); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; font-size: 12px; max-width: 240px;
  box-shadow: var(--shadow); pointer-events: none;
}

.empty {
  text-align: center; color: var(--muted); padding: 32px 12px;
  font-size: 13px;
}
.muted { color: var(--muted); }
.right { margin-left: auto; }
.split { display: grid; grid-template-columns: 1.2fr 1fr; gap: 14px; min-height: 0; }
.split-map { display: grid; grid-template-columns: 1fr 340px; gap: 0; height: 100%; }
.list-pane { overflow: auto; border-left: 1px solid var(--line); background: var(--surface); padding: 14px; }
.qth-board {
  height: 100%; min-height: 0;
  overflow: hidden;
  display: grid; grid-template-columns: 190px 200px minmax(0, 1fr) 312px;
}
.qth-cities, .qth-mid {
  display: flex; flex-direction: column; min-height: 0;
  border-right: 1px solid var(--line); background: var(--surface);
}
.qth-cities .panel-head, .qth-mid .panel-head { padding: 12px 12px 8px; margin-bottom: 0; gap: 6px; }
.qth-cities .panel-head h3, .qth-mid .panel-head h3 { min-width: 0; }
.qth-city-list, .qth-mid-list { overflow: auto; padding: 8px; display: flex; flex-direction: column; gap: 4px; }
.city-btn {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  width: 100%; text-align: left; padding: 9px 10px;
  border: 1px solid transparent; border-radius: 8px;
  background: transparent; font-size: 13px;
}
.city-btn:hover { background: var(--surface-2); }
.city-btn.active {
  background: var(--accent-soft); border-color: var(--accent); color: var(--accent-2);
}
html[data-theme="dark"] .city-btn.active { color: var(--accent); }
.city-btn .n { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.qth-filter {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1 1 0;
}
.qth-filter + .qth-filter { border-top: 1px solid var(--line); }
.qth-filter .qth-city-list { flex: 1; min-height: 0; }
.qth-right {
  display: contents;
}
.qth-map-wrap {
  position: relative;
  min-width: 0; min-height: 0;
  height: 100%;
  border-left: 1px solid var(--line);
  background: var(--surface-2);
}
.qth-map-wrap .map { height: 100%; border: 0; border-radius: 0; }
.qth-map-hint {
  display: none;
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 500;
  max-width: min(92%, 440px);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--elev) 88%, transparent);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow);
  color: var(--text);
  font-size: 12px;
  line-height: 1.35;
  text-align: center;
  pointer-events: none;
}
.qth-map-wrap.is-map-editing .qth-map-hint { display: block; }
.qth-vertex.leaflet-div-icon {
  background: transparent;
  border: none;
}
.qth-vertex-dot {
  display: block;
  box-sizing: border-box;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px #0003, var(--shadow);
}
.qth-vertex-dot.is-end {
  width: 16px;
  height: 16px;
}
.qth-vertex-dot.is-editing { cursor: grab; }
.qth-map-actions {
  position: absolute;
  left: 50%;
  bottom: calc(14px + 7%);
  transform: translateX(-50%);
  z-index: 500;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  max-width: 94%;
}
.qth-map-actions .btn {
  background: color-mix(in srgb, var(--elev) 82%, transparent);
  backdrop-filter: blur(8px);
  border-color: var(--line-strong);
  box-shadow: var(--shadow);
}
.qth-map-actions .btn:hover {
  background: color-mix(in srgb, var(--elev) 94%, transparent);
}
.qth-map-actions .btn-primary {
  background: color-mix(in srgb, var(--accent) 88%, transparent);
  border-color: var(--accent);
  color: var(--accent-fg);
}
.qth-map-actions .btn-primary:hover {
  background: var(--accent);
}
.qth-map-cancel, .qth-map-save, .qth-map-undo { display: none; }
.qth-map-wrap.is-map-editing .qth-map-edit { display: none; }
.qth-map-wrap.is-map-editing .qth-map-cancel,
.qth-map-wrap.is-map-editing .qth-map-save,
.qth-map-wrap.is-map-editing .qth-map-undo { display: inline-flex; }
.qth-heading {
  display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0;
}
.qth-title {
  display: flex; align-items: center; gap: 4px;
  margin: 0; min-width: 0; flex: 1;
  min-height: 28px;
  font-size: inherit; font-weight: 650; line-height: 1.25;
}
.qth-title-txt { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qth-desc-row {
  flex-shrink: 0; margin: 0 0 10px;
  min-height: 22px;
}
.qth-desc-row .qth-desc {
  margin: 0; display: flex; align-items: center; gap: 4px;
  min-height: 22px; font-size: 13px; line-height: 1.3;
}
.qth-inline-edit { flex: 1; min-width: 0; }
.qth-inline-input {
  flex: 1; min-width: 0;
  margin: 0; padding: 0 2px;
  border: 0; border-bottom: 1px solid var(--accent);
  border-radius: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: inherit;
  font-weight: inherit;
  line-height: inherit;
  height: 1.3em;
  outline: none;
}
.qth-desc .qth-inline-input { color: var(--text); font-weight: 400; }
.qth-pencil {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  cursor: pointer;
  width: 22px;
  height: 22px;
  line-height: 0;
}
.qth-pencil svg { width: 14px; height: 14px; }
.qth-pencil:hover { color: var(--accent); }
.qth-ok:hover { color: var(--ok); }
.qth-no:hover { color: var(--danger); }
.qth-detail {
  min-width: 0; min-height: 0;
  height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  padding: 12px;
}
.qth-detail > .empty { margin: auto; }
.qth-detail > .panel-head { flex-shrink: 0; }
.qth-desc { flex-shrink: 0; font-size: 13px; }
.qth-plantel {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.qth-plantel .turno-col,
.qth-plantel > .empty {
  flex: 1;
  min-height: 0;
}
.turno-seg {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  flex-shrink: 0;
  align-items: center;
  margin: 0;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}
.turno-seg button {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 500;
  border-radius: 999px;
  white-space: nowrap;
  min-width: 0;
  overflow: hidden;
}
.turno-seg button span {
  font-variant-numeric: tabular-nums;
  opacity: 0.75;
  margin-left: 4px;
}
.turno-seg button:hover { color: var(--text); }
.turno-seg button.active {
  background: var(--accent);
  color: var(--accent-fg);
  box-shadow: none;
}
.turno-seg button.active span { opacity: 0.9; color: inherit; }
html[data-theme="dark"] .turno-seg button.active {
  background: var(--accent);
  color: #072033;
}
.qth-main {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 0.68fr);
  gap: 12px;
}
.qth-visitas {
  min-height: 0;
  display: flex;
  flex-direction: column;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  background: var(--elev);
}
.qth-visitas .qth-dl { margin-top: 0; }
.qth-visitas-list { overflow: auto; min-height: 0; flex: 1; }
.qth-visitas .qth-visita { margin-top: 8px; grid-template-columns: 1fr; }
.turno-col {
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 8px;
  background: var(--elev);
  min-height: 0;
  display: flex; flex-direction: column; gap: 8px;
  overflow: hidden;
}
.turno-block {
  padding: 8px 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  min-width: 0;
}
.turno-block-enc {
  flex: none;
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 28%, var(--line));
}
.turno-block-per {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 28%, var(--line));
}
.turno-block-h {
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
  font-size: 11px; font-weight: 650; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--muted);
  margin-bottom: 6px;
}
.turno-block-enc .turno-block-h,
.turno-block-per .turno-block-h { color: var(--accent-2); }
.turno-add {
  display: flex; align-items: center; justify-content: center;
  width: 100%; min-height: 44px; padding: 8px;
  border: 1px dashed var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--muted);
}
.turno-add:hover { border-color: var(--accent); color: var(--accent); background: var(--surface); }
.turno-person {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 8px 8px 10px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 13px;
}
.turno-person > div:first-child { min-width: 0; flex: 1; }
.turno-person .nm { font-weight: 600; }
.turno-person .meta {
  display: flex; align-items: center; flex-wrap: wrap; gap: 2px 0;
  font-size: 11px; color: var(--muted);
}
.turno-person .meta > span { min-width: 0; }
.turno-person .meta-dot { padding: 0 6px; color: var(--faint); }
.tel-toggle {
  display: inline-flex; align-items: center; gap: 0;
  margin: 0; padding: 1px 2px;
  border: 0; border-radius: 4px;
  background: transparent; color: var(--accent);
  cursor: pointer; line-height: 1; vertical-align: middle;
}
.tel-toggle svg { width: 14px; height: 14px; flex-shrink: 0; }
.tel-toggle .tel-num {
  display: inline-block;
  max-width: 0; margin-left: 0;
  overflow: hidden; opacity: 0;
  white-space: nowrap;
  font-family: var(--mono);
  color: var(--text);
  transition: max-width 180ms ease, opacity 160ms ease, margin 160ms ease;
}
.tel-toggle.is-open .tel-num {
  max-width: 11em; opacity: 1; margin-left: 5px;
}
.tel-toggle:hover, .tel-toggle.is-open { color: var(--accent-2); }
.turno-col > div:last-child {
  flex: 1; min-height: 0; display: flex; flex-direction: column;
}
.turno-people { display: flex; flex-direction: column; gap: 6px; flex: 1; min-height: 0; overflow: auto; }
.pick-toolbar { display: flex; flex-direction: column; gap: 10px; }
.pick-q { width: 100%; box-sizing: border-box; }
.pick-head, .pick-item {
  display: grid;
  grid-template-columns: minmax(90px, 1.1fr) minmax(72px, 0.8fr) minmax(90px, 1fr) minmax(90px, 1fr) minmax(110px, 1.3fr) minmax(76px, 0.7fr);
  gap: 8px;
  align-items: center;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  box-sizing: border-box;
}
.pick-head {
  margin-top: 10px;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  padding-bottom: 4px;
}
.pick-list { display: flex; flex-direction: column; gap: 4px; max-height: 320px; overflow: auto; }
.pick-item {
  border: 1px solid var(--line); border-radius: 8px; background: var(--elev);
}
.pick-item.is-asignado { background: var(--surface-2); }
.pick-item span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick-item .pick-estado { font-size: 12px; font-weight: 600; }
.pick-item.is-libre .pick-estado { color: var(--ok); font-weight: 500; }
.pick-item.is-asignado .pick-estado { color: var(--accent-2); }
.pick-head span:last-child, .pick-item .pick-km { text-align: right; }
.pick-item .pick-km.muted { font-size: 12px; }
.pick-item:hover { border-color: var(--accent); background: var(--accent-soft); }
.qth-dl {
  margin: 12px 0 6px; font-size: 11px; font-weight: 650;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted);
}
.turno-col .qth-dl { margin-top: 0; }
.qth-line {
  display: flex; flex-direction: column; gap: 4px;
  padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13px;
}
.qth-visita-top {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.qth-visita-ts {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--chip-r);
  padding: 2px 7px;
  white-space: nowrap;
}
.qth-visita-obs { min-width: 0; color: var(--text); line-height: 1.35; }
.qth-visita {
  display: grid; grid-template-columns: 140px 1fr auto; gap: 8px; align-items: center;
  margin-top: 12px;
}
.qth-visita select, .qth-visita input {
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 8px 10px; font-size: 13px;
}
.qth-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  text-align: left; padding: 10px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--elev); color: inherit; width: 100%;
}
.qth-card:hover, .qth-card.active { border-color: var(--accent); background: var(--accent-soft); }
.qth-card strong { font-size: 13px; }
.city-group { margin-bottom: 14px; }
.city-h {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font-size: 11px; font-weight: 650; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--accent); margin-bottom: 6px;
}
.chip-group { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; width: 100%; margin-bottom: 8px; }
.chip-group-l {
  font-size: 11px; font-weight: 650; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--muted); min-width: 108px;
}
.qth-item {
  padding: 10px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 8px;
  cursor: pointer; background: var(--elev);
}
.qth-item:hover, .qth-item.active { border-color: var(--accent); }
.bar {
  height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden;
}
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.check { width: 16px; height: 16px; accent-color: var(--accent); }

.more-sheet {
  position: fixed; left: 0; right: 0; bottom: var(--bottom);
  background: var(--surface); border-top: 1px solid var(--line);
  padding: 10px 12px 14px; z-index: 29;
  display: grid; gap: 6px;
}
.more-sheet a { padding: 10px; border-radius: 8px; color: var(--text); }
.more-sheet a:hover { background: var(--surface-2); }

.dash-split { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; margin-top: 14px; }
.log-split { display: grid; grid-template-columns: 1fr 280px; gap: 14px; margin-bottom: 14px; align-items: start; }
.log-split #log-map { height: 420px; }
.log-cer {
  max-height: 420px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.log-cer #cer-res {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  max-height: 320px;
}
.log-cer .cer-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
  line-height: 1.3;
}

@media (max-width: 960px) {
  .dash-split, .log-split { grid-template-columns: 1fr !important; }
  .app-shell {
    grid-template-columns: 1fr;
    min-width: 0;
    padding-bottom: var(--bottom);
  }
  #app, .main, .content { min-width: 0; }
  .sidebar { display: none; }
  .sidebar.open {
    display: flex; position: fixed; inset: 0 auto 0 0; width: min(280px, 86vw); z-index: 40;
  }
  .menu-btn { display: grid; }
  .content { padding-bottom: 16px; }
  .page-fill { padding-bottom: 12px; }
  .bottom-nav { display: flex; }
  .dual { grid-template-columns: 1fr; }
  .dual-mid { flex-direction: row; padding: 4px 0; }
  .split, .split-map, .quick-links, .row-fields, .row-flag, .row-3 { grid-template-columns: 1fr; }
  .split-map { height: auto; }
  .map-lg { min-height: 240px; height: 240px; }
  .qth-board {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-width: 0;
    overflow-x: hidden;
    overflow-y: auto;
  }
  .qth-cities, .qth-mid {
    flex: none;
    max-height: none;
    min-width: 0;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .qth-cities { overflow: visible; }
  .qth-filter {
    flex: none;
    display: flex;
    flex-direction: column;
    min-width: 0;
  }
  .qth-filter + .qth-filter { border-top: 1px solid var(--line); }
  .qth-filter .panel-head {
    padding: 8px 12px 0;
    margin: 0;
  }
  .qth-filter .panel-head h3 {
    font-size: 11px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    line-height: 1.2;
  }
  .qth-filter .qth-city-list,
  .qth-mid-list {
    flex: none;
    flex-direction: row;
    flex-wrap: nowrap;
    min-width: 0;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    scrollbar-width: thin;
    gap: 6px;
  }
  .qth-filter .qth-city-list { padding: 4px 12px 8px; }
  .qth-mid .panel-head { padding: 10px 12px 6px; }
  .qth-mid-list { padding: 6px 12px 10px; }
  .qth-city-list .empty, .qth-mid-list .empty {
    padding: 8px 4px;
    text-align: left;
    white-space: nowrap;
  }
  .city-btn, .qth-card {
    width: auto;
    flex: 0 0 auto;
    white-space: nowrap;
  }
  .qth-card { min-width: 148px; }
  .qth-detail {
    flex: 1 0 auto;
    height: auto;
    min-width: 0;
    min-height: 0;
    overflow: visible;
    padding: 12px;
  }
  .qth-detail > .panel-head { min-width: 0; }
  .qth-heading { flex: 1 1 auto; min-width: 0; }
  .qth-main {
    flex: 1 1 auto;
    grid-template-columns: 1fr 1fr;
    min-height: 0;
  }
  .qth-visitas, .turno-col, .qth-plantel { min-height: 0; }
  .qth-visitas-list, .turno-people { max-height: 220px; }
  .qth-map-wrap {
    flex: none;
    height: 40vh;
    height: 40dvh;
    min-height: 40vh;
    min-height: 40dvh;
    border-left: 0;
    border-top: 1px solid var(--line);
  }
  .turno-seg button { padding: 8px 6px; }
  .qth-visita { grid-template-columns: 1fr; }
  .qth-heading h3 { overflow-wrap: anywhere; }
}

@media (max-width: 640px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .login-card { padding: 24px 18px; }
  .qth-main { grid-template-columns: 1fr; flex: none; }
  .qth-plantel, .turno-col { flex: none; }
  .qth-visitas-list, .turno-people { max-height: none; }
  .qth-map-wrap { height: 40vh; height: 40dvh; min-height: 40vh; min-height: 40dvh; }
  .qth-detail > .panel-head { gap: 8px; }
  .qth-heading { flex: 1 0 100%; }
  .qth-detail { flex: none; }
  .turno-col > div:last-child { flex: none; }
  .turno-seg button { padding: 8px 4px; }
  .pick-head, .pick-item {
    grid-template-columns: minmax(64px, 1fr) minmax(56px, 0.8fr) minmax(64px, 1fr) minmax(64px, 1fr) minmax(72px, 1.1fr) minmax(56px, 0.7fr);
    gap: 4px;
    padding: 8px 6px;
  }
  .pick-item { font-size: 12px; }
}

/* ——— Asignar efectivos a zonas ——— */
.toast.has-action { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; vertical-align: middle; }
kbd {
  font-family: var(--mono); font-size: 10px; padding: 1px 5px;
  border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; background: var(--surface-2);
}
.asg {
  height: 100%; min-height: 0;
  display: grid; grid-template-columns: 250px minmax(0, 1fr);
}
.asg-panel {
  display: flex; flex-direction: column; gap: 10px; min-height: 0;
  padding: 14px 12px; border-right: 1px solid var(--line); background: var(--surface);
}
.asg-scope { display: grid; gap: 8px; }
.asg-scope label { display: grid; gap: 4px; font-size: 11px; font-weight: 650; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); }
.asg-zlist {
  flex: 1; min-height: 0; overflow: auto;
  display: flex; flex-direction: column; gap: 6px; padding: 2px; outline: none;
}
.asg-zlist:focus-visible { box-shadow: 0 0 0 2px var(--accent-soft); border-radius: var(--radius-sm); }
.asg-z {
  display: grid; gap: 4px; text-align: left; width: 100%;
  padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--elev); color: var(--text); cursor: pointer;
}
.asg-z:hover { border-color: var(--line-strong); }
.asg-z.active { border-color: var(--accent); background: var(--accent-soft); }
.asg-z-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.asg-z-n { font-size: 13px; font-weight: 600; }
.asg-z-l { font-size: 11px; color: var(--muted); font-weight: 400; }
.asg-z-c { font-family: var(--mono); font-size: 12px; color: var(--muted); white-space: nowrap; }
.asg-z .bar { height: 5px; }
.asg-z.full .bar > i { background: var(--ok); }
.asg-z.over .bar > i { background: var(--warn); }
.asg-z.over .asg-z-c { color: var(--warn); font-weight: 650; }
.asg-cupo {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font-size: 12px; color: var(--muted);
}
.asg-cupo strong { color: var(--text); }
.asg-cupo .input { width: 76px; padding: 6px 8px; }
.asg-tot {
  display: grid; gap: 2px; font-size: 12px; color: var(--muted);
  padding-top: 8px; border-top: 1px solid var(--line);
}
.asg-tot strong { color: var(--text); font-family: var(--mono); }
.asg-hint { margin: 0; font-size: 11px; color: var(--faint); line-height: 1.6; }
.asg-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.asg-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--surface);
}
.asg-bar .input { width: auto; max-width: 220px; padding: 6px 8px; font-size: 12px; }
.asg-bar-sp { flex: 1; }
.asg-seg {
  display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden;
  background: var(--surface-2);
}
.asg-seg button {
  border: 0; background: transparent; color: var(--muted);
  padding: 6px 12px; font-size: 12px; font-weight: 550; cursor: pointer;
}
.asg-seg button + button { border-left: 1px solid var(--line); }
.asg-seg button.active { background: var(--accent); color: var(--accent-fg); }
.asg-seg.sm button { padding: 4px 9px; font-size: 11px; }
.asg-chk { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); cursor: pointer; }
.asg-inl { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.asg-body { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 12px 16px 16px; overflow: hidden; }
.asg-lista { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.asg-note { margin: 0 0 8px; font-size: 12px; color: var(--muted); }
.asg-note strong { color: var(--text); }
.asg-tools { padding: 8px 12px; }
.asg-tools .input { flex: 1; min-width: 0; }
.asg-more { align-self: center; margin: 4px 0; }
.asg-mid-n { font-family: var(--mono); font-size: 11px; color: var(--accent); min-height: 14px; }
.person-b { min-width: 0; }
.person.is-blocked { opacity: 0.6; border-style: dashed; }
.person.is-blocked.selected { opacity: 1; }
[data-drop].drop-hover { outline: 2px dashed var(--accent); outline-offset: -4px; }
.asg-mapwrap { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 12px; }
.asg-map { height: 100%; min-height: 360px; }
.asg-mapside { display: flex; flex-direction: column; gap: 12px; min-height: 0; overflow: auto; }
.asg-legend, .asg-mapsel {
  display: grid; gap: 6px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); font-size: 12px;
}
.asg-legend label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.asg-legend-z { display: grid; gap: 4px; margin-top: 4px; }
.asg-lz {
  display: flex; align-items: center; gap: 6px; width: 100%; text-align: left;
  border: 1px solid transparent; background: transparent; color: var(--text);
  border-radius: var(--radius-sm); padding: 4px 6px; font-size: 12px; cursor: pointer;
}
.asg-lz .asg-z-c { margin-left: auto; }
.asg-lz.active { border-color: var(--accent); background: var(--accent-soft); }
.asg-mapbtns { display: flex; flex-wrap: wrap; gap: 6px; }
.asg-mapsel-list { display: grid; gap: 2px; max-height: 260px; overflow: auto; }
.asg-zpin { background: none; border: 0; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.45)); cursor: pointer; }
.asg-zpin svg { display: block; }
.asg-zpin.is-active { filter: drop-shadow(0 0 3px rgba(0, 0, 0, 0.6)) drop-shadow(0 2px 4px rgba(0, 0, 0, 0.4)); }
.asg-lz svg { flex-shrink: 0; }
.plan { flex: 1; min-height: 0; overflow: auto; display: grid; gap: 14px; align-content: start; }
.plan-cfg, .plan-res {
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface);
  padding: 14px 16px; display: grid; gap: 10px; min-width: 0;
}
.plan-cfg h3 { margin: 0; font-size: 15px; }
.plan-cfg p { margin: 0; font-size: 12px; }
.plan-table-wrap { overflow-x: auto; }
.plan-ztable, .plan-rtable { width: 100%; border-collapse: collapse; font-size: 12px; }
.plan-ztable th { text-align: left; font-size: 11px; color: var(--muted); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.plan-ztable td, .plan-rtable td { padding: 5px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.plan-ztable tr.is-active td { background: var(--accent-soft); }
.plan-cupo { width: 80px; padding: 4px 6px; }
.plan-opts { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; }
.plan-acts { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.plan-sum { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }
.plan-sum > div {
  display: grid; gap: 2px; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2);
}
.plan-sum strong { font-size: 18px; font-family: var(--mono); }
.plan-sum span { font-size: 11px; color: var(--muted); }
.plan-sum .warn { border-color: var(--warn); background: var(--warn-soft); }
.plan-res h4 { display: flex; align-items: center; gap: 6px; margin: 12px 0 4px; font-size: 13px; }
.plan-rtable .input { padding: 4px 6px; font-size: 12px; min-width: 140px; }
.plan-rtable tr.is-far td { background: var(--warn-soft); }
.plan-dom { color: var(--muted); max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plan-map { height: 480px; }
.cq-tools { display: flex; flex-wrap: wrap; gap: 6px; }
.cq-tree { border: 1px solid var(--line); border-radius: var(--radius-sm); max-height: 46vh; overflow: auto; }
.cq-row {
  display: grid; grid-template-columns: minmax(0, 1fr) 72px 96px 64px; gap: 8px; align-items: center;
  padding: 4px 10px; border-bottom: 1px solid var(--line); font-size: 13px;
}
.cq-row:last-child { border-bottom: 0; }
.cq-head {
  position: sticky; top: 0; z-index: 1; background: var(--surface-2);
  font-size: 11px; font-weight: 600; color: var(--muted); padding: 6px 10px;
}
.cq-row.lvl-0 { font-weight: 600; background: var(--surface-2); }
.cq-row.lvl-1 .cq-name { padding-left: 20px; }
.cq-row.lvl-2 .cq-name { padding-left: 40px; font-size: 12px; }
.cq-name { display: flex; align-items: center; gap: 4px; min-width: 0; }
.cq-name > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cq-tog, .cq-tog-sp { width: 20px; height: 20px; flex-shrink: 0; }
.cq-tog { border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 0; font-size: 12px; }
.cq-num { font-family: var(--mono); font-size: 12px; color: var(--muted); text-align: right; }
.cq-in { padding: 4px 6px; font-size: 12px; text-align: right; }
.cq-in::placeholder { color: var(--faint); }
.cq-avisos {
  display: grid; gap: 2px; padding: 8px 10px; font-size: 12px;
  border: 1px solid var(--warn); border-radius: var(--radius-sm); background: var(--warn-soft); color: var(--warn);
}
.cq-s0 { border-color: var(--ok) !important; background: var(--ok-soft) !important; }
.cq-s1 { border-color: var(--info) !important; background: var(--info-soft) !important; }
.cq-s2 { border-color: var(--warn) !important; background: var(--warn-soft) !important; }
.cq-s3 { border-color: var(--danger) !important; background: var(--danger-soft) !important; }
.cq-b0 { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.cq-b1 { background: var(--info-soft); color: var(--info); border-color: transparent; }
.cq-b2 { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.cq-b3 { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.cq-ztable td.cq-c0 { color: var(--ok); font-weight: 600; }
.cq-ztable td.cq-c1 { color: var(--info); font-weight: 600; }
.cq-ztable td.cq-c2 { color: var(--warn); font-weight: 600; }
.cq-ztable td.cq-c3 { color: var(--danger); font-weight: 600; }
.cq-ztable td.cq-falta { color: var(--danger); font-weight: 650; }
.cq-ztable td svg { vertical-align: -2px; }
.cq-detail > td { background: var(--surface-2); padding: 4px 8px 10px; }

@media (max-width: 960px) {
  .content.no-pad:has(.asg) { overflow: auto; }
  .asg { grid-template-columns: 1fr; height: auto; min-height: 100%; }
  .asg-panel { border-right: 0; border-bottom: 1px solid var(--line); }
  .asg-zlist { flex-direction: row; overflow-x: auto; overflow-y: hidden; flex: none; padding-bottom: 4px; }
  .asg-z { width: auto; min-width: 150px; flex: 0 0 auto; }
  .asg-hint { display: none; }
  .asg-body { overflow: visible; padding: 10px 12px 16px; }
  .asg-lista .dual-list { max-height: 55vh; }
  .asg-mapwrap { grid-template-columns: 1fr; }
  .asg-map { height: 55vh; min-height: 300px; }
  .asg-bar { padding: 8px 12px; }
  .asg-bar .input { max-width: none; flex: 1 1 140px; }
  .plan { overflow: visible; }
}

/* ——— Visitas de control (inspector en recorrida) ——— */
.vis { display: grid; grid-template-columns: minmax(280px, 360px) minmax(0, 1fr); gap: 14px; align-items: start; }
.vis-list, .vis-ficha {
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface);
  padding: 12px; min-width: 0;
}
.vis-top { display: grid; gap: 8px; }
.vis-top .input { width: 100%; min-width: 0; font-size: 15px; }
.vis-search { display: flex; gap: 6px; }
.vis-search .input { flex: 1; min-width: 0; }
.vis-search .btn.active { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.vis-prog { margin: 10px 2px 8px; font-size: 13px; color: var(--muted); }
.vis-prog strong { color: var(--text); }
.vis-items { display: grid; gap: 6px; max-height: calc(100vh - 250px); overflow: auto; }
.vis-item {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 52px; padding: 8px 12px;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--elev);
  color: var(--text); text-align: left; cursor: pointer;
}
.vis-item:hover { border-color: var(--accent); }
.vis-item.is-sel { border-color: var(--accent); background: var(--accent-soft); }
.vis-it-main { display: grid; flex: 1; min-width: 0; }
.vis-it-main strong { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vis-it-main small { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vis-km { font-size: 12px; color: var(--muted); }
.vis-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; background: var(--ok); }
.vis-dot.pend { background: transparent; border: 2px solid var(--muted); }
.vis-dot.warn { background: var(--warn); }
.vis-dot.danger { background: var(--danger); }
.vis-vacia { padding: 40px 0; }
.vis-nav { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.vis-pos { flex: 1; text-align: center; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.vis-back { display: none; }
.vis-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.vis-head h2 { margin: 0 0 2px; font-size: 20px; }
.vis-head .btn { flex-shrink: 0; }
.vis-ult { margin-top: 6px; font-size: 13px; color: var(--ok); font-weight: 550; }
.vis-ult.pend { color: var(--warn); }
.vis-form { display: grid; gap: 8px; padding: 12px; margin-bottom: 14px; border-radius: var(--radius-sm); background: var(--surface-2); }
.vis-res { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.vis-rb {
  min-height: 48px; padding: 8px 6px; border: 2px solid var(--line); border-radius: var(--radius-sm);
  background: var(--elev); color: var(--text); font-size: 14px; font-weight: 600; cursor: pointer;
}
.vis-rb.ok.active { border-color: var(--ok); background: var(--ok-soft); color: var(--ok); }
.vis-rb.warn.active { border-color: var(--warn); background: var(--warn-soft); color: var(--warn); }
.vis-rb.danger.active { border-color: var(--danger); background: var(--danger-soft); color: var(--danger); }
.vis-obs { width: 100%; resize: vertical; font-size: 15px; }
.vis-go { min-height: 46px; font-size: 15px; }
.vis-plantel { display: grid; gap: 8px; margin-bottom: 14px; }
.vis-personal { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.vis-personal li {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 6px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); font-size: 13px;
}
.vis-personal li > span { display: grid; min-width: 0; }
.vis-personal li small { font-size: 12px; }
.vis-personal .badge { margin-left: 6px; font-size: 10px; vertical-align: 1px; }
.vis-tel { flex-shrink: 0; }
.vis-hist h4 { margin: 0 0 6px; font-size: 12px; font-weight: 650; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.vis-hrow { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.vis-hrow p { flex-basis: 100%; margin: 0; color: var(--muted); }

@media (max-width: 900px) {
  .vis { grid-template-columns: minmax(0, 1fr); }
  .vis:not(.has-sel) .vis-ficha { display: none; }
  .vis.has-sel .vis-list { display: none; }
  .vis-back { display: inline-flex; }
  .vis-items { max-height: none; }
  .vis-head { flex-direction: column; }
  .vis-head .btn { width: 100%; justify-content: center; }
}
