/* ============================================
   Promotora Inmobiliaria Ami Hogar
   Sistema de Gestión Integral
   Estilos Kickstarter-Style
   ============================================ */

/* ---------- Reset & Base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    /* Ronda 14 — reskin "SaaS navy": --primary pasa a ser azul (marca/acción), reemplazando el
       naranja industrial de la Ronda 12. --success se mantiene como token dedicado y separado
       (verde=correcto/pagado/al corriente) — no vuelve a fusionarse con --primary, mismo
       principio que ya protegía el significado semántico de color desde la Ronda 12. */
    --primary: #2563EB;
    --primary-dark: #1D4ED8;
    --primary-light: #DBEAFE;
    --success: #16A34A;
    --success-dark: #15803D;
    --success-light: #DCFCE7;
    --danger: #e74c3c;
    --danger-dark: #c0392b;
    --danger-light: #fdeaea;
    --warning: #f39c12;
    --warning-dark: #8a6415;
    --warning-light: #fef5e7;
    --info: #3498db;
    --info-dark: #1a5276;
    --info-light: #eaf2fa;
    --dark: #111827;
    --carbon: #111C2E;
    --gray-900: #1e293b;
    --gray-700: #475569;
    --gray-500: #64748b;
    --gray-400: #94a3b8;
    --gray-300: #cbd5e1;
    --gray-200: #e2e8f0;
    --gray-100: #f1f5f9;
    --gray-50: #f8fafc;
    --white: #fff;
    --bg: #f5f5f5;
    --card-shadow: 0 1px 2px rgba(16,24,40,.04), 0 1px 3px rgba(16,24,40,.07);
    --card-shadow-hover: 0 4px 8px rgba(16,24,40,.06), 0 12px 24px rgba(16,24,40,.1);
    --radius: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;
    --nav-height: 60px;
    --sidebar-width: 240px;
    --transition: .2s ease;
    --font: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    --font-heading: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
}

html { font-size: 14px; }
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--dark);
    line-height: 1.55;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

/* Accessible focus rings */
a:focus-visible, button:focus-visible, .btn:focus-visible,
input:focus-visible, select:focus-visible, textarea:focus-visible,
[tabindex]:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* ---------- Utilities ---------- */
.hidden { display: none !important; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--gray-500); }
.text-danger { color: var(--danger-dark); }
.text-success { color: var(--success-dark); }
.text-warning { color: var(--warning-dark); }
.text-info { color: var(--info-dark); }
.text-sm { font-size: .85rem; }
.text-lg { font-size: 1.15rem; }
.text-xl { font-size: 1.4rem; }
.text-bold { font-weight: 600; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.ml-auto { margin-left: auto; }
.gap-1 { gap: .5rem; }
.gap-2 { gap: 1rem; }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }
.w-full { width: 100%; }
.overflow-auto { overflow-x: auto; }

/* ---------- Login Screen ---------- */
.login-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--dark) 0%, #16213e 50%, #0f3460 100%);
    padding: 1rem;
}
.login-container {
    background: var(--white);
    border-radius: var(--radius-xl);
    padding: 2.5rem 2rem;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 24px 64px rgba(0,0,0,.32);
    border: 1px solid rgba(255,255,255,.08);
}
.login-logo { text-align: center; margin-bottom: 2rem; }
.logo-icon { font-size: 3rem; margin-bottom: .5rem; }
.login-logo h1 { font-size: 2rem; color: var(--dark); letter-spacing: 2px; }
.login-subtitle { color: var(--gray-500); font-size: .9rem; margin-top: .25rem; }
.login-form .form-group { margin-bottom: 1.25rem; }
.login-form label { display: block; margin-bottom: .35rem; font-weight: 600; color: var(--gray-700); font-size: .85rem; }
.login-form input {
    width: 100%; padding: .7rem .9rem;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: .95rem;
    transition: border var(--transition), box-shadow var(--transition);
}
.login-form input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.password-field { position: relative; }
.password-field input { padding-right: 2.6rem; }
.password-toggle {
    position: absolute; right: .4rem; top: 50%; transform: translateY(-50%);
    background: none; border: none; cursor: pointer; font-size: 1.1rem; padding: .3rem .4rem;
    line-height: 1; opacity: .55; border-radius: var(--radius);
}
.password-toggle:hover { opacity: 1; }
.role-autocomplete { position: relative; }
.role-suggestions {
    position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 20;
    background: var(--white); border: 1.5px solid var(--gray-200); border-radius: var(--radius);
    box-shadow: var(--card-shadow-hover); max-height: 220px; overflow-y: auto;
}
.role-suggestion-item {
    padding: .6rem .9rem; cursor: pointer; font-size: .9rem; color: var(--dark);
}
.role-suggestion-item:hover, .role-suggestion-item.active { background: var(--primary-light); }
.role-suggestion-empty { padding: .6rem .9rem; font-size: .85rem; color: var(--gray-500); }
.login-error {
    margin-top: 1rem; padding: .6rem; text-align: center;
    background: var(--danger-light); color: var(--danger-dark);
    border-radius: var(--radius); font-size: .85rem;
}
.login-footer {
    margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--gray-100);
    text-align: center; color: var(--gray-500); font-size: .8rem;
}
.login-footer p { font-weight: 600; margin-bottom: .35rem; color: var(--gray-700); }
.login-footer small { line-height: 1.8; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    padding: .55rem 1.2rem;
    border: none; border-radius: var(--radius);
    font-size: .85rem; font-weight: 600;
    cursor: pointer; transition: all var(--transition);
    white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled, .btn.disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--primary); color: var(--white); box-shadow: 0 1px 2px rgba(16,24,40,.08); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: var(--danger); color: var(--white); box-shadow: 0 1px 2px rgba(16,24,40,.08); }
