:root {
  --bg: #f5f5f2;
  --surface: #ffffff;
  --surface-2: #fafaf8;
  --border: #e4e3de;
  --text: #1d2321;
  --muted: #6b716e;
  /* Marca Lladó de Lara: dorado del logo y azul marino */
  --gold: #BCA06B;          /* botones principales (con texto marino) */
  --gold-hover: #A88B52;
  --accent: #7D6430;        /* dorado oscuro: enlaces, pestañas y realces sobre blanco (contraste AA) */
  --accent-soft: #F4EEE2;
  --navy: #0E1D30;
  --navy-2: #182A42;
  --danger: #b4382f;
  --danger-soft: #fbe9e7;
  --warn: #a8670f;
  --warn-soft: #fdf1dc;
  --ok: #1d7a4c;
  --ok-soft: #dff3e7;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 8px 24px rgba(0,0,0,.06);
  --sidebar: 232px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 14px/1.45 Inter, system-ui, -apple-system, sans-serif;
  display: flex;
}
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }

/* Sidebar */
.sidebar {
  width: var(--sidebar); flex: none; background: var(--navy); color: #dde3ec;
  display: flex; flex-direction: column; padding: 18px 12px; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; gap: 10px; align-items: center; justify-content: center; padding: 8px 8px 26px; }
.brand-logo { height: 46px; width: auto; flex: none; display: block; }
.login-logo { display: block; width: 220px; max-width: 70%; height: auto; margin: 0 auto 26px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: #c3cbd8; text-decoration: none; font-weight: 500; }
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a.active { background: rgba(188,160,107,.16); color: var(--gold); box-shadow: inset 3px 0 0 var(--gold); }
.nav .lbl-short, .show-sm, .btn.show-sm { display: none; }
.nav .sep { height: 1px; background: rgba(255,255,255,.08); margin: 10px 4px; }

/* Main */
.view { flex: 1; min-width: 0; padding: 24px 28px 40px; }
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { font-size: 22px; margin: 0; font-weight: 700; letter-spacing: -.2px; }
.page-head .sub { color: var(--muted); font-size: 13px; }
.spacer { flex: 1; }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar select, .toolbar input[type=search] { height: 36px; padding: 0 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); min-width: 150px; }
.toolbar input[type=search] { min-width: 220px; }

