/* Appyverse admin — one stylesheet.
   Navy rail, off-white workspace, teal for actions, marigold only for "look here" (environment, review queue).
   Bricolage Grotesque for headings, Atkinson Hyperlegible for everything else. */

/* ---------- Fonts ---------- */
@font-face {
  font-family: "Bricolage Grotesque";
  src: url("/fonts/BricolageGrotesque-normal-500_800.woff2") format("woff2");
  font-weight: 500 800;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Atkinson Hyperlegible";
  src: url("/fonts/AtkinsonHyperlegible-normal-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Atkinson Hyperlegible";
  src: url("/fonts/AtkinsonHyperlegible-normal-700.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Atkinson Hyperlegible";
  src: url("/fonts/AtkinsonHyperlegible-italic-400.woff2") format("woff2");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

/* ---------- Tokens ---------- */
:root {
  --navy: #16224a;
  --teal: #23977f;
  --marigold: #eba334;
  --offwhite: #f3f5ff;

  --canvas: #f3f5fb;
  --surface: #ffffff;
  --surface-2: #f6f8fc;
  --ink: #16224a;
  --ink-soft: #46527c;
  --ink-faint: #637096;
  --line: #d3dbea;
  --line-soft: #e5eaf3;
  --row-hover: #eef3fb;
  --action: #138a78;
  --action-hover: #0e6e60;
  --action-ink: #ffffff;
  --focus: #7b4fb0;
  --danger: #b4283f;
  --danger-hover: #951f33;
  --danger-soft: #fbeaed;
  --warn-ink: #7a4d00;
  --warn-soft: #fdf0d8;
  --ok-ink: #0b6656;
  --ok-soft: #dff2ec;
  --info-ink: #2b3c7a;
  --info-soft: #e5eaf8;
  --neutral-ink: #4d587d;
  --neutral-soft: #eceff6;

  --rail: #16224a;
  --rail-ink: #e9edfa;
  --rail-ink-soft: #a9b3d6;
  --rail-hover: #1f2d5c;
  --rail-active: #26366c;
  --rail-line: #2a3a6e;

  --band: #eba334;
  --band-ink: #16224a;

  --shadow-pop: 0 1px 0 rgb(22 34 74 / 0.05), 0 18px 48px -16px rgb(22 34 74 / 0.4);
  --radius-s: 5px;
  --radius-m: 8px;
  --radius-l: 12px;

  --font-display: "Bricolage Grotesque", ui-sans-serif, system-ui, sans-serif;
  --font-body: "Atkinson Hyperlegible", ui-sans-serif, system-ui, sans-serif;
  color-scheme: light;
}

/* Dark: the brand navy, deepened. Never black. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --canvas: #101935;
    --surface: #16214a;
    --surface-2: #1a2654;
    --ink: #e8edf8;
    --ink-soft: #b0bad6;
    --ink-faint: #8f9ac0;
    --line: #2c3b6a;
    --line-soft: #22305e;
    --row-hover: #1d2a58;
    --action: #2db39c;
    --action-hover: #4cc8b2;
    --action-ink: #0b1a2e;
    --focus: #c3a0f5;
    --danger: #ff8096;
    --danger-hover: #ff9eb0;
    --danger-soft: #3a1f3a;
    --warn-ink: #f5c76f;
    --warn-soft: #3a3020;
    --ok-ink: #6fdcc6;
    --ok-soft: #173b45;
    --info-ink: #b8c6ff;
    --info-soft: #233266;
    --neutral-ink: #b0bad6;
    --neutral-soft: #24305c;
    --rail: #0b1330;
    --rail-hover: #16214a;
    --rail-active: #1f2d5e;
    --rail-line: #1e2a55;
    --shadow-pop: 0 1px 0 rgb(0 0 0 / 0.2), 0 18px 48px -16px rgb(0 0 0 / 0.7);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --canvas: #101935;
  --surface: #16214a;
  --surface-2: #1a2654;
  --ink: #e8edf8;
  --ink-soft: #b0bad6;
  --ink-faint: #8f9ac0;
  --line: #2c3b6a;
  --line-soft: #22305e;
  --row-hover: #1d2a58;
  --action: #2db39c;
  --action-hover: #4cc8b2;
  --action-ink: #0b1a2e;
  --focus: #c3a0f5;
  --danger: #ff8096;
  --danger-hover: #ff9eb0;
  --danger-soft: #3a1f3a;
  --warn-ink: #f5c76f;
  --warn-soft: #3a3020;
  --ok-ink: #6fdcc6;
  --ok-soft: #173b45;
  --info-ink: #b8c6ff;
  --info-soft: #233266;
  --neutral-ink: #b0bad6;
  --neutral-soft: #24305c;
  --rail: #0b1330;
  --rail-hover: #16214a;
  --rail-active: #1f2d5e;
  --rail-line: #1e2a55;
  --shadow-pop: 0 1px 0 rgb(0 0 0 / 0.2), 0 18px 48px -16px rgb(0 0 0 / 0.7);
  color-scheme: dark;
}

/* ---------- Base ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}
html,
body {
  height: 100%;
}
body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  min-width: 1024px;
}
[hidden] {
  display: none !important;
}
a {
  color: var(--action);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
  text-underline-offset: 2px;
}
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 3px;
}
h1,
h2,
h3 {
  font-family: var(--font-display);
  color: var(--ink);
  margin: 0;
  letter-spacing: -0.01em;
}
h1 {
  font-size: 26px;
  font-weight: 700;
  line-height: 1.15;
}
h2 {
  font-size: 18px;
  font-weight: 650;
  line-height: 1.25;
}
h3 {
  font-size: 15px;
  font-weight: 650;
}
p {
  margin: 0;
}
kbd {
  font-family: var(--font-body);
  font-size: 11.5px;
  border: 1px solid currentColor;
  border-radius: 4px;
  padding: 0 4px;
  opacity: 0.85;
}
.muted {
  color: var(--ink-faint);
}
.soft {
  color: var(--ink-soft);
}
.small {
  font-size: 12.5px;
}
.nowrap {
  white-space: nowrap;
}
.prewrap {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.boot {
  padding: 48px;
  color: var(--ink-faint);
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }
}

/* ---------- Brand mark ---------- */
.mark {
  width: 28px;
  height: 28px;
  flex: none;
  overflow: visible;
}
.mark-lg {
  width: 44px;
  height: 44px;
}
.mark-tile {
  fill: var(--teal);
}
.mark-moon {
  fill: var(--marigold);
}
.mark-ring {
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
}
.mark-ring-gap {
  fill: none;
  stroke: var(--rail);
  stroke-width: 3.8;
}
.signin .mark-ring-gap {
  stroke: var(--surface);
}

/* ---------- Buttons and fields ---------- */
.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font: inherit;
  font-weight: 700;
  font-size: 13.5px;
  line-height: 1;
  min-height: 32px;
  padding: 0 12px;
  border-radius: var(--radius-s);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover {
  border-color: var(--ink-faint);
  text-decoration: none;
}
.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.btn-primary {
  background: var(--action);
  border-color: var(--action);
  color: var(--action-ink);
}
.btn-primary:hover {
  background: var(--action-hover);
  border-color: var(--action-hover);
}
.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}
:root[data-theme="dark"] .btn-danger {
  color: #2a0d16;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .btn-danger {
    color: #2a0d16;
  }
}
.btn-danger:hover {
  background: var(--danger-hover);
  border-color: var(--danger-hover);
}
.btn-danger-quiet {
  color: var(--danger);
}
.btn-danger-quiet:hover {
  border-color: var(--danger);
}
.btn-small {
  min-height: 26px;
  padding: 0 9px;
  font-size: 12.5px;
}
.btn-block {
  width: 100%;
  min-height: 38px;
}
.btn-link {
  appearance: none;
  border: 0;
  background: none;
  padding: 0;
  font: inherit;
  color: var(--action);
  cursor: pointer;
}
.btn-link:hover {
  text-decoration: underline;
}
.input,
.select,
.textarea {
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  min-height: 32px;
  padding: 5px 9px;
}
.input:focus,
.select:focus,
.textarea:focus {
  outline: 2px solid var(--focus);
  outline-offset: 0;
  border-color: transparent;
}
.textarea {
  width: 100%;
  min-height: 88px;
  resize: vertical;
  line-height: 1.45;
}
.sub-head {
  margin: 22px 0 8px;
}
.gap {
  height: 16px;
}
.field-help.block {
  display: block;
  margin-top: 2px;
}
.field-label {
  display: block;
  font-weight: 700;
  margin: 0 0 6px;
}
.field-help {
  color: var(--ink-faint);
  font-size: 12.5px;
  margin-top: 6px;
}
.form-error {
  color: var(--danger);
  background: var(--danger-soft);
  border-radius: var(--radius-s);
  padding: 8px 10px;
  margin-top: 12px;
}
.check {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  cursor: pointer;
}
.check input {
  margin-top: 3px;
  accent-color: var(--danger);
}

/* ---------- Sign-in ---------- */
.signin {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 40px 16px;
}
.signin-card {
  width: 380px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  padding: 28px;
  box-shadow: var(--shadow-pop);
}
.signin-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
  color: var(--ink);
}
.signin-title {
  font-size: 22px;
}
.signin-env:not(:empty) {
  margin-top: 4px;
  display: inline-block;
  font-weight: 700;
  font-size: 12.5px;
  color: var(--band-ink);
  background: var(--band);
  border-radius: 999px;
  padding: 1px 9px;
}
.signin-card .input {
  width: 100%;
  min-height: 38px;
}
.signin-card .btn-block {
  margin-top: 18px;
}

