:root {
  color-scheme: light;
  --bg: #f4f6f3;
  --panel: #ffffff;
  --panel-soft: #f8faf7;
  --text: #17201b;
  --muted: #647067;
  --line: #dce4dd;
  --accent: #1f6f4a;
  --accent-dark: #155337;
  --warning: #9a6b1c;
  --danger: #a23535;
  --shadow: 0 18px 50px rgba(27, 42, 34, 0.12);
  font-family: Arial, Helvetica, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(180deg, rgba(31, 111, 74, 0.08), transparent 280px),
    var(--bg);
  color: var(--text);
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

.page-shell {
  width: min(100%, 920px);
  margin: 0 auto;
  padding: 32px 16px;
}

.form-panel,
.login-card,
.detail-panel,
.submission-list {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.form-panel {
  padding: clamp(20px, 4vw, 44px);
}

.brand-block {
  border-bottom: 1px solid var(--line);
  margin-bottom: 28px;
  padding-bottom: 22px;
}

.brand-head {
  align-items: flex-start;
  display: flex;
  justify-content: space-between;
  gap: 18px;
}

.admin-login-link {
  flex: 0 0 auto;
}

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

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

h1 {
  font-size: clamp(1.75rem, 3vw, 2.6rem);
  line-height: 1.1;
  margin-bottom: 10px;
}

h2 {
  font-size: 1.2rem;
}

h3 {
  font-size: 1rem;
  margin-bottom: 8px;
}

.brand-block p:last-child,
.hint,
.empty-text,
small {
  color: var(--muted);
}

.consent-form {
  display: grid;
  gap: 22px;
}

fieldset {
  border: 0;
  margin: 0;
  padding: 0;
}

legend,
label > span,
.signature-head label {
  display: block;
  font-weight: 700;
  margin-bottom: 8px;
}

b {
  color: var(--danger);
}

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

input[type='text'],
input[type='email'],
input[type='date'],
input[type='password'] {
  width: 100%;
  min-height: 48px;
  border: 1px solid #cfd8d1;
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 11px 13px;
  outline: none;
}

input:focus,
.signature-canvas:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 111, 74, 0.16);
}

