:root {
  --primary: #2458a6;
  --primary-dark: #183e78;
  --primary-soft: #e9f1fb;
  --secondary: #147d82;
  --secondary-soft: #e7f5f4;
  --light: #f7f9fc;
  --soft: #edf3fa;
  --success: #257a55;
  --warning: #a96a12;
  --danger: #b84444;
  --dark: #202c3d;
  --muted: #657286;
  --bg: #f3f6fa;
  --bg-alt: #eef2f7;
  --card: #fff;
  --border: #dce4ee;
  --shadow: 0 4px 14px rgba(25, 48, 78, .055);
  --radius: 10px;
  color-scheme: light;
}

html.theme-dark {
  --primary: #7aa8e8;
  --primary-dark: #c0d7fa;
  --primary-soft: #20334d;
  --secondary: #62b8b7;
  --secondary-soft: #1a393a;
  --light: #172233;
  --soft: #202d40;
  --success: #72c59a;
  --warning: #e7b55e;
  --danger: #e68787;
  --dark: #e7edf5;
  --muted: #a8b5c7;
  --bg: #101926;
  --bg-alt: #121d2b;
  --card: #192536;
  --border: #2b3a4e;
  --shadow: 0 5px 18px rgba(0, 0, 0, .18);
  color-scheme: dark;
}

body,
html.theme-dark body {
  background: var(--bg);
  color: var(--dark);
}

body {
  line-height: 1.55;
}

.boot-fallback { background: var(--bg); }
.boot-panel {
  width: min(100%, 340px);
  gap: 12px;
  padding: 27px 23px 24px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
  color: var(--dark);
  box-shadow: 0 14px 42px rgba(25, 48, 78, .12);
  backdrop-filter: none;
}
.boot-panel::before { display: none; }
.boot-logo {
  width: 82px;
  height: 82px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 5px;
  box-shadow: 0 3px 10px rgba(25, 48, 78, .08);
  animation: none;
}
.boot-spinner { width: 144px; background: var(--soft); }
.boot-spinner::after { background: var(--primary); }
.boot-panel strong { color: var(--primary-dark); font-size: 19px; }
.boot-panel span { color: var(--muted); }

html.theme-dark .boot-fallback { background: var(--bg); }
html.theme-dark .boot-panel { border-color: var(--border); background: var(--card); color: var(--dark); }
html.theme-dark .boot-logo { border-color: var(--border); background: #fff; }
html.theme-dark .boot-panel strong { color: var(--dark); }

.app-shell-header {
  max-width: none;
  margin: 0;
  padding: 10px clamp(16px, 3vw, 42px) 8px;
  gap: 8px 20px;
  border: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  background: rgba(255, 255, 255, .97);
  color: var(--dark);
  box-shadow: 0 2px 10px rgba(25, 48, 78, .05);
  backdrop-filter: blur(14px);
}

html.theme-dark .app-shell-header {
  background: rgba(22, 33, 48, .97);
  border-bottom-color: var(--border);
  box-shadow: 0 2px 12px rgba(0, 0, 0, .18);
}

.brand-lockup { gap: 11px; }
.brand-logo {
  width: 42px;
  height: 42px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  box-shadow: none;
}

.shell-eyebrow,
#headerContextText { display: none; }

.app-shell-brand h1 {
  margin: 0;
  color: var(--primary-dark);
  font-size: 17px;
  font-weight: 800;
  line-height: 1.35;
}

.app-shell-actions {
  width: auto;
  margin-inline-start: auto;
  gap: 8px;
  flex-wrap: nowrap;
  justify-content: flex-end;
}
.shell-status-card {
  display: flex;
  order: 0;
  width: auto;
  min-width: 0;
  gap: 6px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
}

.shell-status-card span { display: none; }
.shell-status-card .shell-user-line,
.shell-status-card span:last-child {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 5px 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--light);
  white-space: nowrap;
}

.shell-status-card span:last-child::before {
  width: 7px;
  height: 7px;
  margin-inline-end: 6px;
  border-radius: 50%;
  background: var(--success);
  content: "";
}

