@import url('https://fonts.googleapis.com/css2?family=Libre+Baskerville:ital,wght@0,400..700;1,400..700&family=Montserrat:ital,wght@0,100..900;1,100..900&display=swap');

:root {
    --color-primary: #1493d1;
    --color-secondary: #f4c20d;
    --color-dark: #111111;
    --color-dark-soft: #1c1c1c;
    --color-bg: #f5f7fa;
    --color-white: #ffffff;
    --color-border: #d9e1ea;
    --color-text: #1f2937;
    --color-muted: #6b7280;
    --color-danger: #dc2626;
    --color-success: #16a34a;

    --radius-lg: 18px;
    --radius-xl: 24px;

    --shadow-card: 0 10px 30px rgba(0, 0, 0, 0.08);
    --shadow-soft: 0 6px 18px rgba(0, 0, 0, 0.06);
}

html, body {
    margin: 0;
    padding: 0;
    background: var(--color-bg);
    color: var(--color-text);
    font-family: "Montserrat", sans-serif;
}

body.auth-page {
    background:
        linear-gradient(135deg, rgba(20,147,209,0.08), rgba(244,194,13,0.12)),
        var(--color-bg);
}

.brand-logo {
    width: 90px;
    height: auto;
    object-fit: contain;
}

.brand-title {
    color: var(--color-dark);
    font-weight: 800;
    letter-spacing: -0.02em;
}

.brand-accent {
    color: var(--color-primary);
}

.auth-card {
    background: var(--color-white);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-card);
}

.panel-card {
    background: var(--color-white);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
}

.form-label {
    display: block;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 8px;
}

.form-input {
    width: 100%;
    border: 1px solid var(--color-border);
    border-radius: 14px;
    background: #fff;
    padding: 14px 16px;
    font-size: 0.95rem;
    color: var(--color-text);
    outline: none;
    transition: all 0.2s ease;
    box-sizing: border-box;
}

.form-input:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 4px rgba(20, 147, 209, 0.12);
}

.btn-primary {
    width: 100%;
    border: none;
    border-radius: 14px;
    background: var(--color-secondary);
    color: var(--color-dark);
    padding: 14px 18px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}

.btn-primary:hover {
    filter: brightness(0.97);
    transform: translateY(-1px);
}

.btn-danger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 12px;
    background: var(--color-danger);
    color: var(--color-white);
    padding: 10px 16px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s ease;
    box-sizing: border-box;
}

.btn-danger:hover {
    filter: brightness(1.05);
}

.alert-error {
    border: 1px solid rgba(220, 38, 38, 0.2);
    background: rgba(220, 38, 38, 0.08);
    color: #991b1b;
    border-radius: 14px;
    padding: 12px 14px;
    font-size: 0.95rem;
}

.topbar {
    background: var(--color-white);
    border-bottom: 1px solid var(--color-border);
}

.topbar-title {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--color-dark);
}

.topbar-subtitle {
    color: var(--color-muted);
    font-size: 0.92rem;
}

.user-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(20, 147, 209, 0.08);
    color: var(--color-primary);
    border: 1px solid rgba(20, 147, 209, 0.15);
    border-radius: 999px;
    padding: 8px 12px;
    font-weight: 600;
    font-size: 0.9rem;
}

.admin-body {
    background: var(--color-bg);
    min-height: 100vh;
}

.app-shell {
    min-height: 100vh;
}

.app-content {
    min-height: calc(100vh - 78px);
}

.content-wrap {
    width: 100%;
}

.layout-topbar {
    width: 100%;
}

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 290px;
    height: 100vh;
    background: #0f172a;
    color: #fff;
    z-index: 60;
    border-right: 1px solid rgba(255, 255, 255, 0.06);
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    display: flex;
    flex-direction: column;
}

.sidebar.is-open {
    transform: translateX(0);
}

.sidebar-inner {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 100%;
    overflow-y: auto;
}

.sidebar-brand {
    padding: 24px 22px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
}

.sidebar-brand-title {
    font-size: 1.1rem;
    font-weight: 800;
    color: #fff;
    margin: 0;
}

.sidebar-brand-subtitle {
    margin: 4px 0 0;
    color: rgba(255, 255, 255, 0.65);
    font-size: 0.9rem;
}

