/*
  The one stylesheet of the server-rendered pages (internal/web): the admin console (its data
  pages' classes follow the shared ones) and the firm panel (its classes are at the end). The
  Content-Security-Policy allows no script, no inline style and no other origin, so every style
  lives here and only system fonts are used. Light and dark follow prefers-color-scheme; the
  tokens match the public site (web/assets/css/site.css).
*/

:root {
  color-scheme: light dark;
  --bg: #f3f6fa;
  --surface: #ffffff;
  --text: #17202a;
  --muted: #485666;
  --brand: #1f5fa8;
  --brand-strong: #164a85;
  --on-brand: #ffffff;
  --border: #d5dde7;
  --error-bg: #fdecea;
  --error-border: #b3261e;
  --focus: #b35c00;
  --chip-bg: #fff1d6;
  --chip-text: #6b3d00;
  --chip-border: #d99a2b;
  --warn-bg: #fdecea;
  --warn-text: #8c1d18;
  --notice-bg: #e8f1fb;
  --danger: #b3261e;
  --danger-strong: #8c1d18;
  --row-alt: #f7f9fc;
  --radius: 0.75rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e141b;
    --surface: #18212c;
    --text: #e7edf3;
    --muted: #a9b6c4;
    --brand: #82b4f0;
    --brand-strong: #a9cbf5;
    --on-brand: #0e141b;
    --border: #2b3746;
    --error-bg: #3a1d1b;
    --error-border: #f2b8b5;
    --focus: #ffb15c;
    --chip-bg: #3a2a10;
    --chip-text: #ffd89a;
    --chip-border: #b9852e;
    --warn-bg: #3a1d1b;
    --warn-text: #f9c9c5;
    --notice-bg: #172b42;
    --danger: #f2b8b5;
    --danger-strong: #f9dedc;
    --row-alt: #1c2734;
  }
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.5;
}