/* ---------- App shell ---------- */
.app {
  display: grid;
  grid-template-columns: 224px minmax(0, 1fr);
  height: 100vh;
}
.rail {
  background: var(--rail);
  color: var(--rail-ink);
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
  overflow-y: auto;
}
.rail-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--rail-ink);
  padding: 4px 8px;
  border-radius: var(--radius-s);
}
.rail-brand:hover {
  text-decoration: none;
}
.rail-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15.5px;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.env-tag {
  margin: 12px 8px 4px;
  align-self: flex-start;
  font-weight: 700;
  font-size: 12.5px;
  border-radius: 999px;
  padding: 2px 10px;
  background: var(--band);
  color: var(--band-ink);
}
.env-tag:empty {
  display: none;
}
.env-tag.is-prod {
  background: var(--danger);
  color: #fff;
}
.rail-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 14px;
}
.rail-nav a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--rail-ink-soft);
  padding: 7px 10px;
  border-radius: var(--radius-s);
  font-weight: 700;
}
.rail-nav a:hover {
  color: var(--rail-ink);
  background: var(--rail-hover);
  text-decoration: none;
}
.rail-nav a[aria-current="page"] {
  color: var(--rail-ink);
  background: var(--rail-active);
  box-shadow: inset 3px 0 0 var(--teal);
}
.rail-nav a:focus-visible,
.rail .btn:focus-visible,
.theme-switch button:focus-visible,
.rail-brand:focus-visible {
  outline-color: var(--marigold);
}
.nav-count {
  background: var(--marigold);
  color: var(--navy);
  font-size: 12px;
  border-radius: 999px;
  padding: 0 7px;
  line-height: 18px;
  min-width: 20px;
  text-align: center;
}
.rail-foot {
  margin-top: auto;
  padding-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.rail-hint,
.rail-session {
  color: var(--rail-ink-soft);
  font-size: 12px;
  padding: 0 4px;
}
.theme-switch {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border: 1px solid var(--rail-line);
  border-radius: var(--radius-s);
  padding: 2px;
  gap: 2px;
}
.theme-switch button {
  appearance: none;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: var(--rail-ink-soft);
  font: inherit;
  font-size: 12px;
  padding: 4px 0;
  cursor: pointer;
}
.theme-switch button[aria-checked="true"] {
  background: var(--rail-active);
  color: var(--rail-ink);
  font-weight: 700;
}
.btn-rail {
  background: transparent;
  border-color: var(--rail-line);
  color: var(--rail-ink);
}
.btn-rail:hover {
  border-color: var(--rail-ink-soft);
}

.work {
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100vh;
}
/* The environment band: the one place marigold fills a whole strip. */
.env-band {
  flex: none;
  background: var(--band);
  color: var(--band-ink);
  font-weight: 700;
  font-size: 13px;
  padding: 5px 28px;
}
.env-band.is-prod {
  background: var(--danger);
  color: #fff;
}
.main {
  flex: 1;
  overflow-y: auto;
  padding: 20px 28px 64px;
  outline: none;
}
.crumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--ink-faint);
  font-size: 13px;
  margin-bottom: 8px;
}
.crumbs a {
  color: var(--ink-soft);
}
.crumbs .sep {
  color: var(--line);
}
.crumbs [aria-current] {
  color: var(--ink);
  max-width: 50ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Page header ---------- */
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}
.page-head .sub {
  color: var(--ink-soft);
  margin-top: 4px;
}
.page-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.title-row {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}
.title-row h1 {
  overflow-wrap: anywhere;
}
.title-pills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 6px;
}