.sidebar-nav {
    padding: 18px 14px 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    color: rgba(255, 255, 255, 0.84);
    text-decoration: none;
    padding: 13px 14px;
    border-radius: 14px;
    font-weight: 700;
    transition: all 0.2s ease;
}

.sidebar-link:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.sidebar-link.is-active,
.sidebar-link.active {
    background: linear-gradient(135deg, rgba(20, 147, 209, 0.22), rgba(244, 194, 13, 0.22));
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-icon {
    width: 22px;
    display: inline-flex;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.sidebar-section-title {
    margin: 18px 12px 6px;
    font-size: 0.76rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255, 255, 255, 0.45);
}

.sidebar-footer {
    margin-top: auto;
    padding: 18px 14px 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.02);
    flex-shrink: 0;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    padding: 12px 14px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
    font-weight: 700;
    font-size: 0.95rem;
    word-break: break-word;
}

.sidebar-logout {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px 14px;
    border-radius: 14px;
    background: var(--color-danger);
    color: #fff;
    text-decoration: none;
    font-weight: 700;
    transition: all 0.2s ease;
    box-sizing: border-box;
}

.sidebar-logout:hover {
    filter: brightness(1.05);
    transform: translateY(-1px);
}

.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 55;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
}

.sidebar-overlay.is-open {
    opacity: 1;
    visibility: visible;
}

body.sidebar-open {
    overflow: hidden;
}

.mini-feature-card {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 16px;
    border-radius: 16px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
}

.mini-feature-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(20, 147, 209, 0.1);
    font-size: 1.1rem;
    flex-shrink: 0;
}

.mini-feature-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 800;
    color: var(--color-dark);
}

.mini-feature-text {
    margin: 4px 0 0;
    font-size: 0.92rem;
    color: var(--color-muted);
}

.summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    padding-bottom: 12px;
    border-bottom: 1px solid #e5e7eb;
    font-size: 0.96rem;
    color: var(--color-text);
}

.summary-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

/* =========================================================
   HELPERS GENERALES
========================================================= */

.table-mobile-card,
.table-mobile-card table,
.table-mobile-card thead,
.table-mobile-card tbody,
.table-mobile-card tr,
.table-mobile-card th,
.table-mobile-card td {
    box-sizing: border-box;
}

.page-actions,
.filters-row,
.toolbar-row,
.search-row,
.actions-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
}

.table-wrap,
.table-responsive,
.table-container,
.list-table-wrap,
.panel-table-wrap {
    width: 100%;
}

.table-mobile-card table,
.panel-card table,
.table-wrap table,
.table-responsive table,
.table-container table,
.list-table-wrap table,
.panel-table-wrap table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.table-mobile-card table th,
.panel-card table th,
.table-wrap table th,
.table-responsive table th,
.table-container table th,
.list-table-wrap table th,
.panel-table-wrap table th {
    background: #eef2f7;
    color: var(--color-text);
    font-weight: 800;
    font-size: 0.92rem;
    padding: 14px 16px;
    border-bottom: 1px solid var(--color-border);
    text-align: left;
}

.table-mobile-card table td,
.panel-card table td,
.table-wrap table td,
.table-responsive table td,
.table-container table td,
.list-table-wrap table td,
.panel-table-wrap table td {
    padding: 14px 16px;
    border-bottom: 1px solid #e5e7eb;
    color: var(--color-text);
    font-size: 0.95rem;
    vertical-align: middle;
    word-break: break-word;
}

.table-mobile-card table tbody tr:last-child td,
.panel-card table tbody tr:last-child td,
.table-wrap table tbody tr:last-child td,
.table-responsive table tbody tr:last-child td,
.table-container table tbody tr:last-child td,
.list-table-wrap table tbody tr:last-child td,
.panel-table-wrap table tbody tr:last-child td {
    border-bottom: none;
}

.btn-secondary,
.btn-light,
.btn-outline {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    padding: 12px 16px;
    border-radius: 14px;
    font-weight: 700;
    text-decoration: none;
    border: 1px solid var(--color-border);
    background: #fff;
    color: var(--color-text);
    transition: all .2s ease;
    box-sizing: border-box;
}

