/* ============================================================================
   PPSO-E Admin — "Booster" themed design system
   Recreated look & feel: Poppins type, blue primary, soft glow shadows,
   flat white cards, filled grey inputs. Light + dark mode via [data-theme].
   ========================================================================== */

:root {
  /* Brand / primary */
  --primary:      #4c7cf3;
  --primary-600:  #346bf1;
  --primary-700:  #2a5fe0;
  --primary-soft: #dbe5fd;

  /* Semantic */
  --success: #2bcd72;
  --danger:  #ff4b5b;
  --warning: #fac751;
  --info:    #52c4ca;
  --secondary: #949ca9;

  /* extra accents for variety */
  --violet: #8b5cf6;
  --amber:  #fac751;
  --rose:   #ff6b8a;
  --teal:   #52c4ca;
  --green:  #2bcd72;
  --blue:   #4c7cf3;
  --lime:   #2bcd72;

  /* Surfaces */
  --bg:         #f9fafc;
  --surface:    #ffffff;
  --surface-2:  #f0f1f4;
  --surface-3:  #e8eaf0;
  --border:     #e1e4e9;
  --border-2:   #d7dbe2;

  /* Text */
  --heading:    #313131;
  --text:       #555555;
  --text-muted: #777777;
  --text-soft:  #949ca9;

  /* Status soft backgrounds */
  --success-bg:#e2f8ec; --danger-bg:#ffe5e8; --info-bg:#e2f5f6; --warning-bg:#fef6e0;

  --radius:    7px;
  --radius-sm: 5px;
  --radius-btn: 3px;
  --shadow-sm: 0 0 20px 0 rgba(200,200,200,.18);
  --shadow:    0 0 30px 0 rgba(200,200,200,.22);
  --shadow-lg: 0 10px 40px 0 rgba(140,150,170,.28);

  --sidebar-w: 250px;
  --topbar-h: 64px;
  --font: "Poppins", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

[data-theme="dark"] {
  --primary-soft:#1e2a45;
  --bg:        #1a1d27;
  --surface:   #22262f;
  --surface-2: #2a2f3a;
  --surface-3: #333947;
  --border:    #323743;
  --border-2:  #3c4250;
  --heading:   #eef0f4;
  --text:      #c2c7d0;
  --text-muted:#9aa1ad;
  --text-soft: #6f7785;
  --success-bg:#15311f; --danger-bg:#3a1a1f; --info-bg:#13302f; --warning-bg:#33290f;
  --shadow-sm: 0 0 20px 0 rgba(0,0,0,.35);
  --shadow:    0 0 30px 0 rgba(0,0,0,.4);
  --shadow-lg: 0 10px 40px 0 rgba(0,0,0,.55);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-600); }
h1,h2,h3 { margin: 0; font-weight: 600; color: var(--heading); }

