/* =====================================================================
   MediCare Pharmacy — design system
   Blue medical theme with a navy sidebar. Plain CSS components layered
   on top of Tailwind utilities.
   ===================================================================== */

:root{
  /* brand blue */
  --b-50:#eff6ff;  --b-100:#dbeafe; --b-200:#bfdbfe;
  --b-400:#4b8ff0; --b-500:#2b78e8; --b-600:#1d69e3;
  --b-700:#1857c0; --b-800:#14479c;

  /* navy sidebar */
  --nav-bg:#0e2a47; --nav-bg-2:#0b2039;
  --nav-text:rgba(255,255,255,.74);
  --nav-text-dim:rgba(255,255,255,.40);

  --ink-900:#0f172a; --ink-800:#1e293b; --ink-700:#334155;
  --ink-500:#64748b; --ink-400:#94a3b8; --ink-300:#cbd5e1;

  --line:#e4e9f0; --line-soft:#eef2f7;
  --surface:#ffffff; --canvas:#f4f7fb; --head:#f7f9fc;

  --ok:#16a34a;  --ok-bg:#dcfce7;
  --warn:#ea8a00; --warn-bg:#ffedd5;
  --danger:#dc2626; --danger-bg:#fee2e2;
  --info:#1d69e3; --info-bg:#dbeafe;
  --purple:#7c3aed; --purple-bg:#ede9fe;

  --radius:10px;
  --shadow-xs:0 1px 2px rgba(15,23,42,.05);
  --shadow-sm:0 1px 3px rgba(15,23,42,.07), 0 1px 2px rgba(15,23,42,.04);
  --shadow-md:0 4px 10px rgba(15,23,42,.07), 0 2px 4px rgba(15,23,42,.04);
  --shadow-lg:0 16px 36px rgba(15,23,42,.13);

  --sidebar-w:228px;
  --topbar-h:56px;
}

*{ -webkit-tap-highlight-color:transparent; }
html{ scroll-behavior:smooth; -webkit-text-size-adjust:100%; }

body{
  background:var(--canvas);
  color:var(--ink-900);
  font-family:ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing:antialiased;
  font-size:14px;
}