.btn-secondary:hover,
.btn-light:hover,
.btn-outline:hover {
    background: #f8fafc;
}

.btn-primary,
.btn-danger {
    min-height: 48px;
}

select.form-input,
input.form-input,
textarea.form-input {
    min-height: 50px;
}

@media (min-width: 1024px) {
    .sidebar {
        transform: translateX(0);
    }

    .sidebar-overlay {
        display: none;
    }

    .app-shell {
        margin-left: 290px;
    }

    .layout-topbar,
    .content-wrap {
        max-width: none;
    }
}

@media (max-width: 1023px) {
    .app-shell {
        margin-left: 0;
    }

    .topbar {
        position: sticky;
        top: 0;
        z-index: 40;
    }

    .layout-topbar {
        padding-left: 16px;
        padding-right: 16px;
    }

    .topbar-title,
    .brand-title {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 220px;
    }

    .topbar-subtitle {
        font-size: 0.88rem;
    }

    .content-wrap {
        padding-left: 16px !important;
        padding-right: 16px !important;
    }
}

@media (max-width: 767px) {
    .content-wrap {
        padding-top: 18px !important;
        padding-bottom: 24px !important;
    }

    .panel-card,
    .auth-card {
        border-radius: 18px;
    }

    .page-actions,
    .filters-row,
    .toolbar-row,
    .search-row,
    .actions-row {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .page-actions > *,
    .filters-row > *,
    .toolbar-row > *,
    .search-row > *,
    .actions-row > *,
    .btn-primary,
    .btn-danger,
    .btn-secondary,
    .btn-light,
    .btn-outline {
        width: 100%;
    }

    .grid,
    .filters-grid,
    .form-grid {
        gap: 12px;
    }

    .table-mobile-card,
    .panel-card.table-mobile-card,
    .table-wrap,
    .table-responsive,
    .table-container,
    .list-table-wrap,
    .panel-table-wrap {
        overflow: visible !important;
        border: none;
        background: transparent;
    }

    .table-mobile-card table,
    .panel-card table,
    .table-wrap table,
    .table-responsive table,
    .table-container table,
    .list-table-wrap table,
    .panel-table-wrap table {
        display: block;
        width: 100%;
        border: none;
        background: transparent;
    }

    .table-mobile-card thead,
    .panel-card table thead,
    .table-wrap table thead,
    .table-responsive table thead,
    .table-container table thead,
    .list-table-wrap table thead,
    .panel-table-wrap table thead {
        display: none;
    }

    .table-mobile-card tbody,
    .panel-card table tbody,
    .table-wrap table tbody,
    .table-responsive table tbody,
    .table-container table tbody,
    .list-table-wrap table tbody,
    .panel-table-wrap table tbody {
        display: block;
    }

    .table-mobile-card tr,
    .panel-card table tbody tr,
    .table-wrap table tbody tr,
    .table-responsive table tbody tr,
    .table-container table tbody tr,
    .list-table-wrap table tbody tr,
    .panel-table-wrap table tbody tr {
        display: block;
        width: 100%;
        margin-bottom: 14px;
        padding: 14px;
        background: #ffffff;
        border: 1px solid var(--color-border);
        border-radius: 18px;
        box-shadow: var(--shadow-soft);
    }

    .table-mobile-card tr:last-child,
    .panel-card table tbody tr:last-child,
    .table-wrap table tbody tr:last-child,
    .table-responsive table tbody tr:last-child,
    .table-container table tbody tr:last-child,
    .list-table-wrap table tbody tr:last-child,
    .panel-table-wrap table tbody tr:last-child {
        margin-bottom: 0;
    }

    .table-mobile-card td,
    .panel-card table tbody td,
    .table-wrap table tbody td,
    .table-responsive table tbody td,
    .table-container table tbody td,
    .list-table-wrap table tbody td,
    .panel-table-wrap table tbody td {
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        gap: 12px;
        width: 100%;
        padding: 10px 0;
        border: none;
        border-bottom: 1px solid #edf2f7;
        text-align: right;
        font-size: 0.92rem;
        line-height: 1.45;
    }

    .table-mobile-card td:last-child,
    .panel-card table tbody td:last-child,
    .table-wrap table tbody td:last-child,
    .table-responsive table tbody td:last-child,
    .table-container table tbody td:last-child,
    .list-table-wrap table tbody td:last-child,
    .panel-table-wrap table tbody td:last-child {
        border-bottom: none;
        padding-bottom: 0;
    }

    .table-mobile-card td:first-child,
    .panel-card table tbody td:first-child,
    .table-wrap table tbody td:first-child,
    .table-responsive table tbody td:first-child,
    .table-container table tbody td:first-child,
    .list-table-wrap table tbody td:first-child,
    .panel-table-wrap table tbody td:first-child {
        padding-top: 0;
    }

    .table-mobile-card td::before,
    .panel-card table tbody td::before,
    .table-wrap table tbody td::before,
    .table-responsive table tbody td::before,
    .table-container table tbody td::before,
    .list-table-wrap table tbody td::before,
    .panel-table-wrap table tbody td::before {
        content: attr(data-label);
        flex: 0 0 46%;
        max-width: 46%;
        text-align: left;
        font-weight: 800;
        color: #64748b;
        letter-spacing: 0.02em;
    }

    .table-mobile-card td a,
    .panel-card table tbody td a,
    .table-wrap table tbody td a,
    .table-responsive table tbody td a,
    .table-container table tbody td a,
    .list-table-wrap table tbody td a,
    .panel-table-wrap table tbody td a {
        word-break: break-word;
    }

    .table-mobile-card td.actions-cell,
    .panel-card table tbody td.actions-cell,
    .table-wrap table tbody td.actions-cell,
    .table-responsive table tbody td.actions-cell,
    .table-container table tbody td.actions-cell,
    .list-table-wrap table tbody td.actions-cell,
    .panel-table-wrap table tbody td.actions-cell {
        flex-direction: column;
        align-items: stretch;
        text-align: left;
    }

    .table-mobile-card td.actions-cell::before,
    .panel-card table tbody td.actions-cell::before,
    .table-wrap table tbody td.actions-cell::before,
    .table-responsive table tbody td.actions-cell::before,
    .table-container table tbody td.actions-cell::before,
    .list-table-wrap table tbody td.actions-cell::before,
    .panel-table-wrap table tbody td.actions-cell::before {
        margin-bottom: 4px;
        max-width: 100%;
    }

    .table-mobile-card td span,
    .table-mobile-card td strong,
    .table-mobile-card td small,
    .panel-card table tbody td span,
    .panel-card table tbody td strong,
    .panel-card table tbody td small {
        word-break: break-word;
    }

    .mini-feature-card {
        padding: 14px;
        border-radius: 14px;
        gap: 12px;
    }

    .mini-feature-icon {
        width: 38px;
        height: 38px;
        font-size: 1rem;
        border-radius: 10px;
    }

    .mini-feature-title {
        font-size: 0.96rem;
    }

    .mini-feature-text {
        font-size: 0.86rem;
    }

    .summary-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }
}

@media (max-width: 479px) {
    .topbar-title,
    .brand-title {
        max-width: 170px;
        font-size: 1.05rem;
    }

    .topbar-subtitle {
        font-size: 0.82rem;
    }

    .content-wrap {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }

    .table-mobile-card tr,
    .panel-card table tbody tr,
    .table-wrap table tbody tr,
    .table-responsive table tbody tr,
    .table-container table tbody tr,
    .list-table-wrap table tbody tr,
    .panel-table-wrap table tbody tr {
        padding: 12px;
        border-radius: 16px;
    }

    .table-mobile-card td,
    .panel-card table tbody td,
    .table-wrap table tbody td,
    .table-responsive table tbody td,
    .table-container table tbody td,
    .list-table-wrap table tbody td,
    .panel-table-wrap table tbody td {
        flex-direction: column;
        align-items: flex-start;
        text-align: left;
        gap: 4px;
    }

    .table-mobile-card td::before,
    .panel-card table tbody td::before,
    .table-wrap table tbody td::before,
    .table-responsive table tbody td::before,
    .table-container table tbody td::before,
    .list-table-wrap table tbody td::before,
    .panel-table-wrap table tbody td::before {
        max-width: 100%;
        flex-basis: auto;
    }
}