/* ═══════════════════════════════════════════════════════════════
   SGS QUILMES — Sistema de Gestión Social
   main.css — Design System completo
   Paleta institucional: #783883 (violeta Quilmes)
═══════════════════════════════════════════════════════════════ */

/* ── VARIABLES ─────────────────────────────────────────────── */
:root {
    /* Marca */
    --brand:          #5B3A8C;
    --brand-dark:     #4a2e73;
    --brand-darker:   #38245a;
    --brand-light:    #7B5AAC;
    --brand-pale:     #ede8f5;
    --brand-pale2:    #ddd4ee;
    --brand-gold:     #E8A020;
    --brand-gold-dark:#c48518;

    /* Neutros */
    --gray-50:        #f9fafb;
    --gray-100:       #f3f4f6;
    --gray-200:       #e5e7eb;
    --gray-300:       #d1d5db;
    --gray-400:       #9ca3af;
    --gray-500:       #6b7280;
    --gray-600:       #4b5563;
    --gray-700:       #374151;
    --gray-800:       #1f2937;
    --gray-900:       #111827;

    /* Semánticos */
    --success:        #16a34a;
    --success-bg:     #dcfce7;
    --warning:        #d97706;
    --warning-bg:     #fef3c7;
    --danger:         #dc2626;
    --danger-bg:      #fee2e2;
    --info:           #2563eb;
    --info-bg:        #dbeafe;

    /* Superficie */
    --bg:             #f4f2f8;
    --surface:        #ffffff;
    --surface-raised: #ffffff;
    --border:         #e5e7eb;
    --border-focus:   #5B3A8C;

    /* Texto */
    --text-primary:   #1f2937;
    --text-secondary: #6b7280;
    --text-muted:     #9ca3af;
    --text-inverse:   #ffffff;

    /* Sidebar */
    --sidebar-bg:     #2a1a4a;
    --sidebar-width:  240px;
    --sidebar-item-hover: rgba(255,255,255,0.08);
    --sidebar-item-active: rgba(255,255,255,0.15);
    --sidebar-text:   rgba(255,255,255,0.75);
    --sidebar-text-active: #ffffff;

    /* Topbar */
    --topbar-height:  56px;

    /* Sombras */
    --shadow-sm:      0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md:      0 4px 12px rgba(0,0,0,0.1), 0 2px 4px rgba(0,0,0,0.06);
    --shadow-lg:      0 12px 32px rgba(0,0,0,0.14), 0 4px 8px rgba(0,0,0,0.08);
    --shadow-brand:   0 4px 14px rgba(91,58,140,0.35);

    /* Radios */
    --radius-sm:      6px;
    --radius:         8px;
    --radius-md:      12px;
    --radius-lg:      16px;
    --radius-full:    9999px;

    /* Transición */
    --transition:     0.18s ease;
    --transition-md:  0.28s ease;
}

/* ── RESET & BASE ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; -webkit-text-size-adjust: 100%; }

body {
    font-family: 'DM Sans', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text-primary);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
    height: 100dvh;
}

a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-dark); }

/* ── SCREENS ────────────────────────────────────────────────── */
.screen { display: none; width: 100%; height: 100dvh; }
.screen.active { display: flex; }
.screen.hidden { display: none !important; }

/* ════════════════════════════════════════════════════════════
   LOGIN
════════════════════════════════════════════════════════════ */
#screen-login {
    align-items: center;
    justify-content: center;
    background: var(--brand-darker);
    position: relative;
    overflow: hidden;
}

