/* ==========================================================================
   Nidal — hoja de estilos de la app (Laravel)
   Basada en docs/design-system-comunidad-residentes.html del proyecto WordPress.

   Regla de oro: NINGÚN color va escrito a mano fuera del bloque :root.
   Todo se pide por token semántico (--bg, --surface, --text, ...). Así el
   modo oscuro (bloque [data-theme="dark"] más abajo, ya definido pero sin
   activar) es cambiar un atributo en <html>, no tocar vistas.
   ========================================================================== */

@font-face {
    font-family: 'Sora';
    src: url('../fonts/Sora.ttf') format('truetype');
    font-weight: 100 800;
    font-style: normal;
    font-display: swap;
}

:root {
    /* --- Escalas de marca (Design System) --- */
    --p50: #EEF9FC; --p100: #D4F0F7; --p300: #76CEE5; --p500: #1D7F98; --p600: #18687C; --p700: #124F5E;
    --a50: #FBF2E9; --a100: #F5DEC6; --a300: #E7AD74; --a500: #E0954A; --a700: #945719; --a900: #4E2E0D;
    --s50: #EDF7F1; --s100: #D1EBDB; --s500: #4EB176; --s700: #2F6A47;
    --w50: #FAF4EA; --w100: #F3E2C9; --w500: #D08E2F; --w700: #855B1E;
    --d50: #FBF0EF; --d100: #F3D6D3; --d500: #C74538; --d700: #882F26;
    --n50: #F7F9FA; --n100: #EDF1F3; --n200: #DAE4E7; --n300: #BCCDD2; --n400: #8BA9B1;
    --n500: #628893; --n600: #4E6C74; --n700: #394F56; --n800: #253337; --n900: #161F22;

    /* --- Tokens semánticos (lo único que usan los componentes) --- */
    --bg: #F2F8F9;
    --surface: #FFFFFF;
    --surface-sunken: var(--n100);
    --text: #122A31;
    --text-muted: var(--n600);
    --border: var(--n200);
    --border-strong: var(--n300);
    --placeholder: #587B86; /* 4.57:1 sobre blanco (WCAG AA) */
    --link: var(--p600);
    --focus: var(--p500);

    --primary: var(--p500);
    --primary-hover: var(--p600);
    --primary-contrast: #FFFFFF;
    --primary-soft: var(--p50);
    --accent: var(--a500);
    --accent-btn: var(--a700);
    --accent-btn-hover: var(--a900);

    --sidebar-bg: var(--n900);
    --sidebar-text: #EDF1F3;
    --sidebar-muted: var(--n400);
    --sidebar-border: #2A3A40;
    --sidebar-hover: #202C30;
    --sidebar-active-bg: var(--p500);

    --ok-bg: var(--s100);   --ok-fg: var(--s700);
    --warn-bg: var(--w100); --warn-fg: var(--w700);
    --bad-bg: var(--d100);  --bad-fg: var(--d700);
    --info-bg: var(--p100); --info-fg: var(--p700);
    --neutral-bg: var(--n100); --neutral-fg: var(--n600);

    --danger: var(--d500);

    /* Visualización de datos: una sola tonalidad de marca para series; cuadrícula discreta */
    --viz-1: var(--p500);
    --viz-track: var(--p100);
    --viz-grid: var(--border);
    --viz-base: var(--border-strong);

    /* --- Espaciado, radios, sombras --- */
    --radius-sm: 6px; --radius: 8px; --radius-lg: 12px;
    --shadow-sm: 0 1px 2px rgba(18, 42, 49, .06);
    --shadow: 0 1px 3px rgba(18, 42, 49, .08), 0 1px 2px rgba(18, 42, 49, .04);
    --shadow-lg: 0 12px 32px rgba(18, 42, 49, .18);
    --target: 2.75rem;          /* objetivo táctil mínimo (44 px a tamaño base); solo se exige en móvil, ver @media al final */
    --sidebar-w: 16rem;
    --topbar-h: 4rem;

    --font: 'Sora', -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* Modo oscuro — definido a propósito, todavía NO se activa en ningún lado
   (no hay interruptor ni prefers-color-scheme). Se enciende con
   <html data-theme="dark">. */
:root[data-theme="dark"] {
    --bg: #0F1A1E;
    --surface: #16232A;
    --surface-sunken: #121C21;
    --text: #E7EEF0;
    --text-muted: #8BA9B1;
    --border: #2E3E44;
    --border-strong: #3B4F56;
    --placeholder: #8BA9B1;
    --link: #76CEE5;
    --primary-soft: #12303A;
    --sidebar-bg: #0B1214;
    --sidebar-border: #1F2D33;
    --sidebar-hover: #16232A;
    --ok-bg: #1F4A38;   --ok-fg: #8FD6B0;
    --warn-bg: #4A3A1E; --warn-fg: #E6C07A;
    --bad-bg: #4A2623;  --bad-fg: #F0A59E;
    --info-bg: #123B47; --info-fg: #9ADCEE;
    --neutral-bg: #1D2B31; --neutral-fg: #A9BEC4;
    --viz-1: var(--p300);
    --viz-track: #1B3A45;
    --shadow-sm: none; --shadow: none; --shadow-lg: 0 12px 32px rgba(0, 0, 0, .5);
    color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; font-size: 100%; }
[hidden] { display: none !important; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: .9375rem;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { font-family: var(--font); line-height: 1.2; margin: 0; color: var(--text); }
p { margin: 0 0 .75rem; }
img { max-width: 100%; }
.muted { color: var(--text-muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: .5rem; } .mt-2 { margin-top: 1rem; } .mt-3 { margin-top: 1.5rem; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: .5rem; } .mb-2 { margin-bottom: 1rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.icon { width: 1.25rem; height: 1.25rem; flex: none; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.icon.sm { width: 1rem; height: 1rem; }

/* ---------- Shell: sidebar + topbar + contenido ---------- */
.shell { min-height: 100vh; }
.sidebar {
    position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w);
    background: var(--sidebar-bg); color: var(--sidebar-text);
    display: flex; flex-direction: column; overflow-y: auto; z-index: 40;
    transition: transform .2s ease;
}
.sidebar .brand {
    height: var(--topbar-h); display: flex; align-items: center; justify-content: center;
    border-bottom: 1px solid var(--sidebar-border); flex: none; padding: 0 1rem;
}
.sidebar .brand img { height: 1.875rem; width: auto; display: block; }
.sidebar .brand small { display: block; text-align: center; color: var(--sidebar-muted); font-size: .66rem; letter-spacing: .08em; text-transform: uppercase; margin-top: .15rem; }
.sidebar nav { padding: .5rem 0 1.5rem; flex: 1; }
.nav-group { padding: 1rem 1.25rem .4rem; font-size: .7rem; letter-spacing: .06em; text-transform: uppercase; color: var(--sidebar-muted); font-weight: 400; }
.nav-item {
    position: relative; display: flex; align-items: center; gap: .8rem;
    padding: .62rem 1.25rem; color: var(--sidebar-text); font-size: .9rem; font-weight: 400;
    background: none; border: 0; width: 100%; text-align: left; cursor: pointer; font-family: inherit;
}
.nav-item:hover { background: var(--sidebar-hover); text-decoration: none; }
.nav-item.active { background: var(--sidebar-active-bg); font-weight: 600; color: #fff; }
.nav-item.active::after { content: ''; position: absolute; right: 0; top: 0; bottom: 0; width: .25rem; background: var(--accent); }
.nav-item .icon { opacity: .9; }
.sidebar form { margin: 0; }

.main-col { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; transition: margin-left .2s ease; }
.topbar {
    height: var(--topbar-h); background: var(--surface); border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between; padding: 0 1.5rem;
    position: sticky; top: 0; z-index: 30;
}
.icon-btn { background: none; border: 0; color: var(--text-muted); cursor: pointer; padding: .4rem; border-radius: var(--radius-sm); display: inline-flex; }
.icon-btn:hover { background: var(--surface-sunken); color: var(--text); }
.topbar-title { margin-left: .75rem; font-size: .9rem; color: var(--text-muted); }

.user-menu { position: relative; }
.user-menu > button {
    display: flex; align-items: center; gap: .6rem; background: none; border: 0; cursor: pointer;
    font-family: inherit; font-size: .9rem; color: var(--text); padding: .25rem .4rem; border-radius: var(--radius);
}
.user-menu > button:hover { background: var(--surface-sunken); }
.user-menu .who { text-align: right; line-height: 1.15; }
.user-menu .who small { display: block; color: var(--text-muted); font-size: .72rem; }

.dropdown {
    position: absolute; right: 0; top: calc(100% + .375rem); min-width: 12.5rem; background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg);
    padding: .35rem; z-index: 60; display: none;
}
.dropdown.open { display: block; }
.dropdown a, .dropdown button {
    display: flex; align-items: center; gap: .6rem; width: 100%; padding: .5rem .65rem; border: 0; background: none;
    color: var(--text); font: inherit; font-size: .88rem; border-radius: var(--radius-sm); cursor: pointer; text-align: left;
}
.dropdown a:hover, .dropdown button:hover { background: var(--surface-sunken); text-decoration: none; }
.dropdown .danger { color: var(--danger); }
.dropdown form { margin: 0; }

.content { padding: 1.75rem 1.75rem 3rem; width: 100%; max-width: none; }
.scrim { display: none; }

/* Sidebar colapsada (escritorio): queda un riel de íconos, como en WordPress */
:root { --sidebar-w-collapsed: 4.5rem; }
.sidebar .brand .logo-mini { display: none; height: 1.625rem; width: auto; }
.nav-item .label { white-space: nowrap; }
@media (min-width: 60.0625em) {
    body.sidebar-collapsed .sidebar { width: var(--sidebar-w-collapsed); overflow-x: hidden; }
    body.sidebar-collapsed .main-col { margin-left: var(--sidebar-w-collapsed); }
    body.sidebar-collapsed .brand { padding: 0; }
    body.sidebar-collapsed .brand .logo-full { display: none; }
    body.sidebar-collapsed .brand .logo-mini { display: block; }
    body.sidebar-collapsed .nav-group { font-size: 0; height: 0; padding: 0; margin: .6rem 1.1rem; border-top: 1px solid var(--sidebar-border); }
    body.sidebar-collapsed .nav-item { justify-content: center; padding: .8rem 0; gap: 0; }
    body.sidebar-collapsed .nav-item .label { display: none; }
}

@media (max-width: 60em) {
    .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
    .main-col { margin-left: 0; }
    body.sidebar-open .sidebar { transform: none; }
    body.sidebar-open .scrim { display: block; position: fixed; inset: 0; background: rgba(10, 20, 24, .5); z-index: 35; }
    .content { padding: 1.25rem 1rem 2.5rem; }
    .topbar { padding: 0 1rem; }
    .user-menu .who { display: none; }
}

/* ---------- Cabecera de página ---------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.page-head h1 { font-size: 1.65rem; font-weight: 700; letter-spacing: -.01em; }
.page-head p { margin: .3rem 0 0; color: var(--text-muted); font-size: .95rem; }
.page-head .actions { display: flex; gap: .6rem; flex-wrap: wrap; }
.h2 { font-size: 1.15rem; font-weight: 700; }

/* ---------- Botones ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
    padding: .6rem 1.1rem; border-radius: var(--radius); border: 1px solid transparent;
    background: var(--primary); color: var(--primary-contrast); font: inherit; font-size: .9rem; font-weight: 600;
    cursor: pointer; text-decoration: none; line-height: 1.2; transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--primary-hover); text-decoration: none; color: var(--primary-contrast); }
.btn.outline { background: var(--surface); color: var(--text); border-color: var(--border-strong); font-weight: 500; }
.btn.outline:hover { background: var(--surface-sunken); color: var(--text); }
.btn.danger { background: var(--surface); color: var(--danger); border-color: var(--d100); font-weight: 500; }
.btn.danger:hover { background: var(--d50); color: var(--d700); }
.btn.accent { background: var(--accent-btn); color: #fff; }
.btn.accent:hover { background: var(--accent-btn-hover); }
.btn.sm { padding: .38rem .8rem; font-size: .82rem; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--link); cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
.inline-form { display: inline; margin: 0; }
.btn-row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }

/* ---------- Tarjetas, tablas ---------- */
.card { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow); border: 1px solid var(--border); margin-bottom: 1.25rem; }
.card-pad { padding: 1.5rem; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); }
.card-head .count { display: flex; align-items: center; gap: .5rem; font-size: .9rem; }
.card h2 { font-size: 1.15rem; font-weight: 700; margin-bottom: .75rem; }

.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-weight: 700; font-size: .88rem; padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: .9rem 1.25rem; border-bottom: 1px solid var(--border); font-size: .9rem; vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--n50); }
.table .strong { font-weight: 700; }
.table .col-actions { text-align: right; width: 1%; white-space: nowrap; }
.table .empty td { text-align: center; color: var(--text-muted); padding: 2.5rem 1rem; }
.cell-user { display: flex; align-items: center; gap: .85rem; }
.cell-user .sub { display: block; color: var(--text-muted); font-size: .78rem; font-weight: 400; }