.shell-actions-group { gap: 6px; flex-wrap: nowrap; }
.app-shell-actions .shell-icon-btn,
.shell-logout-btn,
.shell-install-btn {
  width: 36px;
  min-width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  color: #40536c;
  box-shadow: none;
}

.app-shell-actions .shell-icon-btn:hover,
.shell-logout-btn:hover,
.shell-install-btn:hover {
  transform: none;
  border-color: #a9bfdc;
  background: var(--primary-soft);
  color: var(--primary-dark);
}

.app-shell-actions .shell-icon-btn.btn-primary {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.shell-menu-btn,
.shell-menu-btn.is-active {
  border-color: var(--border) !important;
  background: var(--primary-soft) !important;
  color: var(--primary-dark) !important;
}

.shell-logout-btn { color: var(--danger); }
.shell-action-label { display: none; }
.shell-icon { font-size: 17px; }
.shell-action-badge { border-color: var(--card); }
.app-shell-actions .shell-icon-btn.has-alert { background: #b7791f; color: #fff; }

.quick-access-bar {
  flex: 1 0 100%;
  display: flex;
  gap: 4px;
  max-height: none;
  padding: 6px 0 0;
  overflow-x: auto;
  overflow-y: hidden;
  border: 0;
  border-radius: 0;
  background: transparent;
  scrollbar-width: none;
}

.quick-access-bar::-webkit-scrollbar { display: none; }
.quick-access-item {
  flex: 0 0 auto;
  min-height: 32px;
  padding: 6px 11px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.quick-access-item:hover,
.quick-access-item:focus-visible {
  border-color: var(--border);
  background: var(--light);
  color: var(--primary-dark);
}

.quick-access-item.is-active {
  border-color: #c7d9f1;
  background: var(--primary-soft);
  color: var(--primary-dark);
  box-shadow: none;
}

.app-shell-header.is-compact {
  padding: 8px clamp(16px, 3vw, 42px);
  border-radius: 0;
  box-shadow: 0 2px 10px rgba(25, 48, 78, .06);
}

.app-shell-header.is-compact .app-shell-brand h1 { margin: 0; font-size: 16px; }
.app-shell-header.is-compact .brand-logo { width: 38px; height: 38px; border-radius: 9px; }
.app-shell-header.is-compact .shell-status-card { max-width: none; opacity: 1; }
.app-shell-header.is-compact .app-shell-actions .shell-icon-btn { width: 36px; min-width: 36px; height: 36px; }

.app {
  max-width: 1280px;
  padding: 22px clamp(14px, 2.4vw, 30px) 34px;
}

.topbar {
  align-items: center;
  gap: 12px 18px;
  margin-bottom: 16px;
  padding-bottom: 13px;
  border-bottom: 1px solid var(--border);
}

.brand { margin: 0; color: var(--primary-dark); font-size: 23px; line-height: 1.3; }
.topbar-note { margin-top: 4px; color: var(--muted); font-size: 13px; line-height: 1.65; }
.quick-links { gap: 7px; }

.branch-badge,
.role-badge,
.status-badge {
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--light);
  color: var(--primary-dark);
  font-size: 12px;
}

.card,
.branch-overview-card,
.seller-overview-card,
.list-card,
.branch-product-card,
.summary-tile,
.total-line,
.details-grid div,
.profile-metric,
.reports-branch-option-card,
.compact-product-row,
.branch-receivable-box {
  border-color: var(--border);
  border-radius: 10px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.card { padding: 16px; }
.list-card,
.branch-overview-card,
.seller-overview-card { padding: 15px; }

.btn {
  min-height: 38px;
  padding: 8px 13px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.35;
  transition: background-color .16s ease, border-color .16s ease, box-shadow .16s ease;
}

.btn:hover { transform: none; box-shadow: 0 3px 9px rgba(22, 49, 82, .11); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--secondary); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-warning { background: #b7791f; color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-light {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--primary-dark);
}

.field label { margin-bottom: 5px; color: var(--dark); font-size: 12px; font-weight: 700; }
.field input,
.field select,
.field textarea,
.medicine-search-field input,
.medicine-name-field select,
.invoice-inline-input {
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  color: var(--dark);
  font-size: 14px;
  box-shadow: none;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.medicine-search-field input:focus {
  border-color: #7197ca;
  box-shadow: 0 0 0 3px rgba(36, 88, 166, .12);
  outline: none;
}

table th {
  background: var(--light);
  color: #43546b;
  font-size: 12px;
  font-weight: 800;
}

table td { color: var(--dark); font-size: 13px; }
table th,
table td { border-bottom-color: var(--border); }

.responsive-card-table tr {
  border-color: var(--border);
  border-radius: 9px;
  background: var(--card);
  box-shadow: 0 2px 8px rgba(25, 48, 78, .035);
}

.app-dialog,
.debt-payment-dialog,
.barcode-scanner-panel {
  border-color: var(--border);
  border-radius: 12px;
  background: var(--card);
  box-shadow: 0 18px 48px rgba(18, 38, 65, .18);
}

.app-dialog-title { color: var(--primary-dark); font-size: 20px; }
.app-dialog-message { color: var(--muted); font-size: 14px; }

.login-body { background: var(--bg); }
.login-wrap {
  min-height: 100vh;
  min-height: 100svh;
  padding: clamp(14px, 3vw, 32px);
  gap: 12px;
  background: var(--bg);
}

.login-shell {
  width: min(100%, 900px);
  min-height: min(560px, calc(100svh - 80px));
  grid-template-columns: minmax(0, .88fr) minmax(360px, 1fr);
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
  box-shadow: 0 14px 42px rgba(25, 48, 78, .11);
}

.login-shell::before { height: 4px; background: var(--primary); }
.login-visual { background: #193f73; }
.login-visual-photo { background: #193f73; }
.login-visual-photo::after { inset: 18px; border-color: rgba(255, 255, 255, .13); border-radius: 9px; }
.login-visual-content { min-height: 0; padding: 28px; }
.login-visual .login-brand-lockup { gap: 14px; }
.login-visual .login-logo { width: 112px; height: 112px; padding: 8px; border-radius: 12px; box-shadow: 0 10px 24px rgba(8, 25, 48, .2); }
.login-visual .login-kicker { margin-bottom: 7px; border: 0; border-radius: 5px; background: rgba(255, 255, 255, .13); color: #e8f1fc; }
.login-visual h1 { font-size: 27px; }
.login-card { padding: clamp(24px, 4vw, 42px); background: var(--card); }
.login-card .login-kicker { border: 0; border-radius: 5px; background: var(--primary-soft); color: var(--primary-dark); }
.login-card h2 { color: var(--dark); font-size: 25px; }
.login-form { gap: 12px; }
.login-form .field input { min-height: 44px; border-radius: 8px; background: var(--light); }
.login-form .btn { min-height: 44px; border-radius: 8px; }
.login-submit-btn { background: var(--primary); box-shadow: none; }
.login-credit { color: var(--muted); text-shadow: none; }

html.theme-dark .login-shell,
html.theme-dark .login-card { border-color: var(--border); background: var(--card); }
html.theme-dark .login-visual,
html.theme-dark .login-visual-photo { background: #142c49; }
html.theme-dark .login-card h2 { color: var(--dark); }
html.theme-dark .login-card .login-kicker { background: #20334d; color: #c0d7fa; }
html.theme-dark .login-form .field input { border-color: var(--border); background: #121d2b; color: var(--dark); }
html.theme-dark .login-credit { color: var(--muted); }

#dashboardPage.dashboard-page { max-width: 1240px; padding-top: 18px; }

#dashboardPage .dashboard-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, auto);
  align-items: center;
  gap: 14px 22px;
  margin-bottom: 16px;
  padding: 4px 0 15px;
  overflow: visible;
  border: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

#dashboardPage .dashboard-hero::before { content: none; }
#dashboardPage .dashboard-hero-copy,
#dashboardPage .dashboard-hero-actions { position: static; z-index: auto; }
#dashboardPage .dashboard-hero-copy { min-height: 0; }

#dashboardPage .dashboard-eyebrow {
  width: max-content;
  margin: 0 0 4px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--secondary);
  font-size: 11px;
  font-weight: 800;
}

#dashboardPage .dashboard-hero .brand {
  color: var(--primary-dark);
  font-size: 25px;
  line-height: 1.25;
}

#dashboardPage .dashboard-hero .topbar-note {
  max-width: 660px;
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

#dashboardPage .dashboard-hero-actions {
  justify-content: flex-start;
  align-content: center;
  gap: 6px;
}

#dashboardPage .dashboard-hero-actions .branch-badge,
#dashboardPage .dashboard-hero-actions .role-badge {
  min-height: 32px;
  padding: 5px 9px;
  border-color: var(--border);
  border-radius: 7px;
  background: var(--light);
  box-shadow: none;
}

#dashboardPage .dashboard-hero-actions .btn {
  min-height: 34px;
  padding: 6px 10px;
  border-radius: 7px;
  box-shadow: none;
}

#dashboardPage .dashboard-stats-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}

#dashboardPage .dashboard-stat-card,
#dashboardPage .dashboard-stat-card:nth-child(n) {
  grid-column: auto;
  min-height: 91px;
  padding: 13px 15px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--card);
  box-shadow: var(--shadow);
}

#dashboardPage .dashboard-stat-card::after { content: none; }
#dashboardPage .dashboard-stat-card h3 {
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

#dashboardPage .dashboard-stat-card h3::before {
  width: 6px;
  height: 6px;
  margin-inline-end: 6px;
  background: var(--secondary);
}

#dashboardPage .dashboard-stat-card:nth-child(2) h3::before,
#dashboardPage .dashboard-stat-card:nth-child(5) h3::before { background: #6688b4; }
#dashboardPage .dashboard-stat-card:nth-child(3) h3::before { background: #ba8b3c; }
#dashboardPage .dashboard-stat-card:nth-child(4) h3::before { background: var(--primary); }
#dashboardPage .dashboard-stat-card:nth-child(6) h3::before { background: var(--danger); }

#dashboardPage .dashboard-stat-card .value {
  color: var(--dark);
  font-size: 23px;
  line-height: 1.2;
}

