:root {
  --ink: #1e293b;
  --ink-soft: #64748b;
  --ink-faint: #94a3b8;
  --line: #e2e8f0;
  --line-soft: #f1f5f9;
  --page: #f6f7f9;
  --card: #fff;
  --brand: #4f46e5;
  --brand-dark: #4338ca;
  --role: #3b82f6;
  --role-dark: #1d4ed8;
  --entity: #16a34a;
  --entity-dark: #15803d;
}

*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font: 15px/1.6 system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--page);
  color: var(--ink);
}

header {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 20px;
  height: 60px;
  position: sticky;
  top: 0;
  z-index: 5;
}

header .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  color: #0f172a;
  text-decoration: none;
  font-size: 16px;
}

header .brand img {
  height: 28px;
  width: auto;
  display: block;
}

header nav {
  display: flex;
  gap: 4px;
  margin-left: 8px;
}

header nav a {
  padding: 6px 12px;
  border-radius: 7px;
  text-decoration: none;
  color: #475569;
  font-size: 14px;
}

header nav a:hover {
  background: var(--line-soft);
  color: #0f172a;
}

header nav a.on {
  background: #eef2ff;
  color: #3730a3;
  font-weight: 600;
}

header .spacer {
  flex: 1;
}

header .who {
  font-size: 13px;
  color: var(--ink-faint);
}

header form {
  margin: 0;
}

header button.out {
  font: inherit;
  font-size: 14px;
  border: 1px solid var(--line);
  background: var(--card);
  color: #475569;
  border-radius: 7px;
  padding: 6px 14px;
  cursor: pointer;
  font-weight: 400;
}

header button.out:hover {
  border-color: #cbd5e1;
  color: #0f172a;
  background: var(--card);
}

main {
  max-width: 56rem;
  margin: 0 auto;
  padding: 28px 24px 72px;
}

main.bare {
  max-width: 28rem;
  padding: 12vh 24px;
  min-height: 100vh;
}

footer {
  max-width: 56rem;
  margin: 0 auto;
  padding: 0 24px 40px;
  color: var(--ink-faint);
  font-size: 13px;
}

footer a {
  color: var(--ink-soft);
}

h1 {
  font-size: 22px;
  margin: 0 0 4px;
}

main h1 {
  font-size: 20px;
  margin: 0 0 18px;
}

p.lead {
  color: var(--ink-soft);
  margin: 0 0 24px;
}

.muted {
  color: var(--ink-faint);
  font-size: 13px;
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 22px 24px;
  margin-bottom: 18px;
}

.panel h2 {
  font-size: 15px;
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
}

.panel h2:not(:first-child) {
  margin-top: 26px;
}

.panel h3 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
  margin: 20px 0 8px;
}

.panel p {
  margin: 0 0 12px;
}

.panel ul {
  margin: 0 0 12px;
  padding-left: 20px;
}

.panel li {
  margin-bottom: 6px;
}

.cards {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 28px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px 22px;
  min-width: 150px;
}

.card .n {
  font-size: 30px;
  font-weight: 600;
  color: #0f172a;
  font-variant-numeric: tabular-nums;
}

.card .k {
  font-size: 13px;
  color: var(--ink-soft);
  margin-top: 2px;
}

main.bare .card {
  padding: 34px 38px;
  text-align: center;
  min-width: 0;
}

main.bare .card img {
  height: 40px;
  margin-bottom: 18px;
}

main.bare .card h1 {
  font-size: 20px;
  margin: 0 0 10px;
}

main.bare .card p {
  color: var(--ink-soft);
  margin: 0 0 22px;
}

a.button,
form button,
.submit,
.actions button {
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  padding: 11px 26px;
  border: 0;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}

a.button:hover,
form button:hover,
.submit:hover,
.actions button:hover {
  background: var(--brand-dark);
}

form button.ghost {
  background: var(--card);
  color: #475569;
  border: 1px solid #cbd5e1;
}

form button.ghost:hover {
  background: #f8fafc;
}

.submit:disabled,
form button:disabled,
.actions button:disabled {
  background: #cbd5e1;
  cursor: not-allowed;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th {
  text-align: left;
  font-weight: 600;
  color: var(--ink-soft);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0 10px 8px 0;
  border-bottom: 1px solid var(--line);
}

td {
  padding: 10px 10px 10px 0;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: top;
}

tr:last-child td {
  border-bottom: 0;
}

td.n {
  font-variant-numeric: tabular-nums;
}

table.facts {
  width: auto;
  margin: 4px 0 0;
}

table.facts th {
  text-transform: none;
  letter-spacing: 0;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-soft);
  white-space: nowrap;
  padding: 7px 22px 7px 0;
  border: 0;
  vertical-align: top;
}

table.facts td {
  padding: 7px 0;
  border: 0;
  color: #0f172a;
  font-weight: 500;
}

