/* ==========================================================================
   Careivo — signed-in app shell
   Shares the token set in site.css. This file only lays out the product.
   Body class is `portal` (not `app`: the marketing hero mockup owns `.app`).
   ========================================================================== */

body.portal {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  min-height: 100vh;
  background: var(--bg-alt);
  overflow: visible;
}

/* --- Sidebar ------------------------------------------------------------ */

.side {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  background: var(--surface); border-right: 1px solid var(--line);
  padding: 1.25rem 1rem;
}
.side__brand {
  font-family: var(--font-display); font-weight: 900; font-size: 1.25rem;
  letter-spacing: -0.035em; color: var(--ink); padding: .25rem .5rem;
}
.side__role {
  font-family: var(--font-mono); font-size: .6875rem; letter-spacing: .12em;
  text-transform: uppercase; color: var(--ink-3); padding: 0 .5rem; margin: .125rem 0 1.25rem;
}
.side__nav { display: flex; flex-direction: column; gap: .125rem; }
.side__nav a {
  display: flex; align-items: center; gap: .625rem;
  padding: .625rem .75rem; border-radius: 3px;
  font-size: .9375rem; font-weight: 600; color: var(--ink-2);
}
.side__nav a svg { width: 18px; height: 18px; flex-shrink: 0; opacity: .85; }
.side__nav a:hover { background: var(--bg-alt); color: var(--ink); }
.side__nav a.is-active { background: var(--brand-50); color: var(--brand-700); }
.side__nav a .count {
  margin-left: auto; font-family: var(--font-mono); font-size: .6875rem; font-weight: 600;
  background: var(--brand-600); color: #fff; border-radius: 3px; padding: .0625rem .4375rem;
}
.side__user {
  margin-top: auto; padding: .875rem .75rem 0; border-top: 1px solid var(--line);
  font-size: .875rem;
}
.side__user b { display: block; }
.side__user small { display: block; color: var(--ink-3); margin-bottom: .5rem; }
.side__logout {
  font: inherit; font-size: .8125rem; font-weight: 600; color: var(--ink-2);
  background: none; border: 1px solid var(--line); border-radius: 3px; padding: .375rem .75rem; cursor: pointer;
}
.side__logout:hover { border-color: var(--ink-3); color: var(--ink); }

/* --- Main ----------------------------------------------------------------- */

.main { padding: 1.75rem clamp(1.25rem, 3vw, 2.5rem) 3rem; min-width: 0; }
.topbar { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.topbar h1 { font-size: clamp(1.5rem, 2.4vw, 2rem); letter-spacing: -0.03em; }
.topbar p { color: var(--ink-2); margin-top: .25rem; }
.topbar__actions { display: flex; gap: .625rem; flex-wrap: wrap; }

.notice {
  border-radius: var(--r-sm); padding: .8125rem 1rem; margin-bottom: 1rem;
  font-size: .9375rem; border: 1px solid var(--line); background: var(--surface);
}
.notice--warn, .notice--warning { background: var(--amber-lt); border-color: #F5D7B0; color: #7A4A0B; }
.notice--success { background: var(--brand-50);  border-color: var(--brand-200); color: var(--brand-700); }
.notice--error   { background: var(--rose-lt);  border-color: var(--rose); color: var(--rose); }
.notice--info    { background: var(--surface-2); }

/* --- KPI tiles ------------------------------------------------------------ */

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 1.125rem 1.25rem; box-shadow: var(--sh-sm); }
.kpi__label { font-size: .8125rem; color: var(--ink-2); margin-bottom: .375rem; }
.kpi__value { font-family: var(--font-display); font-size: 1.75rem; font-weight: 900; letter-spacing: -0.04em; line-height: 1; font-variant-numeric: tabular-nums; }
.kpi__hint { font-size: .75rem; color: var(--ink-3); margin-top: .375rem; }

/* --- Panels & tables ------------------------------------------------------ */

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--sh-sm); margin-bottom: 1.25rem; overflow: hidden; }
.panel__head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .875rem 1.125rem; border-bottom: 1px solid var(--line); }
.panel__head h2 { font-size: 1.0625rem; letter-spacing: -0.02em; }
.panel__body { padding: 1.125rem; }
.panel__empty { padding: 2rem 1.125rem; text-align: center; color: var(--ink-2); }
.panel__empty b { display: block; color: var(--ink); margin-bottom: .25rem; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem; align-items: start; }

