/* =============================================
   CONTINENTAL DRYWALL - PANEL DE GESTIÓN
   CSS Principal del Panel de Administración
   Versión: 1.0.0
   Fuentes: Instrument Sans (títulos) + Inter (cuerpo)
   Paleta: #FF5733 (primary), #202124 (dark), #0cbc87 (success)
   ============================================= */

/* ---- Importar fuentes ---- */
@import url('https://fonts.googleapis.com/css2?family=Instrument+Sans:wght@400;500;600;700&family=Inter:wght@300;400;500;600&display=swap');

/* ---- Variables del sistema ---- */
:root {
    --mad-primary:        #FF5733;
    --mad-primary-dark:   #cc3d1f;
    --mad-primary-light:  #fff0ec;
    --mad-primary-rgb:    255, 87, 51;

    --mad-sidebar-bg:     #12151e;
    --mad-sidebar-width:  260px;
    --mad-navbar-height:  64px;

    --mad-body-bg:        #f0f2f7;
    --mad-card-bg:        #ffffff;
    --mad-border:         #e2e6ed;

    --mad-text:           #202124;
    --mad-text-muted:     #606261;
    --mad-heading-font:   'Instrument Sans', sans-serif;
    --mad-body-font:      'Inter', sans-serif;

    --mad-success:        #0cbc87;
    --mad-warning:        #f7c32e;
    --mad-danger:         #d6293e;
    --mad-info:           #17a2b8;
    --mad-orange:         #fd7e14;

    --mad-shadow-sm:      0 2px 8px rgba(29, 58, 83, 0.08);
    --mad-shadow:         0 4px 20px rgba(29, 58, 83, 0.10);
    --mad-shadow-lg:      0 8px 40px rgba(29, 58, 83, 0.14);
    --mad-radius:         0.5rem;
    --mad-radius-sm:      0.313rem;
    --mad-radius-lg:      0.75rem;

    --mad-sidebar-text:       rgba(255, 255, 255, 0.65);
    --mad-sidebar-text-hover: rgba(255, 255, 255, 0.95);
    --mad-sidebar-active-bg:  rgba(255, 87, 51, 0.18);
    --mad-sidebar-section:    rgba(255, 255, 255, 0.30);
}

/* =============================================
   RESET Y BASE
   ============================================= */

*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: var(--mad-body-font);
    font-size: 0.9rem;
    color: var(--mad-text);
    background-color: var(--mad-body-bg);
    margin: 0;
    padding: 0;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--mad-heading-font);
    color: var(--mad-text);
    font-weight: 600;
}

a { text-decoration: none; }

/* =============================================
   LAYOUT PRINCIPAL: sidebar + contenido
   ============================================= */

.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/* ---- Sidebar ---- */
.app-sidebar {
    width: var(--mad-sidebar-width);
    min-height: 100vh;
    background: linear-gradient(180deg, #151821 0%, #12151e 100%);
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1040;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
    overflow-y: auto;
    overflow-x: hidden;
}

.app-sidebar::-webkit-scrollbar { width: 4px; }
.app-sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 4px; }

#sidebar-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

/* Logo del sidebar */
.sidebar-logo {
    padding: 1.35rem 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    display: flex;
    align-items: center;
    gap: 0.8rem;
    flex-shrink: 0;
}

.sidebar-logo img {
    height: 36px;
    width: auto;
}

.sidebar-logo-text {
    font-family: var(--mad-heading-font);
    font-weight: 700;
    font-size: 1.05rem;
    color: #fff;
    letter-spacing: -0.01em;
}

.sidebar-logo-sub {
    font-size: 0.65rem;
    color: rgba(255,255,255,0.28);
    font-weight: 500;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    display: block;
    margin-top: 1px;
}

/* Secciones de navegación */
.sidebar-section-label {
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: rgba(255,255,255,0.25);
    padding: 1.25rem 1.5rem 0.4rem;
}

/* Links de navegación */
.sidebar-nav {
    padding: 0.75rem 0;
    flex: 1;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 0.9rem;
    border-left: 3px solid transparent;
    border-radius: 0 var(--mad-radius-sm) var(--mad-radius-sm) 0;
    color: var(--mad-sidebar-text);
    font-size: 0.865rem;
    font-weight: 500;
    transition: all 0.15s ease;
    cursor: pointer;
    white-space: nowrap;
    margin-bottom: 3px;
    text-decoration: none;
}

