/* Pharmio — brand colours taken from the logo */
:root {
  --ph-navy: #0b2e6f;
  --ph-blue: #1a73e8;
  --ph-green: #12a26f;
  --ph-sidebar-w: 248px;
  --bs-primary: #1a5fd0;
  --bs-primary-rgb: 26, 95, 208;
  --bs-success: #12a26f;
  --bs-success-rgb: 18, 162, 111;
  --bs-link-color: #1a5fd0;
  --bs-link-color-rgb: 26, 95, 208;
  --bs-body-font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Bengali", "Helvetica Neue", Arial, sans-serif;
  --ph-bg: #f4f7fb;
  --ph-surface: #ffffff;
  --ph-border: #e3e8f0;
  --ph-muted: #64748b;
}
[data-bs-theme="dark"] {
  --ph-bg: #0f172a;
  --ph-surface: #172033;
  --ph-border: #263248;
  --ph-muted: #94a3b8;
  --bs-body-bg: #0f172a;
  --bs-primary: #4f8ff5;
  --bs-primary-rgb: 79, 143, 245;
  --bs-link-color: #7aaaf7;
  --bs-link-color-rgb: 122, 170, 247;
}
body { background: var(--ph-bg); }
.btn-primary { --bs-btn-bg: var(--bs-primary); --bs-btn-border-color: var(--bs-primary); --bs-btn-hover-bg: #164fb0; --bs-btn-hover-border-color: #164fb0; --bs-btn-active-bg: #12439a; }
.btn-success { --bs-btn-bg: var(--ph-green); --bs-btn-border-color: var(--ph-green); --bs-btn-hover-bg: #0e8a5e; --bs-btn-hover-border-color: #0e8a5e; }
.text-primary { color: var(--bs-primary) !important; }

/* Shell */
.app-shell { display: flex; min-height: 100vh; }
.app-sidebar { width: var(--ph-sidebar-w); flex-shrink: 0; background: var(--ph-surface); border-right: 1px solid var(--ph-border);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; z-index: 1040; }
.sidebar-brand { display: block; padding: 18px 20px 14px; border-bottom: 1px solid var(--ph-border); }
.sidebar-brand img { max-width: 100%; height: 40px; object-fit: contain; object-position: left; }
[data-bs-theme="dark"] .sidebar-brand img, [data-bs-theme="dark"] .auth-logo { filter: brightness(1.6) saturate(.9); }
.sidebar-nav { padding: 10px 10px 20px; flex: 1; }
.nav-section { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ph-muted); padding: 14px 12px 6px; font-weight: 600; }
.sidebar-nav .nav-link { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 8px; color: var(--bs-body-color); font-size: .92rem; }
.sidebar-nav .nav-link i { font-size: 1.05rem; color: var(--ph-muted); }
.sidebar-nav .nav-link:hover { background: rgba(var(--bs-primary-rgb), .07); }
.sidebar-nav .nav-link.active { background: rgba(var(--bs-primary-rgb), .12); color: var(--bs-primary); font-weight: 600; }
.sidebar-nav .nav-link.active i { color: var(--bs-primary); }
.sidebar-foot { padding: 10px 20px; font-size: .75rem; color: var(--ph-muted); border-top: 1px solid var(--ph-border); }
.sidebar-backdrop { display: none; }

.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.app-topbar { position: sticky; top: 0; z-index: 1030; display: flex; align-items: center; gap: 12px; padding: 10px 24px;
  background: var(--ph-surface); border-bottom: 1px solid var(--ph-border); }
.branch-switch { display: flex; align-items: center; gap: 8px; }
.branch-switch select { min-width: 200px; }
.topbar-clock { font-size: .85rem; color: var(--ph-muted); font-variant-numeric: tabular-nums; }
.btn-icon { width: 38px; height: 38px; display: inline-flex; align-items: center; justify-content: center; border-radius: 8px; border: 1px solid var(--ph-border); background: transparent; }
.btn-user { display: flex; align-items: center; gap: 8px; border: 1px solid var(--ph-border); border-radius: 999px; padding: 3px 12px 3px 3px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: linear-gradient(135deg, var(--ph-blue), var(--ph-green)); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; font-weight: 600; font-size: .85rem; }
.app-content { padding: 24px; flex: 1; }
.app-footer { padding: 14px 24px; font-size: .8rem; color: var(--ph-muted); border-top: 1px solid var(--ph-border); }

@media (max-width: 991.98px) {
  .app-sidebar { position: fixed; left: 0; transform: translateX(-100%); transition: transform .2s ease; box-shadow: 0 0 40px rgba(0,0,0,.15); }
  body.sidebar-open .app-sidebar { transform: none; }
  body.sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 1035; }
  .app-topbar { padding: 10px 16px; }
  .app-content { padding: 16px; }
  .branch-switch select { min-width: 0; max-width: 46vw; }
}

