/* MedPin admin.
 *
 * The same palette as the clinic app — #003399 accent, the contrast-repaired
 * neutrals — so the two read as one product. Utilitarian throughout: this is a
 * panel one person operates a few times a week, not something to be impressed
 * by, and the only thing worth making loud is which practices are waiting.
 */
:root {
  --ground: #f7f9fc;
  --surface: #ffffff;
  --surface-sub: #eef2f8;
  --ink: #111827;
  --ink-muted: #545e72;
  --ink-faint: #69738a;
  --line: #dde3ec;
  --line-soft: #e9edf4;
  --accent: #003399;
  --accent-tint: #ebf1fb;
  --danger: #b91c1c;
  --danger-tint: #fdecec;
  --warn: #b45309;
  --warn-tint: #fef6e7;
  --ok: #076b3c;
  --ok-tint: #e7f5ee;
  --shadow: 0 6px 18px rgba(11, 27, 58, 0.05);
  --r: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ground: #0c111a;
    --surface: #141b26;
    --surface-sub: #1b2430;
    --ink: #e8ecf3;
    --ink-muted: #a3adbf;
    --ink-faint: #8791a4;
    --line: #26303e;
    --line-soft: #1e2733;
    --accent: #7fa8f0;
    --accent-tint: #16233b;
    --danger: #f1928c;
    --danger-tint: #2c1719;
    --warn: #e0a857;
    --warn-tint: #2a2015;
    --ok: #62bc8d;
    --ok-tint: #12241c;
    --shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1 { font-size: 1.5rem; font-weight: 600; letter-spacing: -0.015em; margin: 0; }
h2 { font-size: 1.15rem; font-weight: 600; margin: 0 0 0.35rem; }
p { margin: 0; }

code, .mono, .num {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
}

/* --- chrome ----------------------------------------------------------- */
.bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.85rem clamp(1rem, 4vw, 2.5rem);
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.brand { display: flex; align-items: baseline; gap: 0.45rem; }
.brand strong { letter-spacing: -0.02em; }
.brand span {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.13em;
  color: var(--ink-faint);
}
.who { display: flex; align-items: center; gap: 0.9rem; font-size: 0.85rem; color: var(--ink-muted); }

.page { max-width: 62rem; margin: 0 auto; padding: clamp(1.5rem, 4vw, 3rem) clamp(1rem, 4vw, 2.5rem) 5rem; }
.narrow { max-width: 24rem; }
.lede { color: var(--ink-muted); max-width: 60ch; }

.head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.1rem; }

/* --- tabs and filters --------------------------------------------------- */
.tabs { display: flex; gap: 0.3rem; margin-bottom: 1.75rem; border-bottom: 1px solid var(--line); }
.tab {
  background: none; border: 0; border-bottom: 2px solid transparent;
  padding: 0.5rem 0.85rem; margin-bottom: -1px;
  font: inherit; color: var(--ink-muted); cursor: pointer;
}
.tab.is-on { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }

.filters { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 1.25rem; }
.chip {
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
  padding: 0.28rem 0.8rem; font: inherit; font-size: 0.85rem;
  color: var(--ink-muted); cursor: pointer;
}
.chip.is-on { border-color: var(--accent); color: var(--accent); background: var(--accent-tint); }

/* --- the list ----------------------------------------------------------- */
.list { display: flex; flex-direction: column; gap: 0.75rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  padding: 1.1rem 1.25rem;
}
/* A practice waiting on the operator is the only thing here worth shouting
   about, so it gets the one loud treatment on the page. */
.card.waiting { border-left: 3px solid var(--warn); }

