/* ============================================================
   Gardenia Bariatric Care Module — Design System (theme.css)
   Direction: "Clinical Precision" — premium HIS product UI.
   Single source of truth. Screens use ONLY these classes.
   ============================================================ */

/* ---------- Tokens ---------- */
:root {
  /* Gardenia Medical Centre brand: green #017A4A + navy #10314F + petal blue */
  --teal:        #017A4A;   /* brand green (primary accent) */
  --teal-deep:   #10314F;   /* navy (sidebar / dark surfaces) */
  --teal-bright: #0E9E62;   /* bright green (gradients) */
  --teal-ink:    #0B5D39;   /* deep green (text-on-light accent) */
  --mint:        #F3F7F8;   /* page bg */
  --aqua:        #E4F1EA;   /* soft green surface tint */
  --aqua-2:      #EDF4F0;
  --surface:     #FFFFFF;
  --ink:         #14303F;   /* navy-ink primary text */
  --muted:       #5E7788;   /* slate secondary text */
  --faint:       #93A7B2;   /* tertiary */
  --line:        #DEE7EC;   /* borders */
  --line-soft:   #EAF1F0;

  --coral:       #E2603F;   /* alert / danger */
  --coral-soft:  #FBEAE4;
  --amber:       #E8A13A;   /* warning */
  --amber-soft:  #FBF0DC;
  --green:       #2E9E6B;   /* success */
  --green-soft:  #E1F1E9;
  --blue:        #3E7CB1;   /* info */
  --blue-soft:   #E5EEF5;

  /* chart series */
  --c1: #017A4A; --c2: #5E93C4; --c3: #E8A13A; --c4: #E2603F; --c5: #7C97A6;
  --navy: #1E4D7B; --petal-blue: #5E93C4;

  --radius:    14px;
  --radius-sm: 9px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 2px rgba(20,48,63,.05), 0 1px 3px rgba(20,48,63,.05);
  --shadow:    0 6px 22px -8px rgba(11,93,57,.18), 0 2px 6px rgba(20,48,63,.05);
  --shadow-lg: 0 24px 60px -20px rgba(11,93,57,.30);
  --sans: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Arial, sans-serif;

  --sidebar-w: 250px;
  --topbar-h: 64px;
}

