/* PharmaBI — shared design system (self-contained, offline; shadcn/21st.dev-inspired) */
:root{
  --bg:#f8fafc; --surface:#ffffff; --surface-2:#f1f5f9;
  --border:#e5e7eb; --border-strong:#cbd5e1;
  --text:#0f172a; --muted:#64748b; --muted-2:#94a3b8;
  --primary:#4f46e5; --primary-600:#4338ca; --primary-tint:#eef2ff;
  --green:#16a34a; --green-tint:#dcfce7; --red:#dc2626; --red-tint:#fee2e2;
  --amber:#d97706; --amber-tint:#fef3c7; --sky:#0284c7; --purple:#7c3aed; --teal:#0d9488;
  --r:14px; --r-sm:9px; --r-pill:999px;
  --sh:0 1px 2px rgba(15,23,42,.04), 0 2px 6px rgba(15,23,42,.05);
  --sh-md:0 4px 14px rgba(15,23,42,.08);
  --fs:14px;
}
*{ box-sizing:border-box; }
html{ -webkit-text-size-adjust:100%; }
body{ margin:0; font-family:system-ui,-apple-system,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;
  font-size:var(--fs); color:var(--text); background:var(--bg); line-height:1.45; }

/* App bar */
.nav{ position:sticky; top:0; z-index:40; display:flex; align-items:center; gap:6px;
  padding:0 22px; height:58px; background:rgba(255,255,255,.85); backdrop-filter:saturate(180%) blur(8px);
  border-bottom:1px solid var(--border); }
