:root {
    --primary: #1e3c72;
    --primary-light: #2a5298;
    --secondary: #7cb342;
    --danger: #e74c3c;
    --warning: #f39c12;
    --success: #27ae60;
    --text-dark: #2c3e50;
    --text-light: #7f8c8d;
    --border-color: #e0e0e0;
    --bg-light: #f5f7fa;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg-light);
    color: var(--text-dark);
}

/* Login Screen */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    padding: 2rem;
}

.login-box {
    background: white;
    padding: 3rem;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    width: 100%;
    max-width: 450px;
    animation: fadeInUp 0.5s ease;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.login-logo {
    text-align: center;
    margin-bottom: 2rem;
}

.login-logo h1 {
    color: var(--primary);
    font-size: 2.5em;
    margin-bottom: 0.5rem;
}

.login-logo p {
    color: var(--text-light);
    font-size: 0.95em;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-dark);
    font-weight: 500;
}

.form-group input {
    width: 100%;
    padding: 0.9rem;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    font-size: 1em;
    transition: all 0.3s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(30, 60, 114, 0.1);
}

.btn {
    width: 100%;
    padding: 1rem;
    border: none;
    border-radius: 10px;
    font-size: 1.1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-light);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(30, 60, 114, 0.3);
}

.error-message {
    background: linear-gradient(135deg, #fee 0%, #fdd 100%);
    color: var(--danger);
    padding: 1rem 1.2rem;
    border-radius: 10px;
    margin-bottom: 1rem;
    display: none;
    border-left: 4px solid var(--danger);
    font-size: 0.95em;
    line-height: 1.5;
    box-shadow: 0 2px 10px rgba(231, 76, 60, 0.2);
    animation: slideInDown 0.3s ease;
}

@keyframes slideInDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.error-message.show {
    display: block;
}

.error-message::before {
    content: '';
    display: inline-block;
    margin-right: 0.5rem;
}

/* Dashboard Layout */
.dashboard {
    display: none;
}

.dashboard.active {
    display: block;
}

.dashboard-header {
    background: white;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.dashboard-logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.dashboard-logo h2 {
    color: var(--primary);
    font-size: 1.8em;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: var(--secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 1.2em;
}

.btn-logout {
    padding: 0.6rem 1.2rem;
    background: var(--danger);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s;
}

.btn-logout:hover {
    background: #c0392b;
    transform: translateY(-2px);
}

.dashboard-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: white;
    padding: 1.8rem;
    border-radius: 15px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    transition: all 0.3s;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.12);
}

.stat-icon {
    font-size: 2.5em;
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 2.5em;
    font-weight: bold;
    color: var(--primary);
    margin-bottom: 0.3rem;
}

.stat-label {
    color: var(--text-light);
    font-size: 0.95em;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.section-header h3 {
    font-size: 1.8em;
    color: var(--primary);
}

.btn-add {
    padding: 0.8rem 1.5rem;
    background: var(--secondary);
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s;
}

.btn-add:hover {
    background: #689f38;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(124, 179, 66, 0.3);
}

.tabs {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    border-bottom: 2px solid var(--border-color);
}

.tab {
    padding: 1rem 2rem;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-size: 1.1em;
    font-weight: 600;
    color: var(--text-light);
    transition: all 0.3s;
}

.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.tab:hover {
    color: var(--primary);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Payment Sub-tabs */
.payment-subtab {
    padding: 0.8rem 1.5rem;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-size: 1em;
    font-weight: 600;
    color: var(--text-light);
    transition: all 0.3s;
}

.payment-subtab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.payment-subtab:hover {
    color: var(--primary);
}

.payment-subtab-content {
    display: none;
}

.payment-subtab-content.active {
    display: block;
}

.data-table {
    background: white;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead {
    background: var(--primary);
    color: white;
}

th {
    padding: 1.2rem;
    text-align: left;
    font-weight: 600;
}

td {
    padding: 1.2rem;
    border-bottom: 1px solid var(--border-color);
}

tbody tr:hover {
    background: var(--bg-light);
}

.badge {
    display: inline-block;
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-size: 0.85em;
    font-weight: 600;
}

.badge-active {
    background: #d4edda;
    color: #155724;
}

.badge-inactive {
    background: #f8d7da;
    color: #721c24;
}

.badge-online {
    background: #d1ecf1;
    color: #0c5460;
}

.action-buttons {
    display: flex;
    gap: 0.5rem;
}

.btn-icon {
    padding: 0.5rem 0.8rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9em;
    transition: all 0.3s;
}

.btn-edit {
    background: #3498db;
    color: white;
}

.btn-edit:hover {
    background: #2980b9;
}

.btn-delete {
    background: var(--danger);
    color: white;
}

.btn-delete:hover {
    background: #c0392b;
}

.btn-assign {
    background: var(--warning);
    color: white;
}

.btn-assign:hover {
    background: #e67e22;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 20px;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    padding: 2rem;
    border-bottom: 2px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 1.8em;
    color: var(--primary);
}

.btn-close {
    background: none;
    border: none;
    font-size: 2em;
    cursor: pointer;
    color: var(--text-light);
    transition: all 0.3s;
}

.btn-close:hover {
    color: var(--danger);
    transform: rotate(90deg);
}

.modal-body {
    padding: 2rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

select {
    width: 100%;
    padding: 0.9rem;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    font-size: 1em;
    transition: all 0.3s;
}

select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(30, 60, 114, 0.1);
}

textarea {
    width: 100%;
    padding: 0.9rem;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    font-size: 1em;
    font-family: inherit;
    resize: vertical;
    min-height: 100px;
    transition: all 0.3s;
}

textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(30, 60, 114, 0.1);
}

.modal-footer {
    padding: 1.5rem 2rem;
    border-top: 2px solid var(--border-color);
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
}

.btn-secondary {
    padding: 0.8rem 1.5rem;
    background: var(--text-light);
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s;
}

.btn-secondary:hover {
    background: #636e72;
}

.btn-save {
    padding: 0.8rem 1.5rem;
    background: var(--secondary);
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s;
}

.btn-save:hover {
    background: #689f38;
}

.device-select-list {
    max-height: 300px;
    overflow-y: auto;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    padding: 1rem;
}

.device-checkbox {
    display: flex;
    align-items: center;
    padding: 0.8rem;
    margin-bottom: 0.5rem;
    border-radius: 8px;
    transition: all 0.3s;
}

.device-checkbox:hover {
    background: var(--bg-light);
}

.device-checkbox input {
    margin-right: 1rem;
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.device-info {
    flex: 1;
}

.device-name {
    font-weight: 600;
    color: var(--text-dark);
}

.device-id {
    font-size: 0.85em;
    color: var(--text-light);
}

/* Responsive */
@media (max-width: 768px) {
    .form-row {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .tabs {
        overflow-x: auto;
    }

    .data-table {
        overflow-x: auto;
    }

    table {
        min-width: 600px;
    }
}

/* Tarjetas Financieras - Efecto Hover */
.financial-card {
    cursor: default;
}

.financial-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2) !important;
}

/* Animación de entrada para las tarjetas */
@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.financial-card {
    animation: slideInUp 0.6s ease forwards;
}

.financial-card:nth-child(1) {
    animation-delay: 0.1s;
}

.financial-card:nth-child(2) {
    animation-delay: 0.2s;
}

.financial-card:nth-child(3) {
    animation-delay: 0.3s;
}

/* ========== SIDEBAR LAYOUT ========== */
.app-container {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 250px;
    background: linear-gradient(180deg, var(--primary) 0%, #0f2a4a 100%);
    color: white;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 1000;
    transition: width 0.3s ease;
}

.sidebar-header {
    padding: 1.5rem;
    text-align: center;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-header h1 {
    font-size: 1.5em;
    margin-bottom: 0.5rem;
}

.sidebar-header p {
    font-size: 0.85em;
    opacity: 0.8;
}

.sidebar-nav {
    padding: 1rem 0;
}

.sidebar-link {
    display: flex;
    align-items: center;
    padding: 0.9rem 1.5rem;
    color: rgba(255,255,255,0.85);
    text-decoration: none;
    transition: all 0.3s ease;
    border-left: 3px solid transparent;
}

.sidebar-link:hover {
    background: rgba(255,255,255,0.1);
    color: white;
    border-left-color: var(--secondary);
}

.sidebar-link.active {
    background: rgba(255,255,255,0.15);
    color: white;
    border-left-color: var(--secondary);
}

.sidebar-icon {
    font-size: 1.2em;
    margin-right: 0.75rem;
    width: 24px;
    text-align: center;
}

.sidebar-text {
    font-weight: 500;
}

.main-wrapper {
    flex: 1;
    margin-left: 250px;
    display: flex;
    flex-direction: column;
}

.main-header {
    background: white;
    padding: 1rem 2rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    display: flex;
    justify-content: flex-end;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

#mainContent {
    flex: 1;
    padding: 2rem;
    background: var(--bg-light);
    overflow-y: auto;
}

.loading-spinner {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 200px;
    font-size: 1.2em;
    color: var(--text-light);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .sidebar {
        width: 60px;
    }
    .sidebar-text {
        display: none;
    }
    .sidebar-header h1 {
        font-size: 1em;
    }
    .sidebar-header p {
        display: none;
    }
    .main-wrapper {
        margin-left: 60px;
    }
}