.sidebar-link:hover {
    background-color: rgba(255,255,255,0.06);
    color: var(--mad-sidebar-text-hover);
    border-left-color: rgba(240,25,25,0.35);
}

.sidebar-link.active {
    background-color: rgba(240,25,25,0.13);
    color: #fff;
    font-weight: 600;
    border-left-color: var(--mad-primary);
}

.sidebar-link .bi {
    font-size: 1rem;
    flex-shrink: 0;
    width: 20px;
    text-align: center;
    opacity: 0.85;
}

.sidebar-link.active .bi,
.sidebar-link:hover .bi {
    opacity: 1;
}

/* Badge en sidebar */
.sidebar-badge {
    margin-left: auto;
    background: var(--mad-primary);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.1rem 0.45rem;
    border-radius: 50rem;
    line-height: 1.6;
}

/* Footer del sidebar */
.sidebar-footer {
    padding: 0.75rem 0.65rem;
    border-top: 1px solid rgba(255,255,255,0.06);
    flex-shrink: 0;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.7rem 0.85rem;
    border-radius: var(--mad-radius-sm);
    cursor: pointer;
    transition: background 0.15s;
    border: 1px solid transparent;
}

.sidebar-user:hover {
    background: rgba(255,255,255,0.06);
    border-color: rgba(255,255,255,0.07);
}

.sidebar-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--mad-primary), #990000);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--mad-heading-font);
    font-weight: 700;
    font-size: 0.82rem;
    color: #fff;
    flex-shrink: 0;
    box-shadow: 0 0 0 2px rgba(240,25,25,0.3);
}

.sidebar-user-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: rgba(255,255,255,0.9);
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    font-size: 0.68rem;
    color: rgba(255,255,255,0.38);
    white-space: nowrap;
}

/* ---- Área de contenido principal ---- */
.app-main {
    margin-left: var(--mad-sidebar-width);
    flex: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow-x: clip;
}

/* ---- Navbar superior ---- */
.app-navbar {
    height: var(--mad-navbar-height);
    background: #fff;
    border-bottom: 1px solid var(--mad-border);
    display: flex;
    align-items: center;
    padding: 0 1.75rem;
    position: sticky;
    top: 0;
    z-index: 1030;
    gap: 1rem;
    box-shadow: var(--mad-shadow-sm);
}

.navbar-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.25rem;
    color: var(--mad-text-muted);
    padding: 0.35rem;
    cursor: pointer;
    border-radius: var(--mad-radius-sm);
    transition: background 0.15s;
}

.navbar-toggle:hover { background: var(--mad-body-bg); }

.navbar-page-title {
    font-family: var(--mad-heading-font);
    font-size: 1rem;
    font-weight: 600;
    color: var(--mad-text);
    margin: 0;
}

.navbar-spacer { flex: 1; }

.navbar-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.navbar-icon-btn {
    width: 36px;
    height: 36px;
    border-radius: var(--mad-radius-sm);
    background: none;
    border: 1px solid var(--mad-border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    color: var(--mad-text-muted);
    cursor: pointer;
    transition: all 0.15s;
    position: relative;
}

.navbar-icon-btn:hover {
    background: var(--mad-body-bg);
    color: var(--mad-text);
}

.navbar-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--mad-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--mad-heading-font);
    font-weight: 700;
    font-size: 0.8rem;
    color: #fff;
    cursor: pointer;
    border: 2px solid var(--mad-primary-light);
}

/* ---- Área de contenido de páginas ---- */
.app-content {
    padding: 1.75rem;
    flex: 1;
    min-width: 0;
}

/* =============================================
   ENCABEZADO DE PÁGINA
   ============================================= */

.page-header {
    margin-bottom: 1.5rem;
}

.page-title {
    font-family: var(--mad-heading-font);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--mad-text);
    margin: 0;
}

.page-subtitle {
    font-size: 0.875rem;
    color: var(--mad-text-muted);
    margin-top: 0.25rem;
}

/* =============================================
   TARJETAS (CARDS)
   ============================================= */

