:root{font-family:Inter,ui-sans-serif,system-ui,-apple-system,"Segoe UI",sans-serif;color:#172033;background:#f5f7fb;font-synthesis:none}*{box-sizing:border-box}body{margin:0}.topbar{min-height:64px;height:auto;flex-wrap:wrap;row-gap:10px;padding-top:9px;padding-bottom:9px;background:#fff;border-bottom:1px solid #dde3ec;display:flex;align-items:center;justify-content:space-between;padding-left:max(20px,calc((100vw - 1200px)/2));padding-right:max(20px,calc((100vw - 1200px)/2));position:sticky;top:0;z-index:10}.brand a{font-weight:800;color:#163c69;text-decoration:none}.topbar nav{display:flex;gap:18px;align-items:center}.topbar nav a{color:#334155;text-decoration:none;font-weight:600;font-size:14px}.container{max-width:1200px;margin:0 auto;padding:28px 20px 60px}.heading{display:flex;align-items:center;justify-content:space-between;gap:16px;margin-bottom:20px}.heading h1,.form-card h1{margin:0 0 4px}.heading p,.form-card>p{margin:0;color:#64748b}.button,button{border:1px solid #cbd5e1;background:#fff;color:#24364b;border-radius:9px;padding:10px 14px;text-decoration:none;font-weight:700;cursor:pointer}.primary{background:#1769aa;color:#fff;border-color:#1769aa}.large{width:100%;font-size:18px;padding:15px}.cards{display:grid;grid-template-columns:repeat(auto-fit,minmax(260px,1fr));gap:16px}.card,.form-card,.auth-card,.meter-card{background:#fff;border:1px solid #dde3ec;border-radius:14px;padding:20px;box-shadow:0 4px 18px rgba(25,40,65,.05)}.card h2{margin:4px 0 8px}.eyebrow{text-transform:uppercase;letter-spacing:.08em;font-size:12px;font-weight:800;color:#64748b}.progress{height:8px;border-radius:999px;background:#e7edf5;overflow:hidden}.progress span{display:block;height:100%;background:#1769aa}.card-actions,.actions,.capture-nav{display:flex;gap:10px;align-items:center;margin-top:16px}.table-wrap{overflow:auto;background:#fff;border:1px solid #dde3ec;border-radius:12px}table{width:100%;border-collapse:collapse;min-width:760px}th,td{text-align:left;padding:12px 14px;border-bottom:1px solid #edf1f5;font-size:14px}th{font-size:12px;text-transform:uppercase;letter-spacing:.04em;color:#64748b;background:#f9fbfd}.search{display:flex;gap:8px;margin-bottom:16px}.search input{flex:1}.stack{display:grid;gap:14px}.grid-form{display:grid;grid-template-columns:1fr 1fr;gap:14px}.wide{grid-column:1/-1}label{display:grid;gap:6px;font-size:13px;font-weight:700;color:#43546a}input,select,textarea{width:100%;border:1px solid #cbd5e1;border-radius:9px;padding:11px 12px;background:#fff;color:#172033;font:inherit}input:focus,select:focus,textarea:focus{outline:2px solid rgba(23,105,170,.18);border-color:#1769aa}.auth-card{max-width:440px;margin:8vh auto}.form-card{max-width:760px;margin:0 auto}.alert{padding:11px 13px;border-radius:9px;margin:12px 0}.error{background:#fff0f0;color:#8f2525;border:1px solid #f1c4c4}.ok{background:#eefaf2;color:#1f6a39;border:1px solid #c7ead2}.badge,.badge-button{display:inline-block;border-radius:999px;padding:6px 9px;font-size:12px;font-weight:800;border:0}.badge.open,.paid{background:#e8f6ee;color:#21703f}.badge.closed,.unpaid{background:#f3f5f7;color:#5d6673}.inline{display:inline}.link-button{padding:0;border:0;background:none;color:#1769aa}.nowrap{white-space:nowrap}.mobile-shell{max-width:560px;margin:0 auto}.capture-head{display:flex;justify-content:space-between;margin-bottom:8px}.capture-head a{text-decoration:none;color:#1769aa;font-weight:700}.meter-card{margin-top:14px}.meter-card h1{font-size:30px;margin:6px 0}.meter-card h2{font-size:17px;font-weight:600;margin:0 0 18px;color:#526274}.reading-old{background:#f4f7fb;border-radius:11px;padding:14px 16px;display:flex;justify-content:space-between;align-items:center;margin-bottom:18px}.reading-old strong{font-size:24px}.big-input input{font-size:32px;font-weight:800;text-align:center;padding:15px}.capture-nav{justify-content:space-between}details{margin:12px 0} @media(max-width:700px){.topbar{height:auto;padding:12px 14px;align-items:flex-start;gap:8px}.topbar nav{gap:10px;flex-wrap:wrap;justify-content:flex-end}.topbar nav a{font-size:12px}.container{padding:18px 12px 40px}.heading{align-items:flex-start;flex-direction:column}.grid-form{grid-template-columns:1fr}.wide{grid-column:auto}.actions{flex-wrap:wrap}.meter-card{padding:16px}.search{position:sticky;top:82px;z-index:5;background:#f5f7fb;padding:6px 0}}
.muted{color:#64748b}.section-gap{margin-top:20px}.two-cards{grid-template-columns:repeat(auto-fit,minmax(320px,1fr))}.warning-list{max-height:320px;overflow:auto;padding-left:22px}.warning-list li{margin:6px 0}code{background:#eef2f7;border-radius:5px;padding:2px 5px;font-size:.92em}
.check-row{display:flex;grid-template-columns:auto 1fr;gap:9px;align-items:flex-start;font-weight:600}.check-row input{width:auto;margin-top:3px}.audit-metrics{display:grid;grid-template-columns:repeat(auto-fit,minmax(120px,1fr));gap:10px;margin:14px 0}.audit-metrics>div{background:#f6f8fb;border:1px solid #e3e8ef;border-radius:10px;padding:12px}.audit-metrics strong{display:block;font-size:22px}.audit-metrics span{display:block;color:#64748b;font-size:12px;margin-top:2px}.badge.warn{background:#fff1db;color:#8a5700}.row-warning td{background:#fffaf0}.compact{max-height:none;margin-bottom:0}
.user-chip{display:inline-flex;align-items:center;border-radius:999px;background:#eef2f7;color:#526274;padding:5px 9px;font-size:12px;font-weight:700}.danger-button{background:#fff;color:#9b1c1c;border-color:#efb7b7}.danger-link{color:#a12222!important}.row-muted td{opacity:.58;text-decoration:line-through}.statline{display:flex;gap:18px;flex-wrap:wrap}.statline strong{font-size:18px}
.tiny{font-size:11px}.mini-form{min-width:220px;padding:10px}.status-settled{background:#e8f6ee;color:#21703f}.status-rejected,.status-returned,.status-refunded,.status-reversed{background:#fff0f0;color:#8f2525}.status-submitted,.status-exported{background:#eaf3ff;color:#1b5f9e}.status-partial{background:#fff1db;color:#8a5700}.status-pending,.status-draft{background:#f3f5f7;color:#5d6673}.status-cancelled{background:#eceff3;color:#707780;text-decoration:line-through}.status-rejected{font-weight:800}


/* COMUNA-GEST 0.9: identidad de producto + comunidad/cliente */
.identity-bar{display:flex;align-items:center;gap:14px;min-width:320px}
.product-brand{display:flex;align-items:center;gap:9px;color:inherit;text-decoration:none;white-space:nowrap}
.product-logo-placeholder{width:34px;height:34px;border-radius:9px;display:inline-grid;place-items:center;font-weight:900;letter-spacing:-1px;background:#eaf3ff;color:#155c96;border:1px solid #c9ddf0}
.product-name{font-weight:900;letter-spacing:.35px;font-size:17px}
.brand-divider{height:34px;width:1px;background:#dbe2ea}
.community-brand{display:flex;align-items:center;gap:9px;min-width:0}
.community-logo,.community-logo-placeholder{width:34px;height:34px;border-radius:8px;object-fit:contain;background:#fff;border:1px solid #dbe2ea;flex:0 0 auto}
.community-logo-placeholder{display:grid;place-items:center;color:#596574;font-weight:800}
.community-copy{display:flex;flex-direction:column;min-width:0;line-height:1.05}
.community-copy strong{max-width:260px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-size:14px}
.community-label{font-size:10px;text-transform:uppercase;letter-spacing:.08em;opacity:.72;margin-bottom:3px}
.settings-form{display:flex;flex-direction:column;gap:18px}
.settings-section{border:1px solid #dfe5eb;border-radius:12px;padding:16px;background:#fbfcfd}
.settings-section legend{padding:0 8px;font-weight:800;color:#344054}
.field-help{display:block;margin-top:5px;font-size:12px;color:#667085}
.current-logo-row{display:flex;align-items:center;gap:18px;padding-top:4px}
.settings-logo-preview{width:120px;height:70px;object-fit:contain;border:1px solid #dfe5eb;border-radius:10px;background:#fff;padding:6px}
@media (max-width:900px){.topbar{align-items:flex-start}.identity-bar{width:100%}.community-copy strong{max-width:180px}.brand-divider{display:none}.identity-bar{flex-wrap:wrap}.community-brand{padding-left:43px;margin-top:-6px}}


/* COMUNA-GEST 0.9.1: tema claro / oscuro / segun sistema */
html{color-scheme:light}
html[data-theme="dark"]{color-scheme:dark;background:#0b1220;color:#e5e7eb}
html[data-theme="light"]{color-scheme:light}
body{background:#f5f7fb;color:#172033;transition:background-color .18s ease,color .18s ease}
.header-actions{display:flex;align-items:center;gap:16px;flex-wrap:wrap;justify-content:flex-end}

html[data-theme="dark"] body{background:#0b1220;color:#e5e7eb}
html[data-theme="dark"] .topbar{background:#111827;border-bottom-color:#263244}
html[data-theme="dark"] .topbar nav a{color:#d7deea}
html[data-theme="dark"] .product-brand{color:#f8fafc}
html[data-theme="dark"] .brand-divider{background:#334155}
html[data-theme="dark"] .product-logo-placeholder{background:#10253d;color:#8ec5f0;border-color:#23496a}
html[data-theme="dark"] .community-logo,html[data-theme="dark"] .community-logo-placeholder{background:#172033;border-color:#334155;color:#d7deea}
html[data-theme="dark"] .community-label{color:#9aa8ba}
html[data-theme="dark"] .heading p,html[data-theme="dark"] .form-card>p,html[data-theme="dark"] .muted,html[data-theme="dark"] .eyebrow,html[data-theme="dark"] .meter-card h2,html[data-theme="dark"] .field-help{color:#9aa8ba}
html[data-theme="dark"] .card,html[data-theme="dark"] .form-card,html[data-theme="dark"] .auth-card,html[data-theme="dark"] .meter-card{background:#111827;border-color:#293548;box-shadow:0 4px 18px rgba(0,0,0,.22)}
html[data-theme="dark"] .table-wrap{background:#111827;border-color:#293548}
html[data-theme="dark"] th{background:#172033;color:#aeb9c8}
html[data-theme="dark"] th,html[data-theme="dark"] td{border-bottom-color:#263244}
html[data-theme="dark"] label{color:#c9d2de}
html[data-theme="dark"] input,html[data-theme="dark"] select,html[data-theme="dark"] textarea{background:#0f172a;color:#e5e7eb;border-color:#3a475a}
html[data-theme="dark"] input:focus,html[data-theme="dark"] select:focus,html[data-theme="dark"] textarea:focus{outline-color:rgba(66,153,225,.28);border-color:#4299e1}
html[data-theme="dark"] .button,html[data-theme="dark"] button{background:#172033;color:#e5e7eb;border-color:#3a475a}
html[data-theme="dark"] .button.primary,html[data-theme="dark"] button.primary,html[data-theme="dark"] .primary{background:#1f6fae;color:#fff;border-color:#2a7fbd}
html[data-theme="dark"] .danger-button{background:#172033;color:#ffb4b4;border-color:#7a3b3b}
html[data-theme="dark"] .progress{background:#263244}
html[data-theme="dark"] .reading-old{background:#172033}
html[data-theme="dark"] .alert.error,html[data-theme="dark"] .error{background:#35191d;color:#ffc2c2;border-color:#6d3038}
html[data-theme="dark"] .alert.ok,html[data-theme="dark"] .ok{background:#142a20;color:#bce9ca;border-color:#2d5b41}
html[data-theme="dark"] .badge.open,html[data-theme="dark"] .paid,html[data-theme="dark"] .status-settled{background:#173122;color:#9ee0b5}
html[data-theme="dark"] .badge.closed,html[data-theme="dark"] .unpaid,html[data-theme="dark"] .status-pending,html[data-theme="dark"] .status-draft{background:#252d39;color:#b7c0cd}
html[data-theme="dark"] .badge.warn,html[data-theme="dark"] .status-partial{background:#3a2a10;color:#ffd38a}
html[data-theme="dark"] .status-rejected,html[data-theme="dark"] .status-returned,html[data-theme="dark"] .status-refunded,html[data-theme="dark"] .status-reversed{background:#35191d;color:#ffc2c2}
html[data-theme="dark"] .status-submitted,html[data-theme="dark"] .status-exported{background:#14283f;color:#a8d3ff}
html[data-theme="dark"] .status-cancelled{background:#252d39;color:#9aa8ba}
html[data-theme="dark"] .user-chip{background:#243041;color:#cbd5e1}
html[data-theme="dark"] .audit-metrics>div{background:#172033;border-color:#293548}
html[data-theme="dark"] .audit-metrics span{color:#9aa8ba}
html[data-theme="dark"] .row-warning td{background:#2d2415}
html[data-theme="dark"] code{background:#1d2939;color:#dce6f2}
html[data-theme="dark"] .settings-section{background:#0f172a;border-color:#293548}
html[data-theme="dark"] .settings-section legend{color:#d7deea}
html[data-theme="dark"] .settings-logo-preview{background:#172033;border-color:#334155}
html[data-theme="dark"] .link-button,html[data-theme="dark"] .capture-head a{color:#70b7ee}
@media(max-width:700px){html[data-theme="dark"] .search{background:#0b1220}}
@media(max-width:1000px){.header-actions{width:100%;justify-content:space-between}.topbar nav{justify-content:flex-start}}


/* COMUNA-GEST 0.9.2: pie de aplicación */
body{min-height:100vh;display:flex;flex-direction:column}
main.container{width:100%;flex:1}
.app-footer{border-top:1px solid #dde3ec;background:#fff;color:#64748b;margin-top:22px}
.footer-inner{max-width:1200px;margin:0 auto;padding:17px 20px;display:flex;align-items:center;justify-content:center;gap:8px;flex-wrap:wrap;font-size:12px;font-weight:600;text-align:center}
.footer-separator{opacity:.65}
html[data-theme="dark"] .app-footer{background:#111827;border-top-color:#263244;color:#9aa8ba}
@media(max-width:700px){.footer-inner{padding:15px 12px;gap:5px}.footer-separator{display:none}.footer-inner span{width:100%}}


/* COMUNA-GEST 0.9.3: correcciones de cabecera, tema y pie */
html,body{min-height:100%}
body{min-height:100vh;min-height:100dvh;display:flex;flex-direction:column}
.topbar{display:block;min-height:64px;padding-top:9px;padding-bottom:9px}
.topbar-inner{width:100%;max-width:1200px;margin:0 auto;display:flex;align-items:center;justify-content:space-between;gap:20px;min-width:0}
.identity-bar{flex:0 1 auto;min-width:0}
.header-actions{flex:1 1 auto;min-width:0;display:flex;justify-content:flex-end;align-items:center}
.topbar nav{display:flex;gap:16px;align-items:center;justify-content:flex-end;flex-wrap:wrap}
main.container{width:100%;flex:1 0 auto}
.app-footer{flex:0 0 auto;margin-top:auto;width:100%}
.settings-section select[name="theme_mode"]{max-width:260px}

@media(max-width:1000px){
  .topbar-inner{align-items:flex-start;flex-direction:column;gap:10px}
  .header-actions{width:100%;justify-content:flex-start}
  .topbar nav{justify-content:flex-start}
}
@media(max-width:700px){
  .topbar{padding-left:14px;padding-right:14px}
  .topbar-inner{gap:8px}
  .identity-bar{width:100%}
  .header-actions{align-items:flex-start}
}

/* COMUNA-GEST 0.9.4: cabecera por apartado, menú desplegable, permisos y pie fijo */
body{padding-bottom:58px}
.topbar{position:sticky;top:0;z-index:40;display:block;min-height:70px;padding:9px max(20px,calc((100vw - 1200px)/2));}
.topbar-inner{max-width:1200px;margin:0 auto;display:grid;grid-template-columns:minmax(360px,auto) minmax(170px,1fr) auto;align-items:center;gap:20px;width:100%}
.identity-bar{min-width:0}
.header-section-title{min-width:0;text-align:center;font-size:16px;font-weight:900;letter-spacing:.075em;color:#172033;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.header-menu-area{display:flex;justify-content:flex-end;align-items:center;position:relative}
.nav-dropdown{position:relative;margin:0}
.nav-dropdown>summary{list-style:none;display:flex;align-items:center;justify-content:center;gap:9px;min-width:100px;border:1px solid #cbd5e1;border-radius:9px;padding:9px 13px;background:#fff;color:#24364b;font-weight:850;font-size:13px;cursor:pointer;user-select:none}
.nav-dropdown>summary::-webkit-details-marker{display:none}
.nav-dropdown[open]>summary{border-color:#1769aa;box-shadow:0 0 0 3px rgba(23,105,170,.12)}
.menu-caret{font-size:11px;transition:transform .15s ease}.nav-dropdown[open] .menu-caret{transform:rotate(180deg)}
.nav-dropdown-panel{position:absolute;right:0;top:calc(100% + 9px);width:min(310px,calc(100vw - 24px));background:#fff;border:1px solid #dbe2ea;border-radius:13px;box-shadow:0 18px 45px rgba(15,23,42,.18);overflow:hidden;z-index:80}
.nav-dropdown-head{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:12px 14px;border-bottom:1px solid #e6ebf1;background:#f8fafc}
.user-role-label{font-size:11px;color:#64748b;font-weight:750}
.nav-dropdown-links{display:grid;padding:7px}
.nav-dropdown-links a,.nav-dropdown-foot a{display:block;padding:10px 11px;border-radius:8px;text-decoration:none;color:#334155;font-size:14px;font-weight:700}
.nav-dropdown-links a:hover,.nav-dropdown-links a.active,.nav-dropdown-foot a:hover{background:#edf5fc;color:#155f99}
.nav-dropdown-links a.active{font-weight:900}
.nav-dropdown-foot{border-top:1px solid #e6ebf1;padding:7px}.nav-dropdown-foot a{color:#9b1c1c}

.app-footer{position:fixed!important;left:0;right:0;bottom:0;z-index:35;width:100%;margin:0!important;border-top:1px solid #dde3ec;background:#fff;color:#64748b;box-shadow:0 -2px 10px rgba(15,23,42,.04)}
.footer-inner{min-height:52px;padding:10px 20px!important;white-space:nowrap}

.permission-panel{margin:4px 0 0}.permission-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;margin-top:12px}
.permission-option{display:flex;align-items:flex-start;gap:10px;padding:12px;border:1px solid #dfe5eb;border-radius:10px;background:#fff;cursor:pointer}
.permission-option input{width:auto;margin-top:3px;flex:0 0 auto}.permission-option span{display:flex;flex-direction:column;gap:3px}.permission-option small{font-size:11px;color:#7b8797;font-weight:500}.permission-option:hover{border-color:#a9c9e4;background:#f8fbfe}
.permissions-disabled{opacity:.52}.permissions-disabled .permission-option{pointer-events:none}.permission-summary{display:flex;gap:5px;flex-wrap:wrap}.mini-badge{display:inline-block;padding:3px 6px;border-radius:6px;background:#eef3f8;color:#4d6075;font-size:10px;font-weight:750}
.switch-row{display:flex;gap:12px;align-items:flex-start}.switch-row input{width:auto;margin-top:4px}.switch-row span{display:flex;flex-direction:column;gap:5px}.switch-row small{color:#64748b;font-weight:500;line-height:1.4}

html[data-theme="dark"] .header-section-title{color:#f1f5f9}
html[data-theme="dark"] .nav-dropdown>summary{background:#172033;color:#e5e7eb;border-color:#3a475a}
html[data-theme="dark"] .nav-dropdown-panel{background:#111827;border-color:#334155;box-shadow:0 18px 45px rgba(0,0,0,.38)}
html[data-theme="dark"] .nav-dropdown-head{background:#172033;border-bottom-color:#293548}
html[data-theme="dark"] .user-role-label{color:#9aa8ba}
html[data-theme="dark"] .nav-dropdown-links a,html[data-theme="dark"] .nav-dropdown-foot a{color:#d7deea}
html[data-theme="dark"] .nav-dropdown-links a:hover,html[data-theme="dark"] .nav-dropdown-links a.active{background:#1b2b40;color:#8ec5f0}
html[data-theme="dark"] .nav-dropdown-foot{border-top-color:#293548}html[data-theme="dark"] .nav-dropdown-foot a{color:#ffb4b4}
html[data-theme="dark"] .permission-option{background:#111827;border-color:#334155}html[data-theme="dark"] .permission-option:hover{background:#172033;border-color:#49647f}html[data-theme="dark"] .permission-option small{color:#9aa8ba}html[data-theme="dark"] .mini-badge{background:#243041;color:#cbd5e1}

@media(max-width:900px){
  body{padding-bottom:66px}
  .topbar-inner{grid-template-columns:minmax(0,1fr) auto;gap:10px 14px}
  .identity-bar{grid-column:1/-1;width:100%}
  .header-section-title{text-align:left;font-size:14px}
  .header-menu-area{grid-column:2;grid-row:2}
  .community-copy strong{max-width:260px}
}
@media(max-width:700px){
  body{padding-bottom:74px}
  .topbar{padding:9px 12px}.identity-bar{gap:9px}.product-name{font-size:15px}.community-copy strong{max-width:170px}.community-brand{padding-left:0!important;margin-top:0!important}.brand-divider{display:block!important}
  .header-section-title{font-size:13px;letter-spacing:.055em}.nav-dropdown>summary{min-width:88px;padding:8px 10px;font-size:12px}
  .permission-grid{grid-template-columns:1fr}
  .footer-inner{min-height:58px;padding:8px 10px!important;display:flex!important;flex-direction:column!important;gap:2px!important;white-space:normal}.footer-separator{display:none!important}.footer-inner span{width:auto!important}
}

/* Multi-tenant 0.10 */
.tenant-context-note{padding:.7rem 1rem;border-bottom:1px solid #e6ebf1;font-size:.86rem;line-height:1.35}
.tenant-context-note a{display:inline-block;margin-top:.25rem}
.actions-cell{display:flex;gap:.4rem;align-items:center;flex-wrap:wrap}
.inline-form{display:inline;margin:0}

html[data-theme="dark"] .tenant-context-note{border-bottom-color:#293548}

/* COMUNA-GEST 0.10.1: acceso por cliente y alias */
.login-card,.owner-login-card{max-width:520px}
.readonly-field{background:#f3f6f9!important;color:#526174!important;cursor:default}
.client-code{font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;letter-spacing:.035em;white-space:nowrap}
.alias-inline-form{display:flex;gap:6px;align-items:center;min-width:230px}
.alias-inline-form input{min-width:135px;padding:7px 8px}
.alias-inline-form .button{padding:7px 9px;white-space:nowrap}
html[data-theme="dark"] .readonly-field{background:#172033!important;color:#b9c5d4!important}
@media(max-width:900px){.alias-inline-form{min-width:190px;flex-wrap:wrap}.alias-inline-form input{min-width:120px}}

/* 0.10.2 · Recuperación de contraseñas */
.auth-secondary{margin-top:16px;text-align:center;font-size:13px}
.auth-secondary a{color:#1769aa;text-decoration:none;font-weight:700}
.auth-secondary a:hover{text-decoration:underline}
.smtp-test-form{padding-top:18px;border-top:1px solid #e5eaf1}
html[data-theme="dark"] .auth-secondary a{color:#70b7ee}
html[data-theme="dark"] .smtp-test-form{border-top-color:#293548}

/* COMUNA-GEST 0.10.4 · comunicaciones y avisos multidioma */
.compact-button{padding:6px 9px;font-size:12px;white-space:nowrap}
.communication-form-card{max-width:980px}
.recipient-selector{border:1px solid #dfe5eb;border-radius:12px;padding:14px;background:#f9fbfd}
.resident-check-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;max-height:380px;overflow:auto;padding:2px}
.communication-language-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:14px}
.communication-language-grid>div{border:1px solid #e1e7ee;border-radius:10px;padding:14px;background:#f9fbfd}
.message-preview{white-space:pre-wrap;line-height:1.55;color:#43546a}
.communications-summary .card h2{margin-top:5px}
html[data-theme="dark"] .recipient-selector,html[data-theme="dark"] .communication-language-grid>div{background:#111827;border-color:#334155}
html[data-theme="dark"] .message-preview{color:#c2ccd8}
@media(max-width:760px){.resident-check-grid,.communication-language-grid{grid-template-columns:1fr}}

/* COMUNA-GEST 0.10.6 · WhatsApp Business Platform por comunidad */
.channel-consent-box{border:1px solid #dbe5df;border-radius:11px;padding:12px 14px;background:#f7fbf8}
.channel-consent-box .check-row{margin:0}.channel-consent-box .field-help{margin:7px 0 0 28px}
.whatsapp-status-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(120px,1fr));gap:9px;margin:12px 0}
.whatsapp-status-grid>div{border:1px solid #e0e7e3;border-radius:9px;padding:10px;background:#f8fbf9}
html[data-theme="dark"] .channel-consent-box,html[data-theme="dark"] .whatsapp-status-grid>div{background:#111827;border-color:#334155}

/* COMUNA-GEST 0.11.0 · Dashboard anual y tesorería */
.dashboard-heading{align-items:flex-end}.year-selector{min-width:150px}.year-selector label{gap:4px}.year-selector select{padding:8px 10px}
.metric-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(170px,1fr));gap:12px;margin-bottom:22px}.metric-card{background:#fff;border:1px solid #dde3ec;border-radius:13px;padding:16px;box-shadow:0 3px 14px rgba(25,40,65,.045)}.metric-card span{display:block;color:#64748b;font-size:12px;font-weight:800;text-transform:uppercase;letter-spacing:.045em}.metric-card strong{display:block;margin-top:8px;font-size:25px;line-height:1.1}.metric-card small{display:block;margin-top:7px;color:#7b8797}.warning-metric{border-color:#f1d5a5}.danger-metric{border-color:#efc5c5}.balance-metric{border-color:#b9dfc7}.dashboard-section{margin-top:24px}.dashboard-section>h2,.section-title-row h2{margin:0 0 4px}.section-title-row{display:flex;justify-content:space-between;align-items:center;gap:12px;margin-bottom:12px}.section-title-row p{margin:0;color:#64748b}.progress-label{display:flex;justify-content:space-between;gap:10px;margin:12px 0 6px;font-size:12px;color:#64748b}.progress-label.second{margin-top:14px}.finance-progress span{background:#2f8c55}.dashboard-columns{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:16px}.dashboard-panel{background:#fff;border:1px solid #dde3ec;border-radius:14px;padding:18px}.account-summary{margin:14px 0 0}.account-summary>div{display:flex;justify-content:space-between;gap:12px;padding:9px 0;border-bottom:1px solid #edf1f5}.account-summary dt{color:#64748b}.account-summary dd{margin:0;font-weight:800}.account-summary .account-total{font-size:17px;border-bottom:0;padding-top:13px}.negative,.amount-debt{color:#a72b2b;font-weight:800}.breakdown-list{display:grid;gap:0;margin-top:12px}.breakdown-list>div{display:flex;justify-content:space-between;gap:12px;padding:11px 0;border-bottom:1px solid #edf1f5}.alert-stack{display:grid;gap:8px}.dashboard-alert{margin:0;background:#fff7e8;color:#765013;border:1px solid #efd6a6}.compact-table table{min-width:560px}.treasury-form{max-width:none;margin:0}.treasury-metrics{grid-template-columns:repeat(5,minmax(130px,1fr))}
html[data-theme="dark"] .metric-card,html[data-theme="dark"] .dashboard-panel{background:#111827;border-color:#334155}html[data-theme="dark"] .metric-card span,html[data-theme="dark"] .metric-card small,html[data-theme="dark"] .section-title-row p{color:#9aa8ba}html[data-theme="dark"] .account-summary>div,html[data-theme="dark"] .breakdown-list>div{border-bottom-color:#293548}html[data-theme="dark"] .dashboard-alert{background:#2b2416;color:#f4d69a;border-color:#5b4927}
@media(max-width:900px){.dashboard-columns{grid-template-columns:1fr}.treasury-metrics{grid-template-columns:repeat(2,minmax(140px,1fr))}}@media(max-width:600px){.metric-grid{grid-template-columns:repeat(2,minmax(0,1fr))}.metric-card strong{font-size:20px}.dashboard-heading{align-items:flex-start}.year-selector{width:100%}.section-title-row{align-items:flex-start;flex-direction:column}.treasury-metrics{grid-template-columns:1fr 1fr}}


/* COMUNA-GEST 0.11.1 · Dashboard visual + cache-busting release */
.dashboard-page{display:block;width:100%;min-width:0}
.dashboard-page .dashboard-heading{display:flex;align-items:flex-end;justify-content:space-between;gap:18px;margin-bottom:20px}
.dashboard-page .metric-grid{display:grid!important;grid-template-columns:repeat(6,minmax(0,1fr));gap:12px;margin:0 0 24px}
.dashboard-page .metric-card{display:flex;flex-direction:column;min-width:0;min-height:126px;background:#fff;border:1px solid #dde3ec;border-radius:14px;padding:16px;box-shadow:0 3px 14px rgba(25,40,65,.055)}
.dashboard-page .metric-card>span{display:block;color:#64748b;font-size:11px;font-weight:850;text-transform:uppercase;letter-spacing:.055em;line-height:1.25}
.dashboard-page .metric-card>strong{display:block;margin-top:10px;font-size:24px;line-height:1.08;overflow-wrap:anywhere}
.dashboard-page .metric-card>small{display:block;margin-top:auto;padding-top:9px;color:#7b8797;line-height:1.3}
.dashboard-page .warning-metric{border-left:4px solid #d8942f}
.dashboard-page .danger-metric{border-left:4px solid #bd4141}
.dashboard-page .balance-metric{border-left:4px solid #2f8c55}
.dashboard-page .dashboard-section{margin-top:26px;min-width:0}
.dashboard-page .cards{align-items:stretch}
.dashboard-page .card{min-width:0}
.dashboard-page .progress-label{display:flex;align-items:center;justify-content:space-between;gap:12px}
.dashboard-page .dashboard-columns{display:grid!important;grid-template-columns:repeat(2,minmax(0,1fr));gap:16px;align-items:start}
.dashboard-page .dashboard-panel{min-width:0;background:#fff;border:1px solid #dde3ec;border-radius:14px;padding:18px}
.dashboard-page .account-summary>div,.dashboard-page .breakdown-list>div{display:flex;align-items:baseline;justify-content:space-between;gap:14px}
.dashboard-page .account-summary dd,.dashboard-page .breakdown-list strong{white-space:nowrap}
.dashboard-page .table-wrap{max-width:100%}
.dashboard-page .compact-table table{min-width:520px}
html[data-theme="dark"] .dashboard-page .metric-card,html[data-theme="dark"] .dashboard-page .dashboard-panel{background:#111827;border-color:#334155}
html[data-theme="dark"] .dashboard-page .metric-card>span,html[data-theme="dark"] .dashboard-page .metric-card>small{color:#9aa8ba}
@media(max-width:1180px){.dashboard-page .metric-grid{grid-template-columns:repeat(3,minmax(0,1fr))}}
@media(max-width:900px){.dashboard-page .dashboard-columns{grid-template-columns:1fr!important}.dashboard-page .metric-grid{grid-template-columns:repeat(2,minmax(0,1fr))}}
@media(max-width:600px){.dashboard-page .dashboard-heading{align-items:flex-start;flex-direction:column}.dashboard-page .year-selector{width:100%}.dashboard-page .metric-grid{grid-template-columns:1fr}.dashboard-page .metric-card{min-height:auto}.dashboard-page .section-title-row{align-items:flex-start;flex-direction:column}.dashboard-page .compact-table table{min-width:480px}}

/* COMUNA-GEST 0.11.3 · menú persistente + superficies + SMTP por comunidad */
:root{
  --app-sidebar-width:272px;
  --app-topbar-height:70px;
  --app-footer-height:52px;
}
.sidebar-toggle{
  min-width:108px;
  min-height:40px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:9px;
  border:1px solid #cbd5e1;
  border-radius:9px;
  padding:8px 13px;
  background:#fff;
  color:#24364b;
  font-size:13px;
  font-weight:850;
  cursor:pointer;
}
.sidebar-toggle:hover{border-color:#9bb8d2;background:#f8fbfe}
.sidebar-toggle:focus-visible,.sidebar-close:focus-visible,.sidebar-nav a:focus-visible{outline:3px solid rgba(23,105,170,.24);outline-offset:2px}
.sidebar-toggle-icon{font-size:17px;line-height:1}

.app-sidebar{
  position:fixed;
  left:0;
  top:var(--app-topbar-height);
  bottom:var(--app-footer-height);
  width:var(--app-sidebar-width);
  z-index:34;
  display:flex;
  flex-direction:column;
  min-height:0;
  background:#fff;
  border-right:1px solid #dbe2ea;
  box-shadow:8px 0 22px rgba(15,23,42,.045);
  transform:translateX(-101%);
  transition:transform .2s ease;
  overflow:hidden;
}
body.sidebar-open .app-sidebar{transform:translateX(0)}
.sidebar-head{
  min-height:62px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:11px 13px 11px 16px;
  border-bottom:1px solid #e6ebf1;
  background:#f8fafc;
}
.sidebar-user{display:flex;flex-direction:column;align-items:flex-start;gap:3px;min-width:0}
.sidebar-user .user-chip{max-width:190px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.sidebar-close{
  flex:0 0 auto;
  width:36px;
  height:36px;
  padding:0;
  border-radius:9px;
  border:1px solid #d7dee8;
  background:#fff;
  color:#4b5d72;
  font-size:23px;
  line-height:1;
}
.sidebar-close:hover{background:#eef4fa;color:#174f7d}
.sidebar-nav{
  flex:1 1 auto;
  min-height:0;
  overflow-y:auto;
  overscroll-behavior:contain;
  padding:10px 9px 14px;
  display:flex;
  flex-direction:column;
  gap:3px;
}
.sidebar-nav a{
  position:relative;
  display:flex;
  align-items:center;
  gap:10px;
  min-height:43px;
  padding:9px 11px;
  border-radius:9px;
  color:#334155;
  text-decoration:none;
  font-size:13px;
  font-weight:750;
  line-height:1.25;
}
.sidebar-nav a:hover{background:#f0f6fb;color:#155f99}
.sidebar-nav a.active{background:#e8f2fa;color:#155f99;font-weight:900}
.sidebar-link-mark{
  flex:0 0 auto;
  width:7px;
  height:7px;
  border-radius:50%;
  background:#bdc8d5;
}
.sidebar-nav a.active .sidebar-link-mark{background:#1769aa;box-shadow:0 0 0 4px rgba(23,105,170,.12)}
.sidebar-foot{flex:0 0 auto;padding:10px;border-top:1px solid #e6ebf1;background:#fafbfc}
.sidebar-foot a{display:block;padding:10px 11px;border-radius:8px;text-decoration:none;color:#9b1c1c;font-size:13px;font-weight:800}
.sidebar-foot a:hover{background:#fff0f0}
.sidebar-backdrop{display:none}

main.app-content{transition:width .2s ease,margin-left .2s ease,padding-left .2s ease,padding-right .2s ease}
@media(min-width:901px){
  body.sidebar-open main.app-content{
    max-width:none;
    width:calc(100% - var(--app-sidebar-width));
    margin-left:var(--app-sidebar-width);
    margin-right:0;
    padding-left:max(20px,calc((100vw - var(--app-sidebar-width) - 1200px)/2));
    padding-right:max(20px,calc((100vw - var(--app-sidebar-width) - 1200px)/2));
  }
}

html[data-theme="dark"] .sidebar-toggle{background:#172033;color:#e5e7eb;border-color:#3a475a}
html[data-theme="dark"] .sidebar-toggle:hover{background:#1c293c;border-color:#506079}
html[data-theme="dark"] .app-sidebar{background:#111827;border-right-color:#334155;box-shadow:8px 0 24px rgba(0,0,0,.24)}
html[data-theme="dark"] .sidebar-head{background:#172033;border-bottom-color:#293548}
html[data-theme="dark"] .sidebar-close{background:#111827;color:#cbd5e1;border-color:#3a475a}
html[data-theme="dark"] .sidebar-close:hover{background:#1b2b40;color:#8ec5f0}
html[data-theme="dark"] .sidebar-nav a{color:#d7deea}
html[data-theme="dark"] .sidebar-nav a:hover,html[data-theme="dark"] .sidebar-nav a.active{background:#1b2b40;color:#8ec5f0}
html[data-theme="dark"] .sidebar-link-mark{background:#536176}
html[data-theme="dark"] .sidebar-nav a.active .sidebar-link-mark{background:#70b7ee;box-shadow:0 0 0 4px rgba(112,183,238,.12)}
html[data-theme="dark"] .sidebar-foot{background:#0f172a;border-top-color:#293548}
html[data-theme="dark"] .sidebar-foot a{color:#ffb4b4}
html[data-theme="dark"] .sidebar-foot a:hover{background:#2a171b}

@media(max-width:900px){
  :root{--app-sidebar-width:min(310px,88vw)}
  .sidebar-toggle{min-width:96px;min-height:38px;padding:7px 11px;font-size:12px}
  .app-sidebar{box-shadow:14px 0 34px rgba(15,23,42,.24)}
  .sidebar-backdrop{
    position:fixed;
    left:0;
    right:0;
    top:var(--app-topbar-height);
    bottom:var(--app-footer-height);
    z-index:33;
    background:rgba(15,23,42,.42);
    backdrop-filter:blur(1px);
  }
  body.sidebar-open .sidebar-backdrop{display:block}
  body.sidebar-open{overflow:hidden}
}
@media(max-width:600px){
  .sidebar-toggle span:last-child{display:none}
  .sidebar-toggle{min-width:42px;width:42px;padding:0}
  .sidebar-toggle-icon{font-size:20px}
}
@media(prefers-reduced-motion:reduce){
  .app-sidebar,main.app-content{transition:none}
}


/* COMUNA-GEST 0.11.3: estado del menú aplicado antes del primer pintado. */
@media(min-width:901px){
  html.sidebar-pref-open .app-sidebar{transform:translateX(0)}
  html.sidebar-pref-open body.has-sidebar main.app-content{
    max-width:none;
    width:calc(100% - var(--app-sidebar-width));
    margin-left:var(--app-sidebar-width);
    margin-right:0;
    padding-left:max(20px,calc((100vw - var(--app-sidebar-width) - 1200px)/2));
    padding-right:max(20px,calc((100vw - var(--app-sidebar-width) - 1200px)/2));
  }
}

/* Las superficies deben distinguirse claramente del fondo general en oscuro. */
html[data-theme="dark"] .card,
html[data-theme="dark"] .form-card,
html[data-theme="dark"] .auth-card,
html[data-theme="dark"] .meter-card,
html[data-theme="dark"] .table-wrap,
html[data-theme="dark"] .settings-section,
html[data-theme="dark"] .permission-option,
html[data-theme="dark"] .recipient-selector,
html[data-theme="dark"] .communication-language-grid>div,
html[data-theme="dark"] .channel-consent-box,
html[data-theme="dark"] .whatsapp-status-grid>div,
html[data-theme="dark"] .metric-card,
html[data-theme="dark"] .dashboard-panel,
html[data-theme="dark"] .dashboard-page .metric-card,
html[data-theme="dark"] .dashboard-page .dashboard-panel{
  background:#162235;
  border-color:#34445a;
}
html[data-theme="dark"] .audit-metrics>div{background:#1a293d;border-color:#34445a}
html[data-theme="dark"] th{background:#1d2b40}

/* COMUNA-GEST 0.11.4 · toma móvil de lecturas y fotografía */
.mobile-reading-page{max-width:760px;margin:0 auto;min-width:0}.mobile-reading-heading{margin-bottom:18px}.mobile-period-list{display:grid;gap:12px}.mobile-period-card{display:flex;align-items:center;justify-content:space-between;gap:18px;padding:18px;border:1px solid var(--panel-border,#dbe3ec);border-radius:14px;background:var(--panel-bg,#fff);text-decoration:none;color:inherit}.mobile-period-card:hover{border-color:#9db9d0}.mobile-period-card>div:first-child{display:flex;flex-direction:column;gap:5px}.mobile-period-card span{font-size:12px;color:#718096}.mobile-period-progress{text-align:right;color:#526579}.mobile-period-card.is-closed{opacity:.7}.mobile-meter-card{max-width:none}.photo-actions{display:grid;grid-template-columns:1fr 1fr;gap:10px}.photo-action{min-height:54px;border:1px solid #cbd5e1;border-radius:12px;background:#f8fafc;display:flex;align-items:center;justify-content:center;gap:8px;cursor:pointer;text-align:center}.photo-action:hover{background:#eef5fb;border-color:#9bb8d2}.sr-only{position:absolute!important;width:1px!important;height:1px!important;padding:0!important;margin:-1px!important;overflow:hidden!important;clip:rect(0,0,0,0)!important;white-space:nowrap!important;border:0!important}.photo-preview,.meter-photo-current{display:grid;gap:8px}.photo-preview img,.meter-photo-current img{width:100%;max-height:320px;object-fit:contain;border-radius:12px;border:1px solid #dbe3ec;background:#eef2f6}.meter-photo-current span{font-size:12px;color:#66758a}.mobile-reading-form .large{min-height:54px;font-size:17px}.mobile-reading-form .big-input input{font-size:26px;min-height:58px}.capture-nav{display:flex;justify-content:space-between;gap:10px;flex-wrap:wrap}html[data-theme="dark"] .mobile-period-card,html[data-theme="dark"] .photo-action{background:#172235;border-color:#35445a}html[data-theme="dark"] .photo-action:hover{background:#1d2b40}@media(max-width:560px){.mobile-period-card{align-items:flex-start;flex-direction:column}.mobile-period-progress{text-align:left}.photo-actions{grid-template-columns:1fr}.mobile-reading-page{max-width:none}}

/* COMUNA-GEST 0.11.5/0.11.6 · periodos configurables y conceptos */
.settings-shortcuts{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:14px}.settings-shortcut{display:flex;flex-direction:column;gap:7px;text-decoration:none;color:inherit;transition:border-color .15s ease}.settings-shortcut:hover{border-color:#96b5cf}.settings-shortcut strong{font-size:17px}.settings-shortcut span{color:#66758a;font-size:13px}.compact-input{max-width:90px}.compact-check{min-width:100px}.concept-filter{display:grid;grid-template-columns:minmax(180px,1fr) 220px auto;gap:10px}.concept-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(260px,1fr));gap:13px;margin-top:15px}.concept-card{display:block;background:var(--panel-bg,#fff);border:1px solid var(--panel-border,#dbe3ec);border-radius:14px;padding:16px;text-decoration:none;color:inherit;min-width:0}.concept-card:hover{border-color:#94b3cd}.concept-card h3{margin:12px 0 5px;font-size:17px}.concept-card p{margin:0;color:#68778a}.concept-card dl{margin:13px 0 0;display:grid;gap:7px}.concept-card dl div{display:flex;justify-content:space-between;gap:12px;border-top:1px solid #edf1f5;padding-top:7px}.concept-card dt{color:#758296;font-size:12px}.concept-card dd{margin:0;text-align:right;font-size:12px;font-weight:700}.concept-card-top{display:flex;align-items:center;justify-content:space-between;gap:8px}.concept-origin{font-size:10px;font-weight:850;letter-spacing:.06em;color:#738297}.concept-disabled{opacity:.72}.compact-alert{padding:8px 10px;margin:11px 0 0;font-size:12px}.readonly-definition{border:1px solid #dbe3ec;background:#f6f8fb;border-radius:10px;padding:12px}.period-checkbox-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(170px,1fr));gap:7px;margin-top:8px}.concept-rules-table{min-width:1080px}.tiny-input{width:105px;min-width:90px;padding:7px}.link-list{display:flex;flex-wrap:wrap;gap:8px;margin-top:12px}.link-list a{padding:7px 10px;border:1px solid #dbe3ec;border-radius:9px;text-decoration:none}.group-members{max-height:520px}.warning{background:#fff6e5;border-color:#efd19b;color:#71501a}html[data-theme="dark"] .concept-card,html[data-theme="dark"] .readonly-definition{background:#172235;border-color:#35445a}html[data-theme="dark"] .concept-card dl div{border-top-color:#2d3b50}html[data-theme="dark"] .settings-shortcut span,html[data-theme="dark"] .concept-card p{color:#aab5c5}@media(max-width:760px){.settings-shortcuts{grid-template-columns:1fr}.concept-filter{grid-template-columns:1fr}.concept-grid{grid-template-columns:1fr}}

/* COMUNA-GEST 0.11.6 · desglose de recibos */
.receipt-breakdown{display:grid;gap:0;margin-top:10px}.receipt-breakdown>div{display:flex;align-items:baseline;justify-content:space-between;gap:14px;padding:10px 0;border-bottom:1px solid #edf1f5}.receipt-breakdown small{color:#7a8798}.receipt-breakdown-total{font-size:18px;border-bottom:0!important;border-top:2px solid #d5dde7;margin-top:5px;padding-top:14px!important}.receipt-breakdown-total strong{font-size:21px}html[data-theme="dark"] .receipt-breakdown>div{border-bottom-color:#2b384b}html[data-theme="dark"] .receipt-breakdown-total{border-top-color:#46546a}

/* 0.11.8: entrada con circuitos separados */
.auth-card.entry-card{max-width:820px;margin:36px auto;padding:30px}
.entry-card h1{font-size:30px;margin:0 0 12px}
.entry-options{display:grid;grid-template-columns:1fr 1fr;gap:32px;margin-top:28px}
.entry-options>div+div{border-left:1px solid #8493a8;padding-left:28px}
.entry-options h2{font-size:21px}
.entry-options p{line-height:1.6}
.entry-options a:not(.button){color:#1769aa}
html[data-theme="dark"] .entry-options a:not(.button){color:#8bc9ff}
@media(max-width:640px){.auth-card.entry-card{margin:12px auto;padding:22px}.entry-options{grid-template-columns:1fr;gap:20px}.entry-options>div+div{border-left:0;border-top:1px solid #8493a8;padding:16px 0 0}.entry-card h1{font-size:26px}}
