:root {
  color-scheme: light;
  --ink: #171713;
  --muted: #66665c;
  --paper: #fbfaf6;
  --panel: #ffffff;
  --line: #d8d5c7;
  --copper: #a95635;
  --green: #1d6b4f;
  --blue: #244d8f;
  --gold: #b38416;
  --plum: #5f345f;
  --red: #9f382f;
  --mint: #dcebe3;
  --shadow: 0 18px 40px rgba(24, 23, 18, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(90deg, rgba(23, 23, 19, 0.045) 1px, transparent 1px) 0 0 /
      48px 48px,
    var(--paper);
  color: var(--ink);
}

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

button,
a {
  border-radius: 6px;
}

button {
  border: 1px solid var(--ink);
  background: var(--ink);
  color: white;
  padding: 0.7rem 0.9rem;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

button.secondary,
.tabs button {
  background: transparent;
  color: var(--ink);
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(36, 77, 143, 0.32);
  outline-offset: 2px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  padding: 2rem clamp(1rem, 4vw, 3rem);
  border-bottom: 1px solid var(--line);
  background: rgba(251, 250, 246, 0.86);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.session-panel {
  display: grid;
  gap: 0.2rem;
  text-align: right;
}

.session-panel small {
  color: var(--muted);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2rem, 4vw, 4.8rem);
  font-weight: 500;
  letter-spacing: 0;
}

h2 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.25rem;
  letter-spacing: 0;
}

.eyebrow {
  color: var(--copper);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

main {
  padding: clamp(1rem, 4vw, 3rem);
}

.login-panel,
.workspace,
.record-form,
.metric,
.record-item,
.contract-actions,
.docket-band,
.structure-card,
.calendar-day,
.contact-card,
.role-path,
.path-card,
.evidence-ledger {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.login-panel {
  display: grid;
  gap: 1rem;
  max-width: 880px;
  padding: 1.25rem;
}

.inline-form {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 0.75rem;
}

label {
  display: grid;
  gap: 0.35rem;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
}

input,
select,
textarea {
  min-width: 0;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--ink);
  padding: 0.7rem;
}

textarea {
  min-height: 6rem;
  resize: vertical;
}

.workspace {
  padding: 1rem;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--line);
}

.tabs button.active {
  background: var(--green);
  border-color: var(--green);
  color: white;
}

.tab-panel {
  display: none;
  padding-top: 1rem;
}

.tab-panel.active {
  display: block;
}

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

.metric {
  padding: 1rem;
}

.metric strong {
  display: block;
  margin-top: 0.4rem;
  font-size: 1.7rem;
}

.record-grid,
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.ops-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.92fr) minmax(320px, 1.08fr);
  gap: 1rem;
  align-items: start;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.section-heading {
  display: grid;
  gap: 0.25rem;
  margin: 0.5rem 0 1rem;
}

.record-list {
  display: grid;
  gap: 0.75rem;
}

.record-item,
.record-form {
  padding: 1rem;
  border-radius: 8px;
}

.record-item {
  display: grid;
  gap: 0.45rem;
}

.record-title-row,
.contact-head,
.path-topline {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 0.75rem;
}

.record-item small {
  color: var(--muted);
}

.record-form {
  display: grid;
  gap: 0.85rem;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.check-row input {
  width: auto;
}

.docket-band {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1rem;
  align-items: center;
  padding: 1rem;
  margin-bottom: 1rem;
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(29, 107, 79, 0.12), transparent 44%),
    rgba(255, 255, 255, 0.92);
}

.docket-rail {
  display: grid;
  grid-template-columns: repeat(5, minmax(5.5rem, 1fr));
  gap: 0.35rem;
  min-width: min(100%, 520px);
}

.docket-rail span {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  color: var(--muted);
  padding: 0.45rem 0.55rem;
  text-align: center;
  font-size: 0.76rem;
  font-weight: 800;
}

.structure-card {
  display: grid;
  gap: 0.8rem;
  padding: 1rem;
  border-radius: 8px;
  border-left: 5px solid var(--green);
}

.structure-list {
  display: grid;
  gap: 0.7rem;
  margin: 0;
}

.structure-list div {
  display: grid;
  grid-template-columns: minmax(7rem, 0.32fr) minmax(0, 1fr);
  gap: 0.75rem;
  padding-top: 0.7rem;
  border-top: 1px solid var(--line);
}

