:root {
  --bg: #f2f5f1;
  --surface: #ffffff;
  --surface-alt: #eef7f1;
  --text: #16231a;
  --muted: #54675a;
  --line: #c7d6cb;
  --accent: #0f7d52;
  --accent-strong: #0a633f;
  --danger: #9e2f2f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, sans-serif;
}

body.result-page {
  background: #ffffff;
}

.page {
  max-width: 980px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

.hero,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 20px;
}

.hero-success {
  background: var(--surface-alt);
}

h1,
h2 {
  margin: 0 0 10px;
}

p {
  margin: 0;
  line-height: 1.5;
}

form {
  display: grid;
  gap: 20px;
}

.grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

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

.field {
  display: grid;
  gap: 6px;
}

.is-hidden {
  display: none;
}

.participant-list {
  display: grid;
  gap: 10px;
}

.participant-row {
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1.3fr) minmax(160px, 0.8fr);
}

label {
  font-weight: 700;
}

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid #9eb5a5;
  border-radius: 6px;
  padding: 10px 12px;
  background: #fff;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus,
button:focus,
.button:focus {
  outline: 3px solid rgba(15, 125, 82, 0.22);
  outline-offset: 1px;
}

.checkbox-field {
  align-content: end;
}

.checkbox-field label {
  display: flex;
  gap: 10px;
  align-items: center;
}

.checkbox-field input {
  width: auto;
}

.hint {
  color: var(--muted);
  font-size: 0.95rem;
}

.top-gap {
  margin-top: 12px;
}

.error-text {
  color: var(--danger);
  font-size: 0.95rem;
}

.actions,
.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.classification-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

[data-subject-select] {
  min-height: 44px;
}


button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 16px;
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
  font-weight: 700;
}

button:hover,
.button:hover {
  background: var(--accent-strong);
}

.button.secondary {
  background: #e6efe9;
  color: var(--text);
}

.ficha-wrapper {
  display: flex;
  justify-content: center;
  margin-bottom: 20px;
}

.ficha-card {
  width: 12cm;
  min-height: 7.5cm;
  border: 1px solid #333;
  padding: 0.6cm;
  background: #fff;
  --ficha-cutter-width: 1.2cm;
  --ficha-cutter-gap: 0.32cm;
  --ficha-block-indent: 0.55cm;
}

.ficha-layout {
  min-height: calc(7.5cm - 1.2cm);
  display: flex;
  flex-direction: column;
  gap: 0.28cm;
  font-family: Arial, sans-serif;
  font-size: 10pt;
  line-height: 1.35;
}

.ficha-layout p {
  margin: 0;
}

.ficha-top {
  display: grid;
  grid-template-columns: var(--ficha-cutter-width) minmax(0, 1fr);
  gap: var(--ficha-cutter-gap);
  align-items: start;
}

.ficha-cutter {
  text-align: left;
  white-space: nowrap;
}

.ficha-main {
  display: grid;
  gap: 0.08cm;
}

.ficha-author {
  text-indent: 0;
}

.ficha-title,
.ficha-physical,
.ficha-middle p,
.ficha-subjects p {
  text-indent: var(--ficha-block-indent);
  padding-right: 0.1cm;
}

.ficha-middle,
.ficha-subjects {
  display: grid;
  gap: 0.08cm;
  margin-left: calc(var(--ficha-cutter-width) + var(--ficha-cutter-gap));
}

.ficha-bottom {
  margin-top: auto;
  display: flex;
  justify-content: flex-end;
}

.ficha-cdd {
  text-align: right;
  white-space: nowrap;
}

footer {
  text-align: center;
  margin-top: 20px;
  font-size: 0.9rem;
  color: var(--muted);
  justify-self: anchor-center;
}

@media print {
  body,
  body.result-page {
    background: #fff;
  }

  .hero,
  .panel,
  .result-actions,
  footer {
    display: none;
  }

  .page {
    max-width: none;
    padding: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
  }

  .ficha-wrapper {
    margin-top: auto;  
    margin-bottom: 0;
    justify-content: center;
  }

  .ficha-card {
    border: 1px solid #333;
    margin: 0;
  }
}

@media (max-width: 720px) {
  .participant-row {
    grid-template-columns: 1fr;
  }
}
