:root {
  color-scheme: dark;
  --bg-1: #101114;
  --bg-2: #1c1f26;
  --ink: #171717;
  --paper: #ffffff;
  --paper-line: #444444;
  --paper-soft: #8b8b8b;
  --muted: #6f7683;
  --row-height: 4.5mm;
  --row-gap: 1.45mm;
  --course-gap-height: 13.9mm;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: Arial, Helvetica, sans-serif;
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.08), transparent 30%),
    linear-gradient(180deg, var(--bg-2), var(--bg-1));
  color: #f3f4f6;
}

body {
  min-height: 100vh;
}

.stage {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px;
}

.paper-shell {
  display: grid;
  gap: 14px;
}

.paper-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 255, 255, 0.78);
  font-family: Arial, sans-serif;
  font-size: 13px;
  letter-spacing: 0.04em;
  backdrop-filter: blur(10px);
}

.meta-actions {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

#download-image {
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  border-radius: 999px;
  padding: 7px 12px;
  cursor: pointer;
}

#download-image:hover {
  background: rgba(255, 255, 255, 0.16);
}

#download-image:disabled {
  opacity: 0.65;
  cursor: wait;
}

.paper {
  width: 210mm;
  min-height: 297mm;
  padding: 20mm 15mm 13mm;
  background: var(--paper);
  color: var(--ink);
  display: grid;
  grid-template-rows: auto auto auto;
  gap: 8mm;
  box-shadow:
    0 28px 80px rgba(0, 0, 0, 0.45),
    0 0 0 1px rgba(255, 255, 255, 0.08);
}

body.capture-print {
  --row-height: 3.8mm;
  --row-gap: 1.05mm;
  --course-gap-height: 11.8mm;
  --capture-input-text-offset-y: -0.10mm;
  background: #ffffff;
}

body.capture-print .paper {
  position: relative;
  width: 194mm;
  height: 297mm;
  min-height: 297mm;
  max-height: 297mm;
  margin: 0 auto;
  padding: 14mm 11mm 9mm;
  gap: 5mm;
  box-shadow: none;
  overflow: hidden;
  border: 0;
}

body.capture-print .paper-content {
  padding-top: 1.5mm;
}

body.capture-print .paper-footer {
  padding-top: 5mm;
}

body.capture-print .stage {
  min-height: 0;
  padding: 0;
  display: block;
}

body.capture-print .paper-shell {
  display: block;
  gap: 0;
}

body.capture-print .sheet-grid {
  grid-template-columns: 66mm 1fr !important;
}

body.capture-print .footer-row,
body.capture-print .third-row {
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 0.68fr) minmax(0, 0.85fr) !important;
}

body.capture-print .code-row.is-selected {
  border-color: red;
  box-shadow: none;
  background: transparent;
}

body.capture-print .circle-choice input:checked + span {
  border-color: red;
}

body.capture-print .time-row input,
body.capture-print .line-field input {
  -webkit-appearance: none;
  appearance: none;
  box-shadow: none;
}

body.capture-print .time-row input {
  font-size: 7pt;
  line-height: normal;
  padding: 0 1.4mm;
}

body.capture-print .time-row input.capture-text-hidden {
  color: transparent;
  caret-color: transparent;
}

body.capture-print .capture-value-overlay {
  position: absolute;
  display: flex;
  align-items: center;
  padding: 0 1.4mm;
  font-size: 7pt;
  line-height: 1;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  pointer-events: none;
  transform: translateY(var(--capture-input-text-offset-y));
}

.paper-region {
  position: relative;
}

.paper-region::before {
  display: none;
}

.paper-header {
  padding-bottom: 0;
}

.brand-row {
  display: grid;
  grid-template-rows: auto auto;
  row-gap: 3mm;
}

.brand-logo {
  position: static;
  width: 26mm;
  height: auto;
  display: block;
  object-fit: contain;
}