#dashboardPage .dashboard-section-head { margin: 0 0 9px; }
#dashboardPage .dashboard-section-head .section-title { color: var(--dark); font-size: 17px; }
#dashboardPage .dashboard-menu-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 9px;
  margin-top: 0;
}

#dashboardPage .dashboard-menu-grid .menu-card {
  min-height: 86px;
  grid-template-columns: 38px minmax(0, 1fr);
  grid-template-rows: 1fr;
  align-content: center;
  justify-items: start;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--card);
  box-shadow: 0 2px 8px rgba(25, 48, 78, .035);
  text-align: start;
  transition: border-color .16s ease, background-color .16s ease, box-shadow .16s ease;
}

#dashboardPage .dashboard-menu-grid .menu-card::before,
#dashboardPage .dashboard-menu-grid .menu-card::after { content: none; }

#dashboardPage .dashboard-menu-grid .menu-card:hover {
  transform: none;
  border-color: #a8bfdc;
  background: var(--light);
  box-shadow: 0 4px 12px rgba(25, 48, 78, .07);
}

#dashboardPage .dashboard-menu-grid .menu-card .icon {
  width: 36px;
  height: 36px;
  margin: 0;
  border: 1px solid #dce8f5;
  border-radius: 8px;
  background: var(--primary-soft);
  box-shadow: none;
  font-size: 19px;
  filter: saturate(.58);
}

