:root {
    --primary-50: #fef2f2;
    --primary-100: #fde3e2;
    --primary-200: #fbc9c7;
    --primary-500: #E8261E;
    --primary-600: #d01912;
    --primary-700: #b81c16;
    --primary-color: var(--primary-500);
    --primary-dark: var(--primary-700);
    --primary-tint: var(--primary-50);

    --secondary-color: #64748b;
    --success-color: #10b981;
    --success-tint: #ecfdf5;
    --danger-color: #dc2626;
    --danger-tint: #fef2f2;
    --warning-color: #f59e0b;
    --warning-tint: #fffbeb;
    --info-color: #0ea5e9;

    --bg-body: #f6f7fb;
    --bg-sidebar: #ffffff;
    --bg-card: #ffffff;

    --text-primary: #16202e;
    --text-secondary: #48566b;
    --text-muted: #94a1b4;

    --border-color: #e7eaf1;
    --border-color-strong: #d6dbe6;

    --shadow-xs: 0 1px 2px 0 rgb(16 24 40 / 0.05);
    --shadow-sm: 0 1px 3px 0 rgb(16 24 40 / 0.07), 0 1px 2px -1px rgb(16 24 40 / 0.06);
    --shadow-md: 0 6px 16px -4px rgb(16 24 40 / 0.09), 0 2px 6px -3px rgb(16 24 40 / 0.06);
    --shadow-lg: 0 20px 40px -12px rgb(16 24 40 / 0.16), 0 6px 12px -6px rgb(16 24 40 / 0.08);
    --shadow-brand: 0 12px 24px -10px rgb(232 38 30 / 0.45);

    --font-family: 'Roboto', system-ui, -apple-system, sans-serif;
    --sidebar-width: 264px;
    --header-height: 72px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-xl: 28px;
    --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

::selection { background: var(--primary-200); color: var(--primary-700); }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--border-color-strong); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

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

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 200;
    transition: transform 0.28s var(--ease);
}

.sidebar-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.brand {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.brand img { height: 28px; width: auto; filter: drop-shadow(0 2px 4px rgb(232 38 30 / 0.18)); }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 1.1rem 0.85rem; }
.sidebar-nav ul { list-style: none; display: flex; flex-direction: column; gap: 0.2rem; }

.sidebar-nav li a {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.65rem 0.9rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: var(--radius-md);
    transition: background-color 0.18s var(--ease), color 0.18s var(--ease), transform 0.18s var(--ease);
}

.sidebar-nav li a i {
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 9px;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.92rem;
    transition: background-color 0.18s var(--ease), color 0.18s var(--ease);
}

.sidebar-nav li a:hover { background-color: var(--primary-50); color: var(--primary-700); transform: translateX(2px); }
.sidebar-nav li a:hover i { color: var(--primary-600); }

.sidebar-nav li.active a {
    background: linear-gradient(90deg, var(--primary-50), transparent);
    color: var(--primary-700);
    font-weight: 600;
}

.sidebar-nav li.active a i {
    background: linear-gradient(135deg, var(--primary-500), var(--primary-700));
    color: #fff;
    box-shadow: 0 4px 10px -3px rgb(232 38 30 / 0.55);
}

.sidebar-footer {
    border-top: 1px solid var(--border-color);
    padding: 1rem 1.25rem;
}

.logout-link {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: var(--danger-color);
    font-size: 0.88rem;
    font-weight: 500;
    padding: 0.5rem 0.6rem;
    border-radius: var(--radius-md);
    transition: background-color 0.18s var(--ease);
}

.logout-link:hover { background-color: var(--danger-tint); }

/* Main content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-width: 0;
}

.topbar {
    height: var(--header-height);
    background-color: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.75rem;
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar h1 { font-size: 1.2rem; font-weight: 700; letter-spacing: -0.01em; }

.topbar-user {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.topbar-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-500), var(--primary-700));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.82rem;
    box-shadow: var(--shadow-brand);
}

.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.25rem;
    color: var(--text-primary);
    cursor: pointer;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgb(15 23 42 / 0.45);
    backdrop-filter: blur(2px);
    z-index: 150;
}

.content { padding: 1.85rem; max-width: 1400px; }

/* Cards */
.card {
    background-color: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    padding: 1.6rem;
    transition: box-shadow 0.2s var(--ease);
}

.card + .card { margin-top: 1.5rem; }

.card-title { font-size: 1.05rem; font-weight: 700; margin-bottom: 0.25rem; letter-spacing: -0.01em; }
.card-subtitle { color: var(--text-muted); font-size: 0.85rem; margin-bottom: 1.25rem; }