/* ── Layout ────────────────────────────────────────────────────────────── */
.layout { display: flex; min-height: 100vh; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.content { flex: 1; padding: 1.6rem 1.75rem; max-width: 1320px; width: 100%; margin: 0 auto; }

/* ── Sidebar ───────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; z-index: 40;
}
.brand { display: flex; align-items: center; gap: .65rem; padding: 0 1.25rem; height: var(--topbar-h); border-bottom: 1px solid var(--border); }
.brand-mark {
  width: 36px; height: 36px; border-radius: 8px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--primary), var(--primary-700));
  color: #fff; font-weight: 700; font-size: 1.15rem;
  display: grid; place-items: center; box-shadow: 0 4px 12px rgba(76,124,243,.4);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-name { font-weight: 600; font-size: 1rem; color: var(--heading); }
.brand-sub { font-size: .7rem; color: var(--text-soft); }

.nav { flex: 1; overflow-y: auto; padding: .5rem .65rem 1rem; }
.nav-section { font-size: .68rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-soft); padding: 1rem .7rem .4rem; }
.nav-link {
  display: flex; align-items: center; gap: .75rem;
  padding: .62rem .7rem; border-radius: var(--radius-sm);
  color: var(--text-muted); font-weight: 500; font-size: .9rem;
  margin-bottom: 2px; transition: background .15s, color .15s;
}
.nav-link:hover { background: var(--surface-2); color: var(--heading); }
.nav-link.active { background: var(--primary); color: #fff; box-shadow: 0 4px 12px rgba(76,124,243,.35); }
.nav-link.active:hover { color: #fff; }
.nav-ico { display: grid; place-items: center; width: 20px; height: 20px; flex-shrink: 0; }
.nav-ico svg { width: 18px; height: 18px; }

.sidebar-foot { border-top: 1px solid var(--border); padding: .75rem; }
.user-chip { display: flex; align-items: center; gap: .65rem; padding: .35rem; border-radius: var(--radius-sm); }
.uc-text { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.uc-name { font-weight: 600; font-size: .88rem; color: var(--heading); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.uc-role { font-size: .72rem; color: var(--text-soft); }

.avatar {
  width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, var(--primary), var(--primary-700));
  color: #fff; font-weight: 600; font-size: .82rem;
  display: grid; place-items: center;
}
.avatar.sm { width: 30px; height: 30px; font-size: .7rem; }

/* ── Topbar ────────────────────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 1rem;
  padding: 0 1.75rem; height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 10px 0 rgba(200,200,200,.12);
}
[data-theme="dark"] .topbar { box-shadow: none; }
.topbar-title { font-weight: 600; font-size: 1.05rem; color: var(--heading); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: .4rem; }
.topbar-user { display: flex; align-items: center; gap: .5rem; padding: .25rem .7rem .25rem .3rem; border-radius: 99px; background: var(--surface-2); }
.tu-name { font-size: .85rem; font-weight: 500; color: var(--heading); }
.hamburger { display: none; }

/* ── Buttons ───────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: .45rem;
  padding: .5rem 1.1rem; border-radius: var(--radius-btn);
  font-size: .85rem; font-weight: 500; font-family: inherit;
  border: 1px solid transparent; cursor: pointer;
  transition: background .15s, box-shadow .15s, border-color .15s, color .15s; white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-600); color: #fff; }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-2); }
.btn-secondary:hover { background: var(--surface-2); color: var(--heading); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(.93); color: #fff; }
.btn-sm { padding: .32rem .75rem; font-size: .8rem; }
.btn-block { width: 100%; justify-content: center; }

.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px;
  border-radius: 50%; border: 1px solid transparent; background: transparent;
  color: var(--text-muted); cursor: pointer; transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--primary); }
.icon-btn.danger:hover { background: var(--danger-bg); color: var(--danger); }
.col-actions .icon-btn { border-radius: var(--radius-sm); }
form .icon-btn { padding: 0; }

/* ── Page header ───────────────────────────────────────────────────────── */
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.4rem; flex-wrap: wrap; }
.page-header h1 { font-size: 1.4rem; font-weight: 600; }
.ph-left p { margin: .2rem 0 0; color: var(--text-muted); font-size: .88rem; }
.ph-actions { display: flex; gap: .5rem; }
.crumbs { font-size: .78rem; color: var(--text-soft); margin-bottom: .3rem; }
.crumbs span { margin: 0 .35rem; }

/* ── Cards ─────────────────────────────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden; }
.card + .card, .mt-3 { margin-top: 1.25rem; }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1.05rem 1.35rem; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.card-header h2 { font-size: 1rem; font-weight: 600; }
.card-body { padding: 1.35rem; }
.card-footer { padding: .9rem 1.35rem; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: .6rem; align-items: center; }

/* ── Stat cards (Booster style: colored icon tile + big number) ────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 1.25rem; margin-bottom: 1.4rem; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.3rem 1.4rem; box-shadow: var(--shadow-sm);
  display: grid; grid-template-columns: 1fr auto;
  grid-template-areas: "value icon" "label icon"; align-items: center; column-gap: 1rem;
  transition: box-shadow .18s, transform .18s;
}
a.stat-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.stat-icon { grid-area: icon; width: 52px; height: 52px; border-radius: 12px; display: grid; place-items: center; background: color-mix(in srgb, var(--c, var(--primary)) 15%, transparent); color: var(--c, var(--primary)); }
.stat-icon svg { width: 24px; height: 24px; }
.stat-value { grid-area: value; font-size: 1.7rem; font-weight: 600; color: var(--heading); line-height: 1.1; }
.stat-label { grid-area: label; color: var(--text-muted); font-size: .85rem; margin-top: .15rem; }
.color-teal{--c:var(--teal)} .color-rose{--c:var(--rose)} .color-blue{--c:var(--blue)}
.color-violet{--c:var(--violet)} .color-amber{--c:var(--amber)} .color-lime{--c:var(--lime)} .color-green{--c:var(--green)}

/* ── Tables ────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.table th { text-align: left; font-weight: 600; font-size: .76rem; text-transform: uppercase; letter-spacing: .03em; color: var(--text-soft); padding: .85rem 1.35rem; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface-2); }
.table td { padding: .8rem 1.35rem; border-bottom: 1px solid var(--border); vertical-align: middle; color: var(--text); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: var(--surface-2); }
.table strong { color: var(--heading); font-weight: 600; }
.col-actions { width: 1%; white-space: nowrap; text-align: right; }
.col-actions .icon-btn { width: 32px; height: 32px; }

/* grouped table (e.g. drug support grouped by patient) */
.table-grouped tbody tr:hover { background: transparent; }
.table-grouped tr.grp-start:not(:first-child) td { border-top: 2px solid var(--border-2); }
.table-grouped td.grp-name { background: var(--surface-2); vertical-align: top; border-right: 1px solid var(--border); }
.table-grouped tbody tr:hover td:not(.grp-name) { background: var(--surface-2); }

