:root {
    --sidebar-width: 250px;
    --sidebar-bg: #0f172a;
    --sidebar-hover: #1e293b;
    --sidebar-active: #0d9488;
    --brand: #0d9488;
    --brand-dark: #0f766e;
    --content-bg: #f1f5f9;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
    font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 0.875rem;
    background: var(--content-bg);
    color: #1e293b;
}

/* ---------------------------------------------------------------- layout */
.app-wrapper { display: flex; min-height: 100vh; }
.app-sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: #cbd5e1;
    position: fixed; top: 0; bottom: 0; left: 0;
    overflow-y: auto; z-index: 1040;
    transition: transform .2s ease;
    scrollbar-width: thin; scrollbar-color: #334155 transparent;
}
.app-sidebar::-webkit-scrollbar { width: 6px; }
.app-sidebar::-webkit-scrollbar-thumb { background: #334155; border-radius: 3px; }
.sidebar-brand { padding: 1rem 1.1rem; border-bottom: 1px solid #1e293b; }
.sidebar-brand a { color: #fff; }
.brand-icon {
    width: 40px; height: 40px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #14b8a6, #0d9488); font-size: 1.3rem; margin-right: .7rem; flex-shrink: 0;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: .95rem; }
.brand-text small { font-size: .7rem; color: #94a3b8; }
.sidebar-nav { padding: .5rem 0 1.5rem; }
.nav-section { padding: .9rem 1.1rem .3rem; font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: #64748b; font-weight: 600; }
.sidebar-nav .nav-item {
    display: flex; align-items: center; gap: .65rem; padding: .48rem 1.1rem; color: #cbd5e1; text-decoration: none;
    font-size: .84rem; border-left: 3px solid transparent; transition: background .15s;
}
.sidebar-nav .nav-item i { width: 18px; text-align: center; font-size: 1rem; color: #94a3b8; }
.sidebar-nav .nav-item:hover { background: var(--sidebar-hover); color: #fff; }
.sidebar-nav .nav-item.active { background: rgba(13,148,136,.18); color: #fff; border-left-color: var(--sidebar-active); }
.sidebar-nav .nav-item.active i { color: #2dd4bf; }

.app-main { flex: 1; margin-left: var(--sidebar-width); display: flex; flex-direction: column; min-width: 0; }
.app-topbar {
    height: 58px; background: #fff; border-bottom: 1px solid #e2e8f0; display: flex; align-items: center; gap: 1rem;
    padding: 0 1.25rem; position: sticky; top: 0; z-index: 1020;
}
.topbar-title h1 { font-weight: 600; }
.avatar {
    width: 26px; height: 26px; border-radius: 50%; background: var(--brand); color: #fff; display: inline-flex;
    align-items: center; justify-content: center; font-size: .75rem; font-weight: 600;
}
.app-content { padding: 1.25rem; flex: 1; }
.app-footer { padding: .75rem 1.25rem; font-size: .75rem; color: #64748b; display: flex; justify-content: space-between; border-top: 1px solid #e2e8f0; background: #fff; }
.sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 1035; }

@media (max-width: 991.98px) {
    .app-sidebar { transform: translateX(-100%); }
    .app-sidebar.show { transform: translateX(0); }
    .sidebar-backdrop.show { display: block; }
    .app-main { margin-left: 0; }
}

/* ---------------------------------------------------------------- components */
.card { border: 1px solid #e2e8f0; box-shadow: 0 1px 2px rgba(15,23,42,.04); border-radius: .6rem; }
.card-header { background: #fff; border-bottom: 1px solid #e2e8f0; font-weight: 600; padding: .7rem 1rem; }
.card-header.bg-light { background: #f8fafc !important; }
.page-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1rem; }
.page-header h2 { font-size: 1.15rem; font-weight: 600; margin: 0; }

.stat-card { border-radius: .6rem; padding: 1rem 1.1rem; background: #fff; border: 1px solid #e2e8f0; height: 100%; position: relative; overflow: hidden; }
.stat-card .stat-icon { position: absolute; right: .9rem; top: .9rem; width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 1.25rem; }
.stat-card .stat-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: #64748b; font-weight: 600; }
.stat-card .stat-value { font-size: 1.25rem; font-weight: 700; margin-top: .25rem; font-variant-numeric: tabular-nums; }
.stat-card .stat-sub { font-size: .75rem; color: #64748b; margin-top: .15rem; }
.bg-soft-primary { background: #ccfbf1; color: #0f766e; }
.bg-soft-success { background: #dcfce7; color: #15803d; }
.bg-soft-warning { background: #fef3c7; color: #b45309; }
.bg-soft-danger { background: #fee2e2; color: #b91c1c; }
.bg-soft-info { background: #dbeafe; color: #1d4ed8; }
.bg-soft-secondary { background: #e2e8f0; color: #334155; }

.btn-primary { background: var(--brand); border-color: var(--brand); }
.btn-primary:hover, .btn-primary:focus { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-outline-primary { color: var(--brand); border-color: var(--brand); }
.btn-outline-primary:hover { background: var(--brand); border-color: var(--brand); }
.text-primary { color: var(--brand) !important; }
.form-label { font-weight: 600; font-size: .8rem; margin-bottom: .25rem; color: #334155; }
.form-label .req { color: #dc2626; }
.form-control, .form-select { font-size: .85rem; }
.form-control-sm, .form-select-sm { font-size: .8rem; }
.input-group-text { font-size: .8rem; }

.table { font-size: .82rem; margin-bottom: 0; }
.table > :not(caption) > * > * { padding: .45rem .6rem; vertical-align: middle; }
.table thead th { background: #e2e8f0; font-weight: 700; color: #0f172a; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; border-bottom: 2px solid #94a3b8; padding-top: .55rem; padding-bottom: .55rem; }
.table thead th a { color: inherit; }
.table tfoot td, .table tfoot th { font-weight: 700; background: #f8fafc; }
.table .group-row td { background: #f1f5f9; font-weight: 600; color: #334155; }
.table .subtotal-row td { font-weight: 600; background: #f8fafc; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.text-dr { color: #15803d; }
.text-cr { color: #b91c1c; }
.mono { font-family: Consolas, "Courier New", monospace; }
.badge { font-weight: 600; }
.table-responsive { border-radius: .5rem; }

.select2-container--bootstrap-5 .select2-selection { font-size: .85rem; min-height: calc(1.5em + .75rem + 2px); }
.select2-container--bootstrap-5 .select2-selection--single .select2-selection__rendered { line-height: 1.5; }
.select2-container--bootstrap-5 .select2-dropdown .select2-results__options .select2-results__option { font-size: .82rem; }

.period-filter .btn { font-size: .78rem; }
.report-title { text-align: center; margin-bottom: 1rem; }
.report-title h3 { font-weight: 700; margin: 0; font-size: 1.2rem; }
.report-title .company { font-size: 1rem; font-weight: 600; color: #475569; }
.report-title .period { color: #64748b; font-size: .85rem; }

.line-items td { padding: .3rem .35rem; }
.line-items .form-control { padding: .25rem .45rem; }
.items-total-box { background: #f8fafc; border: 1px solid #e2e8f0; border-radius: .5rem; padding: .75rem 1rem; }
.items-total-box .row + .row { margin-top: .35rem; }
.items-total-box .grand { font-size: 1.1rem; font-weight: 700; color: var(--brand-dark); }
.rate-hint { font-size: .72rem; color: #64748b; }
.help-box { background: #f0fdfa; border-left: 4px solid var(--brand); padding: .6rem .9rem; border-radius: .3rem; font-size: .8rem; color: #134e4a; }

.entry-lines th, .entry-lines td { font-size: .8rem; }
.voucher-box { border: 1px solid #e2e8f0; border-radius: .5rem; padding: 1rem 1.25rem; background: #fff; }
.voucher-box dt { font-size: .72rem; text-transform: uppercase; color: #64748b; letter-spacing: .04em; font-weight: 600; }
.voucher-box dd { margin-bottom: .6rem; font-weight: 500; }

/* ---------------------------------------------------------------- print */
@media print {
    .app-sidebar, .app-topbar, .app-footer, .no-print, .sidebar-backdrop { display: none !important; }
    .app-main { margin-left: 0 !important; }
    .app-content { padding: 0 !important; }
    body { background: #fff; font-size: 11px; }
    .card { border: none; box-shadow: none; }
    .table { font-size: 10.5px; }
    .table thead th { background: #e2e8f0 !important; color: #000 !important; font-weight: 700; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    a { text-decoration: none; color: inherit; }
    .print-only { display: block !important; }
}
.print-only { display: none; }
