:root {
    --sidebar-width: 210px;
    --sidebar-collapsed-width: 64px;
    --sidebar-bg: #172232;
    --sidebar-secondary: #202d3e;
    --sidebar-active: #2563eb;
    --sidebar-text: #d6deea;
    --sidebar-muted: #8290a3;
    --border-color: #dfe3e8;
    --page-bg: #f5f7fa;
    --text-color: #111827;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    background: var(--page-bg);
    color: var(--text-color);
    font-size: 13px;
}

.app-wrapper {
    min-height: 100vh;
    display: flex;
}

/* =====================================================
   SIDEBAR
===================================================== */

.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: #ffffff;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 200;
    border-right: 1px solid #263548;
    transition: width 0.2s ease;
}

.sidebar-brand {
    height: 76px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 10px;
    overflow: hidden;
    background: #eef4ff;
    border-right: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
}

.sidebar-logo {
    display: block;
    width: 100%;
    max-width: 185px;
    max-height: 58px;
    object-fit: contain;
}

.brand-icon {
    display: none;
    width: 36px;
    min-width: 36px;
    height: 36px;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: var(--sidebar-active);
    color: #ffffff;
    font-size: 17px;
    font-weight: 700;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.sidebar-menu {
    display: flex;
    flex-direction: column;
    flex: 1;
    padding: 10px 9px;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-section {
    margin-bottom: 10px;
}

.sidebar-section-title {
    padding: 7px 10px 5px;
    color: var(--sidebar-muted);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    white-space: nowrap;
}

.sidebar-link {
    height: 38px;
    display: flex;
    align-items: center;
    gap: 11px;
    margin-bottom: 3px;
    padding: 0 11px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 12px;
    border-radius: 6px;
    border-left: 0;
    white-space: nowrap;
    transition:
        background 0.15s ease,
        color 0.15s ease,
        transform 0.15s ease;
}

.sidebar-link:hover {
    background: var(--sidebar-secondary);
    color: #ffffff;
}

.sidebar-link.active {
    background: var(--sidebar-active);
    color: #ffffff;
    font-weight: 600;
    box-shadow: 0 4px 10px rgba(37, 99, 235, 0.2);
}

.sidebar-link.active::after {
    content: "";
    width: 4px;
    height: 4px;
    margin-left: auto;
    border-radius: 50%;
    background: #ffffff;
}

.sidebar-link i {
    width: 18px;
    min-width: 18px;
    text-align: center;
    font-size: 15px;
}

.sidebar-footer {
    padding: 8px 9px 12px;
    border-top: 1px solid #2c394a;
}

.sidebar-logout {
    margin: 0;
    color: #cbd5e1;
}

.sidebar-logout:hover {
    background: #3b2730;
    color: #fecaca;
}

.developer-signature {
    margin-top: 10px;
    padding: 10px 8px 2px;
    border-top: 1px solid #2c394a;
    color: #8290a3;
    font-size: 9px;
    line-height: 1.4;
    text-align: center;
}

.developer-signature span,
.developer-signature strong,
.developer-signature small {
    display: block;
}

.developer-signature strong {
    margin-top: 2px;
    color: #d6deea;
    font-size: 10px;
    font-weight: 600;
}

.developer-signature small {
    color: #8290a3;
    font-size: 9px;
}

/* =====================================================
   SIDEBAR CONTRAÍDO
===================================================== */

body.sidebar-collapsed .sidebar {
    width: var(--sidebar-collapsed-width);
}

body.sidebar-collapsed .main-area {
    margin-left: var(--sidebar-collapsed-width);
    width: calc(100% - var(--sidebar-collapsed-width));
}

body.sidebar-collapsed .sidebar-brand {
    justify-content: center;
    padding: 0;
}

body.sidebar-collapsed .sidebar-logo {
    display: none;
}

body.sidebar-collapsed .brand-icon {
    display: flex;
}

body.sidebar-collapsed .sidebar-section-title,
body.sidebar-collapsed .sidebar-link span,
body.sidebar-collapsed .developer-signature {
    display: none;
}

body.sidebar-collapsed .sidebar-menu {
    padding-left: 8px;
    padding-right: 8px;
}

body.sidebar-collapsed .sidebar-link {
    justify-content: center;
    padding: 0;
}

body.sidebar-collapsed .sidebar-link.active::after {
    display: none;
}

/* =====================================================
   ÁREA PRINCIPAL
===================================================== */

.main-area {
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    min-height: 100vh;
    transition:
        margin-left 0.2s ease,
        width 0.2s ease;
}

.topbar {
    height: 64px;
    background: #ffffff;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 18px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.menu-button {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    font-size: 21px;
    color: #475569;
    padding: 0;
}

.menu-button:hover {
    background: #f1f5f9;
    border-color: #e2e8f0;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #111827;
}

.user-avatar {
    width: 31px;
    height: 31px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #e8efff;
    color: #1d4ed8;
    font-size: 10px;
    font-weight: 700;
}

.user-information {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.user-name {
    font-size: 12px;
    font-weight: 600;
}

.user-role {
    margin-top: 2px;
    color: #64748b;
    font-size: 9px;
}

.content-area {
    padding: 16px;
}

.content-area h1,
.content-area h2,
.content-area h3 {
    margin-top: 0;
}

.content-area h2 {
    font-size: 24px;
    margin-bottom: 12px !important;
}

/* =====================================================
   TARJETAS Y FORMULARIOS
===================================================== */

.card {
    border: 1px solid var(--border-color);
    border-radius: 5px;
    box-shadow: none;
    background: #ffffff;
}

.card-header {
    background: #f8fafc;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    padding: 10px 12px;
    font-size: 13px;
}

.card-body {
    padding: 12px;
}

.row.g-3 {
    --bs-gutter-x: 12px;
    --bs-gutter-y: 10px;
}

.form-label {
    font-size: 12px;
    margin-bottom: 4px;
    color: #374151;
}

.form-control,
.form-select {
    min-height: 34px;
    height: 34px;
    border-radius: 4px;
    border: 1px solid #d1d5db;
    font-size: 12px;
    padding: 5px 9px;
}

.form-control:focus,
.form-select:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.08);
}

.form-control[readonly] {
    background: #f8fafc;
    color: #334155;
}

textarea.form-control {
    min-height: 65px;
    height: 65px;
    resize: vertical;
}

/* =====================================================
   BOTONES
===================================================== */

.btn {
    border-radius: 4px;
    font-size: 12px;
    padding: 7px 12px;
}

.btn-primary {
    background: #2563eb;
    border-color: #2563eb;
}

.btn-success {
    background: #16a34a;
    border-color: #16a34a;
}

/* =====================================================
   TABLAS
===================================================== */

.table {
    margin-bottom: 0;
    font-size: 11px;
}

.table th {
    background: #f8fafc;
    font-weight: 600;
    color: #374151;
}

.table td,
.table th {
    padding: 6px 7px;
    vertical-align: middle;
    border-color: var(--border-color);
}

.badge-status {
    display: inline-block;
    padding: 4px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 500;
}

.badge-success {
    background: #dcfce7;
    color: #166534;
}

/* =====================================================
   TOTALES
===================================================== */

.invoice-total-box {
    border: 1px solid var(--border-color);
    background: #ffffff;
    padding: 10px;
}

.invoice-total-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
    font-size: 12px;
}

