/* ========================================
   MARCAS ADMIN PANEL - ESTILOS GLOBALES
   ======================================== */

/* === VARIABLES CSS === */
:root {
    /* Colores principales */
    --primary-color: #72cb10;
    --primary-dark: #5fa80d;
    --primary-light: #8fd93a;
    
    /* Colores de estado */
    --success-color: #10B981;
    --warning-color: #F59E0B;
    --danger-color: #EF4444;
    --info-color: #06B6D4;
    
    /* Grises */
    --gray-50: #F9FAFB;
    --gray-100: #F3F4F6;
    --gray-200: #E5E7EB;
    --gray-300: #D1D5DB;
    --gray-400: #9CA3AF;
    --gray-500: #6B7280;
    --gray-600: #4B5563;
    --gray-700: #374151;
    --gray-800: #1F2937;
    --gray-900: #111827;
    
    /* Layout */
    --sidebar-width: 260px;
    --topbar-height: 64px;
    
    /* Sombras */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    
    /* Bordes */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    
    /* Fuente */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* === RESET Y BASE === */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    font-size: 14px;
    line-height: 1.5;
    color: var(--gray-800);
    background-color: var(--gray-50);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    outline: none;
}

input, textarea, select {
    font-family: inherit;
    font-size: inherit;
    outline: none;
}

/* === PÁGINA DE LOGIN === */
[hidden] { display: none !important; }

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background: #021849;
}

.login-container {
    width: min(420px, 92vw);
}

.login-card {
    width: 100%;
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
    padding: 32px;
}

.login-brand {
    display: flex;
    justify-content: center;
    margin-bottom: 18px;
}
.login-brand-img {
    width: 72px;
    height: 72px;
    display: block;
}

.login-header {
    margin-bottom: 8px;
}

.login-header .logo {
    display: none;
}

.login-header h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 4px;
}

.login-header p {
    font-size: 14px;
    color: var(--gray-500);
    margin-bottom: 24px;
}

.login-form {
    margin-bottom: 0;
}

.login-form .form-group {
    margin-bottom: 0;
}

.login-card label,
.login-form .form-group label {
    display: block;
    font-weight: 600;
    margin: 12px 0 6px;
}

.login-card input,
.login-form .form-group input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--gray-200);
    border-radius: 8px;
}

.login-card > form > button,
.login-card .btn-block {
    width: 100%;
    margin-top: 18px;
    background: var(--primary-color);
    color: #fff;
    border: 0;
    border-radius: 8px;
    padding: 10px 16px;
    font-weight: 600;
    cursor: pointer;
    justify-content: center;
}

.login-footer {
    display: none;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 8px;
}

.form-group-checkbox label.checkbox-inline {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    width: fit-content;
    max-width: 100%;
    margin-bottom: 0;
    padding: 10px 12px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    cursor: pointer;
}

.form-group-checkbox label.checkbox-inline input[type="checkbox"] {
    width: 16px;
    height: 16px;
    min-width: 16px;
    margin: 0;
    flex-shrink: 0;
}

.form-group-checkbox label.checkbox-inline span {
    line-height: 1.4;
}

.form-group input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-md);
    font-size: 14px;
    transition: all 0.2s;
}

.form-group input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(114, 203, 16, 0.18);
}

.error-message {
    padding: 12px;
    background-color: #FEE2E2;
    color: #991B1B;
    border-radius: var(--radius-md);
    font-size: 14px;
    margin-bottom: 16px;
}

.login-footer {
    text-align: center;
    color: var(--gray-500);
    font-size: 12px;
}

/* === BOTONES === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 500;
    border-radius: var(--radius-md);
    transition: all 0.2s;
    gap: 8px;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

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

.btn-success {
    background-color: var(--success-color);
    color: white;
}

.btn-danger {
    background-color: var(--danger-color);
    color: white;
}

.btn-secondary {
    background-color: var(--gray-200);
    color: var(--gray-700);
}

.btn-secondary:hover:not(:disabled) {
    background-color: var(--gray-300);
}

.btn-block {
    width: 100%;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

/* === SPINNER === */
.spinner {
    animation: rotate 2s linear infinite;
    width: 20px;
    height: 20px;
}

.spinner .path {
    stroke: currentColor;
    stroke-linecap: round;
    animation: dash 1.5s ease-in-out infinite;
}

@keyframes rotate {
    100% { transform: rotate(360deg); }
}