.declaration {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.declaration p,
.detail-section p {
  line-height: 1.6;
}

.check-row {
  align-items: flex-start;
  display: grid;
  gap: 12px;
  grid-template-columns: 22px 1fr;
  line-height: 1.45;
}

.check-row input {
  height: 20px;
  margin-top: 2px;
  width: 20px;
}

.signature-block {
  display: grid;
  gap: 8px;
}

.signature-head {
  align-items: center;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.signature-canvas {
  width: 100%;
  height: clamp(170px, 28vw, 240px);
  display: block;
  border: 1px solid #cfd8d1;
  border-radius: 8px;
  background:
    linear-gradient(#ffffff, #ffffff) padding-box,
    repeating-linear-gradient(0deg, transparent 0, transparent 42px, rgba(31, 111, 74, 0.1) 43px) border-box;
  touch-action: none;
}

.signature-canvas.is-invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(162, 53, 53, 0.16);
}

.primary-button,
.danger-button,
.ghost-button,
.ghost-link {
  align-items: center;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  font-weight: 700;
  justify-content: center;
  min-height: 44px;
  padding: 11px 16px;
  text-decoration: none;
}

.primary-button {
  background: var(--accent);
  border: 1px solid var(--accent);
  color: #fff;
}

.primary-button:hover {
  background: var(--accent-dark);
}

.danger-button {
  background: #fff;
  border: 1px solid rgba(162, 53, 53, 0.45);
  color: var(--danger);
}

.danger-button:hover {
  background: rgba(162, 53, 53, 0.08);
}

.ghost-button,
.ghost-link {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--text);
}

.ghost-button:hover,
.ghost-link:hover {
  border-color: var(--accent);
}

.small {
  min-height: 38px;
  padding: 8px 12px;
}

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

.notice ul {
  margin: 8px 0 0 18px;
  padding: 0;
}

.notice-success {
  background: rgba(31, 111, 74, 0.1);
  border: 1px solid rgba(31, 111, 74, 0.25);
  color: var(--accent-dark);
}

.notice-error {
  background: rgba(162, 53, 53, 0.08);
  border: 1px solid rgba(162, 53, 53, 0.24);
  color: var(--danger);
}

.notice-warning {
  background: rgba(154, 107, 28, 0.1);
  border: 1px solid rgba(154, 107, 28, 0.28);
  color: var(--warning);
}

.admin-body {
  background: #eef2ef;
}

.login-shell {
  align-items: center;
  display: grid;
  min-height: 100vh;
  padding: 20px;
}

.login-card {
  margin: 0 auto;
  max-width: 430px;
  padding: 28px;
  width: 100%;
}

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

.admin-topbar {
  align-items: center;
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 18px clamp(16px, 4vw, 34px);
}

.admin-topbar h1 {
  font-size: clamp(1.35rem, 2.4vw, 2rem);
  margin-bottom: 0;
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.admin-shell {
  width: min(100%, 1220px);
  margin: 0 auto;
  padding: 24px 16px;
}

.admin-layout {
  align-items: start;
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(260px, 340px) 1fr;
}

.submission-list,
.detail-panel {
  box-shadow: none;
}

.submission-list {
  overflow: hidden;
}

.list-head {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  padding: 16px;
}

.list-head h2 {
  font-size: 1rem;
  margin: 0;
}

.list-head span {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-weight: 700;
  min-width: 34px;
  padding: 5px 10px;
  text-align: center;
}

.submission-row {
  border-bottom: 1px solid var(--line);
  color: var(--text);
  display: grid;
  gap: 4px;
  padding: 14px 16px;
  text-decoration: none;
}

.submission-row:hover,
.submission-row.is-active {
  background: rgba(31, 111, 74, 0.08);
}

.submission-row span,
.submission-row em {
  color: var(--muted);
  font-size: 0.9rem;
}

.submission-row em {
  color: var(--accent-dark);
  font-style: normal;
  font-weight: 700;
}

.detail-panel {
  min-height: 420px;
  padding: clamp(18px, 3vw, 28px);
}

.detail-head {
  align-items: flex-start;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  padding-bottom: 18px;
}

.detail-head h2 {
  font-size: clamp(1.35rem, 2.4vw, 2rem);
  margin: 0;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.mail-send-form {
  align-items: end;
  display: grid;
  gap: 10px;
  min-width: min(100%, 340px);
}

.mail-options {
  display: grid;
  gap: 7px;
}

.radio-option {
  align-items: start;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  display: grid;
  gap: 9px;
  grid-template-columns: 18px 1fr;
  line-height: 1.25;
  padding: 10px;
}

.radio-option input {
  margin: 2px 0 0;
}

.radio-option > span {
  display: grid;
  font-weight: 700;
  gap: 2px;
  margin: 0;
}

.radio-option small {
  font-weight: 400;
  overflow-wrap: anywhere;
}

.radio-option.is-disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

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

.detail-grid div,
.certificate-grid div {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

dt {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  margin-bottom: 5px;
  text-transform: uppercase;
}

dd {
  margin: 0;
  overflow-wrap: anywhere;
}

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

.detail-section + .detail-section {
  margin-top: 18px;
}

.signature-preview {
  border: 1px solid var(--line);
  border-radius: 8px;
  max-width: 520px;
  overflow: hidden;
}

.signature-preview img {
  background: #fff;
  display: block;
  height: auto;
  width: 100%;
}

.certificate-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
  margin: 0;
}

.certificate-grid dd {
  font-family: Consolas, 'Courier New', monospace;
  font-size: 0.92rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

code {
  background: rgba(23, 32, 27, 0.07);
  border-radius: 4px;
  padding: 2px 5px;
}

@media (max-width: 780px) {
  .page-shell {
    padding: 14px;
  }

  .field-grid,
  .admin-layout,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .admin-topbar,
  .brand-head,
  .detail-head {
    align-items: stretch;
    flex-direction: column;
  }

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

  .action-row {
    justify-content: stretch;
  }

  .action-row form,
  .action-row button,
  .ghost-link,
  .primary-button {
    width: 100%;
  }
}

@media (max-width: 420px) {
  .form-panel,
  .login-card,
  .detail-panel {
    border-radius: 0;
    margin-left: -14px;
    margin-right: -14px;
  }

  .signature-head {
    align-items: stretch;
    flex-direction: column;
  }
}
