:root {
  --ink: #1a1a1a;
  --muted: #6b6b6b;
  --border: #e6e6e6;
  --bg: #fafafa;
  --accent: #2b2b2b;
  --paid: #1e8246;
  --unpaid: #be5a14;
}
* { box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  margin: 0;
  padding: 0 20px 60px;
}
.wrap { max-width: 960px; margin: 0 auto; }
header.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 28px 0 20px; border-bottom: 1px solid var(--border); margin-bottom: 28px;
}
header.topbar h1 { font-size: 20px; margin: 0; letter-spacing: -0.01em; }
header.topbar .tag { color: var(--muted); font-size: 13px; }
.btn {
  display: inline-block; padding: 10px 18px; border-radius: 8px;
  background: var(--accent); color: #fff; text-decoration: none;
  font-size: 14px; font-weight: 600; border: none; cursor: pointer;
}
.btn:hover { opacity: 0.88; }
.btn.secondary { background: #fff; color: var(--ink); border: 1px solid var(--border); }
table.invoices { width: 100%; border-collapse: collapse; margin-top: 10px; }
table.invoices th {
  text-align: left; font-size: 12px; letter-spacing: 0.03em; color: var(--muted);
  text-transform: uppercase; padding: 10px 12px; border-bottom: 1px solid var(--border);
}
table.invoices td {
  padding: 14px 12px; border-bottom: 1px solid var(--border); font-size: 14px;
}
table.invoices tr:hover { background: #fff; }
.status-pill {
  display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
}
.status-pill.paid { background: #e6f4ec; color: var(--paid); }
.status-pill.unpaid { background: #fbeee1; color: var(--unpaid); }
.status-pill.overdue { background: #fdeaea; color: #c0392b; }
.actions a { margin-right: 12px; font-size: 13px; text-decoration: none; color: var(--ink); font-weight: 600; }
.link-btn { background: none; border: none; padding: 0; margin-right: 12px; font-size: 13px; font-weight: 600; color: var(--ink); cursor: pointer; font-family: inherit; }
.link-btn:hover { text-decoration: underline; }
.empty { text-align: center; color: var(--muted); padding: 60px 0; }

form.invoice-form { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 28px; margin-top: 10px; }
form.invoice-form fieldset { border: none; padding: 0; margin: 0 0 24px; }
form.invoice-form legend { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); margin-bottom: 12px; padding: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.field input, .field textarea, .field select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 14px; font-family: inherit; background: #fff;
}
.field textarea { resize: vertical; }
table.items-table { width: 100%; border-collapse: collapse; margin-bottom: 10px; }
table.items-table th { text-align: left; font-size: 12px; color: var(--muted); padding: 6px 8px; }
table.items-table td { padding: 6px 8px; }
table.items-table input { width: 100%; }
.item-row .remove-item { color: #c0392b; background: none; border: none; cursor: pointer; font-size: 13px; font-weight: 600; }
#add-item { margin-top: 4px; }
.totals-preview { text-align: right; font-size: 14px; margin-top: 14px; color: var(--muted); }
.totals-preview strong { color: var(--ink); font-size: 16px; }
.form-actions { margin-top: 24px; display: flex; gap: 12px; }
.alert { background: #fdeaea; color: #c0392b; padding: 12px 16px; border-radius: 8px; font-size: 14px; margin-bottom: 20px; }
.hint { color: var(--muted); font-size: 12.5px; margin-top: 4px; }

/* --- Sidebar layout --- */
body { padding: 0; }
.app-shell { display: flex; min-height: 100vh; align-items: stretch; }
.sidebar {
  width: 220px; flex-shrink: 0; background: #fff; border-right: 1px solid var(--border);
  padding: 22px 14px; box-sizing: border-box; display: flex; flex-direction: column;
}
.sidebar-brand { font-weight: 700; font-size: 14px; padding: 0 8px 18px; letter-spacing: -0.01em; }
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; margin-bottom: 22px; }
.sidebar-nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 8px; border-radius: 8px;
  text-decoration: none; color: var(--ink); font-size: 13.5px;
}
.sidebar-nav a:hover { background: #f2f2f2; }
.sidebar-nav a.active { background: #eef0ff; font-weight: 700; }
.sidebar-icon { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }
.sidebar-badge {
  margin-left: auto; background: #d64545; color: #fff; font-size: 11px; font-weight: 700;
  border-radius: 999px; min-width: 18px; height: 18px; display: inline-flex; align-items: center;
  justify-content: center; padding: 0 5px;
}
.sidebar-reminders { border-top: 1px solid var(--border); padding-top: 14px; margin-top: auto; }
.sidebar-reminders h4 { font-size: 11px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); margin: 0 0 8px; padding: 0 8px; }
.sidebar-reminders .sidebar-empty { font-size: 12px; color: var(--muted); padding: 0 8px; }
.sidebar-reminders .reminder-item {
  display: flex; align-items: center; gap: 6px; padding: 4px 8px; border-radius: 6px;
}
.sidebar-reminders .reminder-item:hover { background: #f2f2f2; }
.sidebar-reminders .reminder-link {
  display: flex; flex-direction: column; gap: 1px; text-decoration: none; color: var(--ink);
  font-size: 12px; flex: 1; min-width: 0; padding: 3px 0;
}
.reminder-name { font-weight: 600; }
.reminder-date { color: var(--muted); font-size: 11px; }
.reminder-wa {
  flex-shrink: 0; text-decoration: none; font-size: 15px; line-height: 1; padding: 4px;
  border-radius: 5px;
}
.reminder-wa:hover { background: #dcf8e0; }
.main-area { flex: 1; min-width: 0; padding: 0 20px 60px; box-sizing: border-box; }

/* --- Right-hand rail: Today's Appointments + Follow-ups, on every page --- */
.right-rail {
  width: 250px; flex-shrink: 0; background: #fff; border-left: 1px solid var(--border);
  padding: 22px 16px; box-sizing: border-box;
}
.rail-block { margin-bottom: 26px; }
.rail-block:last-child { margin-bottom: 0; }
.rail-block h4 { font-size: 11px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); margin: 0 0 10px; }
.rail-empty { font-size: 12px; color: var(--muted); }
.rail-item { display: flex; align-items: center; gap: 6px; padding: 6px 0; border-bottom: 1px solid #f2f2f2; }
.rail-item:last-child { border-bottom: none; }
.rail-link { display: flex; flex-direction: column; gap: 1px; text-decoration: none; color: var(--ink); font-size: 12.5px; flex: 1; min-width: 0; }
.rail-name { font-weight: 600; }
.rail-sub { color: var(--muted); font-size: 11px; }
.rail-wa { flex-shrink: 0; display: flex; padding: 4px; border-radius: 5px; }
.rail-wa:hover { background: #dcf8e0; }
.wa-icon { display: block; }
@media (max-width: 1000px) {
  .app-shell { flex-wrap: wrap; }
  .right-rail { width: 100%; border-left: none; border-top: 1px solid var(--border); order: 3; }
  .main-area { order: 2; }
}
@media (max-width: 800px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--border); }
  .sidebar-nav { flex-direction: row; flex-wrap: wrap; }
}

/* --- Professional detail card (used by invoice View and prescription View) --- */
.detail-card { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 22px 24px; margin-bottom: 20px; }
.detail-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 18px; }
.detail-header .dh-title { font-size: 16px; font-weight: 700; }
.detail-header .dh-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.detail-header .dh-right { text-align: right; }
.detail-section { margin-bottom: 22px; }
.detail-section:last-of-type { margin-bottom: 0; }
.detail-section-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 700;
  margin-bottom: 12px; padding-bottom: 7px; border-bottom: 1px solid var(--border);
}
.detail-section-title .dst-note { font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--muted); }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px 22px; margin-bottom: 14px; }
.detail-grid .dg-label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.02em; margin-bottom: 3px; }
.detail-grid .dg-value { font-size: 13.5px; font-weight: 500; }
.detail-block { font-size: 13.5px; margin-bottom: 14px; line-height: 1.6; }
.detail-block:last-child { margin-bottom: 0; }
.detail-block .db-label { font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: 0.02em; color: var(--muted); margin-bottom: 5px; }
table.detail-table { width: 100%; border-collapse: collapse; margin-bottom: 10px; }
table.detail-table th { text-align: left; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.02em; padding: 4px 10px 8px 0; border-bottom: 1px solid var(--border); }
table.detail-table td { padding: 8px 10px 8px 0; font-size: 13.5px; border-bottom: 1px solid #f2f2f2; }
table.detail-table td:last-child, table.detail-table th:last-child { text-align: right; }

/* --- Label/value table for Clinical Findings and similar detail blocks --- */
table.kv-table { width: 100%; border-collapse: collapse; margin-bottom: 14px; }
table.kv-table th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.02em; color: var(--muted);
  font-weight: 600; padding: 8px 16px 8px 0; border-bottom: 1px solid #f2f2f2; width: 170px; vertical-align: top; white-space: nowrap;
}
table.kv-table td { padding: 8px 0; font-size: 13.5px; border-bottom: 1px solid #f2f2f2; vertical-align: top; }
table.kv-table tr:last-child th, table.kv-table tr:last-child td { border-bottom: none; }
@media (max-width: 600px) {
  table.kv-table, table.kv-table tbody, table.kv-table tr, table.kv-table th, table.kv-table td { display: block; width: auto; }
  table.kv-table tr { padding: 6px 0; border-bottom: 1px solid #f2f2f2; }
  table.kv-table th, table.kv-table td { border-bottom: none; padding: 1px 0; }
}