@keyframes dash {
    0% {
        stroke-dasharray: 1, 150;
        stroke-dashoffset: 0;
    }
    50% {
        stroke-dasharray: 90, 150;
        stroke-dashoffset: -35;
    }
    100% {
        stroke-dasharray: 90, 150;
        stroke-dashoffset: -124;
    }
}

/* === LAYOUT DEL PANEL === */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* === SIDEBAR === */
.sidebar {
    width: var(--sidebar-width);
    background-color: white;
    border-right: 1px solid var(--gray-200);
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    z-index: 100;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--gray-200);
}

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

.sidebar-logo-img {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    object-fit: cover;
    display: block;
}

.sidebar-logo h1 {
    font-size: 18px;
    font-weight: 700;
    color: var(--gray-900);
}

.sidebar-nav {
    flex: 1;
    padding: 20px 0;
    overflow-y: auto;
}

.nav-section {
    margin-bottom: 24px;
}

.nav-section-title {
    padding: 0 20px;
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    color: var(--gray-700);
    font-weight: 500;
    transition: all 0.2s;
    cursor: pointer;
}

.nav-item:hover {
    background-color: var(--gray-50);
    color: var(--primary-color);
}

.nav-item.active {
    background-color: var(--primary-color);
    color: white;
    border-left: 3px solid var(--primary-dark);
}

.nav-item svg {
    width: 20px;
    height: 20px;
}

.nav-badge {
    margin-left: auto;
    background-color: var(--danger-color);
    color: white;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 12px;
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid var(--gray-200);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 14px;
}

.user-details {
    flex: 1;
}

.user-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-900);
}

.user-company {
    font-size: 12px;
    color: var(--gray-500);
}

.btn-logout {
    width: 100%;
    padding: 10px;
    background-color: var(--gray-100);
    color: var(--gray-700);
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-logout:hover {
    background-color: var(--gray-200);
}

/* === MAIN CONTENT === */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
}

.topbar {
    height: var(--topbar-height);
    background-color: white;
    border-bottom: 1px solid var(--gray-200);
    padding: 0 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 90;
}

.topbar-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--gray-900);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.content-wrapper {
    flex: 1;
    padding: 32px;
    overflow-y: auto;
}

/* === CARDS === */
.card {
    background-color: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
    padding: 24px;
    margin-bottom: 24px;
}

.card-header {
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}

.card-header .card-title {
    flex: 1 1 200px;
    min-width: 0;
}

.card-header .btn {
    flex: 0 1 auto;
    max-width: 100%;
}

.card-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--gray-900);
}

.card-body {
    /* Contenido */
}

/* === STATS GRID === */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background-color: white;
    border-radius: var(--radius-lg);
    padding: 20px;
    border: 1px solid var(--gray-200);
    box-shadow: var(--shadow-sm);
    transition: all 0.2s;
}

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