.btn-danger:hover { background: var(--danger-dark); }
.btn-warning { background: var(--warning); color: var(--dark); box-shadow: 0 1px 2px rgba(16,24,40,.08); }
.btn-info { background: var(--info); color: var(--white); box-shadow: 0 1px 2px rgba(16,24,40,.08); }
.btn-outline {
    background: transparent; border: 1.5px solid var(--gray-300); color: var(--gray-700);
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary-dark); background: var(--primary-light); }
.btn-sm { padding: .35rem .8rem; font-size: .78rem; }
.btn-block { width: 100%; }
.btn-group { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ---------- Top Navigation ---------- */
/* Ronda 12 — chrome industrial: top-nav en negro carbón (igual que el sidebar), con una línea
   de acento naranja debajo (detalle de "franja de seguridad"). Todo el texto/ícono de esta barra
   pasa a un tono claro para mantener contraste sobre el fondo oscuro. */
.top-nav {
    position: fixed; top: 0; left: 0; right: 0; z-index: 100;
    height: var(--nav-height);
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    box-shadow: 0 1px 2px rgba(16,24,40,.04);
    display: flex; align-items: center;
    padding: 0 1rem;
}
.nav-left { display: flex; align-items: center; gap: .75rem; min-width: 180px; }
.nav-center { flex: 1; text-align: center; overflow: hidden; }
.nav-center h2 { font-family: var(--font-heading); font-size: 1.05rem; font-weight: 600; color: var(--dark); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-right { display: flex; align-items: center; gap: .75rem; min-width: 180px; justify-content: flex-end; }

.menu-toggle {
    display: none; background: none; border: none; cursor: pointer;
    width: 28px; height: 20px; position: relative; padding: 0;
}
.menu-toggle span {
    display: block; height: 2px; background: var(--dark);
    border-radius: 2px; transition: var(--transition);
    position: absolute; left: 0; right: 0;
}
.menu-toggle span:nth-child(1) { top: 0; }
.menu-toggle span:nth-child(2) { top: 9px; }
.menu-toggle span:nth-child(3) { top: 18px; }

.nav-brand { display: flex; align-items: center; gap: .5rem; }
.brand-icon { font-size: 1.4rem; }
.brand-name { font-family: var(--font-heading); font-size: 1.15rem; font-weight: 700; color: var(--dark); }

.icon-btn {
    background: none; border: none; cursor: pointer; position: relative;
    font-size: 1.1rem; padding: .3rem; border-radius: 50%;
    transition: background var(--transition);
    color: var(--gray-700);
    display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: rgba(0,0,0,.06); }

.badge {
    position: absolute; top: -4px; right: -4px;
    background: var(--danger); color: var(--white);
    font-size: .65rem; font-weight: 700;
    min-width: 16px; height: 16px;
    border-radius: 8px; display: flex; align-items: center; justify-content: center;
    padding: 0 4px;
}

.user-btn {
    display: flex; align-items: center; gap: .5rem;
    background: none; border: none; cursor: pointer; padding: .25rem;
    border-radius: var(--radius); transition: background var(--transition);
}
.user-btn:hover { background: rgba(0,0,0,.06); }
.avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--primary); color: var(--white);
    display: flex; align-items: center; justify-content: center;
    font-size: .7rem; font-weight: 700;
}
.user-name-block { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.15; }
.user-name-text { font-size: .95rem; font-weight: 700; color: var(--dark); text-transform: uppercase; letter-spacing: .02em; }
.user-role-text { font-size: .72rem; font-weight: 500; color: var(--gray-500); }

/* Dropdowns */
.dropdown {
    position: absolute; top: 100%; right: 0;
    background: var(--white); border-radius: var(--radius);
    box-shadow: var(--card-shadow-hover); border: 1px solid var(--gray-200);
    min-width: 220px; max-width: calc(100vw - 2rem); z-index: 200; overflow: hidden;
    margin-top: .25rem;
}
.nav-notifications, .nav-user { position: relative; }
.dropdown-header {
    padding: .75rem 1rem; font-weight: 600; font-size: .85rem;
    border-bottom: 1px solid var(--gray-100); color: var(--gray-700);
}
#user-role-display.dropdown-header { padding: .9rem 1rem; }
.user-dropdown-name { font-family: var(--font-heading); font-size: 1.05rem; font-weight: 700; color: var(--dark); line-height: 1.3; }
.user-dropdown-role { font-size: .78rem; color: var(--gray-500); margin-top: .15rem; }
.user-dropdown-role strong { color: var(--primary-dark); }
.dropdown-body { max-height: 300px; overflow-y: auto; }
.dropdown-item {
    display: block; width: 100%; text-align: left;
    padding: .6rem 1rem; border: none; background: none;
    font-size: .85rem; cursor: pointer; color: var(--dark);
    transition: background var(--transition);
}
.dropdown-item:hover { background: var(--gray-50); }
.notif-item { padding: .75rem 1rem; border-bottom: 1px solid var(--gray-100); font-size: .82rem; }
.notif-item.unread { background: var(--primary-light); }
.notif-item .notif-time { font-size: .72rem; color: var(--gray-500); margin-top: .2rem; }
.notif-empty { padding: 1.5rem; text-align: center; color: var(--gray-500); font-size: .85rem; }

