:root {
  --ink: #44464a;
  --pine: #4b4c50;
  --moss: #f47f2c;
  --amber: #f47f2c;
  --paper: #f8f8f7;
  --line: #dedfdf;
  --muted: #707276;
  --danger: #b54b43;
  --white: #ffffff;
  --shadow: 0 16px 42px rgba(75, 76, 80, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: linear-gradient(180deg, #f1f1f0 0, #ffffff 240px);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.5;
}

a {
  color: var(--pine);
}

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

button,
a.primary-button,
a.ghost-button,
a.admin-link {
  min-height: 44px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--white);
  color: var(--ink);
  margin-top: 6px;
  padding: 11px 12px;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus,
button:focus,
a:focus {
  outline: 3px solid rgba(244, 127, 44, 0.35);
  outline-offset: 2px;
}

label {
  color: var(--pine);
  display: block;
  font-size: 0.9rem;
  font-weight: 700;
}

label span {
  color: var(--danger);
}

.app-header {
  align-items: center;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  padding: 10px clamp(16px, 4vw, 40px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand img {
  display: block;
  height: 76px;
  object-fit: contain;
  width: auto;
}

.admin-link,
.admin-nav a,
.ghost-button {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--pine);
  display: inline-flex;
  font-weight: 700;
  justify-content: center;
  padding: 9px 14px;
  text-decoration: none;
}

.admin-nav {
  display: flex;
  gap: 10px;
}

.form-shell,
.admin-shell {
  margin: 0 auto;
  max-width: 1120px;
  padding: 26px clamp(14px, 4vw, 36px) 64px;
}

.form-title,
.admin-title {
  margin-bottom: 24px;
}

.eyebrow {
  color: var(--moss);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  margin: 0 0 6px;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  color: var(--pine);
  font-size: clamp(2rem, 5vw, 3.4rem);
  line-height: 1;
  margin-bottom: 10px;
}

h2 {
  color: var(--pine);
  font-size: 1.18rem;
  margin-bottom: 0;
}

h3 {
  color: var(--pine);
  font-size: 1rem;
  margin-bottom: 0;
}

.lede {
  color: var(--muted);
  max-width: 680px;
}

.notice,
.alert {
  border-radius: 8px;
  margin-bottom: 18px;
  padding: 14px 16px;
}

.notice {
  background: #fff5ed;
  border: 1px solid #f5c6a3;
}

.alert {
  background: #fff1ef;
  border: 1px solid #e4aaa4;
  color: #7d2d27;
}

.alert ul {
  margin: 8px 0 0;
  padding-left: 20px;
}

.section-panel,
.filter-panel,
.table-card,
.login-panel,
.confirmation-panel,
.detail-section,
.detail-grid {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.section-panel {
  margin-bottom: 18px;
  padding: clamp(16px, 3vw, 24px);
}

.compact-panel {
  box-shadow: none;
}

.section-heading {
  align-items: baseline;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 12px;
  margin-bottom: 18px;
  padding-bottom: 12px;
}

.section-kicker {
  background: var(--pine);
  border-radius: 4px;
  color: var(--amber);
  font-weight: 800;
  padding: 3px 7px;
}

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

.span-all,
.single-field {
  grid-column: 1 / -1;
}

.repeat-list,
.table-repeat {
  display: grid;
  gap: 14px;
}

.repeat-item,
.table-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.repeat-top {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin-bottom: 12px;
}

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

.secondary-button,
.primary-button,
.icon-button {
  align-items: center;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  font-weight: 800;
  justify-content: center;
  text-decoration: none;
}

.primary-button {
  background: var(--pine);
  border-bottom: 3px solid var(--amber);
  color: var(--white);
  padding: 12px 18px;
}

.secondary-button {
  background: #f1f1f0;
  color: var(--pine);
  margin-top: 14px;
  padding: 10px 14px;
}

.secondary-button:disabled,
.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.icon-button {
  background: #f7e8e6;
  color: var(--danger);
  flex: 0 0 40px;
  font-size: 1.25rem;
  height: 40px;
  width: 40px;
}

.signature-wrap canvas {
  background: var(--white);
  border: 2px dashed #aab9b3;
  border-radius: 8px;
  display: block;
  height: 190px;
  touch-action: none;
  width: 100%;
}

.signature-error {
  border-color: var(--danger) !important;
}

.signature-actions {
  align-items: end;
  display: grid;
  gap: 14px;
  grid-template-columns: 1fr;
  margin-top: 14px;
}

.captcha-field {
  max-width: 320px;
}

.screen-reader-field {
  height: 1px;
  left: -10000px;
  opacity: 0;
  position: absolute;
  width: 1px;
}

.submit-bar {
  display: flex;
  justify-content: flex-end;
  margin-top: 18px;
  padding: 6px 0 0;
}

.submit-bar .primary-button {
  width: 100%;
}

.center-page {
  align-items: center;
  display: flex;
  min-height: 100vh;
  padding: 24px;
}

.login-panel,
.confirmation-panel {
  margin: auto;
  max-width: 440px;
  padding: 26px;
  width: 100%;
}

.confirmation-logo {
  height: auto;
  margin-bottom: 18px;
  max-width: 260px;
  width: 100%;
}

.stack-form {
  display: grid;
  gap: 16px;
}

.filter-panel {
  align-items: end;
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(1, minmax(0, 1fr));
  margin-bottom: 18px;
  padding: 16px;
}

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

.admin-table {
  border-collapse: collapse;
  min-width: 760px;
  width: 100%;
}

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

.admin-table th {
  background: #f1f1f0;
  color: var(--pine);
}

.admin-table tbody tr {
  cursor: pointer;
}

.admin-table tbody tr:hover {
  background: #fff7f0;
}

.empty-cell {
  color: var(--muted);
  text-align: center !important;
}

.badge {
  border-radius: 999px;
  display: inline-flex;
  font-size: 0.78rem;
  font-weight: 800;
  padding: 4px 9px;
}

.badge-ok {
  background: #f1f1f0;
  color: #4b4c50;
}

.badge-warn {
  background: #fff0d3;
  color: #8a5a08;
}

.detail-header {
  align-items: center;
  display: flex;
  gap: 18px;
  justify-content: space-between;
  margin-bottom: 18px;
}

.detail-header h1 {
  font-size: clamp(1.8rem, 4vw, 2.6rem);
}

.detail-grid {
  display: grid;
  gap: 1px;
  grid-template-columns: repeat(1, minmax(0, 1fr));
  margin-bottom: 18px;
  overflow: hidden;
}

.detail-grid div {
  background: #fbfcfc;
  padding: 14px;
}

.detail-grid span {
  color: var(--muted);
  display: block;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.detail-grid strong {
  color: var(--pine);
  display: block;
  margin-top: 4px;
}

.detail-section {
  margin-bottom: 18px;
  padding: 18px;
}

.detail-block {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.compact-table {
  min-width: 680px;
}

@media (min-width: 720px) {
  .field-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .table-row {
    align-items: end;
    grid-template-columns: 0.7fr 1.4fr repeat(4, 0.75fr) 1.3fr 44px;
  }

  .material-row {
    grid-template-columns: 0.6fr 1.8fr 0.8fr 0.8fr 1.6fr 44px;
  }

  .signature-actions,
  .filter-panel {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .signature-actions .secondary-button {
    grid-column: span 2;
  }

  .signature-actions label {
    grid-column: span 2;
  }

  .submit-bar .primary-button {
    width: auto;
  }

  .detail-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  .brand img {
    height: 66px;
    width: auto;
  }

  .app-header {
    padding-inline: 12px;
  }

  .admin-nav {
    gap: 6px;
  }

  .admin-link,
  .admin-nav a {
    padding-inline: 10px;
  }
}
