/* The admin dashboard. Rules ported from the approved mockup (mockups/accounts/admin.html with
   vendor/presenter/presenter.css, shared/mockup.css and shared/components.css), theme tokens only.
   Calm and dense; the only motion is the standard content change, and none with reduced motion. */
@font-face {
  font-family: 'Atkinson Hyperlegible';
  src: url('/admin/assets/atkinson-hyperlegible-latin-400-normal.woff2') format('woff2');
  font-weight: 400;
}
@font-face {
  font-family: 'Atkinson Hyperlegible';
  src: url('/admin/assets/atkinson-hyperlegible-latin-700-normal.woff2') format('woff2');
  font-weight: 700;
}

/* Base, as the app. */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
html { scrollbar-color: var(--line) transparent; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 17px/1.5 'Atkinson Hyperlegible', system-ui, sans-serif;
  display: flex;
  flex-direction: column;
}
h1, h2, h3, p, ol, ul { margin: 0; padding: 0; }
ol, ul { list-style: none; }
h1 { font-size: 34px; line-height: 1.15; }
h2 { font-size: 21px; line-height: 1.25; }
a { color: var(--accent); }
code { font: inherit; }
.wordmark { font-weight: 700; display: flex; align-items: center; gap: 8px; }
.soft { color: var(--soft); }
.small { font-size: 15px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack-tight { display: flex; flex-direction: column; gap: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.mk-sprite { display: none; }

/* Controls. */
button, input, select, textarea { font: inherit; }
button {
  min-height: 44px; padding: 0 16px; border: 1.5px solid var(--line); border-radius: 10px;
  background: var(--bg); color: var(--ink); cursor: pointer;
}
button:hover { border-color: var(--ink); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 22px; border: 0; border-radius: 10px;
  background: var(--accent); color: var(--on-accent); font-weight: 700; text-decoration: none; cursor: pointer;
}
.btn:hover { background: var(--accent); }
.btn.btn-quiet { background: transparent; color: var(--accent); box-shadow: inset 0 0 0 2px var(--accent); }
.btn.btn-quiet:hover { background: var(--tint); }
button.link { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0 14px; border: 0; background: transparent; color: var(--soft); }
button.link:hover { color: var(--ink); }
.mk-quiet-link { display: inline-flex; align-items: center; min-height: 44px; padding: 0 14px; color: var(--soft); }
.mk-quiet-link:hover { color: var(--ink); }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid var(--accent); outline-offset: 2px;
}
input::placeholder, textarea::placeholder { color: var(--soft); opacity: 1; }
.mk-skip { position: absolute; left: 12px; top: -60px; z-index: 40; padding: 10px 16px; border-radius: 10px; background: var(--accent); color: var(--on-accent); font-weight: 700; }
.mk-skip:focus { top: 12px; }

/* Icons: one line set in the text colour. */
.mk-icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; vertical-align: -4px; }
.mk-line { display: flex; align-items: center; gap: 10px; }
.mk-nowrap { white-space: nowrap; }
.mk-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.mk-note { padding: 12px 16px; border-radius: 10px; background: var(--hold-tint); color: var(--ink); }
.mk-note.good { background: var(--tint); }
.mk-note.good > .mk-icon { color: var(--good); }
.mk-section { display: flex; flex-direction: column; gap: 14px; padding: 20px 22px; border: 1.5px solid var(--line); border-radius: 18px; background: var(--bg); }
.mk-section h2 { font-size: 21px; line-height: 1.25; }
.mk-facts { display: flex; flex-direction: column; gap: 10px; }
.mk-facts > div { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.mk-facts dt { color: var(--soft); }
.mk-facts dd { margin: 0; font-weight: 700; }
.mk-wording { padding: 14px 16px; border-radius: 10px; background: var(--panel); }
.mk-check { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.mk-check input { width: 20px; height: 20px; accent-color: var(--accent); }

/* The frame: the side menu and the desk. */
.frame { flex: 1; min-height: 0; display: flex; }
.script { flex: 0 0 270px; min-width: 0; display: flex; flex-direction: column; padding: 28px 16px; background: var(--panel); overflow-y: auto; }
.script .wordmark { margin: 0 12px 10px; color: var(--soft); }
#steps { display: flex; flex-direction: column; gap: 1px; font-size: 15px; }
#steps .mk-nav {
  display: flex; align-items: center; justify-content: flex-start; gap: 10px; width: 100%; min-height: 36px;
  padding: 0 12px; border-radius: 8px; color: var(--ink); text-decoration: none;
}
#steps .mk-nav .mk-icon { width: 18px; height: 18px; }
#steps .mk-nav:hover { background: var(--bg); }
#steps .mk-nav[aria-current='page'] { background: var(--tint); color: var(--ink); font-weight: 700; }
.mk-who { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; margin-top: auto; padding: 16px 12px 0; }
.mk-who button.link { padding: 0; }
.desk { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; gap: 20px; padding: 24px clamp(20px, 4vw, 56px); }
.mk-desk { gap: 0; padding-top: 0; }
.mk-desk-content { display: flex; flex-direction: column; gap: 18px; max-width: 980px; min-width: 0; padding-bottom: 32px; }
.mk-desk-content > header { padding-top: 8px; }
@media (min-width: 761px) { .frame .desk { overflow-y: auto; } }

/* The top bar: search, flags, who is signed in. */
.mk-topbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 16px;
  margin: 0 calc(-1 * clamp(20px, 4vw, 56px)) 24px; padding: 12px clamp(20px, 4vw, 56px);
  border-bottom: 1.5px solid var(--line); background: var(--bg);
}
.mk-top-search { flex: 0 1 420px; }
.mk-top-search .mk-tf__box { min-height: 44px; }
.mk-kbd { display: grid; place-items: center; min-width: 24px; height: 24px; padding: 0 6px; border: 1.5px solid var(--line); border-radius: 7px; color: var(--soft); font: inherit; font-size: 13px; }
.mk-top-end { display: flex; align-items: center; gap: 14px; }
.mk-icon-btn {
  position: relative; display: grid; place-items: center; width: 44px; min-height: 44px; padding: 0;
  border: 1.5px solid var(--line); border-radius: 12px; background: var(--bg); color: var(--ink);
}
.mk-icon-btn:hover { border-color: var(--ink); }
.mk-dot {
  position: absolute; top: -6px; right: -6px; display: grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px;
  border-radius: 999px; background: var(--hold); color: var(--bg); font-size: 12px; font-weight: 700;
}
.mk-me { display: inline-flex; align-items: center; gap: 8px; font-size: 15px; }
.mk-avatar { display: grid; place-items: center; flex: none; width: 32px; height: 32px; border-radius: 50%; background: var(--tint); color: var(--accent); font-size: 14px; font-weight: 700; }

