:root {
  --teal: #003942;
  --teal-soft: #174f57;
  --gold: #c5a880;
  --paper: #f3f3f3;
  --ink: #222222;
  --muted: #5d6a6c;
  --line: #bfcdd0;
  --white: #ffffff;
  --danger: #8b2e2e;
  font-family: "Segoe UI", "Avenir Next", Avenir, sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 320px; background: var(--paper); }
button, input, select { font: inherit; }
h1, h2, .header-title, .eyebrow, .slot-index, .slot-title {
  font-family: Montserrat, "Avenir Next", "Segoe UI", sans-serif;
}
h1 { margin: .35rem 0 .65rem; font-size: clamp(2rem, 4vw, 3.4rem); line-height: 1.08; font-weight: 400; }
h2 { margin: 0 0 .35rem; font-size: 1.15rem; font-weight: 500; }
p { margin: 0; }
.small { font-size: .86rem; }
.muted { color: var(--muted); }
.eyebrow { margin: 0; color: var(--muted); font-size: .72rem; letter-spacing: .15em; text-transform: uppercase; font-weight: 600; }

.brand-header {
  min-height: 6.25rem;
  padding: .8rem clamp(1rem, 4vw, 3.5rem);
  display: grid;
  grid-template-columns: minmax(7.5rem, .8fr) minmax(11rem, 2fr) minmax(8rem, .8fr);
  align-items: center;
  gap: 1rem;
  background: var(--teal);
  color: var(--white);
}
.official-logo { display: block; width: 7rem; max-width: 100%; filter: brightness(0) invert(1); }
.header-title { text-align: center; font-size: .9rem; font-weight: 400; letter-spacing: .13em; text-transform: uppercase; }
.header-status { justify-self: end; padding: .42rem .72rem; border: 1px solid var(--white); border-radius: 999px; font-size: .76rem; }

.content { width: min(1180px, 100%); margin: 0 auto; padding: 1.5rem clamp(1rem, 4vw, 3.5rem) 2rem; }
.gold-rule { height: 1px; margin-bottom: 2rem; background: var(--gold); }
.hero { max-width: 48rem; margin-bottom: 2rem; }
.hero > .muted { font-size: 1.05rem; }

.period-row, .action-row, .result-card, footer { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.period-row { align-items: end; padding: 1rem 0; margin-bottom: 1.4rem; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.period-copy { max-width: 31rem; }
.period-controls { display: flex; gap: .75rem; align-items: end; }
label { display: grid; gap: .42rem; color: var(--teal); font-size: .78rem; font-weight: 600; letter-spacing: .04em; }
select, dialog input { min-height: 2.75rem; padding: .55rem .8rem; border: 1px solid #93a7aa; border-radius: 2px; color: var(--ink); background: var(--white); }
select:focus, dialog input:focus, button:focus-visible, a:focus-visible, .upload-slot:focus-within { outline: 3px solid rgba(197, 168, 128, .5); outline-offset: 2px; }

.stepper { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .9rem; padding: 0; margin: 0 0 1.4rem; list-style: none; }
.step { display: grid; gap: .18rem; padding-top: .7rem; border-top: 2px solid var(--line); color: var(--muted); }
.step strong { color: var(--ink); font-weight: 500; }
.step span { font-size: .82rem; }
.step.is-current { border-color: var(--teal); }
.step.is-current strong, .step.is-current span { color: var(--teal); }

.upload-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .9rem; }
.upload-slot { min-height: 13rem; padding: 1.1rem; display: flex; flex-direction: column; align-items: flex-start; gap: .65rem; border: 1px dashed #93a7aa; background: rgba(255, 255, 255, .68); cursor: pointer; transition: border-color .2s, background .2s; }
.upload-slot:hover, .upload-slot.has-file { border-color: var(--teal); background: var(--white); }
.slot-index { color: #9b7b52; font-weight: 600; }
.slot-title { color: var(--ink); font-size: 1.02rem; font-weight: 500; }
.upload-slot input { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; }
.file-button { margin-top: auto; padding: .55rem .78rem; border: 1px solid var(--teal); color: var(--teal); font-size: .8rem; letter-spacing: .03em; }
.file-name { width: 100%; overflow: hidden; color: var(--muted); font-size: .76rem; text-overflow: ellipsis; white-space: nowrap; }

.action-row { margin-top: 1.2rem; }
.primary-button { display: inline-flex; min-height: 2.85rem; padding: .7rem 1.15rem; align-items: center; justify-content: center; border: 1px solid var(--teal); border-radius: 0; background: var(--teal); color: var(--white); text-decoration: none; cursor: pointer; }
.primary-button:hover { background: var(--teal-soft); }
.primary-button:disabled { opacity: .5; cursor: wait; }
.message { margin-top: 1rem; padding: .9rem 1rem; border-left: 3px solid var(--gold); background: var(--white); }
.message.error { border-color: var(--danger); color: var(--danger); }
.result-card { margin-top: 1.5rem; padding: 1.4rem; border: 1px solid var(--gold); background: var(--white); }
.warnings { margin: .7rem 0 0; padding-left: 1.2rem; color: var(--danger); font-size: .86rem; }
footer { margin-top: 2.2rem; padding-top: 1rem; border-top: 1px solid var(--line); color: var(--muted); font-size: .76rem; }
.text-button { border: 0; border-bottom: 1px solid currentColor; padding: .15rem 0; background: transparent; color: var(--teal); cursor: pointer; }

dialog { width: min(28rem, calc(100% - 2rem)); padding: 0; border: 0; box-shadow: 0 1.5rem 5rem rgba(0, 30, 35, .3); }
dialog::backdrop { background: rgba(0, 30, 35, .68); }
dialog form { display: grid; gap: 1rem; padding: 2rem; background: var(--paper); }
dialog img { width: 7rem; margin-bottom: .5rem; }
dialog .primary-button { width: 100%; margin-top: .25rem; }
.form-error { color: var(--danger); font-size: .84rem; }

@media (max-width: 720px) {
  .brand-header { grid-template-columns: auto 1fr; }
  .header-title { text-align: right; }
  .header-status { grid-column: 1 / -1; justify-self: stretch; text-align: center; }
  .period-row, .result-card { align-items: stretch; flex-direction: column; }
  .period-controls, .period-controls label { width: 100%; }
  .period-controls select { width: 100%; }
  .upload-grid, .stepper { grid-template-columns: 1fr; }
  .upload-slot { min-height: 11rem; }
}

@media (max-width: 460px) {
  .action-row { align-items: stretch; flex-direction: column; }
  .primary-button { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}