.btn { height: 36px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; font-weight: 500; white-space: nowrap; text-decoration: none; color: var(--text); }
.btn:hover { background: var(--surface-2); border-color: #d2d1cb; }
.btn.primary { background: var(--gold); border-color: var(--gold); color: var(--navy); font-weight: 600; }
.btn.primary:hover { background: var(--gold-hover); border-color: var(--gold-hover); }
.btn.danger-ghost { color: var(--danger); border-color: transparent; background: transparent; }
.btn.danger-ghost:hover { background: var(--danger-soft); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: transparent; height: 34px; padding: 0 12px; display: inline-flex; gap: 6px; align-items: center; cursor: pointer; color: var(--muted); font-weight: 500; }
.seg button.on { background: var(--accent-soft); color: var(--accent); }
.icon-btn { border: 0; background: transparent; width: 32px; height: 32px; border-radius: 7px; display: inline-grid; place-items: center; cursor: pointer; color: var(--muted); font-size: 20px; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.danger:hover { color: var(--danger); background: var(--danger-soft); }

/* Acciones rápidas en el listado de activos */
th.actions-h { text-align: right !important; }
.quick-actions { display: inline-flex; gap: 6px; }
.qa { width: 34px; height: 34px; border-radius: 10px; border: 1px solid transparent; display: inline-grid; place-items: center; cursor: pointer; transition: transform .12s, box-shadow .12s, background .12s; }
.qa svg { width: 18px; height: 18px; }
.qa:hover { transform: translateY(-1px); box-shadow: 0 4px 10px rgba(0,0,0,.12); }
.qa:active { transform: none; box-shadow: none; }
.qa-contract { background: #e4ecf7; color: #2d5fa8; }
.qa-contract:hover { background: #2d5fa8; color: #fff; }
.qa-opp { background: #fdf1dc; color: #b45309; }
.qa-opp:hover { background: #d97706; color: #fff; }

.qa-pay { background: var(--ok-soft); color: var(--ok); }
.qa-pay:hover { background: var(--ok); color: #fff; }

/* Facturas */
.fac-resumen { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
.fac-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px 14px; }
.fac-grid .k { font-size: 11px; color: var(--muted); }
.fac-grid .v { font-weight: 600; font-variant-numeric: tabular-nums; }
.fac-total .v { font-size: 18px; color: var(--accent); }
.fac-error { margin-top: 10px; color: var(--danger); background: var(--danger-soft); border-radius: 7px; padding: 8px 10px; font-weight: 500; }
.fac-aviso { margin-top: 10px; color: var(--warn); background: var(--warn-soft); border-radius: 7px; padding: 8px 10px; font-size: 12px; }
.modal.pdf-modal { width: min(900px, 100%); }
.pdf-alt { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 8px; }
.pdf-frame { width: 100%; height: 72vh; border: 1px solid var(--border); border-radius: 8px; background: #525659; }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin-bottom: 14px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.kpi .l { color: var(--muted); font-size: 12px; }
.kpi .v { font-size: 20px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }

/* Tables */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data { width: 100%; border-collapse: collapse; }
table.data th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface-2); }
table.data td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr.click { cursor: pointer; }
table.data tbody tr.click:hover { background: var(--surface-2); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data td.actions { text-align: right; white-space: nowrap; width: 1%; }
.row-title { font-weight: 600; }
.muted { color: var(--muted); }
.row-client { color: #3d4441; font-weight: 500; }
.small { font-size: 12px; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 500; background: #eeede8; color: #4a504d; margin: 1px 2px 1px 0; white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.off { background: #eeede8; color: var(--muted); }
.pill.accent { background: var(--accent-soft); color: var(--accent); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }
.empty { padding: 48px 20px; text-align: center; color: var(--muted); }
.empty strong { display: block; color: var(--text); font-size: 15px; margin-bottom: 4px; }

.pill.info { background: #e4ecf7; color: #2d5fa8; }
.show-sm-block { display: none; }

/* Oportunidades */
.sub-title { font-size: 14px; margin: 22px 0 10px; padding-top: 14px; border-top: 1px solid var(--border); }
.inline-select { border: 1px solid var(--border); border-radius: 7px; padding: 4px 8px; background: #fff; font-weight: 500; }
.evt-form { gap: 8px; margin-bottom: 14px; }
.evt-form textarea { min-height: 64px; }
.evt-row { display: flex; gap: 8px; align-items: center; }
.evt-row input[type=date] { width: auto !important; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 14px; border-left: 2px solid var(--border); }
.timeline li { position: relative; padding: 0 0 14px 14px; }
.timeline li::before { content: ''; position: absolute; left: -21px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); border: 2px solid var(--surface); }
.timeline li.is-status::before { background: #b8bbb8; }
.timeline li.is-status .tl-text { color: var(--muted); font-style: italic; }
.timeline li.empty-tl::before { display: none; }
.tl-head { display: flex; gap: 8px; align-items: center; font-size: 12px; min-height: 28px; }
.tl-head .icon-btn { width: 26px; height: 26px; }
.tl-head .icon-btn svg { width: 15px; height: 15px; }
.tl-text { white-space: pre-wrap; }

/* Map */
#map { height: calc(100vh - 290px); min-height: 380px; border-radius: var(--radius); border: 1px solid var(--border); }
.map-legend { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 8px; }
.map-pin { background: none; border: 0; filter: drop-shadow(0 2px 2px rgba(0,0,0,.35)); }
.map-pin svg { width: 32px; height: 46px; display: block; } /* anula el tamaño genérico de iconos: el anclaje del pin depende de 32×46 */
.legend-icon { display: inline-flex; align-items: center; gap: 4px; }
.legend-icon svg { width: 15px; height: 15px; color: var(--text); }
.legend-sep { width: 1px; height: 14px; background: var(--border); }
.blq-ico { display: inline-flex; vertical-align: -3px; margin-right: 8px; color: var(--muted); }
.blq-ico svg { width: 16px; height: 16px; }
.icon-pick { display: flex; flex-wrap: wrap; gap: 6px; }
.icon-pick .chip-check span { padding: 6px 8px; display: inline-flex; color: var(--text); }
.icon-pick .chip-check input:checked + span { color: var(--accent); }
.icon-pick svg { width: 20px; height: 20px; }
.pick-map { height: 240px; border-radius: 8px; border: 1px solid var(--border); margin-top: 6px; }
.leaflet-popup-content { font: 13px/1.4 Inter, system-ui, sans-serif; }

/* Modal */
.modal-wrap { position: fixed; inset: 0; background: rgba(18, 24, 22, .45); display: grid; place-items: center; z-index: 1000; padding: 16px; }
.modal { background: var(--surface); border-radius: 14px; box-shadow: var(--shadow); width: min(560px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; }
.modal.wide { width: min(820px, 100%); }
.modal > header { display: flex; align-items: center; padding: 16px 18px 8px; }
.modal > header h2 { font-size: 17px; margin: 0; flex: 1; }
.modal-body { padding: 8px 18px 18px; overflow-y: auto; }
.modal > footer { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 12px 18px; border-top: 1px solid var(--border); }

/* Pestañas dentro de un modal */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin: 0 0 16px; overflow-x: auto; }
.tab { border: 0; background: none; padding: 9px 12px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; cursor: pointer; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.tab:hover { color: var(--text); }
.tab.on { color: var(--accent); border-bottom-color: var(--accent); }
.tab .count { background: #eeede8; color: var(--muted); border-radius: 99px; padding: 0 7px; font-size: 11px; line-height: 18px; }
.tab.on .count { background: var(--accent-soft); color: var(--accent); }
.pane-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }

/* Forms */
.form { display: grid; gap: 12px 14px; }
.form.grid2 { grid-template-columns: 1fr 1fr; }
.form .span2 { grid-column: 1 / -1; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.form label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: 600; color: #3d4441; }
.form [hidden] { display: none; } /* que el atributo hidden gane al display de las etiquetas */
.form input:not([type=checkbox]):not([type=file]), .form select, .form textarea {
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; background: #fff; font-weight: 400; font-size: 14px; min-height: 38px; width: 100%;
}
.form textarea { min-height: 76px; resize: vertical; }
.form input:focus, .form select:focus, .form textarea:focus, .toolbar select:focus, .toolbar input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.form fieldset { border: 0; padding: 0; margin: 0; }
.form legend { font-size: 12px; font-weight: 600; color: #3d4441; margin-bottom: 6px; padding: 0; }
.form .section-title { grid-column: 1 / -1; font-size: 11px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); font-weight: 600; margin-top: 6px; border-top: 1px solid var(--border); padding-top: 12px; }
.with-add { display: flex; gap: 6px; }
.with-add select { flex: 1; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-check { flex-direction: row !important; cursor: pointer; }
.chip-check input { position: absolute; opacity: 0; pointer-events: none; }
.chip-check span { display: inline-block; padding: 6px 12px; border: 1px solid var(--border); border-radius: 99px; font-weight: 500; font-size: 13px; color: var(--muted); background: #fff; }
.chip-check input:checked + span { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.chip-check input:focus-visible + span { outline: 2px solid var(--accent); }
.files { display: flex; flex-direction: column; gap: 6px; }
.file-row { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); font-size: 13px; }
.file-row a { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.detail { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 18px; }
.detail .k { font-size: 12px; color: var(--muted); }
.detail .v { font-weight: 500; }
.detail .span2 { grid-column: 1 / -1; }

/* Status alquileres */
.status-scroll { max-height: calc(100vh - 230px); overflow: auto; }
table.status { border-collapse: separate; border-spacing: 0; min-width: 100%; font-size: 12px; }
table.status th, table.status td { border-bottom: 1px solid var(--border); padding: 4px 3px; text-align: center; background: var(--surface); }
table.status thead th { position: sticky; top: 0; z-index: 2; font-size: 11px; color: var(--muted); font-weight: 600; background: var(--surface-2); padding: 6px 2px; }
table.status thead th small { display: block; font-weight: 400; font-size: 9px; }
table.status thead th.cur { color: var(--accent); }
table.status .sticky { position: sticky; left: 0; z-index: 1; text-align: left; min-width: 150px; max-width: 180px; border-right: 1px solid var(--border); padding: 6px 10px; }
table.status .sticky .row-title { font-size: 13px; }
table.status thead th.sticky { z-index: 3; }
table.status td.cell.none { color: #c9c8c2; background: repeating-linear-gradient(135deg, #fbfbf9 0 6px, #f4f4f1 6px 12px); }
table.status td.cell { white-space: nowrap; padding: 6px 3px; position: relative; }
table.status td.cell.curm { box-shadow: inset 0 0 0 2px var(--accent-soft); }
/* Estados de cada mes: Previsto (negro), Facturado (naranja oscuro), Cobrado (verde) */
:root { --st-prev: #1d2321; --st-fact: #c2410c; --st-fact-bg: #fff1e6; --st-cob: #15803d; --st-cob-bg: #e6f5eb; }
.st-prev { color: var(--st-prev); }
.st-fact { color: var(--st-fact); }
.st-cob { color: var(--st-cob); }
table.status td.cell.st-fact { background: var(--st-fact-bg); }
table.status td.cell.st-cob { background: var(--st-cob-bg); }
.st-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: currentColor; margin-right: 5px; vertical-align: -1px; }
.amt { font: inherit; font-weight: 600; font-variant-numeric: tabular-nums; color: inherit; background: none; border: 1px solid transparent; border-radius: 5px; padding: 2px 4px; font-size: 11.5px; letter-spacing: -.1px; }
/* Versión editable (administradores): el importe se ve como un botón */
button.amt { cursor: pointer; background: #fff; border-color: currentColor; box-shadow: 0 1px 0 rgba(0,0,0,.08); padding: 2px 5px; }
td.st-prev button.amt:hover { background: var(--st-prev); color: #fff; }
td.st-fact button.amt:hover { background: var(--st-fact); color: #fff; }
td.st-cob button.amt:hover { background: var(--st-cob); color: #fff; }
button.amt:active { transform: translateY(1px); box-shadow: none; }
/* Facturación manual: contrato en vigor sin importe previsto; se emite la factura del mes indicando el importe */
table.status td.cell.st-manual { text-align: center; background: var(--accent-soft); color: var(--accent); }
.amt.manual { line-height: 0; padding: 3px 8px; }
.amt.manual svg { width: 16px; height: 16px; }
td.st-manual button.amt:hover { background: var(--accent); color: #fff; }
.st-manual-ico { color: var(--accent); }
.clip { position: absolute; top: 0; right: 0; border: 0; background: none; padding: 1px; cursor: pointer; color: #b8bbb8; border-radius: 4px; line-height: 0; }
.clip svg { width: 11px; height: 11px; }
.clip:hover { color: var(--text); }
.clip:not(.on) { opacity: 0; }
td.cell:hover .clip:not(.on), .clip:not(.on):focus-visible { opacity: 1; }
@media (hover: none) { .clip:not(.on) { opacity: .5; } }
.clip.on { color: var(--accent); }
.legend svg { width: 14px; height: 14px; vertical-align: -2px; }
table.status td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; padding: 6px 8px; font-weight: 600; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin: 0 0 10px; align-items: center; }
.legend i { display: inline-block; width: 14px; height: 14px; border-radius: 4px; vertical-align: -3px; margin-right: 5px; border: 1px solid var(--border); }
.year-nav { display: inline-flex; align-items: center; gap: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 1px; }
.year-nav strong { min-width: 48px; text-align: center; }
.year-nav button:disabled { opacity: .3; cursor: default; }

/* Config */
.cfg-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.card-head { display: flex; align-items: center; padding: 14px 16px 6px; gap: 8px; }
.card-head h3 { margin: 0; font-size: 15px; flex: 1; }
.card-body { padding: 8px 16px 16px; }

/* Usuario y login */
.user-box { margin-top: auto; padding: 12px 10px 4px; border-top: 1px solid rgba(255,255,255,.08); font-size: 12px; }
.user-name { color: #fff; font-weight: 600; margin-bottom: 2px; }
.user-actions { color: #8d99ab; }
.user-actions button { background: none; border: 0; padding: 0; color: #8d99ab; cursor: pointer; font-size: 12px; }
.user-actions button:hover { color: #fff; text-decoration: underline; }
body.auth .sidebar { display: none; }
.login { max-width: 380px; margin: 10vh auto 0; }
.login form { padding: 22px; }
.login h1 { font-size: 19px; margin: 0 0 4px; }
.login .btn { justify-content: center; height: 40px; margin-top: 4px; }
.login-err { color: var(--danger); margin: 0; min-height: 1em; font-size: 13px; }
.login-msg { color: var(--muted); margin: 0; }

/* Toast */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 20px); background: var(--navy); color: #fff; padding: 10px 16px; border-radius: 9px; opacity: 0; transition: .2s; pointer-events: none; z-index: 2000; font-weight: 500; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Portátiles: deja más ancho a las tablas */
@media (min-width: 861px) and (max-width: 1440px) {
  :root { --sidebar: 196px; }
  .view { padding: 20px 20px 32px; }
}

/* Mobile */
@media (max-width: 860px) {
  body { flex-direction: column; }
  .sidebar { position: fixed; bottom: 0; top: auto; left: 0; right: 0; height: auto; width: 100%; padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); z-index: 900; }
  .sidebar .brand, .nav .sep, .nav .lbl-long, .user-box { display: none; }
  .nav a.active { box-shadow: inset 0 2px 0 var(--gold); }
  .nav .lbl-short { display: inline; }
  .show-sm, .btn.show-sm { display: inline-flex; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .kpi .v { font-size: 17px; }
  .show-sm-block { display: block; }
  .nav { flex-direction: row; justify-content: space-around; }
  .nav a { flex-direction: column; gap: 2px; font-size: 10px; padding: 6px 4px; flex: 1; text-align: center; }
  .view { padding: 16px 16px 90px; }
  .page-head h1 { font-size: 19px; }
  .toolbar select, .toolbar input[type=search] { flex: 1 1 140px; min-width: 0; }
  .hide-sm { display: none; }
  .form.grid2, .grid3, .grid2, .detail, .cfg-grid { grid-template-columns: 1fr; }
  .fac-grid { grid-template-columns: 1fr 1fr; }
  .modal-wrap { padding: 0; place-items: end stretch; }
  .modal, .modal.wide { width: 100%; max-height: 92vh; border-radius: 14px 14px 0 0; }
  #map { height: calc(100vh - 330px); }
  table.status .sticky { min-width: 150px; max-width: 170px; }
}
span.clip { cursor: default; pointer-events: none; }

/* Status alquileres: fila de total mensual */
table.status tfoot td { position: sticky; bottom: 0; z-index: 1; background: var(--surface-2); border-top: 1px solid var(--border); border-bottom: 0; font-weight: 700; }
table.status tfoot td.sticky { z-index: 3; font-size: 12px; }
td.tot-mes { padding: 6px 4px; }
.tot-v { font-size: 11.5px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tot-bar { display: flex; height: 4px; border-radius: 2px; background: #dcdbd5; overflow: hidden; margin: 4px 4px 0; }
.tot-bar .b-cob { background: var(--st-cob); }
.tot-bar .b-fact { background: var(--st-fact); }

/* Gastos */
.gasto-pill { background: color-mix(in srgb, var(--c) 12%, #fff); color: var(--c); }
.gasto-reparto .k { font-size: 11px; color: var(--muted); margin-bottom: 6px; }
.reparto-meses { display: flex; flex-wrap: wrap; gap: 6px; }
.reparto-meses span { display: flex; flex-direction: column; align-items: center; min-width: 64px; padding: 5px 6px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface-2); }
.reparto-meses small { font-size: 10px; color: var(--muted); }
.reparto-meses b { font-size: 12px; font-variant-numeric: tabular-nums; }

/* Menú móvil con muchas secciones */
@media (max-width: 860px) {
  .nav a { font-size: 9px; padding: 6px 1px; min-width: 0; }
  .nav a svg { width: 17px; height: 17px; }
}

/* Gastos: tabla anual */
.gastos-tabla .gasto-link { cursor: pointer; }
.gastos-tabla .gasto-link:hover { color: var(--accent); text-decoration: underline; }
.gastos-tabla .gasto-pill { font-size: 10.5px; padding: 1px 6px; }

/* Reportes */
.page-tabs { margin-bottom: 14px; }
.switch { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text); cursor: pointer; }
.switch input { accent-color: var(--accent); width: 16px; height: 16px; }
.kpi .v.neg, table.pyg td.neg { color: var(--danger); }
table.pyg td.pos { color: var(--st-cob); }
table.pyg { border-collapse: separate; border-spacing: 0; min-width: 100%; font-size: 11.5px; font-variant-numeric: tabular-nums; letter-spacing: -.1px; }
table.pyg th, table.pyg td { padding: 6px 4px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--border); background: var(--surface); }
table.pyg thead th { position: sticky; top: 0; z-index: 2; background: var(--surface-2); color: var(--muted); font-size: 11px; font-weight: 600; }
table.pyg thead th.cur { color: var(--accent); }
table.pyg .sticky { position: sticky; left: 0; z-index: 1; text-align: left; min-width: 140px; max-width: 170px; white-space: normal; border-right: 1px solid var(--border); padding-left: 10px; }
table.pyg thead th.sticky { z-index: 3; }
table.pyg td.curm { background: #FBF8F2; }
table.pyg td.tot { font-weight: 700; background: var(--surface-2); }
table.pyg tr.pyg-sec td { background: #f0efea; font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: #3d4441; text-align: left; }
table.pyg tr.pyg-sub td { font-weight: 700; background: var(--surface-2); }
table.pyg tr.pyg-sub.ing td:not(.sticky) { color: var(--st-cob); }
table.pyg tr.pyg-sub.gas td:not(.sticky) { color: var(--st-fact); }
table.pyg tr.pyg-res td { font-weight: 800; font-size: 12px; background: var(--accent-soft); border-top: 2px solid var(--gold); }
table.pyg tr.pyg-marg td { color: var(--muted); font-size: 11px; }

/* Menú móvil: se desplaza horizontalmente si no caben todas las secciones */
@media (max-width: 860px) {
  .nav { overflow-x: auto; justify-content: flex-start; scrollbar-width: none; }
  .nav::-webkit-scrollbar { display: none; }
  .nav a { flex: 0 0 auto; min-width: 58px; }
}

/* Mantenimiento: estados con color y texto */
.pill.st-m-venc { background: #FBE3D3; color: #8A3B06; }
.pill.st-m-sem { background: #E1EAF5; color: #1E4A7A; }
.pill.st-m-prog { background: #E2EEE7; color: #1F5C4A; }
.pill.st-m-sin, .pill.st-m-canc { background: #ECECE8; color: #3F4541; }
.pill.st-m-curso { background: #EDE7F6; color: #4B2E83; }
.pill.st-m-hecha { background: var(--ok-soft); color: var(--ok); }
.pill.st-m-legal { background: #FDF0D5; color: #7A4B00; }
.kpi .v.st-m-venc-t { color: #8A3B06; }
.kpi .v.st-m-sem-t { color: #1E4A7A; }
.kpi-btn { text-align: left; cursor: pointer; font: inherit; }
.kpi-btn:hover { border-color: var(--accent); }
.mono { font-family: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.th-sort { background: none; border: 0; padding: 0; font: inherit; color: inherit; cursor: pointer; min-height: 28px; }
.th-sort.on { color: var(--accent); }
.mant-bloques { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 14px; }
.mini-list { list-style: none; margin: 0; padding: 0; }
.mini-list li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); min-height: 44px; }
.mini-list li:last-child { border-bottom: 0; }
.mini-list li > div:first-child { flex: 1; min-width: 0; }
.mini-list li.click { cursor: pointer; }
.mini-list li.click:hover { background: var(--surface-2); }
.checklist { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.checklist label { display: flex; gap: 8px; align-items: center; min-height: 36px; cursor: pointer; }
.checklist input { width: 18px; height: 18px; accent-color: var(--accent); }
.occ-accion:not(:empty) { margin-top: 6px; padding: 4px 14px 14px; border: 1px solid var(--gold); border-radius: 10px; background: #FBF8F2; }
.aviso { background: var(--warn-soft); color: var(--warn); border-radius: 8px; padding: 10px 12px; margin-bottom: 14px; font-size: 13px; }
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.tpl-card { padding: 14px; display: flex; flex-direction: column; gap: 6px; }
.tpl-card h3 { margin: 2px 0; font-size: 15px; }
.tpl-head { display: flex; align-items: center; gap: 8px; }
.tpl-freq { font-size: 12px; color: var(--muted); }
.tpl-card dl { display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; margin: 4px 0; font-size: 12.5px; }
.tpl-card dt { color: var(--muted); }
.tpl-card dd { margin: 0; }
.tpl-foot { display: flex; align-items: center; gap: 6px; margin-top: auto; padding-top: 8px; border-top: 1px solid var(--border); }
.apl-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 6px; max-height: 280px; overflow: auto; }
.apl-item { flex-direction: row !important; align-items: center; gap: 8px !important; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font-weight: 400 !important; font-size: 13px !important; min-height: 44px; cursor: pointer; }
.apl-item input { width: 18px; height: 18px; accent-color: var(--accent); }
.apl-item.disabled { opacity: .55; cursor: default; }
@media (max-width: 1100px) { .mant-bloques { grid-template-columns: 1fr; } }

/* Incidencias */
.pill.st-m-inc { background: #FDE7E7; color: #9B1C1C; }
.btn.btn-inc { background: #b42318; border-color: #b42318; }
.btn.btn-inc:hover { background: #912018; }
@media (min-width: 1101px) { .mant-bloques { grid-template-columns: repeat(2, 1fr); } }

/* Aviso de filtros activos en listados */
.filtro-activo { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; background: var(--accent-soft); color: var(--text); border-radius: 8px; padding: 8px 12px; margin-bottom: 10px; font-size: 13px; }
.filtro-activo span { flex: 1; }
.card-head .btn.sm { flex: none; }

/* Web pública: pestaña Web y sección de páginas */
.pill.accent svg { width: 12px; height: 12px; vertical-align: -2px; }
.carac-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.carac-check { flex-direction: row !important; cursor: pointer; }
.carac-check input { position: absolute; opacity: 0; pointer-events: none; }
.carac-check span { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 9px; font-weight: 500; font-size: 13px; color: var(--muted); background: #fff; min-height: 44px; }
.carac-check span svg { width: 22px; height: 22px; flex: none; }
.carac-check input:checked + span { background: var(--accent-soft); border-color: var(--gold); color: var(--accent); }
.carac-check input:focus-visible + span { outline: 2px solid var(--accent); }
.fotos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
.foto-item { position: relative; margin: 0; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; background: var(--surface-2); }
.foto-item img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.foto-item figcaption { display: flex; justify-content: space-between; padding: 2px; }
.foto-item .icon-btn { width: 30px; height: 30px; }
.foto-item .icon-btn svg { width: 15px; height: 15px; }
.foto-portada { position: absolute; top: 6px; left: 6px; background: var(--navy); color: var(--gold); font-size: 10px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; padding: 2px 7px; border-radius: 99px; }
.foto-add { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 120px; border: 1.5px dashed var(--border); border-radius: 9px; background: none; color: var(--muted); cursor: pointer; font: inherit; }
.foto-add:hover { border-color: var(--gold); color: var(--accent); }
.slug-field { display: flex; align-items: center; border: 1px solid var(--border); border-radius: 8px; background: #fff; padding-left: 10px; overflow: hidden; }
.slug-field span { white-space: nowrap; font-size: 12px; }
.slug-field input { border: 0 !important; min-width: 0; }
.pag-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.pag-card { display: flex; flex-direction: column; overflow: hidden; }
.pag-cover { position: relative; aspect-ratio: 16 / 9; background: var(--navy); display: grid; place-items: center; color: var(--gold); }
.pag-cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.pag-cover svg { width: 40px; height: 40px; }
.pag-cover .pill { position: absolute; top: 10px; right: 10px; }
.pag-body { padding: 12px 14px; display: grid; gap: 4px; }
.pag-body h3 { margin: 0; font-size: 16px; }
.pag-url { font-size: 12px; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pag-foot { display: flex; gap: 6px; align-items: center; padding: 10px 14px; border-top: 1px solid var(--border); margin-top: auto; flex-wrap: wrap; }