.login-bg {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.login-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(60px);
    opacity: 0.45;
}
.orb-1 {
    width: 500px; height: 500px;
    background: radial-gradient(circle, #9b52a8, transparent);
    top: -150px; right: -100px;
    animation: orbFloat 8s ease-in-out infinite;
}
.orb-2 {
    width: 400px; height: 400px;
    background: radial-gradient(circle, #5c2866, transparent);
    bottom: -100px; left: -80px;
    animation: orbFloat 10s ease-in-out infinite reverse;
}
.orb-3 {
    width: 200px; height: 200px;
    background: radial-gradient(circle, #783883, transparent);
    top: 40%; left: 40%;
    animation: orbFloat 6s ease-in-out infinite 2s;
}

@keyframes orbFloat {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(20px, -30px) scale(1.05); }
}

.login-card {
    position: relative;
    z-index: 1;
    background: rgba(255,255,255,0.97);
    backdrop-filter: blur(20px);
    border-radius: var(--radius-lg);
    padding: 40px 36px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg), 0 0 0 1px rgba(255,255,255,0.1);
    animation: cardIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes cardIn {
    from { opacity: 0; transform: translateY(24px) scale(0.96); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.login-header { text-align: center; margin-bottom: 28px; }

.login-logo {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

.login-logo-emblem {
    width: 44px; height: 44px;
    background: var(--brand);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-brand);
}

.login-logo-text {
    display: flex;
    align-items: baseline;
    gap: 5px;
}

.logo-main {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--brand);
    letter-spacing: -0.5px;
}
.logo-sep {
    color: var(--gray-300);
    font-weight: 300;
}
.logo-sub {
    font-size: 1rem;
    font-weight: 500;
    color: var(--gray-600);
}

.login-header h1 {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}
.login-header p {
    font-size: 0.82rem;
    color: var(--text-muted);
}

.login-footer {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 20px;
}

/* ════════════════════════════════════════════════════════════
   APP LAYOUT
════════════════════════════════════════════════════════════ */
#screen-app {
    display: none;
    width: 100%;
    height: 100dvh;
    overflow: hidden;
}
#screen-app.active { display: flex; }

/* ── SIDEBAR ────────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    height: 100dvh;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: transform var(--transition-md);
    z-index: 200;
    flex-shrink: 0;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 14px 12px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-logo-icon {
    width: 34px; height: 34px;
    background: var(--brand);
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sidebar-logo-labels { display: flex; flex-direction: column; }
.sidebar-logo-title {
    font-size: 0.88rem;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: -0.2px;
    line-height: 1.2;
}
.sidebar-logo-sub {
    font-size: 0.7rem;
    color: var(--sidebar-text);
    line-height: 1.2;
}

/* Nav */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 12px 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 4px; }

.nav-label {
    display: block;
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255,255,255,0.35);
    padding: 12px 10px 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    color: var(--sidebar-text);
    font-size: 0.875rem;
    font-weight: 450;
    transition: background var(--transition), color var(--transition);
    cursor: pointer;
    position: relative;
}
.nav-item svg { flex-shrink: 0; opacity: 0.75; transition: opacity var(--transition); }
.nav-item:hover {
    background: var(--sidebar-item-hover);
    color: var(--sidebar-text-active);
}
.nav-item:hover svg { opacity: 1; }
.nav-item.active {
    background: var(--sidebar-item-active);
    color: var(--sidebar-text-active);
    font-weight: 600;
}
.nav-item.active svg { opacity: 1; }
.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0; top: 20%; bottom: 20%;
    width: 3px;
    background: var(--brand-light);
    border-radius: 0 3px 3px 0;
}

.nav-badge {
    margin-left: auto;
    background: var(--brand);
    color: white;
    font-size: 0.68rem;
    font-weight: 600;
    padding: 1px 7px;
    border-radius: var(--radius-full);
    min-width: 20px;
    text-align: center;
    display: none;
}
.nav-badge:not(:empty) { display: inline-block; }

/* Sidebar user */
.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.user-info { flex: 1; min-width: 0; }
.user-name {
    font-size: 0.82rem;
    font-weight: 600;
    color: white;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.user-role {
    font-size: 0.7rem;
    color: var(--sidebar-text);
    text-transform: capitalize;
}

/* ── OVERLAY MOBILE ─────────────────────────────────────────── */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 150;
    backdrop-filter: blur(2px);
}
.sidebar-overlay.visible { display: block; }

/* ── TOPBAR ─────────────────────────────────────────────────── */
.app-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    height: 100dvh;
    overflow: hidden;
}

.topbar {
    height: var(--topbar-height);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 16px;
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
}

.btn-menu { display: none; }

.topbar-breadcrumb { flex: 1; }
.topbar-module {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

.topbar-right { display: flex; align-items: center; gap: 8px; }

.topbar-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 10px 4px 4px;
    background: var(--gray-100);
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
}

/* ── MODULE CONTENT ─────────────────────────────────────────── */
.module-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.module-content::-webkit-scrollbar { width: 6px; }
.module-content::-webkit-scrollbar-track { background: transparent; }
.module-content::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 4px; }
.module-content::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }

/* ════════════════════════════════════════════════════════════
   COMPONENTES BASE
════════════════════════════════════════════════════════════ */

