:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #16181d;
  --muted: #5d6470;
  --border: #d9dde3;
  --accent: #1f5fbf;
  --accent-text: #ffffff;
  --danger: #b42318;
  --danger-bg: #fdecea;
  --ok: #067647;
  --ok-bg: #e7f6ee;
  --warn-bg: #fff6df;
  --warn-border: #e8c46a;
  --code-bg: #eef1f5;
  --warn: #8a5a00;
  --na: #5d6470;
  --na-bg: #eceff3;
  --radius: 8px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111317;
    --surface: #1a1d23;
    --text: #e8eaee;
    --muted: #9aa2ae;
    --border: #2e333c;
    --accent: #5b9bff;
    --accent-text: #0b1220;
    --danger: #ff8a80;
    --danger-bg: #3a1d1b;
    --ok: #6fd6a0;
    --ok-bg: #16301f;
    --warn-bg: #2f2814;
    --warn-border: #7a6320;
    --code-bg: #242833;
    --warn: #f0c060;
    --na: #9aa2ae;
    --na-bg: #242833;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
[hidden] { display: none !important; }
h1, h2 { margin: 0 0 .75rem; line-height: 1.25; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.1rem; }
p { margin: 0 0 .75rem; }
code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .9em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Header */
.bar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem 1rem;
  padding: .5rem 1rem; background: var(--surface); border-bottom: 1px solid var(--border);
}
.bar-title { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; font-weight: 600; min-height: 44px; }
.brand { color: var(--muted); font-weight: 500; }
.sep { color: var(--border); }
.badge {
  font-size: .75rem; font-weight: 600; padding: .1rem .5rem; border-radius: 999px;
  background: var(--code-bg); color: var(--muted); text-transform: uppercase; letter-spacing: .04em;
}
.bar-session { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; min-width: 0; }
.bar-session strong { overflow-wrap: anywhere; }

main { max-width: 1280px; margin: 0 auto; padding: 1rem; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem; margin-bottom: 1rem;
}
.card.narrow { max-width: 480px; margin: 2rem auto; }