#dashboardPage .dashboard-menu-grid .menu-card .title {
  color: var(--dark);
  font-size: 13px;
  line-height: 1.4;
}

#dashboardPage .dashboard-menu-grid .barcode-inquiry-card,
#dashboardPage .dashboard-menu-grid .barcode-inquiry-card:hover {
  border-color: #c3d6ef;
  background: #edf4fd;
  color: var(--primary-dark);
}

#dashboardPage .dashboard-menu-grid .barcode-inquiry-card .icon {
  border-color: #ccdcf0;
  background: #fff;
  color: var(--primary);
}

#dashboardPage .dashboard-menu-grid .barcode-inquiry-card .title { color: var(--primary-dark); }

html.theme-dark #dashboardPage .dashboard-hero {
  border-bottom-color: var(--border);
  background: transparent;
}

html.theme-dark #dashboardPage .dashboard-hero .brand,
html.theme-dark #dashboardPage .dashboard-section-head .section-title,
html.theme-dark #dashboardPage .dashboard-stat-card .value,
html.theme-dark #dashboardPage .dashboard-menu-grid .menu-card .title {
  color: var(--dark);
}

html.theme-dark #dashboardPage .dashboard-hero .topbar-note,
html.theme-dark #dashboardPage .dashboard-stat-card h3 { color: var(--muted); }
html.theme-dark #dashboardPage .dashboard-eyebrow { background: transparent; color: #75c3c2; }