.title-block {
  width: 100%;
  text-align: center;
  padding-top: 0;
}

.sheet-title {
  margin: 0 0 1mm;
  font-size: 8pt;
  font-weight: 700;
  text-transform: uppercase;
  text-decoration: underline;
  letter-spacing: 0.08em;
}

.paper h1 {
  margin: 0;
  font-size: 8.6pt;
  line-height: 1.2;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.sheet-note {
  margin: 1mm 0 0;
  font-size: 7.3pt;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.paper-content {
  padding-top: 3mm;
}

.sheet-grid {
  display: grid;
  grid-template-columns: 66mm 1fr;
  gap: 9mm;
  align-items: start;
}

.panel-head,
.code-row,
.time-row {
  display: grid;
  align-items: center;
}

.panel-head {
  grid-template-columns: 15mm 1fr;
  gap: 5mm;
  padding-bottom: 1.4mm;
  margin-bottom: 0.6mm;
  font-size: 7.2pt;
  font-weight: 700;
  text-transform: uppercase;
}

.code-list {
  display: grid;
  gap: var(--row-gap);
}

.code-row {
  grid-template-columns: 15mm 1fr;
  gap: 5mm;
  min-height: 0;
  height: var(--row-height);
  padding: 0 1.2mm;
  font-size: 7pt;
  line-height: 1;
  text-transform: uppercase;
  border-radius: 999px;
  border: 1px solid transparent;
  box-shadow: none;
  background: transparent;
  cursor: pointer;
  user-select: none;
}

.code-row.is-selected {
  border-color: red;
}

.code-row:focus-visible {
  outline: none;
  border-color: var(--paper-line);
}

.code-row strong {
  font-weight: 700;
  line-height: 1;
}

.code-row span {
  line-height: 1;
}

.course-label-block {
  display: flex;
  align-items: center;
  min-height: var(--course-gap-height);
  padding-left: 20mm;
  font-size: 7pt;
  font-weight: 700;
  text-transform: uppercase;
}

.course-label-block.second {
  min-height: var(--course-gap-height);
}

.bottom-group {
  margin-top: 0;
}

.final-group {
  margin-top: 0;
}

.time-panel {
  display: grid;
  gap: 0;
}

.time-row {
  grid-template-columns: 1fr 1fr 1fr 0.78fr;
  gap: 0;
}

.time-header {
  margin-bottom: 0.6mm;
}

.time-header span {
  padding: 0 0 1.4mm;
  font-size: 7.2pt;
  font-weight: 700;
  text-transform: uppercase;
  text-align: center;
}

.time-body {
  display: grid;
  gap: var(--row-gap);
}

.time-row input {
  width: 100%;
  height: var(--row-height);
  padding: 0 1.4mm;
  border: 1px solid var(--paper-line);
  border-right-width: 0;
  background: transparent;
  color: var(--ink);
  font-size: 7pt;
  outline: none;
  border-radius: 0;
}

.time-row input[readonly] {
  background: rgba(0, 0, 0, 0.015);
}

.time-row input.input-error {
  border-color: #b60000;
}

.time-row input:last-child {
  border-right-width: 1px;
}

.course-gap {
  height: var(--course-gap-height);
  margin: 0;
  display: flex;
  align-items: center;
}

.course-freewrite {
  width: 100%;
  height: calc(2.4em + 0.8mm);
  max-height: calc(2.4em + 0.8mm);
  resize: none;
  margin: 0;
  padding: 0.4mm 0.8mm;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 7pt;
  line-height: 1.2;
  overflow: hidden;
  outline: none;
}

.course-freewrite:focus {
  outline: none;
}

.short-group,
.final-group {
  margin-top: 0;
}

.paper-footer {
  padding-top: 8mm;
}

.footer-rows {
  display: grid;
  gap: 3.2mm;
}

.footer-row {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 0.68fr) minmax(0, 0.85fr);
  gap: 4mm;
  align-items: end;
}

.third-row {
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 0.68fr) minmax(0, 0.85fr);
}

