:root {
  color-scheme: light;
  --ink: #251723;
  --muted: #665762;
  --soft: #f8f4f7;
  --white: #ffffff;
  --line: #eadde6;
  --magenta: #9d0f63;
  --magenta-deep: #6f0b49;
  --orange: #f28a1d;
  --orange-deep: #cc6411;
  --shadow: 0 20px 54px rgba(111, 11, 73, 0.13);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Arial, Helvetica, sans-serif;
  background: linear-gradient(120deg, rgba(157, 15, 99, 0.08), rgba(242, 138, 29, 0.08)), var(--soft);
  color: var(--ink);
}

a {
  color: inherit;
}

.shell {
  width: min(1080px, calc(100% - 28px));
  margin: 0 auto;
}

.portal-header {
  padding: 14px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.portal-logo img {
  width: min(210px, 48vw);
  display: block;
}

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

.link-button,
.button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 15px;
  border: 0;
  border-radius: 8px;
  background: var(--magenta);
  color: var(--white);
  font: inherit;
  font-weight: 800;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
}

.link-button.secondary,
.button.secondary {
  border: 1px solid rgba(157, 15, 99, 0.22);
  background: var(--white);
  color: var(--magenta-deep);
}

.card {
  margin: 12px auto 28px;
  padding: clamp(20px, 4vw, 34px);
  border: 1px solid rgba(234, 221, 230, 0.94);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.narrow {
  max-width: 560px;
}

.page-title {
  margin: 0;
  color: var(--magenta-deep);
  font-size: clamp(28px, 5vw, 42px);
  line-height: 1.08;
  letter-spacing: 0;
}

.lead {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.55;
}

.alert {
  margin: 0 0 16px;
  padding: 12px 14px;
  border-radius: 8px;
  background: rgba(242, 138, 29, 0.14);
  color: var(--orange-deep);
  font-weight: 700;
  line-height: 1.45;
}

.success {
  background: rgba(37, 128, 86, 0.12);
  color: #17613f;
}

form {
  margin-top: 24px;
}

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

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

.field.full,
.section.full {
  grid-column: 1 / -1;
}

label,
legend {
  color: var(--ink);
  font-size: 14px;
  font-weight: 800;
}

input,
textarea,
select {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  color: var(--ink);
  font: inherit;
}

.password-control {
  position: relative;
  display: block;
  width: 100%;
}

.password-control input {
  display: block;
  padding-right: 48px;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  z-index: 2;
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: var(--white);
  color: var(--muted);
  cursor: pointer;
}

.password-toggle:hover,
.password-toggle:focus-visible,
.password-toggle.is-visible {
  color: var(--magenta-deep);
}

.password-toggle svg {
  width: 20px;
  height: 20px;
  pointer-events: none;
}

textarea {
  min-height: 86px;
  resize: vertical;
}

fieldset {
  margin: 24px 0 0;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

legend {
  padding: 0 8px;
  color: var(--magenta-deep);
  font-size: 17px;
}

.actions {
  margin-top: 22px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.children-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
}

.children-table th,
.children-table td {
  padding: 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.children-table th {
  color: var(--magenta-deep);
  font-size: 13px;
}

.children-table input,
.children-table select {
  min-height: 40px;
}

.small {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.document-card {
  max-width: 980px;
}

.document-heading {
  display: flex;
  align-items: center;
  gap: 22px;
  padding-bottom: 20px;
  border-bottom: 2px solid var(--line);
}

.document-heading img {
  width: 170px;
  height: auto;
  flex: 0 0 auto;
}

.document-section {
  margin-top: 24px;
}

.document-section h2 {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(157, 15, 99, 0.08);
  color: var(--magenta-deep);
  font-size: 18px;
  letter-spacing: 0;
}

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

.detail-grid div {
  min-height: 70px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
}

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

.detail-grid span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.detail-grid strong {
  display: block;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.45;
  word-break: break-word;
}

.empty {
  color: #8a7c85;
  font-style: italic;
  font-weight: 400;
}

.empty-block {
  margin: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  color: var(--muted);
}

.table-scroll {
  overflow-x: auto;
}

.document-table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
  background: var(--white);
}

.document-table th,
.document-table td {
  padding: 11px 10px;
  border: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.document-table th {
  color: var(--magenta-deep);
  background: rgba(242, 138, 29, 0.08);
  font-size: 13px;
}

.document-footer {
  margin-top: 24px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 22px;
}

.stats-grid div {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
}

.stats-grid span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.stats-grid strong {
  display: block;
  margin-top: 8px;
  color: var(--magenta-deep);
  font-size: 30px;
  line-height: 1;
}

.table-action {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  justify-content: center;
  padding: 7px 11px;
  border-radius: 8px;
  background: rgba(157, 15, 99, 0.1);
  color: var(--magenta-deep);
  font-weight: 800;
  text-decoration: none;
}

.status-card {
  margin-top: 22px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
}

.status-card span,
.status-card small {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.status-card strong {
  display: block;
  margin: 8px 0;
  color: var(--magenta-deep);
  font-size: 22px;
  line-height: 1.2;
}

@media (max-width: 760px) {
  .portal-header,
  .header-links {
    align-items: stretch;
    flex-direction: column;
  }

  .portal-logo {
    display: flex;
    justify-content: center;
  }

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

  .card {
    margin-top: 8px;
    padding: 18px;
  }

  fieldset {
    padding: 16px;
  }

  .actions,
  .document-footer {
    display: grid;
  }

  .button,
  .link-button {
    width: 100%;
  }

  .document-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 14px;
  }

  .document-heading img {
    width: min(210px, 100%);
  }

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

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

  .children-table,
  .children-table thead,
  .children-table tbody,
  .children-table tr,
  .children-table th,
  .children-table td,
  .document-table,
  .document-table thead,
  .document-table tbody,
  .document-table tr,
  .document-table th,
  .document-table td {
    display: block;
  }

  .children-table thead,
  .document-table thead {
    display: none;
  }

  .children-table tr,
  .document-table tr {
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
  }

  .children-table td,
  .document-table td {
    border: 0;
    padding: 6px 0;
  }

  .document-table {
    min-width: 0;
  }

  .children-table td::before,
  .document-table td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 5px;
    color: var(--magenta-deep);
    font-size: 13px;
    font-weight: 800;
  }
}

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

  .shell {
    width: 100%;
  }

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

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

  .document-heading img {
    width: 150px;
  }

  .document-section {
    break-inside: avoid;
  }
}