/* ── BOTONES ────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 8px 18px;
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background var(--transition), color var(--transition), border-color var(--transition), box-shadow var(--transition), transform 0.1s;
    white-space: nowrap;
    line-height: 1.4;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary {
    background: var(--brand);
    color: white;
    border-color: var(--brand);
    box-shadow: var(--shadow-brand);
}
.btn-primary:hover:not(:disabled) { background: var(--brand-dark); border-color: var(--brand-dark); }

.btn-secondary {
    background: var(--surface);
    color: var(--text-primary);
    border-color: var(--border);
    box-shadow: var(--shadow-sm);
}
.btn-secondary:hover:not(:disabled) { background: var(--gray-50); border-color: var(--gray-300); }

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border-color: transparent;
}
.btn-ghost:hover:not(:disabled) { background: var(--gray-100); color: var(--text-primary); }

.btn-danger {
    background: var(--danger);
    color: white;
    border-color: var(--danger);
}
.btn-danger:hover:not(:disabled) { background: #b91c1c; }

.btn-sm { padding: 5px 12px; font-size: 0.8rem; }
.btn-lg { padding: 11px 24px; font-size: 0.95rem; }
.btn-full { width: 100%; }
.btn-icon-label { gap: 6px; }

/* Icon button */
.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px; height: 34px;
    border-radius: var(--radius);
    border: none;
    background: transparent;
    color: var(--sidebar-text);
    cursor: pointer;
    transition: background var(--transition);
    flex-shrink: 0;
}
.btn-icon:hover { background: rgba(255,255,255,0.1); }
.btn-icon-ghost { color: var(--text-secondary); }
.btn-icon-ghost:hover { background: var(--gray-100); color: var(--text-primary); }

.btn-toggle-pass {
    position: absolute;
    right: 10px; top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: color var(--transition);
}
.btn-toggle-pass:hover { color: var(--text-secondary); }

/* ── FORMULARIOS ────────────────────────────────────────────── */
.field-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-bottom: 16px;
}
.field-group:last-of-type { margin-bottom: 20px; }

label {
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-secondary);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="tel"],
input[type="date"],
input[type="search"],
select,
textarea {
    width: 100%;
    padding: 9px 13px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 0.875rem;
    color: var(--text-primary);
    background: var(--surface);
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
    line-height: 1.5;
}
input:focus, select:focus, textarea:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(120,56,131,0.12);
}
input::placeholder, textarea::placeholder { color: var(--text-muted); }
textarea { resize: vertical; min-height: 80px; }
select { cursor: pointer; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpolyline points='6,9 12,15 18,9'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }

input[readonly],
textarea[readonly] {
    background: var(--gray-50);
    border-color: transparent;
    color: var(--text-primary);
    cursor: default;
    pointer-events: none;
}
input[readonly]:focus,
textarea[readonly]:focus {
    border-color: transparent;
    box-shadow: none;
}
select[disabled] {
    background-color: var(--gray-50);
    border-color: transparent;
    color: var(--text-primary);
    cursor: default;
    opacity: 1;
    pointer-events: none;
    -webkit-appearance: none;
    background-image: none;
}

.input-with-toggle { position: relative; }
.input-with-toggle input { padding-right: 40px; }

/* Field row (inline fields) */
.field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}
.field-row-3 { grid-template-columns: 1fr 1fr 1fr; }

/* ── AVATARES ───────────────────────────────────────────────── */
.user-avatar {
    width: 32px; height: 32px;
    border-radius: var(--radius-full);
    background: var(--brand);
    color: white;
    font-size: 0.72rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.user-avatar.sm { width: 26px; height: 26px; font-size: 0.65rem; }
.user-avatar.lg { width: 44px; height: 44px; font-size: 0.9rem; }

/* ── CARDS ──────────────────────────────────────────────────── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.card-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}
.card-body { padding: 20px; }
.card-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    background: var(--gray-50);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Stat card */
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: box-shadow var(--transition), transform var(--transition-md);
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

.stat-label {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.stat-value {
    font-size: 1.9rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -1px;
    line-height: 1;
}
.stat-sub {
    font-size: 0.78rem;
    color: var(--text-muted);
}
.stat-icon {
    width: 38px; height: 38px;
    border-radius: var(--radius);
    background: var(--brand-pale);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--brand);
    align-self: flex-start;
}

/* ── PAGE HEADER ────────────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}
.page-header-left { display: flex; flex-direction: column; gap: 3px; }
.page-title {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.3px;
}
.page-subtitle {
    font-size: 0.83rem;
    color: var(--text-muted);
}
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ── TABLAS ─────────────────────────────────────────────────── */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    font-size: 0.86rem;
}
thead { background: var(--gray-50); }
th {
    padding: 10px 14px;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
td {
    padding: 11px 14px;
    border-bottom: 1px solid var(--gray-100);
    color: var(--text-primary);
    vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--gray-50); }

