:root {
    --brand: #0f766e;
    --brand-dark: #0b5a54;
    --brand-light: #e6f4f3;
    --sidebar-bg: #103331;
    --sidebar-bg-2: #0c2826;
    --sidebar-text: #cde7e4;
    --sidebar-active: #14958a;
    --topbar-bg: #ffffff;
    --content-bg: #f3f6f7;
    --card-border: #e4e9ea;
    --danger: #c0392b;
    --warning: #b8860b;
    --success: #1e8449;
    --sidebar-width: 264px;
}

* { box-sizing: border-box; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--content-bg);
    color: #1e2b2a;
}

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

/* ---------- Sidebar ---------- */
.app-sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--sidebar-bg) 0%, var(--sidebar-bg-2) 100%);
    color: var(--sidebar-text);
    position: fixed;
    top: 0; left: 0; bottom: 0;
    overflow-y: auto;
    z-index: 1040;
    transition: transform .25s ease;
    padding-bottom: 20px;
}
.sidebar-brand {
    display: flex; align-items: center; gap: 10px;
    padding: 18px 18px; font-weight: 700; font-size: 1.05rem; color: #fff;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-brand i { font-size: 1.4rem; color: var(--sidebar-active); }
.sidebar-nav { padding: 10px 10px; }
.sidebar-nav .nav-link {
    display: flex; align-items: center; gap: 10px;
    color: var(--sidebar-text); padding: 10px 12px; border-radius: 8px;
    font-size: .9rem; font-weight: 500; margin-bottom: 2px;
}
.sidebar-nav .nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar-nav .nav-link.active { background: var(--sidebar-active); color: #fff; }
.nav-group-toggle {
    width: 100%; display: flex; align-items: center; gap: 10px;
    background: none; border: none; color: var(--sidebar-text);
    padding: 10px 12px; font-size: .9rem; font-weight: 500; border-radius: 8px;
}
.nav-group-toggle:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-group-toggle .toggle-icon { margin-left: auto; transition: transform .2s; font-size: .75rem; }
.nav-group-toggle[aria-expanded="true"] .toggle-icon { transform: rotate(180deg); }
.nav-group .collapse .nav-link { padding-left: 34px; font-size: .85rem; font-weight: 400; }
.sidebar-backdrop {
    display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 1035;
}

/* ---------- Main ---------- */
.app-main { flex: 1; margin-left: var(--sidebar-width); display: flex; flex-direction: column; min-height: 100vh; }
.app-topbar {
    height: 62px; background: var(--topbar-bg); border-bottom: 1px solid var(--card-border);
    display: flex; align-items: center; padding: 0 20px; position: sticky; top: 0; z-index: 1020; gap: 10px;
}
.page-title { font-size: 1.15rem; font-weight: 700; margin: 0; }
.topbar-spacer { flex: 1; }
.btn-hamburger { background: none; border: none; font-size: 1.4rem; color: #333; }
.branch-switcher select { min-width: 160px; }
.user-menu-btn {
    display: flex; align-items: center; gap: 8px; background: none; border: 1px solid var(--card-border);
    border-radius: 30px; padding: 5px 12px 5px 5px; font-size: .88rem; font-weight: 600;
}
.avatar {
    width: 30px; height: 30px; border-radius: 50%; background: var(--brand); color: #fff;
    display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .85rem;
}
.app-content { flex: 1; padding: 22px; }
.app-footer { padding: 12px 22px; font-size: .78rem; color: #8a9a99; text-align: center; }

/* ---------- Cards / KPIs ---------- */
.kpi-card {
    background: #fff; border: 1px solid var(--card-border); border-radius: 12px; padding: 18px;
    display: flex; flex-direction: column; gap: 6px; height: 100%;
}
.kpi-card .kpi-label { font-size: .8rem; color: #6b7c7b; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.kpi-card .kpi-value { font-size: 1.55rem; font-weight: 700; }
.kpi-card .kpi-icon {
    width: 42px; height: 42px; border-radius: 10px; display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem; margin-bottom: 4px;
}
.card { border: 1px solid var(--card-border); border-radius: 12px; }
.card-header { background: #fff; border-bottom: 1px solid var(--card-border); font-weight: 700; }

/* ---------- Tables ---------- */
.table-card { background: #fff; border: 1px solid var(--card-border); border-radius: 12px; overflow: hidden; }
table.dataTable thead th { font-size: .78rem; text-transform: uppercase; letter-spacing: .02em; color: #55645f; }
.table > :not(caption) > * > * { padding: .65rem .85rem; }

/* ---------- Voucher entry grid ---------- */
.voucher-lines-table input, .voucher-lines-table select { min-width: 120px; }
.voucher-lines-table .amount-input { text-align: right; min-width: 110px; }
.voucher-totals { font-weight: 700; }
.voucher-totals.balanced { color: var(--success); }
.voucher-totals.unbalanced { color: var(--danger); }

/* ---------- COA tree ---------- */
.coa-tree ul { list-style: none; padding-left: 22px; }
.coa-tree > ul { padding-left: 0; }
.coa-tree .node { padding: 4px 0; display: flex; align-items: center; gap: 8px; }
.coa-tree .node .toggle { cursor: pointer; width: 18px; color: #888; }
.coa-tree .bal-dr { color: var(--brand-dark); }
.coa-tree .bal-cr { color: var(--danger); }

/* ---------- Status badges ---------- */
.badge-draft { background: #f0ad4e; color: #fff; }
.badge-posted { background: var(--success); color: #fff; }
.badge-cancelled { background: #999; color: #fff; }

/* ---------- Responsive ---------- */
@media (max-width: 991.98px) {
    .app-sidebar { transform: translateX(-100%); }
    .app-sidebar.open { transform: translateX(0); box-shadow: 4px 0 24px rgba(0,0,0,.25); }
    .app-main { margin-left: 0; }
    .sidebar-backdrop.show { display: block; }
    .page-title { font-size: 1rem; }
}
@media (max-width: 575.98px) {
    .app-content { padding: 14px; }
    .kpi-card .kpi-value { font-size: 1.25rem; }
}

/* ---------- Command palette ---------- */
.cmdk-backdrop {
    display: none; position: fixed; inset: 0; background: rgba(11,25,24,.55); z-index: 2000;
    align-items: flex-start; justify-content: center; padding-top: 10vh;
}
.cmdk-backdrop.show { display: flex; }
.cmdk-box { width: 100%; max-width: 560px; background: #fff; border-radius: 14px; box-shadow: 0 30px 80px rgba(0,0,0,.35); overflow: hidden; max-height: 70vh; display: flex; flex-direction: column; }
.cmdk-input-row { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--card-border); }
.cmdk-input-row i { color: #8a9a99; font-size: 1.1rem; }
.cmdk-input-row input { flex: 1; border: none; outline: none; font-size: 1rem; }
.cmdk-input-row kbd { font-size: .7rem; background: #f1f5f5; border: 1px solid #dfe6e6; border-radius: 4px; padding: 2px 6px; color: #667; }
.cmdk-results { overflow-y: auto; padding: 6px; }
.cmdk-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 8px; cursor: pointer; }
.cmdk-item i { color: var(--brand); width: 20px; text-align: center; }
.cmdk-item .cmdk-label { font-weight: 600; font-size: .88rem; }
.cmdk-item .cmdk-group { margin-left: auto; font-size: .72rem; color: #8a9a99; }
.cmdk-item.active { background: var(--brand-light); }
.cmdk-empty { padding: 24px; text-align: center; color: #8a9a99; font-size: .88rem; }
.cmdk-footer { border-top: 1px solid var(--card-border); padding: 8px 14px; display: flex; gap: 14px; font-size: .72rem; color: #8a9a99; }
.cmdk-footer kbd { font-size: .68rem; background: #f1f5f5; border: 1px solid #dfe6e6; border-radius: 4px; padding: 1px 5px; }

/* ---------- Shortcuts help modal ---------- */
.shortcuts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 24px; }
@media (max-width: 575.98px) { .shortcuts-grid { grid-template-columns: 1fr; } }
.shortcuts-grid .row-item { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; border-bottom: 1px dashed var(--card-border); font-size: .85rem; }
.shortcuts-grid .shortcuts-subhead { grid-column: 1 / -1; margin-top: 8px; font-size: .8rem; color: #556; text-transform: uppercase; letter-spacing: .03em; }
.shortcuts-grid kbd { background: #f1f5f5; border: 1px solid #dfe6e6; border-radius: 4px; padding: 2px 7px; font-size: .78rem; }

/* ---------- Notification bell ---------- */
.notif-btn { position: relative; background: none; border: 1px solid var(--card-border); border-radius: 10px; width: 38px; height: 38px; display: flex; align-items: center; justify-content: center; font-size: 1.1rem; color: #445; }
.notif-badge { position: absolute; top: -4px; right: -4px; background: var(--danger); color: #fff; font-size: .65rem; font-weight: 700; border-radius: 10px; min-width: 17px; height: 17px; display: flex; align-items: center; justify-content: center; padding: 0 4px; }
.notif-dropdown { width: 340px; max-height: 420px; overflow-y: auto; padding: 6px; }
.notif-item { display: flex; gap: 10px; padding: 10px; border-radius: 8px; align-items: flex-start; }
.notif-item:hover { background: #f6f8f8; }
.notif-item i { font-size: 1.1rem; margin-top: 2px; }
.notif-item .notif-title { font-size: .85rem; font-weight: 600; color: #223; }
.notif-item .notif-detail { font-size: .76rem; color: #7a8a89; }
.notif-empty { padding: 30px 14px; text-align: center; color: #8a9a99; font-size: .85rem; }
.notif-sev-warning i { color: #b8860b; }
.notif-sev-danger i { color: var(--danger); }
.notif-sev-info i { color: var(--brand); }

.login-page {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--sidebar-bg) 0%, var(--brand) 100%); padding: 16px;
}
.login-card { background: #fff; border-radius: 16px; padding: 36px 32px; width: 100%; max-width: 400px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.login-card .brand { text-align: center; margin-bottom: 22px; }
.login-card .brand i { font-size: 2.2rem; color: var(--brand); }
