/* ============================================================================
   PREMIER RX — PHARMACY OPERATIONS PORTAL
   Design tokens + component primitives
   Direction: clinical-operational · navy structure · royal interaction ·
              medical-green confirmation · compact, data-first density
   Light mode primary. Desktop dispatcher/admin.
   ----------------------------------------------------------------------------
   This file is the source of truth. Rebuild any portal screen using only
   these tokens and the .component classes below.
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Hanken+Grotesk:wght@400;500;600;700;800&family=Geist+Mono:wght@400;500;600&display=swap');

:root {
  /* ---- BRAND : NAVY (structure / chrome / headings) ------------------- */
  --navy-900: #0d2244;   /* app sidebar, deepest ink            */
  --navy-800: #143057;
  --navy-700: #1b3e6c;
  --navy-600: #244f86;
  --navy-100: #e6edf6;   /* navy tint surface                   */

  /* ---- BRAND : SKY / LIGHT BLUE (#00adf0 brand · interactive) -------- */
  --sky-700: #005f88;    /* primary hover / darkest                  */
  --sky-600: #0076a8;    /* primary action · links · accessible blue */
  --sky-500: #00adf0;    /* BRAND light blue — focus, accents, dots  */
  --sky-400: #38c4f5;
  --sky-100: #d4f0fc;    /* selected row / info tint                 */
  --sky-050: #eef9fe;

  /* ---- BRAND : MEDICAL GREEN (#38b54a brand · confirmation) --------- */
  --green-800: #166528;
  --green-700: #1f8538;  /* accessible green text / success button   */
  --green-600: #2f9d40;  /* fills (map nodes, route pins)            */
  --green-500: #38b54a;  /* BRAND green — accents, online ring        */
  --green-100: #e3f6e6;

  /* ---- NEUTRALS : cool slate ----------------------------------------- */
  --ink:       #0e1726;  /* primary text                        */
  --slate-700: #334155;  /* strong secondary text               */
  --slate-600: #475569;
  --slate-500: #64748b;  /* secondary text / icons              */
  --slate-400: #94a3b8;  /* muted / placeholder                 */
  --slate-300: #cbd5e1;  /* strong border                       */
  --slate-200: #e2e8f0;  /* default border / divider            */
  --slate-150: #eaeef4;
  --slate-100: #f1f5f9;  /* subtle fill / hover                 */
  --slate-50:  #f7f9fc;  /* page background                     */
  --white:     #ffffff;
  --surface:   #ffffff;  /* card / panel background             */

  /* ---- SEMANTIC ------------------------------------------------------- */
  --success:   var(--green-700);  --success-bg: var(--green-100);
  --info:      var(--sky-600);    --info-bg:    var(--sky-100);
  --warning:   #c2780a;           --warning-bg: #fdf0d5;
  --danger:    #d6443a;           --danger-bg:  #fde4e2;

  /* ---- STATUS PALETTE : delivery queue lifecycle --------------------- */
  --st-new:        #3257a8;  --st-new-bg:        #e7edfa;  /* New / received     */
  --st-prep:       #b06a07;  --st-prep-bg:       #fbecd2;  /* In prep / filling  */
  --st-ready:      #0c7a86;  --st-ready-bg:      #d8f1f3;  /* Ready for route    */
  --st-out:        #0076a8;  --st-out-bg:        #d4f0fc;  /* Out for delivery   */
  --st-delivered:  #1f8538;  --st-delivered-bg:  #def0e1;  /* Delivered          */
  --st-exception:  #c23b32;  --st-exception-bg:  #fbe1df;  /* Exception / failed */
  --st-hold:       #5b6677;  --st-hold-bg:       #eceff3;  /* On hold            */

  /* pharmacy flags */
  --flag-cold:    #0c7a86;  --flag-cold-bg:    #d8f1f3;   /* refrigerated   */
  --flag-control: #8a3ec2;  --flag-control-bg: #f0e4fb;   /* controlled rx  */
  --flag-stat:    #d6443a;  --flag-stat-bg:    #fde4e2;   /* STAT / urgent  */

  /* ---- TYPE ----------------------------------------------------------- */
  --font-sans: 'Hanken Grotesk', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'Geist Mono', ui-monospace, 'SFMono-Regular', monospace;

  --fs-display: 28px;  --lh-display: 34px;
  --fs-h1: 22px;       --lh-h1: 28px;
  --fs-h2: 18px;       --lh-h2: 24px;
  --fs-h3: 15px;       --lh-h3: 20px;
  --fs-body: 14px;     --lh-body: 20px;   /* base for dense ops UI */
  --fs-sm: 13px;       --lh-sm: 18px;
  --fs-xs: 12px;       --lh-xs: 16px;
  --fs-micro: 11px;    --lh-micro: 14px;  /* uppercase labels      */

  /* ---- SPACE (4px base grid) ----------------------------------------- */
  --sp-1: 2px;  --sp-2: 4px;  --sp-3: 6px;  --sp-4: 8px;  --sp-5: 12px;
  --sp-6: 16px; --sp-7: 20px; --sp-8: 24px; --sp-9: 32px; --sp-10: 40px;
  --sp-11: 48px; --sp-12: 64px;

  /* ---- RADIUS --------------------------------------------------------- */
  --r-sm: 4px; --r-md: 6px; --r-lg: 8px; --r-xl: 12px; --r-2xl: 16px; --r-pill: 999px;

  /* ---- ELEVATION ------------------------------------------------------ */
  --sh-xs: 0 1px 2px rgba(13, 34, 68, .06);
  --sh-sm: 0 1px 2px rgba(13, 34, 68, .06), 0 1px 3px rgba(13, 34, 68, .08);
  --sh-md: 0 2px 4px rgba(13, 34, 68, .06), 0 4px 12px rgba(13, 34, 68, .08);
  --sh-lg: 0 8px 24px rgba(13, 34, 68, .12), 0 2px 6px rgba(13, 34, 68, .08);
  --sh-pop: 0 12px 32px rgba(13, 34, 68, .18);
  --ring: 0 0 0 3px rgba(0, 173, 240, .32);

  /* ---- LAYOUT --------------------------------------------------------- */
  --sidebar-w: 232px;
  --topbar-h: 56px;
  --row-h: 44px;       /* compact table row */
}

