:root {
  --ink: #12242a;
  --muted: #5b6f76;
  --paper: #ffffff;
  --canvas: #f6f5ef;
  --line: #d9ddd2;
  --primary: #0c5b52;
  --accent: #dc6b2f;
  --danger: #a5352f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at 20% 10%, #e8f3ef, transparent 40%),
    radial-gradient(circle at 80% 40%, #f5e4ce, transparent 35%),
    var(--canvas);
  color: var(--ink);
  font-family: "Avenir Next", Avenir, "Trebuchet MS", sans-serif;
}

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

.bg-shape {
  position: fixed;
  z-index: -1;
  border-radius: 999px;
  filter: blur(16px);
  opacity: 0.45;
}

.bg-shape-1 {
  width: 260px;
  height: 260px;
  background: #cbe8df;
  top: -110px;
  left: -80px;
}

.bg-shape-2 {
  width: 300px;
  height: 300px;
  background: #f7d6b6;
  right: -100px;
  top: 35%;
}

.app-header {
  background: linear-gradient(110deg, #0b4e46, #0c5b52 48%, #1b6b62);
  color: white;
  padding: 26px max(20px, calc((100vw - 1120px) / 2));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.eyebrow {
  margin: 0;
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #b6e0d8;
  font-weight: 700;
}

.app-header h1 {
  margin: 2px 0 5px;
  font-size: clamp(1.75rem, 3.8vw, 3rem);
}

.subtitle {
  margin: 0;
  max-width: 780px;
  color: #def1ec;
}

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

main {
  max-width: 1120px;
  margin: 0 auto;
  padding: 20px;
}

.season-bar {
  display: grid;
  grid-template-columns: minmax(180px, 0.7fr) minmax(180px, 0.7fr) 2fr;
  gap: 12px;
  align-items: end;
  padding: 16px;
  border: 1px solid var(--line);
  border-top: 4px solid var(--primary);
  background: var(--paper);
}

.season-state {
  min-height: 42px;
  padding: 5px 10px;
  border-left: 1px solid var(--line);
}

.season-state span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
}

.season-state strong {
  display: block;
  margin-top: 3px;
}

.season-active {
  color: #0f684f;
}

.season-closed {
  color: #73501e;
}

.season-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.season-notice {
  grid-column: 1 / -1;
  margin: 0;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.86rem;
}

.status-bar {
  background: var(--paper);
  border: 1px solid var(--line);
  border-left: 5px solid var(--accent);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  padding: 16px;
}

.status-bar div {
  border-left: 1px solid #e8ece2;
  padding-left: 12px;
}

.status-bar div:first-child {
  border-left: 0;
  padding-left: 0;
}

.status-bar span {
  color: var(--muted);
  font-size: 0.82rem;
}

.status-bar strong {
  display: block;
  margin-top: 4px;
  font-size: 1.4rem;
  color: var(--primary);
}

.tabs {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tab {
  border: 1px solid #95b3ad;
  background: white;
  color: var(--primary);
  font-weight: 700;
  min-height: 42px;
  padding: 8px 12px;
  cursor: pointer;
}

.tab.is-active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.panel {
  display: none;
  margin-top: 14px;
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 22px;
}

.panel.is-active {
  display: block;
  animation: panelIn 230ms ease;
}

@keyframes panelIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.panel-heading h2 {
  margin: 0;
  font-size: 1.4rem;
}

.panel-heading p {
  margin: 6px 0 0;
  color: var(--muted);
}

.audit-link {
  color: var(--primary);
  font-weight: 700;
}

.form-grid {
  margin-top: 16px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.9rem;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #a4b7b2;
  border-radius: 4px;
  min-height: 42px;
  padding: 9px 10px;
  background: white;
  color: var(--ink);
}

input:focus,
select:focus,
textarea:focus {
  outline: 3px solid #c7e5dd;
  border-color: var(--primary);
}

textarea {
  resize: vertical;
}

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

.activity-options {
  margin: 0;
  border: 1px solid #a4b7b2;
  padding: 12px;
}

.activity-options legend {
  padding: 0 6px;
  font-weight: 700;
}

.activity-options label {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  margin-right: 20px;
}

.activity-options input {
  width: 20px;
  min-height: 20px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.primary-button,
.outline-button,
.danger-button,
.secondary-button,
.warning-button {
  min-height: 42px;
  border: 1px solid var(--primary);
  border-radius: 4px;
  padding: 8px 14px;
  font-weight: 700;
  cursor: pointer;
}

.text-action {
  border: 1px solid var(--primary);
  background: white;
  color: var(--primary);
  min-height: 34px;
  padding: 5px 9px;
  font-weight: 700;
  cursor: pointer;
}

.storage-note {
  margin: 14px 0 0;
  padding: 10px 12px;
  border-left: 4px solid var(--accent);
  background: #fff5e9;
  color: #725238;
}

.status-red {
  color: var(--danger) !important;
}

.status-orange {
  color: #9b5a18 !important;
}

.status-green {
  color: #0f684f !important;
}

.primary-button {
  background: var(--primary);
  color: white;
}

.outline-button {
  background: transparent;
  color: white;
  border-color: #8bb8b1;
}

.danger-button {
  border-color: #d3a39d;
  color: var(--danger);
  background: white;
}

.secondary-button {
  border-color: #8aa19c;
  color: var(--ink);
  background: white;
}

.warning-button {
  border-color: #a96b24;
  color: #744615;
  background: #fff4df;
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.table-wrap {
  margin-top: 14px;
  overflow: auto;
  border: 1px solid var(--line);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}

th,
td {
  padding: 9px 10px;
  border-bottom: 1px solid #e7ebe1;
  text-align: left;
  vertical-align: top;
}

th {
  background: #edf6f3;
  color: #154f47;
  position: sticky;
  top: 0;
}

.overdue {
  color: var(--danger);
  font-weight: 700;
}

.cards {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}

.card {
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  padding: 12px;
  background: #fff;
}

.card h3 {
  margin: 0 0 8px;
}

.card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.card .meta {
  margin-top: 8px;
  font-size: 0.82rem;
  color: #4e676e;
}

.doc-grid {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}

.doc-item {
  border: 1px solid var(--line);
  background: #fff;
  padding: 12px;
}

.doc-item h3 {
  margin: 0 0 6px;
  color: #144b44;
}

.doc-item p,
.doc-item li {
  color: var(--muted);
  margin: 0;
}

.doc-item ul {
  margin: 8px 0 0;
  padding-left: 18px;
}

.compliance-box {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--primary);
  background: #f8fbfa;
  padding: 14px;
}

.compliance-box h3 {
  margin: 0;
  color: #154f47;
}

.compliance-box p {
  margin: 6px 0 0;
  color: var(--muted);
}

.compliance-box ul {
  margin: 12px 0 0;
  padding-left: 18px;
  display: grid;
  gap: 8px;
}

.compliance-box li {
  border: 1px solid #dbe4df;
  padding: 8px;
  list-style: none;
}

.compliance-ok {
  background: #eaf6f1;
}

.compliance-ok strong {
  color: #0f684f;
}

.compliance-missing {
  background: #fff0ee;
}

.compliance-missing strong {
  color: var(--danger);
}

.compliance-box li span {
  color: var(--muted);
}

.print-controls {
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
}

.print-controls label {
  min-width: 180px;
}

.print-pack {
  display: none;
}

.print-title-block {
  border-bottom: 2px solid var(--primary);
  margin-bottom: 12px;
}

.print-title-block h1 {
  margin: 0 0 4px;
}

.print-title-block p {
  margin: 2px 0;
}

.print-card {
  border: 1px solid #b9c7c3;
  margin: 0 0 12px;
  padding: 8px;
}

.print-card h2 {
  margin: 0 0 8px;
  font-size: 1.05rem;
  color: #154f47;
}

.print-text {
  white-space: pre-line;
  line-height: 1.45;
}

.print-public-details {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 12px;
  margin-bottom: 10px;
}

.print-public-details p {
  margin: 0;
  padding: 7px;
  background: #edf6f3;
}

.separate-attachments {
  margin-top: 10px;
  padding: 8px;
  border: 1px solid #cbd4d1;
}

.separate-attachments h3 {
  margin: 0 0 6px;
  font-size: 1rem;
}

.print-hidden {
  display: none !important;
}

.print-signatures > div {
  display: grid;
  grid-template-columns: 1.3fr 1fr 2fr;
  gap: 10px;
  min-height: 28mm;
  padding: 8px;
  border-top: 1px solid #cbd4d1;
}

.manual-check-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 12px 0;
}

.manual-check-grid span {
  min-height: 12mm;
  padding: 8px;
  border: 1px solid #cbd4d1;
}

.form-certification {
  margin-top: 12px;
  padding: 10px;
  border: 1px solid #cbd4d1;
}

dialog {
  width: min(620px, calc(100vw - 24px));
  padding: 0;
  border: 0;
  color: var(--ink);
  box-shadow: 0 24px 70px rgba(18, 36, 42, 0.3);
}

dialog::backdrop {
  background: rgba(12, 38, 42, 0.64);
}

#newSeasonForm {
  padding: 22px;
}

.dialog-heading {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.dialog-heading h2 {
  margin: 2px 0 4px;
}

.dialog-heading p:last-child {
  margin: 0;
  color: var(--muted);
}

.dialog-heading .eyebrow {
  color: var(--primary);
}

.dialog-close {
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  border: 0;
  background: #edf3f0;
  color: var(--ink);
  font-size: 1.6rem;
  cursor: pointer;
}

.season-choice-list {
  margin: 18px 0 0;
  padding: 0;
  border: 0;
}

.season-choice-list legend {
  margin-bottom: 8px;
  font-weight: 700;
}

.season-choice-list label {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 10px;
  align-items: start;
  padding: 12px;
  border: 1px solid var(--line);
  cursor: pointer;
}

.season-choice-list label + label {
  margin-top: 8px;
}

.season-choice-list input {
  width: 20px;
  min-height: 20px;
  margin: 2px 0 0;
}

.season-choice-list strong,
.season-choice-list small {
  display: block;
}

.season-choice-list small {
  margin-top: 3px;
  color: var(--muted);
  font-weight: 500;
  line-height: 1.4;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

@media (max-width: 760px) {
  .app-header {
    padding: 20px 16px;
    flex-direction: column;
    align-items: flex-start;
  }

  .header-actions {
    width: 100%;
  }

  .header-actions button {
    flex: 1;
  }

  main {
    padding: 12px;
  }

  .status-bar {
    grid-template-columns: 1fr 1fr;
  }

  .season-bar {
    grid-template-columns: 1fr;
  }

  .season-state {
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .season-actions {
    justify-content: stretch;
  }

  .season-actions button {
    flex: 1 1 150px;
  }

  .season-notice {
    grid-column: auto;
  }

  .dialog-actions {
    flex-direction: column-reverse;
  }

  .dialog-actions button {
    width: 100%;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .wide {
    grid-column: auto;
  }
}

@media print {
  @page {
    size: A4 portrait;
    margin: 10mm;
  }

  body.print-A4-landscape {
    --print-size: A4 landscape;
  }

  body.print-A3-portrait {
    --print-size: A3 portrait;
  }

  body.print-A3-landscape {
    --print-size: A3 landscape;
  }

  @page {
    size: var(--print-size, A4 portrait);
  }

  body > :not(main),
  main > :not(.print-pack) {
    display: none !important;
  }

  body {
    background: white;
    color: #111;
  }

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

  .print-pack {
    display: block;
    font-size: 10pt;
  }

  .print-title-block {
    break-after: avoid;
  }

  .print-card {
    break-inside: avoid;
  }

  .print-card table {
    break-inside: auto;
  }

  .print-card tr {
    break-inside: avoid;
  }

  .print-card thead {
    display: table-header-group;
  }

  .print-form-page {
    break-before: page;
    min-height: 260mm;
  }

  body.print-A4-landscape .print-form-page {
    min-height: 175mm;
  }

  body.print-A3-portrait .print-form-page {
    min-height: 370mm;
  }

  body.print-A3-landscape .print-form-page {
    min-height: 260mm;
  }

  .print-form-page tbody td {
    height: 12mm;
  }

  .print-pack table {
    font-size: 9pt;
  }

  .print-pack th {
    background: #ececec !important;
    color: #111 !important;
  }

  body.print-A3-portrait .print-pack,
  body.print-A3-landscape .print-pack {
    font-size: 11pt;
  }

  body.print-A3-portrait .print-pack table,
  body.print-A3-landscape .print-pack table {
    font-size: 10pt;
  }
}