.stat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.stat-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-icon.primary { background-color: #ecfccb; color: var(--primary-color); }
.stat-icon.success { background-color: #D1FAE5; color: var(--success-color); }
.stat-icon.warning { background-color: #FEF3C7; color: var(--warning-color); }
.stat-icon.danger { background-color: #FEE2E2; color: var(--danger-color); }

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 4px;
}

.stat-label {
    font-size: 14px;
    color: var(--gray-600);
}

.stat-hint {
    font-size: 12px;
    color: var(--gray-500);
    margin-top: 4px;
    line-height: 1.35;
}

/* === TABLES === */
.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead {
    background-color: var(--gray-50);
    border-bottom: 2px solid var(--gray-200);
}

th {
    padding: 12px 16px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-700);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

td {
    padding: 16px;
    border-bottom: 1px solid var(--gray-200);
    color: var(--gray-800);
}

tr:last-child td {
    border-bottom: none;
}

.btn-icon-verificacion {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 8px;
    border: 1px solid var(--gray-200);
    background: #fff;
    color: var(--gray-700);
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.btn-icon-verificacion:hover {
    transform: translateY(-1px);
    border-color: #1e3a5f;
    color: #1e3a5f;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.btn-icon-verificacion.fichaje-verificacion-alerta {
    border-color: #dc2626;
    color: #dc2626;
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.25);
}

.fichaje-verificacion-huella {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    color: var(--gray-500);
    cursor: default;
}

.stat-card-clickable {
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.stat-card-clickable:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
}

.foto-modal-revision {
    color: #dc2626;
    font-weight: 600;
}

tbody tr {
    transition: background-color 0.2s;
}

tbody tr:hover {
    background-color: var(--gray-50);
}

/* === BADGES === */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.badge-success {
    background-color: #D1FAE5;
    color: #065F46;
}

.badge-warning {
    background-color: #FEF3C7;
    color: #92400E;
}

.badge-danger {
    background-color: #FEE2E2;
    color: #991B1B;
}

.badge-info {
    background-color: #E0F2FE;
    color: #075985;
}

.badge-gray {
    background-color: var(--gray-200);
    color: var(--gray-700);
}

/* === PAGINATION === */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 24px;
}

.pagination button {
    padding: 8px 12px;
    border: 1px solid var(--gray-300);
    background-color: white;
    border-radius: var(--radius-md);
    color: var(--gray-700);
    font-weight: 500;
    transition: all 0.2s;
}

.pagination button:hover:not(:disabled) {
    background-color: var(--gray-50);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination button.active {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.empleado-estado-group {
    padding: 16px;
    background-color: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
}

.empleado-estado-group label {
    font-weight: 600;
}

th.sortable {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

th.sortable:hover {
    color: var(--primary-color);
}

th.sortable.active {
    color: var(--primary-color);
}

.sort-icon {
    margin-left: 4px;
    font-size: 12px;
}

.sort-icon-muted {
    opacity: 0.35;
}

/* === MODAL === */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background-color: white;
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    padding: 24px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.modal-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--gray-900);
    flex: 1 1 auto;
    min-width: 0;
}

.modal-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: var(--gray-100);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.modal-close:hover {
    background-color: var(--gray-200);
}

.modal-body {
    padding: 24px;
    max-height: calc(90vh - 160px);
    overflow-y: auto;
}

.foto-modal-frame {
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    min-height: 220px;
    max-height: 70vh;
}

.foto-rotado-izq {
    display: none;
    transform: rotate(-90deg);
    transform-origin: center center;
    max-height: min(90vw, 520px);
    max-width: 70vh;
    border-radius: 8px;
}

.modal-footer {
    padding: 24px;
    border-top: 1px solid var(--gray-200);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* === FILTERS === */
.filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(160px, 100%), 1fr));
    gap: 12px;
    align-items: end;
    margin-bottom: 20px;
}

.filter-group {
    min-width: 0;
    width: auto;
}

.filter-search {
    min-width: 0;
}

.locales-checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(140px, 100%), 1fr));
    gap: 10px;
}

.checkbox-inline {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    cursor: pointer;
}

.checkbox-inline input {
    margin: 0;
}

.timestamp-cell {
    min-width: 180px;
}

/* === EMPTY STATE === */
.empty-state {
    text-align: center;
    padding: 60px 20px;
}

.empty-state-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    color: var(--gray-400);
}

.empty-state-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--gray-900);
    margin-bottom: 8px;
}

.empty-state-text {
    font-size: 14px;
    color: var(--gray-600);
}

/* === LOADING === */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

/* === UTILITIES === */
.hidden { display: none !important; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.gap-2 { gap: 16px; }

/* === LOCALES MODULE === */
.color-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.color-swatch {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    padding: 0;
}

.color-swatch:hover {
    transform: scale(1.08);
}

.color-swatch.selected {
    border-color: var(--gray-900);
    box-shadow: 0 0 0 2px white, 0 0 0 4px var(--gray-900);
}

.local-color-badge {
    font-weight: 600;
}

.locales-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.local-card {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: all 0.2s;
}

.local-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--gray-300);
}

.local-card.local-inactive {
    opacity: 0.6;
    background: var(--gray-50);
}

.local-card-header {
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    border-bottom: 1px solid var(--gray-100);
}

.local-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
}

.local-card-body {
    padding: 16px;
}

.local-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--gray-900);
    margin-bottom: 4px;
}

.local-address {
    font-size: 13px;
    color: var(--gray-500);
    margin-bottom: 12px;
}

.local-details {
    display: flex;
    gap: 16px;
}

.local-detail {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--gray-600);
}

.local-card-footer {
    padding: 12px 16px;
    background: var(--gray-50);
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

/* Modal large para mapa */
.modal-large {
    max-width: 800px;
}

/* Mapa */
.local-map {
    height: 350px;
    border-radius: var(--radius-md);
    border: 1px solid var(--gray-300);
    z-index: 1;
}

.form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 0;
}

.form-row .form-group {
    flex: 1 1 180px;
    min-width: 0;
}

.form-group-sm {
    flex: 0 0 120px !important;
}

.address-search-row {
    display: flex;
    gap: 8px;
    align-items: stretch;
}

