:root {
    --brand: #fe4d01;
    --brand-dark: #d94300;
    --accent: #28a745;
    --danger: #dc3545;
    --info-bg: #e6f7ff;
    --info-color: #096dd9;
    --border-light: #e0e0e0;
    --text-menu: #6c757d;
    --text-color: #222222;
    --bg-light: #f8f9fa;
    --sidebar-width: 260px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --transition: all 0.3s ease;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-light);
    color: var(--text-color);
    line-height: 1.6;
    overflow-x: hidden;
    zoom: 90%;
}

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

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: #ffffff;
    border-right: 1px solid var(--border-light);
    height: 110vh;
    position: fixed;
    left: 0;
    top: 0;
    z-index: 1000;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 0.5rem;
    text-align: center;
    border-bottom: 1px solid var(--border-light);
}

.logo {
    max-width: 80px;
    max-height: 80px;
    object-fit: contain;
}

.sidebar-close {
    display: none;
    background: none;
    border: none;
    color: var(--text-menu);
    font-size: 1.5rem;
    cursor: pointer;
    position: absolute;
    right: 1rem;
    top: 1rem;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
}

.sidebar-menu {
    list-style: none;
    padding: 0.5rem 0;
}

.menu-item a {
    display: flex;
    align-items: center;
    padding: 0.4rem 1.2rem;
    color: var(--text-menu);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
    border-left: 4px solid transparent;
    font-size: 0.85rem;
}

.menu-item a:hover,
.menu-item.active a {
    background: rgba(254, 77, 1, 0.05);
    color: var(--brand);
    border-left-color: var(--brand);
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 2rem;
    transition: var(--transition);
    min-width: 0;
    /* Prevent horizontal scroll in some flex layouts */
}

/* Mobile Header (Hidden by default) */
.mobile-header {
    display: none;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 950;
    backdrop-filter: blur(2px);
}

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

/* Cards & Stats */
.card {
    background: #ffffff;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}

.btn {
    display: inline-block;
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: var(--transition);
    border: none;
}

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

.btn-primary:hover {
    background: var(--brand-dark);
    transform: translateY(-1px);
}

/* Tables */
.table-container {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

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

/* Forms */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.form-control {
    width: 100%;
    padding: 0.8rem;
    border-radius: 8px;
    border: 1px solid var(--border-light);
    outline: none;
    transition: var(--transition);
}

.form-control:focus {
    border-color: var(--brand);
}

/* Modals */
dialog {
    max-width: 95vw;
    border: none;
    border-radius: 12px;
    box-shadow: var(--shadow);
}

/* Responsive */
@media (max-width: 768px) {
    .app-wrapper {
        display: block;
        /* Disable flex on mobile for simpler layout */
    }

    .sidebar {
        transform: translateX(-100%);
        box-shadow: 10px 0 30px rgba(0, 0, 0, 0.1);
        z-index: 1300;
        /* Sidebar on top */
        height: 100%;
    }

    .sidebar-overlay {
        z-index: 1200;
        /* Overlay below sidebar */
    }

    .main-content {
        margin-left: 0 !important;
        padding: 1rem;
        padding-top: 85px;
        /* Space for fixed header */
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .mobile-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        background: #ffffff;
        padding: 0 1rem;
        height: 70px;
        width: 100%;
        position: fixed;
        /* More reliable than sticky in Chrome */
        top: 0;
        left: 0;
        z-index: 1100;
        /* Header above content */
        border-bottom: 1px solid var(--border-light);
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    }

    .mobile-toggle {
        width: 50px;
        height: 70px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: none;
        border: none;
        color: var(--brand);
        font-size: 1.6rem;
        cursor: pointer;
        outline: none;
        -webkit-tap-highlight-color: transparent;
    }

    .mobile-logo-container {
        flex: 1;
        display: flex;
        justify-content: center;
        align-items: center;
        height: 70px;
    }

    .mobile-logo {
        height: 35px;
        width: auto;
        object-fit: contain;
    }

    .mobile-spacer {
        width: 50px;
    }

    /* Adjust cards for mobile */
    .card {
        padding: 1rem;
    }

    .dashboard-header {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 1rem;
    }

    .dashboard-header .btn {
        width: 100%;
        text-align: center;
    }

    /* 2 columns for stats on mobile */
    .stats-grid {
        grid-template-columns: 1fr 1fr !important;
        gap: 0.8rem !important;
    }

    .stats-grid .card {
        padding: 0.8rem !important;
    }

    .stats-grid .card div[style*="font-size: 2rem"] {
        font-size: 1.5rem !important;
    }

    .form-grid,
    .grid-stack-mobile {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }

    .modal-wide {
        width: 95vw !important;
        padding: 1rem !important;
    }

    .flex-mobile-column {
        flex-direction: column !important;
    }

    /* Hide some table columns on very small screens */
    @media (max-width: 480px) {
        .hide-mobile {
            display: none;
        }
    }
}

/* Footer (Fixed to bottom of content) */
.content-footer {
    margin-top: auto;
    padding: 1rem 0;
    border-top: 1px solid var(--border-light);
    font-size: 0.85rem;
    color: var(--text-menu);
    display: flex;
    display: flex;
    justify-content: space-between;
}

/* --- Módulo Clientes --- */
.clients-table tr th {
    padding: 1rem;
    color: var(--text-menu);
    border-bottom: 2px solid var(--border-light);
}

.clients-table tr td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-light);
}

