:root {
  color-scheme: light;
  --ink: #172033;
  --muted: #667085;
  --line: #d8deea;
  --panel: #ffffff;
  --page: #f3f6fb;
  --accent: #2457c5;
  --accent-dark: #193f91;
  --soft: #eaf0ff;
}

* {
  box-sizing: border-box;
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 24px clamp(18px, 4vw, 48px);
  background: #111827;
  color: #fff;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.45rem, 2.8vw, 2.4rem);
  letter-spacing: 0;
}

h2 {
  font-size: 1.35rem;
}

.eyebrow {
  margin-bottom: 4px;
  color: #88a8ff;
  font-size: .78rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

nav a,
button {
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font: inherit;
  font-weight: 750;
  padding: 10px 14px;
  text-decoration: none;
}

nav a {
  background: rgba(255, 255, 255, .12);
}

button:hover {
  background: var(--accent-dark);
}

main {
  display: grid;
  gap: 22px;
  max-width: 1120px;
  margin: 0 auto;
  padding: 24px clamp(14px, 4vw, 36px) 56px;
}

.notice,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 12px 30px rgba(23, 32, 51, .07);
}

.notice {
  padding: 14px 16px;
}

.panel {
  padding: clamp(16px, 3vw, 26px);
}

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

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

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

.filter-grid {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

label {
  display: grid;
  gap: 6px;
  color: #344054;
  font-size: .92rem;
  font-weight: 750;
}

.wide {
  grid-column: 1 / -1;
}

.form-section {
  grid-column: 1 / -1;
  margin: 8px 0 0;
  border-top: 1px solid var(--line);
  padding-top: 14px;
  color: #1d2939;
  font-size: 1rem;
  letter-spacing: 0;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #c9d2e3;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  padding: 11px 12px;
}

textarea {
  resize: vertical;
}

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

button.secondary {
  background: var(--soft);
  color: var(--accent-dark);
}

.button-link {
  align-items: center;
  background: var(--soft);
  border-radius: 8px;
  color: var(--accent-dark);
  display: inline-flex;
  font-weight: 750;
  justify-content: center;
  padding: 10px 14px;
  text-decoration: none;
}

.status {
  min-height: 1.5em;
  margin-top: 12px;
}

.fine-print {
  margin-top: 10px;
  color: var(--muted);
  font-size: .88rem;
}

.blank-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 18px;
  margin-top: 18px;
}

.blank-title {
  grid-column: 1 / -1;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 2px solid var(--ink);
  padding-bottom: 8px;
}

.blank-title strong {
  font-size: 1.3rem;
}

.blank-title span,
.blank-note {
  color: var(--muted);
  font-size: .9rem;
}

.blank-section {
  grid-column: 1 / -1;
  margin: 10px 0 0;
  border-bottom: 1px solid var(--line);
  padding-bottom: 4px;
  font-size: 1rem;
}

.blank-item {
  display: grid;
  gap: 5px;
  min-height: 42px;
}

.blank-wide,
.blank-note {
  grid-column: 1 / -1;
}

.blank-label {
  color: #344054;
  font-size: .88rem;
  font-weight: 800;
}

.blank-line {
  display: block;
  border-bottom: 1px solid #344054;
  min-height: 20px;
}

.blank-lines {
  display: block;
  min-height: 92px;
  background: repeating-linear-gradient(to bottom, transparent 0, transparent 21px, #344054 22px);
}

.blank-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  min-height: 24px;
  color: #344054;
}

.lead-sheet-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 18px;
}

.filled-form {
  margin-top: 12px;
}

.filled-item {
  min-height: 42px;
}

.filled-value {
  display: block;
  min-height: 20px;
  border-bottom: 1px solid #344054;
  color: var(--ink);
  font-weight: 650;
  overflow-wrap: anywhere;
  padding: 2px 0 1px;
}

