:root {
  --erp-bg: #f4f6fa;
  --erp-surface: #ffffff;
  --erp-border: #e3e8ef;
  --erp-text: #1b2533;
  --erp-muted: #5f6b7a;
  --erp-primary: #0f6e8c;
  --erp-primary-soft: #e3f2f6;
  --erp-sidebar: #0e2a36;
  --erp-sidebar-text: #c8d7de;
  --erp-sidebar-active: #134152;
  --bs-primary: #0f6e8c;
  --bs-primary-rgb: 15, 110, 140;
  --bs-link-color: #0f6e8c;
  --bs-link-color-rgb: 15, 110, 140;
  --bs-body-font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --erp-bg: #0f151c; --erp-surface: #172029; --erp-border: #26323f; --erp-text: #e4eaf0; --erp-muted: #9aa8b6;
    --erp-primary-soft: #12313b; --erp-sidebar: #0a1218; --erp-sidebar-active: #15303b;
    /* Bootstrap component colours follow these variables. */
    --bs-body-color: #e4eaf0; --bs-body-color-rgb: 228, 234, 240; --bs-body-bg: #0f151c; --bs-body-bg-rgb: 15, 21, 28;
    --bs-emphasis-color: #ffffff; --bs-heading-color: #f1f5f9; --bs-secondary-color: #9aa8b6; --bs-secondary-bg: #1d2731;
    --bs-tertiary-bg: #1a232d; --bs-tertiary-color: #9aa8b6; --bs-border-color: #2c3946; --bs-border-color-translucent: rgba(255, 255, 255, .12);
    --bs-form-control-bg: #0f171f; --bs-light-rgb: 34, 45, 56; --bs-dark-rgb: 222, 226, 230;
    --bs-link-color: #5cc4d9; --bs-link-color-rgb: 92, 196, 217; --bs-link-hover-color: #8ad6e6;
  }
  :root:not([data-theme="light"]) body { color-scheme: dark; }
  :root:not([data-theme="light"]) .table { --bs-table-color: var(--erp-text); --bs-table-bg: transparent; --bs-table-border-color: var(--erp-border); }
  :root:not([data-theme="light"]) .form-control, :root:not([data-theme="light"]) .form-select { background-color: #0f171f; color: var(--erp-text); border-color: var(--erp-border); }
  :root:not([data-theme="light"]) .btn-light { --bs-btn-bg: #222d38; --bs-btn-color: var(--erp-text); --bs-btn-border-color: #2c3946; --bs-btn-hover-bg: #2a3744; --bs-btn-hover-color: #fff; }
  :root:not([data-theme="light"]) .dropdown-menu, :root:not([data-theme="light"]) .modal-content, :root:not([data-theme="light"]) .list-group-item { background: var(--erp-surface); color: var(--erp-text); }
  :root:not([data-theme="light"]) .text-bg-light { background: #26323f !important; color: var(--erp-text) !important; }
  :root:not([data-theme="light"]) .metric-card.alert-tone .metric-value, :root:not([data-theme="light"]) .text-danger { color: #f97066 !important; }
  :root:not([data-theme="light"]) .metric-card.warn-tone .metric-value, :root:not([data-theme="light"]) .text-warning { color: #fdb022 !important; }
  :root:not([data-theme="light"]) .content a:not(.btn):not(.metric-card):not(.dropdown-item) { color: #5cc4d9; }
  :root:not([data-theme="light"]) .topbar .btn-light { color: var(--erp-text); }
}

html, body { background: var(--erp-bg); color: var(--erp-text); }
body { font-size: .935rem; }
a { color: var(--erp-primary); }
.text-secondary, .muted { color: var(--erp-muted) !important; }
.card { background: var(--erp-surface); border: 1px solid var(--erp-border); border-radius: 14px; box-shadow: 0 1px 2px rgba(16, 24, 40, .04); }
.card-header { background: transparent; border-bottom: 1px solid var(--erp-border); font-weight: 600; }
.table { --bs-table-bg: transparent; }
.table > :not(caption) > * > * { padding: .55rem .65rem; vertical-align: middle; }
.table thead th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--erp-muted); font-weight: 600; white-space: nowrap; }
.table-sm > :not(caption) > * > * { padding: .35rem .5rem; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85em; white-space: nowrap; }
kbd { font-size: .7rem; background: rgba(0, 0, 0, .25); padding: .05rem .3rem; }

/* Shell */
/* !important: Bootstrap's .offcanvas-lg forces a transparent background at >= 992px. */
.has-sidebar .sidebar { width: 240px; background-color: var(--erp-sidebar) !important; color: var(--erp-sidebar-text); }
@media (min-width: 992px) {
  .has-sidebar .sidebar { position: fixed; inset: 0 auto 0 0; overflow-y: auto; }
  .has-sidebar .main-wrap { margin-left: 240px; }
}
.sidebar .offcanvas-header { color: #fff; }
.sidebar-inner { padding: 1rem .75rem 2rem; }
.sidebar .brand { display: flex; align-items: center; gap: .5rem; color: #fff; font-weight: 700; font-size: 1.1rem; text-decoration: none; padding: .25rem .5rem .75rem; }
.sidebar .brand i { color: #5cc4d9; }
.sidebar .store-name { font-size: .78rem; color: #8fb1bd; padding: 0 .5rem .5rem; }
.sidebar .nav-section { font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: #7d98a3; padding: .9rem .6rem .3rem; }
.sidebar .nav-link { display: flex; align-items: center; gap: .6rem; color: var(--erp-sidebar-text); border-radius: 8px; padding: .45rem .6rem; font-size: .9rem; }
.sidebar .nav-link:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.sidebar .nav-link.active { background: var(--erp-sidebar-active); color: #fff; box-shadow: inset 3px 0 0 #5cc4d9; }
.topbar { position: sticky; top: 0; z-index: 1020; display: flex; align-items: center; gap: .5rem; padding: .6rem 1.25rem; background: var(--erp-surface); border-bottom: 1px solid var(--erp-border); }
.content { padding: 1.25rem; max-width: 1500px; }
@media (max-width: 575.98px) { .content { padding: 1rem; } .topbar { padding: .5rem 1rem; } }
.guest-main { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem; }

/* Page header */
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: .75rem; margin-bottom: 1rem; }
.page-head h1 { font-size: 1.45rem; margin: 0; font-weight: 700; }
.page-head .eyebrow { font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--erp-primary); margin-bottom: .15rem; }

/* Metrics */
.metric-card { padding: 1rem 1.1rem; height: 100%; color: var(--erp-text); display: block; }
a.metric-card:hover { border-color: var(--erp-primary); }
.metric-label { color: var(--erp-muted); font-size: .8rem; margin-bottom: .25rem; display: flex; gap: .4rem; align-items: center; }
.metric-value { font-size: 1.45rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.metric-sub { font-size: .78rem; color: var(--erp-muted); }
.metric-card.alert-tone .metric-value { color: #b42318; }
.metric-card.warn-tone .metric-value { color: #b54708; }
.quick-actions .btn { display: inline-flex; align-items: center; gap: .4rem; }
.chart-box { position: relative; height: 260px; }

/* POS */
.pos-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 1rem; align-items: start; }
@media (max-width: 1199.98px) { .pos-grid { grid-template-columns: 1fr; } }
.pos-search { position: relative; }
.pos-search input { font-size: 1.05rem; padding: .7rem 1rem .7rem 2.5rem; }
.pos-search .bi-upc-scan { position: absolute; left: .85rem; top: 50%; transform: translateY(-50%); color: var(--erp-muted); }
.ac-menu { position: absolute; left: 0; right: 0; top: 100%; z-index: 1050; max-height: 360px; overflow-y: auto; background: var(--erp-surface); border: 1px solid var(--erp-border); border-radius: 10px; box-shadow: 0 10px 30px rgba(16, 24, 40, .15); margin-top: .25rem; }
.ac-item { padding: .55rem .8rem; cursor: pointer; border-bottom: 1px solid var(--erp-border); }
.ac-item:last-child { border-bottom: 0; }
.ac-item.active, .ac-item:hover { background: var(--erp-primary-soft); }
.ac-item .ac-sub { font-size: .78rem; color: var(--erp-muted); }
.pos-lines input.form-control-sm, .pos-lines select.form-select-sm { min-width: 64px; }
.pos-lines td { vertical-align: top; }
.pos-total { font-size: 2rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.pos-summary dt { font-weight: 500; color: var(--erp-muted); }
.pos-summary dd { text-align: right; margin-bottom: .25rem; font-variant-numeric: tabular-nums; }
.batch-note { font-size: .75rem; color: var(--erp-muted); }
.is-busy { position: relative; pointer-events: none; opacity: .7; }

/* Forms */
.form-label { font-weight: 500; font-size: .85rem; margin-bottom: .25rem; }
.required::after { content: " *"; color: #b42318; }
.lines-table input, .lines-table select { min-width: 84px; }
.lines-table input[type=month] { min-width: 150px; }
.lines-table select[data-f="purchase_unit"] { min-width: 140px; }
.pos-lines select[data-k="sale_unit"] { min-width: 120px; }
.lines-table .col-med { min-width: 240px; }

/* Print helpers (screen) */
.doc-meta dt { color: var(--erp-muted); font-weight: 500; font-size: .8rem; }
.doc-meta dd { margin-bottom: .5rem; }
