:root {
  --primary: #0e7490;         /* deep teal-blue */
  --primary-strong: #155e75;
  --primary-600: #0891b2;
  --primary-soft: #ecfeff;    /* cyan-50 */
  --accent: #0891b2;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #f1f5f9;              /* slate-100 */
  --card: #ffffff;
  --success: #059669;
  --danger: #dc2626;
  --shadow-sm: 0 1px 2px rgba(15,23,42,.06), 0 1px 3px rgba(15,23,42,.08);
  --shadow-md: 0 4px 12px rgba(15,23,42,.10);
  --radius: 12px;
}

* { box-sizing: border-box; }
/* Type scale: Title(.practice-title 30/800) · Heading(h2 22/700) · Section(h3 12/700 caps)
   · Body(15/400) · Secondary(.muted 13) */
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif; margin: 0; color: var(--ink); background: var(--bg); font-size: 15px; line-height: 1.5; }
.hidden { display: none !important; }
.ic { width: 18px; height: 18px; flex: 0 0 auto; vertical-align: -3px; }

/* ---- Login / centered cards ---- */
.center { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 24px; }
.center h1 { margin: 0; font-size: 26px; display: flex; align-items: center; gap: 10px; }
.brand-badge { width: 48px; height: 48px; border-radius: 14px; background: linear-gradient(135deg, var(--primary), var(--primary-600)); color: #fff; display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow-md); }
.brand-badge .ic { width: 28px; height: 28px; }

/* ---- Top bar ---- */
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 12px; padding: 12px 18px; background: var(--card); border-bottom: 1px solid var(--line); box-shadow: var(--shadow-sm); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--primary); font-size: 17px; }
.brand .ic { color: var(--primary); }
.spacer { flex: 1; }
#doctor-name { color: var(--muted); font-size: 14px; }

