:root {
  --ink: #16241c;
  --muted: #5c6b62;
  --paper: #f3efe6;
  --card: #fffdf8;
  --line: #d8d0c2;
  --forest: #143528;
  --moss: #1f6a48;
  --moss-ink: #e8f4ee;
  --warn: #8a4b12;
  --err: #8a1f1f;
  --ok: #1b5c38;
  --shadow: 0 12px 32px rgba(22, 36, 28, 0.06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.45 "Segoe UI", system-ui, sans-serif;
}

a { color: var(--moss); }

.shell {
  display: grid;
  grid-template-columns: 248px 1fr;
  min-height: 100vh;
}

.session-body {
  min-height: 100vh;
  margin: 0;
  padding: 0;
  background: var(--paper);
}

.session-shell {
  display: grid;
  grid-template-columns: minmax(320px, 420px) 1fr;
  min-height: 100vh;
}

.session-panel {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  background: var(--paper);
  padding: 48px 40px;
}

.session-panel-inner {
  width: 100%;
  max-width: 360px;
}

.session-kicker {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.session-title {
  margin: 0;
  color: var(--ink);
  font-family: Georgia, "Iowan Old Style", serif;
  font-size: 32px;
  font-weight: 500;
  letter-spacing: 0;
  line-height: 1.15;
}

.session-lede {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.45;
  max-width: none;
}

.session-account {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.session-account strong {
  color: var(--ink);
  font-weight: 600;
}

.session-panel .flash {
  margin: 0 0 16px;
  padding: 10px 12px;
  border-radius: 0;
}

.session-form {
  display: grid;
  gap: 14px;
  margin-top: 22px;
}

.session-form label.field {
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 400;
}

.session-form input[type="email"],
.session-form input[type="password"],
.session-form input[type="text"] {
  height: 38px;
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-weight: 400;
}

.session-form input::placeholder {
  color: #9aa59e;
  letter-spacing: normal;
}

.secret-row {
  position: relative;
  display: block;
}

.secret-row input { padding-right: 44px; }

.secret-toggle {
  appearance: none;
  position: absolute;
  top: 50%;
  right: 4px;
  width: 32px;
  height: 32px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  display: grid;
  place-items: center;
  transform: translateY(-50%);
  cursor: pointer;
}

.secret-toggle:hover,
.secret-toggle:focus-visible {
  color: var(--ink);
  background: #f7f3ea;
}

.secret-toggle svg { display: block; }
.secret-toggle svg[hidden] { display: none; }

.otp-input {
  letter-spacing: 0.18em;
  font-variant-numeric: tabular-nums;
}

.session-form input.session-submit,
.session-submit {
  width: 100%;
  height: 38px;
  margin-top: 4px;
  border: 1px solid var(--moss);
  border-radius: 0;
  background: var(--moss);
  color: #fff;
  font: inherit;
  font-weight: 400;
  text-align: center;
}

.session-form input.session-submit:hover,
.session-submit:hover {
  background: #18553a;
  border-color: #18553a;
}

.session-cancel {
  display: inline-block;
  margin-top: 16px;
  color: var(--moss);
  font-size: 14px;
  font-weight: 400;
  text-decoration: none;
}

.session-cancel:hover {
  text-decoration: underline;
}

.session-hero {
  position: relative;
  overflow: hidden;
  background: #e8e2d6;
}

.session-hero-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 40%;
}

.session-hero-fade {
  position: absolute;
  inset: 0 auto 0 0;
  width: min(280px, 45%);
  background: linear-gradient(90deg, var(--paper) 0%, rgba(243, 239, 230, 0.78) 38%, rgba(243, 239, 230, 0) 100%);
  pointer-events: none;
  z-index: 1;
}

.session-hero::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 42%;
  background: linear-gradient(180deg, rgba(20, 53, 40, 0) 0%, rgba(20, 53, 40, 0.55) 100%);
  pointer-events: none;
  z-index: 1;
}

.session-hero-copy {
  position: absolute;
  left: 48px;
  right: 48px;
  bottom: 48px;
  z-index: 2;
  max-width: 420px;
  color: #fff;
  text-shadow: 0 1px 14px rgba(0, 0, 0, 0.28);
}

.session-hero-title {
  margin: 0;
  font-family: Georgia, "Iowan Old Style", serif;
  font-size: 28px;
  font-weight: 500;
  letter-spacing: 0;
}

.session-hero-text {
  margin: 10px 0 0;
  color: rgba(255, 255, 255, 0.92);
  font-size: 15px;
  line-height: 1.45;
}

@media (max-width: 900px) {
  .session-shell {
    grid-template-columns: 1fr;
  }

  .session-panel {
    min-height: 100vh;
    padding: 32px 24px;
  }

  .session-panel-inner {
    max-width: 420px;
    margin: 0 auto;
  }

  .session-hero {
    display: none;
  }
}

.sidebar {
  background: var(--forest);
  color: #e7efe9;
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border: 1px solid #c5d8cb;
  display: grid;
  place-items: center;
  font-family: Georgia, serif;
  font-size: 20px;
  flex: none;
}

.brand small {
  display: block;
  color: #9db5a6;
  font-size: 11px;
  line-height: 1.3;
  letter-spacing: 0.02em;
}

.nav { display: grid; gap: 2px; }

.nav-group-label {
  margin: 16px 0 4px;
  padding: 8px 10px 2px;
  color: #9db5a6;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.nav-link {
  color: #d5e4db;
  text-decoration: none;
  padding: 8px 10px;
  border-left: 2px solid transparent;
}

.nav-link.nav-sub {
  padding-left: 18px;
  font-size: 14px;
}

.nav-link:hover,
.nav-link.is-active {
  background: rgba(255, 255, 255, 0.05);
  border-left-color: #d7b56d;
  color: #fff;
}

.sidebar-foot {
  margin-top: auto;
  color: #9db5a6;
  font-size: 12px;
}

.sidebar-foot strong {
  display: block;
  color: #e7efe9;
  margin-bottom: 8px;
}

.sidebar .btn-secondary,
.sidebar button.btn-secondary {
  background: transparent;
  color: #e7efe9;
  border-color: #c5d8cb;
  margin: 0 0 10px;
}

.sidebar .btn-secondary:hover,
.sidebar button.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border-color: #e7efe9;
}

