html {
    font-size: 14px;
    min-height: 100%;
}

@media (min-width: 768px) {
    html {
        font-size: 16px;
    }
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

:root {
    --header-height: 72px;
    --footer-height: 58px;
    --sidebar-width: 290px;
    --bg-page: #f4f5f7;
    --bg-surface: #ffffff;
    --bg-sidebar: #f8f9fb;
    --border-soft: #e6e8ec;
    --text-main: #1f2340;
    --text-muted: #6e7485;
    --brand-primary: #0b7f87;
    --brand-secondary: #69ad7e;
    --brand-dark: #2f7d83;
    --overlay: rgba(25, 31, 45, 0.22);
    --shadow-soft: 0 6px 18px rgba(26, 32, 44, 0.08);
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg-page);
    color: var(--text-main);
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    overflow-x: hidden;
}

/* ===== HEADER ===== */
.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-soft);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    z-index: 1200;
}

.app-header-left,
.app-header-right {
    display: flex;
    align-items: center;
}

.app-header-right {
    margin-left: auto;
}

.app-brand {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    text-decoration: none;
    max-width: 220px;
}

.app-brand-image {
    display: block;
    height: 38px;
    width: auto;
    max-width: 100%;
}

.app-brand-text-fallback {
    font-size: 1.85rem;
    font-weight: 700;
    line-height: 1;
    color: var(--brand-primary);
    letter-spacing: 0.2px;
}

.app-brand:hover {
    color: var(--brand-primary);
}

/* ===== BOTÓN MENU ===== */
.menu-toggle {
    width: 42px;
    height: 42px;
    border: none;
    background: transparent;
    display: inline-flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 4px;
    padding: 0;
    cursor: pointer;
    border-radius: 10px;
    flex: 0 0 auto;
}

    .menu-toggle:hover {
        background: rgba(11, 127, 135, 0.08);
    }

    .menu-toggle span {
        width: 18px;
        height: 2px;
        background: var(--text-main);
        border-radius: 2px;
        display: block;
    }

/* ===== SIDEBAR ===== */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    max-width: 86vw;
    height: 100vh;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-soft);
    box-shadow: var(--shadow-soft);
    transform: translateX(-100%);
    transition: transform 0.28s ease;
    z-index: 1250;
    display: flex;
    flex-direction: column;
}

    .sidebar.open {
        transform: translateX(0);
    }

.sidebar-top {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    border-bottom: 1px solid var(--border-soft);
}

.sidebar-logo-link {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
    max-width: 190px;
}

.sidebar-logo-image {
    display: block;
    height: 42px;
    width: auto;
    max-width: 100%;
}

.sidebar-logo-text-fallback {
    font-size: 2rem;
    font-weight: 700;
    color: var(--brand-primary);
    line-height: 1;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    padding: 1rem 1rem 1.25rem;
    gap: 0.35rem;
    height: calc(100vh - var(--header-height));
    overflow-y: auto;
}

.sidebar-link {
    display: flex;
    align-items: center;
    min-height: 46px;
    padding: 0.8rem 0.95rem;
    border-radius: 14px;
    text-decoration: none;
    color: var(--text-main);
    font-size: 1rem;
    font-weight: 500;
    transition: background-color 0.2s ease, color 0.2s ease;
}

    .sidebar-link:hover {
        background: rgba(11, 127, 135, 0.08);
        color: var(--brand-primary);
    }

    .sidebar-link.active {
        background: rgba(11, 127, 135, 0.1);
        color: var(--brand-primary);
        font-weight: 700;
    }

.sidebar-section-title {
    margin: 1rem 0 0.35rem;
    padding: 0 0.95rem;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #9aa1b2;
}

.sidebar-spacer {
    flex: 1 1 auto;
}

.sidebar-link-logout {
    color: #7a3140;
}

    .sidebar-link-logout:hover {
        background: rgba(122, 49, 64, 0.08);
        color: #7a3140;
    }

/* ===== OVERLAY ===== */
.overlay {
    position: fixed;
    inset: 0;
    background: var(--overlay);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
    z-index: 1240;
}

    .overlay.active {
        opacity: 1;
        visibility: visible;
    }

/* ===== CONTENIDO ===== */
.main-content {
    padding-top: calc(var(--header-height) + 1rem);
    padding-bottom: calc(var(--footer-height) + 1rem);
}

.main-shell {
    width: 100%;
    max-width: 1500px;
    margin: 0 auto;
    padding-left: 1rem;
    padding-right: 1rem;
}

/* ===== FOOTER ===== */
.app-footer {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: var(--footer-height);
    background: var(--brand-dark);
    color: #d9f1df;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 1rem;
    z-index: 1200;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.app-footer-center {
    text-align: center;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ===== FOCUS ===== */
.btn:focus,
.btn:active:focus,
.btn-link.nav-link:focus,
.form-control:focus,
.form-check-input:focus,
.menu-toggle:focus {
    box-shadow: none;
    outline: none;
}

.app-header-left,
.app-header-right {
    display: flex;
    align-items: center;
}

.app-header-left {
    gap: 0.9rem;
    min-width: 0;
    flex: 1 1 auto;
}

.app-header-right {
    margin-left: 1rem;
    flex: 0 0 auto;
}

/* ===== SEARCH HEADER ===== */
.header-search {
    display: flex;
    align-items: center;
    gap: 0;
    min-width: 0;
    width: min(100%, 420px);
}

.header-search-input {
    height: 42px;
    border: 1px solid var(--border-soft);
    border-right: none;
    background: #fff;
    color: var(--text-main);
    border-radius: 12px 0 0 12px;
    padding: 0 0.95rem;
    width: 100%;
    min-width: 0;
    font-size: 0.95rem;
}

    .header-search-input::placeholder {
        color: #98a1b3;
    }

    .header-search-input:focus {
        outline: none;
        border-color: rgba(11, 127, 135, 0.35);
    }

.header-search-button {
    height: 42px;
    border: 1px solid var(--brand-primary);
    background: var(--brand-primary);
    color: #fff;
    padding: 0 1rem;
    border-radius: 0 12px 12px 0;
    font-size: 0.92rem;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
}

    .header-search-button:hover {
        background: #086d74;
        border-color: #086d74;
    }

    .header-search-button:focus {
        outline: none;
        box-shadow: none;
    }

/* ===== RESPONSIVE ===== */
@media (max-width: 767.98px) {
    .app-header {
        padding: 0 0.85rem;
    }

    .app-brand {
        max-width: 160px;
    }

    .app-brand-image {
        height: 30px;
    }

    .app-brand-text-fallback {
        font-size: 1.45rem;
    }

    .sidebar-logo-image {
        height: 36px;
    }

    .sidebar-logo-text-fallback {
        font-size: 1.7rem;
    }

    .main-shell {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }

    .app-footer {
        padding: 0 0.85rem;
    }

    .app-footer-center {
        font-size: 0.82rem;
    }

    .header-search {
        width: min(100%, 220px);
    }

    .header-search-input {
        font-size: 0.9rem;
        padding: 0 0.75rem;
    }

    .header-search-button {
        padding: 0 0.8rem;
        font-size: 0.85rem;
    }
}