html.theme-dark #dashboardPage .dashboard-stat-card,
html.theme-dark #dashboardPage .dashboard-stat-card:nth-child(n),
html.theme-dark #dashboardPage .dashboard-menu-grid .menu-card {
  border-color: var(--border);
  background: var(--card);
  box-shadow: var(--shadow);
}

html.theme-dark #dashboardPage .dashboard-menu-grid .menu-card .icon {
  border-color: #344960;
  background: #20334d;
}

html.theme-dark #dashboardPage .dashboard-menu-grid .barcode-inquiry-card,
html.theme-dark #dashboardPage .dashboard-menu-grid .barcode-inquiry-card:hover {
  border-color: #35577e;
  background: #1b2d45;
}

html.theme-dark #dashboardPage .dashboard-menu-grid .barcode-inquiry-card .icon {
  border-color: #35577e;
  background: #243b58;
  color: #b7d2f6;
}

html.theme-dark #dashboardPage .dashboard-menu-grid .barcode-inquiry-card .title { color: #c0d7fa; }

html.theme-dark .card,
html.theme-dark .branch-overview-card,
html.theme-dark .seller-overview-card,
html.theme-dark .list-card,
html.theme-dark .branch-product-card,
html.theme-dark #salesPage .sale-entry-card,
html.theme-dark #salesPage .active-invoice-card,
html.theme-dark .summary-tile,
html.theme-dark .total-line,
html.theme-dark .details-grid div,
html.theme-dark .profile-metric,
html.theme-dark .reports-branch-option-card,
html.theme-dark .compact-product-row,
html.theme-dark .branch-receivable-box,
html.theme-dark .responsive-card-table tr,
html.theme-dark .app-dialog,
html.theme-dark .debt-payment-dialog,
html.theme-dark .barcode-scanner-panel {
  border-color: var(--border);
  background: var(--card);
  color: var(--dark);
}

html.theme-dark .field input,
html.theme-dark .field select,
html.theme-dark .field textarea,
html.theme-dark .medicine-search-field input,
html.theme-dark .medicine-name-field select,
html.theme-dark .invoice-inline-input,
html.theme-dark .app-dialog-input {
  border-color: var(--border);
  border-radius: 8px;
  background: #121d2b;
  color: var(--dark);
}

html.theme-dark .btn-light,
html.theme-dark .product-history-marker,
html.theme-dark .product-inquiry-button,
html.theme-dark .product-edit-button,
html.theme-dark .product-action-group,
html.theme-dark .mobile-nav,
html.theme-dark .branch-badge,
html.theme-dark .role-badge,
html.theme-dark .status-badge {
  border-color: var(--border);
  background: #1c2a3d;
  color: var(--primary-dark);
}