.invoice-total-row.total {
    border-top: 1px solid var(--border-color);
    padding-top: 8px;
    margin-top: 8px;
    font-size: 15px;
    font-weight: 700;
}

.mt-3 {
    margin-top: 10px !important;
}

.mt-4 {
    margin-top: 12px !important;
}

/* =====================================================
   LOGIN
===================================================== */

.login-page {
    min-height: 100vh;
    background: #eef2f7;
}

.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-card {
    width: 100%;
    max-width: 370px;
    overflow: hidden;
    background: #ffffff;
    border: 1px solid #dfe3e8;
    border-radius: 8px;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
}

.login-brand {
    min-height: 105px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 14px 24px;
    background: #ffffff;
    border-bottom: 1px solid #e5e7eb;
}

.login-logo {
    display: block;
    width: 100%;
    max-width: 280px;
    max-height: 80px;
    object-fit: contain;
}

.login-body {
    padding: 22px;
}

.login-title {
    margin-bottom: 4px;
    font-size: 18px;
    font-weight: 600;
}

.login-subtitle {
    margin-bottom: 18px;
    color: #64748b;
    font-size: 12px;
}

.login-footer {
    padding: 12px 20px;
    border-top: 1px solid #e5e7eb;
    color: #64748b;
    font-size: 9px;
    text-align: center;
}

.login-footer strong {
    margin: 0 3px;
    color: #334155;
}

/* =====================================================
   PANTALLAS MEDIANAS
===================================================== */

@media (max-width: 1200px) {

    :root {
        --sidebar-width: 190px;
    }

    body {
        font-size: 12px;
    }

    .sidebar-logo {
        max-width: 165px;
    }

    .sidebar-link {
        font-size: 11px;
    }

    .content-area {
        padding: 12px;
    }

    .content-area h2 {
        font-size: 21px;
    }

    .form-control,
    .form-select {
        font-size: 11px;
    }

    .table {
        font-size: 10px;
    }

}

/* =====================================================
   PANTALLAS PEQUEÑAS
===================================================== */

@media (max-width: 768px) {

    .sidebar {
        width: 210px;
        transform: translateX(-100%);
        transition: transform 0.2s ease;
    }

    body.sidebar-open .sidebar {
        transform: translateX(0);
    }

    .main-area,
    body.sidebar-collapsed .main-area {
        margin-left: 0;
        width: 100%;
    }

    .content-area {
        padding: 10px;
    }

    .user-role {
        display: none;
    }

}