.filled-lines {
  min-height: 92px;
  border-bottom: 0;
  background: repeating-linear-gradient(to bottom, transparent 0, transparent 21px, #344054 22px);
  white-space: pre-wrap;
}

.results {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.print-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  break-inside: avoid;
  overflow: hidden;
}

.card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  background: #f8faff;
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
}

.select-row {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 8px;
}

.select-row input {
  width: auto;
}

.row-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.edit-row {
  padding: 7px 10px;
}

.row-number {
  color: var(--muted);
  font-weight: 800;
}

dl {
  display: grid;
  grid-template-columns: 160px 1fr;
  margin: 0;
}

dt,
dd {
  border-bottom: 1px solid #edf1f7;
  margin: 0;
  padding: 9px 12px;
}

dt {
  color: #475467;
  font-weight: 800;
}

dd {
  white-space: pre-wrap;
}

.empty {
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  padding: 18px;
  text-align: center;
}

dialog {
  width: min(840px, calc(100vw - 28px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  color: var(--ink);
}

dialog::backdrop {
  background: rgba(17, 24, 39, .55);
}

.dialog-panel {
  padding: clamp(16px, 3vw, 24px);
}

@media (max-width: 760px) {
  .topbar,
  .section-heading {
    align-items: stretch;
    flex-direction: column;
  }

  nav {
    justify-content: flex-start;
  }

  .form-grid,
  .filter-grid,
  .blank-form,
  .lead-sheet-form,
  dl {
    grid-template-columns: 1fr;
  }

  dt {
    padding-bottom: 2px;
  }

  dd {
    padding-top: 2px;
  }
}

@media print {
  body {
    background: #fff;
  }

  .topbar,
  .notice,
  .fine-print,
  #entry,
  #blank,
  #lookup > .section-heading,
  #searchForm,
  #lookup > .actions,
  #searchStatus,
  .select-row {
    display: none !important;
  }

  .edit-row,
  dialog {
    display: none !important;
  }

  main {
    max-width: none;
    padding: 0;
  }

  .panel {
    border: 0;
    box-shadow: none;
    padding: 0;
  }

  .results {
    gap: 0;
  }

  .print-card {
    border: 0;
    box-shadow: none;
    page-break-after: always;
    page-break-inside: avoid;
    padding: 0;
  }

  .print-card:last-child {
    page-break-after: auto;
  }

  .card-head {
    display: none !important;
  }

  .filled-form {
    margin-top: 0;
  }

  .lead-sheet-form {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 3px 12px;
    font-size: 8.7pt;
    line-height: 1.12;
  }

  .lead-sheet-form .blank-title {
    font-size: 15pt;
    line-height: 1;
    margin-bottom: 0;
    padding-bottom: 3px;
  }

  .lead-sheet-form .blank-section {
    font-size: 7.8pt;
    line-height: 1;
    margin-top: 4px;
    padding-bottom: 1px;
  }

  .lead-sheet-form .blank-item {
    gap: 1px;
    min-height: 22px;
    break-inside: avoid;
  }

  .lead-sheet-form .blank-label {
    font-size: 7.8pt;
  }

  .lead-sheet-form .filled-value {
    min-height: 13px;
    padding: 0;
  }

  .lead-sheet-form .filled-lines {
    min-height: 42px;
    background: repeating-linear-gradient(to bottom, transparent 0, transparent 13px, #344054 14px);
    white-space: pre-wrap;
  }

  body.print-blank .topbar,
  body.print-blank .notice,
  body.print-blank #entry,
  body.print-blank #lookup,
  body.print-blank #blank > .section-heading,
  body.print-blank #blank > .actions {
    display: none !important;
  }

  body.print-blank #blank {
    display: block !important;
  }

  body.print-blank .blank-form {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px 16px;
    font-size: 11pt;
  }

  body.print-blank .blank-title {
    margin-bottom: 2px;
  }

  body.print-blank .blank-section {
    margin-top: 8px;
  }

  body.print-blank .blank-item {
    min-height: 34px;
    break-inside: avoid;
  }

  body.print-blank .blank-lines {
    min-height: 70px;
  }
}