.card .top { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.card .name { font-weight: 600; }
.card .meta {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.78rem; color: var(--ink-faint); margin-top: 0.15rem;
}
.card .actions { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.9rem; }

.badges { display: flex; gap: 0.35rem; flex-wrap: wrap; }
.badge {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.7rem; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase;
  padding: 0.12rem 0.42rem; border-radius: 3px; white-space: nowrap;
}
.badge.ok { color: var(--ok); background: var(--ok-tint); }
.badge.warn { color: var(--warn); background: var(--warn-tint); }
.badge.bad { color: var(--danger); background: var(--danger-tint); }
.badge.mute { color: var(--ink-faint); background: var(--surface-sub); }

/* --- controls ----------------------------------------------------------- */
button { font: inherit; cursor: pointer; border-radius: 8px; }
button:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

.primary {
  background: var(--accent); color: #fff; border: 1px solid var(--accent);
  padding: 0.5rem 1rem; font-weight: 500;
}
.ghost {
  background: transparent; color: var(--ink-muted); border: 1px solid var(--line);
  padding: 0.4rem 0.8rem;
}
.danger {
  background: var(--danger); color: #fff; border: 1px solid var(--danger);
  padding: 0.5rem 1rem; font-weight: 500;
}
.small { padding: 0.32rem 0.7rem; font-size: 0.85rem; }
button[disabled] { opacity: 0.55; cursor: not-allowed; }

label { display: block; margin: 0.9rem 0 0.25rem; font-size: 0.85rem; color: var(--ink-muted); }
.opt { color: var(--ink-faint); font-weight: 400; }
input, textarea {
  width: 100%; font: inherit; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 8px; padding: 0.5rem 0.7rem;
}
textarea { resize: vertical; }

form .primary, form .danger { margin-top: 1.1rem; }

.error {
  color: var(--danger); background: var(--danger-tint);
  border-radius: 6px; padding: 0.5rem 0.7rem; margin-top: 0.9rem; font-size: 0.9rem;
}

/* --- table -------------------------------------------------------------- */
.scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: 0.9rem; }
th, td { text-align: left; padding: 0.55rem 0.9rem; border-bottom: 1px solid var(--line-soft); }
thead th {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.09em;
  color: var(--ink-faint); font-weight: 500;
  background: var(--surface-sub); border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
tbody tr:last-child td { border-bottom: 0; }

/* --- dialogs and toast --------------------------------------------------- */
dialog {
  border: 1px solid var(--line); border-radius: var(--r);
  background: var(--surface); color: var(--ink);
  padding: 1.4rem 1.5rem; max-width: 28rem; width: calc(100% - 2rem);
  box-shadow: 0 18px 48px rgba(11, 27, 58, 0.18);
}
dialog::backdrop { background: rgba(11, 27, 58, 0.35); }
dialog menu { display: flex; justify-content: flex-end; gap: 0.5rem; padding: 0; margin: 1.3rem 0 0; }

.toast {
  position: fixed; left: 50%; bottom: 1.5rem; transform: translateX(-50%);
  background: var(--ink); color: var(--ground);
  padding: 0.6rem 1rem; border-radius: 8px; font-size: 0.9rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25); z-index: 10;
}

.empty { color: var(--ink-muted); padding: 2rem 0; }

@media (max-width: 34rem) {
  .card .top { flex-direction: column; }
  .head { flex-direction: column; align-items: flex-start; }
}

/* An audit change, read as a diff rather than two values. */
.diff { white-space: nowrap; }
.diff s { color: var(--ink-faint); text-decoration-thickness: 1px; }
.diff b { color: var(--ink); font-weight: 600; }

/* ------------------------------------------------------------------ account */

/* A button that reads as a link. Underlined rather than only coloured: at this
 * size and weight the accent alone is close to failing on the muted ground, and
 * "lost the password" is exactly the control somebody is scanning for. */
.link {
  display: block; margin: 0.9rem 0 0; padding: 0;
  background: none; border: 0; color: var(--accent);
  font-size: 0.9rem; text-decoration: underline; text-underline-offset: 3px;
}

/* Six digits, tracked apart so a transposition is visible while typing. */
.code {
  max-width: 9rem;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 1.15rem; letter-spacing: 0.28em;
}

/* Not a modal and not a toast: it stays until the thing it names is fixed. */
.nag {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  margin-bottom: 1.5rem; padding: 0.85rem 1rem;
  border: 1px solid var(--warn); border-left-width: 3px;
  border-radius: var(--r); background: var(--warn-tint);
  font-size: 0.9rem; color: var(--ink);
}
.nag strong { display: block; }

.facts {
  display: grid; grid-template-columns: max-content 1fr; gap: 0.35rem 1.5rem;
  margin: 0 0 1.75rem; font-size: 0.9rem;
}
.facts dt { color: var(--ink-muted); }
.facts dd { margin: 0; }

.panel {
  padding: 1.25rem; margin-bottom: 1rem;
  border: 1px solid var(--line); border-radius: var(--r);
  background: var(--surface); box-shadow: var(--shadow);
}
.panel .lede { margin-bottom: 0.5rem; font-size: 0.9rem; }

/* The setup key. Wraps rather than scrolls — it is being copied by eye onto a
 * phone, and a line that runs off the edge is where that goes wrong. */
.key {
  display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap;
  margin: 0.75rem 0; padding: 0.75rem 0.9rem;
  border: 1px dashed var(--line); border-radius: 8px; background: var(--surface-sub);
}
.key code { font-size: 1rem; word-break: break-all; user-select: all; }

.row { display: flex; gap: 0.5rem; margin-top: 1.1rem; }
.row .primary, .row .danger { margin-top: 0; }

@media (max-width: 34rem) {
  .nag { flex-direction: column; align-items: flex-start; }
  .facts { grid-template-columns: 1fr; gap: 0 0; }
  .facts dd { margin-bottom: 0.6rem; }
}