/* ---------- Reset / base ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--mint);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-size: 14px;
  line-height: 1.5;
}
h1,h2,h3,h4,h5 { margin: 0; font-weight: 700; letter-spacing: -.01em; color: var(--ink); }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
.tnum { font-variant-numeric: tabular-nums; }

/* ---------- App shell ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

.sidebar {
  background: var(--teal-deep);
  color: #CBDBE6;
  padding: 20px 16px;
  display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 6px 8px 22px; }
.brand-mark {
  width: 42px; height: 42px; flex: none;
  background: url("gardenia-mark.png") center / contain no-repeat;
  display: grid; place-items: center;
  color: transparent; font-size: 0;
}
/* larger logo lockup variant (index / cover) */
.brand-mark.lg { width: 58px; height: 58px; background-size: contain; }
.brand-name { color: #fff; font-weight: 700; font-size: 15px; line-height: 1.15; letter-spacing: -.01em; }
.brand-sub { color: #8AA6B8; font-size: 11px; font-weight: 500; letter-spacing: .02em; }

.nav-label { color: #6FA19D; font-size: 10.5px; font-weight: 700; letter-spacing: .11em; text-transform: uppercase; padding: 16px 10px 7px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 11px; border-radius: 10px; color: #B4C6D2;
  font-size: 13.5px; font-weight: 500; cursor: pointer; transition: .15s;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: var(--teal); color: #fff; font-weight: 600; box-shadow: var(--shadow-sm); }
.nav-item .ic { width: 18px; height: 18px; flex: none; opacity: .95; }
.nav-item .tag { margin-left: auto; background: var(--coral); color: #fff; font-size: 10.5px; font-weight: 700; border-radius: 20px; padding: 1px 7px; }
.sidebar-foot { margin-top: auto; padding-top: 16px; border-top: 1px solid rgba(255,255,255,.08); }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 8px 8px; border-radius: 10px; }
.user-chip:hover { background: rgba(255,255,255,.06); }

.main { min-width: 0; display: flex; flex-direction: column; }

/* ---------- Topbar ---------- */
.topbar {
  height: var(--topbar-h); background: rgba(255,255,255,.85); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 16px; padding: 0 28px;
  position: sticky; top: 0; z-index: 20;
}
.page-title { font-size: 18px; font-weight: 700; }
.page-sub { color: var(--muted); font-size: 12.5px; }
.topbar-spacer { flex: 1; }
.search {
  display: flex; align-items: center; gap: 8px; background: var(--mint);
  border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; color: var(--muted);
  min-width: 220px; font-size: 13px;
}
.icon-btn { width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); display: grid; place-items: center; color: var(--muted); cursor: pointer; position: relative; }
.icon-btn:hover { border-color: var(--teal); color: var(--teal); }
.icon-btn .dot { position: absolute; top: 7px; right: 8px; width: 7px; height: 7px; border-radius: 50%; background: var(--coral); border: 2px solid var(--surface); }

.content { padding: 26px 28px 40px; }

/* ---------- Journey spine (SIGNATURE) ---------- */
.journey { display: flex; align-items: stretch; gap: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 4px; box-shadow: var(--shadow-sm); overflow: hidden; }
.journey-stage { flex: 1; display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 10px; position: relative; min-width: 0; }
.journey-stage + .journey-stage::before { content: ""; position: absolute; left: -1px; top: 22%; height: 56%; width: 1px; background: var(--line); }
.journey-stage .jnum { width: 26px; height: 26px; flex: none; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; border: 1.5px solid var(--line); color: var(--faint); background: var(--surface); }
.journey-stage .jt { min-width: 0; }
.journey-stage .jt b { display: block; font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.journey-stage .jt span { font-size: 11px; color: var(--faint); }
.journey-stage.done .jnum { background: var(--teal); border-color: var(--teal); color: #fff; }
.journey-stage.done .jt b { color: var(--ink); }
.journey-stage.current { background: var(--aqua); }
.journey-stage.current::before, .journey-stage.current + .journey-stage::before { background: transparent; }
.journey-stage.current .jnum { background: var(--surface); border-color: var(--teal); color: var(--teal); box-shadow: 0 0 0 4px rgba(1,122,74,.14); }
.journey-stage.current .jt b { color: var(--teal-ink); }

/* ---------- Grid helpers ---------- */
.grid { display: grid; gap: 18px; }
.g-2 { grid-template-columns: repeat(2,1fr); }
.g-3 { grid-template-columns: repeat(3,1fr); }
.g-4 { grid-template-columns: repeat(4,1fr); }
.row { display: flex; gap: 18px; }
.stack { display: flex; flex-direction: column; gap: 18px; }
.mt-18 { margin-top: 18px; }
.mt-24 { margin-top: 24px; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-pad { padding: 18px 20px; }
.card-head { display: flex; align-items: center; gap: 12px; padding: 15px 20px; border-bottom: 1px solid var(--line-soft); }
.card-head h3 { font-size: 14.5px; }
.card-head .sub { color: var(--muted); font-size: 12px; }
.card-head .spacer { flex: 1; }
.section-eyebrow { font-size: 11px; font-weight: 700; letter-spacing: .11em; text-transform: uppercase; color: var(--teal); margin-bottom: 5px; }

/* ---------- Stat tile ---------- */
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow-sm); position: relative; overflow: hidden; }
.stat .lbl { color: var(--muted); font-size: 12px; font-weight: 500; display: flex; align-items: center; gap: 7px; }
.stat .val { font-size: 27px; font-weight: 800; letter-spacing: -.02em; margin-top: 8px; line-height: 1; }
.stat .val small { font-size: 14px; font-weight: 600; color: var(--muted); }
.stat .delta { margin-top: 9px; font-size: 12px; font-weight: 600; display: inline-flex; align-items: center; gap: 4px; }
.stat .delta.up { color: var(--green); }
.stat .delta.down { color: var(--coral); }
.stat .delta.flat { color: var(--muted); }
.stat .accent { position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--teal); }
.stat.a-coral .accent { background: var(--coral); }
.stat.a-amber .accent { background: var(--amber); }
.stat.a-green .accent { background: var(--green); }

/* ---------- Badges / pills ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; padding: 3px 9px; border-radius: 20px; line-height: 1.4; white-space: nowrap; }
.b-teal { background: var(--aqua); color: var(--teal-ink); }
.b-green { background: var(--green-soft); color: #1E6E48; }
.b-amber { background: var(--amber-soft); color: #97671A; }
.b-coral { background: var(--coral-soft); color: #A83B22; }
.b-blue { background: var(--blue-soft); color: #2A5578; }
.b-gray { background: #EEF2F1; color: var(--muted); }
.dotb { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }

.pill-tabs { display: inline-flex; gap: 4px; background: var(--aqua-2); padding: 4px; border-radius: 11px; }
.pill-tabs button { border: 0; background: transparent; color: var(--muted); font: inherit; font-size: 12.5px; font-weight: 600; padding: 6px 14px; border-radius: 8px; cursor: pointer; }
.pill-tabs button.active { background: var(--surface); color: var(--teal-ink); box-shadow: var(--shadow-sm); }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: inherit; font-size: 13px; font-weight: 600; padding: 9px 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; transition: .15s; white-space: nowrap; }
.btn:hover { border-color: var(--teal); color: var(--teal); }
.btn-primary { background: var(--teal); border-color: var(--teal); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--teal-ink); border-color: var(--teal-ink); color: #fff; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn-sm { padding: 6px 11px; font-size: 12px; }

/* ---------- Tables ---------- */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; color: var(--muted); font-weight: 600; font-size: 11.5px; letter-spacing: .03em; text-transform: uppercase; padding: 11px 16px; border-bottom: 1px solid var(--line); }
.table td { padding: 13px 16px; border-bottom: 1px solid var(--line-soft); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--mint); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: linear-gradient(140deg, var(--teal-bright), var(--teal)); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 12.5px; flex: none; }
.avatar.sm { width: 28px; height: 28px; font-size: 11px; }
.patient-cell { display: flex; align-items: center; gap: 11px; }
.patient-cell b { font-weight: 600; font-size: 13px; display: block; }
.patient-cell span { color: var(--muted); font-size: 11.5px; display: block; }