.address-search-row input {
    flex: 1 1 auto;
    min-width: 0;
}

.address-search-row .btn {
    flex: 0 0 auto;
    white-space: nowrap;
}

.form-hint {
    display: block;
    font-size: 12px;
    color: var(--gray-500);
    margin-top: 6px;
}

/* Empty state mejoras */
.empty-state svg {
    color: var(--gray-400);
    margin-bottom: 16px;
}

.empty-state .btn {
    margin-top: 16px;
}

/* Foto de perfil empleado */
.foto-perfil-preview {
    margin-bottom: 16px;
}

.foto-perfil-preview label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 8px;
}

.foto-perfil-preview img {
    max-width: 100%;
    max-height: 240px;
    border-radius: var(--radius-md);
    border: 1px solid var(--gray-200);
    object-fit: contain;
    background: var(--gray-50);
}

.checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-right: 16px;
    margin-bottom: 8px;
    font-size: 14px;
    flex: 1 1 180px;
}

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

.table-actions .btn-sm {
    white-space: nowrap;
}

.local-hours-item {
    font-size: 12px;
    margin-bottom: 4px;
    color: var(--gray-600);
}

/* === UBICACIÓN FICHAJES === */
.ubicacion-pin {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: none;
    background: transparent;
    cursor: default;
    vertical-align: middle;
}

.ubicacion-pin--bad {
    cursor: pointer;
}

.ubicacion-pin--bad:hover {
    transform: scale(1.08);
}

.ubicacion-indicator {
    display: inline-flex;
    align-items: center;
    margin-right: 6px;
    vertical-align: middle;
}

.ubicacion-indicator--bad {
    cursor: help;
}

.empleado-con-pin {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.fichaje-map {
    height: 320px;
    border-radius: var(--radius-md);
    border: 1px solid var(--gray-200);
    z-index: 1;
}

@media (max-width: 768px) {
    .fichaje-map {
        height: 240px;
    }
}

/* === FORM CONTROLS (inputs en módulos) === */
.form-control,
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-md);
    font-size: 14px;
    background-color: white;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus,
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(114, 203, 16, 0.18);
}

.filter-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 6px;
}

.filter-actions {
    grid-column: 1 / -1;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    width: 100%;
}

.filter-actions .btn {
    flex: 0 1 auto;
    min-width: 100px;
    max-width: 100%;
}

/* === TOPBAR LAYOUT === */
.topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.sidebar-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    background-color: var(--gray-100);
    color: var(--gray-700);
    flex-shrink: 0;
    transition: background-color 0.2s;
}

.sidebar-toggle:hover {
    background-color: var(--gray-200);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background-color: rgba(17, 24, 39, 0.45);
    z-index: 95;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.topbar-date {
    font-size: 13px;
    color: var(--gray-600);
    text-align: right;
}

/* Títulos duplicados dentro del contenido (ya están en topbar) */
.content-wrapper .topbar-title,
.dashboard > .topbar-title {
    display: none;
}

/* Scroll suave en tablas */
.table-container {
    -webkit-overflow-scrolling: touch;
    margin: 0 -4px;
    padding: 0 4px;
}

@media (max-width: 768px) {
    .table-container::before {
        content: 'Desliza horizontalmente para ver más columnas';
        display: block;
        font-size: 12px;
        color: var(--gray-500);
        margin-bottom: 8px;
    }

    .table-container table {
        min-width: 640px;
    }
}

/* Evitar zoom en iOS al enfocar inputs */
@media (max-width: 768px) {
    .form-control,
    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 16px;
    }
}

/* === RESPONSIVE: TABLET === */
@media (max-width: 1024px) {
    :root {
        --sidebar-width: 260px;
    }

    .content-wrapper {
        padding: 24px 20px;
    }

    .topbar {
        padding: 0 20px;
    }

    .card {
        padding: 20px;
    }

    .card-header .btn {
        white-space: normal;
    }

    .modal-large {
        max-width: 95%;
    }

    .local-map {
        height: 280px;
    }

    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    }
}