.line-field,
.plain-field {
  display: flex;
  align-items: flex-end;
  gap: 1.5mm;
  min-height: 7mm;
  min-width: 0;
}

.line-field span,
.plain-field span {
  flex: 0 0 auto;
  font-size: 7.2pt;
  font-weight: 700;
  text-transform: uppercase;
}

.line-field input {
  flex: 1 1 auto;
  min-width: 0;
  height: 5.6mm;
  padding: 0 0.6mm;
  border: 0;
  border-bottom: 1px solid var(--paper-line);
  background: transparent;
  color: var(--ink);
  font-size: 7.4pt;
  outline: none;
  border-radius: 0;
}

.line-field:not(.handwritten-field) input {
  font-size: 10pt;
}

.handwritten-field input {
  font-family: "Brush Script MT", "Segoe Script", cursive;
  font-size: 12pt;
}

.signature-line input {
  font-size: 13pt;
}

.wide {
  grid-column: auto;
}

.plain-text {
  justify-content: space-between;
}

.plain-text strong {
  font-size: 7.6pt;
  font-weight: 700;
  text-transform: uppercase;
}

.per-diem {
  align-items: flex-end;
  justify-content: flex-start;
  min-width: 0;
  gap: 1.2mm;
}

.per-diem > span {
  line-height: 1;
  white-space: nowrap;
}

.circle-choice {
  position: relative;
  display: inline-flex;
  align-items: center;
  align-self: flex-end;
  transform: translateY(1.22mm);
  cursor: pointer;
}

.circle-choice input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.circle-choice span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 7.5mm;
  height: 4.9mm;
  padding: 0 1.2mm;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 7.6pt;
  font-weight: 700;
  text-transform: uppercase;
  line-height: 1;
}

.circle-choice input:checked + span {
  border-color: red;
}

@page {
  size: A4;
  margin: 0 8mm;
}

@media print {
  :root {
    color-scheme: light;
    --row-height: 3.8mm;
    --row-gap: 1.05mm;
    --course-gap-height: 11.8mm;
  }

  html,
  body {
    width: auto;
    height: auto;
    min-height: 0;
    margin: 0;
    padding: 0;
    background: #ffffff;
    color: #000000;
  }

  .stage {
    min-height: 0;
    padding: 0;
    display: block;
  }

  .paper-shell {
    display: block;
    gap: 0;
  }

  .paper-meta {
    display: none;
  }

  .paper-region::before {
    display: none;
  }

  .paper {
    width: 194mm;
    height: 297mm;
    min-height: 297mm;
    max-height: 297mm;
    margin: 0 auto;
    padding: 14mm 11mm 9mm;
    gap: 5mm;
    box-shadow: none;
    overflow: hidden;
    break-inside: avoid;
    page-break-inside: avoid;
    page-break-after: avoid;
    border: 0;
  }

  .paper-content {
    padding-top: 1.5mm;
  }

  .paper-footer {
    padding-top: 5mm;
  }

  .time-row input,
  .line-field input {
    -webkit-appearance: none;
    appearance: none;
    box-shadow: none;
  }

  .line-field input,
  .time-row input,
  .plain-text strong,
  .sheet-title,
  .paper h1,
  .sheet-note,
  .panel-head,
  .code-row,
  .course-label-block,
  .line-field span,
  .plain-field span {
    color: #000000;
  }

  .time-row input.input-error {
    border-color: var(--paper-line);
  }
}


/* Keep print layout in desktop mode so the form does not stack into two pages. */
@media print {
  .sheet-grid {
    grid-template-columns: 66mm 1fr !important;
  }

  .footer-row,
  .third-row {
    grid-template-columns: 1.35fr 0.75fr 0.68fr !important;
  }

  .title-block {
    padding-top: 0 !important;
  }
}