/* ---------- Sections ---------- */
.section {
  margin-top: 28px;
}
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.section-head .count {
  color: var(--ink-faint);
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 14px;
  margin-left: 6px;
}
.section-note {
  color: var(--ink-soft);
  margin: -4px 0 10px;
  max-width: 80ch;
}
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
}
.panel-pad {
  padding: 14px 16px;
}
.two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

/* ---------- Toolbar ---------- */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}
.toolbar .search {
  width: 300px;
}
.toolbar .grow {
  flex: 1;
}
.toolbar-label {
  color: var(--ink-soft);
  font-size: 13px;
}
.seg {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  background: var(--surface);
  padding: 2px;
  gap: 2px;
}
.seg button {
  appearance: none;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 13px;
  color: var(--ink-soft);
  padding: 4px 10px;
  border-radius: 3px;
  cursor: pointer;
}
.seg button:hover {
  color: var(--ink);
}
.seg button[aria-pressed="true"] {
  background: var(--ink);
  color: var(--surface);
  font-weight: 700;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: 999px;
  padding: 2px 4px 2px 10px;
  font-size: 13px;
}
.chip button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  font: inherit;
  padding: 0 6px;
  border-radius: 999px;
}
.chip button:hover {
  background: var(--line-soft);
  color: var(--ink);
}