/* ---------- Sidebar ---------- */
/* Ronda 14 — sidebar en navy oscuro, texto claro por defecto; el item activo es un bloque sólido
   en el color de marca (--primary) con texto blanco, en vez del "chip" pálido de la Ronda 12.
   Nombres de módulo en case normal (ya no mayúsculas), solo el rótulo de sección sigue en
   mayúsculas pequeñas (patrón estándar de "eyebrow label"). */
.sidebar {
    position: fixed; top: var(--nav-height); left: 0; bottom: 0;
    width: var(--sidebar-width); background: var(--carbon);
    border-right: 1px solid rgba(255,255,255,.08);
    overflow-y: auto; z-index: 90;
    transition: transform var(--transition);
    padding: .5rem .5rem;
}
.nav-menu { list-style: none; }
.nav-menu li { }
.nav-menu .nav-section {
    padding: .75rem .75rem .35rem;
    font-size: .68rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: .5px;
    color: var(--gray-400);
}
.nav-menu .nav-item {
    display: flex; align-items: center; gap: .6rem;
    padding: .6rem .75rem;
    font-family: var(--font-heading);
    font-size: .85rem; font-weight: 500; color: var(--gray-300);
    cursor: pointer; transition: all var(--transition);
    border-radius: 8px;
}
.nav-menu .nav-item:hover {
    background: rgba(255,255,255,.08); color: var(--white);
}
.nav-menu .nav-item.active {
    background: var(--primary);
    color: var(--white);
    font-weight: 600;
}
.nav-menu .nav-item .nav-icon { font-size: 1rem; width: 22px; text-align: center; display: flex; align-items: center; justify-content: center; }
.nav-menu .nav-item .nav-item-label { flex: 1; }
.nav-menu .nav-item .nav-badge {
    margin-left: auto; background: var(--danger);
    color: var(--white); font-size: .65rem; font-weight: 700;
    padding: .1rem .45rem; border-radius: 10px;
}
/* ---------- Menú lateral: submódulos como acordeón desplegable ---------- */
.nav-menu .nav-item .nav-chevron {
    font-size: 1.1rem; line-height: 1; margin-left: auto;
    transition: transform var(--transition); color: var(--gray-500);
}
.nav-menu .nav-item .nav-chevron.open { transform: rotate(90deg); color: inherit; }
.nav-submenu {
    list-style: none; max-height: 0; overflow: hidden;
    transition: max-height var(--transition);
}
.nav-submenu.open { max-height: 600px; }
.nav-submenu .nav-subitem {
    padding: .5rem .75rem .5rem 2.9rem;
    font-family: var(--font); font-size: .78rem; color: var(--gray-400);
    cursor: pointer; border-left: 3px solid transparent;
    transition: all var(--transition);
}
.nav-submenu .nav-subitem:hover { background: rgba(255,255,255,.06); color: var(--white); }
.nav-submenu .nav-subitem.active {
    background: rgba(37,99,235,.28); color: var(--white);
    border-left-color: var(--primary); font-weight: 600;
}

/* ---------- Content Area ---------- */
.content {
    margin-left: var(--sidebar-width);
    margin-top: var(--nav-height);
    padding: 1.5rem;
    min-height: calc(100vh - var(--nav-height));
    transition: margin var(--transition);
}

/* ---------- Cards ---------- */
.card {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--card-shadow);
    overflow: hidden;
    transition: box-shadow var(--transition);
}
.card:hover { box-shadow: var(--card-shadow-hover); }
.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--gray-100);
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: .5rem;
}
.card-header h3 { font-family: var(--font-heading); font-size: .95rem; font-weight: 600; }
.card-body { padding: 1.25rem; }
.card-footer {
    padding: .75rem 1.25rem;
    border-top: 1px solid var(--gray-100);
    background: var(--gray-50);
}

/* Stat Cards */
.stat-card {
    background: var(--white); border-radius: var(--radius-lg);
    box-shadow: var(--card-shadow); padding: 1.25rem;
    display: flex; flex-direction: column; gap: .25rem;
    transition: box-shadow var(--transition), transform var(--transition);
    cursor: default;
    border-left: 4px solid var(--primary);
    position: relative;
}
/* Ronda 12 — icono acento en la esquina de las tarjetas KPI del Tablero (tarjeta visual, no
   solo texto/números). El color se fija en línea por tarjeta para que coincida con su acento. */