html.theme-dark table th { background: #1d2b3e; color: #c9d5e5; }
html.theme-dark table td { color: var(--dark); }

@media (max-width: 1100px) {
  .app-shell-header { margin: 0; }
  .app-shell-actions { width: auto; justify-content: flex-end; }
  .shell-status-card { order: 0; width: auto; }
  #dashboardPage .dashboard-hero { grid-template-columns: 1fr; }
  #dashboardPage .dashboard-stats-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  #dashboardPage .dashboard-menu-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .app-shell-header {
    position: sticky;
    top: 0;
    z-index: 100;
    margin: 0;
    padding: 8px 12px 6px;
    gap: 7px;
    border-radius: 0 0 10px 10px;
    flex-direction: row;
    align-items: center;
  }

  .app-shell-brand { flex: 1 1 auto; }
  .brand-lockup { gap: 8px; }
  .brand-logo,
  .app-shell-header.is-compact .brand-logo { width: 36px; height: 36px; border-radius: 8px; }
  .app-shell-brand h1,
  .app-shell-header.is-compact .app-shell-brand h1 { font-size: 14px; }
  .app-shell-actions { width: auto; gap: 0; }
  .shell-status-card { display: none !important; }
  .shell-actions-group { width: auto; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 5px; }
  .app-shell-actions .shell-icon-btn,
  .shell-logout-btn,
  .shell-install-btn { width: 33px; min-width: 33px; height: 33px; border-radius: 8px; }
  .shell-logout-btn { font-size: 0; }
  .shell-logout-btn::after { content: "↪"; font-size: 16px; line-height: 1; }
  .shell-icon { font-size: 16px; }
  .quick-access-bar { gap: 2px; padding-top: 5px; }
  .quick-access-item { min-height: 30px; padding: 5px 9px; font-size: 11px; }

  .app { padding: 16px 12px 26px; }
  .topbar { align-items: flex-start; margin-bottom: 13px; padding-bottom: 11px; }
  .brand { font-size: 20px; }
  .topbar-note { font-size: 12px; }
  .quick-links { gap: 6px; }
  .branch-badge,
  .role-badge,
  .status-badge { min-height: 32px; padding: 5px 8px; font-size: 11px; }
  .card { padding: 12px; }
  .btn { min-height: 38px; padding: 8px 10px; }
  .field input,
  .field select,
  .field textarea { min-height: 42px; }

  #dashboardPage.dashboard-page { padding-top: 15px; }
  #dashboardPage .dashboard-hero { gap: 9px; margin-bottom: 13px; padding: 0 0 12px; }
  #dashboardPage .dashboard-hero .brand { font-size: 21px; }
  #dashboardPage .dashboard-hero .topbar-note { margin-top: 3px; font-size: 12px; }
  #dashboardPage .dashboard-hero-actions { display: flex; width: 100%; justify-content: flex-start; }
  #dashboardPage .dashboard-hero-actions .branch-badge,
  #dashboardPage .dashboard-hero-actions .role-badge,
  #dashboardPage .dashboard-hero-actions .btn { width: auto; max-width: 100%; }
  #dashboardPage .dashboard-stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 8px; margin-bottom: 16px; }
  #dashboardPage .dashboard-stat-card,
  #dashboardPage .dashboard-stat-card:nth-child(n) { min-height: 78px; padding: 10px 11px; }
  #dashboardPage .dashboard-stat-card h3 { margin-bottom: 5px; font-size: 11px; }
  #dashboardPage .dashboard-stat-card .value { font-size: clamp(17px, 5vw, 21px); overflow-wrap: anywhere; }
  #dashboardPage .dashboard-section-head { margin-bottom: 8px; }
  #dashboardPage .dashboard-section-head .section-title { font-size: 15px; }
  #dashboardPage .dashboard-menu-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 7px; }
  #dashboardPage .dashboard-menu-grid .menu-card { min-height: 68px; grid-template-columns: 32px minmax(0, 1fr); gap: 8px; padding: 9px; }
  #dashboardPage .dashboard-menu-grid .menu-card .icon { width: 32px; height: 32px; border-radius: 7px; font-size: 17px; }
  #dashboardPage .dashboard-menu-grid .menu-card .title { font-size: 12px; }

  .notification-banner { width: auto; margin: 8px 12px 0; padding: 0; }

  .login-shell { width: min(100%, 520px); min-height: 0; grid-template-columns: 1fr; border-radius: 11px; }
  .login-visual-content { min-height: 170px; padding: 18px; }
  .login-visual .login-brand-lockup { flex-direction: row; text-align: start; }
  .login-visual .login-logo { width: 68px; height: 68px; border-radius: 9px; }
  .login-visual h1 { font-size: 20px; }
  .login-card { padding: 21px 17px; }
  .login-card h2 { font-size: 22px; }
}