/* Tabs (Marketplace) */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 14px;
}
.tabs a {
  padding: 8px 12px;
  color: var(--ink-soft);
  font-weight: 700;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tabs a:hover {
  color: var(--ink);
  text-decoration: none;
}
.tabs a[aria-current="page"] {
  color: var(--ink);
  border-bottom-color: var(--action);
}

/* ---------- Tables ---------- */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  /* clip, not auto: a scroll container here would stop the sticky header from sticking to the page. */
  overflow: clip;
}
table.data {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13.5px;
}
table.data th,
table.data td {
  padding: 7px 12px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--line-soft);
}
table.data thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-2);
  color: var(--ink-soft);
  font-weight: 700;
  font-size: 12.5px;
  border-bottom: 1px solid var(--line);
}
table.data tbody tr:last-child td {
  border-bottom: 0;
}
table.data tbody tr:hover td {
  background: var(--row-hover);
}
table.data tr.is-link {
  cursor: pointer;
}
table.data tr.is-muted td {
  color: var(--ink-faint);
}
table.data .num {
  text-align: right;
  white-space: nowrap;
}
table.data td.clip {
  max-width: 38ch;
}
table.data td.clip-wide {
  max-width: 60ch;
}
table.data .cell-main {
  font-weight: 700;
  color: var(--ink);
  overflow-wrap: break-word;
}
table.data td:first-child:not(.num) {
  min-width: 17ch;
}
table.data a.cell-main {
  color: var(--ink);
}
table.data a.cell-main:hover {
  color: var(--action);
}
table.data .cell-sub {
  color: var(--ink-faint);
  font-size: 12.5px;
  overflow-wrap: break-word;
}
table.data tfoot td {
  background: var(--surface-2);
  font-weight: 700;
  border-top: 1px solid var(--line);
  border-bottom: 0;
}
.lines {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.truncate-3 {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}
.row-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}
.list-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  color: var(--ink-faint);
  font-size: 13px;
}

