:root {
    --sidebar-w: 255px;
    --primary: #0d6efd;
    --dark-bg: #212529;
}

body {
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    background: #f4f6fb;
    font-size: 0.9rem;
}

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

/* ---------- Sidebar ---------- */
.sidebar {
    width: var(--sidebar-w);
    min-height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 1040;
    overflow-y: auto;
    background: #1c2331 !important;
    transition: transform .25s ease;
}
.sidebar .nav-link {
    color: #aab3c5;
    border-radius: 8px;
    padding: 0.55rem 0.75rem;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
}
.sidebar .nav-link:hover { color: #fff; background: rgba(255,255,255,.06); }
.sidebar .nav-link.active { color: #fff; background: var(--primary); }
.sidebar .submenu { padding-left: 1.1rem; }
.sidebar .submenu .nav-link { font-size: 0.85rem; }
.sidebar .submenu .nav-link.active { background: rgba(13,110,253,.18); color: #8ab4ff; }
.sidebar .chev { transition: transform .2s; font-size: .7rem; }
.sidebar .nav-link[aria-expanded="true"] .chev { transform: rotate(180deg); }
.sidebar .nav-section { letter-spacing: .5px; font-size: .7rem; }
.sidebar .sidebar-brand { background: rgba(0,0,0,.15); }
.sidebar .sidebar-footer { margin-top: auto; }

/* ---------- Main area ---------- */
.app-main {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    width: calc(100% - var(--sidebar-w));
}
.topbar { position: sticky; top: 0; z-index: 1030; }
.content { flex: 1; }
.footer { flex-shrink: 0; }

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

/* ---------- Cards ---------- */
.card { border: 0; border-radius: 12px; box-shadow: 0 2px 10px rgba(16,40,90,.06); }
.card-header { background: #fff; border-bottom: 1px solid #eef1f6; border-radius: 12px 12px 0 0 !important; font-weight: 600; }
.stat-card { border-radius: 12px; color: #fff; position: relative; overflow: hidden; }
.stat-card .stat-icon { position: absolute; right: 14px; top: 14px; font-size: 2rem; opacity: .35; }
.stat-card .stat-value { font-size: 1.6rem; font-weight: 700; }

.bg-gradient-primary { background: linear-gradient(135deg, #0d6efd, #0a58ca); }
.bg-gradient-success { background: linear-gradient(135deg, #198754, #146c43); }
.bg-gradient-warning { background: linear-gradient(135deg, #fd7e14, #e95f02); }
.bg-gradient-info { background: linear-gradient(135deg, #0dcaf0, #0aa2c0); }
.bg-gradient-danger { background: linear-gradient(135deg, #dc3545, #b02a37); }
.bg-gradient-purple { background: linear-gradient(135deg, #6f42c1, #5936a2); }
.bg-gradient-teal { background: linear-gradient(135deg, #20c997, #159f7c); }

/* ---------- Tables ---------- */
.table { --bs-table-hover-bg: #f6f9ff; }
.table thead th {
    background: #f8f9fc;
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .3px;
    white-space: nowrap;
    border-bottom: 2px solid #e4e9f2;
}
.table td { vertical-align: middle; }
.sortable { cursor: pointer; user-select: none; }
.sortable:hover { color: var(--primary); }
.sortable .sort-ind { font-size: .7rem; color: #b6c2d3; }

.avatar-sm { width: 34px; height: 34px; font-size: .85rem; }

/* ---------- Forms ---------- */
.form-label { font-weight: 600; font-size: .82rem; color: #495057; }
.required::after { content: " *"; color: #dc3545; }
.form-control, .form-select { border-radius: 8px; }
.form-control:focus, .form-select:focus { box-shadow: 0 0 0 .2rem rgba(13,110,253,.12); border-color: #86b7fe; }

/* ---------- Voucher form ---------- */
.pay-type-box {
    display: inline-flex; align-items: center; gap: .6rem;
    border: 2px solid #e3e7ef; border-radius: 10px; padding: .55rem 1rem;
    cursor: pointer; transition: all .15s; background: #fff;
}
.pay-type-box.selected { border-color: var(--primary); background: #eef5ff; }
.voucher-amount-box { font-size: 1.35rem; font-weight: 700; color: var(--primary); }
.words-box {
    background: #f8f9fc; border-radius: 8px; padding: .55rem .9rem;
    font-size: .85rem; color: #6c757d; min-height: 42px; border: 1px dashed #d3d9e5;
}

/* ---------- Grid ---------- */
.search-panel { background: #fff; border-radius: 12px; }
.grid-toolbar .btn { font-size: .82rem; }
.page-link { cursor: pointer; }

/* ---------- Print voucher ---------- */
.voucher-paper {
    max-width: 760px; margin: 0 auto; background: #fff;
    border: 1px solid #dee2e6; border-radius: 8px; padding: 30px;
}
.voucher-paper .voucher-head { border-bottom: 3px double #000; padding-bottom: 12px; }
.voucher-paper .sig-box { height: 70px; }
.voucher-paper .info-table td { padding: 5px 8px; font-size: .9rem; }

/* ---------- Toast ---------- */
#toastWrap { position: fixed; top: 16px; right: 16px; z-index: 2000; }

/* ---------- Print ---------- */
@media print {
    .sidebar, .topbar, .footer, .no-print, .card-header .btn { display: none !important; }
    .app-main { margin-left: 0; width: 100%; }
    .content { padding: 0 !important; }
    .card { box-shadow: none; border: none; }
    body { background: #fff; }
}
