@font-face {
  font-family: Inter;
  src: url('../font/InterVariable.ttf') format('truetype');
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
}

:root {
  color-scheme: light;
  --bg: #f6f1e9;
  --panel: #fffdf9;
  --text: #10244f;
  --muted: #5d6676;
  --line: rgba(16, 36, 79, 0.16);
  --accent: #1d55d5;
  --accent-dark: #10244f;
  --coral: #f06c51;
  --danger: #a83c34;
  --shadow: 0 22px 70px rgba(16, 36, 79, 0.09);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, sans-serif;
  line-height: 1.55;
}

button,
input {
  font: inherit;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 22px max(24px, calc((100% - 1180px) / 2));
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.app-title {
  display: flex;
  align-items: center;
  gap: clamp(24px, 4vw, 58px);
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  font-weight: 750;
  line-height: 1.05;
  letter-spacing: -0.03em;
  text-decoration: none;
}

.app-brand small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 550;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.brand-mark {
  display: grid;
  width: 43px;
  height: 43px;
  place-items: center;
  border-radius: 50%;
  background: var(--text);
  color: #fff;
  font-size: 0.75rem;
  letter-spacing: 0.02em;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(28px, 3vw, 44px);
  font-weight: 590;
  letter-spacing: -0.045em;
}

h2 {
  margin-bottom: 10px;
  font-size: 28px;
  letter-spacing: -0.035em;
}

h3 {
  font-size: 18px;
}

.eyebrow {
  margin-bottom: 6px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.13em;
}

.muted {
  color: var(--muted);
  line-height: 1.5;
}

main {
  width: min(1180px, calc(100% - 32px));
  margin: 46px auto 80px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: clamp(24px, 4vw, 52px);
}

.panel + .panel {
  margin-top: 20px;
}

.panel-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.mode-switch,
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

button {
  min-height: 46px;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  color: var(--text);
  cursor: pointer;
}

button:hover {
  border-color: var(--accent);
}

button.active,
button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

button.primary {
  min-height: 52px;
  font-weight: 750;
}

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

button.danger {
  border-color: #e2b7b7;
  color: var(--danger);
}

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

label {
  display: grid;
  gap: 8px;
  color: var(--text);
  font-weight: 700;
}

input {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  color: var(--text);
}

input:focus,
button:focus,
canvas:focus {
  outline: 3px solid rgba(29, 85, 213, 0.2);
  outline-offset: 2px;
}

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

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  grid-column: 1 / -1;
}

.check-row input {
  width: 20px;
  min-height: 20px;
}

.inline-form {
  display: flex;
  gap: 10px;
  max-width: 520px;
}

.field-builder {
  display: grid;
  gap: 16px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f3f6ff;
}

.field-builder-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 28px;
}

.field-builder-head h3 {
  margin-bottom: 4px;
}

.field-builder-head .muted {
  margin-bottom: 0;
}

#addFieldButton {
  flex: 0 0 auto;
  min-width: 46px;
  margin-top: 4px;
  padding: 0;
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
  font-size: 24px;
  font-weight: 700;
}

.fixed-field {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: #293446;
  font-weight: 700;
}

.custom-fields {
  display: grid;
  gap: 10px;
}

.custom-field-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.icon-button {
  min-width: 44px;
  padding: 0 12px;
}

.restore-box {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

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

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

canvas {
  display: block;
  width: 100%;
  height: 220px;
  border: 2px solid #c8d1df;
  border-radius: 8px;
  background: linear-gradient(#fff, #fff), repeating-linear-gradient(0deg, transparent 0 38px, #eef2f6 39px 40px);
  touch-action: none;
}

.message {
  min-height: 24px;
  margin: 14px 0 0;
  color: var(--accent-dark);
  font-weight: 700;
}

.status-pill {
  flex: 0 0 auto;
  padding: 7px 10px;
  border-radius: 999px;
  background: #eaf0ff;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 700;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 900px;
  background: #ffffff;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  background: #edf2ff;
  color: var(--text);
  font-size: 13px;
  text-transform: uppercase;
}

td img {
  width: 170px;
  height: 58px;
  object-fit: contain;
  border: 1px solid var(--line);
  background: #ffffff;
}

.empty {
  padding: 28px;
  color: var(--muted);
  text-align: center;
}

.hidden {
  display: none !important;
}

.app-footer {
  display: flex;
  justify-content: center;
  gap: 24px;
  padding: 8px 24px 36px;
  font-size: 13px;
}

.app-footer a {
  color: var(--muted);
  text-decoration: none;
}

.app-footer a:hover {
  color: var(--accent);
}

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

  .mode-switch button,
  .toolbar button {
    flex: 1 1 auto;
  }

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

  .inline-form {
    display: grid;
    max-width: none;
  }

  .app-title {
    align-items: flex-start;
    flex-direction: column;
  }

  .app-footer {
    flex-wrap: wrap;
    gap: 12px 20px;
  }
}

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

  .app-header,
  .app-footer,
  #setupPanel,
  #participantPanel,
  #adminGatePanel,
  .toolbar,
  .status-pill {
    display: none !important;
  }

  main {
    width: 100%;
    margin: 0;
  }

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

  .table-wrap {
    overflow: visible;
    border: 0;
  }

  table {
    min-width: 0;
    font-size: 11px;
  }

  th,
  td {
    padding: 6px;
  }
}