/* ============================================================================
   BASE
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  color: var(--ink);
  background: var(--slate-50);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.mono { font-family: var(--font-mono); font-feature-settings: "tnum" 1; }
.tnum { font-variant-numeric: tabular-nums; }

/* type helpers */
.t-display { font-size: var(--fs-display); line-height: var(--lh-display); font-weight: 800; letter-spacing: -.02em; }
.t-h1 { font-size: var(--fs-h1); line-height: var(--lh-h1); font-weight: 700; letter-spacing: -.01em; }
.t-h2 { font-size: var(--fs-h2); line-height: var(--lh-h2); font-weight: 700; letter-spacing: -.01em; }
.t-h3 { font-size: var(--fs-h3); line-height: var(--lh-h3); font-weight: 600; }
.t-body { font-size: var(--fs-body); line-height: var(--lh-body); }
.t-sm { font-size: var(--fs-sm); line-height: var(--lh-sm); }
.t-xs { font-size: var(--fs-xs); line-height: var(--lh-xs); }
.t-label {
  font-size: var(--fs-micro); line-height: var(--lh-micro);
  font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--slate-500);
}
.t-muted { color: var(--slate-500); }
.t-faint { color: var(--slate-400); }

/* ============================================================================
   BUTTONS
   ========================================================================== */
.btn {
  --btn-h: 32px;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-3);
  height: var(--btn-h); padding: 0 var(--sp-5);
  font-family: var(--font-sans); font-size: var(--fs-sm); font-weight: 600;
  line-height: 1; border-radius: var(--r-md); border: 1px solid transparent;
  cursor: pointer; white-space: nowrap; user-select: none;
  transition: background .12s ease, border-color .12s ease, box-shadow .12s ease, color .12s ease;
}
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn svg { width: 15px; height: 15px; }