table.facts tr + tr th,
table.facts tr + tr td {
  border-top: 1px solid var(--line-soft);
}

.pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  background: var(--line-soft);
  color: #475569;
  margin-right: 4px;
}

.pill.warn {
  background: #fef3c7;
  color: #92400e;
}

.pill.ok {
  background: #dcfce7;
  color: #166534;
}

.pill.off {
  background: #fee2e2;
  color: #991b1b;
}

a.pill {
  text-decoration: none;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 22px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
  font-size: 13px;
  color: var(--ink-soft);
}

.legend li {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
  flex: none;
  border: 1px solid rgba(0, 0, 0, 0.12);
}

.dot.role { background: var(--role); }
.dot.entity { background: var(--entity); }
.dot.missed { background: #fcd34d; }
.dot.bad { background: #fca5a5; }
.dot.ok { background: #86efac; }
.dot.warn { background: #fcd34d; }
.dot.off { background: #fca5a5; }

.bar {
  height: 6px;
  border-radius: 3px;
  background: var(--line);
  overflow: hidden;
  min-width: 90px;
  margin-top: 5px;
}

.bar span {
  display: block;
  height: 100%;
  background: var(--brand);
}

form label {
  display: block;
  margin-bottom: 16px;
  font-size: 14px;
  color: #334155;
  font-weight: 600;
}

form input[type="text"],
form input[type="number"],
form textarea,
form select {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 9px 11px;
  font: inherit;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-weight: 400;
}

form input:focus,
form textarea:focus,
form select:focus {
  outline: 2px solid #c7d2fe;
  border-color: #818cf8;
}

form input.other {
  margin-top: 8px;
}

form input.other[hidden] {
  display: none;
}

fieldset {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px;
  margin: 0 0 16px;
}

legend {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
  font-weight: 600;
  padding: 0 6px;
}

.checks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
}

.checks.stack {
  flex-direction: column;
  gap: 8px;
}

label.check {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  font-weight: 400;
  font-size: 14px;
}

.error {
  color: #b91c1c;
  font-size: 14px;
}

p.error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  padding: 10px 14px;
  border-radius: 8px;
}

/* Labelling & Context Elements */
details.help {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 10px;
  margin: 0 0 22px;
  font-size: 14px;
  padding: 0;
}

details.help summary {
  padding: 12px 18px;
  cursor: pointer;
  font-weight: 600;
  color: #92400e;
  list-style: none;
}

details.help summary::-webkit-details-marker {
  display: none;
}

details.help summary::after {
  content: " \25BE";
  opacity: 0.6;
}

details.help[open] summary::after {
  content: " \25B4";
}

details.help ul {
  margin: 0;
  padding: 0 18px 14px 36px;
}

details.help li {
  margin-bottom: 4px;
  color: #78350f;
}

.context {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px 20px;
  margin-bottom: 22px;
}

.context .field {
  margin-bottom: 12px;
}

.context .field:last-child {
  margin-bottom: 0;
}

.context .name {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ink-faint);
  margin-bottom: 3px;
}

.context .value {
  white-space: pre-wrap;
}

#widget {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 22px 24px;
}

#widget label {
  font-weight: 400;
  margin-bottom: 10px;
}

#widget label:last-child {
  margin-bottom: 0;
}

.actions {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-top: 20px;
}

.passage {
  font-size: 17px;
  line-height: 2.4;
}

.passage.pick {
  cursor: text;
  user-select: text;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px;
}

.passage.pick mark {
  border-radius: 4px;
  padding: 3px 5px;
  cursor: pointer;
  background: #fde68a;
  font-weight: 600;
}

.passage.pick mark.role {
  background: var(--role);
  color: #fff;
  box-shadow: 0 0 0 1px var(--role-dark);
}

.passage.pick mark.entity {
  background: var(--entity);
  color: #fff;
  box-shadow: 0 0 0 1px var(--entity-dark);
}

.modes {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.mode {
  font: inherit;
  font-size: 14px;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid #cbd5e1;
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
  font-weight: 400;
}

.mode:hover {
  background: #f8fafc;
}

.mode.role.on {
  background: var(--role);
  color: #fff;
  border-color: var(--role-dark);
  font-weight: 600;
}

.mode.entity.on {
  background: var(--entity);
  color: #fff;
  border-color: var(--entity-dark);
  font-weight: 600;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 14px 0;
}

.chip {
  background: #eef2ff;
}

.exam-notes {
  background-color: #fff8e6;
  border-left: 4px solid #f59e0b;
  padding: 12px 16px 12px 32px;
  margin: 16px 0;
  border-radius: 4px;
  line-height: 1.6;
}

.exam-notes li {
  margin-bottom: 8px;
}

.exam-notes li:last-child {
  margin-bottom: 0;
}