*,
*::before,
*::after {
    box-sizing: border-box;
}

:root {
    --bg: #f3f5f0;
    --panel: #ffffff;
    --panel-soft: #f8faf6;
    --sidebar: #0d1b2a;
    --sidebar-2: #14283a;
    --text: #17202a;
    --muted: #6a7380;
    --line: #dce2df;
    --gold: #f8b400;
    --gold-soft: #fff4d6;
    --green: #198754;
    --green-soft: #e7f6ef;
    --blue: #2563eb;
    --blue-soft: #eaf0ff;
    --red: #c43b3b;
    --red-soft: #ffe8e8;
    --ink: #0d1b2a;
    --shadow: 0 16px 40px rgba(20, 31, 43, .08);
    --radius: 8px;
}

html {
    min-height: 100%;
}

body {
    min-height: 100vh;
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, "Segoe UI", Arial, Helvetica, sans-serif;
}

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

button,
input,
select,
textarea {
    font: inherit;
}

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

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 20;
    width: 280px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding: 20px 16px;
    overflow-y: auto;
    background: var(--sidebar);
    color: #eef5f8;
    border-right: 1px solid rgba(255, 255, 255, .08);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 8px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.brand img {
    width: 66px;
    height: 66px;
    object-fit: contain;
    border-radius: 0;
}

.brand strong {
    display: block;
    font-size: 18px;
    letter-spacing: .08em;
}

.brand small,
.sidebar-user small {
    display: block;
    color: #aebccc;
    margin-top: 2px;
}

.sidebar-user {
    display: grid;
    grid-template-columns: 42px 1fr;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: rgba(255, 255, 255, .07);
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: var(--radius);
}

.sidebar-user img,
.avatar-link img,
.profile-photo {
    width: 42px;
    height: 42px;
    object-fit: cover;
    border-radius: 50%;
}

.menu {
    display: grid;
    gap: 6px;
}

.menu a {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 42px;
    padding: 10px 12px;
    border-radius: var(--radius);
    color: #d8e2ea;
    border: 1px solid transparent;
}

.menu a:hover,
.menu a.active {
    background: rgba(248, 180, 0, .14);
    border-color: rgba(248, 180, 0, .26);
    color: #ffffff;
}

.menu-icon {
    width: 22px;
    height: 22px;
    display: inline-grid;
    place-items: center;
    color: var(--gold);
}

.menu-icon::before {
    content: attr(data-icon);
    width: 20px;
    height: 20px;
    display: grid;
    place-items: center;
    font-size: 10px;
    font-weight: 800;
    color: #101820;
    background: var(--gold);
    border-radius: 6px;
}

.menu-icon[data-icon="grid"]::before { content: "M"; }
.menu-icon[data-icon="chart"]::before { content: "D"; }
.menu-icon[data-icon="cart"]::before { content: "C"; }
.menu-icon[data-icon="receipt"]::before { content: "G"; }
.menu-icon[data-icon="cash"]::before { content: "$"; }
.menu-icon[data-icon="lock"]::before { content: "X"; }
.menu-icon[data-icon="report"]::before { content: "R"; }
.menu-icon[data-icon="users"]::before { content: "U"; }
.menu-icon[data-icon="gear"]::before { content: "A"; }
.menu-icon[data-icon="profile"]::before { content: "P"; }

.logout-link {
    margin-top: auto;
    padding: 12px;
    border-radius: var(--radius);
    color: #ffd6d6;
    background: rgba(196, 59, 59, .14);
    border: 1px solid rgba(196, 59, 59, .25);
}

.main {
    width: 100%;
    min-height: 100vh;
    margin-left: 280px;
    padding: 24px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 20px;
}

.topbar h1 {
    margin: 2px 0 0;
    font-size: 30px;
    line-height: 1.15;
    letter-spacing: 0;
}

.eyebrow {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .08em;
}

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

.date-pill,
.badge,
.status-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 30px;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 800;
    background: var(--panel);
    border: 1px solid var(--line);
}

.badge-green,
.status-activo,
.status-abierta {
    color: #0b653d;
    background: var(--green-soft);
    border-color: #b8e2ce;
}

.badge-red,
.status-inactivo,
.status-cerrada {
    color: #9d2424;
    background: var(--red-soft);
    border-color: #ffc7c7;
}

.badge-gold {
    color: #7a5200;
    background: var(--gold-soft);
    border-color: #f6daa1;
}

.grid {
    display: grid;
    gap: 16px;
}

.grid-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.card,
.stat-card,
.table-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.card {
    padding: 18px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 14px;
    margin-bottom: 16px;
}

.card-header h2,
.card-header h3 {
    margin: 0;
}

.card-header p {
    margin: 4px 0 0;
    color: var(--muted);
}

.stat-card {
    padding: 16px;
}

.stat-card small {
    display: block;
    color: var(--muted);
    font-weight: 700;
    margin-bottom: 8px;
}

.stat-card strong {
    display: block;
    font-size: 25px;
    line-height: 1.15;
}

.stat-card span {
    display: block;
    color: var(--muted);
    margin-top: 6px;
    font-size: 13px;
}

