:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --text: #1e293b;
  --muted: #64748b;
  --border: #dbe1ea;
  --primary: #1d4ed8;
  --primary-hover: #1e40af;
  --danger-bg: #fee2e2;
  --danger-text: #991b1b;
  --topbar: #0f2a4a;
  --sidebar-w: 320px;
  font-size: 15px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}
a { color: var(--primary); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* Top bar */
.topbar {
  display: flex; align-items: center; gap: 1.5rem;
  height: 52px; padding: 0 1rem;
  background: var(--topbar); color: #fff;
}
.brand { display: flex; align-items: center; gap: .6rem; color: #fff; text-decoration: none; font-weight: 600; }
.brand small { font-weight: 400; opacity: .75; margin-left: .3rem; }
/* App logo: the favicon image (folded map, municipal orange) */
.brand-mark { display: block; flex-shrink: 0; width: 32px; height: 32px; }
.login-brand .brand-mark { width: 44px; height: 44px; }
.mainnav { display: flex; gap: 1rem; flex: 1; }
.mainnav a { color: #fff; text-decoration: none; opacity: .9; }
.mainnav a:hover { opacity: 1; text-decoration: underline; }
.nav-soon { opacity: .45; cursor: default; }
.userbox { display: flex; gap: 1rem; align-items: center; font-size: .9rem; }
.userbox small { opacity: .7; }
.userbox a { color: #fff; }

/* Layouts */
.main { padding: 1.5rem; max-width: 1200px; margin: 0 auto; }
.layout-full { display: flex; flex-direction: column; }
.main-full { flex: 1; min-height: 0; }
.map-layout { display: flex; height: 100%; }
#map { flex: 1; height: 100%; }

/* Sidebar */
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0; overflow-y: auto;
  background: var(--surface); border-right: 1px solid var(--border);
  padding: 1rem;
}
.sidebar h2 { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 1rem 0 .5rem; }
.sidebar h2:first-child { margin-top: 0; }
.sidebar label { display: block; font-size: .85rem; margin-bottom: .6rem; }
.sidebar select, .sidebar input[type=date] { width: 100%; margin-top: .2rem; }
.sidebar .row-dates { grid-template-columns: repeat(auto-fit, minmax(132px, 1fr)); }
.sidebar label.check { display: flex; gap: .4rem; align-items: center; }
fieldset.solo-lectura { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset.disabled-block { border: 1px dashed var(--border); border-radius: 8px; padding: .6rem .8rem; margin: .8rem 0; opacity: .6; }
fieldset legend { font-size: .8rem; color: var(--muted); padding: 0 .3rem; }
.badge { background: #e2e8f0; color: var(--muted); border-radius: 999px; padding: .05rem .45rem; font-size: .7rem; }

/* Forms */
input[type=text], input[type=password], input[type=date], input[type=tel], input[type=email], select, textarea {
  font: inherit; padding: .45rem .55rem; border: 1px solid var(--border); border-radius: 6px; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid #93c5fd; border-color: #60a5fa; }
.btn { font: inherit; padding: .55rem 1rem; border-radius: 6px; border: 1px solid transparent; cursor: pointer; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.alert { padding: .6rem .8rem; border-radius: 6px; margin-bottom: 1rem; font-size: .9rem; }
.alert-error { background: var(--danger-bg); color: var(--danger-text); }

/* Login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login-card {
  width: 100%; max-width: 360px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 1.75rem; box-shadow: 0 8px 30px rgba(15, 42, 74, .08);
}
.login-brand { display: flex; gap: .75rem; align-items: center; margin-bottom: 1.25rem; }
.login-brand small { color: var(--muted); }
.login-card label { display: block; margin-bottom: .9rem; font-size: .9rem; }
.login-card input { width: 100%; margin-top: .25rem; }
.login-card .btn { width: 100%; margin-top: .3rem; }
.login-card p { text-align: center; margin: 1rem 0 0; }
body:not(.layout-full) > .main:has(.login-wrap) { padding: 0; max-width: none; }

/* Map labels */
.barrio-label {
  background: transparent; border: none; box-shadow: none;
  font-size: 10px; font-weight: 600; color: #1e3a8a; text-shadow: 0 0 3px #fff, 0 0 3px #fff;
}
.barrio-label::before { display: none; }

/* Pages */
h1 { font-size: 1.45rem; margin: .2rem 0 .3rem; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.page-head p { margin: 0; }
.actions { display: flex; gap: .5rem; }
.btn { background: #fff; border-color: var(--border); color: var(--text); text-decoration: none; display: inline-block; }
.btn:hover { background: #f1f5f9; }
.btn-primary { border-color: transparent; background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-link { background: none; border: none; color: var(--primary); padding-left: .3rem; padding-right: .3rem; }
.btn-link:hover { background: none; text-decoration: underline; }
.alert-ok { background: #dcfce7; color: #166534; }
.progress { width: 260px; height: 6px; background: #e2e8f0; border-radius: 999px; overflow: hidden; margin-top: .4rem; }
.progress span { display: block; height: 100%; background: #16a34a; }

.filters { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: .7rem; margin-bottom: .5rem; }
.filters input[type=search] { flex: 1 1 220px; font: inherit; padding: .45rem .55rem; border: 1px solid var(--border); border-radius: 6px; }
.filters label.check { display: flex; gap: .3rem; align-items: center; font-size: .9rem; }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th, .table td { padding: .5rem .7rem; border-bottom: 1px solid #eef2f7; text-align: left; vertical-align: top; }
.table th { background: #f8fafc; font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); position: sticky; top: 0; }
.table tr:hover td { background: #f8fafc; }
.table .c { text-align: center; }
.table .r { text-align: right; white-space: nowrap; }
.row-inactive td { opacity: .55; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: .4rem; vertical-align: middle; }
.tag { display: inline-block; font-size: .7rem; padding: .05rem .4rem; border-radius: 4px; background: #e2e8f0; color: #475569; margin-left: .3rem; }
.tag-muni { background: #dbeafe; color: #1e40af; }
.ok { color: #16a34a; }
.warn { color: #b45309; font-size: .8rem; }

/* Espacio form */
.form-grid { display: grid; grid-template-columns: minmax(280px, 380px) 1fr; gap: 1.25rem; border: 0; padding: 0; margin: 0; }
.form-col label { display: block; margin-bottom: .75rem; font-size: .9rem; }
.form-col input[type=text], .form-col select, .form-col textarea { width: 100%; margin-top: .2rem; }
.form-col label.check { display: flex; gap: .4rem; align-items: center; }
.coords { display: flex; gap: .5rem; align-items: flex-end; }
.coords label { flex: 1; }
.coords input { background: #f8fafc; }
.coords .btn-link { margin-bottom: .8rem; }
.form-actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .5rem; }
.form-map { position: relative; }
#map-form { height: 560px; border: 1px solid var(--border); border-radius: 8px; }
.geo-search { display: flex; gap: .5rem; margin-bottom: .5rem; }
.geo-search input { flex: 1; font: inherit; padding: .45rem .55rem; border: 1px solid var(--border); border-radius: 6px; }
.geo-results { list-style: none; margin: 0 0 .5rem; padding: 0; background: #fff; border: 1px solid var(--border); border-radius: 6px; max-height: 200px; overflow-y: auto; }
.geo-results li { border-bottom: 1px solid #eef2f7; padding: .1rem; font-size: .85rem; }
.geo-results li.muted { padding: .5rem; }
.geo-results button { all: unset; display: block; box-sizing: border-box; width: 100%; padding: .4rem .5rem; cursor: pointer; white-space: normal; }
.geo-results button:hover { background: #eff6ff; }

/* Main map: espacio card */
.card-esp h3 { margin: 0 0 .2rem; font-size: 1rem; }
.card-esp .meta { color: var(--muted); font-size: .82rem; margin-bottom: .4rem; }
.card-esp .stats { display: flex; gap: .8rem; font-size: .85rem; margin: .4rem 0; }
.card-esp .stats b { font-size: 1.05rem; }
.legend { font-size: .82rem; }
.legend div { display: flex; align-items: center; gap: .3rem; margin-bottom: .2rem; }
.legend label.check { margin-bottom: .25rem; }

.sw { display: inline-block; width: 16px; height: 11px; border-radius: 2px; margin-right: .4rem; border: 1px solid rgba(0,0,0,.15); vertical-align: middle; }
.row-dates { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem; }
.sq { display: inline-block; width: 10px; height: 10px; background: #64748b; transform: rotate(45deg); margin-right: .4rem; }
.act-marker { width: 12px; height: 12px; transform: rotate(45deg); border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.35); }

/* Catalogs */
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); margin-bottom: 1rem; }
.tabs a { padding: .5rem .9rem; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.cat-list { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; }
/* Fixed width for the actions column: each row is its own grid, so an "auto" column would
   make the header and the rows compute different widths and misalign the titles. */
.cat-row { display: grid; grid-template-columns: 52px minmax(180px, 1fr) 80px 60px 70px 250px; gap: .6rem; align-items: center; padding: .45rem .7rem; }
.cat-head { font-size: .75rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); background: #f8fafc; border-bottom: 1px solid var(--border); border-radius: 8px 8px 0 0; }
.cat-item { border-bottom: 1px solid #eef2f7; }
.cat-item:last-child { border-bottom: 0; }
.cat-row input[type=text], .cat-row input[type=number] { width: 100%; font: inherit; padding: .35rem .5rem; border: 1px solid var(--border); border-radius: 6px; }
.cat-row input[type=color] { width: 44px; height: 32px; padding: 2px; border: 1px solid var(--border); border-radius: 6px; background: #fff; cursor: pointer; }
.cat-actions { display: flex; gap: .2rem; justify-content: flex-end; flex-wrap: wrap; }
.btn-sm { padding: .3rem .6rem; font-size: .85rem; }
.btn-link.danger { color: #b91c1c; }
.merge-row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; padding: .5rem .7rem .7rem 4.3rem; font-size: .88rem; background: #fffbeb; }
.cat-new { margin-top: 1rem; }
.cat-new .cat-row { padding: 0; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
@media (max-width: 760px) {
  .cat-row { grid-template-columns: 48px 1fr 64px; }
  .cat-head { display: none; }
  .cat-actions { grid-column: 1 / -1; justify-content: flex-start; }
}

/* Agenda */
.agenda-bar { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; justify-content: space-between; margin-bottom: .6rem; }
.seg { display: flex; gap: .25rem; align-items: center; }
.agenda-title { padding: 0 .5rem; min-width: 14rem; text-align: center; }
.ag-dia { margin-bottom: 1.2rem; }
.ag-fecha { font-size: 1rem; margin: .4rem 0 .5rem; padding-bottom: .3rem; border-bottom: 2px solid var(--border); }
.ag-fecha.hoy { color: var(--primary); border-bottom-color: var(--primary); }
.ag-item { display: grid; grid-template-columns: 64px 1fr auto; gap: .8rem; background: var(--surface); border: 1px solid var(--border);
  border-left: 5px solid #9ca3af; border-radius: 8px; padding: .6rem .8rem; margin-bottom: .45rem; }
.ag-hora { font-weight: 700; font-size: 1.05rem; line-height: 1.2; }
.ag-hora small { display: block; font-weight: 400; color: var(--muted); font-size: .8rem; }
.ag-tit { font-weight: 600; }
.ag-tit .tag, .ag-tit .estado { margin-left: .3rem; font-weight: 400; }
.ag-sub { font-size: .88rem; color: #334155; }
.ag-desc { font-size: .9rem; margin: .2rem 0; }
.ag-lugar { font-size: .88rem; margin-top: .25rem; }
.ag-acc { display: flex; flex-direction: column; gap: .2rem; font-size: .85rem; text-align: right; white-space: nowrap; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface); }
.cal-h { background: #f8fafc; font-size: .75rem; text-transform: uppercase; color: var(--muted); padding: .35rem .5rem; border-bottom: 1px solid var(--border); }
.cal-d { min-height: 110px; border-right: 1px solid #eef2f7; border-bottom: 1px solid #eef2f7; padding: .25rem .3rem; font-size: .78rem; }
.cal-d.out { background: #fafbfc; color: #94a3b8; }
.cal-d.today { background: #eff6ff; }
.cal-n { font-weight: 700; text-decoration: none; color: inherit; display: inline-block; margin-bottom: .15rem; }
.cal-ev { display: block; text-decoration: none; color: var(--text); border-left: 3px solid #9ca3af; padding: .05rem .3rem; margin-bottom: .15rem;
  background: #f8fafc; border-radius: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-ev:hover { background: #e0e7ff; }
.estado-borde-cancelada, .estado-borde-suspendida { text-decoration: line-through; opacity: .6; }
.estado-borde-a_confirmar { font-style: italic; }
.dot-priv { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: #dc2626; vertical-align: middle; }
.cal-more { font-size: .75rem; }
.print-only { display: none; }
@media (max-width: 760px) {
  .ag-item { grid-template-columns: 52px 1fr; }
  .ag-acc { grid-column: 1 / -1; flex-direction: row; justify-content: flex-end; gap: .8rem; }
  .cal-d { min-height: 70px; }
  .cal-ev { font-size: .7rem; }
}
@media print {
  .topbar, .no-print, .filters, .live-status, .bsc-list { display: none !important; }
  .print-only { display: block; }
  body { background: #fff; font-size: 11pt; }
  .main { padding: 0; max-width: none; }
  .print-head h1 { font-size: 15pt; margin: 0 0 .2rem; }
  .print-head p { margin: 0 0 .8rem; color: #444; }
  .ag-item { break-inside: avoid; border-color: #bbb; grid-template-columns: 56px 1fr; }
  .ag-fecha { break-after: avoid; }
  .cal-d { min-height: 90px; }
  a { color: inherit; text-decoration: none; }
}

/* Searchable select (buscable.js) */
.bsc { position: relative; display: block; margin-top: .2rem; }
.filters .bsc { display: inline-block; min-width: 220px; margin-top: 0; }
.bsc-native { position: absolute !important; opacity: 0; pointer-events: none; width: 1px !important; height: 1px; bottom: 0; left: 0; }
.bsc-input { width: 100%; font: inherit; padding: .45rem 1.9rem .45rem .55rem; border: 1px solid var(--border); border-radius: 6px; background: #fff
  url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") no-repeat right .6rem center; color: var(--text); }
.bsc-input:focus { outline: 2px solid #93c5fd; border-color: #60a5fa; }
.bsc-input:disabled { background-color: #f8fafc; color: var(--muted); }
.bsc-clear { position: absolute; right: 1.7rem; top: 50%; transform: translateY(-50%); border: 0; background: none; color: var(--muted); font-size: 1.1rem; line-height: 1; cursor: pointer; padding: 0 .2rem; }
.bsc-clear:hover { color: var(--text); }
.bsc-list { position: absolute; z-index: 1200; left: 0; right: 0; top: calc(100% + 2px); max-height: 280px; overflow-y: auto; margin: 0; padding: .2rem 0;
  list-style: none; background: #fff; border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 10px 25px rgba(15, 42, 74, .15); min-width: 220px; }
.bsc-opt { padding: .38rem .65rem; cursor: pointer; font-size: .9rem; }
.bsc-opt.act { background: #eff6ff; }
.bsc-opt.sel { font-weight: 600; }
.bsc-opt.empty { color: var(--muted); font-style: italic; }
.bsc-opt mark { background: #fde68a; color: inherit; padding: 0; border-radius: 2px; }
.bsc-alt { display: block; font-size: .75rem; color: var(--muted); }
.bsc-group { padding: .45rem .65rem .2rem; font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.bsc-none { padding: .5rem .65rem; color: var(--muted); font-size: .85rem; }

/* Live filters */
.filters.is-loading { opacity: 1; }
.filters.is-loading ~ [data-live-region], .is-loading + * [data-live-region] { opacity: .6; transition: opacity .15s; }
.live-status { font-size: .8rem; color: var(--muted); min-width: 5rem; }

/* Barrios */
#map-barrio { height: 640px; border: 1px solid var(--border); border-radius: 8px; }
.card-warn { border-color: #fcd34d; background: #fffbeb; }
.inline-form { display: inline-flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.help-card { margin-top: 1rem; }
.help-card ul { margin: 0; padding-left: 1.1rem; }
.help-card li { margin-bottom: .3rem; }
.geo-stats { margin: .2rem 0 .6rem; }
.hist { list-style: none; margin: 0; padding: 0; max-height: 320px; overflow-y: auto; }
.hist li { border-bottom: 1px solid #eef2f7; padding: .4rem 0; }
@media (max-width: 760px) { #map-barrio { height: 420px; } }

/* Users */
.narrow-form { max-width: 520px; }
.usr-form { max-width: 720px; }
.usr-form h2 { margin: 1rem 0 .4rem; }
.perm-acc { display: flex; flex-wrap: wrap; gap: .4rem .6rem; align-items: center; margin-bottom: .5rem; }
.card .perm-acc label { white-space: nowrap; display: flex; gap: .4rem; align-items: center; margin: 0; }
.perm-acc select { width: auto; max-width: 200px; }
.perm-tabla td, .perm-tabla th { padding: .35rem .5rem; }
.perm-tabla input[type=radio] { width: 1.1rem; height: 1.1rem; margin: 0; cursor: pointer; }
.pass-row { display: flex; gap: .5rem; margin-top: .2rem; }
.pass-row [aria-pressed] { min-width: 5.5rem; justify-content: center; }
.pass-row input, .card .pass-row input { flex: 1; min-width: 0; margin-top: 0; font-family: ui-monospace, Consolas, monospace; }
.alert-warn { background: #fef3c7; color: #92400e; }
.userbox a small { opacity: .7; }

/* Coverage */
.bar-cell { position: relative; min-width: 90px; text-align: left; }
.bar-cell .bar { display: inline-block; height: 8px; background: #93c5fd; border-radius: 4px; vertical-align: middle; margin-right: .4rem; max-width: 70%; }
.rec { display: inline-block; min-width: 48px; padding: .1rem .4rem; border-radius: 999px; font-size: .8rem; font-weight: 600; }
.rec-1 { background: #dcfce7; color: #166534; }
.rec-3 { background: #ecfccb; color: #3f6212; }
.rec-6 { background: #fef9c3; color: #854d0e; }
.rec-mas { background: #ffedd5; color: #9a3412; }
.rec-nunca { background: #fee2e2; color: #991b1b; }

/* Activities */
.nowrap { white-space: nowrap; }
.desc-cell { min-width: 260px; max-width: 520px; }
.tags { margin-top: .25rem; }
.tags .tag { margin-left: 0; margin-right: .25rem; }
.tag-gab { background: #fef3c7; color: #92400e; }
.tag-priv { background: #fee2e2; color: #991b1b; }
.tag-aut { background: #ede9fe; color: #5b21b6; }
.estado { font-size: .78rem; padding: .1rem .45rem; border-radius: 999px; white-space: nowrap; }
.estado-realizada { background: #dcfce7; color: #166534; }
.estado-planificada { background: #dbeafe; color: #1e40af; }
.estado-a_confirmar { background: #fef3c7; color: #92400e; }
.estado-suspendida { background: #fce7f3; color: #9d174d; }
.estado-cancelada { background: #e5e7eb; color: #4b5563; text-decoration: line-through; }
.btn-active { background: #e0e7ff; border-color: #a5b4fc; }
.btn-danger { background: #fff; color: #b91c1c; border-color: #fca5a5; margin-left: auto; }
.btn-danger:hover { background: #fef2f2; }
.pager { display: flex; gap: 1rem; align-items: center; justify-content: center; margin: 1rem 0; }
.filters label { font-size: .85rem; display: flex; gap: .3rem; align-items: center; }
.table th a { color: inherit; text-decoration: none; }
.th-sort { display: inline-block; white-space: nowrap; }
.th-sort:hover { color: var(--primary); text-decoration: underline; }
.th-sort.activo { color: var(--primary); }

.act-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; border: 0; padding: 0; margin: 0; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 1rem; }
.card h2 { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 0 0 .75rem; }
.card label { display: block; margin-bottom: .7rem; font-size: .9rem; }
.card input[type=text], .card input[type=date], .card input[type=time], .card input[type=search], .card select, .card textarea { width: 100%; margin-top: .2rem; }
.card label.check { display: flex; gap: .4rem; align-items: center; }
.card-wide { grid-column: 1 / -1; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.row3 { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: .5rem; }
@media (max-width: 480px) {
  .row3 { grid-template-columns: 1fr 1fr; }
  .row3 > :first-child { grid-column: 1 / -1; }
}
.mb-s { margin-bottom: .3rem; }
#map-act { height: 340px; border: 1px solid var(--border); border-radius: 8px; }
/* Map timeline */
.tl-row { display: flex; align-items: center; gap: .5rem; }
.tl-row input[type=range] { flex: 1; }
.tl-label { font-weight: 600; font-size: 1.05rem; margin: .4rem 0 .2rem; }

/* Tablero */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: .8rem 1rem; }
.tile-l { font-size: .82rem; color: var(--muted); }
.tile-v { font-size: 2rem; font-weight: 600; line-height: 1.2; margin: .15rem 0 .25rem; }
.tile-v small { font-size: .9rem; font-weight: 400; color: var(--muted); }
.tile-alert { border-color: #fcd34d; background: #fffbeb; }
.meter { height: 8px; background: #dbeafe; border-radius: 999px; overflow: hidden; margin: .2rem 0 .3rem; }
.meter span { display: block; height: 100%; background: #2563eb; border-radius: 999px; }
.chart-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 1rem; margin-bottom: 1rem; }
.chart-card h2 { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 0 0 .5rem; }
.chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr)); gap: 1rem; }
.chart-grid .chart-card { margin-bottom: 0; }
.chart-grid + .chart-card { margin-top: 1rem; }
.legend-inline { display: flex; gap: 1rem; font-size: .82rem; color: #475569; margin-bottom: .5rem; }
.legend-inline i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: .35rem; vertical-align: -1px; }
.sw-r { background: #2563eb; } .sw-p { background: #f59e0b; }
.cols { display: flex; align-items: stretch; gap: 2px; height: 220px; border-bottom: 1px solid #e2e8f0; padding-top: .5rem; }
.col { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; text-decoration: none; color: inherit; position: relative; padding-bottom: 1.3rem; }
.col:hover .col-stack, .col:focus .col-stack { opacity: .8; }
.col-v { font-size: .72rem; color: #475569; font-variant-numeric: tabular-nums; margin-bottom: 2px; }
.col-stack { width: 100%; max-width: 24px; display: flex; flex-direction: column; gap: 2px; min-height: 0; }
.col-stack span:first-child { border-radius: 4px 4px 0 0; }
.seg-r { background: #2563eb; min-height: 2px; } .seg-p { background: #f59e0b; min-height: 2px; }
.col-l { position: absolute; bottom: 0; font-size: .7rem; color: #64748b; white-space: nowrap; }
.col-hoy { color: #0f172a; font-weight: 600; }
.as-table { margin-top: .6rem; font-size: .85rem; }
.as-table summary { cursor: pointer; color: #475569; }
.as-table .table { max-width: 420px; margin-top: .4rem; }
.hbars { display: flex; flex-direction: column; gap: .35rem; }
.hbar { display: grid; grid-template-columns: minmax(120px, 42%) 1fr; gap: .6rem; align-items: center; font-size: .85rem; }
.hbar-l { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-t { display: flex; align-items: center; gap: .4rem; }
.hbar-f { height: 14px; background: #2563eb; border-radius: 0 4px 4px 0; min-width: 2px; }
.hbar-v { font-variant-numeric: tabular-nums; color: #334155; white-space: nowrap; }
.hbar:hover .hbar-f, .hbar:focus .hbar-f { background: #1d4ed8; }
.olv-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.olv-head h2 { margin: 0; }
.pend-grupo { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 1.5rem 0 .5rem; }
.pend { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: .6rem 1rem; margin-bottom: .6rem; }
.pend summary { cursor: pointer; font-weight: 600; display: flex; align-items: center; gap: .6rem; }
.pend[open] summary { margin-bottom: .4rem; }
.pend-n { min-width: 2rem; text-align: center; padding: .1rem .5rem; border-radius: 999px; background: #fef3c7; color: #92400e; font-size: .85rem; }
.pend-n.pend-ok { background: #dcfce7; color: #166534; }
.pend .table-wrap { margin-bottom: .5rem; }
.modo-lugar { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: .9rem; }
.modo-op { display: flex; align-items: center; gap: .4rem; margin: 0; padding: .45rem .75rem; border: 1px solid var(--border); border-radius: 6px; cursor: pointer; font-weight: 500; }
.modo-op:has(input:checked) { border-color: #2563eb; background: #eff6ff; color: #1e40af; }
.modo-op input { margin: 0; }
.sticky-actions { position: sticky; bottom: 0; background: var(--bg); padding: .75rem 0; border-top: 1px solid var(--border); margin-top: 1rem; }
code { font-size: .78rem; background: #eef2f7; padding: .1rem .3rem; border-radius: 4px; }

/* Map card: visit list */
.card-esp .visitas { list-style: none; margin: .3rem 0; padding: 0; max-height: 180px; overflow-y: auto; border-top: 1px solid #eef2f7; }
.card-esp .visitas li { padding: .3rem 0; border-bottom: 1px solid #eef2f7; font-size: .82rem; }
.card-esp .visitas .f { font-weight: 600; }
.card-esp .visitas .fut { color: #b45309; }

@media (max-width: 1000px) {
  .act-grid { grid-template-columns: 1fr; }
  .row2 { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .form-grid { grid-template-columns: 1fr; }
  #map-form { height: 380px; }
  .map-layout { flex-direction: column; }
  .sidebar { width: 100%; max-height: 40vh; border-right: 0; border-bottom: 1px solid var(--border); }
  .brand small { display: none; }
}

/* Top bar: the menu goes to its own row (and wraps) when it does not fit next to the brand */
@media (max-width: 1250px) {
  .topbar { flex-wrap: wrap; flex-shrink: 0; height: auto; padding: .5rem 1rem; gap: .4rem 1rem; justify-content: space-between; }
  .mainnav { order: 3; flex: 1 0 100%; flex-wrap: wrap; gap: .3rem 1rem; }
  .userbox { flex-wrap: wrap; gap: .2rem 1rem; }
}
.brand, .mainnav a, .userbox a { white-space: nowrap; }

/* People in charge of an espacio (contactos.js) */
.cont-box { border: 1px solid var(--border); border-radius: 8px; padding: .6rem .8rem; margin: .2rem 0 .8rem; background: #f8fafc; }
.cont-box::before { content: "Responsables del espacio"; display: block; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: .3rem; }
.cont-box p { margin: .2rem 0 .4rem; }
.cont-list { list-style: none; margin: 0 0 .5rem; padding: 0; }
.cont-item { display: flex; justify-content: space-between; gap: .6rem; align-items: flex-start; padding: .45rem 0; border-bottom: 1px solid var(--border); }
.cont-item:last-child { border-bottom: none; }
.cont-datos { display: flex; flex-wrap: wrap; gap: .2rem 1rem; margin-top: .15rem; }
.cont-datos a { color: var(--primary); text-decoration: none; }
.cont-datos a:hover { text-decoration: underline; }
.cont-btns { display: flex; flex-shrink: 0; }
.cont-form { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem .8rem; padding: .6rem; margin: .3rem 0; border: 1px dashed var(--border); border-radius: 8px; background: var(--surface); }
.cont-form label { margin: 0; }
.cont-form input { width: 100%; margin-top: .2rem; box-sizing: border-box; }
.cont-form label:last-of-type, .cont-err, .cont-actions { grid-column: 1 / -1; }
.cont-err { color: var(--danger-text); background: var(--danger-bg); padding: .3rem .6rem; border-radius: 6px; margin: 0; font-size: .9rem; }
.cont-actions { display: flex; gap: .4rem; }
@media (max-width: 640px) { .cont-form { grid-template-columns: 1fr; } }

/* Help link in the top bar */
.userbox .help-link { opacity: .85; }
.userbox .help-link:hover { opacity: 1; }

/* User manual (ayuda.php) */
.manual-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 2rem; align-items: start; }
.manual-toc { position: sticky; top: 1rem; max-height: calc(100vh - 2rem); overflow-y: auto; font-size: .88rem; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: .8rem 1rem; }
.manual-toc ul { list-style: none; margin: .4rem 0 0; padding: 0; }
.manual-toc li { margin: .15rem 0; }
.manual-toc .toc-h2 { margin-top: .7rem; font-weight: 600; }
.manual-toc .toc-h3 { padding-left: .8rem; }
.manual-toc a { color: var(--text); text-decoration: none; display: block; padding: .1rem .3rem; border-radius: 4px; }
.manual-toc a:hover { background: #f1f5f9; }
.manual-toc a.active { background: #e0e7ff; color: var(--primary); }
.manual { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 1.5rem 2rem 2.5rem; line-height: 1.6; max-width: 900px; }
.manual h2 { font-size: 1.45rem; margin: 2.5rem 0 .8rem; padding-bottom: .4rem; border-bottom: 2px solid var(--primary); color: var(--topbar); }
.manual h2:first-child { margin-top: 0; }
.manual h3 { font-size: 1.15rem; margin: 2rem 0 .5rem; }
.manual h4 { font-size: 1rem; margin: 1.4rem 0 .4rem; }
.manual h2, .manual h3, .manual h4 { scroll-margin-top: 1rem; }
.manual ul, .manual ol { padding-left: 1.4rem; }
.manual li { margin: .25rem 0; }
.manual figure { margin: 1rem 0 1.4rem; }
.manual figure img { display: block; max-width: 100%; height: auto; border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 2px 8px rgba(15, 42, 74, .08); }
.manual figcaption { font-size: .85rem; color: var(--muted); margin-top: .35rem; text-align: center; }
.manual table { border-collapse: collapse; width: 100%; margin: .8rem 0; font-size: .95rem; }
.manual th, .manual td { border: 1px solid var(--border); padding: .45rem .7rem; text-align: left; vertical-align: top; }
.manual th { background: #f1f5f9; }
.manual .nota, .manual .aviso { border-radius: 8px; padding: .6rem .9rem; margin: .8rem 0; font-size: .95rem; }
.manual .nota { background: #eff6ff; border-left: 4px solid #2563eb; }
.manual .nota::before { content: "Consejo: "; font-weight: 600; }
.manual .aviso { background: #fffbeb; border-left: 4px solid #d97706; }
.manual .aviso::before { content: "Atención: "; font-weight: 600; }
@media (max-width: 900px) {
  .manual-layout { grid-template-columns: 1fr; }
  .manual-toc { position: static; max-height: none; }
  .manual { padding: 1rem 1.1rem 2rem; }
}
@media print {
  .manual-layout { display: block; }
  .manual { border: none; padding: 0; max-width: none; }
  .manual figure { break-inside: avoid; }
  .manual h2 { break-before: page; }
  .manual h2:first-child { break-before: auto; }
  .manual h3, .manual h4 { break-after: avoid; }
}
.manual figure.chica img { max-width: 560px; margin: 0 auto; }

/* CSV importer (importar.php) */
.imp-subir { max-width: 720px; }
.imp-subir input[type=file] { display: block; margin-top: .4rem; }
.imp-filtros { display: flex; flex-wrap: wrap; gap: .4rem; margin: 0 0 .8rem; }
.imp-filtros .btn b { margin-left: .25rem; }
.imp-chip { display: inline-block; font-size: .75rem; padding: .1rem .5rem; border-radius: 999px; white-space: nowrap; background: #e5e7eb; color: #374151; }
.imp-nueva { background: #dcfce7; color: #166534; }
.imp-revisar { background: #fef3c7; color: #92400e; }
.imp-completa { background: #dbeafe; color: #1e40af; }
.imp-igual { background: #f1f5f9; color: #64748b; }
.imp-repetida, .imp-error { background: #fee2e2; color: #991b1b; }
.imp-alias { background: #ede9fe; color: #5b21b6; }
.imp-resolver { margin-bottom: 1rem; border-color: #fcd34d; background: #fffbeb; }
.imp-resolver h3 { font-size: .95rem; margin: .8rem 0 .4rem; }
.imp-res-lista { display: grid; gap: .5rem; }
.imp-res-item { display: grid; grid-template-columns: minmax(200px, 1fr) minmax(260px, 1.4fr); gap: .3rem 1rem; align-items: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: .5rem .7rem; }
.imp-res-ctrl { display: flex; gap: .4rem; align-items: center; }
.imp-res-ctrl select, .imp-res-ctrl .bsc { flex: 1; min-width: 0; margin-top: 0 !important; }
.imp-tabla tr.imp-off td { opacity: .5; }
.imp-res { min-width: 240px; }
.imp-cambios { margin: .3rem 0 0; padding-left: 1.1rem; font-size: .85rem; }
.imp-cambios li { margin-bottom: .15rem; }
.imp-cambios li.imp-conflicto { list-style: none; margin-left: -1.1rem; background: #fff7ed; border-left: 3px solid #f59e0b; padding: .25rem .4rem; }
.imp-conf { display: flex; flex-wrap: wrap; gap: .2rem .8rem; margin-top: .2rem; }
.imp-conf label { display: inline-flex; gap: .25rem; align-items: center; font-size: .82rem; }
.imp-aviso { font-size: .82rem; color: var(--muted); margin-top: .2rem; }
.imp-aviso-rev { color: #92400e; font-weight: 600; }
.imp-escrito { font-style: italic; }
.imp-escrito::after { content: " (escrito)"; color: var(--muted); font-style: normal; font-size: .8rem; }
.imp-falta { color: #92400e; font-size: .85rem; }
.imp-nofig { margin-top: 1rem; }
.imp-acciones { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; z-index: 5; }
.imp-resumen { display: flex; flex-wrap: wrap; gap: 1.2rem; margin: 0 0 1rem; }
.imp-resumen b { font-size: 1.2rem; }
@media (max-width: 720px) { .imp-res-item { grid-template-columns: 1fr; } }
.pend-lote { background: #f8fafc; font-weight: 600; }
.imp-cambios li.imp-completa, .imp-cambios li.imp-actualiza { background: none; color: inherit; }

/* My account: second factor and sessions */
.perfil-grid { display: grid; gap: 1rem; max-width: 760px; }
.tag-ok { background: #dcfce7; color: #166534; margin-left: 0; }
.pasos-2fa { padding-left: 1.2rem; }
.pasos-2fa > li { margin-bottom: 1rem; }
.qr-2fa { margin: .6rem 0; width: 216px; padding: 8px; background: #fff; border: 1px solid var(--border); border-radius: 8px; }
.qr-2fa img, .qr-2fa canvas { display: block; }
.clave-2fa { font-size: 1.05rem; letter-spacing: .05em; word-break: break-all; }
.codigo-2fa { font-size: 1.3rem; letter-spacing: .25em; width: 9.5rem; text-align: center; font-variant-numeric: tabular-nums; }
.card .codigo-2fa { width: 9.5rem; }
.recup-codigos { columns: 2; font-size: 1.05rem; padding-left: 1.6rem; }
.recup-codigos li { margin-bottom: .3rem; }
.form-2fa-admin .form-actions { margin-top: .3rem; }
.usr-seguridad { margin-top: 1rem; }
@media print {
  body:has(.recup-codigos) .topbar, body:has(.recup-codigos) .page-head, body:has(.recup-codigos) .perfil-grid > :not(#segundo-factor),
  body:has(.recup-codigos) #segundo-factor button { display: none !important; }
}
.card input[type=password] { width: 100%; margin-top: .2rem; }
.card input.codigo-2fa { width: 9.5rem; margin-top: 0; }
.audit-resumen { display: flex; flex-wrap: wrap; gap: .4rem .6rem; align-items: center; background: #fef3c7; color: #92400e; padding: .55rem .8rem; border-radius: 8px; margin-bottom: .8rem; font-size: .9rem; }
.audit-chip { background: #fff; border: 1px solid #fcd34d; border-radius: 999px; padding: .1rem .55rem; }
.audit-chip-critica { background: var(--danger-bg); color: var(--danger-text); border-color: #fca5a5; font-weight: 600; }
.table tr.audit-alerta td { background: #fffbeb; }
.table tr.audit-alerta td:first-child { box-shadow: inset 3px 0 0 #f59e0b; }