.placeholder-box {
    border: 1.5px dashed var(--border-color-strong);
    border-radius: var(--radius-md);
    padding: 2.5rem 1rem;
    text-align: center;
    color: var(--text-muted);
    background: linear-gradient(180deg, #fafbfd, transparent);
}

.placeholder-box i { font-size: 1.75rem; color: var(--border-color-strong); margin-bottom: 0.75rem; display: block; }

/* KPI stat tiles */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.1rem;
    margin-bottom: 1.5rem;
}

.stat-tile {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.3rem 1.4rem;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

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

.stat-tile-icon {
    width: 38px;
    height: 38px;
    border-radius: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-500), var(--primary-700));
    color: #fff;
    font-size: 1rem;
    box-shadow: var(--shadow-brand);
}

.stat-tile-label { font-size: 0.8rem; color: var(--text-muted); font-weight: 500; }
.stat-tile-value { font-size: 1.55rem; font-weight: 700; letter-spacing: -0.02em; }
.stat-tile-delta { font-size: 0.78rem; font-weight: 600; display: flex; align-items: center; gap: 0.3rem; }
.stat-tile-delta.up { color: var(--success-color); }
.stat-tile-delta.down { color: var(--danger-color); }

.chart-legend { display: flex; gap: 1.25rem; align-items: center; flex-wrap: wrap; margin-bottom: 0.5rem; }
.chart-legend span { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.8rem; color: var(--text-secondary); font-weight: 500; }
.chart-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

.chart-wrap { position: relative; height: 320px; }

/* Filter bar */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: flex-end;
    margin-bottom: 1.4rem;
}

.filter-bar .form-group { margin-bottom: 0; min-width: 160px; }
.filter-bar .form-group input { padding: 0.55rem 0.8rem; font-size: 0.88rem; }

.btn-filter {
    background: linear-gradient(135deg, var(--primary-500), var(--primary-700));
    color: #fff;
    border: none;
    border-radius: var(--radius-md);
    padding: 0.6rem 1.3rem;
    font-family: var(--font-family);
    font-size: 0.88rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: var(--shadow-brand);
    height: 40px;
}

/* Data table */
.table-scroll { overflow-x: auto; }

.data-table { width: 100%; min-width: 640px; border-collapse: collapse; font-size: 0.87rem; table-layout: fixed; }

.data-table thead th {
    text-align: left;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.65rem 0.7rem;
    border-bottom: 1.5px solid var(--border-color);
    white-space: nowrap;
}

.data-table tbody td {
    padding: 0.7rem 0.7rem;
    border-bottom: 1px solid var(--border-color);
    overflow: hidden;
    text-overflow: ellipsis;
}

.data-table td.wrap { white-space: normal; overflow-wrap: anywhere; }

.data-table tbody tr:hover { background: var(--primary-50); }
.data-table tbody tr:last-child td { border-bottom: none; }

.badge {
    display: inline-block;
    padding: 0.22rem 0.65rem;
    border-radius: 999px;
    font-size: 0.74rem;
    font-weight: 700;
}

.badge-neutral { background: #eef0f5; color: var(--text-secondary); }
.badge-success { background: var(--success-tint); color: var(--success-color); }
.badge-warning { background: var(--warning-tint); color: var(--warning-color); }
.badge-danger { background: var(--danger-tint); color: var(--danger-color); }

/* Login */
.login-page, .registro-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    background: radial-gradient(circle at 15% 15%, var(--primary-600), var(--primary-700) 45%, #7a0f0b 100%);
    padding: 1.5rem;
}

.login-page::before, .registro-page::before,
.login-page::after, .registro-page::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    filter: blur(60px);
    opacity: 0.35;
}

.login-page::before, .registro-page::before {
    width: 420px; height: 420px;
    background: #ff6b61;
    top: -120px; left: -120px;
}

.login-page::after, .registro-page::after {
    width: 380px; height: 380px;
    background: #ffb199;
    bottom: -140px; right: -100px;
}

.login-card, .registro-card {
    background: rgba(255, 255, 255, 0.97);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 380px;
    padding: 2.6rem 2.1rem;
    text-align: center;
    position: relative;
    z-index: 1;
    animation: rise-in 0.45s var(--ease);
}

.registro-card { max-width: 460px; }

@keyframes rise-in {
    from { opacity: 0; transform: translateY(14px); }
    to { opacity: 1; transform: translateY(0); }
}