.main { min-width: 0; }

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 22px 32px 0;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.topbar-meta {
  display: flex;
  gap: 16px;
  color: var(--muted);
  font-size: 13px;
  align-items: end;
}

.page { padding: 24px 32px 48px; }

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 16px;
  margin-bottom: 22px;
}

.page-head h1,
.stack h1 {
  margin: 0;
  font-family: Georgia, "Iowan Old Style", serif;
  font-size: 32px;
  font-weight: 500;
}

.lede { margin: 6px 0 0; color: var(--muted); max-width: 62ch; }

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.actions form,
.actions .button_to {
  display: inline-flex;
  margin: 0;
}

.actions .btn,
.actions .btn-secondary,
.actions .btn-danger,
.actions button,
.actions a.btn,
.actions a.btn-secondary {
  padding: 8px 12px;
  line-height: 1.25;
  white-space: nowrap;
}

.grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.grid-2 { grid-template-columns: 1.4fr 1fr; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 18px 18px 16px;
}

.card h2 {
  margin: 0 0 12px;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}

.metric {
  font-family: Georgia, serif;
  font-size: 28px;
}

.table-wrap { overflow: auto; }

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

table.data th,
table.data td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

table.data th {
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

table.data tr.is-current td {
  background: color-mix(in srgb, var(--moss) 8%, #fff);
}

.pill {
  display: inline-block;
  padding: 2px 8px;
  border: 1px solid var(--line);
  font-size: 12px;
  background: #f7f3ea;
}

.pill-event-signed,
.pill-event-ready,
.pill-transmission-accepted,
.pill-event-transmitted { color: var(--ok); border-color: #b9d4c4; background: #eef6f1; }
.pill-event-validation-error,
.pill-transmission-failed,
.pill-transmission-rejected { color: var(--err); border-color: #e3b6b6; background: #f8ecec; }
.pill-event-transmitting,
.pill-transmission-processing,
.pill-transmission-sent { color: var(--warn); border-color: #e2c49a; background: #f8f0e4; }

.btn,
.btn-secondary,
button.btn,
input[type="submit"] {
  appearance: none;
  border: 1px solid var(--moss);
  background: var(--moss);
  color: #fff;
  padding: 8px 12px;
  font: inherit;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}

.btn-secondary,
a.btn-secondary {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}

.btn-danger {
  background: transparent;
  color: var(--err);
  border: 1px solid #e3b6b6;
  padding: 4px 8px;
  font: inherit;
  cursor: pointer;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 16px;
  align-items: start;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 16px;
}

.credential-banner {
  display: grid;
  gap: 2px;
  margin: 0 0 14px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: #f7f3ea;
}

.credential-banner.is-ok {
  border-color: #b9d4c4;
  background: #eef6f1;
}

.credential-banner.is-pending {
  border-color: #e2c49a;
  background: #f8f0e4;
}

.credential-banner.is-empty {
  border-color: #e3b6b6;
  background: #f8ecec;
}

.credential-banner strong {
  font-size: 14px;
}

.credential-banner span {
  color: var(--muted);
  font-size: 13px;
}

.replace-secret {
  margin-top: 14px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.replace-secret summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
}

.form-grid-mapping {
  align-items: start;
}

label.field {
  display: grid;
  grid-template-rows: auto auto;
  align-content: start;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

input, select, textarea {
  box-sizing: border-box;
  font: inherit;
  color: var(--ink);
  border: 1px solid var(--line);
  background: #fff;
  padding: 8px 10px;
  width: 100%;
  min-height: 38px;
}

input[type="text"],
input[type="password"],
input[type="search"],
input[type="email"],
input[type="number"],
input[type="date"],
input[type="url"],
select {
  height: 38px;
  min-height: 38px;
  line-height: 1.2;
  padding-top: 0;
  padding-bottom: 0;
}

input[type="checkbox"],
input[type="radio"] {
  width: 16px;
  height: 16px;
  min-height: 0;
  padding: 0;
  border: 0;
  background: none;
  accent-color: var(--moss);
}

input[type="submit"] {
  width: auto;
}

input[type="date"] {
  appearance: none;
}

.choice-list {
  display: grid;
  gap: 8px;
}

.choice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-size: 14px;
  cursor: pointer;
}

.choice input {
  margin-top: 3px;
}

.choice strong {
  display: block;
  font-weight: 600;
}

.choice small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.flash {
  margin: 16px 32px 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
}

.flash-ok { background: #eef6f1; border-color: #b9d4c4; }
.flash-err { background: #f8ecec; border-color: #e3b6b6; }

.issue-box,
.issue-card {
  border: 1px solid #e3b6b6;
  background: #f8ecec;
}

.issue-box {
  max-height: 240px;
  overflow: auto;
  margin: 12px 0;
  padding: 10px 12px;
}

.issue-box ul,
.issue-card ul {
  margin: 8px 0 0;
  padding-left: 18px;
}

.issue-card h2 { margin-top: 0; }

.receipt-box {
  margin: 0 0 16px;
  padding: 16px 18px;
  border: 1px solid #b9d4c4;
  background: #eef6f1;
}

.receipt-box__label {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ok, #2f6b4f);
}

.receipt-box__number {
  margin: 6px 0 0;
  font-size: 1.35rem;
  line-height: 1.3;
  word-break: break-all;
}

.receipt-box__number code {
  font-size: inherit;
  font-weight: 600;
  color: #163528;
}

.receipt-box__meta {
  margin: 10px 0 0;
  font-size: 13px;
  color: #4a6356;
}

.receipt-box__meta code {
  font-size: 12px;
}

.receipt-inline {
  font-size: 1.05em;
  font-weight: 600;
  word-break: break-all;
}

pre.xml {
  background: #1b241f;
  color: #e5efe8;
  padding: 14px;
  overflow: auto;
  max-height: min(70vh, 640px);
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

.stack { display: grid; gap: 16px; }

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

.empty {
  padding: 24px;
  border: 1px dashed var(--line);
  color: var(--muted);
}

.pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
}

.pager-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.pager-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pager-link {
  min-width: 36px;
  padding: 6px 10px;
  text-align: center;
  border: 1px solid var(--line);
  color: var(--ink);
  text-decoration: none;
  background: #fff;
  font: inherit;
  cursor: pointer;
}

button.pager-link {
  appearance: none;
}

.pager-link.is-current {
  background: var(--moss);
  border-color: var(--moss);
  color: #fff;
}

.pager-link.is-disabled {
  color: var(--muted);
  background: #f7f3ea;
  cursor: default;
}

.pager-jump {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
}

.pager-jump-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

.pager-jump-input {
  width: 4.5rem;
  min-height: 34px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font: inherit;
}

.row-open { cursor: pointer; }
.row-open:hover td { background: #f7f3ea; }
.row-open.is-inactive td { color: var(--muted); }

dialog.modal {
  width: min(720px, calc(100vw - 32px));
  border: 1px solid var(--line);
  padding: 0;
  background: var(--card);
  box-shadow: var(--shadow);
  color: var(--ink);
  overflow: visible;
}

dialog.modal::backdrop {
  background: rgba(22, 36, 28, 0.45);
}

.modal-panel { padding: 22px 24px 24px; overflow: visible; }

.autocomplete { position: relative; }

.autocomplete-control {
  position: relative;
}

.autocomplete-control input {
  padding-right: 110px;
}

.autocomplete-control button {
  position: absolute;
  top: 50%;
  right: 10px;
  width: auto;
  padding: 0;
  border: 0;
  background: none;
  color: var(--moss);
  cursor: pointer;
  font-size: 12px;
  transform: translateY(-50%);
}

.autocomplete.is-expanded .autocomplete-list {
  max-height: min(420px, 50vh);
}

.autocomplete-list {
  position: absolute;
  z-index: 4;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  max-height: 220px;
  margin: 0;
  padding: 4px 0;
  list-style: none;
  overflow: auto;
  border: 1px solid var(--line);
  background: #fff;
  box-shadow: var(--shadow);
}

.autocomplete-list li {
  padding: 8px 10px;
  cursor: pointer;
}

.autocomplete-list li:hover,
.autocomplete-list li[aria-selected="true"] {
  background: #f7f3ea;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.modal-head h2 {
  margin: 0;
  font-family: Georgia, serif;
  font-size: 22px;
  font-weight: 500;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.crumb {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 13px;
}

.crumb a { color: var(--moss); text-decoration: none; }

.month-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.month-card {
  border: 1px solid var(--line);
  background: #fff;
  padding: 16px;
}

.month-card h3 {
  margin: 4px 0 8px;
  font-family: Georgia, serif;
  font-size: 22px;
  font-weight: 500;
}

.month-card.is-open { border-color: #b9d4c4; }

.steps {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  padding: 0;
  margin: 0 0 20px;
}

.step {
  border: 1px solid var(--line);
  padding: 10px 12px;
  color: var(--muted);
  font-size: 13px;
  display: flex;
  gap: 8px;
  align-items: center;
}

.step-n {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  font-size: 12px;
}

.step.is-done { color: var(--ok); border-color: #b9d4c4; background: #eef6f1; }
.step.is-current { color: var(--ink); border-color: var(--moss); background: #fff; }

.report-body {
  background: #fff;
  color: var(--ink);
}

.report-sheet {
  max-width: 1100px;
  margin: 24px auto 48px;
  padding: 0 24px;
}

.help-toc__list {
  margin: 8px 0 0;
  padding-left: 20px;
}

.help-doc h1 {
  font-size: 1.6rem;
  margin-top: 0;
}

.help-doc h2 {
  margin-top: 1.6em;
  padding-top: 0.4em;
  border-top: 1px solid var(--line);
}

.help-doc h3 {
  margin-top: 1.2em;
}

.help-doc p,
.help-doc li {
  line-height: 1.55;
}

.help-pre {
  background: #1b241f;
  color: #e5efe8;
  padding: 12px 14px;
  overflow: auto;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.help-quote {
  margin: 12px 0;
  padding: 10px 14px;
  border-left: 3px solid var(--moss);
  background: #f3f7f4;
}

.help-list {
  padding-left: 1.25rem;
}

.help-check label {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.help-table code {
  font-size: 12px;
}

.sort-link {
  color: inherit;
  text-decoration: none;
  white-space: nowrap;
}

.sort-link:hover,
.sort-link.is-active {
  color: var(--moss);
}

.events-filters {
  margin-bottom: 4px;
}

.events-filters__grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px 16px;
  align-items: end;
}

.events-filters .field {
  display: grid;
  gap: 6px;
  min-width: 0;
  font-size: 13px;
  color: var(--muted);
}

.events-filters select,
.events-filters input[type="date"] {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  font: inherit;
  color: var(--ink);
  padding: 8px 10px;
  border: 1px solid var(--line);
  background: #fff;
  min-height: 38px;
}

.events-filters__actions {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.events-filters__actions-label {
  display: block;
  line-height: 1;
  font-size: 13px;
}

.events-filters__actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  min-height: 38px;
}

@media (max-width: 960px) {
  .events-filters__grid {
    grid-template-columns: 1fr;
  }
}

@media print {
  .sidebar, .topbar, .flash, .actions, .crumb, .pager, .btn, .btn-secondary, .help-toc { display: none !important; }
  .shell { display: block; }
  .card { box-shadow: none; break-inside: avoid; }
  .report-sheet { max-width: none; margin: 0; padding: 0; }
  .help-doc h2 { break-after: avoid; }
}

@media (max-width: 960px) {
  .steps { grid-template-columns: 1fr; }
}

@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; flex-wrap: wrap; }
  .grid, .grid-2, .form-grid { grid-template-columns: 1fr; }
  .page-head { display: grid; }
}
