/* Ledger console: paper canvas, one sapphire accent, controls at 4px. */

:root {
  --canvas: oklch(0.945 0.008 250);
  --sidebar-bg: oklch(0.985 0.005 250);
  --ink: oklch(0.24 0.02 255);
  --muted: oklch(0.42 0.02 255);
  --line: oklch(0.88 0.01 255);
  --sapphire: oklch(0.42 0.09 258);
  --sapphire-ink: oklch(0.38 0.085 258);
  --on-sapphire: oklch(0.98 0.01 258);
  --soft: oklch(0.955 0.016 258);
  --ok: oklch(0.42 0.08 155);
  --ok-bg: oklch(0.95 0.025 155);
  --danger: oklch(0.46 0.13 25);
  --danger-bg: oklch(0.96 0.015 25);
  --radius-control: 4px;
  --sidebar-width: 216px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --sans: "Avenir Next", "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Songti SC", "STSong", serif;
}

* { box-sizing: border-box; }

html { height: 100%; }

body {
  margin: 0;
  min-height: 100%;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--sapphire-ink); text-decoration: none; }

h1, h2, h3 { line-height: 1.3; font-weight: 600; }
h1 { margin: 0 0 8px; font-size: 1.75rem; }
h2 { margin: 0; font-size: 1.05rem; }
h3 { margin: 0 0 14px; font-size: 0.82rem; font-weight: 600; color: var(--muted); }
p { margin: 0 0 0.8em; }

:focus-visible {
  outline: 2px solid var(--sapphire);
  outline-offset: 3px;
}

.skip {
  position: absolute;
  left: 12px;
  top: -48px;
  background: var(--sidebar-bg);
  color: var(--ink);
  padding: 8px 12px;
  z-index: 5;
}
.skip:focus { top: 8px; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.shell {
  display: flex;
  min-height: 100vh;
  align-items: stretch;
}

.sidebar {
  width: var(--sidebar-width);
  flex: 0 0 var(--sidebar-width);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 28px 18px 18px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: block;
  margin: 0 8px 28px;
  color: var(--ink);
  text-decoration: none;
}
.brand-mark {
  font-family: var(--serif);
  font-weight: 500;
  letter-spacing: 0;
}
.brand .brand-mark { font-size: 1.35rem; }
h1 .brand-mark { font-size: inherit; }
.brand-suffix {
  margin-left: 0.35rem;
  color: var(--sapphire);
  font-weight: 600;
}
.brand:active { transform: scale(0.96); }

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.side-nav a {
  display: block;
  color: var(--muted);
  padding: 8px 10px;
  border-radius: var(--radius-control);
  font-weight: 600;
  text-decoration: none;
  transition: transform 120ms var(--ease), background-color 120ms linear;
}
.side-nav a.is-current {
  background: var(--soft);
  color: var(--sapphire-ink);
}
.side-nav a:active { transform: scale(0.96); }

.side-foot {
  margin-top: auto;
  padding: 16px 8px 0;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.who {
  color: var(--muted);
  font-size: 0.88rem;
  overflow-wrap: anywhere;
}

.workspace { flex: 1; min-width: 0; }

.content {
  width: min(1040px, calc(100% - 80px));
  margin: 0 auto;
  padding: 48px 0 88px;
}

.guest-main {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 20px;
}
.guest-main .content { width: min(420px, 100%); padding: 0; }
.guest-card h1 { margin-top: 18px; }

.kicker {
  margin: 0 0 8px;
  color: var(--sapphire);
  font-size: 0.75rem;
  font-weight: 600;
}
.lede, .hint, .empty {
  color: var(--muted);
  max-width: 52ch;
}
.hint { margin: 14px 0 0; font-size: 0.9rem; }
.field-note { margin: 0; color: var(--muted); font-size: 0.86rem; }
.nowrap { white-space: nowrap; }
.empty { margin: 28px 0 8px; }
.page-head { margin: 0 0 36px; }
.page-links { margin: 16px 0 0; }

.section { margin-top: 48px; }
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.metrics div { padding: 18px 20px 16px 0; }
.metrics div + div {
  padding-left: 20px;
  border-left: 1px solid var(--line);
}
.metrics dt {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
}
.metrics dd {
  margin: 4px 0 0;
  font-size: clamp(1.2rem, 2.5vw, 1.65rem);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}
.metrics dd .is-over { color: var(--danger); }
.metric-sub {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 8px;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
}
.metric-sub .link-button { padding: 0; }

.result-count {
  margin: 0;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.user-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 12px 16px;
  margin: 22px 0 8px;
}
.finder {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  align-items: end;
  margin: 0;
  flex: 1 1 280px;
}
.finder label { flex: 1 1 240px; max-width: 420px; }
.user-tools > .button { flex: 0 0 auto; }

.directory-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 24px;
}
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 20px;
  margin: 0;
}
.sorter {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
.sorter label {
  display: flex;
  align-items: center;
  gap: 8px;
}
.sorter select {
  width: auto;
  min-width: 12rem;
  min-height: 40px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: var(--sidebar-bg);
  color: var(--ink);
  font: inherit;
  font-weight: 600;
}
.filters a {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 6px 0;
  color: var(--muted);
  font-weight: 600;
  text-decoration: none;
  transition: transform 120ms var(--ease), color 120ms linear;
}
.filters a[aria-current="page"] {
  color: var(--sapphire-ink);
  box-shadow: inset 0 -1px 0 var(--sapphire);
}
.filters a:active { transform: scale(0.96); }

.roster { margin-top: 12px; }
.person { border-top: 1px solid var(--line); }
.roster .person:last-child { border-bottom: 1px solid var(--line); }

.person-row {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1.5fr) auto;
  gap: 8px 28px;
  align-items: center;
  padding: 20px 0;
}