@media (max-width: 839px) {
  .app-shell-header { transition: transform .2s ease; }
  .app-shell-header.is-scroll-hidden {
    transform: translateY(calc(-100% - 8px));
    pointer-events: none;
  }
}

@media (max-width: 839px) and (prefers-reduced-motion: reduce) {
  .app-shell-header { transition: none; }
}

@media (max-width: 390px) {
  .app-shell-header { padding-inline: 9px; }
  .app-shell-brand h1,
  .app-shell-header.is-compact .app-shell-brand h1 { font-size: 13px; }
  .app-shell-actions .shell-icon-btn,
  .shell-logout-btn,
  .shell-install-btn { width: 31px; min-width: 31px; height: 31px; }
  .shell-actions-group { gap: 4px; }
  #dashboardPage .dashboard-menu-grid .menu-card { grid-template-columns: 29px minmax(0, 1fr); gap: 6px; padding: 8px; }
  #dashboardPage .dashboard-menu-grid .menu-card .icon { width: 29px; height: 29px; font-size: 16px; }
}

@media (min-width: 840px) {
  .app-shell-header {
    position: fixed;
    inset: 0 0 0 auto;
    z-index: 100;
    width: 252px;
    height: 100vh;
    max-width: none;
    margin: 0;
    padding: 19px 14px 14px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    flex-wrap: nowrap;
    gap: 14px;
    overflow: hidden;
    border: 0;
    border-left: 1px solid var(--border);
    background: var(--card);
    box-shadow: -5px 0 20px rgba(25, 48, 78, .045);
    backdrop-filter: none;
  }

  html.theme-dark .app-shell-header {
    border-left-color: var(--border);
    background: var(--card);
    box-shadow: -5px 0 20px rgba(0, 0, 0, .14);
  }

  .app-shell-brand { flex: 0 0 auto; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
  .brand-lockup { gap: 9px; }
  .brand-logo { width: 40px; height: 40px; }
  .app-shell-brand h1 { font-size: 14px; }
  .app-shell-header.is-compact .app-shell-brand h1 { font-size: 14px; }

  .app-shell-actions {
    width: 100%;
    margin: 0;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: center;
    justify-content: stretch;
    gap: 7px;
  }

  .shell-status-card {
    grid-column: 1 / -1;
    width: 100%;
    min-width: 0;
    display: grid;
    gap: 5px;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--light);
    font-size: 10px;
  }

  .shell-status-card .shell-user-line,
  .shell-status-card span:last-child {
    min-height: 0;
    justify-content: space-between;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
  }

  .shell-status-card span:last-child::before { margin-inline-end: 5px; }
  .shell-actions-group {
    grid-column: 1 / -1;
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  #headerMenuButton { display: none !important; }
  .app-shell-actions .shell-icon-btn,
  .shell-logout-btn,
  .shell-install-btn { width: 100%; min-width: 0; height: 36px; }
  #headerInstallButton,
  #headerNumbersToggleButton { grid-column: span 1; }
  #headerLogoutButton { grid-column: span 2; min-width: 0; padding: 6px 10px; font-size: 12px; }

  #appShellHeader #quickAccessBar,
  #appShellHeader #quickAccessBar.hidden {
    flex: 1 1 0;
    width: 100%;
    min-height: 0;
    max-height: none;
    display: flex !important;
    flex-direction: column;
    align-items: stretch;
    gap: 3px;
    padding: 10px 0 0;
    overflow-x: hidden;
    overflow-y: auto;
    border: 0;
    border-top: 1px solid var(--border);
    border-radius: 0;
    background: transparent;
  }

  #quickAccessBar::before {
    flex: 0 0 auto;
    padding: 0 9px 5px;
    color: var(--muted);
    content: "القائمة الرئيسية";
    font-size: 11px;
    font-weight: 800;
  }

  .quick-access-item {
    flex: 0 0 auto;
    width: 100%;
    min-height: 39px;
    padding: 8px 10px;
    border: 1px solid transparent;
    border-inline-start: 3px solid transparent;
    border-radius: 7px;
    color: var(--muted);
    text-align: start;
  }

  .quick-access-item:hover,
  .quick-access-item:focus-visible { border-color: var(--border); background: var(--light); }
  .quick-access-item.is-active {
    border-color: #d4e2f2;
    border-inline-start-color: var(--primary);
    background: var(--primary-soft);
    color: var(--primary-dark);
  }

  .app-shell-header.is-compact { padding: 19px 14px 14px; border-radius: 0; }
  .app-shell-header.is-compact .brand-logo { width: 40px; height: 40px; }
  .app-shell-header.is-compact .shell-status-card { display: grid; max-width: none; opacity: 1; }
  .app-shell-header.is-compact .app-shell-actions .shell-icon-btn { width: 100%; min-width: 0; }

  .app-shell-header:not(.hidden) ~ .app {
    width: auto;
    max-width: none;
    margin: 0 252px 0 0;
    padding: 24px clamp(20px, 3vw, 48px) 38px;
  }

  .app-shell-header:not(.hidden) ~ .notification-banner {
    width: auto;
    max-width: none;
    margin: 12px 252px 0 0;
    padding: 0 clamp(20px, 3vw, 48px);
  }

  .app-shell-header:not(.hidden) ~ .app-credit {
    width: auto;
    margin-inline-start: 252px;
  }

  #dashboardPage.dashboard-page { max-width: none; padding-top: 18px; }
}

