:root {
  --paper: #efe8dc;
  --card: #f8f3ea;
  --ink: #1f1a14;
  --muted: #5c5348;
  --line: #d2c6b4;
  --teal: #15443e;
  --teal-hover: #0f332f;
  --rust: #b4451b;
  --rust-hover: #933614;
  --warn-bg: #f4e3d4;
  --error: #8f1d1d;
  --shadow: 0 12px 40px rgba(31, 26, 20, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(21, 68, 62, 0.08), transparent 50%),
    var(--paper);
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
}

.page {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 40px 0 72px;
}

.hero {
  margin-bottom: 28px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--teal);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  font-size: 12px;
  font-weight: 700;
}

h1 {
  margin: 0 0 12px;
  font-size: 40px;
  line-height: 1.1;
  font-weight: 600;
}

.lede,
.foot p,
.modal-help,
.field small,
.note p,
.note li {
  color: var(--muted);
  line-height: 1.55;
}

.lede {
  margin: 0;
  max-width: 42em;
  font-size: 17px;
}

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

.card h2,
.modal-bar h2 {
  margin: 0 0 18px;
  font-size: 20px;
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.span-2 {
  grid-column: 1 / -1;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  font-size: 13px;
  font-weight: 600;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fffdf8;
  color: var(--ink);
  padding: 10px 12px;
  font: 400 15px/1.4 "Avenir Next", "Segoe UI", sans-serif;
}

.field textarea {
  resize: vertical;
  min-height: 92px;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: 2px solid var(--teal);
  outline-offset: 1px;
}

.field small {
  font-weight: 400;
}

.check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  font-size: 14px;
  color: var(--muted);
}

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

.note ul {
  margin: 0 0 16px;
  padding-left: 20px;
}

.note code {
  font-family: "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 12px;
  background: #fffdf8;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 5px;
}

.warn {
  margin: 0;
  padding: 12px 14px;
  background: var(--warn-bg);
  border-radius: 10px;
  color: var(--ink);
}

.provider-grid {
  margin-top: 18px;
}

.error {
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: 10px;
  background: #f8dede;
  color: var(--error);
  font-family: "Avenir Next", "Segoe UI", sans-serif;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.btn,
.file-btn {
  appearance: none;
  border: 1px solid var(--line);
  background: #fffdf8;
  color: var(--ink);
  border-radius: 999px;
  padding: 10px 16px;
  font: 600 14px/1 "Avenir Next", "Segoe UI", sans-serif;
  cursor: pointer;
}

.btn:hover,
.file-btn:hover {
  border-color: var(--ink);
}

.btn.primary {
  background: var(--rust);
  border-color: var(--rust);
  color: #fffaf4;
}

.btn.primary:hover {
  background: var(--rust-hover);
  border-color: var(--rust-hover);
}

.btn.full {
  width: 100%;
  margin-top: 18px;
}

.foot {
  margin-top: 28px;
}

.status-line,
.totals,
.events,
.section-head,
.table-wrap,
h3 {
  font-family: "Avenir Next", "Segoe UI", sans-serif;
}

.status-line {
  margin: 16px 0 0;
  color: var(--muted);
}

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

.section-head h2 {
  margin: 0;
}

.totals {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 16px;
  color: var(--muted);
}

.table-wrap {
  overflow-x: auto;
}

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

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

th {
  color: var(--muted);
  font-weight: 600;
}

.btn.compact {
  padding: 6px 10px;
  font-size: 12px;
}

h3 {
  margin: 20px 0 8px;
  font-size: 16px;
}

.events {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
}

.events span {
  opacity: 0.75;
}

.foot code,
.note code {
  font-family: "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 12px;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(31, 26, 20, 0.46);
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: 24px;
}

.modal[hidden] {
  display: none;
}

.modal-card {
  width: min(1100px, 100%);
  background: var(--card);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px 8px;
}

.modal-bar h2 {
  margin: 0;
}

.modal-help {
  margin: 0 18px 12px;
}

#test-frame {
  flex: 1;
  min-height: 62vh;
  border: 0;
  border-top: 1px solid var(--line);
  background: #fff;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(430px, 100%);
  padding: 36px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.login-card h1 {
  font-size: 32px;
}

.login-card .lede {
  margin-bottom: 24px;
}

.login-password {
  margin-top: 14px;
}

.admin-bar {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 10px max(16px, calc((100vw - 1120px) / 2));
  border-bottom: 1px solid var(--line);
  background: rgba(248, 243, 234, 0.92);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  color: var(--ink);
  font-size: 18px;
  font-weight: 600;
  text-decoration: none;
}

.admin-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font: 13px "Avenir Next", "Segoe UI", sans-serif;
}

.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
}

.page-heading h1 {
  margin-bottom: 8px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metric {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  box-shadow: var(--shadow);
  font: 13px "Avenir Next", "Segoe UI", sans-serif;
  color: var(--muted);
}

.metric strong {
  display: block;
  margin-bottom: 4px;
  color: var(--ink);
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  font-size: 28px;
  font-weight: 600;
}

.package-link {
  color: var(--teal);
  font-weight: 700;
  text-decoration: none;
}

.package-link:hover {
  text-decoration: underline;
}

.back-link {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--teal);
  padding: 0;
  margin-bottom: 18px;
  cursor: pointer;
  font: 600 14px "Avenir Next", "Segoe UI", sans-serif;
}

.back-link::before {
  content: "← ";
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.8fr) minmax(420px, 1.4fr);
  gap: 16px;
}

.detail-grid .card {
  min-width: 0;
}

.definition-list {
  display: grid;
  grid-template-columns: minmax(110px, auto) 1fr;
  gap: 10px 16px;
  margin: 0;
  font: 14px/1.45 "Avenir Next", "Segoe UI", sans-serif;
}

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

.definition-list dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.status-pill {
  display: inline-block;
  padding: 3px 7px;
  border-radius: 999px;
  background: #e3ece5;
  color: var(--teal);
  font-size: 12px;
}

.status-pill.muted {
  background: #e9e4db;
  color: var(--muted);
}

button[disabled] {
  opacity: 0.55;
  cursor: wait;
}

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

  .span-2 {
    grid-column: auto;
  }

  h1 {
    font-size: 32px;
  }

  .page-heading,
  .admin-bar {
    align-items: flex-start;
  }

  .page-heading {
    flex-direction: column;
  }

  .metric-grid {
    grid-template-columns: 1fr 1fr;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }
}