/* === RESPONSIVE: MÓVIL === */
@media (max-width: 768px) {
    .sidebar-toggle {
        display: inline-flex;
    }

    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        box-shadow: none;
    }

    body.sidebar-open .sidebar {
        transform: translateX(0);
        box-shadow: var(--shadow-lg);
    }

    body.sidebar-open .sidebar-overlay {
        display: block;
        opacity: 1;
    }

    body.sidebar-open {
        overflow: hidden;
    }

    .main-content {
        margin-left: 0;
        width: 100%;
    }

    .topbar {
        height: auto;
        min-height: var(--topbar-height);
        padding: 12px 16px;
        gap: 8px;
    }

    .topbar-title {
        font-size: 17px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .topbar-actions {
        flex-shrink: 0;
    }

    .topbar-date {
        font-size: 11px;
        max-width: 120px;
        line-height: 1.3;
    }

    .content-wrapper {
        padding: 16px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
        margin-bottom: 20px;
    }

    .stat-card {
        padding: 14px;
    }

    .stat-value {
        font-size: 22px;
    }

    .stat-label {
        font-size: 12px;
    }

    .card {
        padding: 16px;
        margin-bottom: 16px;
        border-radius: var(--radius-md);
    }

    .card-header {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        margin-bottom: 16px;
    }

    .card-header .btn {
        width: 100%;
    }

    .card-title {
        font-size: 16px;
    }

    .filters {
        grid-template-columns: 1fr;
    }

    .filter-actions .btn {
        flex: 1 1 calc(50% - 4px);
    }

    .form-row {
        flex-direction: column;
        gap: 0;
    }

    .form-row .form-group {
        flex: 1 1 auto;
        width: 100%;
    }

    .checkbox-label {
        flex: 1 1 100%;
        margin-right: 0;
    }

    .table-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .table-actions .btn-sm {
        width: 100%;
        white-space: normal;
    }

    .locales-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .local-card-footer {
        flex-wrap: wrap;
    }

    .local-card-footer .btn {
        flex: 1;
        min-width: calc(50% - 4px);
    }

    .local-details {
        flex-direction: column;
        gap: 8px;
    }

    th, td {
        padding: 10px 12px;
        font-size: 13px;
    }

    th {
        font-size: 11px;
    }

    .timestamp-cell {
        min-width: 140px;
    }

    .btn-icon-verificacion,
    .fichaje-verificacion-huella {
        width: 40px;
        height: 40px;
    }

    .modal {
        padding: 12px;
        align-items: flex-end;
    }

    .modal-content {
        width: 100%;
        max-width: 100%;
        max-height: 92vh;
        border-bottom-left-radius: 0;
        border-bottom-right-radius: 0;
    }

    .modal-large {
        max-width: 100%;
    }

    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 16px;
    }

    .modal-footer {
        flex-direction: column-reverse;
    }

    .modal-footer .btn {
        width: 100%;
    }

    .pagination {
        flex-wrap: wrap;
        gap: 6px;
    }

    .pagination button {
        padding: 8px 10px;
        font-size: 13px;
    }

    .empty-state {
        padding: 40px 16px;
    }

    .login-card {
        padding: 28px 20px;
    }

    .login-container {
        padding: 16px;
    }

    .btn {
        min-height: 44px;
    }

    .btn-sm {
        min-height: 36px;
    }

    .nav-item {
        padding: 12px 20px;
    }

    .user-name,
    .user-company {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .color-swatch {
        width: 32px;
        height: 32px;
    }

    .checkbox-inline {
        padding: 10px 12px;
    }

    .empleado-estado-group {
        padding: 12px;
    }
}

/* === PLANIFICACIONES === */
.planificaciones-module .filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.plan-dias-libres-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 8px;
    margin-top: 8px;
}

.plan-dia-libre-item {
    padding: 8px 10px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-secondary, #f8fafc);
}