/* Page building blocks */
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.page-head h1 { font-size: 1.4rem; font-weight: 650; margin: 0; }
.page-head .sub { color: var(--ph-muted); font-size: .9rem; margin-top: 2px; }
.card { border: 1px solid var(--ph-border); border-radius: 12px; background: var(--ph-surface); box-shadow: 0 1px 2px rgba(15,23,42,.04); }
.card-header { background: transparent; border-bottom: 1px solid var(--ph-border); font-weight: 600; padding: 14px 18px; }
.card-body { padding: 18px; }
.table { --bs-table-bg: transparent; margin-bottom: 0; }
.table > thead th { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ph-muted); font-weight: 600; border-bottom-width: 1px; white-space: nowrap; }
.table td { vertical-align: middle; }
.table-responsive { border-radius: 12px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; }
.filters .form-control, .filters .form-select { width: auto; min-width: 160px; }
@media (max-width: 575.98px) { .filters .form-control, .filters .form-select { min-width: 0; flex: 1 1 100%; } }
.kpi { padding: 16px 18px; }
.kpi .label { color: var(--ph-muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
.kpi .value { font-size: 1.6rem; font-weight: 650; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .icon { width: 42px; height: 42px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; font-size: 1.2rem;
  background: rgba(var(--bs-primary-rgb), .1); color: var(--bs-primary); }
.kpi .icon.green { background: rgba(18,162,111,.12); color: var(--ph-green); }
.badge-soft { background: rgba(var(--bs-primary-rgb), .1); color: var(--bs-primary); font-weight: 600; }
.badge-soft-success { background: rgba(18,162,111,.12); color: #0d8a5d; font-weight: 600; }
.badge-soft-secondary { background: rgba(100,116,139,.14); color: var(--ph-muted); font-weight: 600; }
.badge-soft-warning { background: rgba(245,158,11,.15); color: #b45309; font-weight: 600; }
.badge-soft-danger { background: rgba(220,38,38,.12); color: #b91c1c; font-weight: 600; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.form-label { font-weight: 500; font-size: .9rem; }
.required::after { content: " *"; color: #dc2626; }
.perm-grid td, .perm-grid th { text-align: center; }
.perm-grid td:first-child, .perm-grid th:first-child { text-align: left; }
.empty-state { text-align: center; padding: 48px 16px; color: var(--ph-muted); }
.empty-state i { font-size: 2.2rem; display: block; margin-bottom: 8px; }
.dl-grid { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0; }
.dl-grid dt { color: var(--ph-muted); font-weight: 500; }
.dl-grid dd { margin: 0; }

/* Auth pages */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px;
  background: radial-gradient(1200px 600px at 10% -10%, rgba(26,115,232,.12), transparent), radial-gradient(900px 500px at 110% 110%, rgba(18,162,111,.14), transparent), var(--ph-bg); }
.auth-card { width: 100%; max-width: 420px; background: var(--ph-surface); border: 1px solid var(--ph-border); border-radius: 16px; padding: 32px 28px; box-shadow: 0 10px 30px rgba(15,23,42,.08); }
.auth-card.wide { max-width: 760px; }
.auth-logo { height: 52px; max-width: 100%; object-fit: contain; }
.step-badge { width: 26px; height: 26px; border-radius: 50%; background: var(--bs-primary); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: .8rem; font-weight: 600; margin-right: 8px; }

.topbar-search { position: relative; align-items: center; }
.topbar-search i { position: absolute; left: 10px; color: var(--ph-muted); font-size: .85rem; }
.topbar-search input { padding-left: 30px; width: 280px; }
/* Item picker dropdown */
.picker { position: relative; }
.picker-menu { position: fixed; z-index: 1065; max-height: 380px; overflow-y: auto; overscroll-behavior: contain; background: var(--ph-surface);
  border: 1px solid var(--ph-border); border-radius: 8px; box-shadow: 0 10px 30px rgba(15,23,42,.15); display: none; }
.picker-menu.show { display: block; }
.picker-item { padding: 8px 12px; cursor: pointer; border-bottom: 1px solid var(--ph-border); font-size: .9rem; }
.picker-item:last-child { border-bottom: 0; }
.picker-item.active, .picker-item:hover { background: rgba(var(--bs-primary-rgb), .08); }
.picker-item .meta { font-size: .78rem; color: var(--ph-muted); }
.line-table td { vertical-align: top; }
.line-table .form-control, .line-table .form-select { min-width: 80px; }
.tot-row td { font-weight: 600; }
.print-only { display: none; }
.print-header { display: flex; gap: 14px; align-items: center; margin-bottom: 14px; }
.print-header img { height: 40px; }
@media print {
  .app-sidebar, .app-topbar, .app-footer, .no-print, .filters, .pagination, .btn, form.no-print { display: none !important; }
  .print-only { display: flex !important; }
  .app-content { padding: 0; }
  body, .card { background: #fff !important; box-shadow: none !important; }
  .card { border: 0; }
  a { color: inherit; text-decoration: none; }
}
/* Chart series (validated categorical order; dark steps validated against the dark card surface) */
:root { --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100; --chart-grid: #e8ecf2; --chart-text: #52514e; }
[data-bs-theme="dark"] { --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500; --chart-grid: #263248; --chart-text: #c3c2b7; }
.chart-box { position: relative; height: 260px; }
.chart-box.tall { height: 320px; }
.kpi .sub { font-size: .78rem; color: var(--ph-muted); margin-top: 2px; }
.kpi.link { text-decoration: none; color: inherit; display: block; transition: border-color .15s; }
.kpi.link:hover { border-color: var(--bs-primary); }
.sidebar-brand { text-decoration: none; }
