:root {
  color-scheme: light;
  --bg: #f6f7f2;
  --surface: #ffffff;
  --ink: #1e2520;
  --muted: #66716a;
  --line: #d8ded6;
  --accent: #0f7b67;
  --accent-dark: #095f50;
  --warn: #8a5a00;
  --warn-bg: #fff3d7;
  --error: #9f2b2b;
  --error-bg: #fde7e7;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.45;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
select,
input,
textarea {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
}

button {
  min-height: 2.5rem;
  padding: 0.55rem 0.85rem;
  cursor: pointer;
}

button:hover:not(:disabled) {
  border-color: var(--accent);
}

button:disabled,
select:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

button.is-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
  font-weight: 700;
}

button.is-primary:hover:not(:disabled) {
  background: var(--accent-dark);
}

textarea,
input,
select {
  width: 100%;
  min-height: 2.45rem;
  padding: 0.5rem 0.6rem;
}

textarea {
  resize: vertical;
}

.trial-shell {
  min-height: 100vh;
}

.trial-toolbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: minmax(11rem, 0.6fr) minmax(16rem, 1fr) auto auto;
  gap: 0.75rem;
  align-items: end;
  padding: 1rem clamp(1rem, 3vw, 2rem);
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
}

.trial-brand p,
.trial-brand h1,
.trial-results h2,
.trial-sidebar h2 {
  margin: 0;
}

.trial-brand p {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
}

.trial-brand h1 {
  font-size: 1.35rem;
}

.trial-control {
  display: grid;
  gap: 0.3rem;
}

.trial-control > span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.trial-status-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.75rem;
  align-items: stretch;
  padding: 1rem clamp(1rem, 3vw, 2rem) 0;
}

.trial-status,
.trial-banner,
.trial-error {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.75rem 0.85rem;
  background: var(--surface);
}

.trial-status span {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
}

.trial-status strong {
  display: block;
  margin-top: 0.1rem;
}

.trial-banner {
  border-color: #e3bd67;
  background: var(--warn-bg);
  color: var(--warn);
  font-weight: 700;
}

.trial-error {
  grid-column: 1 / -1;
  border-color: #e0a3a3;
  background: var(--error-bg);
  color: var(--error);
  font-weight: 700;
}

.trial-layout {
  display: grid;
  grid-template-columns: minmax(19rem, 24rem) minmax(0, 1fr);
  gap: 1rem;
  padding: 1rem clamp(1rem, 3vw, 2rem) 2rem;
}

.trial-sidebar,
.trial-results {
  display: grid;
  align-content: start;
  gap: 1rem;
}

.trial-sidebar > section,
.trial-results > div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 1rem;
}

.trial-sidebar h2,
.trial-results h2 {
  font-size: 1rem;
}

.trial-sidebar section {
  display: grid;
  gap: 0.8rem;
}

.trial-results {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.trial-results > div[data-trial-output="compact-year-table"],
.trial-results > div[data-trial-output="aggregate-rollup"] {
  grid-column: 1 / -1;
}

.trial-actions,
.trial-year-nav,
.trial-note-actions,
.trial-note-heading,
.trial-block-heading {
  display: flex;
  gap: 0.55rem;
  align-items: center;
}

.trial-year-nav {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
}

.trial-block-heading {
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.trial-pill {
  border-radius: 999px;
  padding: 0.18rem 0.55rem;
  background: var(--warn-bg);
  color: var(--warn);
  font-size: 0.76rem;
  font-weight: 700;
}

.trial-fields {
  display: grid;
  gap: 0.45rem;
  margin: 0;
}

.trial-field {
  display: grid;
  grid-template-columns: minmax(8rem, 0.8fr) minmax(0, 1fr);
  gap: 0.75rem;
}

.trial-field dt,
.trial-field dd {
  margin: 0;
}

.trial-field dt,
.trial-meta,
.trial-empty {
  color: var(--muted);
}

.trial-field dd {
  overflow-wrap: anywhere;
  font-weight: 650;
}

.trial-list {
  margin: 0;
  padding-left: 1.1rem;
}

.trial-timeline {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.85rem;
}

.trial-tick {
  min-width: 3.5rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.3rem 0.45rem;
  text-align: center;
}

.trial-tick.is-window-start {
  border-color: var(--accent);
  background: #e6f3ef;
  color: var(--accent-dark);
  font-weight: 750;
}

.trial-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.trial-table th,
.trial-table td {
  border-bottom: 1px solid var(--line);
  padding: 0.5rem;
  text-align: right;
  white-space: nowrap;
}

.trial-table th:first-child,
.trial-table td:first-child {
  text-align: left;
}

.trial-table tr.is-active {
  background: #eef6f3;
}

.trial-note {
  display: grid;
  gap: 0.55rem;
  border-top: 1px solid var(--line);
  padding-top: 0.75rem;
}

.trial-note-heading {
  justify-content: space-between;
}

.trial-note-edit {
  min-height: 5rem;
}

@media (max-width: 900px) {
  .trial-toolbar,
  .trial-layout,
  .trial-status-row,
  .trial-results {
    grid-template-columns: 1fr;
  }

  .trial-toolbar {
    position: static;
  }

  .trial-results > div[data-trial-output="compact-year-table"],
  .trial-results > div[data-trial-output="aggregate-rollup"] {
    grid-column: auto;
  }
}

@media (max-width: 560px) {
  .trial-actions,
  .trial-note-actions,
  .trial-note-heading,
  .trial-block-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .trial-field {
    grid-template-columns: 1fr;
    gap: 0.15rem;
  }

  .trial-table {
    display: block;
    overflow-x: auto;
  }
}
