/* RSSD Ayurveda HMS — "Herbarium" theme
   Forest sidebar, herb-green actions, sage canvas, turmeric only for alerts. */
:root {
  --forest: #0F3D2E;
  --forest-2: #164B39;
  --forest-3: #1E5C46;
  --herb: #1F7A4D;
  --herb-dark: #17633E;
  --leaf: #3FA36B;
  --leaf-soft: #E3F1E8;
  --canvas: #F3F7F4;
  --surface: #FFFFFF;
  --line: #DCE6DF;
  --line-2: #EAF0EC;
  --ink: #15241C;
  --ink-2: #4A5D52;
  --ink-3: #7A8C81;
  --turmeric: #C9921A;
  --turmeric-soft: #FBF1D9;
  --clay: #B4432F;
  --clay-soft: #FBE6E1;
  --sky: #2C6E8F;
  --sky-soft: #E1EEF5;
  --r-lg: 16px;
  --r-md: 10px;
  --r-sm: 7px;
  --shadow: 0 1px 2px rgba(15, 61, 46, .06), 0 6px 18px -8px rgba(15, 61, 46, .12);
  --font: "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --display: "Fraunces", Georgia, "Times New Roman", serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 14.5px; line-height: 1.5;
  color: var(--ink); background: var(--canvas);
  font-feature-settings: "tnum" 1, "cv11" 1; -webkit-font-smoothing: antialiased;
}
a { color: var(--herb); text-decoration: none; }
a:hover { color: var(--herb-dark); text-decoration: underline; text-underline-offset: 3px; }
:focus-visible { outline: 2.5px solid var(--leaf); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
.ic { flex: none; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--forest); color: #fff; padding: 8px 14px; border-radius: 8px; z-index: 99; }
.skip:focus { left: 8px; }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: 252px 1fr; min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  background: var(--forest); color: #CFE3D7;
  background-image: radial-gradient(120% 60% at 0% 0%, rgba(63,163,107,.18), transparent 60%);
}
.brand { display: flex; gap: 12px; align-items: center; padding: 22px 20px 18px; }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 11px; background: var(--leaf); color: var(--forest); }
.brand strong { display: block; color: #fff; font-family: var(--display); font-weight: 600; font-size: 17px; letter-spacing: .1px; }
.brand small { display: block; color: #9DBFAC; font-size: 12px; max-width: 170px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav { flex: 1; overflow-y: auto; padding: 6px 12px 12px; }
.nav-group { margin-top: 14px; }
.nav-label { display: block; padding: 0 10px 6px; font-size: 12px; color: #82A894; font-weight: 600; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 9px; color: #D7E8DE; font-weight: 500; }
.nav a:hover { background: var(--forest-2); color: #fff; text-decoration: none; }
.nav a.on { background: var(--forest-3); color: #fff; box-shadow: inset 3px 0 0 var(--leaf); }
.nav a.on .ic { color: var(--leaf); }
.side-user { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-top: 1px solid rgba(255,255,255,.08); }
.side-user .who { flex: 1; min-width: 0; }
.side-user strong { display: block; color: #fff; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-user small { color: #9DBFAC; font-size: 12px; }
.side-user .icon-btn { color: #B7D3C3; }
.side-user .icon-btn:hover { background: var(--forest-2); color: #fff; }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--leaf-soft); color: var(--forest); font-weight: 700; font-size: 12.5px; flex: none; }

.main { min-width: 0; }
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 14px; padding: 18px 32px; background: rgba(243,247,244,.88); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line-2); }
.top h1 { font-family: var(--display); font-weight: 600; font-size: 26px; letter-spacing: -.2px; flex: 1; color: var(--forest); }
.top-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.content { padding: 24px 32px 48px; max-width: 1360px; }
.top .nav-toggle { display: none; }
.scrim { display: none; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px; height: 38px; padding: 0 16px;
  border-radius: var(--r-sm); border: 1px solid transparent; cursor: pointer;
  font: 600 14px var(--font); background: var(--herb); color: #fff; white-space: nowrap;
}
.btn:hover { background: var(--herb-dark); color: #fff; text-decoration: none; }
.btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: var(--leaf-soft); color: var(--forest); }
.btn-danger { background: var(--clay); }
.btn-danger:hover { background: #973625; }
.btn-sm { height: 30px; padding: 0 11px; font-size: 13px; }
.icon-btn { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; border: 0; background: transparent; color: var(--ink-2); cursor: pointer; }
.icon-btn:hover { background: var(--line-2); }

/* ---------- Panels ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); margin-bottom: 20px; }
.panel-head { display: flex; align-items: center; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--line-2); }
.panel-head h2 { font-size: 15.5px; font-weight: 700; flex: 1; }
.panel-head .muted { font-size: 13px; }
.panel-body { padding: 20px; }
.panel-body.tight { padding: 0; }
.grid { display: grid; gap: 20px; }
.g2 { grid-template-columns: 1fr 1fr; }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g-side { grid-template-columns: minmax(0, 1fr) 340px; }
.muted { color: var(--ink-3); }
.small { font-size: 13px; }

/* Stat strip: one band, divided — not a row of identical cards */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); margin-bottom: 20px; overflow: hidden; }
.stat { padding: 18px 20px; border-right: 1px solid var(--line-2); }
.stat:last-child { border-right: 0; }
.stat .n { font-family: var(--display); font-size: 30px; font-weight: 600; color: var(--forest); line-height: 1.1; }
.stat .l { color: var(--ink-2); font-size: 13px; margin-top: 4px; }
.stat .d { font-size: 12.5px; color: var(--ink-3); }
.stat.alert .n { color: var(--turmeric); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; }
.t th { text-align: left; font-size: 12.5px; font-weight: 600; color: var(--ink-3); padding: 11px 16px; background: #FAFCFA; border-bottom: 1px solid var(--line); white-space: nowrap; }
.t td { padding: 12px 16px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.t tr:last-child td { border-bottom: 0; }
.t tbody tr:hover td { background: #F8FBF9; }
.t .num { text-align: right; white-space: nowrap; }
.t .strong { font-weight: 600; }
.cell-person { display: flex; align-items: center; gap: 10px; }
.cell-person small { display: block; color: var(--ink-3); font-size: 12.5px; }

/* ---------- Pills ---------- */
.pill { display: inline-flex; align-items: center; height: 23px; padding: 0 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill-ok { background: var(--leaf-soft); color: #1B6B42; }
.pill-info { background: var(--sky-soft); color: var(--sky); }
.pill-warn { background: var(--turmeric-soft); color: #8A6310; }
.pill-bad { background: var(--clay-soft); color: var(--clay); }
.pill-mute { background: #EEF1EF; color: var(--ink-2); }
.tag { display: inline-block; padding: 2px 8px; border-radius: 6px; background: var(--line-2); color: var(--ink-2); font-size: 12px; font-weight: 600; }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.wide { grid-column: span 2; }
.field.full { grid-column: 1 / -1; }
.field > span { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field i { color: var(--clay); font-style: normal; }
.field small { color: var(--ink-3); font-size: 12px; }
input, select, textarea {
  font: 14.5px var(--font); color: var(--ink); background: #fff;
  border: 1px solid var(--line); border-radius: var(--r-sm); padding: 9px 11px; width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
input, select { height: 40px; }
textarea { resize: vertical; min-height: 70px; }
input:focus, select:focus, textarea:focus { outline: 0; border-color: var(--leaf); box-shadow: 0 0 0 3px rgba(63,163,107,.18); }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; padding-top: 16px; margin-top: 16px; border-top: 1px solid var(--line-2); }
.form-section { font-size: 13.5px; font-weight: 700; color: var(--forest); grid-column: 1 / -1; padding-top: 6px; border-top: 1px dashed var(--line); margin-top: 4px; }
.form-section:first-child { border-top: 0; padding-top: 0; margin-top: 0; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.toolbar .search { position: relative; flex: 1; min-width: 220px; max-width: 420px; }
.toolbar .search .ic { position: absolute; left: 11px; top: 11px; color: var(--ink-3); }
.toolbar .search input { padding-left: 36px; }
.toolbar select, .toolbar input[type=date] { width: auto; }
.checks { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.checks label { display: inline-flex; gap: 8px; align-items: center; font-weight: 500; }
.checks input { width: 17px; height: 17px; accent-color: var(--herb); }

/* ---------- Flash & empty ---------- */
.flash { display: flex; gap: 9px; align-items: center; margin: 16px 32px 0; padding: 11px 14px; border-radius: var(--r-md); font-weight: 500; max-width: 1296px; }
.flash-ok { background: var(--leaf-soft); color: #1B5E3B; }
.flash-err { background: var(--clay-soft); color: var(--clay); }
.flash-warn { background: var(--turmeric-soft); color: #7A570D; }
.empty { text-align: center; padding: 48px 20px; color: var(--ink-2); }
.empty h2 { font-family: var(--display); color: var(--forest); font-size: 22px; margin-bottom: 8px; }
.empty p { margin: 0 0 18px; }
.empty-row { text-align: center; color: var(--ink-3); padding: 28px !important; }

.pager { display: flex; gap: 14px; justify-content: flex-end; align-items: center; padding: 12px 16px; border-top: 1px solid var(--line-2); font-size: 13.5px; }

/* ---------- Lists ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--line-2); }
.list li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .grow small { display: block; color: var(--ink-3); font-size: 12.5px; }
.alert-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--turmeric); flex: none; }
.alert-dot.bad { background: var(--clay); }

/* ---------- Patient header ---------- */
.patient-head { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.patient-head .avatar { width: 54px; height: 54px; font-size: 18px; background: var(--forest); color: #fff; }
.patient-head h2 { font-family: var(--display); font-size: 24px; color: var(--forest); }
.meta { display: flex; flex-wrap: wrap; gap: 6px 18px; color: var(--ink-2); font-size: 13.5px; margin-top: 4px; }
.allergy { display: flex; gap: 8px; align-items: center; padding: 9px 14px; border-radius: var(--r-md); background: var(--clay-soft); color: var(--clay); font-weight: 600; margin-top: 14px; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 8px 14px; font-size: 14px; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; }
.tabs a { padding: 10px 14px; color: var(--ink-2); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a.on { color: var(--forest); border-color: var(--herb); }
.tabs a:hover { text-decoration: none; color: var(--forest); }

/* ---------- Dosha balance bar (signature element) ---------- */
.dosha { display: flex; height: 12px; border-radius: 999px; overflow: hidden; background: var(--line-2); }
.dosha span { display: block; height: 100%; }
.dosha .v { background: #7FA7C9; }
.dosha .p { background: #D9774A; }
.dosha .k { background: #5FA37A; }
.dosha-legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--ink-2); margin-top: 8px; }
.dosha-legend b { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 6px; }

/* ---------- Progress screen ---------- */
.compare { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0; }
.compare > div { padding: 16px 20px; border-right: 1px solid var(--line-2); }
.compare > div:last-child { border-right: 0; }
.compare .lbl { font-size: 13px; color: var(--ink-2); font-weight: 600; }
.compare .vals { display: flex; align-items: baseline; gap: 8px; margin-top: 6px; }
.compare .from { color: var(--ink-3); font-size: 15px; }
.compare .to { font-family: var(--display); font-size: 28px; font-weight: 600; color: var(--forest); }
.compare .delta { font-size: 12.5px; font-weight: 700; }
.delta.better { color: #1B6B42; }
.delta.worse { color: var(--clay); }
.sessions-track { display: flex; gap: 4px; flex-wrap: wrap; }
.sessions-track span { width: 22px; height: 22px; border-radius: 6px; background: var(--line-2); display: grid; place-items: center; font-size: 10.5px; font-weight: 700; color: var(--ink-3); }
.sessions-track .done { background: var(--leaf); color: #fff; }
.sessions-track .missed { background: var(--clay-soft); color: var(--clay); }
.sessions-track .scheduled { background: var(--sky-soft); color: var(--sky); }
.chart-box { padding: 16px 20px 8px; }
.chart-box svg { width: 100%; height: auto; display: block; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12.5px; color: var(--ink-2); padding: 0 20px 16px; }
.legend b { display: inline-block; width: 14px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 6px; }
.timeline { list-style: none; margin: 0; padding: 4px 20px 16px; }
.timeline li { position: relative; padding: 12px 0 12px 22px; border-left: 2px solid var(--line); margin-left: 6px; }
.timeline li::before { content: ""; position: absolute; left: -7px; top: 16px; width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 2px solid var(--leaf); }
.timeline li.warn::before { border-color: var(--clay); }
.timeline .when { font-size: 12.5px; color: var(--ink-3); }

/* ---------- Bed board ---------- */
.beds { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.bed { border: 1px solid var(--line); border-radius: var(--r-md); padding: 12px; background: #fff; min-height: 86px; }
.bed .no { font-weight: 700; display: flex; justify-content: space-between; align-items: center; }
.bed small { display: block; color: var(--ink-3); margin-top: 4px; font-size: 12.5px; }
.bed.available { border-left: 4px solid var(--leaf); }
.bed.occupied { border-left: 4px solid var(--turmeric); background: #FFFCF4; }
.bed.cleaning, .bed.blocked { border-left: 4px solid #B9C4BE; background: #F7F9F8; }
.bed a.pname { font-weight: 600; color: var(--ink); display: block; margin-top: 6px; }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; background: var(--canvas); }
.login-art {
  position: relative; overflow: hidden; color: #E6F2EA; padding: 48px 56px;
  background: var(--forest);
  display: flex; flex-direction: column; justify-content: space-between;
}
.login-art svg.veins { position: absolute; right: -120px; bottom: -80px; width: 620px; opacity: .22; color: var(--leaf); }
.login-art h1 { font-family: var(--display); font-weight: 500; font-size: 44px; line-height: 1.08; color: #fff; max-width: 460px; letter-spacing: -.6px; }
.login-art p { max-width: 420px; color: #B8D5C4; font-size: 15.5px; }
.login-art .brand { padding: 0; }
.login-form { display: grid; place-items: center; padding: 40px 24px; }
.login-card { width: 100%; max-width: 380px; }
.login-card h2 { font-family: var(--display); font-size: 28px; color: var(--forest); margin-bottom: 6px; }
.login-card .field { margin-bottom: 14px; }
.login-card .btn { width: 100%; justify-content: center; height: 44px; margin-top: 6px; }
.login-foot { font-size: 12.5px; color: var(--ink-3); margin-top: 22px; }

/* ---------- Print ---------- */
.print-only { display: none; }
@media print {
  .side, .top, .no-print, .flash, .scrim { display: none !important; }
  .shell { display: block; }
  .content { padding: 0; max-width: none; }
  .panel { box-shadow: none; border: 0; }
  .print-only { display: block; }
  body { background: #fff; font-size: 12.5px; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .g-side, .g3 { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; left: 0; top: 0; z-index: 30; width: 272px; transform: translateX(-100%); transition: transform .22s ease; }
  body.nav-open .side { transform: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(10, 30, 22, .45); z-index: 20; }
  .top .nav-toggle { display: inline-grid; }
  .top { padding: 12px 16px; flex-wrap: wrap; gap: 10px; }
  .top h1 { font-size: 21px; flex: 1 1 calc(100% - 60px); }
  .top-actions { width: 100%; }
  .top-actions .btn { flex: 1; justify-content: center; }
  .list li { flex-wrap: wrap; }
  .list .grow { flex-basis: 60%; }
  .content { padding: 16px 16px 40px; }
  .flash { margin: 12px 16px 0; }
  .g2 { grid-template-columns: 1fr; }
  .field.wide { grid-column: auto; }
  .login { grid-template-columns: 1fr; }
  .login-art { padding: 32px 24px; min-height: 230px; }
  .login-art h1 { font-size: 30px; }
  .stat { border-bottom: 1px solid var(--line-2); }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---------- Help & tutorial ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.chips a { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); font-weight: 600; font-size: 13px; }
.chips a span { color: var(--ink-3); font-weight: 500; }
.chips a:hover { text-decoration: none; border-color: var(--leaf); color: var(--forest); }
.chips a.on { background: var(--forest); border-color: var(--forest); color: #fff; }
.chips a.on span { color: #9DBFAC; }
.help-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 20px; align-items: start; }
.help-grid .panel { margin: 0; }
.steps { margin: 0; padding: 0; list-style: none; counter-reset: s; }
.steps li { counter-increment: s; position: relative; padding: 0 0 12px 38px; }
.steps li::before { content: counter(s); position: absolute; left: 0; top: -1px; width: 25px; height: 25px; border-radius: 50%; background: var(--leaf-soft); color: var(--forest); font-weight: 700; font-size: 12.5px; display: grid; place-items: center; }
.steps li:not(:last-child)::after { content: ""; position: absolute; left: 12px; top: 26px; bottom: 2px; width: 1px; background: var(--line); }
.help-tip { display: flex; gap: 8px; align-items: flex-start; margin: 4px 0 0; padding: 10px 12px; border-radius: var(--r-md); background: var(--turmeric-soft); color: #6E4F0B; font-size: 13.5px; }
.help-tip .ic { margin-top: 2px; }
.help-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line-2); }
@media (max-width: 900px) { .help-grid { grid-template-columns: 1fr; } }