/* ---------- Avatares ---------- */
.avatar {
    --size: 2.5rem; width: var(--size); height: var(--size); border-radius: 50%; flex: none;
    background: var(--primary-soft); color: var(--p700); display: inline-flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: calc(var(--size) * .38); letter-spacing: .02em; overflow: hidden; user-select: none;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar.sm { --size: 2rem; } .avatar.lg { --size: 3.5rem; } .avatar.xl { --size: 6rem; }
.avatar.square { border-radius: var(--radius); }

/* ---------- Badges ---------- */
.badge {
    display: inline-flex; align-items: center; padding: .18rem .6rem; border-radius: 999px;
    font-size: .7rem; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; white-space: nowrap;
    background: var(--neutral-bg); color: var(--neutral-fg);
}
.badge.ok { background: var(--ok-bg); color: var(--ok-fg); }
.badge.warn { background: var(--warn-bg); color: var(--warn-fg); }
.badge.bad { background: var(--bad-bg); color: var(--bad-fg); }
.badge.info { background: var(--info-bg); color: var(--info-fg); }

/* ---------- Formularios ---------- */
.field { margin-bottom: 1rem; min-width: 0; }
.field label, label.lbl { display: block; font-size: .85rem; font-weight: 700; margin-bottom: .35rem; color: var(--text); }
.field label .opt, label.lbl .opt { font-weight: 400; color: var(--text-muted); }
.input, .select, .textarea, .field input[type=text], .field input[type=email], .field input[type=password], .field input[type=number], .field input[type=tel], .field input[type=url],
.field input[type=date], .field input[type=time], .field input[type=search], .field input[type=file], .field select, .field textarea {
    width: 100%; padding: .65rem .8rem; border: 1px solid var(--border-strong); border-radius: var(--radius);
    background: var(--surface); color: var(--text); font: inherit; font-size: .92rem; min-height: 2.75rem;
}
.field input[type=file] { padding: .5rem .6rem; }
.textarea, .field textarea { min-height: 7.5rem; resize: vertical; }
.input:focus, .select:focus, .textarea:focus, .field input:focus, .field select:focus, .field textarea:focus {
    outline: 2px solid var(--focus); outline-offset: 0; border-color: var(--focus);
}
.field input[readonly] { background: var(--surface-sunken); color: var(--text-muted); }
.field input::placeholder, .input::placeholder, .search input::placeholder, .field textarea::placeholder { color: var(--placeholder); opacity: 1; }
.hint { font-size: .8rem; color: var(--text-muted); margin-top: .3rem; }
.form-grid { display: grid; gap: 0 1.5rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .span-2 { grid-column: 1 / -1; }
@media (max-width: 45em) { .form-grid { grid-template-columns: 1fr; } }
.form-section { margin: 1.5rem 0 1rem; padding-top: 1.25rem; border-top: 1px solid var(--border); }
.form-section h2 { font-size: 1.1rem; margin-bottom: .25rem; }
.check { display: flex; gap: .6rem; align-items: flex-start; font-size: .9rem; margin-bottom: .75rem; }
.check input { width: 1.125rem; height: 1.125rem; margin-top: .15rem; accent-color: var(--primary); }
.form-actions { display: flex; gap: .6rem; margin-top: 1.25rem; flex-wrap: wrap; }
.input-group { position: relative; }
.input-group .toggle { position: absolute; right: .35rem; top: 50%; transform: translateY(-50%); }
.input-group input { padding-right: 2.6rem !important; }
.narrow { max-width: 40rem; } .narrow-sm { max-width: 28.75rem; }

/* ---------- Buscador y filtros de fecha ---------- */
.search { display: flex; gap: .5rem; align-items: center; }
.search .field-icon { position: relative; }
.search .field-icon .icon { position: absolute; left: .75rem; top: 50%; transform: translateY(-50%); color: var(--n400); pointer-events: none; }
.search input { padding-left: 2.4rem; min-width: 16.25rem; min-height: 2.75rem; border: 1px solid var(--border-strong); border-radius: var(--radius); font: inherit; font-size: .9rem; background: var(--surface); color: var(--text); width: 100%; padding-top: .5rem; padding-bottom: .5rem; padding-right: .8rem; }
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.seg a { padding: .55rem .9rem; font-size: .84rem; color: var(--text); border-right: 1px solid var(--border-strong); white-space: nowrap; }
.seg a:last-child { border-right: 0; }
.seg a:hover { background: var(--surface-sunken); text-decoration: none; }
.seg a.active { background: var(--primary); color: #fff; font-weight: 600; }
.range-form { display: flex; gap: .75rem; align-items: flex-end; flex-wrap: wrap; padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); background: var(--n50); }
.range-form .field { margin: 0; }
.quick { display: flex; gap: .5rem; flex-wrap: wrap; }
.tabs { display: flex; gap: 1.5rem; border-bottom: 1px solid var(--border); margin-bottom: 1.25rem; }
.tabs a { padding: .6rem .1rem; font-size: .92rem; color: var(--text-muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.active { color: var(--text); font-weight: 700; border-bottom-color: var(--primary); }
.tabs a:hover { text-decoration: none; color: var(--text); }

/* ---------- Menú de acciones por fila ("…") ---------- */
.row-menu { position: relative; display: inline-block; }
.row-menu .dropdown { min-width: 11.25rem; }

/* ---------- Alertas ---------- */
.alert { display: flex; gap: .75rem; align-items: flex-start; padding: .85rem 1.1rem; border-radius: var(--radius); margin-bottom: 1.25rem; font-size: .9rem; border: 1px solid transparent; }
.alert .icon { margin-top: .1rem; }
.alert.ok { background: var(--ok-bg); color: var(--ok-fg); }
.alert.bad { background: var(--bad-bg); color: var(--bad-fg); }
.alert.info { background: var(--info-bg); color: var(--info-fg); }
.alert ul { margin: 0; padding-left: 1.1rem; }
.alert .close { margin-left: auto; background: none; border: 0; color: inherit; cursor: pointer; opacity: .7; padding: 0; }

/* ---------- Estadísticas (dashboard) ---------- */
.stats { display: grid; gap: 1.25rem; grid-template-columns: repeat(auto-fit, minmax(16.25rem, 1fr)); margin-bottom: 1.25rem; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 1.25rem 1.4rem; }
.stat .top { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.stat .label { font-weight: 700; font-size: .95rem; }
.stat .ico { width: 2.5rem; height: 2.5rem; border-radius: 50%; border: 1.5px solid var(--primary); color: var(--primary); display: inline-flex; align-items: center; justify-content: center; flex: none; }
.stat .value { font-size: 2rem; font-weight: 700; margin-top: .6rem; letter-spacing: -.02em; }
.stat .foot { margin-top: .8rem; }
.stat .seg { width: 100%; flex-wrap: wrap; }
.stat .seg a { flex: 1; text-align: center; padding: .45rem .5rem; font-size: .78rem; }
.tiles { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(13.75rem, 1fr)); }
.tile { display: flex; gap: .9rem; align-items: center; padding: 1.1rem 1.25rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); color: var(--text); box-shadow: var(--shadow); }
.tile:hover { border-color: var(--primary); text-decoration: none; }
.tile .ico { width: 2.625rem; height: 2.625rem; border-radius: var(--radius); background: var(--primary-soft); color: var(--primary); display: inline-flex; align-items: center; justify-content: center; }
.tile strong { display: block; font-size: .95rem; }
.tile span { color: var(--text-muted); font-size: .8rem; }

/* ---------- Listas de contenido (noticias, comunicados, recibos) ---------- */
.feed { padding: .5rem 1.25rem; }
.feed-item { display: flex; gap: 1.25rem; padding: 1.5rem .25rem; border-bottom: 1px solid var(--border); }
.feed-item:last-child { border-bottom: 0; }
.feed-item .thumb { width: 7.5rem; height: 7.5rem; border-radius: var(--radius); object-fit: cover; flex: none; background: var(--surface-sunken); }
.feed-item .body { flex: 1; min-width: 0; }
.feed-item .head { display: flex; justify-content: space-between; gap: 1rem; align-items: baseline; }
.feed-item h3 { font-size: 1.25rem; font-weight: 700; letter-spacing: -.01em; }
.feed-item .date { color: var(--text-muted); font-size: .82rem; white-space: nowrap; }
.feed-item .excerpt { margin: .5rem 0 .75rem; color: var(--text); white-space: pre-line; }
.feed-item .links { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
@media (max-width: 40em) {
    .feed-item { flex-direction: column; }
    .feed-item .thumb { width: 100%; height: 10rem; }
    .feed-item .head { flex-direction: column; gap: .25rem; }
}
.breakdown { margin-top: .6rem; font-size: .88rem; display: grid; gap: .15rem; }
.breakdown .total { font-weight: 700; }

/* ---------- Modal de confirmación ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(10, 20, 24, .55); display: none; align-items: center; justify-content: center; z-index: 100; padding: 1rem; }
.modal-backdrop.open { display: flex; }
.modal { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); width: 100%; max-width: 27.5rem; padding: 1.5rem; }
.modal h3 { font-size: 1.15rem; margin-bottom: .5rem; }
.modal p { color: var(--text-muted); margin-bottom: 1.25rem; }
.modal .btn-row { justify-content: flex-end; }

/* ---------- Paginación ---------- */
.pager { display: flex; gap: .35rem; flex-wrap: wrap; justify-content: center; margin: 1.25rem 0 0; }
.pager a, .pager span { padding: .4rem .75rem; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); font-size: .85rem; background: var(--surface); color: var(--text); }
.pager a:hover { background: var(--surface-sunken); text-decoration: none; }
.pager .current { background: var(--primary); color: #fff; border-color: var(--primary); font-weight: 600; }
.pager .disabled { color: var(--n400); }

/* ---------- Dos columnas (calles/ciudadelas) ---------- */
.cols-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem; align-items: start; }
@media (max-width: 56.25em) { .cols-2 { grid-template-columns: 1fr; } }
.list-rows .row { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .65rem .9rem; border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: .5rem; }
.list-rows .row:last-child { margin-bottom: 0; }
.add-row { display: flex; gap: .5rem; margin-bottom: 1rem; }
.add-row .input { flex: 1; }

/* ---------- Perfil ---------- */
.profile-head { display: flex; gap: 1.25rem; align-items: center; margin-bottom: 1.5rem; flex-wrap: wrap; }
.profile-head h2 { font-size: 1.4rem; margin: 0; }
.profile-photo { display: flex; flex-direction: column; gap: .5rem; align-items: flex-start; }

/* ---------- Login ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); background: var(--bg); }
.auth-aside {
    background: var(--sidebar-bg); color: var(--sidebar-text); display: flex; flex-direction: column; justify-content: space-between;
    padding: 3rem 3.5rem; position: relative; overflow: hidden;
}
.auth-aside::before { content: ''; position: absolute; width: 32.5rem; height: 32.5rem; border-radius: 50%; right: -11.25rem; bottom: -12.5rem; background: radial-gradient(circle, rgba(29, 127, 152, .45), transparent 70%); }
.auth-aside::after { content: ''; position: absolute; width: 20rem; height: 20rem; border-radius: 50%; left: -7.5rem; top: 30%; background: radial-gradient(circle, rgba(224, 149, 74, .16), transparent 70%); }
.auth-aside img { height: 2.625rem; width: auto; position: relative; z-index: 1; align-self: flex-start; }
.auth-aside .pitch { position: relative; z-index: 1; max-width: 28.75rem; }
.auth-aside .pitch h2 { color: #fff; font-size: 2rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; }
.auth-aside .pitch p { color: var(--sidebar-muted); margin-top: 1rem; font-size: 1rem; }
.auth-aside .foot { position: relative; z-index: 1; color: var(--sidebar-muted); font-size: .8rem; }
.auth-main { display: flex; align-items: center; justify-content: center; padding: 2rem 1.5rem; }
.auth-card { width: 100%; max-width: 25rem; }
.auth-card .logo-mobile { display: none; height: 2.125rem; margin-bottom: 2rem; }
.auth-card h1 { font-size: 1.75rem; font-weight: 700; letter-spacing: -.02em; }
.auth-card .lead { color: var(--text-muted); margin: .5rem 0 1.75rem; }
.auth-card .comunidad-chip { display: inline-flex; align-items: center; gap: .5rem; background: var(--primary-soft); color: var(--p700); padding: .3rem .8rem; border-radius: 999px; font-size: .8rem; font-weight: 600; margin-bottom: 1rem; }
.auth-card .btn { width: 100%; min-height: 2.875rem; margin-top: .5rem; }
.auth-card .foot { margin-top: 1.5rem; font-size: .82rem; color: var(--text-muted); text-align: center; }
@media (max-width: 56.25em) {
    .auth { grid-template-columns: 1fr; }
    .auth-aside { display: none; }
    .auth-card .logo-mobile { display: block; }
}

/* ---------- Welcome / vacío ---------- */
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text-muted); }

/* Impresión: solo el contenido */
@media print { .sidebar, .topbar { display: none !important; } .main-col { margin: 0; } }

/* ---------- Errores de campo ---------- */
.field-error { color: var(--bad-fg); font-size: .8rem; margin-top: .3rem; }
.field.invalid input, .field.invalid select, .field.invalid textarea { border-color: var(--danger); }

/* Ajustes: checkbox dentro de .field y acciones de tabla en una sola línea */
.field label.check { display: flex; font-weight: 400; margin-bottom: .75rem; }
.col-actions .btn-row { flex-wrap: nowrap; }
.col-actions form { display: inline; margin: 0; }

/* ---------- Móvil ---------- */
.search { flex-wrap: wrap; }
.search .field-icon { flex: 1 1 12.5rem; min-width: 0; }
.search input { min-width: 0; }
.seg { flex-wrap: wrap; max-width: 100%; }
.table-wrap > .table { min-width: 35rem; }
.table-wrap > .table.stack { min-width: 0; }

@media (max-width: 45em) {
    .page-head h1 { font-size: 1.4rem; }
    .card-head { padding: .85rem 1rem; }
    .seg a { padding: .45rem .7rem; font-size: .8rem; }
    .search { width: 100%; }
    .search .btn { flex: none; }

    /* Tablas "apiladas": cada fila pasa a ser una tarjeta con etiqueta: valor */
    .table.stack, .table.stack tbody { display: block; }
    .table.stack thead { display: none; }
    .table.stack tr { display: block; padding: .85rem 1rem; border-bottom: 1px solid var(--border); }
    .table.stack tbody tr:last-child { border-bottom: 0; }
    .table.stack td { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .3rem 0; border: 0; text-align: right; }
    .table.stack td::before { content: attr(data-label); font-weight: 700; font-size: .78rem; color: var(--text-muted); text-align: left; flex: none; }
    .table.stack td:not([data-label])::before, .table.stack td[data-label=""]::before { display: none; }
    .table.stack td.col-actions { width: auto; justify-content: flex-end; padding-top: .6rem; }
    .table.stack .empty td { justify-content: center; text-align: center; }
    .table.stack .btn-row { justify-content: flex-end; }
    .table.stack .cell-user { justify-content: flex-end; }
    .stack-primary { font-size: 1.05rem; }
}


/* ---------- Tarjeta de credencial (contraseña temporal) ---------- */
.credencial { background: var(--info-bg); color: var(--info-fg); border: 1px solid var(--p300); border-radius: var(--radius-lg); padding: 1.25rem 1.4rem; margin-bottom: 1.25rem; }
.credencial-head { display: flex; gap: .85rem; align-items: flex-start; }
.credencial-head h2 { color: inherit; font-size: 1.05rem; margin: 0 0 .25rem; }
.credencial-head p { margin: 0; }
.credencial-datos { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: .75rem 1.5rem; margin: 1rem 0; }
.credencial-datos dt { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; opacity: .85; }
.credencial-datos dd { margin: .15rem 0 0; font-weight: 700; color: var(--text); word-break: break-all; }
.credencial-datos code { font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; font-size: 1.1rem; background: var(--surface); padding: .25rem .6rem; border-radius: var(--radius-sm); border: 1px dashed var(--p500); user-select: all; }

/* Botón bloqueado mientras se envía (ver nidal.js) */
.btn.is-busy, .btn[aria-busy="true"] { opacity: .7; cursor: progress; pointer-events: none; }

/* Placa en grande dentro del modal de confirmación (cola del Guardia) */
.modal-plate { margin: .25rem 0 1rem; padding: .6rem 1rem; text-align: center; font-size: 2.4rem; font-weight: 800; letter-spacing: .14em; line-height: 1.1; text-transform: uppercase; background: var(--surface-sunken); color: var(--text); border: 3px solid var(--text); border-radius: var(--radius); }
.modal-plate + p { text-align: center; }

/* ---------- Pantallas de ajustes (SMTP): filas etiqueta | control ---------- */
.setting-row { display: grid; grid-template-columns: 14rem minmax(0, 1fr); gap: .35rem 2rem; padding: 1.25rem 0; border-bottom: 1px solid var(--border); }
.setting-row:last-of-type { border-bottom: 0; }
.setting-row > .lbl { font-weight: 700; font-size: .9rem; padding-top: .65rem; margin: 0; }
.setting-row .control { min-width: 0; }
.setting-row .control .input, .setting-row .control input[type=text], .setting-row .control input[type=email], .setting-row .control input[type=password], .setting-row .control select { max-width: 32rem; }
.setting-row .control .input-port { max-width: 8rem; }
.setting-help { font-size: .84rem; color: var(--text-muted); margin: .4rem 0 0; max-width: 42rem; }
@media (max-width: 45em) { .setting-row { grid-template-columns: 1fr; gap: .25rem; } .setting-row > .lbl { padding-top: 0; } }

.switch { position: relative; display: inline-flex; align-items: center; gap: .65rem; cursor: pointer; font-size: .78rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--text-muted); padding-top: .35rem; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { width: 2.75rem; height: 1.5rem; border-radius: 999px; background: var(--n300); position: relative; flex: none; transition: background .15s; }
.switch .track::after { content: ''; position: absolute; top: .1875rem; left: .1875rem; width: 1.125rem; height: 1.125rem; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0, 0, 0, .25); }
.switch input:checked + .track { background: var(--s500); }
.switch input:checked + .track::after { transform: translateX(1.25rem); }
.switch input:focus-visible + .track { outline: 2px solid var(--focus); outline-offset: 2px; }
.switch .on { display: none; } .switch .off { display: inline; }
.switch input:checked ~ .on { display: inline; } .switch input:checked ~ .off { display: none; }