/* ---------- States ---------- */
.state {
  padding: 28px 20px;
  text-align: center;
  color: var(--ink-soft);
}
.state strong {
  display: block;
  color: var(--ink);
  font-size: 15px;
  margin-bottom: 4px;
}
.state .btn {
  margin-top: 12px;
}
.state-error strong {
  color: var(--danger);
}
.loading {
  color: var(--ink-faint);
  padding: 20px 0;
}
.loading::after {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-left: 8px;
  border: 2px solid var(--line);
  border-top-color: var(--action);
  border-radius: 50%;
  vertical-align: -1px;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.inline-error {
  color: var(--danger);
  background: var(--danger-soft);
  border-radius: var(--radius-s);
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

/* ---------- Pills: text plus a shape, so colour is never the only signal ---------- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 700;
  line-height: 1;
  padding: 4px 8px 4px 7px;
  border-radius: 999px;
  white-space: nowrap;
  background: var(--neutral-soft);
  color: var(--neutral-ink);
}
.pill::before {
  content: "";
  width: 7px;
  height: 7px;
  flex: none;
  background: currentColor;
  border-radius: 50%;
}
.pill-ok {
  background: var(--ok-soft);
  color: var(--ok-ink);
}
.pill-warn {
  background: var(--warn-soft);
  color: var(--warn-ink);
}
.pill-warn::before {
  border-radius: 1px;
  transform: rotate(45deg) scale(0.9);
}
.pill-bad {
  background: var(--danger-soft);
  color: var(--danger);
}
.pill-bad::before {
  border-radius: 1px;
}
.pill-info {
  background: var(--info-soft);
  color: var(--info-ink);
}
.pill-info::before {
  background: linear-gradient(90deg, currentColor 50%, transparent 50%);
  border: 1.5px solid currentColor;
  width: 8px;
  height: 8px;
}
.pill-neutral::before {
  background: transparent;
  border: 1.5px solid currentColor;
}
.pill-plain::before {
  display: none;
}
.pill-plain {
  padding-left: 8px;
}

/* ---------- Ledger (label left, number right) ---------- */
.ledgers {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}
.ledger {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  padding: 12px 16px 8px;
}
.ledger h3 {
  margin-bottom: 6px;
}
.ledger dl {
  margin: 0;
}
.ledger .row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 5px 0;
  border-top: 1px solid var(--line-soft);
}
.ledger .row:first-child {
  border-top: 0;
}
.ledger dt {
  color: var(--ink-soft);
}
.ledger dd {
  margin: 0;
  font-weight: 700;
  text-align: right;
  white-space: nowrap;
}
.ledger .row.is-total dd,
.ledger .row.is-total dt {
  color: var(--ink);
  font-weight: 700;
}
.ledger .row.is-alert dd {
  color: var(--danger);
}

/* Facts strip on detail pages */
.facts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  margin: 0;
  overflow: hidden;
}
.facts > div {
  padding: 10px 14px;
  border-right: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
  min-width: 0;
}
.facts dt {
  color: var(--ink-faint);
  font-size: 12.5px;
  margin-bottom: 2px;
}
.facts dd {
  margin: 0;
  overflow-wrap: anywhere;
}
.idcopy {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
}
.idcopy code {
  font-family: var(--font-body);
  font-size: 12.5px;
  color: var(--ink-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.idcopy button {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink-soft);
  border-radius: 4px;
  font: inherit;
  font-size: 11.5px;
  padding: 0 6px;
  cursor: pointer;
  flex: none;
}
.idcopy button:hover {
  color: var(--ink);
  border-color: var(--ink-faint);
}

/* ---------- Overview ---------- */
.queue {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border: 1px solid var(--line);
  border-left: 6px solid var(--marigold);
  background: var(--surface);
  border-radius: var(--radius-m);
  padding: 16px 20px;
  margin-bottom: 20px;
}
.queue.is-clear {
  border-left-color: var(--teal);
}
.queue-main {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 22px;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.queue-main:hover {
  color: var(--action);
}
.queue-side {
  display: flex;
  gap: 18px;
  color: var(--ink-soft);
}
.queue-side a {
  font-weight: 700;
}

/* ---------- Appy icon ---------- */
.appy-icon {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  flex: none;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 26px;
  color: #fff;
  background: var(--teal);
  overflow: hidden;
}
.appy-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.appy-icon.c-marigold {
  background: #f0a92e;
  color: #16224a;
}
.appy-icon.c-teal {
  background: #138a78;
}
.appy-icon.c-plum {
  background: #7b4fb0;
}
.appy-icon.c-leaf {
  background: #4e9f45;
}
.appy-icon.sm {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  font-size: 15px;
}

/* First request / quoted user text */
.quote {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--teal);
  border-radius: var(--radius-m);
  padding: 12px 16px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 320px;
  overflow-y: auto;
  max-width: 100ch;
}

/* Lists of words (devices, hosts) */
.taglist {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.tag {
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0 6px;
  font-size: 12.5px;
  background: var(--surface-2);
  overflow-wrap: anywhere;
}
.sensitive {
  margin: 0;
  padding: 0;
  list-style: none;
}
.sensitive li {
  padding: 4px 0 4px 20px;
  position: relative;
}
.sensitive li::before {
  content: "!";
  position: absolute;
  left: 0;
  top: 5px;
  width: 14px;
  height: 14px;
  border-radius: 3px;
  background: var(--warn-soft);
  color: var(--warn-ink);
  font-weight: 700;
  font-size: 11px;
  line-height: 14px;
  text-align: center;
}

/* ---------- Moderation actions (Appy detail) ---------- */
.moderation {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  overflow: hidden;
}
.moderation > div {
  padding: 14px 16px;
  border-right: 1px solid var(--line-soft);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.moderation > div:last-child {
  border-right: 0;
}
.moderation p {
  color: var(--ink-soft);
  flex: 1;
}
.moderation .btn {
  align-self: flex-start;
}

/* ---------- Costs ---------- */
.estimate-note {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  color: var(--ink-soft);
  background: var(--info-soft);
  border-radius: var(--radius-s);
  padding: 8px 12px;
  margin-bottom: 12px;
  max-width: 100ch;
}
.estimate-note strong {
  color: var(--info-ink);
}
.totals {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  margin-bottom: 12px;
  overflow: hidden;
}
.totals > div {
  padding: 10px 14px;
  border-right: 1px solid var(--line-soft);
}
.totals > div:last-child {
  border-right: 0;
}
.totals dt {
  color: var(--ink-soft);
  font-size: 12.5px;
}
.totals dd {
  margin: 2px 0 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 19px;
}
.totals .hint {
  color: var(--ink-faint);
  font-size: 12px;
}

/* ---------- Marketplace review ---------- */
.review-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(300px, 1fr);
  gap: 24px;
  align-items: start;
}
.preview {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  padding: 20px;
}
.preview-head {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 16px;
}
.preview-head h2 {
  font-size: 22px;
  overflow-wrap: anywhere;
}
.preview-meta {
  color: var(--ink-soft);
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin-top: 2px;
}
.preview h3 {
  margin: 18px 0 6px;
}
.preview .body {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-width: 75ch;
}
.viewer {
  border-radius: var(--radius-m);
  outline-offset: 3px;
}
.viewer-stage {
  position: relative;
  aspect-ratio: 16 / 10;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  overflow: hidden;
  display: grid;
  place-items: center;
}
.viewer-stage img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.viewer-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
}
.thumbs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.thumbs button {
  appearance: none;
  flex: none;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 5px;
  background: var(--surface-2);
  width: 72px;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  cursor: pointer;
}
.thumbs button img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.thumbs button[aria-current="true"] {
  border-color: var(--action);
}
.side-stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: 0;
}
.decide {
  border: 1px solid var(--line);
  border-left: 6px solid var(--marigold);
  background: var(--surface);
  border-radius: var(--radius-m);
  padding: 14px 16px;
}
.decide.is-done {
  border-left-color: var(--line);
}
.decide .btns {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}
.kv {
  margin: 0;
}
.kv > div {
  display: grid;
  grid-template-columns: 168px minmax(0, 1fr);
  gap: 10px;
  padding: 6px 0;
  border-top: 1px solid var(--line-soft);
}
.kv > div:first-child {
  border-top: 0;
}
.kv dt {
  color: var(--ink-soft);
}
.kv dd {
  margin: 0;
  overflow-wrap: anywhere;
}
.compare {
  width: 100%;
}
.compare td {
  width: 40%;
}
.compare td.field {
  width: 20%;
}
.changed-mark {
  margin-left: 6px;
}

