:root {
    --sidebar-width: 235px;
    --topbar-height: 50px;
    --primary: #1a3a5c;
    --primary-light: #2a5298;
    --accent: #e8a020;
    --sidebar-bg: #0f2744;
    --sidebar-text: rgba(255, 255, 255, 0.8);
    --sidebar-active: rgba(255, 255, 255, 0.1);
}

* {
    box-sizing: border-box;
}

html {
    font-size: 90%;
}

body {
    font-family: 'Inter', sans-serif;
    background: #f0f4f8;
    color: #2d3748;
    font-size: 0.75rem;
    line-height: 1.5;
    margin: 0;
    overflow-x: hidden;
}

/* ---- SIDEBAR ---- */
#sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    z-index: 1050;
    overflow-y: auto;
    transition: transform 0.3s ease;
}

@media (max-width: 991.98px) {
    #sidebar {
        transform: translateX(-100%);
    }

    body.sidebar-open #sidebar {
        transform: translateX(0);
        box-shadow: 10px 0 30px rgba(0, 0, 0, 0.3);
    }
}

.sidebar-brand {
    padding: 1.2rem 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-brand .brand-name {
    font-size: 0.78rem;
    font-weight: 700;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    line-height: 1.3;
}

.sidebar-brand .badge-oa {
    display: inline-block;
    background: var(--accent);
    color: #fff;
    font-size: 0.6rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 3px;
    letter-spacing: 0.05em;
    margin-bottom: 6px;
}

.sidebar-section {
    padding: 1rem 0 0.5rem;
}

.sidebar-section-title {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgba(255, 255, 255, 0.35);
    padding: 0 1.25rem 0.4rem;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.5rem 1.25rem;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 0.75rem;
    font-weight: 500;
    border-left: 3px solid transparent;
    transition: all 0.15s;
}

.sidebar-link:hover,
.sidebar-link.active {
    background: var(--sidebar-active);
    color: #fff;
    border-left: 3px solid var(--accent);
}

.sidebar-link i {
    font-size: 1rem;
    opacity: 0.85;
}

/* ---- TOPBAR ---- */
#topbar {
    position: fixed;
    top: 0;
    left: var(--sidebar-width);
    right: 0;
    height: var(--topbar-height);
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    padding: 0 1.25rem;
    z-index: 1040;
}

@media (max-width: 991.98px) {
    #topbar {
        left: 0 !important;
        padding: 0 1rem;
    }
}

.btn-toggle-sidebar {
    display: none;
    background: none;
    border: none;
    font-size: 1.3rem;
    color: var(--primary);
    cursor: pointer;
    padding: 0;
    margin-right: 0.8rem;
}

@media (max-width: 991.98px) {
    .btn-toggle-sidebar {
        display: block;
    }
}

.topbar-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary);
    flex: 1;
}

/* ---- MAIN CONTENT ---- */
#main-content {
    margin-left: var(--sidebar-width);
    margin-top: var(--topbar-height);
    padding: 1.25rem;
    min-height: calc(100vh - var(--topbar-height));
    background: #f0f4f8;
    width: auto;
}

@media (max-width: 991.98px) {
    #main-content {
        margin-left: 0 !important;
        padding: 1rem;
    }
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1045;
}

body.sidebar-open .sidebar-overlay {
    display: block;
}

/* ---- CARDS & UI ---- */
.card {
    border: none;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.card-header {
    background: #fff;
    font-weight: 600;
    font-size: 0.85rem;
    border-bottom: 1px solid #edf2f7;
}

.stat-card {
    background: #fff;
    border-radius: 6px;
    padding: 0.875rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.stat-icon {
    width: 36px;
    height: 36px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}

.stat-label {
    font-size: 0.6rem;
    color: #718096;
    font-weight: 600;
    text-transform: uppercase;
}

.stat-value {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1.2;
}

.stat-sub {
    font-size: 0.6rem;
    color: #a0aec0;
}

.table {
    font-size: 0.75rem;
}

.table th {
    font-size: 0.65rem;
    text-transform: uppercase;
    color: #718096;
    background: #f8fafc;
    padding: 0.45rem 0.5rem !important;
}

.table td {
    padding: 0.45rem 0.5rem !important;
}

/* ---- ALERTS ---- */
.crisis-bar {
    background: linear-gradient(90deg, #991b1b, #dc2626);
    color: #fff;
    padding: 8px 15px;
    font-size: 0.78rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin: -1.25rem -1.25rem 1.25rem -1.25rem;
}

/* ---- FORMS ---- */
.form-control,
.form-select,
.input-group-text {
    font-size: 0.75rem;
    min-height: 20px;
    height: 20px;
    padding: 0.15rem 0.5rem;
    border-radius: 4px !important;
}

.form-control::placeholder {
    font-size: 0.75rem;
    color: #a0aec0;
}

.form-label {
    margin-bottom: 0.25rem;
}

.btn {
    font-size: 0.75rem;
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    min-height: 28px;
    display: inline-flex;
    align-items: center;
}

/* TomSelect Fix para ficar alinhado com o bootstrap sm e visual Premium */
.ts-control {
    min-height: 20px !important;
    padding: 0.15rem 0.5rem !important;
    font-size: 0.75rem !important;
    border-color: #dee2e6 !important;
    box-shadow: none !important;
    border-radius: 4px !important;
}

.ts-control>input {
    font-size: 0.75rem !important;
}

.ts-control .item {
    font-size: 0.75rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 90%;
}

.ts-dropdown {
    font-size: 0.7rem !important;
    min-width: 100% !important;
    width: max-content !important;
    max-width: 80vw !important;
    border-radius: 0 0 4px 4px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    border-color: #dee2e6;
}

.ts-dropdown .option {
    padding: 6px 10px !important;
    line-height: 1.4 !important;
    white-space: normal;
}

.ts-dropdown .active {
    background-color: var(--primary) !important;
    color: white !important;
}

/* ---- HEADINGS TYPOGRAPHY FIX ---- */
h1,
.h1 {
    font-size: 1.4rem;
}

h2,
.h2 {
    font-size: 1.2rem;
}

h3,
.h3 {
    font-size: 1.1rem;
}

h4,
.h4 {
    font-size: 1.0rem;
}

h5,
.h5 {
    font-size: 0.9rem;
}

h6,
.h6 {
    font-size: 0.8rem;
}