.mad-card {
    background: var(--mad-card-bg);
    border-radius: var(--mad-radius);
    border: 1px solid var(--mad-border);
    box-shadow: var(--mad-shadow-sm);
    overflow: clip;
}
.mad-card-header {
    padding: 1.1rem 1.5rem;
    border-bottom: 1px solid var(--mad-border);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.mad-card-title {
    font-family: var(--mad-heading-font);
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--mad-text);
    margin: 0;
}

.mad-card-actions { margin-left: auto; }

.mad-card-body { padding: 1.5rem; }

/* =============================================
   TARJETAS DE ESTADÍSTICAS (STATS)
   ============================================= */

.stat-card {
    background: var(--mad-card-bg);
    border-radius: var(--mad-radius);
    border: 1px solid var(--mad-border);
    box-shadow: var(--mad-shadow-sm);
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: box-shadow 0.2s, transform 0.2s;
}

.stat-card:hover {
    box-shadow: var(--mad-shadow);
    transform: translateY(-2px);
}

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--mad-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}

.stat-icon.primary   { background: var(--mad-primary-light); color: var(--mad-primary); }
.stat-icon.success   { background: #d4f4ec; color: var(--mad-success); }
.stat-icon.warning   { background: #fef9e7; color: var(--mad-warning); }
.stat-icon.danger    { background: #fce8ea; color: var(--mad-danger); }
.stat-icon.orange    { background: #fff3e0; color: var(--mad-orange); }
.stat-icon.info      { background: #d1ecf1; color: var(--mad-info); }

.stat-info { flex: 1; min-width: 0; }

.stat-value {
    font-family: var(--mad-heading-font);
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--mad-text);
    line-height: 1;
    margin-bottom: 0.25rem;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--mad-text-muted);
    font-weight: 500;
}

/* =============================================
   TABLA GENERAL
   ============================================= */

/* Wrapper scrolleable — usar en todas las tablas del panel */
.tbl-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Card que contiene tabla — permite scroll sin cortar border-radius */
.mad-card-table { overflow: visible; }

.tickets-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.tickets-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.tickets-table thead th {
    background: #f8f9fc;
    padding: 0.75rem 1rem;
    text-align: left;
    font-family: var(--mad-heading-font);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--mad-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--mad-border);
    white-space: nowrap;
}

.tickets-table tbody td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--mad-border);
    vertical-align: middle;
}

.tickets-table tbody tr:last-child td { border-bottom: none; }

.tickets-table tbody tr {
    transition: background 0.15s;
    cursor: pointer;
}