/* Text fields: a label, an icon, a hint or count under. */
.mk-tf { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.mk-tf__label { font-weight: 700; }
.mk-tf__box {
  display: flex; align-items: center; gap: 8px; min-height: 48px; padding: 0 6px 0 14px;
  border: 1.5px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--soft);
}
.mk-tf__box:focus-within { border-color: var(--accent); }
.mk-tf__box input, .mk-tf__box textarea, .mk-tf__box select {
  flex: 1; padding: 0; min-width: 0; min-height: 44px; border: 0; outline: 0; background: transparent; color: var(--ink); font: inherit;
}
.mk-tf__box input:focus-visible, .mk-tf__box textarea:focus-visible, .mk-tf__box select:focus-visible { outline: 0; }
.mk-tf__box textarea { padding: 12px 8px 12px 0; resize: vertical; min-height: 96px; }
.mk-tf__box:has(textarea) { align-items: stretch; padding-left: 14px; }
.mk-tf__foot { display: flex; gap: 12px; font-size: 14px; color: var(--soft); }
.mk-tf__count { margin-left: auto; font-variant-numeric: tabular-nums; }
.mk-search { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; max-width: 560px; }
.mk-grow { flex: 1 1 320px; }
.mk-narrow { max-width: 720px; }
.mk-choice { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
input.mk-amount { flex: none; width: 120px; min-height: 36px; padding: 0 10px; border: 1.5px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--ink); }
.mk-plan-fields { display: grid; align-items: end; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }

/* Switch: a real checkbox with role="switch". */
.mk-switch { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; cursor: pointer; }
.mk-switch__text { display: grid; gap: 2px; min-width: 0; }
.mk-switch__desc { font-size: 14px; color: var(--soft); }
.mk-switch__control { position: relative; display: grid; place-items: center; flex: none; height: 28px; }
.mk-switch input { position: absolute; inset: -6px; width: calc(100% + 12px); height: calc(100% + 12px); margin: 0; opacity: 0; cursor: inherit; }
.mk-switch__track { position: relative; display: block; width: 44px; height: 26px; border-radius: 999px; background: var(--line); pointer-events: none; }
.mk-switch__thumb { position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 999px; background: var(--bg); }
.mk-switch input:checked + .mk-switch__track { background: var(--accent); }
.mk-switch input:checked + .mk-switch__track .mk-switch__thumb { transform: translateX(18px); background: var(--on-accent); }
.mk-switch input:focus-visible + .mk-switch__track { outline: 3px solid var(--accent); outline-offset: 2px; }