.stat-card .stat-icon { position: absolute; top: 1.1rem; right: 1.1rem; width: 26px; height: 26px; opacity: .5; }
.stat-card .stat-icon svg { width: 100%; height: 100%; }
.stat-card:hover { box-shadow: var(--card-shadow-hover); transform: translateY(-2px); }
.stat-card .stat-label { font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; color: var(--gray-500); }
.stat-card .stat-value { font-family: var(--font-heading); font-size: 1.6rem; font-weight: 700; color: var(--dark); }
.stat-card .stat-detail { font-size: .78rem; color: var(--gray-500); }
.stat-card.accent-danger { border-left-color: var(--danger); }
.stat-card.accent-warning { border-left-color: var(--warning); }
.stat-card.accent-info { border-left-color: var(--info); }
.stat-card.accent-primary { border-left-color: var(--primary); }

/* ---------- Tables ---------- */
.table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table {
    width: 100%; border-collapse: collapse; font-size: .85rem;
}
thead { background: var(--gray-50); }
th {
    padding: .7rem .75rem; text-align: left;
    font-weight: 600; color: var(--gray-700);
    border-bottom: 2px solid var(--gray-200);
    white-space: nowrap;
}
td {
    padding: .65rem .75rem;
    border-bottom: 1px solid var(--gray-100);
    vertical-align: middle;
}
tbody tr { transition: background var(--transition); }
tbody tr:hover { background: var(--gray-50); }
tbody tr.row-highlight { background: var(--warning-light); }

/* ---------- Forms ---------- */
.form-group { margin-bottom: 1rem; }
.form-group label {
    display: block; margin-bottom: .3rem;
    font-weight: 600; font-size: .82rem; color: var(--gray-700);
}
.form-group label .required { color: var(--danger-dark); }
.form-control {
    width: 100%; padding: .55rem .75rem;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: .85rem; font-family: var(--font);
    transition: border var(--transition), box-shadow var(--transition);
    background: var(--white);
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-row { display: flex; gap: 1rem; }
.form-row .form-group { flex: 1; }
.form-hint { font-size: .75rem; color: var(--gray-500); margin-top: .2rem; }
.form-error { font-size: .75rem; color: var(--danger-dark); margin-top: .2rem; }
.form-inline { display: flex; align-items: center; gap: .5rem; }

.checkbox-group { display: flex; align-items: center; gap: .4rem; }
.checkbox-group input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--primary); }

/* ---------- Tags / Status Badges ---------- */
.tag {
    display: inline-flex; align-items: center; gap: .25rem;
    padding: .2rem .6rem; border-radius: 20px;
    font-size: .72rem; font-weight: 600; white-space: nowrap;
}
.tag-success { background: var(--success-light); color: var(--success-dark); }
.tag-danger { background: var(--danger-light); color: var(--danger-dark); }
.tag-warning { background: var(--warning-light); color: var(--warning-dark); }
.tag-info { background: var(--info-light); color: var(--info-dark); }
.tag-neutral { background: var(--gray-100); color: var(--gray-700); }