.login-card img { height: 44px; margin-bottom: 0.6rem; filter: drop-shadow(0 4px 10px rgb(232 38 30 / 0.25)); }
.login-card h1 { font-size: 1.05rem; font-weight: 500; color: var(--text-secondary); margin-bottom: 1.75rem; }

.form-group { text-align: left; margin-bottom: 1.1rem; }
.form-group label { display: block; font-size: 0.82rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 0.4rem; }

.form-group input {
    width: 100%;
    padding: 0.7rem 0.9rem;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-md);
    font-family: var(--font-family);
    font-size: 0.95rem;
    transition: border-color 0.18s var(--ease), box-shadow 0.18s var(--ease);
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px var(--primary-tint);
}

.btn-primary {
    width: 100%;
    background: linear-gradient(135deg, var(--primary-500), var(--primary-700));
    color: #fff;
    border: none;
    border-radius: var(--radius-md);
    padding: 0.8rem;
    font-family: var(--font-family);
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: var(--shadow-brand);
    transition: transform 0.15s var(--ease), box-shadow 0.15s var(--ease), filter 0.15s var(--ease);
}

.btn-primary:hover { filter: brightness(1.06); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }

.login-note { margin-top: 1.5rem; font-size: 0.78rem; color: var(--text-muted); }

.alert {
    text-align: left;
    border-radius: var(--radius-md);
    padding: 0.7rem 0.95rem;
    font-size: 0.85rem;
    margin-bottom: 1.1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    animation: rise-in 0.25s var(--ease);
}

.alert-error, .alert-danger { background: var(--danger-tint); color: var(--danger-color); border: 1px solid #fecaca; }
.alert-success { background: var(--success-tint); color: var(--success-color); border: 1px solid #a7f3d0; }

/* Registro facial */
.registro-card img.logo { height: 40px; margin-bottom: 0.75rem; filter: drop-shadow(0 4px 10px rgb(232 38 30 / 0.25)); }
.registro-card h1 { font-size: 1.1rem; font-weight: 700; color: var(--text-primary); margin-bottom: 0.4rem; letter-spacing: -0.01em; }
.registro-card p.subtitulo { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 1.5rem; }

.camara-video-wrap {
    border-radius: var(--radius-md);
    overflow: hidden;
    background: #0f172a;
    margin-bottom: 1rem;
    box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.06);
}

.camara-video-wrap video { width: 100%; display: block; transform: scaleX(-1); }

.camara-slots { display: flex; gap: 0.75rem; justify-content: center; margin-bottom: 1.25rem; }

.camara-thumb {
    width: 72px;
    height: 72px;
    border-radius: var(--radius-md);
    border: 2px dashed var(--border-color-strong);
    background-size: cover;
    background-position: center;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 0.75rem;
    transition: border-color 0.18s var(--ease), transform 0.15s var(--ease);
}

.camara-thumb:hover { transform: scale(1.04); }
.camara-thumb.filled { border-style: solid; border-color: var(--success-color); }

.btn-secondary {
    width: 100%;
    background-color: #fff;
    color: var(--primary-700);
    border: 1.5px solid var(--primary-200);
    border-radius: var(--radius-md);
    padding: 0.72rem;
    font-family: var(--font-family);
    font-size: 0.92rem;
    font-weight: 700;
    cursor: pointer;
    margin-bottom: 0.85rem;
    transition: background-color 0.15s var(--ease), transform 0.15s var(--ease);
}

.btn-secondary:hover { background-color: var(--primary-50); }
.btn-secondary:disabled, .btn-primary:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.status-icon {
    width: 64px; height: 64px;
    margin: 0 auto 1.1rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.7rem;
    font-style: normal;
}

.status-icon.pendiente { color: var(--warning-color); background: var(--warning-tint); }
.status-icon.rechazado { color: var(--danger-color); background: var(--danger-tint); }
.status-icon.ok { color: var(--success-color); background: var(--success-tint); }

/* Responsive */
@media (max-width: 991px) {
    .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .sidebar-toggle { display: inline-flex; }
    .sidebar-overlay.open { display: block; }
}

@media (max-width: 575px) {
    .content { padding: 1.1rem; }
    .card { padding: 1.15rem; border-radius: var(--radius-md); }
    .topbar { padding: 0 1rem; }
    .login-card, .registro-card { padding: 2rem 1.4rem; }
    .stat-grid { grid-template-columns: 1fr 1fr; gap: 0.75rem; }
    .stat-tile { padding: 1rem; }
    .topbar-user span.name-text { display: none; }
}