/* clickable patient picker (drug support) */
.chip-pick { display: flex; flex-wrap: wrap; gap: .65rem; }
.pick-card { display: flex; align-items: center; gap: .6rem; padding: .55rem .85rem .55rem .55rem; border: 1px solid var(--border); border-radius: 99px; background: var(--surface); transition: border-color .15s, box-shadow .15s, background .15s; }
.pick-card:hover { border-color: var(--primary); box-shadow: 0 2px 10px rgba(76,124,243,.18); text-decoration: none; }
.pick-card.active { background: var(--primary-soft); border-color: var(--primary); }
.pick-meta { display: flex; flex-direction: column; line-height: 1.2; }
.pick-meta strong { color: var(--heading); }
.record-count-pill {
  display: inline-block;
  min-width: 1.4rem;
  padding: 0 .35rem;
  background: var(--primary);
  color: #fff;
  border-radius: 999px;
  font-weight: 700;
  font-size: .72rem;
  text-align: center;
  margin-right: .25rem;
  vertical-align: 1px;
}
.pick-card.active .record-count-pill { background: var(--primary-700); }

/* option groups (radio / checkbox) + material list with quantities */
.opt-group { display: flex; flex-wrap: wrap; gap: .5rem .6rem; padding: .15rem 0; }
.opt-check { display: inline-flex; align-items: center; gap: .45rem; font-size: .87rem; background: var(--surface-2); padding: .42rem .75rem; border-radius: var(--radius-sm); border: 1px solid var(--border); cursor: pointer; user-select: none; }
.opt-check input { accent-color: var(--primary); margin: 0; }
.opt-check:hover { border-color: var(--primary); }
.material-list { display: flex; flex-direction: column; gap: .5rem; }
.material-row { display: flex; align-items: center; gap: .6rem; }
.material-row .opt-check { min-width: 150px; }
.qty-input { width: 110px; padding: .42rem .6rem; border: 1px solid var(--border-2); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font-family: inherit; font-size: .85rem; }
.qty-input:focus { outline: none; border-color: var(--primary); }

/* searchable select (combobox) */
.card:has(.combo) { overflow: visible; }   /* let the dropdown panel escape the card */
.combo { position: relative; }
.combo-input { width: 100%; padding: .6rem .8rem; border: 1px solid transparent; border-radius: var(--radius-sm); background: var(--surface-2); color: var(--text); font-family: inherit; font-size: .87rem; }
.combo-input:focus { outline: none; background: var(--primary-soft); border-color: var(--primary); box-shadow: 0 0 0 3px rgba(76,124,243,.12); }
.combo-panel { position: absolute; z-index: 40; left: 0; right: 0; top: calc(100% + 5px); background: var(--surface); border: 1px solid var(--border-2); border-radius: var(--radius-sm); box-shadow: var(--shadow); max-height: 300px; overflow-y: auto; display: none; }
.combo.open .combo-panel { display: block; }
.combo-opt { display: flex; align-items: center; gap: .6rem; width: 100%; text-align: left; padding: .55rem .75rem; background: none; border: 0; border-bottom: 1px solid var(--border); cursor: pointer; font-family: inherit; color: var(--text); }
.combo-opt:last-child { border-bottom: 0; }
.combo-opt:hover, .combo-opt.active { background: var(--primary-soft); }
.combo-opt[hidden] { display: none; }
.combo-empty { padding: .75rem; color: var(--text-soft); font-size: .85rem; text-align: center; }