/* Stars as text, so they read correctly aloud */
.stars {
  white-space: nowrap;
  color: var(--warn-ink);
  letter-spacing: 1px;
}
.stars .off {
  color: var(--line);
}

/* ---------- Dialog ---------- */
dialog.dlg {
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  padding: 0;
  width: min(560px, calc(100vw - 32px));
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-pop);
}
dialog.dlg::backdrop {
  background: rgb(10 16 40 / 0.5);
}
.dlg-head {
  padding: 18px 20px 0;
}
.dlg-head h2 {
  font-size: 19px;
}
.dlg-body {
  padding: 12px 20px 4px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.dlg-body .consequence {
  margin: 0;
  padding: 10px 12px 10px 30px;
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-s);
}
.dlg-body .consequence li + li {
  margin-top: 4px;
}
.dlg-body .consequence.is-danger {
  background: var(--danger-soft);
  border-color: transparent;
}
.dlg-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px 20px 18px;
}
.dlg-result {
  border-left: 4px solid var(--action);
  padding: 4px 0 4px 12px;
}
.dlg-result strong {
  display: block;
  font-size: 15px;
}

/* ---------- Toasts ---------- */
.toasts {
  position: fixed;
  right: 20px;
  bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 50;
}
.toast {
  background: var(--ink);
  color: var(--surface);
  padding: 10px 14px;
  border-radius: var(--radius-m);
  box-shadow: var(--shadow-pop);
  max-width: 420px;
}
.toast.is-error {
  background: var(--danger);
  color: #fff;
}