.person-main {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  min-width: 0;
}
.person-name { font-weight: 600; }
.person-meta {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.person-usage {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.person-when {
  color: var(--muted);
  font-size: 0.88rem;
  overflow-wrap: anywhere;
}

.manage-chip {
  display: inline-flex;
  align-items: center;
  justify-self: end;
  min-height: 40px;
  border: 0;
  background: transparent;
  padding: 0;
  color: var(--sapphire-ink);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: transform 120ms var(--ease);
}
.manage-chip:active { transform: scale(0.96); }

.card-dialog {
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: var(--sidebar-bg);
  color: var(--ink);
  box-shadow: 0 18px 50px oklch(0.24 0.02 255 / 0.16);
}
.card-dialog[open] {
  display: flex;
  flex-direction: column;
  width: min(440px, calc(100vw - 32px));
  max-height: min(86vh, 860px);
  margin: auto;
  padding: 0;
}
.card-dialog-wide[open] { width: min(760px, calc(100vw - 32px)); }
.card-dialog::backdrop { background: oklch(0.24 0.02 255 / 0.32); }
.card-head {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
}
.card-head .link-button { flex: 0 0 auto; }
.card-body {
  min-height: 0;
  padding: 6px 20px 22px;
  overflow: auto;
}
.manage-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 32px;
}
.manage-grid .group,
.manage-grid .group + .group {
  border-top: 0;
  padding-top: 16px;
}
.card-dialog .stack-form { max-width: none; }

.group { padding: 22px 0 8px; }
.group + .group { border-top: 1px solid var(--line); padding-top: 22px; }
.group form + form,
.group .facts + .copy-row,
.group .facts + .hint,
.group .copy-row + form,
.group .hint + form { margin-top: 20px; }

.facts {
  margin: 16px 0 0;
  max-width: 520px;
}
.facts div {
  display: grid;
  grid-template-columns: 7rem 1fr;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}
.facts div:last-child { border-bottom: 1px solid var(--line); }
.facts dt { color: var(--muted); }
.facts dd {
  margin: 0;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.badges { display: flex; flex-wrap: wrap; gap: 6px; }
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-control);
  background: var(--soft);
  color: var(--sapphire-ink);
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-off { background: oklch(0.94 0.005 255); color: oklch(0.42 0.012 255); }
.badge-admin { background: oklch(0.95 0.02 75); color: oklch(0.40 0.07 70); }

label {
  display: grid;
  gap: 6px;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--muted);
}
input {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: var(--sidebar-bg);
  color: var(--ink);
  font: inherit;
}
.stack-form {
  display: grid;
  gap: 16px;
  max-width: 360px;
  margin-top: 16px;
}
.stack-form .button { justify-self: start; }

.button, .link-button, .text-link, .brand {
  transition: transform 120ms var(--ease), background-color 120ms linear, color 120ms linear;
}
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 8px 16px;
  border: 0;
  border-radius: var(--radius-control);
  background: var(--sapphire);
  color: var(--on-sapphire);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.button:active, .link-button:active, .text-link:active { transform: scale(0.96); }
.button:disabled {
  background: oklch(0.86 0.01 255);
  color: oklch(0.52 0.015 255);
  cursor: not-allowed;
  transform: none;
}
.button.danger { background: var(--danger); }
.button.is-done { background: var(--ok); }