.radios { display: flex; gap: .5rem 1.75rem; flex-wrap: wrap; padding-top: .6rem; }
.radios label { display: inline-flex; align-items: center; gap: .5rem; font-weight: 400; margin: 0; cursor: pointer; font-size: .92rem; }
.radios input { width: 1.125rem; height: 1.125rem; accent-color: var(--primary); margin: 0; }
.nota-proveedor { background: var(--primary-soft); color: var(--info-fg); border-radius: var(--radius); padding: .65rem .9rem; font-size: .84rem; margin-top: .6rem; max-width: 42rem; }
.estado-prueba { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; margin-top: 1rem; font-size: .88rem; }
.is-disabled { opacity: .5; pointer-events: none; }


/* ---------- Objetivos táctiles en móvil: mínimo 2.75rem (44 px a tamaño base) ----------
   En rem, no en px: si la persona agranda el texto del navegador, el área de toque
   crece con él. Solo bajo 45em (720 px); en escritorio los controles no cambian. */
@media (max-width: 45em) {
    .btn, .btn.sm { min-height: var(--target); }
    .icon-btn { min-width: var(--target); min-height: var(--target); align-items: center; justify-content: center; }
    .seg a { display: inline-flex; align-items: center; justify-content: center; min-height: var(--target); }
    .tabs a { display: inline-flex; align-items: center; min-height: var(--target); }
    .pager a, .pager span { display: inline-flex; align-items: center; justify-content: center; min-height: var(--target); min-width: var(--target); }
    .dropdown a, .dropdown button { min-height: var(--target); }
    .user-menu > button { min-height: var(--target); }
    .link-btn { min-height: var(--target); display: inline-flex; align-items: center; }
    .check, .radios label { min-height: var(--target); align-items: center; }
    .switch { min-height: var(--target); padding-top: 0; }
    .stat .seg a { min-height: var(--target); }
}