.table-actions { display: flex; gap: 6px; align-items: center; }

/* ── BADGES / CHIPS ─────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 9px;
    border-radius: var(--radius-full);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    white-space: nowrap;
}
.badge-brand   { background: var(--brand-pale); color: var(--brand); }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger  { background: var(--danger-bg);  color: var(--danger); }
.badge-info    { background: var(--info-bg);    color: var(--info); }
.badge-gray    { background: var(--gray-100);   color: var(--gray-600); }

/* ── ALERTS ─────────────────────────────────────────────────── */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 0.84rem;
    line-height: 1.45;
}
.alert-error   { background: var(--danger-bg); color: #991b1b; border: 1px solid #fca5a5; }
.alert-success { background: var(--success-bg); color: #166534; border: 1px solid #86efac; }
.alert-warning { background: var(--warning-bg); color: #92400e; border: 1px solid #fde68a; }
.alert-info    { background: var(--info-bg); color: #1e40af; border: 1px solid #93c5fd; }

/* ── SEARCH BAR ─────────────────────────────────────────────── */
.search-bar {
    position: relative;
    flex: 1;
    min-width: 200px;
    max-width: 340px;
}
.search-bar svg {
    position: absolute;
    left: 11px; top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}
.search-bar input {
    padding-left: 36px;
    background: var(--gray-50);
    border-color: var(--border);
}

/* ── FILTROS ────────────────────────────────────────────────── */
.filters-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

/* ── TABS ───────────────────────────────────────────────────── */
.tabs {
    display: flex;
    gap: 2px;
    border-bottom: 2px solid var(--border);
    margin-bottom: 20px;
    overflow-x: auto;
    flex-wrap: nowrap;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}
.tabs::-webkit-scrollbar { display: none; }
.tab-item {
    padding: 9px 18px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color var(--transition), border-color var(--transition);
    white-space: nowrap;
}
.tab-item:hover { color: var(--brand); }
.tab-item.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }

/* ── GRIDS ──────────────────────────────────────────────────── */
.grid-stats {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}
@media (max-width: 1100px) { .grid-stats { grid-template-columns: repeat(3, 1fr); } }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }

/* ── EMPTY STATE ────────────────────────────────────────────── */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
    gap: 12px;
    color: var(--text-muted);
}
.empty-state svg { opacity: 0.35; }
.empty-state h3 { font-size: 1rem; font-weight: 600; color: var(--text-secondary); }
.empty-state p { font-size: 0.84rem; max-width: 300px; }

/* ── LOADING ────────────────────────────────────────────────── */
.page-loader {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 200px;
}
.spinner {
    width: 28px; height: 28px;
    border: 2.5px solid var(--gray-200);
    border-top-color: var(--brand);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── MODAL ──────────────────────────────────────────────────── */
.modal-container {
    position: fixed;
    inset: 0;
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal-container.hidden { display: none; }

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(3px);
    animation: fadeIn 0.18s ease;
}

.modal-box {
    position: relative;
    z-index: 1;
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 560px;
    max-height: 90dvh;
    display: flex;
    flex-direction: column;
    animation: modalIn 0.22s cubic-bezier(0.34, 1.4, 0.64, 1);
    overflow: hidden;
}
.modal-box.modal-lg  { max-width: 780px; }
.modal-box.modal-sm  { max-width: 400px; }
.modal-box.modal-xl  { max-width: 1100px; width: calc(100vw - 40px); }

.submodal-container {
    position: fixed;
    inset: 0;
    z-index: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.submodal-container.hidden { display: none; }

.submodal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.35);
    animation: fadeIn 0.15s ease;
}

.submodal-box {
    position: relative;
    z-index: 1;
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 680px;
    max-height: 80dvh;
    display: flex;
    flex-direction: column;
    animation: modalIn 0.18s cubic-bezier(0.34, 1.4, 0.64, 1);
    overflow: hidden;
}

@keyframes modalIn {
    from { opacity: 0; transform: translateY(16px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.modal-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}
.modal-body {
    padding: 20px;
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1;
}
.modal-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    flex-shrink: 0;
    background: var(--gray-50);
}

/* ── TOASTS ─────────────────────────────────────────────────── */
.toast-container {
    position: fixed;
    bottom: 24px; right: 24px;
    z-index: 999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-radius: var(--radius);
    background: var(--gray-900);
    color: white;
    font-size: 0.85rem;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    pointer-events: all;
    animation: toastIn 0.25s cubic-bezier(0.34, 1.4, 0.64, 1);
    max-width: 340px;
}
.toast.removing { animation: toastOut 0.2s ease forwards; }
.toast-success { background: #166534; }
.toast-error   { background: #991b1b; }
.toast-warning { background: #92400e; }
.toast-info    { background: var(--brand-dark); }

@keyframes toastIn {
    from { opacity: 0; transform: translateX(24px); }
    to   { opacity: 1; transform: translateX(0); }
}
@keyframes toastOut {
    from { opacity: 1; transform: translateX(0); }
    to   { opacity: 0; transform: translateX(24px); }
}

/* ── ESTADOS ────────────────────────────────────────────────── */
.estado-activo    { color: var(--success); }
.estado-inactivo  { color: var(--danger); }
.estado-pendiente { color: var(--warning); }

/* ── UTILIDADES ─────────────────────────────────────────────── */
.hidden    { display: none !important; }
.invisible { visibility: hidden; }
.truncate  { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mono      { font-family: 'DM Mono', monospace; font-size: 0.82rem; }
.text-muted   { color: var(--text-muted); }
.text-brand   { color: var(--brand); }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-warning { color: var(--warning); }
.fw-600 { font-weight: 600; }
.mb-0  { margin-bottom: 0; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.gap-8  { gap: 8px; }
.flex   { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.align-center { align-items: center; }
.w-full { width: 100%; }

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ════════════════════════════════════════════════════════════
   MÓDULO: DASHBOARD
════════════════════════════════════════════════════════════ */
.dashboard-welcome {
    background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
    border-radius: var(--radius-md);
    padding: 24px 28px;
    color: white;
    margin-bottom: 24px;
    position: relative;
    overflow: hidden;
}
.dashboard-welcome::after {
    content: '';
    position: absolute;
    right: -30px; top: -40px;
    width: 180px; height: 180px;
    border-radius: 50%;
    background: rgba(255,255,255,0.07);
}
.dashboard-welcome::before {
    content: '';
    position: absolute;
    right: 60px; bottom: -50px;
    width: 120px; height: 120px;
    border-radius: 50%;
    background: rgba(255,255,255,0.05);
}
.welcome-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 4px;
    position: relative;
}
.welcome-sub {
    font-size: 0.85rem;
    opacity: 0.8;
    position: relative;
}

/* ════════════════════════════════════════════════════════════
   MÓDULO: ESPACIOS — Detail panel
════════════════════════════════════════════════════════════ */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 20px;
}
.detail-item { display: flex; flex-direction: column; gap: 2px; padding: 8px 0; border-bottom: 1px solid var(--gray-100); }
.detail-item:last-child { border-bottom: none; }
.detail-label { font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); }
.detail-value { font-size: 0.88rem; color: var(--text-primary); }

/* ════════════════════════════════════════════════════════════
   MÓDULO: MAPA
════════════════════════════════════════════════════════════ */
.map-wrapper {
    position: relative;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}
#map-container {
    width: 100%;
    height: calc(100dvh - var(--topbar-height) - 48px - 80px);
    min-height: 400px;
    background: var(--gray-100);
}

/* ════════════════════════════════════════════════════════════
   RESPONSIVE — MOBILE
════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
    body { overflow: auto; }

    .sidebar {
        position: fixed;
        left: 0; top: 0;
        height: 100dvh;
        transform: translateX(-100%);
        z-index: 200;
        transition: transform var(--transition-md);
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay.visible { display: block; }

    .btn-menu { display: flex; }
    .btn-sidebar-close { display: flex; }

    .app-main { width: 100%; }

    .module-content { padding: 16px; }

    .grid-stats { grid-template-columns: 1fr 1fr; gap: 12px; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .field-row, .field-row-3 { grid-template-columns: 1fr; }

    .page-header { flex-direction: column; align-items: flex-start; }
    .page-actions { width: 100%; }

    .filters-bar { gap: 8px; }
    .search-bar { max-width: 100%; }

    .modal-box { max-width: 100%; margin: 0; border-radius: var(--radius-md) var(--radius-md) 0 0; }
    .modal-container { align-items: flex-end; padding: 0; }

    .toast-container { bottom: 16px; right: 12px; left: 12px; }
    .toast { max-width: 100%; }

    .table-wrapper { font-size: 0.82rem; }

    #map-container { height: calc(100dvh - var(--topbar-height) - 130px); }
}

@media (max-width: 480px) {
    .grid-stats { grid-template-columns: 1fr; }
    .login-card { padding: 28px 20px; margin: 16px; }
    .stat-value { font-size: 1.6rem; }
}

@media (min-width: 769px) {
    .btn-sidebar-close { display: none; }
}