/* ---- Buttons ---- */
.btn { display: inline-flex; align-items: center; gap: 7px; padding: 9px 15px; border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 9px; cursor: pointer; font: inherit; font-weight: 600; transition: background .12s, box-shadow .12s, border-color .12s; }
.btn:hover { border-color: #cbd5e1; box-shadow: var(--shadow-sm); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(8,145,178,.25); }
/* Primary CTA */
.btn.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn.primary:hover { background: var(--primary-strong); border-color: var(--primary-strong); }
/* Secondary CTA */
.btn.secondary { background: #fff; color: var(--primary); border-color: var(--primary); }
.btn.secondary:hover { background: var(--primary-soft); border-color: var(--primary-strong); }
/* Tertiary / navigation */
.btn.link { border: none; background: none; color: var(--accent); padding: 6px 2px; box-shadow: none; }
.btn.link:hover { text-decoration: underline; box-shadow: none; }

/* ---- Layout ---- */
section { padding: 20px 18px; max-width: 920px; margin: 0 auto; }
h2 { font-size: 22px; font-weight: 700; margin: 6px 0 14px; }
h3 { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 22px 0 10px; }

/* ---- Practice title ---- */
.practice-title { text-align: center; font-size: 30px; font-weight: 800; color: var(--primary); margin: 18px 0 22px; letter-spacing: -.01em; }

/* ---- Search ---- */
.search-wrap { position: relative; }
.search-wrap .search-ic { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 18px; height: 18px; }
#search-input { width: 100%; padding: 13px 14px 13px 42px; font-size: 16px; border: 1px solid var(--line); border-radius: 11px; background: var(--card); box-shadow: var(--shadow-sm); }
#search-input:focus, .field textarea:focus, .field input:focus, .med-row input:focus, #doctor-picker:focus { outline: none; border-color: var(--primary-600); box-shadow: 0 0 0 3px rgba(8,145,178,.15); }

/* ---- Card lists (patients / visits) ---- */
.list { list-style: none; padding: 0; margin: 14px 0; }
.list li { display: flex; align-items: center; gap: 12px; padding: 14px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 10px; cursor: pointer; box-shadow: var(--shadow-sm); transition: box-shadow .12s, transform .06s, border-color .12s; }
.list li:hover { box-shadow: var(--shadow-md); border-color: #cbd5e1; transform: translateY(-1px); }
.list li.active { border-color: var(--primary); background: var(--primary-soft); box-shadow: var(--shadow-md); }

/* Master–detail: visit list (scrolls on its own) + sticky detail that stays in view */
.visits-pane { display: grid; grid-template-columns: 300px 1fr; gap: 16px; align-items: start; margin-top: 12px; }
.visits-pane #visits-list { max-height: 72vh; overflow-y: auto; margin: 0; padding-right: 4px; }
#visit-detail { position: sticky; top: 72px; margin: 0; }
@media (max-width: 720px) {
  .visits-pane { grid-template-columns: 1fr; }
  .visits-pane #visits-list { max-height: none; overflow: visible; }
  #visit-detail { position: static; }
}
.list li.muted { cursor: default; box-shadow: none; background: transparent; border: none; color: var(--muted); justify-content: center; padding: 28px 12px; font-size: 14px; }
.row-ic { width: 38px; height: 38px; flex: 0 0 auto; border-radius: 10px; background: var(--primary-soft); color: var(--primary); display: flex; align-items: center; justify-content: center; }
.row-main { flex: 1; min-width: 0; }
.muted { color: var(--muted); font-size: .9em; }

/* ---- Detail cards ---- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 16px; margin-bottom: 14px; }
#patient-header h2 { margin: 0 0 4px; }
#visit-body p { margin: 6px 0; }
#visit-body strong { color: var(--muted); font-weight: 600; }

/* ---- Banner ---- */
.banner { background: #fef2f2; color: #991b1b; padding: 11px 16px; text-align: center; border-bottom: 1px solid #fecaca; font-weight: 500; }

/* ---- Tables ---- */
table { width: 100%; border-collapse: collapse; }
#visit-body table, .card table { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
th { text-align: left; padding: 9px 10px; background: var(--primary-soft); color: var(--primary-strong); font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
td { text-align: left; padding: 9px 10px; border-top: 1px solid var(--line); }
.rx-hindi { font-size: 12px; color: var(--muted); }

/* ---- Forms ---- */
.field { display: block; margin: 12px 0; font-weight: 600; font-size: 14px; }
.field textarea, .field input { display: block; width: 100%; margin-top: 5px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; font: inherit; font-weight: 400; background: var(--card); }
.field textarea { min-height: 64px; }
.med-row { display: grid; grid-template-columns: 2fr 1.4fr repeat(3, 52px) 1.4fr 64px auto; gap: 6px; align-items: center; margin-bottom: 8px; }
.med-row input { padding: 8px; border: 1px solid var(--line); border-radius: 8px; font: inherit; width: 100%; }
.med-row .rm { border: none; background: none; color: var(--danger); cursor: pointer; font-size: 20px; line-height: 1; }
.av-actions { margin-top: 20px; display: flex; gap: 10px; }

/* ---- Doctor picker ---- */
#doctor-picker { padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px; max-width: 260px; background: var(--card); font: inherit; }

/* ---- Medicine autocomplete ---- */
#medicine-suggest { position: fixed; z-index: 50; background: var(--card); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-md); max-height: 240px; overflow-y: auto; min-width: 220px; }
#medicine-suggest .opt { padding: 9px 12px; cursor: pointer; }
#medicine-suggest .opt:hover { background: var(--primary-soft); }
#medicine-suggest .create { color: var(--primary); font-weight: 600; border-top: 1px solid var(--line); }

/* ---- Print: only the prescription, black on white ---- */
#print-area { display: none; }
@media print {
  body * { visibility: hidden; }
  #print-area, #print-area * { visibility: visible; }
  #print-area { display: block; position: absolute; left: 0; top: 0; width: 100%; color: #000; }
  .rx-header { text-align: center; }
  .rx-clinic { font-size: 20px; font-weight: 700; }
  .rx-patient { display: flex; flex-wrap: wrap; gap: 12px; margin: 8px 0; }
  .rx-meds { border-collapse: collapse; width: 100%; }
  .rx-meds th, .rx-meds td { border: 1px solid #000; background: #fff; color: #000; text-transform: none; }
  .rx-footer { margin-top: 24px; font-style: italic; text-align: center; }
  .rx-hindi { color: #333; font-size: 11px; }
}
@page { size: A4; margin: 20mm; }