/* ---------- Progress / bars ---------- */
.pbar { height: 8px; background: var(--aqua-2); border-radius: 20px; overflow: hidden; }
.pbar > i { display: block; height: 100%; background: var(--teal); border-radius: 20px; }
.pbar.amber > i { background: var(--amber); }
.pbar.coral > i { background: var(--coral); }
.pbar.green > i { background: var(--green); }

/* ring */
.ring { --p: 70; --col: var(--teal); width: 96px; height: 96px; border-radius: 50%;
  background: conic-gradient(var(--col) calc(var(--p)*1%), var(--aqua-2) 0);
  display: grid; place-items: center; }
.ring::before { content: ""; position: absolute; width: 74px; height: 74px; border-radius: 50%; background: var(--surface); }
.ring .ring-v { position: relative; text-align: center; }
.ring .ring-v b { font-size: 20px; font-weight: 800; }
.ring .ring-v span { display: block; font-size: 10.5px; color: var(--muted); }

/* ---------- Bar chart (CSS) ---------- */
.barchart { display: flex; align-items: flex-end; gap: 10px; height: 150px; padding-top: 8px; }
.barchart .bar { flex: 1; background: linear-gradient(180deg, var(--teal-bright), var(--teal)); border-radius: 6px 6px 0 0; position: relative; min-height: 4px; }
.barchart .bar.soft { background: var(--aqua); }
.barchart .bar span { position: absolute; top: -18px; left: 0; right: 0; text-align: center; font-size: 10.5px; font-weight: 700; color: var(--teal-ink); }
.barchart .bar em { position: absolute; bottom: -20px; left: 0; right: 0; text-align: center; font-size: 10.5px; color: var(--muted); font-style: normal; }

/* Line/area via SVG uses .spark {stroke,fill} inline */
.legend { display: flex; gap: 16px; flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }

/* ---------- Alerts / timeline ---------- */
.alert-row { display: flex; gap: 12px; padding: 12px 14px; border-radius: 11px; border: 1px solid var(--line); align-items: flex-start; }
.alert-row.warn { background: var(--amber-soft); border-color: #F1DDB2; }
.alert-row.crit { background: var(--coral-soft); border-color: #F4CFC4; }
.alert-row .ai { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; flex: none; }
.alert-row.warn .ai { background: var(--amber); color: #fff; }
.alert-row.crit .ai { background: var(--coral); color: #fff; }
.alert-row b { font-size: 13px; }
.alert-row p { font-size: 12px; color: var(--muted); margin-top: 2px; }

.timeline { position: relative; padding-left: 26px; }
.timeline::before { content: ""; position: absolute; left: 8px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.tl-item { position: relative; padding: 0 0 18px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-item::before { content: ""; position: absolute; left: -22px; top: 3px; width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 2px solid var(--teal); }
.tl-item.done::before { background: var(--teal); }
.tl-item .tt { font-size: 13px; font-weight: 600; }
.tl-item .td { font-size: 12px; color: var(--muted); }
.tl-item .tm { font-size: 11px; color: var(--faint); margin-top: 2px; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; font-weight: 600; color: var(--ink); }
.field .hint { font-size: 11px; color: var(--faint); }
.input { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font: inherit; font-size: 13px; background: var(--surface); color: var(--ink); width: 100%; }
.input:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(1,122,74,.12); }
.input::placeholder { color: var(--faint); }
select.input { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235E7788' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { border: 0; border-right: 1px solid var(--line); background: var(--surface); font: inherit; font-size: 12.5px; font-weight: 600; color: var(--muted); padding: 9px 15px; cursor: pointer; }
.seg button:last-child { border-right: 0; }
.seg button.active { background: var(--teal); color: #fff; }
.chip-choice { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line); border-radius: 20px; padding: 7px 13px; font-size: 12.5px; font-weight: 500; cursor: pointer; color: var(--muted); }
.chip-choice.on { background: var(--aqua); border-color: var(--teal); color: var(--teal-ink); font-weight: 600; }

.step-rail { display: flex; flex-direction: column; gap: 2px; }
.step-rail .sr { display: flex; align-items: center; gap: 11px; padding: 11px 12px; border-radius: 10px; font-size: 13px; color: var(--muted); cursor: pointer; }
.step-rail .sr .n { width: 24px; height: 24px; border-radius: 50%; border: 1.5px solid var(--line); display: grid; place-items: center; font-size: 11.5px; font-weight: 700; flex: none; }
.step-rail .sr.done { color: var(--ink); }
.step-rail .sr.done .n { background: var(--green); border-color: var(--green); color: #fff; }
.step-rail .sr.current { background: var(--aqua); color: var(--teal-ink); font-weight: 600; }
.step-rail .sr.current .n { background: var(--teal); border-color: var(--teal); color: #fff; }

/* ---------- Misc ---------- */
.divider { height: 1px; background: var(--line-soft); margin: 4px 0; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line-soft); font-size: 13px; }
.kv:last-child { border-bottom: 0; }
.kv .k { color: var(--muted); }
.kv .v { font-weight: 600; }
.muted { color: var(--muted); }
.tiny { font-size: 11.5px; }
.big-num { font-size: 34px; font-weight: 800; letter-spacing: -.02em; }

/* ---------- Phone frame (mobile screens) ---------- */
.phones { display: flex; gap: 30px; flex-wrap: wrap; justify-content: center; align-items: flex-start; padding: 20px; }
.phone { width: 320px; height: 680px; background: #0A2233; border-radius: 42px; padding: 11px; box-shadow: var(--shadow-lg); flex: none; position: relative; }
.phone-screen { width: 100%; height: 100%; background: var(--mint); border-radius: 32px; overflow: hidden; position: relative; display: flex; flex-direction: column; }
.phone-notch { position: absolute; top: 11px; left: 50%; transform: translateX(-50%); width: 120px; height: 26px; background: #0A2233; border-radius: 0 0 16px 16px; z-index: 5; }
.m-status { display: flex; justify-content: space-between; align-items: center; padding: 12px 20px 6px; font-size: 12px; font-weight: 600; color: var(--ink); }
.m-head { padding: 6px 18px 14px; background: var(--surface); border-bottom: 1px solid var(--line); }
.m-body { flex: 1; overflow-y: auto; padding: 16px 16px 84px; }
.m-title { font-size: 19px; font-weight: 800; letter-spacing: -.02em; }
.m-card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 15px; box-shadow: var(--shadow-sm); }
.m-tabbar { position: absolute; bottom: 0; left: 0; right: 0; background: var(--surface); border-top: 1px solid var(--line); display: flex; justify-content: space-around; padding: 10px 8px 16px; }
.m-tab { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 10px; color: var(--faint); font-weight: 600; }
.m-tab.on { color: var(--teal); }
.m-fab { position: absolute; bottom: 78px; right: 18px; width: 52px; height: 52px; border-radius: 50%; background: var(--teal); color: #fff; display: grid; place-items: center; box-shadow: var(--shadow); z-index: 6; }
.phone-label { text-align: center; margin-top: 14px; font-size: 12.5px; font-weight: 600; color: var(--muted); }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .g-4 { grid-template-columns: repeat(2,1fr); }
  .g-3 { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .g-2 { grid-template-columns: 1fr; }
  .journey { flex-wrap: wrap; }
  .journey-stage { flex: 1 1 40%; }
}