.client-row-inactive {
    opacity: 0.6;
    background: #fdfdfd;
}

.status-badge {
    font-size: 0.8rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.status-badge.active {
    color: var(--accent);
}

.status-badge.inactive {
    color: var(--danger);
}

/* Modales Premium */
.modal-premium {
    padding: 0;
    border: none;
    border-radius: 14px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    margin: 4vh auto;
    overflow: hidden;
}

.modal-header-premium {
    padding: 1.2rem 1.8rem;
    background: var(--brand);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header-premium h3 {
    margin: 0;
    font-size: 1.25rem;
}

.modal-close-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    padding: 5px 10px;
    border-radius: 6px;
    cursor: pointer;
}

.modal-body-premium {
    padding: 1rem;
    overflow-y: auto;
}

.modal-footer-premium {
    padding: 1rem 2rem 1rem;
    background: #f9f9f9;
    border-top: 1px solid #eee;
    text-align: right;
    border-radius: 0 0 14px 14px;
}

/* Tabs */
.modal-tabs {
    display: flex;
    background: #f1f1f1;
    border-bottom: 1px solid #ddd;
}

.tab-btn {
    flex: 1;
    padding: 1rem;
    border: none;
    background: none;
    cursor: pointer;
    font-weight: 700;
    color: #666;
    border-bottom: 3px solid transparent;
    transition: 0.3s;
}

.tab-btn.active {
    color: var(--brand);
    border-bottom-color: var(--brand);
    background: white;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Stats Cards in Details */
.stat-card-detail {
    padding: 1.2rem;
    background: #fff;
    border-radius: 10px;
    border-left: 5px solid;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.stat-card-detail.services {
    border-left-color: var(--accent);
    background: #f6fff8;
}

.stat-card-detail.spent {
    border-left-color: var(--brand);
    background: #fffaf8;
}

.stat-card-detail .label {
    font-size: 0.75rem;
    color: #666;
    font-weight: 700;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.stat-card-detail .value {
    font-size: 2.2rem;
    font-weight: 800;
}

.stat-card-detail.services .value {
    color: #2d6a4f;
}

.stat-card-detail.spent .value {
    color: var(--brand);
}

/* History Table */
.history-scroll-container {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid #eee;
    border-radius: 8px;
    background: white;
}

.history-table thead {
    background: #f8f9fa;
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: 0 2px 2px rgba(0, 0, 0, 0.05);
}

.history-table th,
.history-table td {
    padding: 0.8rem;
    border-bottom: 1px solid #f0f0f0;
}

/* Switch Toggle */
.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 4px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--brand);
}

input:focus + .slider {
    box-shadow: 0 0 1px var(--brand);
}

input:checked + .slider:before {
    transform: translateX(26px);
}