:root {
    --brand: #1f4e79;
    --brand-dark: #173b5c;
    --sidebar-w: 250px;
    --bg: #f3f5f8;
}

body { background: var(--bg); font-size: .925rem; }

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

/* ---------- Sidebar ---------- */
.sidebar {
    width: var(--sidebar-w);
    background: var(--brand-dark);
    color: #cfd8e3;
    position: fixed; top: 0; bottom: 0; left: 0;
    overflow-y: auto;
    z-index: 1040;
    transition: transform .2s ease;
}
.sidebar-brand {
    display: flex; gap: .75rem; align-items: center;
    padding: 1.1rem 1rem;
    background: var(--brand);
    color: #fff;
}
.sidebar-brand > i { font-size: 1.6rem; }
.brand-title { font-weight: 700; line-height: 1.1; }
.brand-sub { font-size: .72rem; opacity: .8; }
.sidebar-nav { padding: .5rem 0 1rem; }
.nav-section {
    font-size: .7rem; text-transform: uppercase; letter-spacing: .08em;
    padding: 1rem 1.25rem .35rem; color: #8ea4bd;
}
.sidebar .nav-link {
    color: #cfd8e3; padding: .55rem 1.25rem; display: flex; gap: .6rem; align-items: center;
    border-left: 3px solid transparent;
}
.sidebar .nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar .nav-link.active { background: rgba(255,255,255,.1); color: #fff; border-left-color: #f0ad4e; }

/* ---------- Main ---------- */
.main { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-width: 0; }
.topbar {
    background: #fff; border-bottom: 1px solid #e3e7ed;
    display: flex; align-items: center; gap: .5rem;
    padding: .6rem 1.25rem; position: sticky; top: 0; z-index: 1030;
}
.page-title { font-size: 1.2rem; margin: 0; font-weight: 600; color: var(--brand-dark); }
.content { padding: 1.25rem; flex: 1; }
.app-footer { padding: .75rem 1.25rem; font-size: .8rem; color: #8a94a3; border-top: 1px solid #e3e7ed; background: #fff; }

@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.show { transform: translateX(0); box-shadow: 0 0 30px rgba(0,0,0,.3); }
    .main { margin-left: 0; }
}

/* ---------- Cards & tables ---------- */
.card { border: 0; box-shadow: 0 1px 3px rgba(16,24,40,.08); }
.card-header { background: #fff; font-weight: 600; }
/* Header colors are set through Bootstrap's table variables so that the
   DataTables rule "table.table.dataTable > :not(caption) > * > *" (which sets
   background-color: var(--bs-table-bg)) picks up the brand color too. */
.table > thead > tr > th,
table.table.dataTable > thead > tr > th {
    --bs-table-bg: var(--brand);
    --bs-table-color: #fff;
    background-color: var(--brand);
    color: #fff;
    font-weight: 600; white-space: nowrap; vertical-align: middle;
}
table.dataTable thead > tr > th span.dt-column-order:before,
table.dataTable thead > tr > th span.dt-column-order:after { color: #fff; }

/* ---------- Select2 (item search) ---------- */
.select2-container--bootstrap-5 .select2-selection { min-height: calc(1.5em + .5rem + 2px); padding: .25rem .5rem; font-size: .875rem; }
.select2-container--bootstrap-5 .select2-dropdown .select2-results__options .select2-results__option { font-size: .875rem; padding: .35rem .6rem; }
.item-opt { display: flex; justify-content: space-between; gap: .75rem; align-items: center; }
.item-opt .item-opt-meta { font-size: .75rem; opacity: .75; white-space: nowrap; }
.select2-results__option--highlighted .item-opt .badge { background: #fff !important; color: var(--brand) !important; }
.table td { vertical-align: middle; }
.stat-card { border-left: 4px solid var(--brand); }
.stat-card .stat-icon { font-size: 2rem; opacity: .25; }
.stat-card .stat-value { font-size: 1.6rem; font-weight: 700; }

.badge-status-OK { background: #c6efce; color: #006100; }
.badge-status-Reorder { background: #ffc7ce; color: #9c0006; }
.badge-status-Out { background: #9c0006; color: #fff; }

.lines-table input.form-control, .lines-table select.form-select { min-width: 90px; }

/* ---------- Login ---------- */
.login-page {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--brand-dark), var(--brand));
}
.login-card { width: 100%; max-width: 400px; }

/* ---------- Print ---------- */
.print-header { display: none; }
@media print {
    @page { size: landscape; margin: 10mm; }
    body { background: #fff; font-size: 11px; }
    .sidebar, .topbar, .app-footer, .no-print, .dataTables_filter, .dt-layout-row:not(.dt-layout-table) { display: none !important; }
    .main { margin-left: 0; }
    .content { padding: 0; }
    .card { box-shadow: none; }
    .card-body { padding: 0; }
    .print-header { display: block; margin-bottom: 8px; }
    .table thead th { background: #1f4e79 !important; color: #fff !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .badge, .table-warning, tr.table-warning > td { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .table { font-size: 10.5px; }
}