.tickets-table tbody tr:hover { background: #f8f9fc; }

/* =============================================
   BADGES
   ============================================= */

.badge-estado,
.badge-urgencia {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.3rem 0.65rem;
    border-radius: 50rem;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
}

.badge-nuevo      { background: var(--mad-primary-light); color: var(--mad-primary); }
.badge-asignado   { background: #fff3e0; color: var(--mad-orange); }
.badge-cerrado    { background: #d4f4ec; color: var(--mad-success); }
.badge-pendiente  { background: #f3f4f6; color: #9ca3af; font-style: italic; }
.badge-baja       { background: #f0f2f7; color: var(--mad-text-muted); }
.badge-media      { background: var(--mad-primary-light); color: var(--mad-primary); }
.badge-alta       { background: #fff3e0; color: var(--mad-orange); }
.badge-critica    { background: #fce8ea; color: var(--mad-danger); }

.badge-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
}

/* =============================================
   FILTROS / TOOLBAR DE BÚSQUEDA
   ============================================= */

.filters-bar {
    background: var(--mad-card-bg);
    border: 1px solid var(--mad-border);
    border-radius: var(--mad-radius);
    padding: 1.1rem 1.25rem;
    margin-bottom: 1.25rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem 0.75rem;
    align-items: flex-end;
    box-shadow: var(--mad-shadow-sm);
}

.filters-bar .filter-group:first-child {
    flex: 1 1 100%;
    min-width: unset;
}

.filters-bar .filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 130px;
}

.filters-bar .filter-group label {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--mad-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.filters-bar .form-control,
.filters-bar .form-select {
    font-family: var(--mad-body-font);
    font-size: 0.85rem;
    height: 36px;
    border-color: var(--mad-border);
    border-radius: var(--mad-radius-sm);
    background-color: var(--mad-body-bg);
    transition: border-color .15s, box-shadow .15s;
}

.filters-bar .form-control:focus,
.filters-bar .form-select:focus {
    border-color: var(--mad-primary);
    box-shadow: 0 0 0 3px rgba(var(--mad-primary-rgb), 0.12);
    background-color: #fff;
}

.filters-bar input[type="date"] {
    font-family: var(--mad-body-font);
}

.filters-bar .btn-mad {
    height: 36px;
    display: flex;
    align-items: center;
    padding-top: 0;
    padding-bottom: 0;
}

.filters-bar .filter-group:first-child .form-control {
    height: 40px;
    font-size: 0.9rem;
    border-radius: var(--mad-radius-sm);
    padding-left: 2.4rem;
}

/* =============================================
   FORMULARIOS
   ============================================= */

.mad-form-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--mad-text);
    margin-bottom: 0.35rem;
    display: block;
}

.mad-form-control,
.mad-form-select {
    width: 100%;
    border: 1px solid var(--mad-border);
    border-radius: var(--mad-radius-sm);
    padding: 0.55rem 0.9rem;
    font-family: var(--mad-body-font);
    font-size: 0.875rem;
    color: var(--mad-text);
    background: #fff;
    transition: border-color 0.15s, box-shadow 0.15s;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.mad-form-control:focus,
.mad-form-select:focus {
    border-color: var(--mad-primary);
    box-shadow: 0 0 0 3px rgba(var(--mad-primary-rgb), 0.12);
}

.mad-form-control::placeholder { color: var(--mad-text-muted); }

textarea.mad-form-control {
    resize: vertical;
    min-height: 100px;
}

/* =============================================
   BOTONES
   ============================================= */

.btn-mad {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.5rem 1.1rem;
    border-radius: var(--mad-radius-sm);
    font-family: var(--mad-body-font);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.18s ease;
    text-decoration: none;
    white-space: nowrap;
}

.btn-mad-primary {
    background: var(--mad-primary);
    color: #fff;
}

.btn-mad-primary:hover {
    background: var(--mad-primary-dark);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(var(--mad-primary-rgb), 0.35);
}

.btn-mad-outline {
    background: transparent;
    color: var(--mad-text-muted);
    border: 1px solid var(--mad-border);
}

.btn-mad-outline:hover {
    background: var(--mad-body-bg);
    color: var(--mad-text);
    border-color: #c0c4cc;
}

.btn-mad-success {
    background: var(--mad-success);
    color: #fff;
}

.btn-mad-success:hover {
    background: #0aa070;
    color: #fff;
}

.btn-mad-danger {
    background: var(--mad-danger);
    color: #fff;
}

.btn-mad-danger:hover {
    background: #b8202f;
    color: #fff;
}

.btn-mad-sm {
    padding: 0.3rem 0.75rem;
    font-size: 0.8rem;
}

.btn-mad-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    justify-content: center;
    border-radius: var(--mad-radius-sm);
}

/* =============================================
   PÁGINAS DE AUTH (LOGIN)
   ============================================= */

.auth-page {
    min-height: 100vh;
    background: linear-gradient(135deg, #0f1420 0%, #1a1d2e 40%, #0d1520 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    position: relative;
    overflow: hidden;
}

.auth-page::before {
    content: '';
    position: absolute;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(240, 25, 25, 0.12) 0%, transparent 70%);
    top: -200px;
    right: -200px;
    pointer-events: none;
}

.auth-page::after {
    content: '';
    position: absolute;
    width: 400px;
    height: 400px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(12, 188, 135, 0.08) 0%, transparent 70%);
    bottom: -150px;
    left: -100px;
    pointer-events: none;
}

.auth-card {
    background: #fff;
    border-radius: var(--mad-radius-lg);
    box-shadow: var(--mad-shadow-lg);
    width: 100%;
    max-width: 440px;
    padding: 2.5rem 2.25rem;
    position: relative;
    z-index: 1;
}

.auth-logo {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-logo img { height: 48px; }

.auth-title {
    font-family: var(--mad-heading-font);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--mad-text);
    text-align: center;
    margin-bottom: 0.4rem;
}

.auth-subtitle {
    font-size: 0.875rem;
    color: var(--mad-text-muted);
    text-align: center;
    margin-bottom: 2rem;
}

/* =============================================
   TOAST / NOTIFICACIONES
   ============================================= */

.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: 360px;
}

.mad-toast {
    background: #fff;
    border-radius: var(--mad-radius);
    box-shadow: var(--mad-shadow-lg);
    padding: 0.9rem 1.2rem;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    border-left: 4px solid var(--mad-primary);
    animation: slideInToast 0.3s ease;
    font-size: 0.875rem;
}

.mad-toast.success { border-color: var(--mad-success); }
.mad-toast.error   { border-color: var(--mad-danger); }
.mad-toast.warning { border-color: var(--mad-warning); }

.mad-toast-icon {
    font-size: 1.1rem;
    flex-shrink: 0;
    margin-top: 1px;
}

.mad-toast.success .mad-toast-icon { color: var(--mad-success); }
.mad-toast.error   .mad-toast-icon { color: var(--mad-danger); }
.mad-toast.warning .mad-toast-icon { color: var(--mad-warning); }
.mad-toast:not(.success):not(.error):not(.warning) .mad-toast-icon { color: var(--mad-primary); }

.mad-toast-body { flex: 1; }
.mad-toast-title { font-weight: 600; color: var(--mad-text); }
.mad-toast-msg   { color: var(--mad-text-muted); margin-top: 0.2rem; }

@keyframes slideInToast {
    from { opacity: 0; transform: translateX(40px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* =============================================
   MODAL
   ============================================= */

.mad-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(18, 21, 30, 0.55);
    z-index: 1050;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    animation: fadeIn 0.2s ease;
}

.mad-modal {
    background: #fff;
    border-radius: var(--mad-radius-lg);
    box-shadow: var(--mad-shadow-lg);
    width: 100%;
    max-width: 540px;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.25s ease;
}

.mad-modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--mad-border);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.mad-modal-title {
    font-family: var(--mad-heading-font);
    font-size: 1rem;
    font-weight: 700;
    color: var(--mad-text);
    margin: 0;
    flex: 1;
}

.mad-modal-close {
    width: 28px;
    height: 28px;
    border-radius: var(--mad-radius-sm);
    background: none;
    border: 1px solid var(--mad-border);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--mad-text-muted);
    font-size: 0.9rem;
    transition: all 0.15s;
}

.mad-modal-close:hover {
    background: var(--mad-body-bg);
    color: var(--mad-text);
}

.mad-modal-body { padding: 1.5rem; }

.mad-modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--mad-border);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

@keyframes fadeIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

/* =============================================
   ESTADO VACÍO
   ============================================= */

.empty-state {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--mad-text-muted);
}