/* Category tags */
.cat-tag {
    display: inline-flex; align-items: center; gap: .3rem;
    padding: .25rem .65rem; border-radius: var(--radius);
    font-size: .75rem; font-weight: 600; cursor: pointer;
    border: 2px solid transparent; transition: all var(--transition);
}
.cat-tag.selected { border-color: var(--dark); }
.cat-lote { background: #fde8d0; color: #8b4513; }
.cat-general { background: #d4edda; color: #155724; }
.cat-urbanizacion { background: #d1ecf1; color: #0c5460; }
.cat-maquinaria { background: #e2d9f3; color: #563d7c; }
.cat-otro { background: var(--gray-100); color: var(--gray-700); }

/* ---------- Progress Bars ---------- */
.progress-bar {
    width: 100%; height: 8px;
    background: var(--gray-200); border-radius: 4px;
    overflow: hidden;
}
.progress-bar .fill {
    height: 100%; border-radius: 4px;
    transition: width .4s ease;
}
.progress-bar .fill.green { background: var(--success); }
.progress-bar .fill.yellow { background: var(--warning); }
.progress-bar .fill.red { background: var(--danger); }
.progress-bar .fill.blue { background: var(--info); }
.progress-bar-sm { display: inline-block; width: 60px; height: 6px; background: var(--gray-200); border-radius: 3px; overflow: hidden; vertical-align: middle; margin-right: .3rem; }
.progress-bar-sm > div { height: 100%; border-radius: 3px; }

/* Cost comparison bar */
.cost-compare {
    display: flex; align-items: center; gap: .5rem; font-size: .8rem;
}
.cost-bar {
    flex: 1; height: 20px; background: var(--gray-200);
    border-radius: 4px; overflow: hidden; position: relative;
}
.cost-bar .cost-fill {
    height: 100%; border-radius: 4px;
    transition: width .5s ease;
    display: flex; align-items: center; justify-content: flex-end;
    padding-right: .4rem; font-size: .7rem; font-weight: 600; color: var(--white);
}

/* ---------- Tabs ---------- */
.tabs {
    display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: 1.25rem;
    padding: .4rem; background: var(--gray-50); border-radius: 10px;
}
.tab-btn {
    padding: .5rem 1rem; border: 1px solid var(--gray-200); background: var(--white);
    font-size: .82rem; font-weight: 500; color: var(--gray-700);
    cursor: pointer; white-space: nowrap; border-radius: 8px;
    transition: all var(--transition);
}
.tab-btn:hover { color: var(--primary-dark); border-color: var(--primary); background: var(--primary-light); }
.tab-btn.active {
    color: var(--white); font-weight: 600;
    background: var(--primary); border-color: var(--primary);
}
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ---------- Search & Filters ---------- */
.search-bar {
    display: flex; align-items: center; gap: .5rem;
    padding: .5rem .75rem; background: var(--gray-50);
    border: 1.5px solid var(--gray-200); border-radius: var(--radius);
    max-width: 320px;
    transition: border var(--transition);
}
.search-bar:focus-within { border-color: var(--primary); }
.search-bar input {
    flex: 1; border: none; background: none; outline: none;
    font-size: .85rem; font-family: var(--font);
}
.filters-row {
    display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
    margin-bottom: 1rem;
}

/* ---------- Alerts ---------- */
.alert {
    padding: .75rem 1rem; border-radius: var(--radius);
    font-size: .85rem; margin-bottom: 1rem;
    display: flex; align-items: flex-start; gap: .5rem;
}
.alert-icon { font-size: 1rem; flex-shrink: 0; }
.alert-success { background: var(--success-light); color: var(--success-dark); border-left: 4px solid var(--success); }
.alert-danger { background: var(--danger-light); color: var(--danger-dark); border-left: 4px solid var(--danger); }
.alert-warning { background: var(--warning-light); color: #856404; border-left: 4px solid var(--warning); }
.alert-info { background: var(--info-light); color: #004085; border-left: 4px solid var(--info); }

/* ---------- Modal ---------- */
.modal-overlay {
    position: fixed; inset: 0; z-index: 500;
    background: rgba(0,0,0,.5);
    display: flex; align-items: center; justify-content: center;
    padding: 1rem;
    backdrop-filter: blur(2px);
}
.modal {
    background: var(--white); border-radius: var(--radius-lg);
    width: 100%; max-width: 640px; max-height: 90vh;
    display: flex; flex-direction: column;
    box-shadow: 0 24px 64px rgba(0,0,0,.24);
}
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 1rem 1.25rem; border-bottom: 1px solid var(--gray-100);
    gap: .75rem;
}
.modal-header h3 { font-family: var(--font-heading); font-size: 1.05rem; font-weight: 600; }
.modal-close {
    background: none; border: none; font-size: 1.5rem;
    cursor: pointer; color: var(--gray-500); line-height: 1;
    padding: 0 .25rem; flex-shrink: 0;
}
.modal-close:hover { color: var(--dark); }
.modal-body { padding: 1.25rem; overflow-y: auto; flex: 1; }
.modal-footer {
    padding: .75rem 1.25rem; border-top: 1px solid var(--gray-100);
    display: flex; justify-content: flex-end; gap: .5rem; flex-wrap: wrap;
}
.modal.modal-lg { max-width: 900px; }

/* ---------- Toast ---------- */
.toast-container {
    position: fixed; top: calc(var(--nav-height) + .75rem); right: 1rem;
    z-index: 600; display: flex; flex-direction: column; gap: .5rem;
}
.toast {
    padding: .75rem 1rem; border-radius: var(--radius);
    font-size: .85rem; min-width: 280px; max-width: 400px;
    box-shadow: var(--card-shadow-hover);
    display: flex; align-items: center; gap: .5rem;
    animation: slideIn .25s ease;
}
.toast-success { background: var(--success-dark); color: var(--white); }
.toast-error { background: var(--danger-dark); color: var(--white); }
.toast-warning { background: var(--warning); color: var(--dark); }
.toast-info { background: var(--info-dark); color: var(--white); }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ---------- Watermark ---------- */
.watermark {
    position: fixed; inset: 0; z-index: 50;
    pointer-events: none;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem; color: rgba(0,0,0,.04);
    transform: rotate(-30deg);
    white-space: nowrap;
    overflow: hidden;
}
.watermark::before {
    content: attr(data-text);
    font-weight: 700; font-size: 2rem;
    letter-spacing: 4px;
}

/* ---------- Dashboard Specific ---------- */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem; margin-bottom: 1.5rem;
}
.module-card {
    background: var(--white); border-radius: var(--radius-lg);
    box-shadow: var(--card-shadow); padding: 1.5rem;
    cursor: pointer; transition: all var(--transition);
    text-align: center; border: 2px solid transparent;
}
.module-card:hover {
    box-shadow: var(--card-shadow-hover); transform: translateY(-3px);
    border-color: var(--primary);
}
.module-card .module-icon { font-size: 2.2rem; margin-bottom: .5rem; color: var(--primary); display: flex; align-items: center; justify-content: center; }
.module-card .module-icon svg { width: 34px; height: 34px; }
.module-card .module-name { font-family: var(--font-heading); text-transform: uppercase; letter-spacing: .4px; font-size: .9rem; font-weight: 600; color: var(--dark); }
.module-card .module-desc { font-size: .75rem; color: var(--gray-500); margin-top: .25rem; }
.module-card.disabled {
    opacity: .4; cursor: not-allowed;
}
.module-card.disabled:hover { transform: none; border-color: transparent; box-shadow: var(--card-shadow); }

/* ---------- Section Headers ---------- */
.section-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 1rem; flex-wrap: wrap; gap: .5rem;
}
.section-header h2 { font-family: var(--font-heading); text-transform: uppercase; letter-spacing: .5px; font-size: 1.1rem; font-weight: 700; }
.section-header h3 { font-family: var(--font-heading); text-transform: uppercase; letter-spacing: .4px; font-size: .95rem; font-weight: 600; }

/* ---------- Empty State ---------- */
.empty-state {
    text-align: center; padding: 3rem 1rem; color: var(--gray-500);
}
.empty-state .empty-icon {
    font-size: 2.6rem; margin-bottom: .75rem;
    display: inline-flex; align-items: center; justify-content: center;
    width: 88px; height: 88px; border-radius: 50%;
    background: var(--gray-50);
}
.empty-state .empty-text { font-size: .9rem; }

/* ---------- Access Denied ---------- */
.access-denied {
    text-align: center; padding: 4rem 1rem;
}
.access-denied .denied-icon {
    font-size: 3.4rem; margin-bottom: 1rem;
    display: inline-flex; align-items: center; justify-content: center;
    width: 96px; height: 96px; border-radius: 50%;
    background: var(--danger-light);
}
.access-denied h2 { color: var(--danger-dark); margin-bottom: .5rem; }
.access-denied p { color: var(--gray-500); max-width: 400px; margin: 0 auto; }

/* ---------- Timeline ---------- */
.timeline { position: relative; padding-left: 2rem; }
.timeline::before {
    content: ''; position: absolute; left: .6rem; top: 0; bottom: 0;
    width: 2px; background: var(--gray-200);
}
.timeline-item { position: relative; margin-bottom: 1.25rem; }
.timeline-item::before {
    content: ''; position: absolute; left: -1.65rem; top: .35rem;
    width: 10px; height: 10px; border-radius: 50%;
    background: var(--primary); border: 2px solid var(--white);
}
.timeline-item .tl-date { font-size: .72rem; color: var(--gray-500); }
.timeline-item .tl-text { font-size: .85rem; }

/* ---------- Lot Grid ---------- */
.lot-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: .5rem;
}
.lot-cell {
    padding: .6rem .4rem; border-radius: var(--radius);
    text-align: center; font-size: .78rem; font-weight: 600;
    cursor: pointer; transition: all var(--transition);
    border: 1px solid var(--gray-200);
}
.lot-cell:hover { transform: scale(1.05); }
.lot-available { background: var(--success-light); color: var(--success-dark); border-color: var(--success); }
.lot-reserved { background: var(--warning-light); color: #856404; border-color: var(--warning); }
.lot-sold { background: var(--danger-light); color: var(--danger-dark); border-color: var(--danger); }
.lot-delivered { background: var(--info-light); color: var(--info-dark); border-color: var(--info); }
.lot-blocked { background: var(--gray-200); color: var(--gray-700); border-color: var(--gray-700); }

/* ---------- Photo Grid ---------- */
.photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: .75rem;
}
.photo-card {
    border-radius: var(--radius); overflow: hidden;
    box-shadow: var(--card-shadow); cursor: pointer;
    transition: transform var(--transition), box-shadow var(--transition);
}
.photo-card:hover { transform: scale(1.03); box-shadow: var(--card-shadow-hover); }
.photo-placeholder {
    width: 100%; aspect-ratio: 4/3;
    background: var(--gray-100);
    display: flex; align-items: center; justify-content: center;
    font-size: 2rem; color: var(--gray-300);
}
.photo-info { padding: .5rem; font-size: .72rem; color: var(--gray-500); }

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); box-shadow: 4px 0 20px rgba(0,0,0,.15); }
    .content { margin-left: 0; }
    .menu-toggle { display: block; }
    .nav-center h2 { font-size: .85rem; }
    .user-name-block { display: none; }
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .dashboard-grid { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
    .form-row { flex-direction: column; gap: 0; }
    .modal { max-width: 100%; margin: .5rem; }
    .filters-row { flex-direction: column; align-items: stretch; }
    .search-bar { max-width: 100%; }
    .tabs { gap: .3rem; }
    .tab-btn { padding: .4rem .7rem; font-size: .75rem; }
    .stat-card .stat-value { font-size: 1.3rem; }
    /* Ronda 12 — objetivo táctil más grande para uso en campo (Supervisor de Obra, Almacén). */
    .btn { min-height: 44px; padding: .6rem 1.2rem; }
    .btn-sm { min-height: 38px; }
    .nav-menu .nav-item { min-height: 46px; padding: .7rem .75rem; }
    .icon-btn { width: 44px; height: 44px; }
    .menu-toggle { width: 44px; height: 44px; }
    .menu-toggle span:nth-child(1) { top: 12px; }
    .menu-toggle span:nth-child(2) { top: 21px; }
    .menu-toggle span:nth-child(3) { top: 30px; }
}