/* Tabs (underline style; links to each tab) and filter chips. */
.mk-tabs { display: flex; gap: 24px; border-bottom: 1.5px solid var(--line); overflow-x: auto; }
.mk-tabs [role='tab'] {
  position: relative; display: inline-flex; align-items: center; min-height: 44px; padding: 0 2px;
  border: 0; border-radius: 0; background: transparent; color: var(--soft); white-space: nowrap; text-decoration: none;
}
.mk-tabs [role='tab'][aria-selected='true'] { color: var(--ink); font-weight: 700; }
.mk-tabs [role='tab'][aria-selected='true']::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; border-radius: 3px; background: var(--accent); }
.mk-tabs .mk-n {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px; margin-left: 6px; padding: 0 6px;
  border-radius: 999px; background: var(--hold-tint); color: var(--ink); font-size: 13px; font-weight: 700;
}
.mk-panel { display: flex; flex-direction: column; gap: 14px; }
.mk-panel > * { min-width: 0; }
.mk-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.mk-chips a {
  display: inline-flex; align-items: center; min-height: 36px; padding: 0 14px;
  border: 1.5px solid var(--line); border-radius: 999px; color: var(--ink); font-size: 15px; text-decoration: none;
}
.mk-chips a:hover { border-color: var(--ink); }
.mk-chips a[aria-current='page'] { border-color: var(--accent); background: var(--tint); font-weight: 700; }
.mk-chips .mk-icon { margin-right: 4px; }
.mk-chips .mk-n { margin-left: 6px; color: var(--soft); font-variant-numeric: tabular-nums; }

/* Tables: calm and dense. */
.mk-table { position: relative; width: 100%; border-collapse: collapse; font-size: 15px; }
.mk-table th { text-align: left; font-weight: 400; color: var(--soft); font-size: 14px; padding: 8px 12px 8px 0; border-bottom: 1.5px solid var(--line); }
.mk-table td { padding: 10px 12px 10px 0; border-bottom: 1px solid var(--line); vertical-align: middle; }
.mk-table button.link { min-height: 32px; padding: 0; color: var(--accent); }
.mk-section .mk-table { font-size: 14px; }
.mk-ref { font-variant-numeric: tabular-nums; letter-spacing: .02em; white-space: nowrap; }
.mk-between { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
@media (max-width: 760px) { .mk-table { display: block; overflow-x: auto; } }

/* Flags: what the service caught on its own, until an admin resolves it with a note. */
.mk-flag { display: flex; align-items: flex-start; gap: 12px; padding: 14px 18px; border-radius: 14px; background: var(--hold-tint); color: var(--ink); }
.mk-flag > .mk-icon { flex: none; margin-top: 3px; color: var(--hold); }
.mk-flag[data-state='resolved'] { background: var(--panel); }
.mk-flag[data-state='resolved'] > .mk-icon { color: var(--good); }
.mk-flag-tag {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px;
  background: var(--hold-tint); color: var(--ink); font-size: 13px; white-space: nowrap; vertical-align: 1px;
}
.mk-flag-tag .mk-icon { width: 14px; height: 14px; color: var(--hold); vertical-align: 0; }
.mk-tags-row { display: inline-flex; flex-wrap: wrap; gap: 4px; }

/* The overview's figures and the log's tools. */
.mk-seg { display: inline-flex; gap: 2px; padding: 3px; border-radius: 12px; background: var(--panel); }
.mk-seg a { display: inline-flex; align-items: center; min-height: 36px; padding: 0 14px; border-radius: 10px; color: var(--soft); font-size: 15px; text-decoration: none; }
.mk-seg a[aria-current='page'] { background: var(--bg); color: var(--ink); font-weight: 700; box-shadow: 0 0 0 1.5px var(--line); }
.mk-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); border: 1.5px solid var(--line); border-radius: 14px; background: var(--bg); overflow: hidden; }
.mk-kpi { display: flex; flex-direction: column; gap: 6px; padding: 16px 20px; box-shadow: -1px 0 0 var(--line), 0 -1px 0 var(--line); }
.mk-kpi-value { display: flex; align-items: center; gap: 10px; font-size: 28px; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.mk-settings { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; align-items: start; max-width: 980px; }
.mk-grid-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px 20px; margin: 0; }
.mk-grid-facts dt { font-size: 14px; color: var(--soft); }
.mk-grid-facts dd { margin: 2px 0 0; font-weight: 700; overflow-wrap: anywhere; }
.mk-log-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.mk-type { display: inline-block; padding: 2px 8px; border-radius: 999px; background: var(--panel); font-size: 13px; white-space: nowrap; }
.mk-pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }

/* Sheets. Without the script a sheet is a card in the page; with it, a dialog over a dimmed page. */
.ob-sheet-card {
  border: 1px solid var(--line); width: min(100%, 640px); max-height: 100%; overflow-y: auto;
  background: var(--bg); color: var(--ink); border-radius: 18px; padding: 26px 28px; display: flex; flex-direction: column; gap: 14px;
}
.ob-sheet-card h2 { font-size: 24px; }
.ob-sheet-card .mk-actions { padding-top: 6px; }
.ob-dim { position: fixed; inset: 0; z-index: 20; background: color-mix(in srgb, var(--ink) 55%, transparent); display: grid; place-items: end center; padding: 20px; }
:root[data-theme='dark'] .ob-dim { background: color-mix(in srgb, var(--bg) 66%, transparent); }

/* The gate: signing in and the code step, one centred column. */
.mk-web { flex: 1 1 auto; overflow-y: auto; background: var(--bg); }
.mk-web-main { max-width: 640px; margin: 0 auto; padding: 28px 20px 48px; display: flex; flex-direction: column; gap: 18px; }
.mk-web-main .wordmark { color: var(--soft); }
.mk-web-main h1 { font-size: clamp(28px, 6vw, 40px); }
.mk-web .btn { width: 100%; }
.mk-setup { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.mk-setup .stack-tight { flex: 1 1 240px; }
.mk-qr { display: block; width: 180px; height: 180px; flex: none; border-radius: 12px; }
.mk-key { font-size: 20px; font-weight: 700; letter-spacing: .08em; overflow-wrap: anywhere; }
.mk-code { max-width: 280px; }
.mk-code input { font-size: 22px; letter-spacing: .2em; font-variant-numeric: tabular-nums; }
@media (min-width: 560px) { .mk-web .btn { width: auto; } }

/* Phone width: the side menu becomes one scrolling row on top. */
@media (max-width: 760px) {
  .frame { flex-direction: column; overflow-y: auto; }
  .frame .script { display: block; flex: none; padding: 12px 16px 4px; overflow: auto hidden; }
  .frame #steps { flex-direction: row; gap: 4px; }
  .frame .mk-nav { white-space: nowrap; }
  .frame .mk-who { display: none; }
  .mk-topbar { position: static; margin: 0 -16px 16px; padding: 10px 16px; }
  .desk { padding: 0 16px; }
  .mk-me-text, .mk-kbd { display: none; }
}

/* Motion, only when welcome: new content rises in once, and a sheet slides up. */
@media (prefers-reduced-motion: no-preference) {
  @keyframes ob-rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
  @keyframes ob-sheet { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
  .mk-desk-content > *, .mk-web-main > * { animation: ob-rise .24s ease-out backwards; }
  .ob-dim .ob-sheet-card { animation: ob-sheet .22s ease-out; }
  .mk-switch__track { transition: background-color 200ms ease; }
  .mk-switch__thumb { transition: transform 260ms cubic-bezier(0.22, 1, 0.36, 1); }
}

/* The overview: figures and the two panels. */
.mk-delta { padding: 2px 8px; border-radius: 999px; font-size: 13px; }
.mk-delta:empty { display: none; }
.mk-delta[data-tone='good'] { background: var(--tint); color: var(--ink); }
.mk-delta[data-tone='bad'] { background: var(--hold-tint); color: var(--ink); }
.mk-cs { display: flex; flex-direction: column; border: 1.5px solid var(--line); border-radius: 14px; background: var(--bg); }
.mk-cs__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; }
.mk-cs__head strong { display: inline-flex; align-items: center; gap: 8px; }
.mk-cs__head span { font-size: 14px; color: var(--soft); }
.mk-cs dl { margin: 0; }
.mk-cs dl > div { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 18px; border-top: 1px solid var(--line); }
.mk-cs dt { color: var(--ink); }
.mk-cs dd { margin: 0; display: inline-flex; align-items: center; gap: 8px; color: var(--soft); text-align: right; }
.mk-cs__trend { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 7px; background: var(--panel); color: var(--soft); font-size: 13px; font-weight: 700; }
.mk-cs__trend[data-tone='good'] { background: var(--tint); color: var(--good); }
.mk-cs__trend[data-tone='bad'] { background: var(--hold-tint); color: var(--hold); }
.mk-cs a.link { display: inline-flex; align-items: center; min-height: 32px; color: var(--accent); }