.empty-state .empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state h5 {
    font-family: var(--mad-heading-font);
    font-size: 1rem;
    color: var(--mad-text-muted);
    margin-bottom: 0.5rem;
}

.empty-state p {
    font-size: 0.875rem;
    margin-bottom: 1.25rem;
}

/* =============================================
   SPINNER DE CARGA
   ============================================= */

.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255,255,255,0.7);
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mad-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--mad-border);
    border-top-color: var(--mad-primary);
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* =============================================
   MÓDULO DE PROYECTOS
   ============================================= */

/* Badges de estado de tarea */
.badge-tarea {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.65rem;
    border-radius: 2rem;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    white-space: nowrap;
}
.tarea-pendiente  { background: #fef9c3; color: #a16207; }
.tarea-en-proceso { background: #dbeafe; color: #1d4ed8; }
.tarea-completada { background: #dcfce7; color: #16a34a; }

/* Badges de estado de proyecto */
.badge-proy {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.65rem;
    border-radius: 2rem;
    font-size: 0.72rem;
    font-weight: 600;
    white-space: nowrap;
}
.proy-activo     { background: #dbeafe; color: #1d4ed8; }
.proy-pausado    { background: #fef9c3; color: #a16207; }
.proy-completado { background: #dcfce7; color: #16a34a; }
.proy-cancelado  { background: #f3f4f6; color: #6b7280; }

/* Tarjeta de proyecto */
.proyecto-card {
    background: #fff;
    border: 1px solid var(--mad-border);
    border-radius: 1rem;
    overflow: hidden;
    cursor: pointer;
    transition: box-shadow 0.18s, transform 0.15s, border-color 0.15s;
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: inherit;
    position: relative;
}
.proyecto-card:hover {
    box-shadow: 0 8px 28px rgba(240,25,25,.12);
    border-color: var(--mad-primary);
    transform: translateY(-2px);
}
.proyecto-card-accent {
    height: 4px;
    width: 100%;
    background: linear-gradient(90deg, var(--mad-primary), #ff6b6b);
    flex-shrink: 0;
}
.proyecto-card-accent.activo     { background: linear-gradient(90deg,#f01919,#ff6b6b); }
.proyecto-card-accent.pausado    { background: linear-gradient(90deg,#f7c32e,#fde68a); }
.proyecto-card-accent.completado { background: linear-gradient(90deg,#0cbc87,#6ee7b7); }
.proyecto-card-accent.cancelado  { background: linear-gradient(90deg,#9ca3af,#d1d5db); }

.proyecto-card-body {
    padding: 1.35rem 1.4rem 0;
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
    flex: 1;
}
.proyecto-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
}
.proyecto-card-icon {
    width: 42px;
    height: 42px;
    border-radius: 0.6rem;
    background: var(--mad-primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-family: var(--mad-heading-font);
    font-size: 0.95rem;
    font-weight: 800;
    color: var(--mad-primary);
}
.proyecto-card-title {
    font-family: var(--mad-heading-font);
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--mad-text);
    margin: 0 0 0.2rem;
    line-height: 1.35;
}
.proyecto-card-empresa {
    font-size: 0.77rem;
    color: var(--mad-text-muted);
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

/* Progress bar */
.prog-bar-wrap {
    background: var(--mad-body-bg);
    border-radius: 2rem;
    height: 6px;
    overflow: hidden;
}
.prog-bar-fill {
    height: 100%;
    border-radius: 2rem;
    background: linear-gradient(90deg, var(--mad-primary), #ff6b6b);
    transition: width 0.5s ease;
}
.prog-bar-fill.done { background: linear-gradient(90deg, var(--mad-success), #6ee7b7); }

.proyecto-card-stats {
    display: flex;
    gap: 0;
    border-top: 1px solid var(--mad-border);
    margin: 0 -1.4rem;
}
.proyecto-card-stat {
    flex: 1;
    text-align: center;
    padding: 0.8rem 0.5rem;
    border-right: 1px solid var(--mad-border);
    font-size: 0.72rem;
    color: var(--mad-text-muted);
}
.proyecto-card-stat:last-child { border-right: none; }
.proyecto-card-stat strong {
    display: block;
    font-size: 1.1rem;
    font-weight: 800;
    font-family: var(--mad-heading-font);
    color: var(--mad-text);
    margin-bottom: 0.15rem;
    line-height: 1;
}
.proyecto-card-meta {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    font-size: 0.77rem;
    color: var(--mad-text-muted);
    flex-wrap: wrap;
}

/* Grid de proyectos */
.proyectos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.15rem;
}

/* Tarea row en proyecto-detalle */
.tarea-row {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1.1rem 1.25rem;
    border-bottom: 1px solid var(--mad-border);
    transition: background 0.15s;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
}
.tarea-row:last-child { border-bottom: none; }
.tarea-row:hover { background: #f8fafc; }
.tarea-row-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--mad-text);
    min-width: 0;
    line-height: 1.4;
    margin-bottom: 0.5rem;
}
.tarea-row-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    background: #f1f5f9;
    border-radius: 0.35rem;
    padding: 0.2rem 0.6rem;
    font-size: 0.75rem;
    color: var(--mad-text-muted);
    white-space: nowrap;
}

/* Paginación */
.mad-pagination {
    display: flex;
    gap: 0.25rem;
    align-items: center;
    justify-content: flex-end;
    margin-top: 1rem;
    flex-wrap: wrap;
}

.mad-page-btn {
    min-width: 34px;
    height: 34px;
    border-radius: var(--mad-radius-sm);
    border: 1px solid var(--mad-border);
    background: #fff;
    color: var(--mad-text-muted);
    font-size: 0.8rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s;
    padding: 0 0.5rem;
}

.mad-page-btn:hover {
    border-color: var(--mad-primary);
    color: var(--mad-primary);
}

.mad-page-btn.active {
    background: var(--mad-primary);
    border-color: var(--mad-primary);
    color: #fff;
}

.mad-page-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* =============================================
   UTILIDADES
   ============================================= */

.text-primary-mad { color: var(--mad-primary) !important; }
.bg-primary-mad   { background: var(--mad-primary-light) !important; }
.fw-600           { font-weight: 600 !important; }
.fw-700           { font-weight: 700 !important; }
.font-heading     { font-family: var(--mad-heading-font) !important; }

.divider-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--mad-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 1rem 0;
}

.divider-label::before,
.divider-label::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--mad-border);
}

/* =============================================
   RESPONSIVE
   ============================================= */

@media (max-width: 991.98px) {
    .app-sidebar {
        transform: translateX(-100%);
        width: 280px;
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.25);
    }

    .app-sidebar.open {
        transform: translateX(0);
    }

    .app-main {
        margin-left: 0;
    }

    .navbar-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.55);
        z-index: 1039;
        display: none;
        backdrop-filter: blur(2px);
    }

    .sidebar-overlay.active {
        display: block;
    }

    .app-navbar {
        padding: 0 1rem;
        gap: 0.65rem;
    }

    .navbar-page-title {
        font-size: 1rem;
    }
}

@media (max-width: 767.98px) {
    .app-content {
        padding: 1rem !important;
    }

    .page-title, .page-head h1 {
        font-size: 1.25rem !important;
    }

    .page-subtitle, .page-head p {
        font-size: 0.78rem !important;
    }

    .filters-bar { flex-direction: column; }
    .filters-bar .filter-group { min-width: 100%; }

    .stat-card { padding: 1rem; }
    .stat-value { font-size: 1.4rem; }

    .proyectos-grid,
    .proj-grid { grid-template-columns: 1fr !important; }

    /* KPI cards — handled per-page */
    .kpi-card {
        padding: 0.85rem !important;
        gap: 0.7rem !important;
    }
    .kpi-icon {
        width: 38px !important;
        height: 38px !important;
        font-size: 1.05rem !important;
    }
    .kpi-value { font-size: 1.2rem !important; }
    .kpi-label { font-size: 0.7rem !important; }

    /* Charts */
    .chart-card { padding: 1rem !important; }
    .chart-card-header { flex-direction: column; align-items: flex-start !important; gap: 0.5rem; }

    /* Toolbar in projects */
    .toolbar {
        flex-direction: column;
        align-items: stretch !important;
        gap: 0.6rem !important;
    }
    .search-wrap { width: 100%; }
    .status-tabs {
        overflow-x: auto;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
    }
    .status-tabs::-webkit-scrollbar { display: none; }
    .filter-select { width: 100%; }

    /* Page head */
    .page-head {
        flex-direction: column;
        align-items: stretch !important;
    }
    .page-head .btn-primary-mod {
        justify-content: center;
        width: 100%;
    }

    /* Modal: full screen feel on mobile */
    .mad-modal {
        width: 95% !important;
        max-width: 95% !important;
        margin: 0.5rem !important;
    }
    .mad-modal-body > div[style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
    }

    /* Projects table on dashboard */
    .projects-table-wrap { overflow-x: auto; }
    .projects-table { min-width: 0; width: 100%; }

    /* Project card financial grid */
    .proj-card-financials { gap: 0.25rem !important; padding: 0.55rem 0.9rem !important; }
    .fin-value { font-size: 0.75rem !important; }
    .fin-label { font-size: 0.6rem !important; }

    /* Card padding tight */
    .proj-card-top { padding: 0.9rem 1rem 0.6rem !important; }
    .proj-card-badges { padding: 0 1rem 0.6rem !important; }
    .proj-card-footer { padding: 0.6rem 1rem !important; flex-wrap: wrap; gap: 0.5rem; }
    .proj-stats { gap: 0.65rem !important; }
}

@media (max-width: 479.98px) {
    .status-tab { padding: 0.35rem 0.7rem !important; font-size: 0.72rem !important; }
}