@media (max-width: 480px) {
    .content { padding: 1rem .75rem; }
    .card-body { padding: 1rem; }
    .card-header { padding: .75rem 1rem; }
    .dashboard-grid { grid-template-columns: 1fr 1fr; }
    .lot-grid { grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); }
    .nav-left { min-width: auto; gap: .5rem; }
    .nav-right { min-width: auto; }
    .brand-name { display: none; }
    .sidebar { width: 82vw; max-width: 300px; }
    .dropdown { position: fixed; top: var(--nav-height); left: 1rem; right: 1rem; width: auto; min-width: 0; max-width: none; margin-top: .5rem; }
    .toast-container { left: 1rem; right: 1rem; }
    .toast { min-width: 0; max-width: 100%; }
}

/* ---------- Print ---------- */
@media print {
    .top-nav, .sidebar, .watermark, .toast-container { display: none !important; }
    .content { margin: 0; padding: 0; }
    .card { box-shadow: none; border: 1px solid var(--gray-200); }
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-500); }

/* ---------- Animations ---------- */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.fade-in { animation: fadeIn .25s ease; }

/* Sidebar overlay for mobile */
.sidebar-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,.3); z-index: 85;
}
.sidebar-overlay.active { display: block; }

/* ---------- Logo & Branding ---------- */
.login-logo-img {
    width: 120px; height: 120px; border-radius: 50%;
    object-fit: contain; margin-bottom: .75rem;
}
.login-brand-name {
    font-size: .85rem; font-weight: 600; color: var(--gray-700);
    letter-spacing: .5px; margin-bottom: -.15rem;
}
.login-logo h1 { font-family: var(--font-heading); text-transform: uppercase; font-size: 1.8rem; font-weight: 600; color: var(--primary-dark); letter-spacing: 2px; }
/* Insignia clara detrás del logo: el archivo de logo no es transparente, así que sobre el nuevo
   chrome oscuro se le da un pequeño "badge" circular claro para que no se vea como una caja
   flotante — no requiere tocar el archivo de imagen. */
