/* Prescription Refill Manager, powered by Authoritize.
   Brand: ink #0A0A0A, paper #FAFAF7, coral #D85A30, pill #FAECE7 / #993C1D, system font stack. */
:root {
  --ink: #0a0a0a;
  --ink-2: #4a4a48;
  --ink-3: #77766f;
  --paper: #fafaf7;
  --card: #ffffff;
  --line: #e6e4dc;
  --coral: #d85a30;
  --coral-deep: #993c1d;
  --coral-tint: #faece7;
  --red: #b42318;
  --red-tint: #fdecea;
  --amber: #8a5a00;
  --amber-tint: #fdf3dc;
  --green: #1f6f43;
  --green-tint: #e6f4ec;
  --radius: 10px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-size: 15px;
  line-height: 1.45;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; background: var(--paper); }
a { color: var(--ink); }
h1 { font-size: 24px; font-weight: 600; letter-spacing: -0.3px; margin: 0 0 4px; }
h2 { font-size: 17px; font-weight: 600; margin: 28px 0 10px; display: flex; align-items: center; gap: 8px; }
h3 { font-size: 15px; font-weight: 600; margin: 0; }
p { margin: 0 0 10px; }
.muted { color: var(--ink-3); }
.small { font-size: 13px; }

/* top bar */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 12px 24px; background: var(--card); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand img { border-radius: 7px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-weight: 600; font-size: 15px; letter-spacing: -0.2px; }
.brand-sub { font-size: 12px; color: var(--ink-3); }
.brand-auth { color: var(--coral-deep); font-weight: 500; }
.nav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.nav a, .nav .link { padding: 6px 10px; border-radius: 8px; text-decoration: none; color: var(--ink-2); font-size: 14px; }
.nav a:hover, .nav .link:hover { background: var(--paper); color: var(--ink); }
.nav a.on { background: var(--coral-tint); color: var(--coral-deep); font-weight: 500; }
.clinic-name { font-weight: 600; font-size: 14px; margin-right: 8px; padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px; }
.main { flex: 1; width: 100%; max-width: 1120px; margin: 0 auto; padding: 24px; }
.footer { padding: 16px 24px; font-size: 12px; color: var(--ink-3); text-align: center; }

/* cards + tables */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.card.narrow { max-width: 440px; margin: 40px auto; }
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-weight: 500; color: var(--ink-3); font-size: 12px; text-transform: uppercase; letter-spacing: 0.4px;
  padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; white-space: nowrap; }
.empty { padding: 18px; color: var(--ink-3); }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }

/* badges */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.badge.red { background: var(--red-tint); color: var(--red); }
.badge.amber { background: var(--amber-tint); color: var(--amber); }
.badge.green { background: var(--green-tint); color: var(--green); }
.badge.grey { background: #efeee9; color: var(--ink-2); }
.count { font-size: 13px; font-weight: 500; color: var(--ink-3); }

/* forms */
form.inline { display: inline; margin: 0; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; }
.field-label { font-size: 13px; font-weight: 500; color: var(--ink-2); }
.hint { font-size: 12px; color: var(--ink-3); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=search], select, textarea {
  font: inherit; padding: 8px 10px; border: 1px solid #d6d4cb; border-radius: 8px; background: #fff; color: var(--ink); width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--coral); outline-offset: 0; border-color: var(--coral); }
textarea { min-height: 120px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 16px; }
.btn, button.btn { display: inline-flex; align-items: center; gap: 6px; font: inherit; font-size: 14px; font-weight: 500; padding: 8px 14px;
  border-radius: 8px; border: 1px solid var(--ink); background: var(--ink); color: #fff; text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn:hover { background: #2a2a28; }
.btn.secondary { background: #fff; color: var(--ink); border-color: #d6d4cb; }
.btn.secondary:hover { background: var(--paper); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.danger { background: #fff; color: var(--red); border-color: #f0c4bf; }
button.link { background: none; border: none; font: inherit; cursor: pointer; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }

/* messages */
.flash { background: var(--green-tint); color: var(--green); padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; }
.error { background: var(--red-tint); color: var(--red); padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; }
.notice { background: var(--coral-tint); color: var(--coral-deep); padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; }
.preview { background: var(--paper); border: 1px dashed #d6d4cb; border-radius: 8px; padding: 10px 14px; margin-bottom: 14px; font-size: 14px; }
.preview strong { font-weight: 600; }
.secret { font-family: ui-monospace, Menlo, monospace; letter-spacing: 1px; background: var(--paper); padding: 6px 10px; border-radius: 6px; word-break: break-all; }
.qr svg { width: 200px; height: 200px; }
.summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 16px 0; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.stat b { display: block; font-size: 24px; font-weight: 600; }
.stat span { font-size: 13px; color: var(--ink-3); }
.stat.red b { color: var(--red); }
details summary { cursor: pointer; color: var(--ink-2); font-size: 14px; }

@media (max-width: 640px) {
  .topbar, .main { padding: 12px 16px; }
  .brand-name { font-size: 14px; }
  td, th { padding: 8px; }
}

/* spacing and width utilities (inline style attributes are blocked by the CSP) */
.mb-14 { margin-bottom: 14px; }
.mt-10 { margin-top: 10px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mt-8 { margin-top: 8px; }
.w-150 { max-width: 150px; }
.w-160 { max-width: 160px; }
.w-180 { max-width: 180px; }
.w-320 { max-width: 320px; }
.w-560 { max-width: 560px; }
.w-640 { max-width: 640px; }
.w-720 { max-width: 720px; }
.mb-8 { margin-bottom: 8px; }
.std-group { border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px 4px; margin: 0 0 12px; }
.std-group legend { font-weight: 600; font-size: 13px; padding: 0 6px; }
.std-item { display: flex; gap: 10px; align-items: flex-start; padding: 6px 0; font-size: 14px; cursor: pointer; }
.std-item input { margin-top: 3px; }
