:root {
  --teal: #0e7c7b; --teal-dark: #0a5c5b; --ink: #12333a; --muted: #6b8a90;
  --bg: #f2f7f7; --card: #fff; --line: #d9e6e6; --warn: #b45309; --error: #c0392b; --radius: 14px;
}
* { box-sizing: border-box; }
/* The `hidden` HTML attribute must always win over class-level `display` (e.g. .modal / .view.auth),
   otherwise those elements leak through (empty modal scrim, login card over the app). */
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg); color: var(--ink); min-height: 100vh; -webkit-font-smoothing: antialiased; }

.view { min-height: 100vh; }
.view.auth { display: flex; align-items: center; justify-content: center; padding: 24px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 24px; width: 100%; max-width: 420px; box-shadow: 0 6px 24px rgba(14,124,123,.08); }

.brand { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.brand.small { margin: 0; gap: 10px; }
.brand-mark { width: 44px; height: 44px; border-radius: 12px;
  background: linear-gradient(135deg, var(--teal), var(--teal-dark)); color: #fff; font-weight: 800;
  display: flex; align-items: center; justify-content: center; font-size: 18px; }
.brand h1 { font-size: 20px; margin: 0; } .brand p { margin: 2px 0 0; }

h2 { font-size: 18px; margin: 0 0 6px; } h3 { font-size: 15px; margin: 20px 0 8px; }
.muted { color: var(--muted); font-size: 14px; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; color: var(--muted); font-size: 13px; }

label { display: block; font-size: 13px; color: var(--muted); margin-top: 14px; font-weight: 600; }
input, select { width: 100%; margin-top: 6px; padding: 12px 14px; border: 1px solid var(--line);
  border-radius: 10px; font-size: 16px; color: var(--ink); background: #fbfefe; }
input:focus, select:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(14,124,123,.12); }
.phone-row { display: flex; gap: 8px; align-items: center; }
.phone-row .dial-select { flex: 0 0 132px; min-width: 0; }
.phone-row input { flex: 1 1 auto; min-width: 0; }
.bio-btn { width: 100%; margin-top: 12px; }
.bio-note { margin: 10px 0 0; }

.btn { display: inline-flex; align-items: center; justify-content: center; padding: 12px 16px;
  border: none; border-radius: 10px; font-size: 15px; font-weight: 700; cursor: pointer; }
.btn.primary { background: var(--teal); color: #fff; } .btn.primary:hover { background: var(--teal-dark); }
.btn.primary:disabled { opacity: .6; cursor: default; }
.btn.ghost { background: transparent; color: var(--teal); border: 1px solid var(--line); }
.btn.danger { background: transparent; color: var(--error); border: 1px solid var(--error); }
.btn.danger:hover { background: var(--error); color: #fff; }
.btn.danger:disabled { opacity: .6; cursor: default; }
.warn-badge { font-size: 14px; margin-left: 2px; }
.item-warn { border-left: 3px solid var(--warn); }
.pair-actions { display: flex; gap: 10px; flex-wrap: wrap; margin: 4px 0 8px; }
.btn.sm { padding: 8px 12px; font-size: 13px; }
#auth-btn { width: 100%; margin-top: 18px; }

.error { color: var(--error); font-size: 14px; margin: 12px 0 0; }
.alert { background: #fff7ed; border: 1px solid #fed7aa; color: var(--warn); padding: 11px 13px;
  border-radius: 10px; font-size: 14px; margin: 12px 0; font-weight: 600; }

.topbar { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px;
  background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.tabs.small { display: flex; gap: 6px; padding: 6px 0 0; }
.tab { border: none; background: transparent; color: var(--muted); font-weight: 700; font-size: 14px;
  padding: 8px 14px; border-radius: 8px; cursor: pointer; }
.tab.active { background: #e4f5f4; color: var(--teal-dark); }

.main { max-width: 560px; margin: 0 auto; padding: 16px; }
.pane-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.phead { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.back { border: none; background: none; color: var(--teal); font-weight: 700; font-size: 15px;
  padding: 6px 0; cursor: pointer; margin-bottom: 6px; }

.list { display: flex; flex-direction: column; gap: 10px; }
.item { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.item.col { flex-direction: column; align-items: stretch; gap: 10px; }
.item.tap { cursor: pointer; } .item.tap:hover { border-color: var(--teal); }
.chev { color: var(--muted); font-size: 22px; }
.dose-top { display: flex; justify-content: space-between; }
.dose-actions, .med-btns { display: flex; gap: 8px; justify-content: flex-end; }

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(12,51,58,.45); display: flex; align-items: flex-start;
  justify-content: center; padding: 24px 16px; overflow-y: auto; z-index: 20; }
.modal-card { background: var(--card); border-radius: var(--radius); padding: 22px; width: 100%; max-width: 460px;
  box-shadow: 0 12px 40px rgba(0,0,0,.2); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

/* Generate-code / multi-action additions */
.pane-head .head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.section-head h3 { margin: 0; }
.row2 { display: flex; gap: 10px; }
.row2 > label { flex: 1 1 0; min-width: 0; }
.times-wrap { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.time-row { display: flex; align-items: center; gap: 8px; }
.time-row .md-time { flex: 1 1 auto; margin-top: 0; }
.time-row .time-del { flex: 0 0 auto; padding: 10px 12px; line-height: 1; }
.time-add { margin-top: 8px; }
.paircode { font-family: Consolas, 'Courier New', monospace; font-size: 30px; font-weight: 800;
  letter-spacing: 4px; text-align: center; color: var(--brand, #0e7c7b);
  background: rgba(14,124,123,.08); border: 1px dashed rgba(14,124,123,.5);
  border-radius: 12px; padding: 16px 12px; margin: 14px 0; user-select: all; }

/* Adherence summary card (patient detail) */
.row-between{display:flex;align-items:center;justify-content:space-between;gap:8px}
.adh-pct{font-weight:700;font-size:20px;padding:2px 10px;border-radius:12px}
.adh-ok{background:#e6f4ea;color:#137333}
.adh-warn{background:#fef7e0;color:#b06000}
.adh-bad{background:#fce8e6;color:#c5221f}
.adh-stats{display:flex;flex-wrap:wrap;gap:10px;margin-top:8px;font-size:14px;color:#333}
.adh-recent{margin-top:10px;border-top:1px solid #eee;padding-top:8px}
