/* VectorForce Clinic — staff app styles.
   Layout: top bar + role tabs, then one working area per page (boards, two-pane doctor desk, tables). */
:root {
  --bg: #f3f5f2;
  --card: #ffffff;
  --ink: #13201c;
  --ink2: #34443e;
  --mute: #677670;
  --line: #e0e6e2;
  --line2: #cbd4cf;
  --soft: #f7f9f7;
  --brand: #0e7a6a;
  --brand-dark: #0a5c50;
  --brand-soft: #e1f2ee;
  --warn: #a35a06;
  --warn-soft: #fdf1d8;
  --danger: #b42318;
  --danger-soft: #fde8e5;
  --ok: #157f3c;
  --ok-soft: #dcf5e4;
  --info: #1f4fbf;
  --info-soft: #e1e9fb;
  --vf: #ff5a1f;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 20, 0.05), 0 6px 18px -10px rgba(16, 24, 20, 0.22);
  --font: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, Menlo, Consolas, monospace;
  --urdu: 'Noto Nastaliq Urdu', 'Jameel Noori Nastaleeq', 'Urdu Typesetting', 'Noto Naskh Arabic', serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand-dark); }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; letter-spacing: -0.01em; }
h1 { font-size: 24px; font-weight: 600; }
h2 { font-size: 18px; font-weight: 600; }
h3 { font-size: 15px; font-weight: 600; }
.muted { color: var(--mute); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.mono, .num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.urdu { font-family: var(--urdu); direction: rtl; line-height: 2.1; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.grow { flex: 1; min-width: 0; }

/* ---------- layout ---------- */
.app { min-height: 100%; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: 0 max(16px, env(safe-area-inset-right, 0px)) 0 max(16px, env(safe-area-inset-left, 0px));
}
.topbar-in { display: flex; align-items: center; gap: 18px; min-height: 58px; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px; flex: 0 0 34px;
  background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 15px;
}
.brand b { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; display: block; }
.brand small { display: block; color: var(--mute); font-size: 12px; }
.nav { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; flex: 1; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  text-decoration: none; color: var(--ink2); padding: 8px 12px; border-radius: 9px; font-weight: 500; white-space: nowrap; font-size: 14px;
}
.nav a:hover { background: var(--soft); }
.nav a.on { background: var(--brand-soft); color: var(--brand-dark); }
.userbox { display: flex; align-items: center; gap: 10px; }
.userbox .who { text-align: right; line-height: 1.2; }
.userbox .who b { display: block; font-size: 13.5px; }
.userbox .who span { font-size: 12px; color: var(--mute); text-transform: capitalize; }
.main {
  flex: 1; width: 100%; max-width: 1480px; margin: 0 auto;
  padding: 20px max(16px, env(safe-area-inset-right, 0px)) 60px max(16px, env(safe-area-inset-left, 0px));
}
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head .title { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack.s8 { gap: 8px; }
.stack.s16 { gap: 16px; }
.cluster { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.cluster.end { justify-content: flex-end; }
.between { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.grid4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 900px) { .grid3, .grid4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .grid2, .grid3, .grid4 { grid-template-columns: 1fr; } }

/* ---------- cards ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }
.card-b { padding: 16px; }
.card-h { padding: 14px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.card-f { padding: 12px 16px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.section-title { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--mute); margin: 4px 0 8px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid var(--line2); background: var(--card); color: var(--ink);
  border-radius: 10px; padding: 9px 14px; font-weight: 500; font-size: 14px; cursor: pointer; text-decoration: none;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s; white-space: nowrap; min-height: 40px;
}
.btn:hover { background: var(--soft); border-color: var(--ink2); }
.btn:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 40%, transparent); outline-offset: 1px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn.dark { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.dark:hover { background: #000; }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.danger.solid { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.btn.warn:hover { background: var(--warn-soft); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--soft); border-color: var(--line); }
.btn.wa { background: #1fa855; border-color: #1fa855; color: #fff; }
.btn.wa:hover { background: #178a45; }
.btn.sm { padding: 5px 10px; font-size: 13px; min-height: 32px; border-radius: 8px; }
.btn.lg { padding: 13px 20px; font-size: 16px; min-height: 50px; border-radius: 12px; }
.btn.xl { padding: 16px 22px; font-size: 18px; min-height: 60px; border-radius: 14px; font-weight: 600; }
.btn.block { width: 100%; }
.btn .k { font-family: var(--mono); font-size: 11px; opacity: 0.75; border: 1px solid currentColor; border-radius: 5px; padding: 0 4px; }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > span { font-size: 13px; font-weight: 500; color: var(--ink2); }
.field > small { font-size: 12px; color: var(--mute); }
.input, .select, .textarea {
  width: 100%; min-width: 0; border: 1px solid var(--line2); background: #fff; border-radius: 10px; padding: 9px 11px; min-height: 40px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.textarea { min-height: 70px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 20%, transparent); }
.input.big { font-size: 18px; min-height: 50px; }
.input.num { text-align: right; }
.check { display: inline-flex; gap: 8px; align-items: center; cursor: pointer; font-size: 14px; }
.check input { width: 18px; height: 18px; accent-color: var(--brand); }
.seg { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.seg button {
  border: 1px solid var(--line2); background: #fff; border-radius: 9px; padding: 7px 12px; cursor: pointer; font-weight: 500; font-size: 14px; min-height: 38px;
}
.seg button:hover { border-color: var(--ink2); }
.seg button.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.seg.brand button.on { background: var(--brand); border-color: var(--brand); }
.err { color: var(--danger); font-size: 13.5px; }

/* ---------- chips / badges ---------- */
.chip { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 500; padding: 2px 9px; border-radius: 999px; background: var(--soft); color: var(--ink2); border: 1px solid var(--line); white-space: nowrap; }
.chip.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.chip.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.chip.danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.chip.info { background: var(--info-soft); color: var(--info); border-color: transparent; }
.chip.brand { background: var(--brand-soft); color: var(--brand-dark); border-color: transparent; }
.chip.dark { background: var(--ink); color: #fff; border-color: transparent; }
.chip.x { cursor: pointer; }
.pick { cursor: pointer; border-style: dashed; }
.pick.on { background: var(--brand-soft); color: var(--brand-dark); border-style: solid; border-color: var(--brand); }

/* ---------- tables ---------- */
.tbl { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th { text-align: left; font-size: 12px; font-weight: 600; color: var(--mute); text-transform: uppercase; letter-spacing: 0.04em; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--soft); }
table.t td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.t tr:last-child td { border-bottom: 0; }
table.t td.num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
table.t th.num { text-align: right; font-family: var(--font); }
table.t tr.void td { color: var(--mute); text-decoration: line-through; }
table.t tfoot td { font-weight: 600; background: var(--soft); }

/* ---------- KPI ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.kpi span { font-size: 12.5px; color: var(--mute); display: block; }
.kpi b { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; display: block; margin-top: 2px; }
.kpi small { font-size: 12px; color: var(--mute); }
.kpi.alert { border-color: color-mix(in srgb, var(--danger) 40%, transparent); background: var(--danger-soft); }
.kpi.alert b { color: var(--danger); }
.kpi.good b { color: var(--ok); }

/* ---------- modal ---------- */
.modal-back {
  position: fixed; inset: 0; background: rgba(12, 20, 17, 0.45); z-index: 100;
  display: flex; align-items: flex-start; justify-content: center; overflow-y: auto;
  padding: max(24px, env(safe-area-inset-top, 0px)) 12px 24px;
}
.modal { background: var(--card); border-radius: 16px; width: 100%; max-width: 640px; box-shadow: 0 30px 80px -30px rgba(0, 0, 0, 0.5); }
.modal.wide { max-width: 900px; }
.modal.narrow { max-width: 440px; }
.modal-h { padding: 16px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.modal-b { padding: 18px; }
.modal-f { padding: 14px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; background: var(--soft); border-radius: 0 0 16px 16px; }
.x-btn { border: 0; background: transparent; font-size: 22px; line-height: 1; cursor: pointer; color: var(--mute); width: 36px; height: 36px; border-radius: 8px; }
.x-btn:hover { background: var(--soft); color: var(--ink); }

/* ---------- toast ---------- */
.toasts { position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: min(92vw, 520px); }
.toast { background: var(--ink); color: #fff; padding: 11px 16px; border-radius: 12px; font-size: 14px; box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5); pointer-events: auto; }
.toast.err { background: var(--danger); }
.toast.ok { background: var(--ok); }

/* ---------- empty / misc ---------- */
.empty { text-align: center; color: var(--mute); padding: 30px 16px; }
.empty b { display: block; color: var(--ink); font-size: 16px; margin-bottom: 4px; font-weight: 600; }
.loading { color: var(--mute); padding: 30px; text-align: center; }
.hr { height: 1px; background: var(--line); margin: 6px 0; }
.kbd { font-family: var(--mono); font-size: 11.5px; border: 1px solid var(--line2); border-bottom-width: 2px; border-radius: 5px; padding: 0 5px; color: var(--ink2); background: #fff; }
.banner { border-radius: var(--radius); padding: 12px 14px; font-size: 14px; display: flex; gap: 10px; align-items: flex-start; }
.banner.warn { background: var(--warn-soft); color: #6b3d05; }
.banner.info { background: var(--info-soft); color: #173d93; }
.banner.danger { background: var(--danger-soft); color: #7a160f; }
.banner.ok { background: var(--ok-soft); color: #0c5a2a; }

/* ---------- token & status ---------- */
.tok {
  font-family: var(--mono); font-weight: 600; font-variant-numeric: tabular-nums;
  min-width: 42px; height: 34px; padding: 0 8px; border-radius: 9px; display: inline-grid; place-items: center;
  background: var(--soft); border: 1px solid var(--line); font-size: 16px;
}
.tok.big { font-size: 46px; height: auto; padding: 4px 18px; min-width: 96px; border-radius: 16px; letter-spacing: -0.02em; }
.st { font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 999px; white-space: nowrap; text-transform: uppercase; letter-spacing: 0.03em; }
.st-booked { background: var(--info-soft); color: var(--info); }
.st-waiting { background: var(--warn-soft); color: var(--warn); }
.st-called { background: var(--brand); color: #fff; }
.st-in_room { background: var(--brand-soft); color: var(--brand-dark); }
.st-done { background: var(--soft); color: var(--mute); border: 1px solid var(--line); }
.st-missed { background: var(--danger-soft); color: var(--danger); }
.st-cancelled { background: var(--soft); color: var(--mute); text-decoration: line-through; }

/* ---------- reception board ---------- */
.board { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 14px; align-items: start; }
.qcard { display: flex; flex-direction: column; }
.qhead { padding: 14px 16px 12px; display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; }
.qhead h3 { font-size: 16px; }
.qnow { margin: 0 16px; padding: 12px; border-radius: 12px; background: var(--brand-soft); display: flex; align-items: center; gap: 14px; }
.qnow.idle { background: var(--soft); }
.qnow .tok.big { background: var(--brand); color: #fff; border: 0; font-size: 34px; min-width: 76px; }
.qnow.idle .tok.big { background: #fff; color: var(--mute); border: 1px solid var(--line); }
.qnow .who { min-width: 0; flex: 1; }
.qnow .who b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qactions { display: flex; gap: 8px; padding: 12px 16px; flex-wrap: wrap; }
.qactions .btn.primary { flex: 1; }
.qstats { display: flex; gap: 6px; padding: 0 16px 10px; flex-wrap: wrap; }
.qlist { border-top: 1px solid var(--line); max-height: 460px; overflow-y: auto; }
.qrow { display: flex; align-items: center; gap: 10px; padding: 9px 16px; border-bottom: 1px solid var(--line); cursor: pointer; }
.qrow:hover { background: var(--soft); }
.qrow:last-child { border-bottom: 0; }
.qrow .nm { min-width: 0; flex: 1; }
.qrow .nm b { font-weight: 500; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14.5px; }
.qrow .nm small { color: var(--mute); font-size: 12px; }
.qrow.is-done { opacity: 0.6; }
.qrow.is-now { background: var(--brand-soft); }
.unpaid { color: var(--danger); font-weight: 600; font-size: 12px; }
.paid { color: var(--ok); font-weight: 500; font-size: 12px; }

/* ---------- search results ---------- */
.results { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #fff; }
.res { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-bottom: 1px solid var(--line); cursor: pointer; width: 100%; text-align: left; background: #fff; border-left: 0; border-right: 0; border-top: 0; }
.res:last-child { border-bottom: 0; }
.res:hover, .res.on { background: var(--brand-soft); }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--soft); border: 1px solid var(--line); display: grid; place-items: center; font-weight: 600; color: var(--ink2); flex: 0 0 36px; font-size: 14px; }
.dropdown { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 30; box-shadow: var(--shadow); max-height: 340px; overflow-y: auto; }
.rel { position: relative; }

/* ---------- doctor desk ---------- */
.desk { display: grid; grid-template-columns: 330px minmax(0, 1fr); gap: 16px; align-items: start; }
.desk-side { position: sticky; top: 74px; display: flex; flex-direction: column; gap: 12px; max-height: calc(100vh - 90px); overflow-y: auto; }
@media (max-width: 980px) { .desk { grid-template-columns: 1fr; } .desk-side { position: static; max-height: none; } }
.pt-head { display: flex; gap: 14px; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; }
.pt-head h2 { font-size: 21px; }
.vitals { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.vitals .field span { font-size: 12px; }
.bp { display: flex; align-items: center; gap: 4px; }
.bp .input { padding-left: 6px; padding-right: 6px; text-align: center; }
.rx { display: flex; flex-direction: column; gap: 8px; }
.rx-row { border: 1px solid var(--line); border-radius: 12px; padding: 10px; display: grid; grid-template-columns: 110px minmax(160px, 1.5fr) 100px 130px 150px 80px 36px; gap: 8px; align-items: start; background: #fff; }
.rx-row .urdu { grid-column: 1 / -1; font-size: 14px; color: var(--ink2); padding: 0 4px; line-height: 2; }
@media (max-width: 1200px) { .rx-row { grid-template-columns: 100px minmax(140px, 1fr) 90px 120px; } .rx-row .w2 { grid-column: span 2; } }
@media (max-width: 640px) { .rx-row { grid-template-columns: 1fr 1fr; } .rx-row .w2 { grid-column: span 2; } }
.rx-row.on { border-color: color-mix(in srgb, var(--brand) 55%, var(--line)); }
.dose-quick { grid-column: 1 / -1; display: flex; gap: 5px; flex-wrap: wrap; align-items: center; padding: 0 2px; }
.dose-quick button { border: 1px solid var(--line); background: var(--soft); border-radius: 7px; font-size: 12.5px; padding: 3px 8px; cursor: pointer; font-family: var(--mono); min-height: 28px; }
.dose-quick button:hover { border-color: var(--brand); color: var(--brand-dark); }
.dose-quick button.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.actionbar { position: sticky; bottom: 0; z-index: 10; background: rgba(255, 255, 255, 0.96); backdrop-filter: blur(6px); border-top: 1px solid var(--line); padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px)); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; border-radius: 0 0 var(--radius) var(--radius); }
.hist-item { border: 1px solid var(--line); border-radius: 12px; padding: 12px; background: #fff; }
.hist-item .rxl { font-size: 13.5px; margin: 6px 0 0; padding-left: 18px; }

/* ---------- auth ---------- */
.auth { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; background:
  radial-gradient(1200px 500px at 10% -10%, color-mix(in srgb, var(--brand) 18%, transparent), transparent),
  var(--bg); }
.auth-card { width: 100%; max-width: 440px; }
.auth-card .card-b { padding: 26px; }
.powered { text-align: center; font-size: 12px; color: var(--mute); margin-top: 14px; }
.powered b { color: var(--vf); }

/* ---------- charts ---------- */
.chart { width: 100%; height: auto; display: block; }
.chart text { font-family: var(--font); font-size: 11.5px; fill: var(--mute); font-variant-numeric: tabular-nums; }

@media (max-width: 720px) {
  .userbox .who { display: none; }
  .brand { flex: 1; }
  .brand b { max-width: 60vw; }
  /* tabs move to their own full-width, swipeable row under the clinic name */
  .topbar-in { gap: 10px; flex-wrap: wrap; row-gap: 0; min-height: 54px; }
  .nav { order: 3; flex: 0 0 100%; padding: 0 0 8px; gap: 4px; }
  .nav a { padding: 7px 11px; background: var(--soft); }
  .nav a.on { background: var(--brand); color: #fff; }
  h1 { font-size: 20px; }
  .tok.big { font-size: 36px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