.nav .brand{ font-weight:800; letter-spacing:-.02em; font-size:1.05rem; margin-right:18px;
  background:linear-gradient(90deg,var(--primary),#7c3aed); -webkit-background-clip:text; background-clip:text; color:transparent; }
.nav a{ color:var(--muted); text-decoration:none; font-size:.88rem; font-weight:500; padding:7px 13px; border-radius:var(--r-pill); transition:.15s; }
.nav a:hover{ color:var(--text); background:var(--surface-2); }
.nav a.active{ color:var(--primary-600); background:var(--primary-tint); font-weight:600; }
.nav .upd{ margin-left:auto; color:var(--muted-2); font-size:.78rem; }

.wrap{ padding:26px 26px 60px; max-width:1500px; margin:0 auto; }
h1{ font-size:1.5rem; font-weight:700; letter-spacing:-.02em; margin:0 0 20px; }
h2{ font-size:.98rem; font-weight:650; letter-spacing:-.01em; margin:0 0 14px; display:flex; align-items:center; gap:8px; }

/* Cards */
.card{ background:var(--surface); border:1px solid var(--border); border-radius:var(--r);
  box-shadow:var(--sh); padding:18px; transition:box-shadow .18s, transform .18s; min-width:0; }
/* let grid/flex children shrink below their content so wide charts scroll INSIDE the card */
.grid>*,.g-2>*,.g-2e>*,.g-3>*,.grid2>*,.grid2b>*,.kpis>*{ min-width:0; }
.card:hover{ box-shadow:var(--sh-md); }

/* Filters */
.filters{ display:flex; gap:14px; align-items:flex-end; flex-wrap:wrap; margin-bottom:20px; }
.filters label{ display:block; font-size:.68rem; font-weight:600; text-transform:uppercase; letter-spacing:.06em; color:var(--muted); margin-bottom:6px; }
select,input[type=date]{ padding:8px 11px; border:1px solid var(--border-strong); border-radius:var(--r-sm);
  font-size:.88rem; color:var(--text); background:var(--surface); outline:none; transition:.15s; }
select:focus,input[type=date]:focus{ border-color:var(--primary); box-shadow:0 0 0 3px var(--primary-tint); }
button{ background:var(--primary); color:#fff; border:0; border-radius:var(--r-sm); padding:9px 18px;
  font-size:.88rem; font-weight:600; cursor:pointer; transition:.15s; }
button:hover{ background:var(--primary-600); }

/* KPI cards */
.kpis{ display:grid; grid-template-columns:repeat(auto-fit,minmax(140px,1fr)); gap:14px; margin-bottom:20px; }
.kpi{ padding:16px 18px; }
.kpi .val{ font-size:1.5rem; font-weight:750; letter-spacing:-.02em; }
.kpi .lbl{ font-size:.68rem; font-weight:600; text-transform:uppercase; letter-spacing:.05em; color:var(--muted); margin-top:4px; }
.kpi .delta{ font-size:.75rem; font-weight:700; margin-top:2px; }
.up{ color:var(--green); } .down{ color:var(--red); }

/* Grids */
.grid{ display:grid; gap:16px; margin-bottom:16px; }
.g-2{ grid-template-columns:1.5fr 1fr; } .g-2e{ grid-template-columns:1fr 1fr; } .g-3{ grid-template-columns:1fr 1fr 1fr; }
/* purchase-page grid vocabulary */
.grid2{ display:grid; gap:16px; margin-bottom:16px; grid-template-columns:1.5fr 1fr; }
.grid2b{ display:grid; gap:16px; margin-bottom:16px; grid-template-columns:1fr 1.3fr; }
@media(max-width:1000px){ .g-2,.g-2e,.g-3,.grid2,.grid2b{ grid-template-columns:1fr; } }

/* Tables */
table{ width:100%; border-collapse:separate; border-spacing:0; font-size:.85rem; }
th,td{ text-align:left; padding:9px 10px; border-bottom:1px solid var(--border); }
th{ color:var(--muted); font-weight:600; font-size:.7rem; text-transform:uppercase; letter-spacing:.05em; background:var(--surface); }
tbody tr{ transition:background .12s; }
tbody tr:hover{ background:var(--surface-2); }
td.r,th.r{ text-align:right; font-variant-numeric:tabular-nums; }
.scroll{ max-height:340px; overflow:auto; border-radius:var(--r-sm); }
.scroll thead th{ position:sticky; top:0; z-index:2; box-shadow:inset 0 -1px 0 var(--border); }

/* Bars */
.bar,.bar-row{ display:flex; align-items:center; gap:10px; margin:7px 0; font-size:.83rem; }
.bar .nm,.bar-row .nm{ width:130px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; color:var(--text); }
.bar .track,.bar-row .track{ flex:1; background:var(--surface-2); border-radius:var(--r-pill); height:16px; overflow:hidden; }
.bar .fill,.bar-row .fill{ height:16px; border-radius:var(--r-pill); background:linear-gradient(90deg,var(--primary),#7c3aed); }
.bar .amt,.bar-row .amt{ width:92px; text-align:right; color:var(--muted); font-variant-numeric:tabular-nums; }
.kpi .val.neg{ color:var(--red); }
.small{ font-size:.8rem; color:var(--muted); }

/* Segmented toggle */
.tog{ margin-left:auto; display:inline-flex; background:var(--surface-2); padding:3px; border-radius:var(--r-pill); }
.tog button{ background:transparent; color:var(--muted); padding:4px 12px; font-size:.78rem; font-weight:600; border-radius:var(--r-pill); }
.tog button:hover{ color:var(--text); }
.tog button.on{ background:var(--surface); color:var(--primary-600); box-shadow:var(--sh); }

/* Pills / badges */
.pill,.badge{ padding:3px 10px; border-radius:var(--r-pill); font-size:.72rem; font-weight:600; display:inline-block; }
.pill-dead{ background:var(--red-tint); color:var(--red); } .pill-ok{ background:var(--surface-2); color:var(--muted); }
.badge{ color:#fff; }
.b-out{ background:var(--red); } .b-min{ background:var(--amber); } .b-re{ background:var(--primary); }

.muted{ color:var(--muted); font-size:.8rem; font-weight:400; }
svg text{ font-size:10px; fill:var(--muted); }

/* Movement modal (purchase page) */
#moveWrap{ position:fixed; inset:0; background:rgba(15,23,42,.45); z-index:50; backdrop-filter:blur(2px); }
#moveWrap > div{ background:var(--surface); border-radius:var(--r); box-shadow:var(--sh-md); }
.msum{ display:flex; gap:14px; margin-bottom:14px; flex-wrap:wrap; }
.msum .box{ flex:1; min-width:120px; background:var(--surface-2); border-radius:var(--r-sm); padding:12px 14px; }
.msum .box .n{ font-size:1.35rem; font-weight:750; } .msum .box .t{ font-size:.68rem; font-weight:600; text-transform:uppercase; letter-spacing:.05em; color:var(--muted); margin-top:2px; }
.mrow{ padding:10px 0; border-bottom:1px solid var(--border); }
.mrow .per{ font-weight:650; font-size:.85rem; margin-bottom:6px; }
.mline{ display:flex; align-items:center; gap:10px; margin:4px 0; font-size:.82rem; }
.mline .tag{ width:74px; color:var(--muted); } .mline .val{ width:52px; text-align:right; font-weight:650; }
.verdict-line{ margin-top:14px; padding:11px 14px; border-radius:var(--r-sm); background:var(--amber-tint); color:#92400e; font-size:.86rem; font-weight:500; }

/*───────────────────────────────────────────────────────────────────────────
  Responsive — tablets and phones
───────────────────────────────────────────────────────────────────────────*/
/* Tablet: give charts/side-by-side panels a single column earlier. */
@media(max-width:820px){
  .wrap{ padding:20px 16px 52px; }
  .tog{ margin-left:0; }
}

/* Phone */
@media(max-width:640px){
  :root{ --fs:15px; }                 /* slightly larger base text for readability */
  .wrap{ padding:14px 12px 44px; }
  h1{ font-size:1.25rem; margin-bottom:14px; }

  /* Nav becomes a horizontally-scrollable strip so all links stay reachable. */
  .nav{ padding:0 10px; gap:2px; height:52px; overflow-x:auto; overflow-y:hidden;
        flex-wrap:nowrap; -webkit-overflow-scrolling:touch; scrollbar-width:none; }
  .nav::-webkit-scrollbar{ display:none; }
  .nav a{ padding:6px 10px; font-size:.84rem; white-space:nowrap; flex:0 0 auto; }
  .nav .brand{ margin-right:8px; flex:0 0 auto; }
  .nav .upd{ display:none; }          /* hide "updated" text on tiny screens */

  /* Filters stack two-up and inputs fill their cell for easy tapping. */
  .filters{ gap:10px; }
  .filters > div{ flex:1 1 46%; }
  .filters select, .filters input, select, input[type=date], input[type=text]{ width:100%; }
  .filters button{ width:100%; }

  /* Cards a touch tighter. */
  .card{ padding:14px; }

  /* KPI cards: 2 per row on phones. */
  .kpis{ grid-template-columns:repeat(2,1fr); gap:10px; }
  .kpi .val{ font-size:1.25rem; }

  /* Any wide table scrolls horizontally instead of breaking the layout. */
  .card > table, .scroll > table, table{ display:block; overflow-x:auto;
        -webkit-overflow-scrolling:touch; white-space:nowrap; }
  th, td{ padding:8px 9px; }
}