.brand-logo-img { width: 30px; height: 30px; border-radius: 6px; object-fit: contain; }
.sidebar-brand {
    padding: .75rem 1rem; text-align: center;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-logo { width: 64px; height: 64px; border-radius: 50%; object-fit: contain; background: var(--bg); padding: 8px; box-sizing: border-box; }

/* ---------- Login gradient (Ronda 12: carbón + resplandor naranja, antes verde) ---------- */
.login-screen {
    background:
        radial-gradient(circle at 15% 15%, rgba(37,99,235,.14), transparent 42%),
        radial-gradient(circle at 85% 85%, rgba(255,255,255,.04), transparent 45%),
        linear-gradient(135deg, #0b1220 0%, #111c2e 50%, #16233a 100%);
}

/* ---------- Document Checklist ---------- */
.doc-checklist { list-style: none; padding: 0; }
.doc-checklist li {
    display: flex; align-items: center; gap: .5rem;
    padding: .45rem 0; border-bottom: 1px solid var(--gray-100);
    font-size: .85rem;
}
.doc-checklist li:last-child { border-bottom: none; }
.doc-checklist input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--primary); }
.doc-check-label { flex: 1; }
.doc-check-label.checked { text-decoration: line-through; color: var(--gray-500); }

/* ---------- Document Progress Gradient Bar ---------- */
.doc-progress-bar {
    width: 100%; height: 14px; border-radius: 7px;
    background: var(--gray-200); overflow: hidden; position: relative;
}
.doc-progress-fill {
    height: 100%; border-radius: 7px;
    transition: width .5s ease, background .5s ease;
}
.doc-progress-label {
    font-size: .72rem; font-weight: 600; margin-top: .2rem;
}