.structure-list dt {
  color: var(--copper);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.structure-list dd {
  margin: 0;
  color: var(--ink);
  line-height: 1.45;
}

.compact-list div {
  grid-template-columns: minmax(4.5rem, 0.25fr) minmax(0, 1fr);
}

.source-pill,
.status-chip {
  justify-self: start;
  border: 1px solid rgba(36, 77, 143, 0.22);
  border-radius: 999px;
  background: rgba(36, 77, 143, 0.08);
  color: var(--blue);
  padding: 0.32rem 0.55rem;
  font-size: 0.72rem;
  font-weight: 800;
}

.calendar-shell {
  margin-top: 1rem;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.55rem;
  margin-bottom: 1rem;
}

.calendar-day {
  min-height: 7.2rem;
  display: grid;
  align-content: start;
  gap: 0.4rem;
  padding: 0.75rem;
  border-radius: 8px;
  box-shadow: none;
}

.calendar-day.today {
  border-color: var(--green);
  background: var(--mint);
}

.calendar-day span {
  border-left: 3px solid var(--plum);
  padding-left: 0.45rem;
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1.25;
}

.calendar-day small {
  color: var(--muted);
}

.vote-ledger,
.evidence-ledger .record-list {
  margin-top: 0.75rem;
}

.compact-button {
  justify-self: start;
  padding: 0.48rem 0.65rem;
  font-size: 0.8rem;
}

.hash-indicator {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.75rem;
  align-items: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--paper);
  padding: 0.8rem;
}

.hash-indicator small,
.hash-text {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.hash-dot {
  width: 0.8rem;
  height: 0.8rem;
  border-radius: 999px;
  background: var(--gold);
  box-shadow: 0 0 0 5px rgba(179, 132, 22, 0.13);
}

.hash-indicator[data-state="working"] .hash-dot {
  background: var(--blue);
  box-shadow: 0 0 0 5px rgba(36, 77, 143, 0.13);
}

.hash-indicator[data-state="ready"] {
  border-style: solid;
  border-color: rgba(29, 107, 79, 0.38);
  background: var(--mint);
}

.hash-indicator[data-state="ready"] .hash-dot {
  background: var(--green);
  box-shadow: 0 0 0 5px rgba(29, 107, 79, 0.13);
}

.file-drop input {
  border-style: dashed;
}

.photo-preview {
  width: 100%;
  max-height: 320px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.evidence-ledger {
  padding: 1rem;
  border-radius: 8px;
}

.contact-grid,
.role-path-grid,
.path-grid {
  display: grid;
  gap: 1rem;
}

.contact-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 1rem;
}

.role-path-grid,
.path-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.contact-card,
.role-path,
.path-card {
  display: grid;
  gap: 0.65rem;
  padding: 1rem;
  border-radius: 8px;
}

.contact-card.current {
  border-color: rgba(29, 107, 79, 0.45);
  background: var(--mint);
}

.contact-card a,
.addendum-band a {
  color: var(--blue);
  overflow-wrap: anywhere;
}

.contact-head span,
.path-topline span {
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  padding: 0.25rem 0.5rem;
  font-size: 0.72rem;
  font-weight: 800;
  white-space: nowrap;
}

.role-path span,
.path-card dd {
  color: var(--muted);
}

.path-card h2 {
  font-size: 1.05rem;
}

.addendum-band {
  grid-template-columns: minmax(0, 1fr) auto;
}

.contract-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem;
  margin-bottom: 1rem;
}

.contract-actions a {
  border: 1px solid var(--line);
  color: var(--blue);
  padding: 0.65rem 0.8rem;
  text-decoration: none;
  background: white;
}

iframe {
  width: 100%;
  min-height: 72vh;
  border: 1px solid var(--line);
  background: white;
}

.hidden {
  display: none !important;
}

.notice {
  color: var(--blue);
  min-height: 1.2rem;
}

.toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  max-width: min(420px, calc(100vw - 2rem));
  background: var(--ink);
  color: white;
  padding: 0.85rem 1rem;
  border-radius: 8px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 840px) {
  .topbar {
    align-items: start;
    flex-direction: column;
    position: static;
  }

  .session-panel {
    text-align: left;
  }

  .metric-grid,
  .record-grid,
  .form-grid,
  .ops-grid,
  .form-row,
  .contact-grid,
  .role-path-grid,
  .path-grid,
  .docket-band,
  .addendum-band {
    grid-template-columns: 1fr;
  }

  .docket-rail,
  .calendar-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .inline-form {
    align-items: stretch;
    flex-direction: column;
  }
}