.link-button, .text-link {
  display: inline-block;
  background: none;
  border: 0;
  padding: 8px 0;
  min-height: 40px;
  color: var(--sapphire-ink);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}

.copy-row {
  display: flex;
  gap: 12px;
  align-items: center;
  max-width: 640px;
  margin-top: 18px;
}
.copy-row input {
  flex: 1;
  min-width: 0;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.82rem;
}
.copy-row .button { flex: 0 0 auto; min-width: 6.5rem; }

.steps {
  margin: 18px 0 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
  max-width: 62ch;
}
.steps li {
  counter-increment: step;
  display: grid;
  grid-template-columns: 1.6rem 1fr;
  gap: 10px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}
.steps li:last-child { border-bottom: 1px solid var(--line); }
.steps li::before {
  content: counter(step);
  color: var(--sapphire);
  font-weight: 600;
}

.actions { margin-top: 18px; }

.flash-stack { display: grid; gap: 10px; margin-bottom: 20px; }
.flash { padding: 12px 14px; background: var(--soft); color: var(--ink); }
.flash-success { background: var(--ok-bg); color: var(--ok); }
.flash-danger { background: var(--danger-bg); color: var(--danger); }
.flash-info { background: var(--soft); }

.section h3.protocol,
.section > h3 { margin-top: 28px; color: var(--ink); font-size: 1rem; }

@media (hover: hover) {
  .side-nav a:hover { background: oklch(0.95 0.008 255); color: var(--ink); }
  .side-nav a.is-current:hover { background: var(--soft); color: var(--sapphire-ink); }
  .button:hover { background: var(--sapphire-ink); }
  .button.danger:hover { background: oklch(0.38 0.12 25); }
  .button.is-done:hover { background: var(--ok); }
  .button:disabled:hover { background: oklch(0.86 0.01 255); }
  .text-link:hover, .link-button:hover, .filters a:hover { color: var(--ink); }
}

@media (max-width: 720px) {
  .shell { flex-direction: column; }
  .sidebar {
    width: 100%;
    height: auto;
    position: static;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 18px 16px 14px;
  }
  .brand { margin-bottom: 14px; }
  .side-nav { flex-direction: row; flex-wrap: wrap; }
  .side-foot { margin-top: 14px; }
  .content { width: min(100% - 32px, 1040px); padding: 28px 0 64px; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .metrics div,
  .metrics div + div { border-left: 0; padding: 14px 12px 12px 0; }
  .metrics div:nth-child(2),
  .metrics div:nth-child(4) { padding-left: 16px; border-left: 1px solid var(--line); }
  .metrics div:nth-child(3),
  .metrics div:nth-child(4) { border-top: 1px solid var(--line); }
  .person-row { grid-template-columns: 1fr; gap: 6px; padding: 16px 0; }
  .manage-chip { justify-self: start; }
  .user-tools { flex-direction: column; align-items: stretch; }
  .finder { flex-direction: column; align-items: stretch; }
  .finder label { max-width: none; }
  .finder .button,
  .user-tools > .button { align-self: flex-start; }
  .directory-bar { align-items: flex-start; }
  .sorter select { flex: 1 1 auto; min-width: 0; }
  .manage-grid { grid-template-columns: 1fr; }
  .copy-row { flex-direction: column; align-items: stretch; }
  .copy-row .button { align-self: flex-start; }
  .facts div { grid-template-columns: 6.2rem 1fr; }
}

@media (prefers-reduced-motion: no-preference) {
  @keyframes rise {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: none; }
  }
  .page-head,
  .metrics,
  .section,
  .guest-card { animation: rise 420ms var(--ease) both; }
  .metrics { animation-delay: 70ms; }
  .section { animation-delay: 140ms; }
  .section + .section { animation-delay: 200ms; }
  .flash { animation: rise 280ms var(--ease) both; }
  .card-dialog[open] { animation: rise 240ms var(--ease) both; }
}

.file-list { margin-top: 8px; }
.file-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0;
  border-top: 1px solid var(--line);
}
.file-list .file-row:last-child { border-bottom: 1px solid var(--line); }
.file-main { min-width: 0; }
.file-name { font-weight: 600; overflow-wrap: anywhere; }
.file-meta { color: var(--muted); font-size: 0.88rem; }
.file-actions { display: flex; gap: 12px; align-items: center; }
.file-actions form { margin: 0; }

@media (prefers-reduced-motion: reduce) {
  .button, .link-button, .text-link, .brand, .side-nav a, .filters a, .manage-chip {
    transition: none;
  }
}