/* ── Badges ────────────────────────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; padding: .25rem .65rem; border-radius: 4px; font-size: .74rem; font-weight: 500; line-height: 1.4; }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-danger  { background: var(--danger-bg);  color: var(--danger); }
.badge-info    { background: var(--info-bg);    color: var(--info); }
.badge-muted   { background: var(--surface-3);  color: var(--text-muted); }
.badge-neutral { background: var(--primary-soft); color: var(--primary-600); }
[data-theme="dark"] .badge-neutral { color: #8fb0f8; }

/* ── Tabs (sub-type nav) ───────────────────────────────────────────────── */
.tabs { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.tab { padding: .45rem .9rem; border-radius: var(--radius-btn); font-size: .83rem; font-weight: 500; color: var(--text-muted); background: var(--surface); border: 1px solid var(--border); transition: all .15s; }
.tab:hover { background: var(--surface-2); color: var(--heading); }
.tab.active { background: var(--primary); color: #fff; border-color: var(--primary); box-shadow: 0 4px 12px rgba(76,124,243,.3); }

/* ── Search ────────────────────────────────────────────────────────────── */
.search-form { display: flex; gap: .5rem; align-items: center; width: 100%; max-width: 440px; }
.search-box { position: relative; flex: 1; display: flex; align-items: center; }
.search-box svg { position: absolute; left: .8rem; color: var(--text-soft); pointer-events: none; }
.search-box input { width: 100%; padding: .55rem .8rem .55rem 2.2rem; border: 1px solid transparent; border-radius: var(--radius-sm); background: var(--surface-2); color: var(--text); font-size: .86rem; font-family: inherit; }
.search-box input:focus { outline: none; background: var(--primary-soft); border-color: var(--primary); }

/* ── Forms ─────────────────────────────────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.05rem 1.15rem; }
.field { display: flex; flex-direction: column; gap: .4rem; min-width: 0; }
.field.span-2, .field.span-full { grid-column: 1 / -1; }
.field label { font-size: .82rem; font-weight: 500; color: var(--heading); }
.field .req { color: var(--danger); }
.field input, .field select, .field textarea {
  width: 100%; padding: .6rem .8rem; font-family: inherit; font-size: .87rem;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--text); transition: border-color .15s, background .15s, box-shadow .15s;
}
.field textarea { resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; background: var(--primary-soft); border-color: var(--primary); box-shadow: 0 0 0 3px rgba(76,124,243,.12); }
[data-theme="dark"] .field input:focus, [data-theme="dark"] .field select:focus, [data-theme="dark"] .field textarea:focus { background: var(--surface-3); }
/* dual date input (manual text + calendar picker) */
.date-field { position: relative; display: block; }
.date-field .date-text { width: 100%; padding-right: 2.5rem; }
.date-pick-btn { position: absolute; right: 1px; top: 1px; bottom: 1px; width: 2.4rem; display: grid; place-items: center; background: transparent; border: 0; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; color: var(--text-soft); cursor: pointer; }
.date-pick-btn:hover { color: var(--primary); background: var(--surface-3); }
.date-native { position: absolute; right: 1.1rem; bottom: 0; width: 1px; height: 1px; padding: 0; margin: 0; border: 0; opacity: 0; pointer-events: none; }

.more-section { margin-top: 1.3rem; border-top: 1px dashed var(--border-2); padding-top: .4rem; }
.more-section summary { cursor: pointer; font-weight: 600; color: var(--primary); padding: .65rem 0; font-size: .88rem; user-select: none; }
.more-section summary:hover { color: var(--primary-600); }

.form-section-title { grid-column: 1 / -1; font-size: .78rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--primary); padding-top: .7rem; border-top: 1px solid var(--border); margin-top: .5rem; }
.form-section-title:first-child { border-top: 0; padding-top: 0; margin-top: 0; }

/* ── Sectioned stepper form ────────────────────────────────────────────── */
.form-card { max-width: 1040px; }
.form-layout { display: grid; grid-template-columns: 230px 1fr; gap: 1.75rem; align-items: start; }
.form-nav { display: flex; flex-direction: column; gap: .25rem; position: sticky; top: calc(var(--topbar-h) + 1rem); }
.form-nav-item { display: flex; align-items: center; gap: .65rem; text-align: left; width: 100%; padding: .6rem .75rem; border-radius: var(--radius-sm); border: 1px solid transparent; background: transparent; font-family: inherit; font-size: .85rem; font-weight: 500; color: var(--text-muted); cursor: pointer; transition: background .15s, color .15s; }
.form-nav-item:hover { background: var(--surface-2); color: var(--heading); }
.form-nav-item.active { background: var(--primary-soft); color: var(--primary-600); }
[data-theme="dark"] .form-nav-item.active { color: #8fb0f8; }
.fn-num { width: 23px; height: 23px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); font-size: .72rem; font-weight: 600; flex-shrink: 0; }
.form-nav-item.active .fn-num { background: var(--primary); color: #fff; }
.form-step { display: none; }
.form-step.active { display: block; animation: stepIn .22s ease; }
.form-step-title { font-size: 1.08rem; font-weight: 600; margin-bottom: 1.2rem; color: var(--heading); }
.form-steps .form-grid { max-width: 640px; }
@keyframes stepIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
.form-footer { justify-content: space-between; }
.form-footer-right { display: flex; gap: .6rem; align-items: center; margin-left: auto; }

/* ── Password show/hide toggle ─────────────────────────────────────────── */
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 2.7rem; }
.pw-toggle { position: absolute; right: .45rem; top: 50%; transform: translateY(-50%); background: none; border: 0; padding: .35rem; cursor: pointer; color: var(--text-soft); display: grid; place-items: center; border-radius: 6px; }
.pw-toggle:hover { color: var(--primary); }
.pw-toggle .ico-off { display: none; }
.pw-toggle.on .ico-on { display: none; }
.pw-toggle.on .ico-off { display: block; }

/* ── Detail (view) grid ────────────────────────────────────────────────── */
.detail-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .1rem 1.6rem; margin: 0; }
.detail-item { padding: .75rem 0; border-bottom: 1px solid var(--border); }
.detail-item.span-full { grid-column: 1 / -1; }
.detail-item dt { font-size: .74rem; font-weight: 600; text-transform: uppercase; letter-spacing: .02em; color: var(--text-soft); margin: 0 0 .25rem; }
.detail-item dd { margin: 0; font-size: .92rem; color: var(--text); }