.plan-locales-por-empleado {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.plan-empleado-locales-block {
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-secondary, #f8fafc);
}

.plan-empleado-locales-block strong {
    display: block;
    margin-bottom: 10px;
}

@media (min-width: 768px) {
    .planificaciones-module .filters {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (min-width: 900px) {
    .planificaciones-module .filters {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@media (max-width: 767px) {
    .planificaciones-module .filters {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .card-header {
        flex-direction: column;
        align-items: stretch;
    }

    .card-header .btn {
        width: 100%;
    }

    .filter-actions .btn {
        flex: 1 1 100%;
    }
}

/* === RESPONSIVE: MÓVIL PEQUEÑO === */
@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .topbar-date {
        display: none;
    }

    .stat-icon {
        width: 32px;
        height: 32px;
    }

    .stat-icon svg {
        width: 16px;
        height: 16px;
    }

    .sidebar-logo h1 {
        font-size: 16px;
    }

    .local-map {
        height: 220px;
    }

    .badge {
        font-size: 11px;
        padding: 3px 8px;
    }
}

/* Safe area para dispositivos con notch */
@supports (padding: max(0px)) {
    .topbar {
        padding-left: max(16px, env(safe-area-inset-left));
        padding-right: max(16px, env(safe-area-inset-right));
    }

    .content-wrapper {
        padding-bottom: max(16px, env(safe-area-inset-bottom));
    }

    .sidebar {
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* === CONFIGURACIÓN === */
.config-form {
    max-width: 560px;
}

.form-help {
    margin-top: 8px;
    font-size: 13px;
    color: var(--gray-500);
    line-height: 1.5;
}

.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 12px 20px;
    border-radius: var(--radius-md);
    background: var(--gray-800);
    color: white;
    font-size: 14px;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.3s, transform 0.3s;
    z-index: 9999;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast-success {
    background: var(--success);
}

.toast-error {
    background: var(--danger);
}

/* === INVENTARIO === */
.inventario-module .inventario-header {
    flex-wrap: wrap;
    gap: 12px;
}

.inventario-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    background: var(--gray-100);
    padding: 4px;
    border-radius: var(--radius-md);
}

.inventario-tab {
    border: none;
    background: transparent;
    color: var(--gray-600);
    font-size: 13px;
    font-weight: 500;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.inventario-tab:hover {
    color: var(--gray-900);
    background: var(--gray-200);
}

.inventario-tab.active {
    background: white;
    color: var(--gray-900);
    box-shadow: var(--shadow-sm);
}

.inventario-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-left: auto;
}

.inventario-module .text-muted {
    font-size: 12px;
    color: var(--gray-500);
    margin-top: 2px;
}

.inventario-module code {
    font-size: 12px;
    background: var(--gray-100);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    color: var(--gray-700);
}

.inventario-module .filter-group-checkbox {
    display: flex;
    align-items: flex-end;
    padding-bottom: 4px;
}

.inventario-module .pagination {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 16px;
}

.inventario-module .pagination-info {
    font-size: 13px;
    color: var(--gray-600);
}

@media (max-width: 768px) {
    .inventario-actions {
        width: 100%;
        margin-left: 0;
    }

    .inventario-actions .btn {
        flex: 1;
    }

    .inventario-tabs {
        width: 100%;
    }

    .inventario-tab {
        flex: 1;
        text-align: center;
        padding: 8px 6px;
        font-size: 12px;
    }
}

/* === Carga masiva de locales === */
.card-header-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.bulk-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.bulk-drop-zone {
    border: 2px dashed var(--gray-300);
    border-radius: var(--radius-md);
    padding: 28px 16px;
    text-align: center;
    cursor: pointer;
    background: var(--gray-50);
    transition: border-color 0.2s, background-color 0.2s;
    margin-bottom: 16px;
}

.bulk-drop-zone:hover,
.bulk-drop-zone.dragover {
    border-color: var(--primary-color);
    background: rgba(59, 130, 246, 0.06);
}

.bulk-drop-text {
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-700);
    margin: 0 0 6px;
}

.bulk-progress {
    margin-bottom: 16px;
}

.bulk-progress-bar {
    height: 8px;
    background: var(--gray-200);
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: 6px;
}

.bulk-progress-fill {
    height: 100%;
    background: var(--primary-color);
    border-radius: 999px;
    transition: width 0.2s ease;
}

.bulk-preview {
    margin-top: 8px;
}

.bulk-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.bulk-table th,
.bulk-table td {
    padding: 10px 8px;
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
    vertical-align: middle;
}

.bulk-table th {
    font-weight: 600;
    color: var(--gray-600);
    background: var(--gray-50);
    white-space: nowrap;
}

.bulk-table tr.bulk-row-error {
    background: rgba(239, 68, 68, 0.08);
}

.bulk-table tr.bulk-row-error td {
    color: var(--gray-700);
}

.bulk-table tr.bulk-row-warning {
    background: rgba(245, 158, 11, 0.1);
}

.bulk-table tr.bulk-row-warning td {
    color: var(--gray-700);
}

.bulk-color-swatch {
    display: inline-block;
    width: 18px;
    height: 18px;
    border-radius: 4px;
    border: 1px solid var(--gray-300);
    vertical-align: middle;
}

@media (max-width: 768px) {
    .card-header-actions {
        width: 100%;
        flex-direction: column;
    }

    .card-header-actions .btn {
        width: 100%;
    }

    .bulk-table th,
    .bulk-table td {
        padding: 8px 6px;
        font-size: 12px;
    }
}
