:root {
  --bg: #f4f6f8; --panel: #ffffff; --ink: #1b2430; --muted: #5f6b7a; --line: #e2e7ee; --line2: #eef1f5;
  --accent: #0f5f5c; --accent-2: #138a85; --accent-soft: #e3f1f0; --side: #0e2a33; --side-ink: #c8d6dc;
  --ok: #1f7a3d; --ok-soft: #e4f4e9; --warn: #9a6200; --warn-soft: #fdf2dc; --err: #b42318; --err-soft: #fde8e6; --info-soft: #e8f0fb;
  --radius: 8px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif; font-size: 14px; color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
a { color: var(--accent); }
h1 { font-size: 20px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 20px 0 8px; }
h3 { font-size: 14px; margin: 14px 0 6px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.neg { color: var(--err); }
.nowrap { white-space: nowrap; }

/* Layout */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-ink); padding: 14px 10px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 8px; color: #fff; font-weight: 700; padding: 4px 8px 14px; font-size: 15px; }
.brand .dot { width: 26px; height: 26px; border-radius: 6px; background: var(--accent-2); display: grid; place-items: center; font-size: 13px; }
/* Grupos del menú contraíbles (acordeón) */
.side .grp { display: flex; justify-content: space-between; align-items: center; width: 100%; background: none; border: 0; cursor: pointer;
  font: inherit; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #7f98a2; text-align: left;
  margin: 6px 0 0; padding: 8px 10px; border-radius: 6px; }
.side .grp:hover { background: rgba(255,255,255,.06); color: #fff; }
.side .grp::after { content: '▸'; font-size: 11px; opacity: .7; }
.side .nav-g.abierto > .grp { color: #fff; }
.side .nav-g.abierto > .grp::after { content: '▾'; }
.side .nav-items { display: none; padding-left: 6px; }
.side .nav-g.abierto > .nav-items { display: block; }
/* Subgrupos dentro de un grupo (Contabilidad › Libros / Estados financieros) */
.side .sub-t { display: flex; justify-content: space-between; align-items: center; width: 100%; background: none; border: 0; cursor: pointer;
  font: inherit; font-size: 13.5px; color: var(--side-ink); text-align: left; padding: 6px 10px; border-radius: 6px; }
.side .sub-t:hover { background: rgba(255,255,255,.06); color: #fff; }
.side .sub-t::after { content: '▸'; font-size: 11px; opacity: .6; }
.side .nav-sub.abierto > .sub-t::after { content: '▾'; }
.side .sub-items { display: none; padding-left: 12px; border-left: 1px solid rgba(255,255,255,.12); margin-left: 10px; }
.side .nav-sub.abierto > .sub-items { display: block; }
.side .sub-items a { font-size: 13px; }
.side a { display: block; color: var(--side-ink); text-decoration: none; padding: 6px 10px; border-radius: 6px; font-size: 13.5px; }
.side a:hover { background: rgba(255,255,255,.06); color: #fff; }
.side a.on { background: var(--accent-2); color: #fff; }
.main { min-width: 0; }
.top { display: flex; align-items: center; gap: 12px; padding: 10px 20px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.top .emp { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.top .emp img { height: 34px; max-width: 110px; object-fit: contain; }
.top select { max-width: 380px; }
.content { padding: 20px; max-width: 1500px; }
.menu-btn { display: none; }

/* Panels */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.kpi .l { color: var(--muted); font-size: 12px; }
.kpi .v { font-size: 22px; font-weight: 650; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .s { font-size: 12px; color: var(--muted); margin-top: 2px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* Forms */
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 3px; }
input, select, textarea { font: inherit; color: inherit; border: 1px solid #cfd6df; border-radius: 6px; padding: 6px 8px; background: #fff; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent-2); }
input[type=checkbox] { width: auto; }
.form { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px 12px; align-items: end; }
.form .wide { grid-column: span 2; }
.form .full { grid-column: 1 / -1; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; margin-bottom: 12px; }
.filters > div { min-width: 140px; }
.btn { font: inherit; border: 1px solid #cfd6df; background: #fff; color: var(--ink); padding: 6px 12px; border-radius: 6px; cursor: pointer; white-space: nowrap; text-decoration: none; display: inline-block; }
.btn:hover { background: #f6f8fa; }
.btn.pri { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.pri:hover { background: var(--accent-2); }
.btn.danger { color: var(--err); border-color: #f1b8b2; }
.btn.sm { padding: 3px 8px; font-size: 12.5px; }
.btn.danger-solid { background: var(--err); border-color: var(--err); color: #fff; }
.btn.danger-solid:hover { background: #912018; }
/* Menú de acciones (⋯) */
.menu-acc { position: absolute; z-index: 30; min-width: 210px; background: #fff; border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 10px 24px rgba(16,24,40,.16); padding: 4px; }
.menu-acc button { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; border: 0; background: none; padding: 7px 10px;
  border-radius: 6px; font: inherit; color: var(--ink); cursor: pointer; }
.menu-acc button:hover { background: #f2f5f8; }
.menu-acc button.peligro { color: var(--err); }
.menu-acc button:disabled { color: #aab3bf; cursor: default; background: none; }
.menu-acc hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }
.btn-menu { border: 1px solid transparent; background: none; border-radius: 6px; padding: 2px 9px; font-size: 16px; line-height: 1; cursor: pointer; color: var(--muted); }
.btn-menu:hover, .btn-menu.on { background: #eef2f6; border-color: var(--line); color: var(--ink); }
.btn:disabled { opacity: .55; cursor: default; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* Tables */
table { border-collapse: collapse; width: 100%; background: var(--panel); }
th, td { padding: 6px 8px; border-bottom: 1px solid var(--line2); text-align: left; vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; background: #f8fafc; position: sticky; top: 0; border-bottom: 1px solid var(--line); }
tr.click { cursor: pointer; }
tr.click:hover td { background: #f6faf9; }
tr.tot td { font-weight: 650; border-top: 2px solid var(--line); background: #fafbfc; }
tr.sub td { font-weight: 600; background: #f6f8fa; }
tr.final td { font-weight: 700; border-top: 2px solid var(--ink); border-bottom: 3px double var(--ink); }
tr.anul td { color: #9aa4b2; text-decoration: line-through; }
td.ind1 { padding-left: 22px; } td.ind2 { padding-left: 40px; color: var(--muted); }
.comp-head td { background: var(--accent-soft); font-weight: 600; }
/* Badges */
.b { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.b.ok { background: var(--ok-soft); color: var(--ok); }
.b.warn { background: var(--warn-soft); color: var(--warn); }
.b.err { background: var(--err-soft); color: var(--err); }
.b.info { background: var(--info-soft); color: #1d4f91; }
.b.mut { background: #eef1f5; color: var(--muted); }
.note { padding: 10px 12px; border-radius: 6px; background: var(--info-soft); font-size: 13px; margin: 8px 0; }
.note.warn { background: var(--warn-soft); }
.note.err { background: var(--err-soft); }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; flex-wrap: wrap; }
.tabs button { border: 0; background: none; padding: 8px 12px; cursor: pointer; font: inherit; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs button.on { color: var(--accent); border-color: var(--accent); font-weight: 600; }

/* Modal / toast */
.modal-bg { position: fixed; inset: 0; background: rgba(15,23,32,.45); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: #fff; border-radius: 10px; width: min(760px, 100%); max-height: 92vh; overflow: auto; padding: 18px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal.wide { width: min(1100px, 100%); }
.modal h2 { margin-top: 0; }
#toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 60; }
.toast { background: var(--ink); color: #fff; padding: 10px 14px; border-radius: 8px; max-width: 420px; box-shadow: var(--shadow); font-size: 13.5px; }
.toast.err { background: var(--err); }
.toast.ok { background: var(--ok); }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(135deg, #0e2a33, #0f5f5c); }
.login .card { width: min(400px, 92vw); padding: 26px; }

.bar { height: 8px; border-radius: 4px; background: var(--accent-2); }
dl.ficha { display: grid; grid-template-columns: 180px 1fr; gap: 6px 12px; margin: 0; }
dl.ficha dt { color: var(--muted); font-size: 12.5px; }
dl.ficha dd { margin: 0; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; left: 0; top: 0; z-index: 40; width: 260px; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; }
  .menu-btn { display: inline-block; }
  .grid2 { grid-template-columns: 1fr; }
  .content { padding: 14px 16px; }
  .barra-fija { margin: -14px -16px 12px; padding: 12px 16px 0; }
  .form .wide { grid-column: auto; }
}
/* ---- Prestigio Comunidades ---- */
.btn.menu-btn { display: none; }
@media (max-width: 900px) { .btn.menu-btn { display: inline-block; } }
.content { max-width: 1400px; }
.acciones-rapidas { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin-bottom: 16px; }
.acciones-rapidas button { font: inherit; text-align: left; border: 1px solid var(--line); background: var(--panel); border-radius: var(--radius);
  padding: 14px; cursor: pointer; box-shadow: var(--shadow); }
.acciones-rapidas button:hover { border-color: var(--accent-2); background: #f6faf9; }
.acciones-rapidas b { display: block; font-size: 15px; margin-bottom: 2px; }
.kpi.alerta .v { color: var(--err); }
.kpi.aviso .v { color: var(--warn); }
.kpi.click { cursor: pointer; }
.kpi.click:hover { border-color: var(--accent-2); }
tr.excedido td { background: var(--err-soft); }
tr.vencida td { background: var(--warn-soft); }
.sugerencias { border: 1px solid var(--line); border-radius: 6px; margin-top: 4px; max-height: 220px; overflow: auto; background: #fff; }
.sugerencias button { display: block; width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--line2); background: none; padding: 6px 8px; font: inherit; cursor: pointer; }
.sugerencias button:hover { background: #f2f7f7; }
.det { white-space: pre-wrap; }
.chk { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink); }
.vacio { padding: 18px; text-align: center; color: var(--muted); }
.checklist { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 4px 12px; max-height: 200px; overflow: auto; border: 1px solid var(--line); border-radius: 6px; padding: 8px; }