/* ── Alerts ────────────────────────────────────────────────────────────── */
.alert { display: flex; align-items: flex-start; gap: .6rem; padding: .85rem 1.1rem; border-radius: var(--radius-sm); margin-bottom: 1.2rem; font-size: .88rem; border: 1px solid transparent; }
.alert ul { margin: .4rem 0 0; padding-left: 1.1rem; }
.alert-success { background: var(--success-bg); color: var(--success); border-color: color-mix(in srgb,var(--success) 25%,transparent); }
.alert-error, .alert-danger { background: var(--danger-bg); color: var(--danger); border-color: color-mix(in srgb,var(--danger) 25%,transparent); }
.alert-info { background: var(--info-bg); color: var(--info); }
.alert-close { margin-left: auto; background: none; border: 0; font-size: 1.2rem; line-height: 1; cursor: pointer; color: inherit; opacity: .6; }
.alert-close:hover { opacity: 1; }

/* ── Empty state ───────────────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 3rem 1rem; }
.empty-icon { font-size: 2.6rem; margin-bottom: .5rem; opacity: .8; }
.empty-state h3 { font-size: 1.05rem; margin-bottom: .3rem; color: var(--heading); }
.empty-state p { color: var(--text-muted); margin: 0; }

/* ── Pagination ────────────────────────────────────────────────────────── */
.pagination { display: flex; gap: .3rem; align-items: center; }
.page-link { padding: .4rem .75rem; border-radius: var(--radius-sm); border: 1px solid var(--border-2); font-size: .84rem; font-weight: 500; color: var(--text-muted); background: var(--surface); }
.page-link:hover { background: var(--surface-2); color: var(--heading); }
.page-link.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-link.disabled { opacity: .45; pointer-events: none; }

/* ── Quick access (dashboard) ──────────────────────────────────────────── */
.quick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: .9rem; }
.quick-card { display: flex; flex-direction: column; align-items: center; gap: .6rem; padding: 1.2rem .6rem; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); transition: transform .15s, box-shadow .15s; }
.quick-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.qc-icon { width: 48px; height: 48px; border-radius: 12px; display: grid; place-items: center; font-size: 1.45rem; }
.qc-label { font-size: .82rem; font-weight: 500; color: var(--heading); text-align: center; }

/* ── Dashboard sections & charts ───────────────────────────────────────── */
.section-title { font-size: .95rem; font-weight: 600; color: var(--heading); margin: 1.8rem 0 .95rem; display: flex; align-items: center; gap: .7rem; }
.section-title .st-line { flex: 1; height: 1px; background: var(--border); }
.metric-grid { display: grid; gap: 1.25rem; align-items: start; }
.metric-grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.metric-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 1080px) { .metric-grid.cols-3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 760px) { .metric-grid.cols-2, .metric-grid.cols-3 { grid-template-columns: 1fr; } }

/* mini bar rows */
.mbar { margin-bottom: .9rem; }
.mbar:last-child { margin-bottom: 0; }
.mbar-head { display: flex; justify-content: space-between; align-items: baseline; font-size: .83rem; margin-bottom: .32rem; color: var(--text); }
.mbar-head .mbar-val { font-weight: 600; color: var(--heading); }
.mbar.zero .mbar-head { color: var(--text-soft); }

/* donut (conic-gradient) */
.donut-wrap { display: flex; align-items: center; gap: 1.4rem; flex-wrap: wrap; justify-content: center; }
.donut { --val: 0; width: 132px; height: 132px; border-radius: 50%; display: grid; place-items: center; position: relative; flex-shrink: 0; background: conic-gradient(var(--donut-color, var(--primary)) calc(var(--val) * 1%), var(--surface-2) 0); }
.donut::before { content: ""; position: absolute; width: 66%; height: 66%; background: var(--surface); border-radius: 50%; }
.donut-label { position: relative; text-align: center; line-height: 1.2; }
.donut-pct { font-size: 1.5rem; font-weight: 600; color: var(--heading); }
.donut-cap { font-size: .72rem; color: var(--text-muted); }
.legend { display: flex; flex-direction: column; gap: .6rem; }
.legend-item { display: flex; align-items: center; gap: .55rem; font-size: .84rem; color: var(--text); }
.legend-dot { width: 11px; height: 11px; border-radius: 3px; flex-shrink: 0; }
.legend-num { margin-left: auto; font-weight: 600; color: var(--heading); padding-left: 1rem; }