.tbl-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tbl th {
  font-family: var(--font-mono); font-size: .6875rem; letter-spacing: .1em; text-transform: uppercase;
  color: var(--ink-3); font-weight: 500; text-align: left; padding: .625rem 1.125rem;
  border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface-2);
}
.tbl td { padding: .75rem 1.125rem; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover td { background: var(--surface-2); }
.tbl .num { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.tbl .muted { color: var(--ink-3); font-size: .8125rem; }
.tbl a.row-link { color: var(--brand-700); font-weight: 600; }
.tbl .is-best td { background: var(--brand-50); }

.pill {
  display: inline-block; font-family: var(--font-mono); font-size: .6875rem; font-weight: 600;
  letter-spacing: .06em; text-transform: uppercase; padding: .2rem .55rem; border-radius: 3px;
  background: var(--bg-alt); color: var(--ink-2); white-space: nowrap;
}
.pill--placed, .pill--uploaded, .pill--reading   { background: var(--amber-lt); color: var(--amber); }
.pill--accepted, .pill--confirmed, .pill--packed { background: #E0ECFF; color: #1D4ED8; }
.pill--dispatched, .pill--out_for_delivery       { background: #EDE9FE; color: #6D28D9; }
.pill--delivered, .pill--verified                { background: var(--brand-50); color: var(--brand-700); }
.pill--cancelled, .pill--rejected                { background: var(--rose-lt); color: var(--rose); }

/* --- Forms & buttons inside the app --------------------------------------- */

.portal .btn { border-radius: 3px; }
.btn--sm { padding: .5rem .875rem; font-size: .8125rem; }
.btn--danger { background: var(--rose-lt); color: var(--rose); border-color: var(--rose); }
.inline-form { display: inline; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: .875rem; }
.form-stack { display: flex; flex-direction: column; gap: 1rem; max-width: 34rem; }
.searchbar { display: flex; gap: .625rem; }
.searchbar .field-input { flex: 1; }

.qty-inline { display: inline-flex; align-items: center; gap: .25rem; }
.qty-inline input { width: 4.5rem; text-align: center; font-family: var(--font-mono); padding: .375rem .5rem; border: 1px solid var(--line); border-radius: 3px; font: inherit; }

/* --- Timeline (order status) --------------------------------------------- */

.steps-line { display: flex; gap: 0; list-style: none; margin: 0; padding: 0; }
.steps-line li { flex: 1; position: relative; padding-top: 1.125rem; font-size: .8125rem; color: var(--ink-3); text-align: center; }
.steps-line li::before { content: ""; position: absolute; top: .25rem; left: 50%; width: 12px; height: 12px; border-radius: 50%; background: var(--line); transform: translateX(-50%); }
.steps-line li::after { content: ""; position: absolute; top: .55rem; left: 50%; width: 100%; height: 2px; background: var(--line); z-index: -1; }
.steps-line li:last-child::after { display: none; }
.steps-line li.done { color: var(--brand-700); font-weight: 600; }
.steps-line li.done::before, .steps-line li.done::after { background: var(--brand-600); }

/* --- Prescription lines --------------------------------------------------- */

.rxline { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .75rem; padding: .875rem 0; border-bottom: 1px solid var(--line-2); }
.rxline:last-child { border-bottom: 0; }
.rxline b { display: block; }
.rxline small { font-family: var(--font-mono); font-size: .75rem; color: var(--ink-3); }
.conf { font-family: var(--font-mono); font-size: .75rem; font-weight: 600; color: var(--brand-600); }
.conf--low { color: var(--amber); }

/* --- Auth pages ----------------------------------------------------------- */

body.auth { background: var(--bg-alt); display: block; }
.auth__wrap { min-height: 100vh; display: grid; place-items: center; padding: 2rem 1rem; }
.auth__card { width: 100%; max-width: 27rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--sh-lg); padding: 2rem; }
.auth__brand { font-family: var(--font-display); font-weight: 900; font-size: 1.375rem; letter-spacing: -0.035em; margin-bottom: 1.25rem; display: block; color: var(--ink); }
.auth__card h1 { font-size: 1.5rem; margin-bottom: .375rem; }
.auth__lead { color: var(--ink-2); font-size: .9375rem; margin-bottom: 1.25rem; }
.auth__alt { text-align: center; font-size: .875rem; color: var(--ink-2); margin-top: 1.125rem; }
.auth__alt a { color: var(--brand-700); font-weight: 600; }

/* --- Narrow ------------------------------------------------------------- */

@media (max-width: 860px) {
  body.portal { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; border-right: 0; border-bottom: 1px solid var(--line); padding: .75rem 1rem; }
  .side__role { display: none; }
  .side__nav { flex-direction: row; flex-wrap: wrap; gap: .25rem; }
  .side__nav a { padding: .5rem .625rem; font-size: .875rem; }
  .side__user { margin-top: 0; margin-left: auto; padding: 0; border: 0; display: flex; align-items: center; gap: .625rem; }
  .side__user small { display: none; }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  }

/* --- Entry pages: three doors ------------------------------------------- */

.gate { width: 100%; max-width: 62rem; }
.gate h1 { font-size: clamp(1.75rem, 3vw, 2.25rem); margin-bottom: .375rem; }
.gate__cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; margin-top: 1.5rem; }
.gate__card {
  display: flex; flex-direction: column; gap: .5rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 1.5rem; box-shadow: var(--sh-sm); color: var(--ink);
  transition: transform .18s cubic-bezier(.22,1,.36,1), box-shadow .18s ease, border-color .18s ease;
}
.gate__card:hover { transform: translateY(-3px); box-shadow: var(--sh-lg); border-color: var(--brand-200); }
.gate__card b { font-family: var(--font-display); font-size: 1.25rem; letter-spacing: -0.03em; }
.gate__card span { font-size: .9375rem; color: var(--ink-2); }
.gate__card em { font-style: normal; font-weight: 700; color: var(--brand-700); margin-top: auto; padding-top: .5rem; }
.gate__icon { width: 44px; height: 44px; border-radius: 4px; display: grid; place-items: center; background: var(--brand-50); margin-bottom: .25rem; }
.gate__icon svg { width: 22px; height: 22px; color: var(--brand-600); }
.gate__card--patient .gate__icon { background: var(--brand-50); }
.gate__card--pharmacy .gate__icon { background: #EDE7E2; }  .gate__card--pharmacy .gate__icon svg { color: #1F1E1C; }
.gate__card--distributor .gate__icon { background: var(--apricot-lt, #FFEDE5); } .gate__card--distributor .gate__icon svg { color: var(--apricot, #FF8256); }
.gate__card--pharmacy:hover { border-color: #D6CCC4; } .gate__card--distributor:hover { border-color: #FFD2C2; }

.auth__role {
  display: inline-flex; align-items: center; gap: .5rem;
  font-family: var(--font-mono); font-size: .6875rem; letter-spacing: .12em; text-transform: uppercase;
  color: var(--brand-700); background: var(--brand-50); border-radius: 3px; padding: .3rem .75rem .3rem .5rem; margin-bottom: 1rem;
}
.auth__role svg { width: 15px; height: 15px; }
.auth__role--pharmacy { background: #EDE7E2; color: #1F1E1C; }
.auth__role--distributor { background: var(--apricot-lt, #FFEDE5); color: #B4471F; }

@media (max-width: 800px) { .gate__cards { grid-template-columns: minmax(0, 1fr); } }