@media (max-width: 839px) {
  .app-shell-header { z-index: 200; backdrop-filter: none; }
  .quick-access-overlay {
    position: fixed;
    inset: 0;
    z-index: 190;
    display: block;
    border: 0;
    background: rgba(18, 32, 51, .38);
    cursor: pointer;
  }

  html.theme-dark .quick-access-overlay { background: rgba(0, 0, 0, .55); }

  #appShellHeader #quickAccessBar {
    position: fixed;
    inset: 0 0 0 auto;
    z-index: 1000;
    width: min(310px, 84vw);
    height: 100vh;
    height: 100dvh;
    max-height: none;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    padding: 68px 13px 18px;
    overflow-x: hidden;
    overflow-y: auto;
    border: 0;
    border-left: 1px solid var(--border);
    border-radius: 0;
    background: var(--card);
    box-shadow: -18px 0 44px rgba(20, 39, 66, .18);
  }

  #appShellHeader #quickAccessBar.hidden { display: none !important; }
  #appShellHeader #quickAccessBar::before {
    position: absolute;
    top: 20px;
    right: 15px;
    color: var(--muted);
    content: "القائمة الرئيسية";
    font-size: 13px;
    font-weight: 800;
  }

  #headerMenuButton[aria-expanded="true"] {
    position: fixed;
    top: 10px;
    right: calc(min(310px, 84vw) - 44px);
    z-index: 1001;
    border-color: var(--border) !important;
    background: var(--card) !important;
    color: var(--primary-dark) !important;
  }

  #headerMenuButton[aria-expanded="true"] .hamburger-lines { display: none; }
  #headerMenuButton[aria-expanded="true"]::after { content: "×"; font-size: 22px; line-height: 1; }

  .quick-access-item {
    flex: 0 0 auto;
    width: 100%;
    min-height: 42px;
    padding: 9px 11px;
    border: 1px solid transparent;
    border-inline-start: 3px solid transparent;
    border-radius: 7px;
    color: var(--muted);
    text-align: start;
  }

  .quick-access-item.is-active {
    border-color: #d4e2f2;
    border-inline-start-color: var(--primary);
    background: var(--primary-soft);
    color: var(--primary-dark);
    box-shadow: none;
  }

  html.theme-dark #appShellHeader #quickAccessBar {
    border-left-color: var(--border);
    background: var(--card);
    box-shadow: -18px 0 44px rgba(0, 0, 0, .3);
  }
}

@media (min-width: 840px) {
  .quick-access-overlay { display: none !important; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