/* report filter card */
.report-filter { padding: 1.35rem; }
.rf-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .9rem; margin-bottom: 1.1rem; }
.rf-field { display: flex; flex-direction: column; gap: .35rem; min-width: 0; }
.rf-field label { font-size: .78rem; font-weight: 600; color: var(--text-muted); }
.rf-field select, .rf-field .search-box input { padding: .55rem .7rem; border: 1px solid transparent; border-radius: var(--radius-sm); background: var(--surface-2); color: var(--text); font-family: inherit; font-size: .86rem; }
.rf-field select:focus { outline: none; background: var(--primary-soft); border-color: var(--primary); }
.rf-actions { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }

/* active filter chips */
.filter-chips { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: .4rem; padding: .28rem .7rem; border-radius: 99px; background: var(--primary-soft); color: var(--primary-600); font-size: .8rem; font-weight: 500; }
[data-theme="dark"] .chip { color: #8fb0f8; }

/* clickable legend rows */
a.legend-item { transition: color .15s; }
a.legend-item:hover { color: var(--primary); }
a.legend-item:hover .legend-num { color: var(--primary); }

/* vertical column chart */
a.col-item { text-decoration: none; cursor: pointer; }
a.col-item:hover .col-bar { filter: brightness(1.08); box-shadow: 0 -3px 14px rgba(76,124,243,.35); }
a.col-item:hover .col-x   { color: var(--primary); }
a.col-item:hover .col-val { border-color: var(--primary); color: var(--primary); }

/* Scroll horizontally when there are many years — guarantees each bar
   gets enough room for its year label and value pill, no overlap. */
.col-chart {
  display: flex; align-items: flex-end; gap: .85rem;
  height: 210px;
  padding: 2rem .25rem .35rem;
  overflow-x: auto;
  overflow-y: visible;
  scrollbar-width: thin;
}
.col-chart::-webkit-scrollbar { height: 8px; }
.col-chart::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 4px; }

.col-item {
  flex: 0 0 46px;           /* fixed width per column */
  display: flex; flex-direction: column; align-items: center;
  height: 100%; justify-content: flex-end;
  gap: .55rem;
}
.col-bar {
  width: 100%; max-width: 46px; min-height: 8px;
  border-radius: 6px 6px 0 0; position: relative;
  transition: height .35s ease;
  background: linear-gradient(var(--primary), var(--primary-600));
  box-shadow: 0 1px 0 rgba(0,0,0,.04) inset;
}
.col-bar.growth { background: linear-gradient(var(--success), #1fae5e); }

/* Value pill sits just above the bar — full breathing room thanks to the
   chart's top padding, no clipping by the parent card's overflow:hidden. */
.col-bar .col-val {
  position: absolute;
  bottom: 100%;
  left: 50%; transform: translateX(-50%);
  margin-bottom: .4rem;
  font-size: .85rem;
  font-weight: 700;
  color: var(--heading);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: .15rem .55rem;
  white-space: nowrap;
  box-shadow: 0 2px 4px rgba(15,23,42,.08);
  letter-spacing: .01em;
}

/* Year labels under each bar — strong and readable */
.col-x {
  font-size: .9rem;
  font-weight: 700;
  color: var(--heading);
  white-space: nowrap;
  letter-spacing: .02em;
  font-variant-numeric: tabular-nums;
}

/* ── Misc utilities ────────────────────────────────────────────────────── */
.text-muted { color: var(--text-muted); }
.text-soft  { color: var(--text-soft); }
.text-sm { font-size: .82rem; }
.flex { display: flex; }
.justify-between { justify-content: space-between; }
.mt-2 { margin-top: .8rem; } .mt-3 { margin-top: 1.25rem; }
.bar-track { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 99px; }

.theme-toggle .ico-moon { display: none; }
[data-theme="dark"] .theme-toggle .ico-sun { display: none; }
[data-theme="dark"] .theme-toggle .ico-moon { display: block; }

.app-foot { display: flex; justify-content: space-between; gap: 1rem; padding: 1.1rem 1.75rem; color: var(--text-soft); font-size: .8rem; border-top: 1px solid var(--border); flex-wrap: wrap; }

.nav-backdrop { display: none; }

/* ── Responsive ────────────────────────────────────────────────────────── */
@media (max-width: 980px) { .dash-row { grid-template-columns: 1fr !important; } }
@media (max-width: 820px) {
  .sidebar { position: fixed; z-index: 60; left: 0; top: 0; transform: translateX(-100%); transition: transform .25s ease; box-shadow: var(--shadow-lg); }
  body.nav-open .sidebar { transform: translateX(0); }
  body.nav-open .nav-backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 50; }
  .hamburger { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: var(--radius-sm); border: 1px solid var(--border-2); background: var(--surface); color: var(--heading); cursor: pointer; }
  .content { padding: 1.1rem; }
  .topbar { padding: 0 1.1rem; }
  .form-grid, .detail-grid { grid-template-columns: 1fr; }
  .tu-name { display: none; }
  .form-layout { grid-template-columns: 1fr; gap: 1rem; }
  .form-nav { flex-direction: row; overflow-x: auto; position: static; padding-bottom: .35rem; }
  .form-nav-item { white-space: nowrap; }
  .form-nav-item span:not(.fn-num) { display: none; }
  .form-steps .form-grid { max-width: none; }
}

/* ── Login ─────────────────────────────────────────────────────────────── */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; background:
  radial-gradient(1100px 560px at 85% -10%, rgba(76,124,243,.16), transparent),
  radial-gradient(900px 500px at -10% 110%, rgba(82,196,202,.14), transparent), var(--bg); }