/* ---------- Client Status Badges ---------- */
.status-prospecto { background: #e8e8e8; color: #444; }
.status-seguimiento { background: #d4e6f1; color: #1a5276; }
.status-apartado { background: var(--warning-light); color: #7d6608; }
.status-pagado { background: var(--success-light); color: var(--success-dark); }
.status-escriturado { background: #d5f5e3; color: #1e8449; }
.status-entregado { background: var(--info-light); color: var(--info-dark); }

/* ---------- Autocomplete ---------- */
.autocomplete-wrapper { position: relative; }
.autocomplete-list {
    position: absolute; top: 100%; left: 0; right: 0;
    background: var(--white); border: 1px solid var(--gray-200);
    border-top: none; border-radius: 0 0 var(--radius) var(--radius);
    max-height: 180px; overflow-y: auto; z-index: 300;
    box-shadow: var(--card-shadow-hover);
}
.autocomplete-item {
    padding: .5rem .75rem; cursor: pointer; font-size: .85rem;
    border-bottom: 1px solid var(--gray-100);
    transition: background var(--transition);
}
.autocomplete-item:hover, .autocomplete-item.highlighted { background: var(--primary-light); }
.autocomplete-item .ac-match { font-weight: 700; color: var(--primary-dark); }
.autocomplete-item .ac-detail { font-size: .75rem; color: var(--gray-500); }

/* ---------- Permission Toggle Grid ---------- */
.perm-grid { display: grid; grid-template-columns: 1fr; gap: .5rem; }
.perm-row {
    display: flex; align-items: center; gap: .75rem;
    padding: .6rem .75rem; background: var(--gray-50);
    border-radius: var(--radius); border: 1px solid var(--gray-100);
}
.perm-row .perm-module { flex: 1; font-weight: 600; font-size: .85rem; }
.perm-toggle {
    position: relative; width: 40px; height: 22px;
    background: var(--gray-300); border-radius: 11px;
    cursor: pointer; transition: background var(--transition);
    border: none; padding: 0;
}
.perm-toggle.on { background: var(--primary); }
.perm-toggle::after {
    content: ''; position: absolute; top: 2px; left: 2px;
    width: 18px; height: 18px; border-radius: 50%;
    background: var(--white); transition: transform var(--transition);
    box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.perm-toggle.on::after { transform: translateX(18px); }
.perm-type-select {
    padding: .25rem .5rem; font-size: .75rem;
    border: 1px solid var(--gray-200); border-radius: var(--radius);
    background: var(--white);
}

/* ---------- Selección de Proyecto ---------- */
.proyecto-container { max-width: 560px; }
.proyecto-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: .9rem; margin-top: 1rem;
}
.proyecto-card {
    background: var(--gray-50); border: 1.5px solid var(--gray-200); border-radius: var(--radius-lg);
    padding: 1.4rem 1rem; text-align: center; cursor: pointer;
    transition: var(--transition);
}
.proyecto-card:hover { border-color: var(--primary); background: var(--primary-light); transform: translateY(-2px); box-shadow: var(--card-shadow); }
.proyecto-card .proyecto-icon { font-size: 1.8rem; margin-bottom: .5rem; }
.proyecto-card .proyecto-nombre { font-weight: 700; color: var(--dark); font-size: .92rem; }
.proyecto-card .proyecto-ubicacion { font-size: .76rem; color: var(--gray-500); margin-top: .25rem; }
.proyecto-card.nuevo { border-style: dashed; border-color: var(--primary); color: var(--primary-dark); }
.proyecto-card.nuevo .proyecto-icon { color: var(--primary); font-weight: 700; }
.project-badge {
    font-size: .72rem; font-weight: 700; background: var(--primary-light); color: var(--primary-dark);
    padding: .25rem .65rem; border-radius: 20px; margin-left: .6rem; white-space: nowrap;
}
@media (max-width: 640px) {
    .project-badge { display: none; }
}

/* ---------- Indicador de sincronización ---------- */
.sync-status {
    display: inline-flex; align-items: center; gap: .35rem;
    font-size: .72rem; font-weight: 600;
    padding: .2rem .55rem; border-radius: 20px;
    margin-left: .5rem; white-space: nowrap;
    transition: background var(--transition), color var(--transition);
}
.sync-status .sync-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.sync-status-online { background: var(--success-light); color: var(--success-dark); }
.sync-status-reconnecting { background: var(--warning-light); color: var(--warning-dark); }
.sync-status-offline { background: var(--danger-light); color: var(--danger-dark); }
@media (max-width: 640px) {
    .sync-status-text { display: none; }
}

/* ---------- Calendario de Recordatorios ---------- */
.calendario-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.calendario-dow { font-size: .72rem; font-weight: 700; text-align: center; color: var(--gray-500); padding: .3rem 0; text-transform: uppercase; }
.calendario-cell {
    min-height: 78px; border: 1px solid var(--gray-200); border-radius: 6px;
    padding: .3rem; font-size: .72rem; overflow: hidden;
    transition: border-color var(--transition), background var(--transition);
}
.calendario-cell.vacia { border: none; }
.calendario-cell.hoy { border-color: var(--primary); background: var(--primary-light); }
.calendario-cell[onclick] { cursor: pointer; }
.calendario-cell[onclick]:hover { border-color: var(--primary); }
.calendario-num { font-weight: 700; margin-bottom: .2rem; }
.calendario-chip {
    background: var(--gray-100); border-radius: 4px; padding: .1rem .3rem; margin-bottom: .15rem;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.calendario-chip.alta { background: var(--danger-light); color: var(--danger-dark); }
.calendario-chip.completada { text-decoration: line-through; opacity: .55; }
/* ---------- MARCADOR TEMPORAL DE REVISIÓN (qa-nuevo) ----------
   Envuelve exclusivamente las piezas nuevas/modificadas de la ronda de
   mejoras en curso, para que el usuario las identifique visualmente
   mientras confirma que funcionan. NO es diseño final:
   - Si se aprueba una pieza: quitar la clase "qa-nuevo" de su marcado.
   - Si se rechaza: retirar la función completa (no solo el estilo).
   No altera lógica ni datos, solo apariencia. */
.qa-nuevo {
    background: #000 !important;
    color: #fff !important;
    border-radius: var(--radius);
    padding: .35rem .6rem;
    display: inline-block;
}
.qa-nuevo, .qa-nuevo * { color: #fff !important; }
.qa-nuevo a, .qa-nuevo .btn-outline { border-color: #fff !important; }
.qa-nuevo .form-control { background: #1a1a1a !important; border-color: #555 !important; }
.qa-nuevo.qa-block { display: block; margin: .5rem 0; }

@media (max-width: 640px) {
    .calendario-cell { min-height: 56px; font-size: .65rem; }
    .calendario-dow { font-size: .62rem; }
}