/* Forms */
label { display: block; font-weight: 600; margin-bottom: .3rem; }
input[type="text"], input[type="password"], select {
  width: 100%; min-height: 44px; padding: .5rem .75rem; font: inherit; color: var(--text);
  background: var(--bg); border: 1px solid var(--border); border-radius: 6px;
}
input:focus-visible, select:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#sign-in-form input { margin-bottom: .75rem; }
.issue-form { display: flex; flex-direction: column; gap: .75rem; margin-bottom: .5rem; }
.field { min-width: 0; }
.checks { display: flex; flex-direction: column; }
.check { display: flex; align-items: center; gap: .6rem; min-height: 44px; font-weight: 500; margin: 0; cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 0; flex: none; accent-color: var(--accent); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: .5rem 1rem;
  font: inherit; font-weight: 600; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 6px; cursor: pointer;
}
.btn:hover { border-color: var(--muted); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-primary:hover { border-color: var(--accent); filter: brightness(1.08); }
.btn-danger { color: var(--danger); border-color: var(--danger); }
.btn-quiet { border-color: transparent; background: transparent; }

.error { color: var(--danger); background: var(--danger-bg); padding: .5rem .75rem; border-radius: 6px; }
.status { padding: .6rem .9rem; border-radius: 6px; background: var(--ok-bg); color: var(--ok); font-weight: 600; }
.status.is-error { background: var(--danger-bg); color: var(--danger); }

/* One-time reveal */
.reveal { background: var(--warn-bg); border-color: var(--warn-border); }
.secret-row { display: flex; flex-direction: column; gap: .5rem; margin-bottom: .75rem; }
.secret {
  display: block; padding: .75rem; background: var(--code-bg); border-radius: 6px;
  overflow-wrap: anywhere; user-select: all; font-size: .95rem;
}

/* Key list: cards on small screens */
.list-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .5rem; }
.list-head h2 { margin: 0; }
.table-wrap { overflow-x: auto; }
.keys { width: 100%; border-collapse: collapse; }
.keys thead { display: none; }
.keys tr { display: block; border: 1px solid var(--border); border-radius: 6px; padding: .5rem .75rem; margin-bottom: .6rem; }
.keys td { display: flex; justify-content: space-between; gap: 1rem; padding: .3rem 0; text-align: right; overflow-wrap: anywhere; }
.keys td::before { content: attr(data-label); font-weight: 600; color: var(--muted); text-align: left; flex: none; }
.keys td.name { font-weight: 600; }
.keys td.actions { justify-content: flex-end; padding-top: .5rem; }
.keys td.actions::before { content: none; }
.keys tr.revoked { opacity: .65; }
.pill { font-size: .8rem; font-weight: 600; padding: .1rem .5rem; border-radius: 999px; white-space: nowrap; }
.pill.admin { background: var(--warn-bg); color: var(--text); border: 1px solid var(--warn-border); }
.pill.write { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.pill.active { background: var(--ok-bg); color: var(--ok); }
.pill.revoked { background: var(--danger-bg); color: var(--danger); }
.you { font-weight: 500; color: var(--muted); }
.sub { display: block; font-size: .8rem; color: var(--muted); }

/* Dialog: full width on small screens */
dialog {
  width: calc(100% - 2rem); max-width: 440px; padding: 1.25rem; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
dialog::backdrop { background: rgb(0 0 0 / .45); }
.dialog-actions { display: flex; flex-direction: column-reverse; gap: .5rem; }
.dialog-actions .btn { width: 100%; }

/* Page navigation between the admin pages */
.tabs { display: flex; gap: .25rem; margin-bottom: 1rem; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tab {
  display: inline-flex; align-items: center; min-height: 44px; padding: .5rem 1rem; font-weight: 600; color: var(--muted);
  text-decoration: none; border-bottom: 3px solid transparent; white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab[aria-current="page"] { color: var(--text); border-bottom-color: var(--accent); }
.tab:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* Supplier health */
.health-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem 1rem; }
.health-title h1 { margin: 0 0 .25rem; }
.health-title p { margin: 0; }
.chip {
  display: inline-flex; align-items: center; gap: .35rem; font-size: .78rem; font-weight: 600; line-height: 1.4;
  padding: .1rem .5rem; border-radius: 4px; white-space: nowrap;
}
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.chip.correct { color: var(--ok); background: var(--ok-bg); }
.chip.gaps { color: var(--warn); background: var(--warn-bg); }
.chip.failing { color: var(--danger); background: var(--danger-bg); }
.chip.notOffered { color: var(--na); background: var(--na-bg); }
.legend { display: flex; flex-wrap: wrap; gap: .5rem .75rem; margin: 0 0 .75rem; }


.supplier-cards { display: grid; grid-template-columns: 1fr; gap: 1rem; margin-bottom: 1rem; }
.supplier-card { margin: 0; display: flex; flex-direction: column; gap: .6rem; min-width: 0; }
.supplier-card.is-open { border-color: var(--accent); }
.supplier-card header { display: flex; justify-content: space-between; align-items: flex-start; gap: .5rem; }
.supplier-card h2 { margin: 0; font-size: 1.05rem; }
.supplier-card .key { display: block; font-size: .8rem; color: var(--muted); font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; }
.areas { margin: 0; padding: 0; list-style: none; display: grid; gap: .45rem; }
.areas li { display: grid; grid-template-columns: 5.5rem 1fr; gap: .5rem; align-items: start; font-size: .9rem; }
.areas li > b { font-weight: 600; color: var(--muted); }
.areas li > div { display: flex; flex-direction: column; align-items: flex-start; gap: .15rem; min-width: 0; }
.areas small { color: var(--muted); font-size: .82rem; overflow-wrap: anywhere; }
.supplier-card .btn { align-self: flex-start; margin-top: auto; }

.detail { scroll-margin-top: 1rem; }
.detail:focus { outline: none; }
.detail:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.detail-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .5rem; margin-bottom: .5rem; }
.detail-head h2 { margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.area { border-top: 1px solid var(--border); padding-top: .9rem; margin-top: .9rem; min-width: 0; }
.area h3 { margin: 0 0 .5rem; font-size: 1rem; display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.issues { margin: 0 0 .75rem; padding-left: 1.1rem; display: grid; gap: .25rem; font-size: .9rem; overflow-wrap: anywhere; }
.issues .failing { color: var(--danger); }
.issues .info { color: var(--muted); }
.metrics { display: grid; grid-template-columns: 1fr; gap: 0; margin: 0 0 .5rem; font-size: .9rem; }
.metrics div { display: flex; justify-content: space-between; gap: 1rem; padding: .35rem 0; border-bottom: 1px solid var(--border); min-width: 0; }
.metrics dt { color: var(--muted); }
.metrics dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; min-width: 0; }
.metrics dd.is-bad { color: var(--danger); font-weight: 600; }
.metrics dd.is-warn { color: var(--warn); font-weight: 600; }
/* Size examples: label/value cards on small screens, a table from md up */
.examples { width: 100%; border-collapse: collapse; font-size: .85rem; }
.examples thead { display: none; }
.examples tr { display: block; border: 1px solid var(--border); border-radius: 6px; padding: .4rem .75rem; margin-bottom: .5rem; }
.examples td { display: flex; justify-content: space-between; gap: 1rem; padding: .25rem 0; text-align: right; overflow-wrap: anywhere; }
.examples td::before { content: attr(data-label); font: 600 .85rem system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--muted); text-align: left; flex: none; }
.examples td.sizes { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; }
.caps { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .6rem; }
.link-check { margin-top: .5rem; display: grid; gap: .5rem; }
.link-check ul { margin: 0; padding-left: 1.1rem; font-size: .85rem; overflow-wrap: anywhere; display: grid; gap: .2rem; }
.run-error { font-size: .85rem; background: var(--code-bg); padding: .5rem .75rem; border-radius: 6px; overflow-wrap: anywhere; white-space: pre-wrap; margin: 0 0 .5rem; }

@media (min-width: 768px) {
  main { padding: 1.5rem; }
  .supplier-cards { grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 2rem; }
  .examples thead { display: table-header-group; }
  .examples tr { display: table-row; border: 0; padding: 0; margin: 0; }
  .examples th, .examples td { display: table-cell; text-align: left; padding: .4rem .6rem; border-bottom: 1px solid var(--border); vertical-align: top; }
  .examples td::before { content: none; }
  .examples th { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); white-space: nowrap; }
  .issue-form { flex-direction: row; flex-wrap: wrap; align-items: flex-end; }
  .issue-form .grow { flex: 1 1 260px; }
  .issue-form .field:not(.grow) { flex: 0 0 150px; }
  .issue-form .checks { flex: 1 1 100%; flex-direction: row; flex-wrap: wrap; column-gap: 1.5rem; }
  .secret-row { flex-direction: row; align-items: center; }
  .secret-row .secret { flex: 1; }
  .dialog-actions { flex-direction: row; justify-content: flex-end; }
  .dialog-actions .btn { width: auto; }

  .keys thead { display: table-header-group; }
  .keys tr { display: table-row; border: 0; padding: 0; margin: 0; }
  .keys th { text-align: left; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: .5rem .75rem; border-bottom: 1px solid var(--border); }
  .keys td { display: table-cell; text-align: left; padding: .6rem .75rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
  .keys td::before { content: none; }
  .keys td.actions { text-align: right; }
  .keys tbody tr:last-child td { border-bottom: 0; }
}