.login-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 2.3rem 2rem; }
.login-brand { display: flex; flex-direction: column; align-items: center; text-align: center; margin-bottom: 1.7rem; }
.login-brand .brand-mark { width: 56px; height: 56px; font-size: 1.7rem; border-radius: 14px; margin-bottom: .9rem; }
.login-brand h1 { font-size: 1.3rem; }
.login-brand p { color: var(--text-muted); margin: .3rem 0 0; font-size: .88rem; }
.login-card .field { margin-bottom: 1.05rem; }
.login-card .field input { padding: .7rem .85rem; }
.login-foot { text-align: center; margin-top: 1.4rem; font-size: .78rem; color: var(--text-soft); }
.hint-box { margin-top: 1rem; padding: .75rem .9rem; background: var(--surface-2); border-radius: var(--radius-sm); font-size: .8rem; color: var(--text-muted); }
.hint-box code { background: var(--surface-3); padding: .1rem .35rem; border-radius: 4px; font-size: .92em; }

@media print {
  .sidebar, .topbar, .app-foot, .ph-actions, .btn { display: none !important; }
  .content { padding: 0; } body { background: #fff; }
  .card { box-shadow: none; border: 1px solid #ddd; break-inside: avoid; }
}

/* ── Reports catalog tiles ─────────────────────────────────────────────── */
.report-group { margin-top: 1.4rem; }
.report-group-title {
  font-size: .82rem; font-weight: 700; color: var(--text-soft);
  text-transform: uppercase; letter-spacing: .06em;
  margin: .8rem 0 .6rem;
}
.report-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: .85rem; }
.report-tile {
  display: flex; align-items: center; gap: .9rem;
  padding: 1rem 1.1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  text-decoration: none; color: var(--text);
  transition: transform .15s, box-shadow .15s, border-color .15s;
}
.report-tile:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 22px -10px rgba(76,124,243,.35);
  border-color: var(--primary);
}
.report-tile-icon { font-size: 1.85rem; flex-shrink: 0; line-height: 1; }
.report-tile-body { flex: 1; min-width: 0; }
.report-tile-title { font-weight: 600; color: var(--text); margin-bottom: .2rem; }
.report-tile-desc  { font-size: .82rem; color: var(--text-soft); line-height: 1.35; }
.report-tile-arrow { color: var(--primary); font-size: 1.3rem; flex-shrink: 0; }

/* ── Report viewer — every section is its own card ──────────────────── */
.report-actions { display: flex; gap: .45rem; flex-wrap: wrap; }
.report-doc {
  display: flex; flex-direction: column; gap: 1rem;
  margin-top: 1rem;
  font-family: 'Poppins', system-ui, sans-serif;
}

.report-header {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: 12px;
  padding: 1.1rem 1.3rem 1rem;
  box-shadow: 0 1px 0 var(--border);
}
.report-header > div { display: block; }
.report-icon  { font-size: 1.6rem; margin-right: .35rem; vertical-align: middle; }
.report-title { font-size: 1.45rem; font-weight: 700; color: var(--text); display: inline; margin: 0; }
.report-desc  { font-size: .9rem;  color: var(--text-soft); margin-top: .35rem; }
.report-meta  { font-size: .78rem; color: var(--text-soft); margin-top: .55rem; padding-top: .55rem; border-top: 1px dashed var(--border); }