.btn-primary { background: var(--sky-600); color: #fff; }
.btn-primary:hover { background: var(--sky-700); }

.btn-secondary { background: var(--white); color: var(--navy-800); border-color: var(--slate-300); }
.btn-secondary:hover { background: var(--slate-100); border-color: var(--slate-400); }

.btn-ghost { background: transparent; color: var(--slate-600); }
.btn-ghost:hover { background: var(--slate-100); color: var(--navy-800); }

.btn-success { background: var(--green-700); color: #fff; }
.btn-success:hover { background: var(--green-800); }

.btn-danger { background: var(--white); color: var(--danger); border-color: #efc3bf; }
.btn-danger:hover { background: var(--danger-bg); }

.btn-sm { --btn-h: 26px; font-size: var(--fs-xs); padding: 0 var(--sp-4); }
.btn-lg { --btn-h: 38px; font-size: var(--fs-body); padding: 0 var(--sp-6); }
.btn-icon { width: var(--btn-h); padding: 0; }
.btn[disabled] { opacity: .5; pointer-events: none; }

/* ============================================================================
   FIELDS
   ========================================================================== */
.field {
  display: inline-flex; align-items: center; gap: var(--sp-3);
  height: 32px; padding: 0 var(--sp-4);
  background: var(--white); border: 1px solid var(--slate-300); border-radius: var(--r-md);
  font-size: var(--fs-sm); color: var(--ink); width: 100%;
  transition: border-color .12s ease, box-shadow .12s ease;
}
.field:focus-within { border-color: var(--sky-500); box-shadow: var(--ring); }
.field svg { width: 15px; height: 15px; color: var(--slate-400); flex: none; }
.field input, .field select {
  border: none; outline: none; background: transparent; width: 100%;
  font-family: var(--font-sans); font-size: var(--fs-sm); color: var(--ink);
}
.field input::placeholder { color: var(--slate-400); }
.field-label { display: block; margin-bottom: var(--sp-3); }

/* ============================================================================
   BADGES / STATUS PILLS
   ========================================================================== */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  height: 20px; padding: 0 8px;
  font-size: var(--fs-xs); font-weight: 600; line-height: 1;
  border-radius: var(--r-sm); white-space: nowrap;
  background: var(--slate-100); color: var(--slate-600);
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge svg { width: 12px; height: 12px; }

/* status — solid dot + tinted bg */
.badge-new        { background: var(--st-new-bg);        color: var(--st-new); }
.badge-prep       { background: var(--st-prep-bg);       color: var(--st-prep); }
.badge-ready      { background: var(--st-ready-bg);      color: var(--st-ready); }
.badge-out        { background: var(--st-out-bg);        color: var(--st-out); }
.badge-delivered  { background: var(--st-delivered-bg);  color: var(--st-delivered); }
.badge-exception  { background: var(--st-exception-bg);  color: var(--st-exception); }
.badge-hold       { background: var(--st-hold-bg);       color: var(--st-hold); }

/* pharmacy flags — outlined chips */
.flag {
  display: inline-flex; align-items: center; gap: 4px;
  height: 20px; padding: 0 7px; border-radius: var(--r-sm);
  font-size: var(--fs-xs); font-weight: 600; line-height: 1; border: 1px solid;
}
.flag svg { width: 12px; height: 12px; }
.flag-cold    { color: var(--flag-cold);    background: var(--flag-cold-bg);    border-color: #b8e2e6; }
.flag-control { color: var(--flag-control); background: var(--flag-control-bg); border-color: #e0c8f4; }
.flag-stat    { color: var(--flag-stat);    background: var(--flag-stat-bg);    border-color: #f3c3bf; }

/* priority dot */
.pri { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-xs); font-weight: 600; }
.pri::before { content: ""; width: 8px; height: 8px; border-radius: 50%; }
.pri-routine::before { background: var(--slate-400); }
.pri-urgent::before  { background: var(--warning); }
.pri-stat::before    { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-bg); }

/* ============================================================================
   CARDS / PANELS / STATS
   ========================================================================== */
.card {
  background: var(--surface); border: 1px solid var(--slate-200);
  border-radius: var(--r-lg); box-shadow: var(--sh-xs);
}
.card-pad { padding: var(--sp-6); }

.stat {
  background: var(--surface); border: 1px solid var(--slate-200);
  border-radius: var(--r-lg); padding: var(--sp-5) var(--sp-6); box-shadow: var(--sh-xs);
}
.stat .stat-label { font-size: var(--fs-xs); font-weight: 600; color: var(--slate-500); text-transform: uppercase; letter-spacing: .05em; }
.stat .stat-value { font-family: var(--font-mono); font-size: 26px; line-height: 1.1; font-weight: 600; color: var(--navy-800); margin-top: 6px; font-variant-numeric: tabular-nums; }
.stat .stat-delta { font-size: var(--fs-xs); font-weight: 600; margin-top: 4px; display: inline-flex; align-items: center; gap: 3px; }
.delta-up { color: var(--green-700); }
.delta-down { color: var(--danger); }

/* ============================================================================
   TABLE (delivery queue)
   ========================================================================== */
.tbl { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.tbl thead th {
  position: sticky; top: 0; background: var(--slate-50);
  text-align: left; font-size: var(--fs-micro); font-weight: 700; letter-spacing: .05em;
  text-transform: uppercase; color: var(--slate-500);
  padding: 9px var(--sp-5); border-bottom: 1px solid var(--slate-200); white-space: nowrap;
}
.tbl tbody td { padding: 0 var(--sp-5); height: var(--row-h); border-bottom: 1px solid var(--slate-150); vertical-align: middle; }
.tbl tbody tr { transition: background .1s ease; }
.tbl tbody tr:hover { background: var(--sky-050); }
.tbl tbody tr.is-selected { background: var(--sky-100); box-shadow: inset 2px 0 0 var(--sky-600); }
.tbl .cell-id { font-family: var(--font-mono); font-weight: 500; color: var(--navy-700); }
.tbl .cell-strong { font-weight: 600; color: var(--ink); }

/* ============================================================================
   AVATAR / DRIVER CHIP
   ========================================================================== */
.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--navy-100); color: var(--navy-700);
  font-size: var(--fs-xs); font-weight: 700; flex: none;
}
.avatar-sm { width: 22px; height: 22px; font-size: 10px; }
.avatar.is-online { box-shadow: 0 0 0 2px var(--white), 0 0 0 4px var(--green-500); }

.driver-chip {
  display: inline-flex; align-items: center; gap: var(--sp-4);
  padding: 5px 10px 5px 5px; background: var(--white);
  border: 1px solid var(--slate-200); border-radius: var(--r-pill);
}

/* ============================================================================
   SEGMENTED CONTROL / TABS
   ========================================================================== */
.seg { display: inline-flex; padding: 3px; background: var(--slate-100); border-radius: var(--r-md); gap: 2px; }
.seg button {
  border: none; background: transparent; cursor: pointer;
  height: 26px; padding: 0 12px; border-radius: var(--r-sm);
  font-family: var(--font-sans); font-size: var(--fs-xs); font-weight: 600; color: var(--slate-500);
}
.seg button.is-active { background: var(--white); color: var(--navy-800); box-shadow: var(--sh-xs); }

.tabs { display: flex; gap: var(--sp-6); border-bottom: 1px solid var(--slate-200); }
.tabs a {
  padding: 10px 0; font-size: var(--fs-sm); font-weight: 600; color: var(--slate-500);
  text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs a.is-active { color: var(--sky-600); border-bottom-color: var(--sky-600); }

/* ============================================================================
   TOAST / NOTIFICATION
   ========================================================================== */
.toast {
  display: flex; gap: var(--sp-5); align-items: flex-start;
  width: 340px; padding: var(--sp-5); background: var(--white);
  border: 1px solid var(--slate-200); border-left: 3px solid var(--sky-600);
  border-radius: var(--r-md); box-shadow: var(--sh-lg);
}
.toast-success { border-left-color: var(--green-600); }
.toast-danger  { border-left-color: var(--danger); }
.toast-warning { border-left-color: var(--warning); }
.toast-ico { width: 28px; height: 28px; border-radius: var(--r-md); display: grid; place-items: center; flex: none; }
.toast-ico svg { width: 16px; height: 16px; }

.notif {
  display: flex; gap: var(--sp-5); padding: var(--sp-5);
  border-bottom: 1px solid var(--slate-150);
}
.notif.is-unread { background: var(--sky-050); }
.notif-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--sky-600); margin-top: 6px; flex: none; }

/* ============================================================================
   CHAT
   ========================================================================== */
.bubble { max-width: 78%; padding: 8px 12px; border-radius: 14px; font-size: var(--fs-sm); line-height: 18px; }
.bubble-in  { background: var(--slate-100); color: var(--ink); border-bottom-left-radius: 4px; align-self: flex-start; }
.bubble-out { background: var(--sky-600); color: #fff; border-bottom-right-radius: 4px; align-self: flex-end; }
.bubble-time { font-size: 10px; color: var(--slate-400); margin-top: 3px; }

/* ============================================================================
   APP SHELL (sidebar + topbar)
   ========================================================================== */
.nav-item {
  display: flex; align-items: center; gap: var(--sp-5);
  height: 36px; padding: 0 var(--sp-5); border-radius: var(--r-md);
  color: rgba(255,255,255,.72); font-size: var(--fs-sm); font-weight: 500;
  text-decoration: none; cursor: pointer;
}
.nav-item svg { width: 17px; height: 17px; flex: none; }
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.is-active { background: var(--sky-600); color: #fff; font-weight: 600; }
.nav-item .nav-badge {
  margin-left: auto; background: rgba(255,255,255,.16); color: #fff;
  font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: var(--r-pill);
}
.nav-item.is-active .nav-badge { background: rgba(255,255,255,.22); }

/* ============================================================================
   MAP / ROUTE ITEM
   ========================================================================== */
.route-stop {
  display: flex; gap: var(--sp-5); align-items: flex-start;
  padding: var(--sp-4) 0; position: relative;
}
.route-stop .node {
  width: 22px; height: 22px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-size: 11px; font-weight: 700;
  background: var(--white); border: 2px solid var(--sky-600); color: var(--sky-600);
  z-index: 1;
}
.route-stop.done .node { background: var(--green-600); border-color: var(--green-600); color: #fff; }
.route-line { position: absolute; left: 10px; top: 22px; bottom: -8px; width: 2px; background: var(--slate-200); }

/* generic helpers */
.row { display: flex; align-items: center; }
.col { display: flex; flex-direction: column; }
.gap-2 { gap: var(--sp-2); } .gap-3 { gap: var(--sp-3); } .gap-4 { gap: var(--sp-4); }
.gap-5 { gap: var(--sp-5); } .gap-6 { gap: var(--sp-6); } .gap-8 { gap: var(--sp-8); }
.grow { flex: 1; } .wrap { flex-wrap: wrap; }