/* Fila de ítem de recibo: categoría | valor | quitar */
.item-row { display: grid; grid-template-columns: 1fr 1fr 2.75rem; gap: .75rem; margin-bottom: .6rem; align-items: center; }
.item-row select, .item-row input { width: 100%; padding: .65rem .8rem; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); color: var(--text); font: inherit; font-size: .92rem; min-height: 2.75rem; }
@media (max-width: 45em) { .item-row { grid-template-columns: 1fr 1fr; } .item-row .quitar-item { grid-column: 1 / -1; } }

/* Foto destacada: caja punteada con el selector de archivo */
.file-drop { border: 1px dashed var(--border-strong); border-radius: var(--radius); padding: .6rem .8rem; background: var(--surface); display: flex; align-items: center; gap: .75rem; min-height: 2.75rem; }
.field .file-drop input[type=file] { border: 0; padding: 0; min-height: 0; width: auto; background: none; flex: 1; }
.file-drop-preview { width: 3rem; height: 3rem; object-fit: cover; border-radius: var(--radius-sm); }

/* ---------- Código QR de la comunidad ---------- */
.qr-card { display: flex; gap: 1.75rem; align-items: flex-start; flex-wrap: wrap; }
.qr-img { width: 13.5rem; max-width: 100%; flex: none; background: #fff; border: 1px solid var(--border); border-radius: var(--radius-lg); padding: .6rem; line-height: 0; }
.qr-img svg { width: 100%; height: auto; display: block; }
.qr-info { flex: 1 1 22rem; min-width: 0; }
.qr-info h2 { margin-bottom: .35rem; }
.qr-stats { display: flex; gap: 2rem; flex-wrap: wrap; margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.qr-stats strong { display: block; font-size: 1.5rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.qr-stats span { color: var(--text-muted); font-size: .8rem; }

/* ---------- Gráficos (estadísticas) ---------- */
.viz-scroll { overflow-x: auto; }
.viz-svg { width: 100%; min-width: 34rem; height: auto; display: block; }
.viz-grid { stroke: var(--viz-grid); stroke-width: 1; }
.viz-base { stroke: var(--viz-base); stroke-width: 1; }
.viz-axis { fill: var(--text-muted); font-size: 11px; font-family: var(--font); }
.viz-label { fill: var(--text); font-size: 12px; font-weight: 700; font-family: var(--font); }
.viz-bar { fill: var(--viz-1); transition: opacity .12s; }
.viz-hit { fill: transparent; cursor: default; outline: none; }
.viz-col:hover .viz-bar, .viz-col:focus-within .viz-bar { opacity: .78; }
.viz-hit:focus-visible { stroke: var(--focus); stroke-width: 2; }
.viz-vacio { color: var(--text-muted); font-size: .88rem; text-align: center; margin: .25rem 0 .75rem; }
.viz-tabla { margin-top: .5rem; font-size: .85rem; }
.viz-tabla summary { cursor: pointer; color: var(--link); width: fit-content; }
.viz-tabla .table-wrap { max-height: 16rem; overflow-y: auto; margin-top: .5rem; }
.viz-tip { position: fixed; z-index: 90; pointer-events: none; background: var(--n900); color: #fff; border-radius: var(--radius-sm); padding: .4rem .65rem; font-size: .78rem; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; gap: .1rem; white-space: nowrap; }
.viz-tip strong { font-size: .95rem; }
.viz-tip span { color: var(--n300); }
.viz-tip[hidden] { display: none; }

.hbars { display: grid; gap: .55rem; }
.hbar { display: grid; grid-template-columns: minmax(6rem, 11rem) 1fr 3rem; gap: .75rem; align-items: center; font-size: .88rem; }
.hbar-label { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-track { height: .625rem; background: var(--viz-track); border-radius: 0 4px 4px 0; overflow: hidden; }
.hbar-fill { display: block; height: 100%; background: var(--viz-1); border-radius: 0 4px 4px 0; }
.hbar-valor { text-align: right; font-weight: 700; }

.meter { height: .75rem; background: var(--viz-track); border-radius: 999px; overflow: hidden; margin-top: .6rem; }
.meter > span { display: block; height: 100%; background: var(--viz-1); border-radius: 999px; }
.hero { font-size: 3rem; font-weight: 800; letter-spacing: -.03em; line-height: 1; }
.viz-card h3 { font-size: 1rem; font-weight: 700; }
.viz-card .viz-sum { color: var(--text-muted); font-size: .85rem; margin: .15rem 0 .75rem; }
.filters-row { display: flex; gap: .75rem 1.25rem; align-items: center; flex-wrap: wrap; margin-bottom: 1.25rem; }
.filters-row .field { margin: 0; min-width: 14rem; }
.grid-2 { display: grid; gap: 1.25rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 60em) { .grid-2 { grid-template-columns: 1fr; } }