/* KPI strip — fully visible cards on their own row */
.report-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: .7rem;
}
.report-kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid #94a3b8;
  border-radius: 10px;
  padding: .85rem 1.05rem;
}
.report-kpi.color-teal   { border-left-color: #14b8a6; }
.report-kpi.color-blue   { border-left-color: #3b82f6; }
.report-kpi.color-violet { border-left-color: #a855f7; }
.report-kpi.color-rose   { border-left-color: #f43f5e; }
.report-kpi.color-amber  { border-left-color: #f59e0b; }
.report-kpi.color-green  { border-left-color: #22c55e; }
.report-kpi.color-lime   { border-left-color: #84cc16; }
.kpi-value { font-size: 1.45rem; font-weight: 700; color: var(--text); line-height: 1.15; }
.kpi-label { font-size: .72rem; color: var(--text-soft); text-transform: uppercase; letter-spacing: .05em; margin-top: .25rem; }
.kpi-sub   { font-size: .72rem; color: var(--text-soft); margin-top: .15rem; }

/* Each chart / table / note is a standalone card */
.report-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1.15rem 1.1rem;
  box-shadow: 0 1px 0 var(--border);
}
.report-section-title {
  font-size: 1.02rem; font-weight: 700; color: var(--text);
  margin: 0 0 .8rem; padding-bottom: .5rem;
  border-bottom: 1px solid var(--border);
}
.report-note { font-size: .9rem; color: var(--text-soft); line-height: 1.5; }
.report-section .table { margin: 0; }
.report-section svg { max-width: 100%; }

/* Status pills used on schedules table */
.badge-active   { background: #dcfce7; color: #166534; padding: .15rem .55rem; border-radius: 999px; font-size: .75rem; font-weight: 600; }
.badge-inactive { background: #fef3c7; color: #854d0e; padding: .15rem .55rem; border-radius: 999px; font-size: .75rem; font-weight: 600; }
.badge-pending  { background: #e0e7ff; color: #3730a3; padding: .15rem .55rem; border-radius: 999px; font-size: .75rem; font-weight: 600; }

/* ── Roles & users ────────────────────────────────────────────────────── */
.role-pill { display: inline-block; padding: .2rem .6rem; border-radius: 999px; font-size: .75rem; font-weight: 600; letter-spacing: .015em; }
.row-inactive { opacity: .55; }
.row-active   { background: var(--primary-soft); }

/* Inline-expand for patient-record drilldown */
.row-toggle-cell { width: 30px; padding-right: 0 !important; }
.row-toggle {
  display: inline-grid; place-items: center;
  width: 24px; height: 24px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text);
  cursor: pointer;
  padding: 0;
  transition: background .15s, border-color .15s, color .15s;
}
.row-toggle:hover { background: var(--primary); border-color: var(--primary); color: #fff; }
.row-toggle .chevron { transition: transform .2s ease; }
.row-toggle.open { background: var(--primary); border-color: var(--primary); color: #fff; }
.row-toggle.open .chevron { transform: rotate(180deg); }

.records-row { display: none; }
.records-row.open { display: table-row; }
.records-cell { padding: 0 !important; background: var(--surface-2); border-top: 0 !important; }
.records-inner { padding: .9rem 1.2rem 1.1rem; }
.records-inner-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; margin-bottom: .65rem;
}
.records-inner-title { display: flex; align-items: center; gap: .65rem; }
.records-inner .table { background: var(--surface); }
.table-compact th, .table-compact td { padding: .45rem .6rem; font-size: .85rem; }
.brand-logo { max-height: 36px; max-width: 44px; border-radius: 6px; flex-shrink: 0; }

/* ── Settings hub (tabbed layout) ─────────────────────────────────────── */
.settings-shell { display: grid; grid-template-columns: 230px 1fr; gap: 1.25rem; align-items: start; }
.settings-nav   { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: .55rem; display: flex; flex-direction: column; gap: .2rem; position: sticky; top: 1rem; }
.settings-nav .tab { display: flex; align-items: center; gap: .6rem; padding: .65rem .85rem; border-radius: 8px; text-decoration: none; color: var(--text); font-weight: 500; font-size: .9rem; transition: background .15s, color .15s; }
.settings-nav .tab:hover { background: var(--surface-2); color: var(--heading); }
.settings-nav .tab.active { background: var(--primary); color: #fff; box-shadow: 0 4px 10px -4px rgba(76,124,243,.5); }
.settings-nav .tab.active:hover { background: var(--primary); color: #fff; }
.settings-tab-ico { font-size: 1rem; line-height: 1; }
@media (max-width: 760px) {
  .settings-shell { grid-template-columns: 1fr; }
  .settings-nav { position: static; flex-direction: row; overflow-x: auto; padding: .35rem; }
  .settings-nav .tab { white-space: nowrap; }
}

/* Two-column section layout for narrower widgets (donut + bar) */
@media (min-width: 1100px) {
  .report-doc.cols-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
  .report-doc.cols-2 .report-header,
  .report-doc.cols-2 .report-kpis { grid-column: 1 / -1; }
}