.top {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.75rem;
  align-items: baseline;
  padding: 0.875rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand {
  font-weight: 700;
  color: var(--brand);
}

.surface {
  color: var(--muted);
}

.page {
  max-width: 32rem;
  margin: 2.5rem auto;
  padding: 0 1rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}

h1 {
  margin: 0 0 0.75rem;
  font-size: 1.5rem;
  line-height: 1.25;
}

p {
  margin: 0 0 1rem;
}

.muted {
  color: var(--muted);
}

.link {
  color: var(--brand);
}

.link:hover {
  color: var(--brand-strong);
}

.notice-error {
  margin: 0 0 1rem;
  padding: 0.75rem 1rem;
  border-left: 4px solid var(--error-border);
  border-radius: 0.25rem;
  background: var(--error-bg);
}

form {
  margin: 0;
}

label {
  display: block;
  margin-bottom: 0.375rem;
  font-weight: 600;
}

.code-input {
  display: block;
  width: 100%;
  max-width: 12rem;
  margin-bottom: 1rem;
  padding: 0.625rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: var(--bg);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 1.5rem;
  letter-spacing: 0.25em;
}

.button {
  display: inline-block;
  padding: 0.625rem 1.25rem;
  border: 2px solid var(--brand);
  border-radius: 0.5rem;
  background: var(--brand);
  color: var(--on-brand);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.button:hover {
  background: var(--brand-strong);
  border-color: var(--brand-strong);
}

.button-secondary {
  background: transparent;
  color: var(--brand);
}

.button-secondary:hover {
  background: transparent;
  color: var(--brand-strong);
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

/* The admin console's data pages (internal/admin): the navigation, wide pages with tables, tags,
   the facts lists, the search and filter forms, and the extraction kill switch. */

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  align-items: baseline;
}

.nav-link {
  color: var(--text);
  text-decoration: none;
  border-bottom: 2px solid transparent;
}

.nav-link:hover {
  color: var(--brand);
}

.nav-current {
  color: var(--brand);
  border-bottom-color: var(--brand);
  font-weight: 600;
}

.nav-logout {
  margin-left: auto;
}

.page-wide {
  max-width: 72rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

h2 {
  margin: 0 0 0.75rem;
  font-size: 1.25rem;
  line-height: 1.3;
}

h3 {
  margin: 1.25rem 0 0.5rem;
  font-size: 1rem;
}

.small {
  font-size: 0.875rem;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

/* A short value that reads as one token (a RUC, a date and time) keeps to one line; its table
   scrolls inside .table-wrap instead. */
.nowrap {
  white-space: nowrap;
  overflow-wrap: normal;
}

.nowrap {
  white-space: nowrap;
}

.notice {
  margin: 0 0 1rem;
  padding: 0.75rem 1rem;
  border-left: 4px solid var(--brand);
  border-radius: 0.25rem;
  background: var(--notice-bg);
}

.page-wide > .notice {
  margin: 0;
}

.table-wrap {
  overflow-x: auto;
  margin: 0 0 1rem;
}

.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9375rem;
}

.data th,
.data td {
  padding: 0.5rem 0.625rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.data th {
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 600;
  white-space: nowrap;
}

.data tbody tr:nth-child(even) {
  background: var(--row-alt);
}

.data .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.tag {
  display: inline-block;
  padding: 0 0.5rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
}

.tag-warn {
  border-color: var(--danger);
  background: var(--warn-bg);
  color: var(--warn-text);
}

.facts {
  display: grid;
  grid-template-columns: minmax(10rem, max-content) 1fr;
  gap: 0.375rem 1.25rem;
  margin: 0 0 1rem;
}

.facts dt {
  color: var(--muted);
}

.facts dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

.search-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: flex-start;
}

.search-row .text-input {
  flex: 1 1 18rem;
  width: auto;
  margin-bottom: 0.5rem;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0 0 1rem;
}

.chip-link {
  padding: 0.25rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  text-decoration: none;
}

.chip-link:hover {
  border-color: var(--brand);
  color: var(--brand);
}

.chip-current {
  border-color: var(--brand);
  background: var(--brand);
  color: var(--on-brand);
}

.chip-current:hover {
  color: var(--on-brand);
}

/* The console's bar charts (internal/admin/chart): inline SVG whose looks come only from these
   classes, with the numbers as a table under a disclosure. */
.chart-figure {
  margin: 0 0 1.5rem;
}

.chart-figure figcaption {
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.chart {
  display: block;
  width: 100%;
  height: auto;
  max-height: 14rem;
}

.chart-bar {
  fill: var(--brand);
}

.chart-axis {
  stroke: var(--border);
  stroke-width: 1;
}

.chart-label {
  fill: var(--muted);
  font-size: 12px;
}

.chart-table summary {
  cursor: pointer;
  color: var(--brand);
  margin-top: 0.25rem;
}

.filter-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0 1rem;
  align-items: flex-end;
}

.field {
  flex: 1 1 12rem;
}

.field-submit {
  flex: 0 0 auto;
  margin-bottom: 1rem;
}

.number-input {
  max-width: 14rem;
}

.check {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 1rem;
  font-weight: 400;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
}

.pager {
  margin: 0 0 1rem;
}

.home-links {
  margin: 0 0 1rem;
  padding-left: 1.25rem;
}

.home-links li {
  margin-bottom: 0.375rem;
}

.meta {
  display: inline-block;
  margin-right: 0.5rem;
}

.kill {
  border-left: 6px solid var(--brand);
}

.kill-off {
  border-left-color: var(--danger);
}

.kill-state {
  font-size: 1.0625rem;
}

.button-danger {
  border-color: var(--danger);
  background: var(--danger);
  color: var(--on-brand);
}

.button-danger:hover {
  border-color: var(--danger-strong);
  background: var(--danger-strong);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

select.text-input {
  max-width: 24rem;
}

/* The firm panel (internal/panel): the Beta chip, who is signed in, the provider buttons and the
   beta note in the footer. */

.chip {
  display: inline-block;
  padding: 0 0.5rem;
  border: 1px solid var(--chip-border);
  border-radius: 999px;
  background: var(--chip-bg);
  color: var(--chip-text);
  font-size: 0.8125rem;
  font-weight: 700;
  line-height: 1.5;
}

.who {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.75rem;
  align-items: baseline;
  margin-left: auto;
  min-width: 0;
}

.who-name {
  overflow-wrap: anywhere;
}

.inline {
  display: inline;
}

.button-link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--brand);
  font: inherit;
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
}

.button-link:hover {
  color: var(--brand-strong);
}

.providers {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin: 0 0 1rem;
}

.providers .button {
  text-align: center;
}

.dev-login {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.text-input {
  display: block;
  width: 100%;
  margin-bottom: 1rem;
  padding: 0.625rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

.reference {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.foot {
  max-width: 32rem;
  margin: 0 auto 2.5rem;
  padding: 0 1rem;
  color: var(--muted);
  font-size: 0.875rem;
}

/* The firm panel's working pages: the workspace navigation, the picker, codes and the message to
   copy, row actions, a client's sources and the choices of a form. */

.notice > p:last-child,
.notice-error > p:last-child {
  margin-bottom: 0;
}

/* A wide page's cards may shrink below their tables' width (the tables scroll inside
   .table-wrap), so a phone never scrolls the whole page sideways. */
.page-wide > * {
  min-width: 0;
}

.source .actions {
  margin-bottom: 1rem;
}

/* On a phone a facts list stacks each value under its label. */
@media (max-width: 40rem) {
  .facts {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .facts dd {
    margin-bottom: 0.625rem;
  }
}

.ws-nav p {
  margin: 0;
}

.ws-nav .ws-name {
  margin-bottom: 0.5rem;
  overflow-wrap: anywhere;
}

.pick-list {
  margin: 0 0 1.25rem;
  padding: 0;
  list-style: none;
}

.pick-list li {
  padding: 0.625rem 0;
  border-bottom: 1px solid var(--border);
  overflow-wrap: anywhere;
}

.code-display {
  margin: 0 0 1rem;
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: 0.15em;
}

.message {
  min-height: 8rem;
  resize: vertical;
}

.tag-muted {
  opacity: 0.75;
}

.row-actions {
  white-space: nowrap;
}

.row-actions .inline {
  margin-left: 0.75rem;
}

.danger-link,
.button-link.danger-link {
  color: var(--danger);
}

.danger-link:hover,
.button-link.danger-link:hover {
  color: var(--danger-strong);
}

.source {
  padding: 1rem 0;
  border-top: 1px solid var(--border);
}

.source h3 {
  margin-top: 0;
  overflow-wrap: anywhere;
}

.choices {
  margin: 0 0 1rem;
  padding: 0.75rem 1rem 0;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
}

.choices legend {
  padding: 0 0.25rem;
  font-weight: 600;
}

.text-input.compact {
  display: inline-block;
  width: auto;
  margin: 0 0.5rem 0 0;
  padding: 0.25rem 0.5rem;
}
