:root {
    --erp-sidebar: #101828;
    --erp-sidebar-2: #1d2939;
    --erp-sidebar-text: #b4bcc8;
    --erp-accent: #0f766e;
    --erp-accent-soft: #ccfbf1;
    --erp-bg: #f4f6f8;
    --erp-border: #e4e7ec;
    --erp-ink: #101828;
    --erp-muted: #667085;
    --bs-primary: #0f766e;
    --bs-primary-rgb: 15, 118, 110;
    --bs-link-color: #0f766e;
    --bs-link-color-rgb: 15, 118, 110;
    --bs-link-hover-color: #115e59;
    --bs-body-font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --bs-body-font-size: .875rem;
    --bs-body-color: #101828;
}

body { background: var(--erp-bg); }
.font-monospace, .num { font-family: 'JetBrains Mono', ui-monospace, monospace !important; font-size: .82rem; }
.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }

.btn-primary { --bs-btn-bg: var(--erp-accent); --bs-btn-border-color: var(--erp-accent); --bs-btn-hover-bg: #115e59; --bs-btn-hover-border-color: #115e59; --bs-btn-active-bg: #134e4a; --bs-btn-disabled-bg: var(--erp-accent); --bs-btn-disabled-border-color: var(--erp-accent); }
.btn-outline-primary { --bs-btn-color: var(--erp-accent); --bs-btn-border-color: var(--erp-accent); --bs-btn-hover-bg: var(--erp-accent); --bs-btn-hover-border-color: var(--erp-accent); --bs-btn-active-bg: var(--erp-accent); }
.text-bg-primary { background-color: var(--erp-accent) !important; }
.form-check-input:checked { background-color: var(--erp-accent); border-color: var(--erp-accent); }
.form-control:focus, .form-select:focus { border-color: #5eead4; box-shadow: 0 0 0 .2rem rgba(15, 118, 110, .15); }
.nav-tabs .nav-link.active { font-weight: 600; }

/* Shell */
.erp-shell { display: flex; min-height: 100vh; }
.erp-sidebar { width: 260px; flex-shrink: 0; background: var(--erp-sidebar); color: var(--erp-sidebar-text); }
@media (min-width: 992px) {
    .erp-sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; }
}
.erp-sidebar.offcanvas-lg { --bs-offcanvas-bg: var(--erp-sidebar); }
.erp-brand { display: flex; align-items: center; justify-content: space-between; padding: 1.1rem 1.25rem; border-bottom: 1px solid rgba(255,255,255,.06); }
.erp-logo { width: 32px; height: 32px; border-radius: 8px; background: linear-gradient(135deg, #14b8a6, #0f766e); display: grid; place-items: center; color: #fff; font-size: 1.1rem; }
.erp-brand-name { color: #fff; font-weight: 700; letter-spacing: -.01em; font-size: 1.05rem; }
.erp-nav { padding: .75rem .6rem 2rem; }
.erp-nav-link { display: flex; align-items: center; gap: .7rem; padding: .5rem .75rem; border-radius: 8px; color: var(--erp-sidebar-text); text-decoration: none; font-weight: 500; margin-bottom: 1px; }
.erp-nav-link:hover { background: var(--erp-sidebar-2); color: #fff; }
.erp-nav-link.active { background: rgba(20, 184, 166, .16); color: #5eead4; }
.erp-nav-link .bi:first-child { font-size: 1rem; width: 1.1rem; }
.erp-caret { margin-left: auto; font-size: .7rem; transition: transform .2s; }
.erp-nav-link.collapsed .erp-caret { transform: rotate(-90deg); }
.erp-nav-sub { display: block; padding: .36rem .75rem .36rem 2.55rem; color: #98a2b3; text-decoration: none; border-radius: 6px; font-size: .83rem; position: relative; }
.erp-nav-sub:hover { color: #fff; background: rgba(255,255,255,.04); }
.erp-nav-sub.active { color: #fff; background: rgba(255,255,255,.07); }
.erp-nav-sub.active::before { content: ''; position: absolute; left: 1.55rem; top: 50%; width: 5px; height: 5px; border-radius: 50%; background: #2dd4bf; transform: translateY(-50%); }

.erp-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.erp-topbar { position: sticky; top: 0; z-index: 1020; display: flex; align-items: center; gap: .75rem; padding: .6rem 1.5rem; background: rgba(255,255,255,.92); backdrop-filter: blur(6px); border-bottom: 1px solid var(--erp-border); }
.erp-page-title { font-weight: 600; font-size: 1rem; }
.erp-content { padding: 1.5rem; flex: 1; }
.erp-footer { padding: .75rem 1.5rem; color: var(--erp-muted); font-size: .75rem; border-top: 1px solid var(--erp-border); }
.erp-avatar { width: 26px; height: 26px; border-radius: 50%; background: var(--erp-accent); color: #fff; display: grid; place-items: center; font-size: .75rem; font-weight: 600; }
.erp-company-switch { min-width: 180px; }
.erp-notif-menu { width: 360px; max-height: 460px; overflow-y: auto; }
.erp-notif-item { display: block; padding: .6rem 1rem; border-bottom: 1px solid var(--erp-border); color: inherit; text-decoration: none; }
.erp-notif-item:hover { background: #f9fafb; }
.erp-notif-item.unread { background: #f0fdfa; }
@media (max-width: 575px) { .erp-content { padding: 1rem; } .erp-notif-menu { width: 300px; } }

/* Cards & tables */
.card { border: 1px solid var(--erp-border); border-radius: 12px; box-shadow: 0 1px 2px rgba(16, 24, 40, .04); }
.card-header { background: #fff; border-bottom: 1px solid var(--erp-border); font-weight: 600; padding: .85rem 1.1rem; border-radius: 12px 12px 0 0 !important; }
.card-body { padding: 1.1rem; }
.table { --bs-table-bg: transparent; margin-bottom: 0; }
.table > thead th { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--erp-muted); font-weight: 600; background: #f9fafb; border-bottom-width: 1px; white-space: nowrap; }
.table td, .table th { padding: .55rem .75rem; vertical-align: middle; }
.table-hover > tbody > tr:hover > * { background: #f9fafb; }
.table tfoot td, .table tfoot th { font-weight: 600; background: #f9fafb; }
.table-clickable tbody tr[data-href] { cursor: pointer; }
.badge-status { font-weight: 500; font-size: .72rem; padding: .35em .7em; }

.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; margin-bottom: 1.1rem; }
.page-head h1 { font-size: 1.35rem; font-weight: 700; letter-spacing: -.02em; margin: 0; }
.page-head .sub { color: var(--erp-muted); }
.page-head .actions { margin-left: auto; display: flex; flex-wrap: wrap; gap: .5rem; }

.filter-bar { background: #fff; border: 1px solid var(--erp-border); border-radius: 12px; padding: .75rem; margin-bottom: 1rem; }
.filter-bar .form-control, .filter-bar .form-select { min-width: 140px; }

/* KPI tiles */
.kpi { background: #fff; border: 1px solid var(--erp-border); border-radius: 12px; padding: 1rem 1.1rem; height: 100%; }
.kpi .label { color: var(--erp-muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.kpi .value { font-size: 1.45rem; font-weight: 700; letter-spacing: -.02em; margin-top: .25rem; font-variant-numeric: tabular-nums; }
.kpi .meta { font-size: .78rem; color: var(--erp-muted); }
.kpi .icon { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--erp-accent-soft); color: var(--erp-accent); font-size: 1.1rem; }

/* Document view */
.doc-meta dt { color: var(--erp-muted); font-weight: 500; font-size: .78rem; }
.doc-meta dd { font-weight: 500; margin-bottom: .6rem; }
.totals-table td { padding: .3rem .75rem; }
.totals-table tr.grand td { font-size: 1rem; font-weight: 700; border-top: 2px solid var(--erp-ink); }
.lines-table input, .lines-table select { min-width: 80px; }
.lines-table .col-item { min-width: 220px; }
.lines-table .col-num input { text-align: right; }

.timeline { list-style: none; padding-left: 0; margin: 0; }
.timeline li { position: relative; padding: 0 0 .9rem 1.4rem; border-left: 2px solid var(--erp-border); margin-left: .4rem; }
.timeline li:last-child { border-left-color: transparent; }
.timeline li::before { content: ''; position: absolute; left: -7px; top: 2px; width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 2px solid #98a2b3; }
.timeline li.approved::before, .timeline li.submitted::before { border-color: #12b76a; background: #12b76a; }
.timeline li.rejected::before { border-color: #f04438; background: #f04438; }
.timeline li.pending::before { border-color: #f79009; }

.flow { display: flex; flex-wrap: wrap; gap: .25rem; align-items: center; font-size: .78rem; }
.flow span { padding: .25rem .6rem; border-radius: 99px; background: #f2f4f7; color: var(--erp-muted); }
.flow span.done { background: var(--erp-accent-soft); color: #115e59; }
.flow span.current { background: var(--erp-accent); color: #fff; }
.flow i { color: #d0d5dd; }

/* Kanban */
.kanban { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; }
.kanban-col { background: #eef1f4; border-radius: 12px; padding: .75rem; min-height: 300px; }
.kanban-col h6 { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--erp-muted); display: flex; justify-content: space-between; }
.kanban-card { background: #fff; border: 1px solid var(--erp-border); border-radius: 10px; padding: .65rem .75rem; margin-bottom: .5rem; cursor: grab; }
.kanban-col.drag-over { outline: 2px dashed var(--erp-accent); }

/* Auth */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-side { background: radial-gradient(circle at 20% 20%, #134e4a, #101828 60%); color: #e4e7ec; padding: 3rem; display: flex; flex-direction: column; justify-content: space-between; }
.auth-side h2 { color: #fff; font-weight: 700; letter-spacing: -.03em; font-size: 2rem; }
.auth-form { display: grid; place-items: center; padding: 2rem; background: #fff; }
.auth-form form { width: 100%; max-width: 380px; }
@media (max-width: 900px) { .auth-wrap { grid-template-columns: 1fr; } .auth-side { display: none; } }

/* Print */
@media print {
    .erp-sidebar, .erp-topbar, .erp-footer, .no-print, .btn, .alert { display: none !important; }
    .erp-content { padding: 0; }
    body { background: #fff; }
    .card { border: none; box-shadow: none; }
}
.print-only { display: none; }
@media print { .print-only { display: block; } }

/* Bootstrap's .offcanvas-lg sets background-color: transparent !important at >=lg; keep the dark sidebar. */
.erp-sidebar.offcanvas-lg { background-color: var(--erp-sidebar) !important; }

/* Keep large amounts inside KPI cards on phones */
@media (max-width: 575.98px) {
    .kpi { padding: .85rem .8rem; }
    .kpi .value { font-size: 1.05rem; overflow-wrap: anywhere; }
    .kpi .icon { width: 30px; height: 30px; font-size: .95rem; }
}

/* Billing */
.kpi-icon-lg { width: 48px; height: 48px; border-radius: 12px; display: grid; place-items: center; background: var(--erp-accent-soft); color: var(--erp-accent); font-size: 1.4rem; flex-shrink: 0; }
.border-dashed { border-style: dashed !important; }
