/* ============================================================
   S3eidat Pharmacy System — Complete RTL Stylesheet
   Font: Tajawal | Colors: Navy + Teal | RTL Arabic
   ============================================================ */

:root {
  --navy:       #0f172a;
  --navy2:      #1e293b;
  --navy3:      #334155;
  --teal:       #0891b2;
  --teal2:      #06b6d4;
  --teal3:      #22d3ee;
  --green:      #16a34a;
  --green2:     #22c55e;
  --red:        #dc2626;
  --red2:       #ef4444;
  --amber:      #d97706;
  --amber2:     #f59e0b;
  --white:      #ffffff;
  --gray50:     #f8fafc;
  --gray100:    #f1f5f9;
  --gray200:    #e2e8f0;
  --gray300:    #cbd5e1;
  --gray400:    #94a3b8;
  --gray500:    #64748b;
  --gray600:    #475569;
  --text:       #0f172a;
  --text2:      #334155;
  --text3:      #64748b;
  --border:     #cbd5e1;
  --shadow:     0 1px 3px rgba(0,0,0,.12), 0 1px 2px rgba(0,0,0,.08);
  --shadow-md:  0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -1px rgba(0,0,0,.06);
  --shadow-lg:  0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -2px rgba(0,0,0,.05);
  --radius:     6px;
  --radius-lg:  10px;
  --font:       'Tajawal', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 14px; }

body {
  font-family: var(--font);
  background: var(--gray100);
  color: var(--text);
  direction: rtl;
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}

/* ── SCROLLBAR ─────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--gray100); }
::-webkit-scrollbar-thumb { background: var(--gray300); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray400); }

/* ── UTILITY ───────────────────────────────────── */
.hidden { display: none !important; }
.text-red   { color: var(--red); }
.text-green { color: var(--green); }
.text-amber { color: var(--amber); }
.text-teal  { color: var(--teal); }
.text-muted { color: var(--text3); }
.text-center { text-align: center; }
.text-right  { text-align: right; }
.fw-bold { font-weight: 700; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.d-flex { display: flex; }
.gap-1  { gap: 4px; }
.gap-2  { gap: 8px; }
.flex-1 { flex: 1; }
.w-100  { width: 100%; }

/* ═══════════════════════════════════════════════
   LOGIN SCREEN
═══════════════════════════════════════════════ */
.login-screen {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
}
.login-bg {
  position: absolute; inset: 0;
  background: linear-gradient(135deg, var(--navy) 0%, #1a3a5c 50%, #0f3460 100%);
}
.login-bg::before {
  content: '';
  position: absolute; inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}
.login-card {
  position: relative; z-index: 1;
  background: var(--white);
  border-radius: 16px;
  padding: 40px;
  width: 420px;
  box-shadow: 0 25px 50px rgba(0,0,0,0.4);
  animation: slideUp .4s ease;
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(30px); }
  to   { opacity: 1; transform: translateY(0); }
}
.login-top { text-align: center; margin-bottom: 28px; }
.lc-logos {
  display: flex; flex-direction: column; align-items: center;
  gap: 10px; margin-bottom: 12px;
}
.lc-logo-wrap { display: flex; align-items: center; justify-content: center; }
/* Pharmacy logo — landscape (logo + text) */
.lc-logo-img.ph {
  max-width: 200px; max-height: 70px; width: auto; height: auto;
  object-fit: contain;
  border-radius: 10px; background: var(--gray50);
  border: 1px solid var(--border); padding: 8px 14px;
}
/* S3eidat icon — square */
.lc-logo-img.s3 {
  width: 48px; height: 48px; object-fit: contain;
  border-radius: 10px; background: var(--gray50);
  border: 1px solid var(--border); padding: 6px;
}
.lc-badge {
  display: inline-block;
  background: linear-gradient(90deg, var(--teal), var(--teal2));
  color: white; font-size: 11px; font-weight: 700;
  padding: 4px 14px; border-radius: 20px;
  letter-spacing: 1px; text-transform: uppercase;
  margin-top: 8px;
}
.lc-icon { font-size: 52px; line-height: 1; }
.lc-phname { font-size: 28px; font-weight: 800; color: var(--navy); margin: 8px 0 4px; }
.lc-sub { color: var(--text3); font-size: 13px; }
.lf-group { margin-bottom: 16px; }
.lf-group label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 13px; color: var(--text2); }
.lf-wrap {
  display: flex; align-items: center;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--gray50);
  overflow: hidden;
  transition: border-color .2s;
}
.lf-wrap:focus-within { border-color: var(--teal); background: white; }
.lf-icon { padding: 0 10px; color: var(--text3); font-size: 16px; }
.lf-wrap input {
  flex: 1; border: none; background: none; outline: none;
  padding: 10px 8px; font-family: var(--font); font-size: 14px;
}
.lf-eye {
  background: none; border: none; cursor: pointer;
  padding: 0 10px; font-size: 16px; color: var(--text3);
}
.login-err {
  background: #fef2f2; border: 1px solid #fecaca;
  color: var(--red); padding: 10px 14px; border-radius: var(--radius);
  font-size: 13px; margin-bottom: 12px;
}
.btn-login {
  width: 100%; padding: 13px;
  background: linear-gradient(135deg, var(--navy), var(--teal));
  color: white; border: none; border-radius: var(--radius);
  font-family: var(--font); font-size: 16px; font-weight: 700;
  cursor: pointer; transition: opacity .2s, transform .1s;
  letter-spacing: 1px;
}
.btn-login:hover { opacity: .9; transform: translateY(-1px); }
.btn-login:active { transform: translateY(0); }
.lc-footer { text-align: center; margin-top: 20px; color: var(--text3); font-size: 12px; }

/* ═══════════════════════════════════════════════
   MAIN APP LAYOUT
═══════════════════════════════════════════════ */
.main-app {
  display: flex; flex-direction: column;
  height: 100vh; overflow: hidden;
}