/* ------------------------------------------------------------ scrollbars */
::-webkit-scrollbar{ width:9px; height:9px; }
::-webkit-scrollbar-track{ background:transparent; }
::-webkit-scrollbar-thumb{ background:#cbd5e1; border-radius:99px; border:2px solid transparent; background-clip:content-box; }
::-webkit-scrollbar-thumb:hover{ background:#94a3b8; background-clip:content-box; }

/* =====================================================================
   App shell
   ===================================================================== */
.app-shell{ display:flex; min-height:100vh; }

.sidebar{
  position:fixed; inset:0 auto 0 0; width:var(--sidebar-w); z-index:60;
  background:var(--nav-bg);
  display:flex; flex-direction:column;
  transform:translateX(-100%);
  transition:transform .28s cubic-bezier(.4,0,.2,1);
  box-shadow:var(--shadow-lg);
}
.sidebar.is-open{ transform:translateX(0); }
@media (min-width:1024px){
  .sidebar{ transform:none; box-shadow:none; }
  .main-area{ margin-left:var(--sidebar-w); }
}

.brand{
  display:flex; align-items:center; gap:9px; height:var(--topbar-h);
  padding:0 14px; flex:none;
  border-bottom:1px solid rgba(255,255,255,.07);
}
.brand-mark{
  height:28px; width:28px; flex:none; border-radius:7px; display:grid; place-items:center;
  background:var(--b-600); color:#fff; overflow:hidden;
}
.brand-name{ color:#fff; font-weight:650; font-size:13px; letter-spacing:-.01em; line-height:1.2; }

.sidebar-scroll{ flex:1; overflow-y:auto; padding:10px 9px; }
.sidebar-scroll::-webkit-scrollbar-thumb{ background:rgba(255,255,255,.16); background-clip:content-box; }

.nav-item{
  display:flex; align-items:center; gap:10px; padding:8px 10px; margin-bottom:2px;
  border-radius:7px; color:var(--nav-text); font-size:12.5px; font-weight:500;
  text-decoration:none; transition:background .15s, color .15s; position:relative;
  width:100%; border:0; background:none; text-align:left; cursor:pointer;
}
.nav-item svg{ height:16px; width:16px; flex:none; opacity:.85; }
.nav-item:hover{ background:rgba(255,255,255,.07); color:#fff; }
.nav-item.is-active{ background:var(--b-600); color:#fff; font-weight:600; }
.nav-item.is-active svg{ opacity:1; }
.nav-badge{
  margin-left:auto; font-size:10px; font-weight:700; padding:1px 6px; border-radius:99px;
  background:#ef4444; color:#fff;
}

.nav-sep{ height:1px; background:rgba(255,255,255,.07); margin:9px 6px; }

.sidebar-foot{ padding:9px; border-top:1px solid rgba(255,255,255,.07); flex:none; }
.sidebar-user{
  display:flex; align-items:center; gap:9px; padding:7px 8px; border-radius:8px;
  background:rgba(255,255,255,.06);
}
.avatar{
  height:30px; width:30px; flex:none; border-radius:7px; display:grid; place-items:center;
  background:var(--b-600); color:#fff; font-weight:700; font-size:11px;
}

.scrim{
  position:fixed; inset:0; z-index:55; background:rgba(15,23,42,.45);
  opacity:0; pointer-events:none; transition:opacity .25s;
}
.scrim.is-open{ opacity:1; pointer-events:auto; }
@media (min-width:1024px){ .scrim{ display:none; } }

.main-area{ flex:1; min-width:0; display:flex; flex-direction:column; }

.topbar{
  position:sticky; top:0; z-index:40; background:#fff; height:var(--topbar-h);
  border-bottom:1px solid var(--line);
  padding:0 12px; display:flex; align-items:center; gap:10px; flex:none;
}
@media (min-width:640px){ .topbar{ padding:0 18px; } }

.topbar-search{ position:relative; flex:1; max-width:340px; }
.topbar-search input{
  width:100%; height:34px; padding:0 12px 0 34px; border:1px solid var(--line);
  border-radius:8px; background:#fff; font-size:12.5px; color:var(--ink-900); outline:none;
  transition:border-color .15s, box-shadow .15s;
}
.topbar-search input:focus{ border-color:var(--b-500); box-shadow:0 0 0 3px rgba(29,105,227,.12); }
.topbar-search svg{ position:absolute; left:11px; top:50%; transform:translateY(-50%); height:15px; width:15px; color:var(--ink-400); }

.page-body{ padding:16px 14px 40px; flex:1; }
@media (min-width:640px){ .page-body{ padding:20px 18px 48px; } }

/* =====================================================================
   Typography
   ===================================================================== */
.page-title{ font-size:18px; font-weight:700; letter-spacing:-.015em; color:var(--ink-900); }
@media (min-width:640px){ .page-title{ font-size:20px; } }
.page-sub{ font-size:12.5px; color:var(--ink-500); margin-top:2px; }
.section-title{ font-size:14px; font-weight:650; color:var(--ink-900); }

/* =====================================================================
   Cards
   ===================================================================== */
.card{
  background:var(--surface); border:1px solid var(--line); border-radius:var(--radius);
  box-shadow:var(--shadow-xs);
}
.card-pad{ padding:14px; }
@media (min-width:640px){ .card-pad{ padding:16px; } }
.card-head{
  display:flex; align-items:center; justify-content:space-between; gap:10px;
  padding:12px 14px; border-bottom:1px solid var(--line);
}
.card-head h3{ font-size:13.5px; font-weight:650; color:var(--ink-900); }

/* KPI ---------------------------------------------------------------- */
.kpi{
  background:var(--surface); border:1px solid var(--line); border-radius:var(--radius);
  padding:13px 14px; box-shadow:var(--shadow-xs); display:block;
  transition:box-shadow .18s, border-color .18s;
}
a.kpi:hover{ box-shadow:var(--shadow-md); border-color:var(--b-200); }
.kpi-top{ display:flex; align-items:center; gap:7px; margin-bottom:8px; }
.kpi-dot{ height:20px; width:20px; border-radius:5px; display:grid; place-items:center; flex:none; }
.kpi-dot svg{ height:12px; width:12px; }
.kpi-label{ font-size:11.5px; font-weight:600; letter-spacing:.005em; }
.kpi-value{ font-size:21px; font-weight:750; letter-spacing:-.025em; color:var(--ink-900); line-height:1.15; }
@media (min-width:640px){ .kpi-value{ font-size:23px; } }
.kpi-trend{ display:inline-flex; align-items:center; gap:3px; font-size:11px; font-weight:650; margin-top:5px; }
.trend-up{ color:var(--ok); } .trend-down{ color:var(--danger); } .trend-flat{ color:var(--ink-400); }
.kpi-note{ font-size:11px; color:var(--ink-400); margin-top:5px; }

/* =====================================================================
   Buttons
   ===================================================================== */
.btn{
  display:inline-flex; align-items:center; justify-content:center; gap:6px;
  padding:8px 14px; border-radius:8px; font-size:12.5px; font-weight:600;
  border:1px solid transparent; cursor:pointer; text-decoration:none; white-space:nowrap;
  transition:background .15s, color .15s, border-color .15s, box-shadow .15s;
  line-height:1.3;
}
.btn:active{ transform:translateY(.5px); }
.btn svg{ height:15px; width:15px; flex:none; }
.btn:disabled,.btn.is-disabled{ opacity:.55; pointer-events:none; }

.btn-primary{ background:var(--b-600); color:#fff; }
.btn-primary:hover{ background:var(--b-700); }
.btn-dark{ background:var(--ink-900); color:#fff; }
.btn-dark:hover{ background:var(--ink-800); }
.btn-light{ background:#fff; color:var(--ink-700); border-color:var(--line); }
.btn-light:hover{ background:#f8fafc; border-color:var(--ink-300); color:var(--ink-900); }
.btn-soft{ background:var(--b-50); color:var(--b-700); }
.btn-soft:hover{ background:var(--b-100); }
.btn-success{ background:var(--ok); color:#fff; }
.btn-success:hover{ background:#15803d; }
.btn-danger{ background:var(--danger); color:#fff; }
.btn-danger:hover{ background:#b91c1c; }
.btn-warn{ background:var(--warn); color:#fff; }
.btn-ghost{ background:transparent; color:var(--ink-500); }
.btn-ghost:hover{ background:#f1f5f9; color:var(--ink-900); }
.btn-sm{ padding:6px 10px; font-size:11.5px; border-radius:7px; }
.btn-sm svg{ height:13px; width:13px; }
.btn-lg{ padding:11px 20px; font-size:14px; border-radius:9px; }
.btn-block{ width:100%; }

.icon-btn{
  height:32px; width:32px; border-radius:7px; display:inline-grid; place-items:center;
  color:var(--ink-500); background:transparent; border:1px solid transparent; cursor:pointer;
  transition:.15s;
}
.icon-btn:hover{ background:#f1f5f9; color:var(--ink-900); }
.icon-btn svg{ height:17px; width:17px; }

/* Square coloured row actions, as used in every table */
.act{
  height:26px; width:26px; border-radius:6px; display:inline-grid; place-items:center;
  border:0; cursor:pointer; transition:.15s; vertical-align:middle;
}
.act + .act{ margin-left:4px; }
.act svg{ height:13px; width:13px; }
.act-view{ background:var(--b-50); color:var(--b-600); }
.act-view:hover{ background:var(--b-600); color:#fff; }
.act-edit{ background:var(--ok-bg); color:var(--ok); }
.act-edit:hover{ background:var(--ok); color:#fff; }
.act-del{ background:var(--danger-bg); color:var(--danger); }
.act-del:hover{ background:var(--danger); color:#fff; }
.act-warn{ background:var(--warn-bg); color:var(--warn); }
.act-warn:hover{ background:var(--warn); color:#fff; }
.act-muted{ background:#f1f5f9; color:var(--ink-500); }
.act-muted:hover{ background:var(--ink-500); color:#fff; }

/* =====================================================================
   Forms
   ===================================================================== */
.field{ margin-bottom:13px; }
.label{ display:block; font-size:12px; font-weight:600; color:var(--ink-700); margin-bottom:5px; }
.label .req{ color:var(--danger); margin-left:2px; }
.hint{ font-size:11px; color:var(--ink-400); margin-top:4px; }

.input, .select, .textarea{
  width:100%; padding:8px 11px; border:1px solid var(--line); border-radius:8px;
  background:#fff; font-size:12.5px; color:var(--ink-900); outline:none;
  transition:border-color .15s, box-shadow .15s;
}
.input::placeholder,.textarea::placeholder{ color:#a8b4c4; }
.input:focus,.select:focus,.textarea:focus{
  border-color:var(--b-500); box-shadow:0 0 0 3px rgba(29,105,227,.12);
}
.input:disabled,.select:disabled{ background:#f4f7fb; color:var(--ink-400); cursor:not-allowed; }
.textarea{ min-height:80px; resize:vertical; }
.select{
  appearance:none; padding-right:32px; cursor:pointer;
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748b' stroke-width='2.2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat:no-repeat; background-position:right 10px center; background-size:15px;
}
.input-error{ border-color:var(--danger)!important; box-shadow:0 0 0 3px rgba(220,38,38,.12)!important; }
.error-text{ font-size:11px; color:var(--danger); margin-top:4px; font-weight:500; }

.input-group{ position:relative; }
.input-group .input{ padding-left:34px; }
.input-icon{
  position:absolute; left:11px; top:50%; transform:translateY(-50%);
  height:15px; width:15px; color:var(--ink-400); pointer-events:none;
}

.switch{ position:relative; display:inline-flex; align-items:center; cursor:pointer; gap:9px; }
.switch input{ position:absolute; opacity:0; width:0; height:0; }
.switch-track{
  height:21px; width:38px; border-radius:99px; background:var(--ink-300); position:relative;
  transition:background .2s; flex:none;
}
.switch-track::after{
  content:""; position:absolute; top:2.5px; left:2.5px; height:16px; width:16px; border-radius:50%;
  background:#fff; box-shadow:var(--shadow-xs); transition:transform .2s;
}
.switch input:checked + .switch-track{ background:var(--b-600); }
.switch input:checked + .switch-track::after{ transform:translateX(17px); }

.check{
  height:15px; width:15px; border-radius:4px; border:1.5px solid var(--ink-300);
  accent-color:var(--b-600); cursor:pointer;
}

/* Radio pill group (Retail / Wholesale etc.) */
.seg{ display:inline-flex; background:#eef2f7; padding:3px; border-radius:8px; gap:2px; }
.seg label{ position:relative; cursor:pointer; }
.seg input{ position:absolute; opacity:0; }
.seg span{
  display:block; padding:5px 13px; border-radius:6px; font-size:12px; font-weight:600;
  color:var(--ink-500); transition:.18s; white-space:nowrap; text-align:center;
}
.seg input:checked + span{ background:#fff; color:var(--b-700); box-shadow:var(--shadow-xs); }

/* Inline radio, mockup style: ● Retail  ○ Wholesale */
.radio-row{ display:flex; flex-wrap:wrap; gap:16px; }
.radio-opt{ display:inline-flex; align-items:center; gap:6px; cursor:pointer; font-size:12.5px; color:var(--ink-700); }
.radio-opt input{ accent-color:var(--b-600); height:14px; width:14px; cursor:pointer; }

/* =====================================================================
   Tables
   ===================================================================== */
.table-wrap{ overflow-x:auto; }
.table{ width:100%; border-collapse:separate; border-spacing:0; font-size:12.5px; }
.table thead th{
  background:var(--head); text-align:left; padding:9px 12px;
  font-size:11px; font-weight:650; color:var(--ink-500);
  border-bottom:1px solid var(--line); white-space:nowrap;
}
.table tbody td{ padding:10px 12px; border-bottom:1px solid var(--line-soft); color:var(--ink-700); vertical-align:middle; }
.table tbody tr{ transition:background .12s; }
.table tbody tr:hover{ background:#f9fbfd; }
.table tbody tr:last-child td{ border-bottom:0; }
.table .num{ text-align:right; font-variant-numeric:tabular-nums; }
.table .strong{ font-weight:650; color:var(--ink-900); }
.table .idx{ color:var(--ink-400); width:40px; }
.table tfoot td{ padding:10px 12px; font-weight:650; color:var(--ink-900); background:var(--head); border-top:1px solid var(--line); }

.empty{ padding:44px 20px; text-align:center; }
.empty-icon{
  height:48px; width:48px; margin:0 auto 12px; border-radius:12px; display:grid; place-items:center;
  background:#f1f5f9; color:var(--ink-400);
}
.empty h4{ font-size:14px; font-weight:650; color:var(--ink-900); }
.empty p{ font-size:12.5px; color:var(--ink-500); margin-top:3px; }

/* =====================================================================
   Badges
   ===================================================================== */
.badge{
  display:inline-flex; align-items:center; gap:4px; padding:2.5px 8px; border-radius:5px;
  font-size:10.5px; font-weight:650; white-space:nowrap; line-height:1.5;
}
.badge-ok{ background:var(--ok-bg); color:var(--ok); }
.badge-warn{ background:var(--warn-bg); color:var(--warn); }
.badge-danger{ background:var(--danger-bg); color:var(--danger); }
.badge-info{ background:var(--info-bg); color:var(--info); }
.badge-brand{ background:var(--b-50); color:var(--b-700); }
.badge-purple{ background:var(--purple-bg); color:var(--purple); }
.badge-muted{ background:#f1f5f9; color:var(--ink-500); }
.dot{ height:5px; width:5px; border-radius:50%; background:currentColor; }

/* =====================================================================
   Alerts & toasts
   ===================================================================== */
.alert{
  display:flex; gap:10px; padding:11px 13px; border-radius:9px; font-size:12.5px;
  border:1px solid transparent; margin-bottom:13px; line-height:1.55;
}
.alert svg{ height:17px; width:17px; flex:none; margin-top:1px; }
.alert-success{ background:var(--ok-bg); border-color:#bbf7d0; color:#15803d; }
.alert-error{ background:var(--danger-bg); border-color:#fecaca; color:#b91c1c; }
.alert-warning{ background:var(--warn-bg); border-color:#fed7aa; color:#c2410c; }
.alert-info{ background:var(--info-bg); border-color:var(--b-200); color:var(--b-800); }

#toasts{ position:fixed; top:14px; right:14px; z-index:200; display:flex; flex-direction:column; gap:9px; max-width:calc(100vw - 28px); }
.toast{
  display:flex; align-items:flex-start; gap:10px; min-width:250px; max-width:360px;
  background:#fff; border:1px solid var(--line); border-radius:9px; padding:11px 13px;
  box-shadow:var(--shadow-lg); animation:toastIn .3s cubic-bezier(.2,1.2,.3,1);
}
.toast.is-out{ animation:toastOut .22s forwards; }
.toast-icon{ height:20px; width:20px; border-radius:6px; display:grid; place-items:center; flex:none; }
.toast-icon svg{ height:12px; width:12px; }
.toast-title{ font-size:12.5px; font-weight:650; color:var(--ink-900); }
.toast-msg{ font-size:11.5px; color:var(--ink-500); margin-top:1px; line-height:1.5; }
@keyframes toastIn{ from{ opacity:0; transform:translateX(26px);} to{opacity:1;transform:none;} }
@keyframes toastOut{ to{ opacity:0; transform:translateX(26px);} }

/* =====================================================================
   Modal
   ===================================================================== */
.modal-backdrop{
  position:fixed; inset:0; z-index:120; background:rgba(15,23,42,.5);
  display:flex; align-items:center; justify-content:center; padding:14px;
  opacity:0; pointer-events:none; transition:opacity .2s;
}
.modal-backdrop.is-open{ opacity:1; pointer-events:auto; }
.modal{
  background:#fff; border-radius:12px; width:100%; max-width:520px; max-height:92vh;
  display:flex; flex-direction:column; box-shadow:var(--shadow-lg);
  transform:translateY(12px); transition:transform .25s cubic-bezier(.2,1,.3,1);
}
.modal-backdrop.is-open .modal{ transform:none; }
.modal-lg{ max-width:780px; } .modal-xl{ max-width:1020px; }
.modal-head{ display:flex; align-items:center; justify-content:space-between; gap:10px; padding:14px 16px; border-bottom:1px solid var(--line); }
.modal-head h3{ font-size:15px; font-weight:680; color:var(--ink-900); }
.modal-body{ padding:16px; overflow-y:auto; }
/* A form loaded into a popup keeps its save/cancel row pinned to the bottom,
   so it stays reachable however long the form is. */
#formModalBody .form-actions{
  position:sticky; bottom:-16px; z-index:5; background:#fff;
  border-top:1px solid var(--line);
  box-shadow:0 -8px 18px rgba(15,23,42,.06);
}
#formModalBody{ padding-bottom:0; }
#formModalBody > *:last-child{ margin-bottom:16px; }

.modal-foot{ padding:12px 16px; border-top:1px solid var(--line); display:flex; gap:9px; justify-content:flex-end; background:#fafbfd; border-radius:0 0 12px 12px; }

/* =====================================================================
   In-page sub navigation (module tabs)
   ===================================================================== */
.ptabs{
  display:flex; gap:4px; overflow-x:auto; padding:4px; background:#fff;
  border:1px solid var(--line); border-radius:9px; margin-bottom:16px;
  scrollbar-width:none;
}
.ptabs::-webkit-scrollbar{ display:none; }
.ptab{
  display:inline-flex; align-items:center; gap:6px; padding:7px 12px; border-radius:7px;
  font-size:12.5px; font-weight:600; color:var(--ink-500); white-space:nowrap;
  text-decoration:none; transition:.15s;
}
.ptab svg{ height:15px; width:15px; }
.ptab:hover{ background:#f1f5f9; color:var(--ink-900); }
.ptab.is-active{ background:var(--b-600); color:#fff; }
.ptab-count{ font-size:10px; font-weight:700; padding:1px 5px; border-radius:99px; background:rgba(0,0,0,.08); }
.ptab.is-active .ptab-count{ background:rgba(255,255,255,.22); }

/* =====================================================================
   Profile header - one card carrying who this is, what they are worth to
   the pharmacy, and the tabs into the detail.

   The strip along the top is the only colour: green when the account is
   settled, red when money is owed. It is a status, not decoration, which is
   why it replaced the large photo-style banner this started out with.
   ===================================================================== */
.profile{ background:#fff; border:1px solid var(--line); border-radius:12px; overflow:hidden; margin-bottom:16px; }

.profile-accent{ height:4px; background:var(--b-600); }
.profile.is-owing  .profile-accent{ background:linear-gradient(90deg,#e11d48,#f43f5e); }
.profile.is-clear  .profile-accent{ background:linear-gradient(90deg,#059669,#10b981); }

.profile-body{ padding:18px 20px 16px; }

.profile-top{ display:flex; align-items:center; gap:15px; flex-wrap:wrap; }

.profile-avatar{
  height:60px; width:60px; border-radius:16px; flex:none;
  background:linear-gradient(135deg,#4b8ff0,#1d69e3); color:#fff;
  display:grid; place-items:center; font-size:20px; font-weight:800; letter-spacing:.5px;
  box-shadow:0 4px 12px rgba(29,105,227,.28);
}

.profile-ident{ min-width:0; flex:1 1 240px; }
.profile-name{ font-size:20px; font-weight:800; color:var(--ink-900,#0f172a); letter-spacing:-.4px; line-height:1.2; }
.profile-meta{ display:flex; flex-wrap:wrap; gap:4px 13px; margin-top:5px; }
.profile-meta span{ display:inline-flex; align-items:center; gap:5px; font-size:12px; color:var(--ink-500); }
.profile-meta svg{ height:13px; width:13px; color:#94a3b8; flex:none; }

.profile-actions{ display:flex; flex-wrap:wrap; gap:8px; margin-left:auto; }

/* The four figures, divided rather than boxed, so they read as one row. */
.profile-stats{
  display:grid; grid-template-columns:repeat(4,1fr); gap:0;
  margin-top:16px; border-top:1px solid var(--line); padding-top:14px;
}
.profile-stat{ padding:0 16px; border-left:1px solid var(--line); }
.profile-stat:first-child{ border-left:0; padding-left:0; }
.profile-stat dt{ font-size:11px; font-weight:600; color:var(--ink-400,#94a3b8); text-transform:uppercase; letter-spacing:.5px; }
.profile-stat dd{ font-size:19px; font-weight:800; margin-top:3px; display:flex; align-items:center; gap:6px; }

.profile-tabs{
  border-top:1px solid var(--line); background:#fbfcfe; padding:5px 10px;
  display:flex; gap:3px; overflow-x:auto; scrollbar-width:none;
}
.profile-tabs::-webkit-scrollbar{ display:none; }
.profile-tab{
  display:inline-flex; align-items:center; gap:6px; padding:9px 13px; border-radius:8px;
  font-size:12.5px; font-weight:600; color:var(--ink-500); white-space:nowrap;
  text-decoration:none; transition:.15s;
}
.profile-tab svg{ height:15px; width:15px; }
.profile-tab:hover{ background:#eef2f8; color:var(--ink-900,#0f172a); }
.profile-tab.is-active{ background:#fff; color:var(--b-700,#1d4ed8); box-shadow:0 1px 2px rgba(15,23,42,.07); }
.profile-tab-count{ font-size:10px; font-weight:700; padding:1px 6px; border-radius:99px; background:#fee2e2; color:#b91c1c; }

@media (max-width:880px){
  .profile-actions{ margin-left:0; width:100%; }
  .profile-actions .btn{ flex:1 1 auto; justify-content:center; }
  /* Back is a way out, not an action; it should not claim equal width. */
  .profile-actions .btn-ghost{ flex:0 0 auto; }
}

@media (max-width:640px){
  .profile-body{ padding:15px 16px 14px; }
  .profile-avatar{ height:52px; width:52px; font-size:17px; border-radius:14px; }
  .profile-name{ font-size:17.5px; }
  .profile-stats{ grid-template-columns:repeat(2,1fr); gap:13px 0; }
  .profile-stat{ padding:0 13px; }
  .profile-stat:nth-child(odd){ border-left:0; padding-left:0; }
  .profile-stat dd{ font-size:17px; }
}
/* Vertical tabs (settings, full medicine form) */
.vtabs{ display:flex; flex-direction:column; gap:2px; }
.vtab{
  display:flex; align-items:center; gap:9px; padding:9px 12px; border-radius:7px;
  font-size:12.5px; font-weight:550; color:var(--ink-600, #475569); text-decoration:none;
  transition:.15s; cursor:pointer; border:0; background:none; width:100%; text-align:left;
}
.vtab svg{ height:15px; width:15px; flex:none; }
.vtab:hover{ background:#f1f5f9; color:var(--ink-900); }
.vtab.is-active{ background:var(--b-600); color:#fff; }

/* =====================================================================
   Report hub cards
   ===================================================================== */
.report-card{
  display:block; border-radius:10px; padding:14px; text-decoration:none;
  border:1px solid transparent; transition:transform .18s, box-shadow .18s;
}
.report-card:hover{ transform:translateY(-2px); box-shadow:var(--shadow-md); }
.report-icon{ height:32px; width:32px; border-radius:8px; display:grid; place-items:center; margin-bottom:9px; }
.report-icon svg{ height:17px; width:17px; }
.report-card h4{ font-size:13px; font-weight:680; color:var(--ink-900); }
.report-card p{ font-size:11px; color:var(--ink-500); margin-top:2px; }

/* =====================================================================
   Document template gallery
   ===================================================================== */
.tpl-card{
  border:1.5px solid var(--line); border-radius:10px; overflow:hidden; background:#fff;
  transition:border-color .18s, box-shadow .18s; cursor:pointer; display:block;
}
.tpl-card:hover{ border-color:var(--b-400); box-shadow:var(--shadow-md); }
.tpl-card.is-default{ border-color:var(--b-600); box-shadow:0 0 0 3px rgba(29,105,227,.12); }
.tpl-thumb{
  height:150px; background:#f7f9fc; border-bottom:1px solid var(--line);
  display:flex; align-items:flex-start; justify-content:center; padding:10px; overflow:hidden;
}
.tpl-paper{
  width:100%; max-width:150px; background:#fff; border:1px solid #e8edf4; border-radius:3px;
  padding:7px; font-size:4.5px; line-height:1.5; color:#475569; box-shadow:0 1px 3px rgba(15,23,42,.06);
}
.tpl-foot{ padding:9px 11px; display:flex; align-items:center; justify-content:space-between; gap:8px; }
.tpl-name{ font-size:12px; font-weight:650; color:var(--ink-900); }

/* =====================================================================
   Printable document preview (dark side panel)
   ===================================================================== */
.doc-stage{ display:grid; grid-template-columns:1fr; gap:0; min-height:100vh; }
@media (min-width:1024px){ .doc-stage{ grid-template-columns:1fr 260px; } }
.doc-canvas{ background:#0e2a47; padding:24px 16px; display:flex; justify-content:center; align-items:flex-start; }
.doc-side{ background:#0b2039; padding:20px 16px; display:flex; flex-direction:column; gap:10px; }
.doc-side-btn{
  display:flex; align-items:center; gap:9px; padding:10px 13px; border-radius:8px;
  background:rgba(255,255,255,.07); color:#fff; font-size:12.5px; font-weight:600;
  text-decoration:none; border:0; cursor:pointer; width:100%; transition:.15s;
}
.doc-side-btn:hover{ background:rgba(255,255,255,.14); }
.doc-side-btn svg{ height:15px; width:15px; }
.doc-side-label{ font-size:10.5px; font-weight:700; letter-spacing:.09em; text-transform:uppercase; color:rgba(255,255,255,.4); margin-top:8px; }
.doc-side select{
  width:100%; padding:9px 12px; border-radius:8px; background:rgba(255,255,255,.07);
  border:1px solid rgba(255,255,255,.12); color:#fff; font-size:12.5px; outline:none;
  appearance:none; cursor:pointer;
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%23ffffff' stroke-width='2.2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat:no-repeat; background-position:right 10px center; background-size:14px;
}
.doc-side select option{ background:#0b2039; color:#fff; }

/* =====================================================================
   POS
   ===================================================================== */
.pos-grid{ display:grid; gap:14px; grid-template-columns:1fr; }

/* From tablet up the cart sits beside the catalogue and stays in view while
   the list scrolls. Below that it becomes a bottom sheet, so it never ends up
   stranded underneath a long list of medicines. */
@media (min-width:1024px){
  .pos-grid{ grid-template-columns:minmax(0,1fr) 360px; align-items:start; }
  .pos-cart{
    position:sticky; top:calc(var(--topbar-h) + 14px);
    /* Sized so the whole panel — including Complete Sale — fits on screen even
       before the page is scrolled and the sticky offset kicks in. */
    max-height:calc(100vh - 150px);
    display:flex; flex-direction:column;
  }
}
@media (min-width:1400px){ .pos-grid{ grid-template-columns:minmax(0,1fr) 400px; } }

/* On a short desktop window the panel simply cannot hold the item list, the
   totals and the pay button at once — so let it flow and the page scroll,
   rather than hiding Complete Sale below the fold. */
@media (min-width:1024px) and (max-height:760px){
  .pos-cart{ position:static; max-height:none; }
  .pos-cart-items{ min-height:auto; max-height:none; overflow:visible; }
}

/* The item list is the only part that scrolls, so totals and the pay button
   are always reachable no matter how many lines are in the sale. */
.pos-cart-items{ overflow-y:auto; flex:1 1 auto; min-height:172px; }
/* min-height:0 lets flexbox shrink the list to whatever is left after the
   totals and pay button, instead of overflowing the panel. */
@media (min-width:1024px){ .pos-cart-items{ max-height:none; min-height:0; } }
@media (max-width:1023.98px){ .pos-cart-items{ max-height:38vh; } }

/* ---- mobile bottom sheet ---- */
@media (max-width:1023.98px){
  .pos-cart{
    position:fixed; left:0; right:0; bottom:0; z-index:110;
    max-height:88vh; display:flex; flex-direction:column;
    border-radius:16px 16px 0 0; border-bottom:0;
    box-shadow:0 -12px 32px rgba(15,23,42,.18);
    transform:translateY(calc(100% + 20px));
    transition:transform .3s cubic-bezier(.4,0,.2,1);
  }
  .pos-cart.is-open{ transform:translateY(0); }
  .pos-cart-grip{
    display:block; height:4px; width:40px; border-radius:99px; background:#cbd5e1;
    margin:8px auto 0; flex:none;
  }
  .page-body{ padding-bottom:84px; }
}
@media (min-width:1024px){ .pos-cart-grip, .pos-bar, .pos-sheet-scrim{ display:none !important; } }

/* Bar pinned to the bottom on small screens: item count, total, open cart. */
.pos-bar{
  position:fixed; left:0; right:0; bottom:0; z-index:100;
  background:#fff; border-top:1px solid var(--line);
  padding:9px 12px calc(9px + env(safe-area-inset-bottom));
  display:flex; align-items:center; gap:10px;
  box-shadow:0 -4px 16px rgba(15,23,42,.08);
}
.pos-sheet-scrim{
  position:fixed; inset:0; z-index:105; background:rgba(15,23,42,.45);
  opacity:0; pointer-events:none; transition:opacity .25s;
}
.pos-sheet-scrim.is-open{ opacity:1; pointer-events:auto; }

/* =====================================================================
   Mobile bottom navigation
   ===================================================================== */
.mnav{
  position:fixed; left:0; right:0; bottom:0; z-index:95;
  background:#fff; border-top:1px solid var(--line);
  display:grid; grid-auto-flow:column; grid-auto-columns:1fr;
  padding-bottom:env(safe-area-inset-bottom);
  box-shadow:0 -2px 12px rgba(15,23,42,.07);
}
@media (min-width:1024px){ .mnav{ display:none; } }

.mnav-item{
  display:flex; flex-direction:column; align-items:center; justify-content:center; gap:3px;
  padding:8px 4px 7px; text-decoration:none; color:var(--ink-400);
  font-size:10px; font-weight:600; letter-spacing:.005em;
  background:none; border:0; cursor:pointer; position:relative; transition:color .15s;
  min-height:54px;
}
.mnav-item svg{ height:19px; width:19px; }
.mnav-item span{ line-height:1.1; }
.mnav-item:active{ background:#f8fafc; }
.mnav-item.is-active{ color:var(--b-600); }
.mnav-item.is-active::before{
  content:""; position:absolute; top:0; left:50%; transform:translateX(-50%);
  height:2.5px; width:26px; border-radius:0 0 3px 3px; background:var(--b-600);
}
.mnav-dot{
  position:absolute; top:6px; right:calc(50% - 18px);
  height:14px; min-width:14px; padding:0 3px; border-radius:99px;
  background:#ef4444; color:#fff; font-size:8.5px; font-weight:700;
  display:grid; place-items:center;
}

/* Room for the bar, so nothing hides behind it. */
@media (max-width:1023.98px){
  body.has-mnav .page-body{ padding-bottom:74px; }
  body.has-mnav footer{ margin-bottom:58px; }
  /* On the POS the cart bar takes this space instead. */
  body.has-posbar .mnav{ display:none; }
}

.pos-pick{
  display:flex; align-items:center; justify-content:space-between; gap:10px;
  padding:9px 12px; border-bottom:1px solid var(--line-soft); cursor:pointer;
  transition:background .12s; width:100%; text-align:left; background:none; border-left:0; border-right:0; border-top:0;
}
.pos-pick:hover{ background:var(--b-50); }
.pos-pick:disabled{ opacity:.45; cursor:not-allowed; }
.pos-pick:last-child{ border-bottom:0; }

.med-tile{
  border:1px solid var(--line); background:#fff; border-radius:9px; padding:11px; cursor:pointer;
  transition:.15s; text-align:left; display:flex; flex-direction:column; gap:3px; height:100%;
}
.med-tile:hover{ border-color:var(--b-400); box-shadow:var(--shadow-sm); }
.med-tile:disabled{ opacity:.5; cursor:not-allowed; box-shadow:none; }

.qty-box{ display:inline-flex; align-items:center; border:1px solid var(--line); border-radius:7px; overflow:hidden; background:#fff; }
.qty-box button{ height:25px; width:25px; display:grid; place-items:center; color:var(--ink-500); transition:.12s; }
.qty-box button:hover{ background:#f1f5f9; color:var(--ink-900); }
.qty-box input{ height:25px; width:38px; text-align:center; border:0; border-left:1px solid var(--line); border-right:1px solid var(--line); font-size:12px; font-weight:650; outline:none; }

.pay-method{ cursor:pointer; }
.pay-method input{ position:absolute; opacity:0; }
.pay-method span{
  display:block; padding:5px 4px; border:1px solid var(--line); border-radius:6px; text-align:center;
  font-size:10.5px; font-weight:600; color:var(--ink-500); transition:.15s; background:#fff;
}
.pay-method input:checked + span{ border-color:var(--b-600); background:var(--b-600); color:#fff; }

/* Full / Partial / Credit. Three states, three colours, no guessing which
   one is active - the till operator has to be able to see it at a glance. */
.paystatus{ display:grid; grid-template-columns:repeat(3,1fr); gap:6px; }
.paystatus-opt{ cursor:pointer; }
.paystatus-opt input{ position:absolute; opacity:0; width:0; height:0; }
.paystatus-opt > span{
  display:flex; align-items:center; justify-content:center; gap:5px;
  padding:9px 6px; border:1.5px solid var(--line); border-radius:9px;
  font-size:12px; font-weight:700; color:var(--ink-500); background:#fff;
  transition:.15s; white-space:nowrap;
}
.paystatus-opt:hover > span{ border-color:#cbd5e1; }
.paystatus-opt input:focus-visible + span{ outline:2px solid var(--b-500); outline-offset:2px; }
.paystatus-opt input:disabled + span{ opacity:.4; cursor:not-allowed; }

.paystatus-opt[data-tone=full].is-on > span{    border-color:#059669; background:#ecfdf5; color:#047857; }
.paystatus-opt[data-tone=partial].is-on > span{ border-color:#d97706; background:#fffbeb; color:#b45309; }
.paystatus-opt[data-tone=credit].is-on > span{  border-color:#e11d48; background:#fff1f2; color:#be123c; }

@media (max-width:359px){
  .paystatus-opt > span{ font-size:11px; padding:8px 3px; gap:3px; }
}

/* =====================================================================
   Misc
   ===================================================================== */
.pager{ display:flex; align-items:center; gap:4px; flex-wrap:wrap; padding:11px 13px; border-top:1px solid var(--line); }
.pager-link{
  min-width:30px; height:30px; padding:0 9px; border-radius:6px; display:inline-grid; place-items:center;
  font-size:12px; font-weight:600; color:var(--ink-500); border:1px solid var(--line); background:#fff;
  text-decoration:none; transition:.15s;
}
.pager-link:hover{ border-color:var(--b-400); color:var(--b-700); }
.pager-link.is-active{ background:var(--b-600); border-color:var(--b-600); color:#fff; }
.pager-info{ margin-left:auto; font-size:11.5px; color:var(--ink-400); }

.progress{ height:5px; border-radius:99px; background:#e8edf4; overflow:hidden; }
.progress > span{ display:block; height:100%; border-radius:99px; background:var(--b-600); transition:width .45s; }

.quick-action{
  display:flex; flex-direction:column; align-items:center; justify-content:center; gap:7px;
  padding:13px 8px; border-radius:9px; border:1px solid var(--line); background:#fff;
  text-decoration:none; transition:.18s; text-align:center;
}
.quick-action:hover{ border-color:var(--b-400); box-shadow:var(--shadow-sm); }
.quick-action span.qa-ico{ height:34px; width:34px; border-radius:8px; display:grid; place-items:center; }
.quick-action span.qa-ico svg{ height:17px; width:17px; }
.quick-action span.qa-txt{ font-size:11.5px; font-weight:600; color:var(--ink-700); line-height:1.3; }

.stat-row{ display:flex; justify-content:space-between; align-items:center; gap:10px; padding:8px 0; font-size:12.5px; }
.stat-row + .stat-row{ border-top:1px solid var(--line-soft); }
.stat-row dt{ color:var(--ink-500); }
.stat-row dd{ font-weight:650; color:var(--ink-900); font-variant-numeric:tabular-nums; text-align:right; }

.skeleton{ background:linear-gradient(90deg,#eef2f7 25%,#f8fafc 50%,#eef2f7 75%); background-size:200% 100%; animation:shimmer 1.3s infinite; border-radius:7px; }
@keyframes shimmer{ to{ background-position:-200% 0; } }

/* `backwards` (not `both`) matters: a retained transform would turn this element into
   the containing block for every position:fixed modal inside it. */
.fade-in{ animation:fadeIn .28s ease backwards; }
@keyframes fadeIn{ from{ opacity:0; transform:translateY(5px);} to{ opacity:1; transform:translateY(0);} }

.spin{ animation:spin 1s linear infinite; }
@keyframes spin{ to{ transform:rotate(360deg); } }

kbd{
  display:inline-block; padding:1px 5px; border-radius:4px; background:#f1f5f9;
  border:1px solid var(--line); font-size:10px; font-weight:600; color:var(--ink-500);
  font-family:inherit;
}

/* =====================================================================
   Login
   ===================================================================== */
.login-wrap{ min-height:100vh; display:grid; grid-template-columns:1fr; background:#fff; }
@media (min-width:1024px){ .login-wrap{ grid-template-columns:minmax(0,480px) 1fr; } }

.login-art{
  position:relative; display:none; overflow:hidden; background:#0e2a47;
}
@media (min-width:1024px){ .login-art{ display:block; } }
.login-art img{ position:absolute; inset:0; height:100%; width:100%; object-fit:cover; object-position:72% center; }
.login-art::after{
  content:""; position:absolute; inset:0;
  background:linear-gradient(100deg, rgba(10,32,57,.97) 0%, rgba(13,45,82,.90) 34%, rgba(18,70,130,.55) 62%, rgba(29,105,227,.14) 100%);
}
.login-art-body{ position:relative; z-index:2; height:100%; display:flex; flex-direction:column; justify-content:center; padding:56px 60px; }

/* =====================================================================
   Print
   ===================================================================== */
@media print{
  .no-print, .sidebar, .topbar, .scrim, #toasts, .doc-side{ display:none !important; }
  body{ background:#fff !important; }
  .main-area{ margin-left:0 !important; }
  .page-body{ padding:0 !important; }
  .card{ border:0 !important; box-shadow:none !important; }
  .doc-stage{ display:block !important; min-height:0 !important; }
  .doc-canvas{ background:#fff !important; padding:0 !important; display:block !important; }
  .print-sheet{ box-shadow:none !important; margin:0 !important; border:0 !important; border-radius:0 !important; }
  @page{ margin:10mm; }
}
