:root {
  color-scheme: light;
  --ink: #172a27;
  --muted: #71817d;
  --line: #e2e9e5;
  --paper: #ffffff;
  --canvas: #f3f6f4;
  --forest: #173d38;
  --green: #168a72;
  --green-soft: #e6f3ef;
  --blue-soft: #eaf1f7;
  --gold-soft: #fbf3e4;
  --rose-soft: #faeceb;
  --shadow: 0 12px 32px rgba(23, 61, 56, .055);
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--canvas); }
body {
  margin: 0;
  color: var(--ink);
  font-family: Tahoma, 'Segoe UI', sans-serif;
  font-size: 15px;
  background-color: var(--canvas);
  background-image: linear-gradient(rgba(23, 61, 56, .025) 1px, transparent 1px), linear-gradient(90deg, rgba(23, 61, 56, .025) 1px, transparent 1px);
  background-size: 28px 28px;
  line-height: 1.65;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
.topbar {
  min-height: 78px;
  display: flex;
  align-items: center;
  gap: 30px;
  padding: 12px max(24px, calc((100vw - 1200px) / 2));
  color: white;
  background: var(--forest);
  box-shadow: 0 4px 18px rgba(18, 54, 48, .13);
}
.brand { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; font-size: 19px; font-weight: 700; }
.brand small { display: block; color: #b9d2cc; font-size: 11px; font-weight: 400; }
.brand-mark { width: 39px; height: 39px; display: grid; place-items: center; color: var(--forest); background: #d7eee7; border-radius: 11px; font-size: 21px; font-weight: 700; }
.brand-mark.large { width: 58px; height: 58px; font-size: 30px; border-radius: 15px; }
.main-nav { display: flex; align-items: center; gap: 5px; flex: 1; }
.main-nav a { padding: 9px 13px; color: #d0e0db; border-radius: 6px; white-space: nowrap; font-size: 13px; }
.main-nav a:hover, .main-nav a.active { color: white; background: #25564f; }
.logout { min-height: 38px; padding: 0 15px; color: white; background: transparent; border: 1px solid #47716a; border-radius: 6px; cursor: pointer; }
.logout:hover { background: #25564f; }
.page-shell { width: min(1200px, calc(100% - 48px)); min-height: calc(100vh - 135px); margin: 0 auto; padding: 34px 0 44px; }
.page-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.page-heading h1 { margin: 0; font-size: 27px; line-height: 1.3; }
.eyebrow { margin: 0 0 4px; color: var(--green); font-size: 11px; font-weight: 700; }
.subcopy, .panel-heading p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 20px; }
.metrics.doctor-metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.metric { min-height: 112px; display: flex; align-items: center; gap: 14px; padding: 20px; background: var(--paper); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }
.metric-icon { width: 43px; height: 43px; display: grid; flex: 0 0 43px; place-items: center; border-radius: 8px; font-weight: 700; }
.metric-icon.green { color: #13745f; background: var(--green-soft); }
.metric-icon.blue { color: #436884; background: var(--blue-soft); }
.metric-icon.gold { color: #9a6b1a; background: var(--gold-soft); }
.metric-icon.rose { color: #a64e4a; background: var(--rose-soft); }
.metric strong { display: block; font-size: 19px; line-height: 1.35; overflow-wrap: anywhere; }
.metric div span { color: var(--muted); font-size: 12px; }
.panel { margin: 0 0 18px; padding: 20px; background: var(--paper); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 16px; }
.panel-heading h2 { margin: 0; font-size: 17px; }
.text-link { color: var(--green); font-size: 13px; font-weight: 700; white-space: nowrap; }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: right; white-space: nowrap; font-size: 13px; }
th { padding: 11px 12px; color: var(--muted); background: #f7f9f8; border-bottom: 1px solid var(--line); font-size: 11px; font-weight: 700; }
td { padding: 12px; border-bottom: 1px solid #edf1ef; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fbfcfb; }
.strong { font-weight: 700; }
.muted { color: var(--muted); }
.badge { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 20px; font-size: 11px; }
.badge.pending { color: #8a641c; background: var(--gold-soft); }
.badge.done { color: #12634f; background: var(--green-soft); }
.badge.cancelled { color: #984743; background: var(--rose-soft); }
.wa-link { color: #138363; font-size: 12px; font-weight: 700; white-space: nowrap; }
.wa-link:hover { text-decoration: underline; }
.row-actions { display: flex; align-items: center; gap: 10px; }
.row-actions form { display: inline; }
.inline-filter { display: flex; align-items: end; gap: 8px; flex-wrap: wrap; }
.inline-filter label { display: grid; gap: 3px; color: var(--muted); font-size: 11px; }
.inline-filter input, .inline-filter select { min-height: 36px; padding: 5px 8px; color: var(--ink); background: white; border: 1px solid var(--line); border-radius: 5px; }
.danger-button { color: #984743; }
.danger-panel { border-color: #eed5d3; }
.reset-form { display: flex; align-items: end; gap: 12px; flex-wrap: wrap; }
.reset-form label { display: grid; gap: 6px; min-width: 240px; color: #984743; font-size: 12px; font-weight: 700; }
.reset-form input, input[type="file"] { min-height: 42px; padding: 8px; background: white; border: 1px solid var(--line); border-radius: 5px; }
.danger-solid { color: white; background: #a63e3e; border-color: #a63e3e; }
.danger-solid:hover { background: #852f2f; }
.mini-button { padding: 6px 9px; color: var(--forest); background: #f2f7f5; border: 1px solid var(--line); border-radius: 5px; cursor: pointer; font-size: 11px; white-space: nowrap; }
.mini-button:hover { border-color: var(--green); }
.form-panel { padding-bottom: 22px; }
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; align-items: end; }
.form-grid label, .login-form label { display: grid; gap: 6px; color: #435550; font-size: 12px; font-weight: 700; }
.form-grid input, .form-grid select, .form-grid textarea, .login-form input { width: 100%; min-height: 43px; padding: 9px 11px; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 5px; outline: none; }
.form-grid textarea { resize: vertical; }
.form-grid input:focus, .form-grid select:focus, .form-grid textarea:focus, .login-form input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(22, 138, 114, .1); }
.span-two { grid-column: span 2; }
.form-actions { display: flex; align-items: end; min-height: 43px; }
.button { min-height: 43px; padding: 9px 17px; border: 1px solid var(--line); border-radius: 5px; cursor: pointer; font-weight: 700; }
.button.primary { color: white; background: var(--green); border-color: var(--green); }
.button.primary:hover { background: #10745f; }
.button.wide { width: 100%; }
.empty { padding: 34px 15px; color: var(--muted); text-align: center; font-size: 13px; }
.empty.compact { padding: 14px 0; text-align: right; }
.notices { display: grid; gap: 8px; margin-bottom: 16px; }
.notice { padding: 10px 13px; border: 1px solid var(--line); border-radius: 5px; background: white; font-size: 13px; }
.notice.success { color: #12634f; border-color: #cce5dc; background: #f0f8f5; }
.notice.error, .notice.warning { color: #984743; border-color: #eed5d3; background: #fff7f6; }
.footer { padding: 0 24px 20px; color: var(--muted); text-align: center; font-size: 11px; }
.footer span { padding: 0 4px; color: var(--green); }
.login-layout { min-height: min(620px, calc(100vh - 120px)); display: grid; grid-template-columns: 1fr minmax(300px, 430px); align-items: center; gap: 8%; }
.login-copy { padding: 35px; }
.login-copy .eyebrow { margin-top: 25px; }
.login-copy h1 { margin: 0; font-size: 32px; }
.login-form { padding: 30px; background: var(--paper); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }
.login-form h2 { margin: 0 0 20px; font-size: 20px; }
.login-form label { margin-bottom: 14px; }
.login-form input { min-height: 46px; }
.form-hint { margin: 13px 0 0; color: var(--muted); font-size: 11px; text-align: center; }
.auth-shell { display: grid; align-items: center; }
.today { color: var(--muted); font-size: 12px; }
.small-button { min-height: 34px; padding: 5px 10px; white-space: nowrap; }
.patient-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.patient-summary > div { display: grid; gap: 5px; padding: 14px 16px; background: var(--paper); border: 1px solid var(--line); border-radius: 7px; }
.patient-summary span, .prescription-meta span, .prescription-diagnosis span { color: var(--muted); font-size: 11px; }
.patient-summary strong { overflow-wrap: anywhere; font-size: 13px; }
.medicine-editor { padding: 16px; border: 1px solid var(--line); border-radius: 7px; background: #fbfcfb; }
.medicine-editor > .panel-heading { margin-bottom: 10px; }
.medicine-row { display: grid; grid-template-columns: 1.4fr 1fr .65fr 1.4fr 36px; gap: 9px; align-items: end; padding: 10px 0; border-top: 1px solid var(--line); }
.medicine-row label { min-width: 0; }
.remove-medicine { width: 36px; height: 40px; color: #984743; background: white; border: 1px solid var(--line); border-radius: 5px; cursor: pointer; font-size: 20px; }
.form-divider { padding-top: 6px; border-top: 1px solid var(--line); }
.form-divider h2 { margin: 0; font-size: 15px; }
.form-divider p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.prescription-sheet { max-width: 820px; min-height: 920px; margin: 0 auto; padding: 46px; background: white; border: 1px solid var(--line); box-shadow: var(--shadow); }
.prescription-heading { display: flex; align-items: center; justify-content: space-between; padding-bottom: 20px; border-bottom: 2px solid var(--forest); }
.prescription-heading h1 { margin: 0; font-size: 26px; }
.prescription-meta { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; padding: 22px 0; }
.prescription-meta > div { display: grid; gap: 4px; padding: 10px 12px; background: var(--canvas); border-radius: 5px; }
.prescription-diagnosis { display: grid; gap: 5px; margin: 12px 0 22px; padding: 13px; border-right: 3px solid var(--green); background: #f7faf8; }
.prescription-sheet h2 { margin: 20px 0 10px; font-size: 17px; }
.prescription-list { display: grid; }
.prescription-item { display: grid; gap: 5px; padding: 15px 4px; border-bottom: 1px solid var(--line); font-size: 13px; }
.medicine-name { font-size: 16px; font-weight: 700; }
.prescription-item span { padding: 0 4px; color: var(--muted); }
.prescription-sign { display: grid; justify-items: start; gap: 35px; margin-top: 70px; color: var(--muted); font-size: 12px; }
.prescription-sign i { width: 180px; border-top: 1px solid #8a9692; }

@media (max-width: 900px) {
  .topbar { flex-wrap: wrap; gap: 10px 18px; padding: 12px 20px; }
  .main-nav { order: 3; flex-basis: 100%; overflow-x: auto; scrollbar-width: thin; }
  .main-nav a { padding: 8px 11px; }
  .brand { margin-left: auto; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .page-shell { width: min(100% - 32px, 760px); padding-top: 25px; }
}
@media (max-width: 560px) {
  body { font-size: 14px; }
  .topbar { min-height: 65px; padding: 10px 14px; }
  .brand { font-size: 17px; }
  .brand-mark { width: 35px; height: 35px; }
  .logout { min-height: 35px; padding: 0 11px; }
  .main-nav { gap: 2px; margin: 0 -4px; }
  .main-nav a { font-size: 12px; }
  .page-shell { width: calc(100% - 24px); padding: 21px 0 32px; }
  .page-heading { align-items: flex-start; margin-bottom: 17px; }
  .page-heading h1 { font-size: 23px; }
  .metrics { gap: 9px; margin-bottom: 13px; }
  .metric { min-height: 92px; gap: 9px; padding: 13px 10px; }
  .metric-icon { width: 34px; height: 34px; flex-basis: 34px; font-size: 12px; }
  .metric strong { font-size: 15px; }
  .metric div span { font-size: 10px; }
  .panel { padding: 15px 12px; margin-bottom: 13px; }
  .panel-heading { margin-bottom: 12px; }
  .panel-heading h2 { font-size: 15px; }
  .form-grid { grid-template-columns: 1fr; gap: 12px; }
  .span-two { grid-column: auto; }
  .form-actions { min-height: 0; }
  .form-actions .button { width: 100%; }
  .patient-summary { grid-template-columns: 1fr; gap: 8px; }
  .medicine-editor { padding: 12px 9px; }
  .medicine-row { grid-template-columns: 1fr 1fr; gap: 9px; }
  .medicine-row label:first-child, .medicine-row label:nth-child(4) { grid-column: span 2; }
  .remove-medicine { grid-column: 2; justify-self: end; }
  .prescription-sheet { min-height: auto; padding: 24px 16px; }
  .prescription-heading h1 { font-size: 21px; }
  .login-layout { min-height: auto; grid-template-columns: 1fr; gap: 22px; padding: 24px 0; }
  .login-copy { padding: 10px 7px 0; }
  .login-copy .eyebrow { margin-top: 15px; }
  .login-copy h1 { font-size: 27px; }
  .login-form { padding: 22px; }
  .auth-shell { align-content: center; }
}

@media print {
  body { background: white; }
  .topbar, .footer, .no-print, .notices { display: none !important; }
  .page-shell { width: 100%; min-height: 0; margin: 0; padding: 0; }
  .prescription-sheet { max-width: none; min-height: 0; margin: 0; padding: 12mm; border: 0; box-shadow: none; }
}