/* Keyboard help */
.keys {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 16px;
  margin: 0;
}
.keys dt {
  white-space: nowrap;
}
.keys dd {
  margin: 0;
  color: var(--ink-soft);
}

/* Narrower screens (down to 1024px) */
@media (max-width: 1200px) {
  .app {
    grid-template-columns: 204px minmax(0, 1fr);
  }
  table.data th,
  table.data td {
    padding: 7px 9px;
  }
  .ledgers {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .two-col {
    grid-template-columns: minmax(0, 1fr);
  }
  .review-layout {
    grid-template-columns: minmax(0, 1.4fr) minmax(280px, 1fr);
    gap: 16px;
  }
  .kv > div {
    grid-template-columns: 120px minmax(0, 1fr);
  }
  .main {
    padding: 18px 20px 56px;
  }
  .toolbar .search {
    width: 240px;
  }
}

/* ---------- Sign in with Google ---------- */
.signin-lede {
  color: var(--ink-soft);
  margin: 0 0 18px;
}
/* Google's sign-in button colours (light: white, grey outline; dark: near-black, light outline). */
.btn-google {
  gap: 10px;
  background: #ffffff;
  border-color: #747775;
  color: #1f1f1f;
  font-size: 14px;
}
.btn-google:hover {
  background: #f2f2f2;
  border-color: #747775;
}
.btn-google .g-logo {
  width: 18px;
  height: 18px;
  flex: none;
}
:root[data-theme="dark"] .btn-google {
  background: #131314;
  border-color: #8e918f;
  color: #e3e3e3;
}
:root[data-theme="dark"] .btn-google:hover {
  background: #1f1f20;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .btn-google {
    background: #131314;
    border-color: #8e918f;
    color: #e3e3e3;
  }
  :root:not([data-theme="light"]) .btn-google:hover {
    background: #1f1f20;
  }
}
.signin-card .form-error {
  margin: 0 0 14px;
}
.signin-foot {
  margin-top: 12px;
  text-align: center;
}
.rail-who {
  color: var(--rail-ink);
  font-size: 12.5px;
  font-weight: 700;
  padding: 0 4px;
  overflow-wrap: anywhere;
}

/* ---------- Admins ---------- */
.admin-add-wrap {
  max-width: 640px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  padding: 16px 18px;
}
.admin-add-row {
  display: flex;
  gap: 8px;
}
.admin-add-row .input {
  flex: 1;
  min-width: 0;
  min-height: 36px;
}
.admin-add-row .btn {
  min-height: 36px;
}
.admin-add .form-error {
  margin-top: 8px;
}
.admin-add .field-help {
  margin-top: 8px;
  max-width: 70ch;
}
.admin-who {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
/* A monogram in the brand mark's rounded tile. */
.admin-initial {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--info-soft);
  color: var(--info-ink);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 13px;
  flex: none;
}
.admin-email {
  overflow-wrap: anywhere;
}
td.admin-act {
  text-align: right;
  white-space: nowrap;
}
@media (max-width: 640px) {
  .admin-add-row {
    flex-direction: column;
  }
}