/* ── PHARMACY BANNER ──────────────────────────── */
.ph-banner {
  position: relative;
  background: linear-gradient(135deg, var(--navy) 0%, #1e3a6e 60%, var(--teal) 100%);
  height: 58px;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; flex-shrink: 0;
}
.ph-banner-bg {
  position: absolute; inset: 0;
  background: repeating-linear-gradient(
    45deg, transparent, transparent 10px,
    rgba(255,255,255,.02) 10px, rgba(255,255,255,.02) 20px
  );
}
.ph-banner-content {
  display: flex; align-items: center; gap: 12px; z-index: 1;
}
.ph-icon { font-size: 24px; }
/* Pharmacy logo in banner — landscape, shows logo+text */
.ph-banner-logo {
  max-width: 160px; max-height: 40px; width: auto; height: auto;
  object-fit: contain;
  border-radius: 6px; background: rgba(255,255,255,.12);
  padding: 4px 10px;
}
/* S3eidat icon in banner — small square, keep original colors */
.ph-s3-logo {
  width: 28px; height: 28px; object-fit: contain;
  margin-bottom: 2px;
}
.ph-name {
  font-size: 26px; font-weight: 900;
  color: white;
  text-shadow: 0 2px 8px rgba(0,0,0,.3);
  letter-spacing: 2px;
}
.ph-sys-badge {
  position: absolute; left: 16px; top: 50%; transform: translateY(-50%);
  display: flex; flex-direction: column; align-items: flex-end;
}
.psb-top { font-size: 13px; font-weight: 800; color: var(--teal2); letter-spacing: 1px; }
.psb-bot { font-size: 10px; color: rgba(255,255,255,.5); }

/* ── MODULE BAR ───────────────────────────────── */
.module-bar {
  display: flex; align-items: center; justify-content: space-between;
  background: linear-gradient(90deg, var(--teal) 0%, var(--teal2) 100%);
  height: 30px; padding: 0 14px; flex-shrink: 0;
  box-shadow: 0 2px 4px rgba(0,0,0,.2);
}
.mb-time, .mb-date {
  font-size: 12px; color: rgba(255,255,255,.9);
  font-weight: 600; letter-spacing: .5px;
  font-variant-numeric: tabular-nums;
}
.mb-title {
  font-size: 14px; font-weight: 800; color: white;
  letter-spacing: 2px; text-shadow: 0 1px 3px rgba(0,0,0,.3);
}

/* ── TOOLBAR ──────────────────────────────────── */
.toolbar {
  display: flex; align-items: center;
  background: var(--white);
  border-bottom: 2px solid var(--gray200);
  padding: 4px 8px; gap: 2px; flex-shrink: 0;
  overflow-x: auto; overflow-y: hidden;
  box-shadow: var(--shadow);
}
.tb-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--gray50); border: 1px solid var(--gray200);
  border-radius: var(--radius); padding: 4px 8px; min-width: 50px;
  cursor: pointer; transition: all .15s; gap: 1px;
  font-family: var(--font); flex-shrink: 0;
}
.tb-btn i { font-size: 15px; line-height: 1; }
.tb-btn span { font-size: 10px; font-weight: 600; color: var(--text2); white-space: nowrap; }
.tb-btn:hover { background: var(--teal); border-color: var(--teal); }
.tb-btn:hover span, .tb-btn:hover i { color: white; }
.tb-btn.tb-red { border-color: #fecaca; }
.tb-btn.tb-red:hover { background: var(--red); border-color: var(--red); }
.tb-btn.tb-green { border-color: #bbf7d0; }
.tb-btn.tb-green:hover { background: var(--green); border-color: var(--green); }
.tb-btn.tb-nav { background: var(--navy); border-color: var(--navy); }
.tb-btn.tb-nav span, .tb-btn.tb-nav i { color: white; }
.tb-btn.tb-nav:hover { background: var(--teal); border-color: var(--teal); }
.tb-btn:disabled { opacity: .4; cursor: not-allowed; }
.tb-btn:disabled:hover { background: var(--gray50); border-color: var(--gray200); }
.tb-btn:disabled:hover span { color: var(--text2); }
.tb-sep { width: 1px; height: 36px; background: var(--gray200); margin: 0 2px; flex-shrink: 0; }

/* ── MAIN AREA ────────────────────────────────── */
.main-area {
  display: flex; flex: 1; overflow: hidden;
  background: var(--gray100);
}

/* ── CONTENT AREA ─────────────────────────────── */
.content-area {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  padding: 6px; display: flex; flex-direction: column;
}
.ca-loading {
  display: flex; align-items: center; justify-content: center;
  height: 100%; color: var(--text3); font-size: 16px;
}

/* ── RIGHT PANEL ──────────────────────────────── */
.right-panel {
  width: 205px; flex-shrink: 0;
  background: var(--navy2);
  display: flex; flex-direction: column;
  border-right: none; border-left: 2px solid var(--navy3);
  overflow-y: auto; overflow-x: hidden;
}
.rp-user {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 8px 6px;
  background: var(--navy);
  border-bottom: 1px solid var(--navy3);
  flex-shrink: 0;
}
.rp-uico { font-size: 18px; }
.rp-uinfo { flex: 1; display: flex; flex-direction: column; }
.rp-uinfo b { font-size: 12px; color: white; font-weight: 700; }
.rp-uinfo small { font-size: 10px; color: var(--teal3); }
.rp-out {
  background: none; border: 1px solid var(--navy3); color: var(--gray400);
  border-radius: 4px; padding: 3px 6px; cursor: pointer; font-size: 14px;
  transition: all .15s;
}
.rp-out:hover { background: var(--red); border-color: var(--red); color: white; }
.rp-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 3px; padding: 6px; flex: 1;
}
.rp-grid button {
  background: var(--navy3); border: 1px solid #3d526b; color: var(--gray200);
  border-radius: var(--radius); padding: 7px 4px; cursor: pointer;
  font-family: var(--font); font-size: 10.5px; font-weight: 600;
  text-align: center; transition: all .15s; line-height: 1.3;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.rp-grid button:hover { background: var(--teal); border-color: var(--teal); color: white; }
.rp-grid .rp-full { grid-column: 1 / -1; }
.rp-divider { grid-column:1/-1; text-align:center; font-size:9px; color:var(--gray600); padding:4px 0 2px; letter-spacing:1px; }
.rp-brand {
  text-align: center; padding: 6px;
  font-size: 10px; color: var(--gray500);
  border-top: 1px solid var(--navy3); flex-shrink: 0;
}

/* ── BOTTOM TABS ──────────────────────────────── */
.bottom-tabs {
  display: flex; background: var(--navy);
  border-top: 2px solid var(--teal);
  overflow-x: auto; flex-shrink: 0;
}
.bottom-tabs::-webkit-scrollbar { height: 3px; }
.btab {
  background: transparent; border: none; border-top: 3px solid transparent;
  color: var(--gray400); padding: 7px 14px;
  font-family: var(--font); font-size: 12px; font-weight: 600;
  cursor: pointer; white-space: nowrap; flex-shrink: 0;
  transition: all .15s;
}
.btab:hover { color: var(--teal3); background: rgba(255,255,255,.04); }
.btab.active { color: white; border-top-color: var(--teal); background: var(--navy2); }

/* ═══════════════════════════════════════════════
   INVOICE FORM (matches screenshots exactly)
═══════════════════════════════════════════════ */
.inv-wrap {
  display: flex; flex-direction: column; gap: 4px;
  height: 100%; min-height: 0;
}

/* Header fields row */
.inv-header {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 4px; background: white; border: 1px solid var(--border);
  border-radius: var(--radius); padding: 6px;
}
.inv-header-left, .inv-header-right { display: flex; flex-direction: column; gap: 3px; }
.inv-row {
  display: flex; align-items: center; gap: 4px;
}
.inv-row label {
  font-size: 12px; font-weight: 600; color: var(--text2);
  min-width: 90px; flex-shrink: 0;
}
.inv-row input, .inv-row select {
  flex: 1; border: 1px solid var(--border); border-radius: 4px;
  padding: 3px 6px; font-family: var(--font); font-size: 12px;
  background: var(--gray50); outline: none; transition: border-color .15s;
}
.inv-row input:focus, .inv-row select:focus {
  border-color: var(--teal); background: white;
}
.inv-row input[readonly] { background: #f0f9ff; color: var(--teal); font-weight: 700; }
.inv-row .lookup-btn {
  background: var(--navy2); color: white; border: none;
  border-radius: 4px; padding: 3px 8px; cursor: pointer;
  font-size: 11px; font-weight: 700; transition: background .15s;
}
.inv-row .lookup-btn:hover { background: var(--teal); }
.inv-checkrow {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 2px 0;
}
.inv-chk { display: flex; align-items: center; gap: 4px; cursor: pointer; }
.inv-chk input[type="checkbox"] { accent-color: var(--teal); width: 13px; height: 13px; }
.inv-chk label { font-size: 11px; font-weight: 600; color: var(--text2); cursor: pointer; }

/* Items table */
.inv-table-wrap {
  flex: 1; overflow: auto; border: 1px solid var(--border);
  border-radius: var(--radius); background: white; min-height: 0;
}
.inv-table {
  width: 100%; border-collapse: collapse;
  font-size: 12px;
}
.inv-table thead tr {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy2) 100%);
  position: sticky; top: 0; z-index: 2;
}
.inv-table thead th {
  padding: 7px 6px; text-align: center;
  color: white; font-weight: 700; font-size: 11px;
  border-left: 1px solid var(--navy3); white-space: nowrap;
}
.inv-table tbody tr:nth-child(even) { background: var(--gray50); }
.inv-table tbody tr:hover { background: #e0f2fe; }
.inv-table tbody tr.selected-row { background: #bfdbfe; }
.inv-table tbody td {
  padding: 3px 4px; border-bottom: 1px solid var(--gray200);
  border-left: 1px solid var(--gray100); text-align: center;
  vertical-align: middle;
}
.inv-table tbody td input {
  width: 100%; border: none; background: transparent; outline: none;
  text-align: center; font-family: var(--font); font-size: 12px;
  padding: 1px 2px;
}
.inv-table tbody td input:focus {
  background: white; border: 1px solid var(--teal);
  border-radius: 3px;
}
.inv-table .td-num { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--teal); }
.inv-table .td-del { width: 28px; }
.del-row-btn {
  background: none; border: none; cursor: pointer;
  color: var(--red2); font-size: 14px; transition: transform .1s;
}
.del-row-btn:hover { transform: scale(1.2); }

/* Bottom totals area */
.inv-bottom {
  display: grid; grid-template-columns: auto 1fr auto;
  gap: 6px; background: white; border: 1px solid var(--border);
  border-radius: var(--radius); padding: 6px;
  flex-shrink: 0;
}
.inv-bot-left { display: flex; flex-direction: column; gap: 3px; }
.inv-bot-center {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.inv-big-total {
  font-size: 36px; font-weight: 900;
  color: var(--teal); font-variant-numeric: tabular-nums;
  text-shadow: 0 2px 4px rgba(8,145,178,.2);
  letter-spacing: 2px;
}
.inv-big-label { font-size: 11px; color: var(--text3); font-weight: 600; }
.inv-bot-right {
  display: flex; flex-direction: column; gap: 2px; min-width: 180px;
}
.inv-total-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 2px 6px; border-radius: 4px;
}
.inv-total-row:nth-child(even) { background: var(--gray50); }
.inv-total-row label { font-size: 12px; font-weight: 600; color: var(--text2); }
.inv-total-row span {
  font-size: 13px; font-weight: 700; color: var(--navy);
  font-variant-numeric: tabular-nums; min-width: 70px; text-align: left;
}
.inv-total-row.net-total { background: var(--navy); border-radius: 5px; }
.inv-total-row.net-total label { color: white; }
.inv-total-row.net-total span { color: var(--teal3); font-size: 15px; }
.inv-bot-meta { font-size: 11px; color: var(--text3); }
.inv-bot-meta span { font-weight: 700; color: var(--text2); }
.inv-checks-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 4px; }
.inv-checks-row .inv-chk label { font-size: 11px; }

/* Subtotal row */
.inv-sub-row {
  display: flex; justify-content: space-between;
  font-size: 12px; padding: 1px 0;
}
.inv-sub-row label { color: var(--text2); font-weight: 600; }
.inv-sub-row span { font-weight: 700; color: var(--red); font-variant-numeric: tabular-nums; }

/* ═══════════════════════════════════════════════
   PRODUCT CARD
═══════════════════════════════════════════════ */
.prod-card {
  background: white; border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 10px;
  display: flex; flex-direction: column; gap: 8px; height: 100%;
}
.prod-toolbar {
  display: flex; gap: 4px; flex-wrap: wrap;
  padding-bottom: 8px; border-bottom: 1px solid var(--gray200);
}
.prod-tb-btn {
  background: var(--gray50); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 5px 12px;
  font-family: var(--font); font-size: 12px; font-weight: 600;
  cursor: pointer; transition: all .15s;
}
.prod-tb-btn:hover { background: var(--teal); color: white; border-color: var(--teal); }
.prod-tb-btn.active { background: var(--navy); color: white; border-color: var(--navy); }

.prod-name-bar {
  display: flex; align-items: center; gap: 8px;
  background: var(--gray50); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 6px 10px;
}
.prod-code-input {
  width: 140px; border: 1px solid var(--border); border-radius: 4px;
  padding: 4px 8px; font-family: var(--font); font-size: 13px;
  font-weight: 700; outline: none;
}
.prod-code-input:focus { border-color: var(--teal); }
.prod-browse-btn {
  background: var(--navy2); color: white; border: none;
  border-radius: 4px; padding: 4px 10px; cursor: pointer; font-size: 12px;
}
.prod-item-name {
  flex: 1; font-size: 16px; font-weight: 800;
  color: var(--red); text-align: center;
}
.prod-fields { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.prod-row {
  display: grid; gap: 6px; align-items: center;
}
.prod-row.cols-4 { grid-template-columns: repeat(4, 1fr); }
.prod-row.cols-3 { grid-template-columns: repeat(3, 1fr); }
.prod-row.cols-2 { grid-template-columns: repeat(2, 1fr); }
.prod-row.cols-1 { grid-template-columns: 1fr; }
.prod-field { display: flex; flex-direction: column; gap: 2px; }
.prod-field label { font-size: 11px; font-weight: 600; color: var(--text3); }
.prod-field input, .prod-field select, .prod-field textarea {
  border: 1px solid var(--border); border-radius: 4px;
  padding: 4px 8px; font-family: var(--font); font-size: 12px;
  background: var(--gray50); outline: none; transition: border-color .15s;
}
.prod-field input:focus, .prod-field select:focus, .prod-field textarea:focus {
  border-color: var(--teal); background: white;
}
.prod-field input[readonly] { background: #f0fdf4; color: var(--green); font-weight: 700; }
.prod-checks {
  display: flex; flex-wrap: wrap; gap: 8px;
  background: var(--gray50); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 8px;
}
.prod-chk { display: flex; align-items: center; gap: 4px; cursor: pointer; }
.prod-chk input { accent-color: var(--teal); }
.prod-chk label { font-size: 11px; font-weight: 600; color: var(--text2); cursor: pointer; }
.prod-stock-bar {
  display: flex; gap: 12px; background: var(--navy);
  border-radius: var(--radius); padding: 6px 12px;
  align-items: center;
}
.prod-stock-item { display: flex; flex-direction: column; align-items: center; }
.prod-stock-item span:first-child { font-size: 10px; color: var(--gray400); }
.prod-stock-item span:last-child { font-size: 16px; font-weight: 800; color: var(--teal3); }
.prod-meta-bar {
  display: flex; gap: 12px; font-size: 11px; color: var(--text3);
  background: var(--gray50); border: 1px solid var(--gray200);
  border-radius: var(--radius); padding: 4px 8px; flex-wrap: wrap;
}
.prod-meta-bar span strong { color: var(--text2); }

/* ═══════════════════════════════════════════════
   LIST / TABLE VIEW
═══════════════════════════════════════════════ */
.list-wrap { display: flex; flex-direction: column; gap: 6px; height: 100%; }
.list-toolbar {
  display: flex; gap: 6px; align-items: center;
  flex-wrap: wrap; flex-shrink: 0;
}
.list-search {
  flex: 1; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 7px 12px; font-family: var(--font); font-size: 13px;
  outline: none; background: white; min-width: 180px;
}
.list-search:focus { border-color: var(--teal); }
.list-table-wrap { flex: 1; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius); background: white; }
.list-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.list-table thead tr { background: var(--navy); position: sticky; top: 0; z-index: 1; }
.list-table thead th { padding: 8px 8px; color: white; font-weight: 700; text-align: center; border-left: 1px solid var(--navy3); white-space: nowrap; }
.list-table tbody tr:nth-child(even) { background: var(--gray50); }
.list-table tbody tr:hover { background: #e0f2fe; cursor: pointer; }
.list-table tbody tr.selected { background: #bfdbfe; }
.list-table tbody td { padding: 6px 8px; border-bottom: 1px solid var(--gray100); text-align: center; }
.list-table tbody td:first-child { font-weight: 700; color: var(--text3); }

/* ═══════════════════════════════════════════════
   MODAL
═══════════════════════════════════════════════ */
.modal-overlay {
  position: fixed; inset: 0; z-index: 5000;
  background: rgba(15,23,42,.7); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.modal-box {
  background: white; border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); display: flex; flex-direction: column;
  max-height: 92vh; width: 100%; max-width: 800px;
  animation: modalIn .2s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(.95) translateY(-10px); }
  to   { opacity: 1; transform: scale(1)  translateY(0); }
}
.modal-box.modal-sm { max-width: 400px; }
.modal-box.modal-lg { max-width: 1100px; }
.modal-box.modal-xl { max-width: 1300px; max-height: 96vh; }
.modal-hdr {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  background: linear-gradient(135deg, var(--navy) 0%, var(--teal) 100%);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0; flex-shrink: 0;
}
.modal-ttl { font-size: 15px; font-weight: 800; color: white; letter-spacing: 1px; }
.modal-close {
  background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.3);
  color: white; border-radius: 50%; width: 28px; height: 28px;
  cursor: pointer; font-size: 14px; display: flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.modal-close:hover { background: var(--red); border-color: var(--red); }
.modal-body { flex: 1; overflow-y: auto; padding: 16px; }
.modal-footer { padding: 12px 16px; border-top: 1px solid var(--gray200); display: flex; gap: 8px; justify-content: flex-end; flex-shrink: 0; }

/* ═══════════════════════════════════════════════
   BUTTONS
═══════════════════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 18px; border-radius: var(--radius);
  border: none; cursor: pointer; font-family: var(--font);
  font-size: 13px; font-weight: 600; transition: all .15s;
}
.btn-primary  { background: var(--teal); color: white; }
.btn-primary:hover  { background: var(--teal2); }
.btn-navy    { background: var(--navy); color: white; }
.btn-navy:hover  { background: var(--navy2); }
.btn-success { background: var(--green); color: white; }
.btn-success:hover { background: var(--green2); }
.btn-danger  { background: var(--red); color: white; }
.btn-danger:hover  { background: var(--red2); }
.btn-warning { background: var(--amber); color: white; }
.btn-warning:hover { background: var(--amber2); }
.btn-ghost   { background: transparent; color: var(--text2); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--gray100); }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-lg { padding: 11px 24px; font-size: 15px; }
.btn-block { width: 100%; justify-content: center; }

/* ═══════════════════════════════════════════════
   FORM ELEMENTS (general)
═══════════════════════════════════════════════ */
.form-section {
  background: white; border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px; margin-bottom: 8px;
}
.form-section-title {
  font-size: 12px; font-weight: 800; color: var(--teal);
  text-transform: uppercase; letter-spacing: 1px;
  margin-bottom: 10px; padding-bottom: 6px;
  border-bottom: 2px solid var(--teal);
}
.form-grid { display: grid; gap: 10px; }
.form-grid.g2 { grid-template-columns: repeat(2, 1fr); }
.form-grid.g3 { grid-template-columns: repeat(3, 1fr); }
.form-grid.g4 { grid-template-columns: repeat(4, 1fr); }
.form-field { display: flex; flex-direction: column; gap: 4px; }
.form-field label { font-size: 12px; font-weight: 600; color: var(--text2); }
.form-field input, .form-field select, .form-field textarea {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 7px 10px; font-family: var(--font); font-size: 13px;
  outline: none; background: var(--gray50); transition: border-color .2s;
}
.form-field input:focus, .form-field select:focus, .form-field textarea:focus {
  border-color: var(--teal); background: white;
  box-shadow: 0 0 0 3px rgba(8,145,178,.1);
}
.form-field textarea { resize: vertical; min-height: 70px; }
.form-field .field-hint { font-size: 11px; color: var(--text3); }
.form-check { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.form-check input { accent-color: var(--teal); width: 15px; height: 15px; }
.form-check label { font-size: 13px; font-weight: 500; cursor: pointer; }

/* ═══════════════════════════════════════════════
   STATS / DASHBOARD CARDS
═══════════════════════════════════════════════ */
.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 8px; margin-bottom: 10px;
}
.stat-card {
  background: white; border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 12px;
  display: flex; flex-direction: column; gap: 4px;
  border-top: 3px solid var(--teal);
  transition: transform .15s, box-shadow .15s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-card.green { border-top-color: var(--green); }
.stat-card.red   { border-top-color: var(--red); }
.stat-card.amber { border-top-color: var(--amber); }
.stat-card.navy  { border-top-color: var(--navy); }
.stat-label { font-size: 11px; font-weight: 600; color: var(--text3); text-transform: uppercase; letter-spacing: .5px; }
.stat-value { font-size: 24px; font-weight: 900; color: var(--navy); }
.stat-sub   { font-size: 11px; color: var(--text3); }

/* ═══════════════════════════════════════════════
   REPORTS
═══════════════════════════════════════════════ */
.report-wrap { display: flex; flex-direction: column; gap: 8px; height: 100%; }
.report-filters {
  background: white; border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px;
  display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end;
}
.filter-field { display: flex; flex-direction: column; gap: 3px; }
.filter-field label { font-size: 11px; font-weight: 600; color: var(--text3); }
.filter-field input, .filter-field select {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 5px 8px; font-family: var(--font); font-size: 12px; outline: none;
}
.filter-field input:focus, .filter-field select:focus { border-color: var(--teal); }
.report-header-card {
  background: var(--navy); color: white;
  border-radius: var(--radius); padding: 10px 14px;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
}
.rhc-item { display: flex; flex-direction: column; }
.rhc-item span:first-child { font-size: 10px; color: var(--teal3); font-weight: 600; }
.rhc-item span:last-child { font-size: 14px; font-weight: 700; }
.report-table-wrap { flex: 1; overflow: auto; }
.report-total-row td { font-weight: 800; background: var(--navy); color: white; }

/* ═══════════════════════════════════════════════
   PATIENTS
═══════════════════════════════════════════════ */
.patient-card { background: white; border-radius: var(--radius-lg); padding: 12px; }
.patient-header {
  display: flex; align-items: center; gap: 12px;
  background: linear-gradient(135deg, var(--navy), var(--teal));
  border-radius: var(--radius); padding: 12px; color: white; margin-bottom: 12px;
}
.patient-avatar {
  width: 52px; height: 52px; border-radius: 50%;
  background: rgba(255,255,255,.2); display: flex; align-items: center; justify-content: center;
  font-size: 24px;
}
.patient-info h3 { font-size: 16px; margin-bottom: 2px; }
.patient-info p { font-size: 12px; opacity: .8; }
.patient-tags { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }
.tag {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 8px; border-radius: 20px; font-size: 10px; font-weight: 700;
}
.tag-red    { background: #fef2f2; color: var(--red); border: 1px solid #fecaca; }
.tag-green  { background: #f0fdf4; color: var(--green); border: 1px solid #bbf7d0; }
.tag-blue   { background: #eff6ff; color: #2563eb; border: 1px solid #bfdbfe; }
.tag-amber  { background: #fffbeb; color: var(--amber); border: 1px solid #fde68a; }
.tag-teal   { background: #f0fdfa; color: var(--teal); border: 1px solid #99f6e4; }

/* ═══════════════════════════════════════════════
   CASH / VOUCHER
═══════════════════════════════════════════════ */
.cash-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px; margin-bottom: 12px;
}
.cash-card {
  background: white; border-radius: var(--radius-lg);
  border: 1px solid var(--border); padding: 14px;
  text-align: center;
}
.cash-card .cc-label { font-size: 12px; color: var(--text3); font-weight: 600; margin-bottom: 6px; }
.cash-card .cc-value { font-size: 28px; font-weight: 900; color: var(--navy); }
.cash-card .cc-sub   { font-size: 11px; color: var(--text3); }

/* ═══════════════════════════════════════════════
   NARCOTICS
═══════════════════════════════════════════════ */
.narc-badge {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--red); color: white;
  padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 700;
  margin-bottom: 10px;
}

/* ═══════════════════════════════════════════════
   TOAST
═══════════════════════════════════════════════ */
.toast {
  position: fixed; bottom: 50px; left: 50%;
  transform: translateX(-50%);
  background: var(--navy); color: white;
  padding: 10px 22px; border-radius: 30px;
  font-size: 13px; font-weight: 600;
  z-index: 9998; box-shadow: var(--shadow-lg);
  border-right: 4px solid var(--teal);
  animation: toastIn .3s ease;
  pointer-events: none; white-space: nowrap;
}
.toast.success { border-right-color: var(--green); }
.toast.error   { border-right-color: var(--red); background: #1c0a09; }
.toast.warning { border-right-color: var(--amber); }
@keyframes toastIn { from { opacity: 0; transform: translateX(-50%) translateY(10px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }

/* ═══════════════════════════════════════════════
   ALERTS / BADGES
═══════════════════════════════════════════════ */
.alert {
  padding: 10px 14px; border-radius: var(--radius);
  font-size: 13px; font-weight: 500; margin-bottom: 8px;
}
.alert-warning { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; }
.alert-danger  { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }
.alert-success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; }
.alert-info    { background: #eff6ff; border: 1px solid #bfdbfe; color: #1e40af; }
.badge {
  display: inline-block; padding: 2px 8px;
  border-radius: 20px; font-size: 11px; font-weight: 700;
}
.badge-teal { background: #ecfeff; color: var(--teal); border: 1px solid #a5f3fc; }
.badge-green { background: #f0fdf4; color: var(--green); border: 1px solid #bbf7d0; }
.badge-red { background: #fef2f2; color: var(--red); border: 1px solid #fecaca; }
.badge-amber { background: #fffbeb; color: var(--amber); border: 1px solid #fde68a; }

/* ═══════════════════════════════════════════════
   PRINT STYLES
═══════════════════════════════════════════════ */
.print-area { display: none; }
@media print {
  body > *:not(#printArea) { display: none !important; }
  #printArea {
    display: block !important;
    font-family: 'Tajawal', sans-serif;
    direction: rtl; color: black;
  }
  .print-invoice {
    padding: 16px; max-width: 80mm;
    margin: 0 auto;
  }
  .print-invoice h2 { text-align: center; font-size: 18px; margin-bottom: 4px; }
  .print-invoice .pi-meta { font-size: 11px; margin-bottom: 6px; border-bottom: 1px dashed #000; padding-bottom: 6px; }
  .print-invoice table { width: 100%; border-collapse: collapse; font-size: 11px; }
  .print-invoice th, .print-invoice td { padding: 3px 4px; text-align: center; border-bottom: 1px solid #eee; }
  .print-invoice .pi-totals { margin-top: 8px; font-size: 12px; }
  .print-invoice .pi-total-final { font-size: 16px; font-weight: 900; text-align: center; margin-top: 6px; }
  .print-invoice .pi-footer { text-align: center; font-size: 10px; color: #666; margin-top: 10px; border-top: 1px dashed #000; padding-top: 6px; }
}

/* ═══════════════════════════════════════════════
   MISC COMPONENTS
═══════════════════════════════════════════════ */
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 48px; color: var(--text3);
  gap: 10px;
}
.empty-state .es-icon { font-size: 48px; opacity: .4; }
.empty-state .es-text { font-size: 14px; font-weight: 600; }
.empty-state .es-sub  { font-size: 12px; }

.divider { height: 1px; background: var(--gray200); margin: 10px 0; }

.section-title {
  font-size: 13px; font-weight: 800; color: var(--navy);
  padding: 6px 0; margin-bottom: 6px;
  border-bottom: 2px solid var(--teal);
  display: flex; align-items: center; gap: 6px;
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }

/* Find Dialog */
.find-dialog { display: flex; flex-direction: column; gap: 8px; }
.find-dialog .fd-title {
  font-size: 18px; font-weight: 800; color: var(--navy);
  text-align: center; margin-bottom: 10px;
}
.fd-btn {
  display: block; width: 100%; padding: 12px;
  background: var(--gray50); border: 1px solid var(--border);
  border-radius: var(--radius); font-family: var(--font);
  font-size: 14px; font-weight: 700; cursor: pointer;
  text-align: center; transition: all .15s;
}
.fd-btn:hover { background: var(--teal); color: white; border-color: var(--teal); }

/* Invoice list popup */
.inv-list-popup { display: flex; flex-direction: column; gap: 8px; height: 100%; }
.ilp-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.ilp-table thead tr { background: var(--navy); }
.ilp-table thead th { padding: 7px; color: white; text-align: center; }
.ilp-table tbody tr:hover { background: #bfdbfe; cursor: pointer; }
.ilp-table tbody tr.sel { background: #93c5fd; }
.ilp-table tbody td { padding: 5px 8px; border-bottom: 1px solid var(--gray100); text-align: center; }

/* Shortage / inventory table */
.shortage-wrap { display: flex; flex-direction: column; gap: 8px; height: 100%; }
.shortage-toolbar { display: flex; gap: 8px; align-items: center; }

/* Voucher form */
.voucher-form { background: white; border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; }
.vf-row { display: grid; grid-template-columns: auto 1fr auto 1fr; gap: 8px; align-items: center; margin-bottom: 6px; }
.vf-row label { font-size: 12px; font-weight: 600; color: var(--text2); white-space: nowrap; }
.vf-row input, .vf-row select {
  border: 1px solid var(--border); border-radius: 4px;
  padding: 4px 8px; font-family: var(--font); font-size: 12px; outline: none;
}
.vf-row input:focus, .vf-row select:focus { border-color: var(--teal); }

/* Tooltip */
[title] { cursor: help; }

/* Readonly / disabled */
input[readonly], select[disabled] { cursor: default; }

/* Number input arrows removal */
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type=number] { -moz-appearance: textfield; }

/* Lookup autocomplete list */
.lookup-list {
  position: absolute; z-index: 100;
  background: white; border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-md);
  max-height: 200px; overflow-y: auto; min-width: 300px;
}
.lookup-list li {
  padding: 7px 12px; cursor: pointer; font-size: 12px;
  border-bottom: 1px solid var(--gray100); list-style: none;
}
.lookup-list li:hover { background: var(--teal); color: white; }
.lookup-list li .ll-code { font-weight: 700; margin-left: 8px; color: var(--text3); font-size: 11px; }
.lookup-list li:hover .ll-code { color: rgba(255,255,255,.7); }

/* Z-Report */
.z-report { padding: 20px; font-family: var(--font); direction: rtl; }
.z-report h2 { text-align: center; font-size: 20px; margin-bottom: 4px; }
.z-report .zr-date { text-align: center; color: var(--text3); font-size: 12px; margin-bottom: 16px; }
.z-report-section { margin-bottom: 12px; }
.z-report-section h4 { font-size: 13px; font-weight: 800; color: var(--teal); border-bottom: 1px solid var(--gray200); padding-bottom: 4px; margin-bottom: 6px; }
.z-row { display: flex; justify-content: space-between; padding: 3px 0; font-size: 13px; }
.z-row.total { font-weight: 800; border-top: 2px solid var(--navy); padding-top: 6px; margin-top: 4px; font-size: 15px; }

/* Loyalty */
.loyalty-bar { display: flex; align-items: center; gap: 12px; background: linear-gradient(135deg, #7c3aed, #a855f7); border-radius: var(--radius); padding: 10px 16px; color: white; margin-bottom: 10px; }
.lb-icon { font-size: 28px; }
.lb-info h4 { font-size: 16px; font-weight: 800; }
.lb-info p { font-size: 12px; opacity: .8; }
.lb-points { font-size: 32px; font-weight: 900; margin-right: auto; }
.tier-badge { padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 800; }
.tier-bronze   { background: #b45309; color: white; }
.tier-silver   { background: #475569; color: white; }
.tier-gold     { background: #d97706; color: white; }
.tier-platinum { background: linear-gradient(90deg, #1e293b, #475569); color: white; }

/* ═══════════════════════════════════════════════
   DARK MODE
═══════════════════════════════════════════════ */
.dark {
  --white:    #1a2234;
  --gray50:   #1e2a3a;
  --gray100:  #162032;
  --gray200:  #243348;
  --gray300:  #2e4060;
  --gray400:  #4d6380;
  --gray500:  #6b849e;
  --border:   #2a3a52;
  --text:     #e2e8f0;
  --text2:    #cbd5e1;
  --text3:    #94a3b8;
  --shadow:   0 1px 3px rgba(0,0,0,.4), 0 1px 2px rgba(0,0,0,.3);
  --shadow-md:0 4px 6px -1px rgba(0,0,0,.4), 0 2px 4px -1px rgba(0,0,0,.3);
}
.dark body                         { background: #0f1623; }
.dark .main-app                    { background: #0f1623; }
.dark .main-area                   { background: #0f1623; }
.dark .content-area                { background: #0f1623; }
.dark .toolbar                     { background: #1a2234; border-bottom-color: #2a3a52; }
.dark .tb-btn                      { background: #243348; border-color: #2e4060; color: #cbd5e1; }
.dark .tb-btn span                 { color: #94a3b8; }
.dark .tb-btn:hover                { background: var(--teal); }
.dark .tb-btn:disabled:hover       { background: #243348; }
.dark .inv-header, .dark .inv-bottom { background: #1a2234; border-color: #2a3a52; }
.dark .inv-table-wrap              { background: #1a2234; border-color: #2a3a52; }
.dark .inv-table thead tr          { background: linear-gradient(135deg,#0f1f35,#1a3050); }
.dark .inv-table tbody tr:nth-child(even) { background: #1e2a3a; }
.dark .inv-table tbody tr:hover    { background: #1a3a5c; }
.dark .inv-table tbody td          { border-color: #2a3a52; }
.dark .inv-table tbody td input    { color: #e2e8f0; }
.dark .prod-card                   { background: #1a2234; border-color: #2a3a52; }
.dark .prod-name-bar               { background: #243348; border-color: #2a3a52; }
.dark .prod-field input, .dark .prod-field select, .dark .prod-field textarea { background: #243348; border-color: #2a3a52; color: #e2e8f0; }
.dark .prod-checks                 { background: #1e2a3a; border-color: #2a3a52; }
.dark .prod-meta-bar               { background: #1e2a3a; border-color: #2a3a52; }
.dark .list-table-wrap             { background: #1a2234; border-color: #2a3a52; }
.dark .list-table tbody tr:hover   { background: #1a3a5c; }
.dark .list-table tbody tr:nth-child(even) { background: #1e2a3a; }
.dark .list-search                 { background: #1a2234; border-color: #2a3a52; color: #e2e8f0; }
.dark .modal-box                   { background: #1a2234; }
.dark .modal-body                  { background: #1a2234; color: #e2e8f0; }
.dark .modal-footer                { border-top-color: #2a3a52; background: #1a2234; }
.dark .btn-ghost                   { border-color: #2a3a52; color: #cbd5e1; }
.dark .btn-ghost:hover             { background: #243348; }
.dark .form-field input, .dark .form-field select, .dark .form-field textarea { background: #243348; border-color: #2a3a52; color: #e2e8f0; }
.dark .form-section                { background: #1a2234; border-color: #2a3a52; }
.dark .stat-card                   { background: #1a2234; border-color: #2a3a52; }
.dark .stat-card .stat-value       { color: #e2e8f0; }
.dark .cash-card                   { background: #1a2234; border-color: #2a3a52; }
.dark .card                        { background: #1a2234; border-color: #2a3a52; }
.dark .inv-row input, .dark .inv-row select { background: #243348; border-color: #2a3a52; color: #e2e8f0; }
.dark .login-card                  { background: #1a2234; }
.dark .lc-phname                   { color: #e2e8f0; }
.dark .lc-logo-img.ph, .dark .lc-logo-img.s3 { background: #243348; border-color: #2a3a52; }
.dark ::-webkit-scrollbar-track    { background: #1a2234; }
.dark ::-webkit-scrollbar-thumb    { background: #2a3a52; }

/* ═══════════════════════════════════════════════
   MODULE BAR ACTIONS (search, notifications, dark mode)
═══════════════════════════════════════════════ */
.mb-actions {
  display: flex; align-items: center; gap: 4px;
}
.mb-action-btn {
  position: relative;
  background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.15);
  color: white; border-radius: 6px; width: 28px; height: 22px;
  cursor: pointer; font-size: 13px;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s;
  padding: 0;
}
.mb-action-btn:hover { background: rgba(255,255,255,.25); }
.notif-badge {
  position: absolute; top: -5px; right: -5px;
  background: var(--red2); color: white;
  font-size: 9px; font-weight: 900;
  min-width: 16px; height: 16px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 3px; border: 1.5px solid white;
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%,100% { transform: scale(1); }
  50%      { transform: scale(1.15); }
}

/* ═══════════════════════════════════════════════
   NOTIFICATIONS DROPDOWN
═══════════════════════════════════════════════ */
.notif-dropdown {
  position: fixed; top: 92px; left: 60px;
  width: 340px; max-height: 480px;
  background: white; border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 40px rgba(0,0,0,.2);
  z-index: 4000; overflow: hidden;
  animation: dropIn .18s ease;
  display: flex; flex-direction: column;
}
.dark .notif-dropdown { background: #1a2234; border-color: #2a3a52; }
@keyframes dropIn {
  from { opacity: 0; transform: translateY(-8px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.notif-header {
  padding: 12px 16px; background: linear-gradient(135deg,var(--navy),var(--teal));
  color: white; font-size: 13px; font-weight: 700;
  display: flex; align-items: center; justify-content: space-between;
}
.notif-body { overflow-y: auto; flex: 1; }
.notif-section-title {
  padding: 8px 14px 4px;
  font-size: 10px; font-weight: 800; color: var(--text3);
  text-transform: uppercase; letter-spacing: 1px;
}
.notif-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 9px 14px; border-bottom: 1px solid var(--gray100);
  cursor: pointer; transition: background .12s;
}
.dark .notif-item { border-bottom-color: #2a3a52; }
.notif-item:hover { background: var(--gray50); }
.dark .notif-item:hover { background: #243348; }
.ni-icon { font-size: 18px; flex-shrink: 0; margin-top: 1px; }
.ni-body { flex: 1; min-width: 0; }
.ni-title { font-size: 12px; font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ni-sub   { font-size: 11px; color: var(--text3); margin-top: 1px; }
.dark .ni-title { color: #e2e8f0; }
.notif-empty {
  padding: 32px; text-align: center;
  color: var(--text3); font-size: 13px;
}
.notif-empty .ne-icon { font-size: 36px; display: block; margin-bottom: 8px; opacity: .4; }

/* ═══════════════════════════════════════════════
   GLOBAL SEARCH OVERLAY (Ctrl+K)
═══════════════════════════════════════════════ */
.search-overlay {
  position: fixed; inset: 0; z-index: 8000;
  background: rgba(15,23,42,.75); backdrop-filter: blur(6px);
  display: flex; align-items: flex-start; justify-content: center;
  padding-top: 80px;
}
.search-box {
  width: 100%; max-width: 640px;
  background: white; border-radius: 16px;
  box-shadow: 0 32px 64px rgba(0,0,0,.35);
  overflow: hidden; animation: searchIn .18s ease;
}
.dark .search-box { background: #1a2234; }
@keyframes searchIn {
  from { opacity: 0; transform: translateY(-16px) scale(.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.search-input-wrap {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--gray200);
}
.dark .search-input-wrap { border-bottom-color: #2a3a52; }
.search-icon { font-size: 18px; color: var(--text3); flex-shrink: 0; }
.search-input-wrap input {
  flex: 1; border: none; outline: none;
  font-family: var(--font); font-size: 16px;
  background: transparent; color: var(--text);
}
.dark .search-input-wrap input { color: #e2e8f0; }
.search-input-wrap input::placeholder { color: var(--text3); }
.search-shortcut {
  font-size: 11px; color: var(--text3);
  background: var(--gray100); border: 1px solid var(--border);
  border-radius: 4px; padding: 2px 7px; font-weight: 600;
  white-space: nowrap;
}
.dark .search-shortcut { background: #243348; border-color: #2a3a52; }
.search-results { max-height: 420px; overflow-y: auto; }
.sr-section-title {
  padding: 8px 16px 4px;
  font-size: 10px; font-weight: 800; color: var(--text3);
  text-transform: uppercase; letter-spacing: 1px;
  background: var(--gray50);
}
.dark .sr-section-title { background: #1e2a3a; }
.sr-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; cursor: pointer;
  border-bottom: 1px solid var(--gray100);
  transition: background .1s;
}
.dark .sr-item { border-bottom-color: #2a3a52; }
.sr-item:hover, .sr-item.active { background: #e0f2fe; }
.dark .sr-item:hover, .dark .sr-item.active { background: #1a3a5c; }
.sr-icon { font-size: 20px; flex-shrink: 0; }
.sr-main { flex: 1; min-width: 0; }
.sr-name { font-size: 13px; font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dark .sr-name { color: #e2e8f0; }
.sr-sub  { font-size: 11px; color: var(--text3); }
.sr-badge { font-size: 11px; font-weight: 700; color: var(--teal); flex-shrink: 0; }
.search-footer {
  padding: 10px 16px; background: var(--gray50);
  border-top: 1px solid var(--gray200);
  display: flex; gap: 16px; align-items: center;
}
.dark .search-footer { background: #1e2a3a; border-top-color: #2a3a52; }
.sf-hint { font-size: 11px; color: var(--text3); display: flex; align-items: center; gap: 4px; }
.sf-key { background: var(--gray200); border-radius: 3px; padding: 1px 5px; font-size: 10px; font-weight: 700; }
.dark .sf-key { background: #2a3a52; }
.search-empty { padding: 32px; text-align: center; color: var(--text3); font-size: 13px; }

/* ═══════════════════════════════════════════════
   CARD COMPONENT (generic)
═══════════════════════════════════════════════ */
.card {
  background: white; border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-header {
  padding: 10px 14px;
  background: linear-gradient(135deg, var(--navy), var(--navy2));
  display: flex; align-items: center; justify-content: space-between;
}
.card-title { font-size: 13px; font-weight: 700; color: white; }
.card-body  { padding: 14px; }

/* ═══════════════════════════════════════════════
   SMOOTH TRANSITIONS & POLISH
═══════════════════════════════════════════════ */
* { transition-property: background-color, border-color, color, box-shadow; transition-duration: .15s; }
/* exclude layout transitions */
.main-app, .main-area, .content-area, .toolbar,
.bottom-tabs, .right-panel, .modal-overlay, .modal-box,
.notif-dropdown, .search-overlay, .search-box { transition: none; }

/* Focus ring */
button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--teal); outline-offset: 2px;
}

/* Better button active states */
.btn:active { transform: scale(.97); }
.tb-btn:active { transform: scale(.95); }

/* Right panel keyboard shortcut hints */
.kb-hint {
  font-size: 9px; color: var(--teal3);
  background: rgba(255,255,255,.08);
  border-radius: 3px; padding: 0 4px;
  margin-right: 4px; font-weight: 700;
}

/* Expiry warning colors */
.expiry-expired { color: var(--red2) !important; font-weight: 700; }
.expiry-critical { color: #f97316 !important; font-weight: 700; }
.expiry-near    { color: var(--amber) !important; }
.expiry-ok      { color: var(--green) !important; }

/* Low stock badge */
.low-stock-badge {
  display: inline-flex; align-items: center; gap: 3px;
  background: #fef2f2; color: var(--red); border: 1px solid #fecaca;
  padding: 1px 7px; border-radius: 20px; font-size: 10px; font-weight: 700;
}

/* Profit/loss colors */
.profit-positive { color: var(--green); }
.profit-negative { color: var(--red); }

/* Mini chart bar */
.mini-chart { display: flex; align-items: flex-end; gap: 3px; height: 40px; }
.mc-bar {
  flex: 1; border-radius: 3px 3px 0 0;
  background: linear-gradient(to top, var(--teal), var(--teal2));
  min-width: 8px; transition: height .4s ease;
  position: relative; cursor: pointer;
}
.mc-bar:hover { background: linear-gradient(to top,var(--navy),var(--teal)); }
.mc-bar .mc-tooltip {
  position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%);
  background: var(--navy); color: white; font-size: 10px; font-weight: 700;
  padding: 2px 6px; border-radius: 4px; white-space: nowrap;
  opacity: 0; pointer-events: none; transition: opacity .15s;
}
.mc-bar:hover .mc-tooltip { opacity: 1; }

/* Keyboard shortcut tooltip on toolbar */
.tb-btn[data-key]::after {
  content: attr(data-key);
  position: absolute; bottom: -18px; left: 50%; transform: translateX(-50%);
  background: var(--navy); color: white; font-size: 9px; font-weight: 700;
  padding: 1px 5px; border-radius: 3px; white-space: nowrap;
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.toolbar:hover .tb-btn[data-key]::after { opacity: .9; }
.tb-btn { position: relative; }

/* ── data-table (used in RPan modals) ──────── */
.data-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.data-table thead tr { background: var(--navy); position: sticky; top: 0; z-index: 1; }
.data-table thead th { padding: 8px; color: white; font-weight: 700; text-align: center; border-left: 1px solid var(--navy3); white-space: nowrap; }
.data-table tbody tr:nth-child(even) { background: var(--gray50); }
.data-table tbody tr:hover { background: #e0f2fe; }
.data-table tbody td { padding: 6px 8px; border-bottom: 1px solid var(--gray100); text-align: center; }
.dark .data-table tbody tr:nth-child(even) { background: #1e2a3a; }
.dark .data-table tbody tr:hover { background: #1a3a5c; }

/* ═══════════════════════════════════════════════
   MOBILE PANEL TOGGLE BUTTON (hidden on desktop)
═══════════════════════════════════════════════ */
.mb-panel-btn {
  display: none;
  background: none;
  border: none;
  color: var(--white);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius);
  line-height: 1;
  flex-shrink: 0;
}
.mb-panel-btn:hover { background: rgba(255,255,255,.15); }

/* Overlay behind slide-out panel (mobile) */
.rp-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 199;
}
.rp-overlay.rp-overlay-visible { display: block; }

/* ═══════════════════════════════════════════════
   TABLET  ≤ 900px
═══════════════════════════════════════════════ */
@media (max-width: 900px) {

  /* Shrink pharmacy banner */
  .ph-banner { padding: 6px 10px; min-height: unset; }
  .ph-name { font-size: 1rem; }
  .ph-icon { font-size: 1.4rem; }
  .ph-sys-badge { font-size: 9px; }

  /* Module bar */
  .mb-panel-btn { display: flex; align-items: center; }
  .mb-time { display: none; }
  .mb-date { font-size: 10px; }

  /* Toolbar — icon only, wrap allowed */
  .toolbar { gap: 2px; padding: 3px 6px; flex-wrap: nowrap; overflow-x: auto; }
  .tb-btn span { display: none; }
  .tb-btn { min-width: 32px; padding: 4px 6px; font-size: 14px; }
  .tb-btn i { font-size: 15px; }
  .tb-sep { width: 1px; min-width: 1px; margin: 0 2px; }

  /* Main area: stack vertically */
  .main-area { flex-direction: column; overflow: hidden; }
  .content-area { flex: 1; overflow-y: auto; width: 100%; }

  /* Right panel: slide-out drawer from right */
  .right-panel {
    position: fixed;
    top: 0; right: -260px;
    width: 260px;
    height: 100%;
    z-index: 200;
    transition: right .25s ease;
    overflow-y: auto;
    box-shadow: -4px 0 20px rgba(0,0,0,.35);
  }
  .right-panel.rp-open { right: 0; }

  /* Bottom tabs: horizontal scroll, larger tap targets */
  .bottom-tabs { gap: 0; padding: 0; overflow-x: auto; flex-shrink: 0; }
  .btab { padding: 9px 10px; font-size: 11px; white-space: nowrap; flex-shrink: 0; border-radius: 0; }

  /* Modal: full-width with smaller margins */
  .modal-box { width: 96vw; max-width: 96vw; margin: 20px auto; }

  /* Dashboard grid: 2 columns */
  .dash-kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .dash-grid { grid-template-columns: 1fr; }

  /* Invoice header: 2 columns */
  .inv-header-grid { grid-template-columns: repeat(2, 1fr) !important; }

  /* Forms: 2 columns max */
  .form-row-3 { grid-template-columns: repeat(2, 1fr); }
  .form-row-4 { grid-template-columns: repeat(2, 1fr); }
}

/* ═══════════════════════════════════════════════
   PHONE  ≤ 540px
═══════════════════════════════════════════════ */
@media (max-width: 540px) {

  html { font-size: 13px; }

  /* Pharmacy banner compact */
  .ph-banner { flex-direction: row; padding: 5px 8px; gap: 6px; }
  .ph-banner-content { gap: 6px; }
  .ph-name { font-size: .9rem; }

  /* Module bar */
  .module-bar { padding: 4px 8px; gap: 6px; }
  .mb-title { font-size: 11px; flex: 1; }
  .mb-date { display: none; }
  .mb-action-btn { font-size: 15px; width: 28px; height: 28px; }

  /* Toolbar: smaller icons */
  .tb-btn { min-width: 28px; padding: 3px 4px; }
  .tb-btn i { font-size: 13px; }

  /* Widen right panel to near full screen */
  .right-panel { width: 88vw; right: -88vw; }

  /* Bottom tabs: even smaller text */
  .btab { padding: 8px 8px; font-size: 10px; }

  /* Modal: bottom-sheet style */
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal-box {
    width: 100vw; max-width: 100vw;
    margin: 0;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    max-height: 92vh;
    overflow-y: auto;
  }

  /* Dashboard: single column */
  .dash-kpi-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .dash-qbtn-grid { grid-template-columns: repeat(2, 1fr); }
  .dash-chart-bar { height: 120px; }

  /* Invoice table: hide less-important columns */
  .inv-items-table th:nth-child(4),
  .inv-items-table td:nth-child(4) { display: none; } /* bonus/expiry col */

  /* Invoice header: single column */
  .inv-header-grid { grid-template-columns: 1fr !important; }

  /* Invoice bottom totals: single column */
  .inv-bottom-grid { grid-template-columns: 1fr !important; flex-direction: column; }

  /* Forms: single column always */
  .form-row-2,
  .form-row-3,
  .form-row-4 { grid-template-columns: 1fr; }
  .form-group[style*="grid-column"] { grid-column: 1 !important; }

  /* Tables: horizontal scroll */
  .table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .data-table { min-width: 480px; }

  /* Page header: stack */
  .page-header { flex-direction: column; align-items: flex-start; gap: 8px; }
  .page-header-actions { width: 100%; display: flex; gap: 6px; flex-wrap: wrap; }
  .page-header-actions .btn { flex: 1; min-width: 90px; }

  /* Card header: stack */
  .card-header { flex-direction: column; gap: 8px; align-items: stretch; }
  .card-header .search-box { width: 100%; }

  /* Buttons: comfortable tap targets */
  .btn { min-height: 36px; padding: 6px 12px; }
  .btn-sm { min-height: 28px; padding: 4px 8px; }
}