.hero-panel {
    display: grid;
    grid-template-columns: minmax(0, 1.3fr) minmax(300px, .7fr);
    gap: 16px;
    align-items: stretch;
    margin-bottom: 16px;
}

.welcome-card {
    padding: 22px;
    color: #fff;
    background: linear-gradient(135deg, #0d1b2a 0%, #17415a 52%, #6b4b0e 100%);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.welcome-card h2 {
    margin: 0 0 8px;
    font-size: 30px;
}

.welcome-card p {
    max-width: 720px;
    margin: 0;
    color: #dce7ef;
}

.quick-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.quick-action {
    min-height: 78px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
}

.quick-action strong,
.quick-action small {
    display: block;
}

.quick-action small {
    margin-top: 4px;
    color: var(--muted);
}

.table-card {
    overflow: hidden;
}

.table-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 16px;
    border-bottom: 1px solid var(--line);
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
}

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

th,
td {
    padding: 12px 14px;
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}

th {
    color: #45515f;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .05em;
    background: #f8faf9;
}

td p {
    margin: 0;
}

td small {
    display: block;
    color: var(--muted);
    margin-top: 3px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.form-row {
    display: grid;
    gap: 7px;
}

.form-row.full {
    grid-column: 1 / -1;
}

label {
    color: #344152;
    font-weight: 800;
    font-size: 14px;
}

input,
select,
textarea {
    width: 100%;
    min-height: 42px;
    padding: 10px 11px;
    color: var(--text);
    background: #fff;
    border: 1px solid #cfd8d3;
    border-radius: var(--radius);
}

textarea {
    min-height: 92px;
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    outline: 0;
    border-color: #3167d8;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .14);
}

.button,
button.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 42px;
    padding: 10px 14px;
    border-radius: var(--radius);
    color: #101820;
    font-weight: 900;
    border: 1px solid #d69d00;
    background: var(--gold);
    cursor: pointer;
}

.button.secondary {
    color: var(--text);
    background: #fff;
    border-color: var(--line);
}

.button.danger {
    color: #fff;
    background: var(--red);
    border-color: var(--red);
}

.button.green {
    color: #fff;
    background: var(--green);
    border-color: var(--green);
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.alert {
    margin-bottom: 14px;
    padding: 12px 14px;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    font-weight: 700;
}

.alert-success {
    color: #0b653d;
    background: var(--green-soft);
    border-color: #b8e2ce;
}

.alert-error {
    color: #9d2424;
    background: var(--red-soft);
    border-color: #ffc7c7;
}

.alert-info {
    color: #184a8a;
    background: var(--blue-soft);
    border-color: #c8d8ff;
}

.login-page {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(390px, 520px);
    background: #101820;
}

.login-visual {
    display: flex;
    align-items: flex-end;
    padding: 46px;
    color: #fff;
    background: linear-gradient(135deg, #0d1b2a 0%, #1b4332 48%, #886400 100%);
}

.login-visual h1 {
    max-width: 680px;
    margin: 0 0 12px;
    font-size: clamp(34px, 5vw, 72px);
    line-height: 1;
}

.login-visual p {
    max-width: 620px;
    margin: 0;
    color: #e7edf2;
    font-size: 18px;
}

.login-card-wrap {
    display: grid;
    place-items: center;
    padding: 30px;
    background: var(--bg);
}

.login-card {
    width: min(430px, 100%);
    padding: 28px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.login-card .login-logo {
    width: 156px;
    height: 156px;
    object-fit: contain;
    border-radius: 0;
    margin-bottom: 16px;
}

.login-card h2 {
    margin: 0 0 6px;
    font-size: 26px;
}

.login-card p {
    margin: 0 0 18px;
    color: var(--muted);
}

.muted {
    color: var(--muted);
}

.profile-head {
    display: flex;
    align-items: center;
    gap: 16px;
}

.profile-head img {
    width: 92px;
    height: 92px;
    border-radius: 18px;
    object-fit: cover;
}

.chart-wrap {
    min-height: 260px;
}

.empty-state {
    padding: 24px;
    color: var(--muted);
    text-align: center;
}

.mobile-menu {
    display: none;
    width: 42px;
    height: 42px;
    border: 1px solid var(--line);
    background: #fff;
    border-radius: var(--radius);
}

.mobile-menu span {
    display: block;
    width: 18px;
    height: 2px;
    background: var(--text);
    margin: 4px auto;
}

@media (max-width: 1180px) {
    .grid-4 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .hero-panel {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 900px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform .2s ease;
    }

    body.sidebar-open .sidebar {
        transform: translateX(0);
    }

    .main {
        margin-left: 0;
        padding: 16px;
    }

    .mobile-menu {
        display: block;
    }

    .topbar {
        align-items: flex-start;
    }

    .grid-2,
    .grid-3,
    .grid-4,
    .form-grid,
    .login-page {
        grid-template-columns: 1fr;
    }

    .login-visual {
        min-height: 280px;
        padding: 30px;
    }
}

@media (max-width: 620px) {
    .topbar {
        flex-wrap: wrap;
    }

    .topbar h1 {
        font-size: 24px;
    }

    .card,
    .login-card {
        padding: 16px;
    }

    .quick-actions {
        grid-template-columns: 1fr;
    }
}
