:root {
  --bg: #f4f4f4;
  --surface: #fff;
  --ink: #101010;
  --muted: #989898;
  --line: #cacaca;
  --blue: #147aff;
  --blue-soft: #edf4ff;
  --red: #e5362d;
  --red-soft: #ffeded;
  --dark-light: #2d2d2d;
}

@font-face {
  font-family: "SF-Pro-Display";
  src: url("fonts/SF-Pro-Display-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "SF-Pro-Display";
  src: url("fonts/SF-Pro-Display-Medium.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "SF-Pro-Display";
  src: url("fonts/SF-Pro-Display-Semibold.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "SF-Pro-Display";
  src: url("fonts/SF-Pro-Display-Bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--bg); color: var(--ink); font-family: "SF-Pro-Display", Arial, sans-serif; font-size: 18px; line-height: 1.2; }
button, input { font: inherit; }
button { transition: background-color .2s ease, border-color .2s ease, color .2s ease, opacity .2s ease; }

.app-shell { width: min(1200px, calc(100vw - 40px)); margin: 0 auto; padding: 36px 0 56px; }
.app-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; margin-bottom: 30px; padding: 34px 40px; color: #fff; background: var(--ink); }
.app-header-copy { min-width: 0; }
.brand-logo { display: block; width: 184px; height: auto; }
.header-logo { margin-bottom: 26px; }
.eyebrow { margin: 0 0 10px; color: var(--blue); font-size: 12px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; }
.app-header h1 { margin: 0; color: #fff; font-size: 42px; font-weight: 600; letter-spacing: -.04em; line-height: 1.05; }
.subtitle { margin: 12px 0 0; color: #c7c7c7; font-size: 18px; }
.offline-badge { display: inline-flex; align-items: center; gap: 9px; flex-shrink: 0; padding: 10px 16px; color: #fff; background: var(--dark-light); font-size: 14px; font-weight: 500; }
.offline-badge i { width: 8px; height: 8px; border-radius: 50%; background: #55d879; }

.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--line); }
.tab { min-height: 52px; padding: 0 22px; border: 0; border-bottom: 3px solid transparent; color: var(--muted); background: transparent; cursor: pointer; font-size: 16px; font-weight: 600; }
.tab:hover { color: var(--ink); }
.tab.is-active { border-bottom-color: var(--blue); color: var(--ink); }
.tab:focus-visible, .generate-button:focus-visible, .secondary-button:focus-visible, input:focus-visible { outline: 3px solid #7eb7ff; outline-offset: 3px; }

.workspace { max-width: 920px; margin: 24px auto 0; }
.form-panel { padding: 30px; border: 1px solid var(--line); background: var(--surface); }
.form-panel[hidden] { display: none; }
.panel-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 30px; }
.panel-heading h2 { margin: 0; font-size: 32px; font-weight: 600; letter-spacing: -.04em; }
.template-size { padding-top: 5px; color: var(--muted); font-size: 14px; font-weight: 500; white-space: nowrap; }

fieldset { margin: 0 0 26px; padding: 0 0 26px; border: 0; border-bottom: 1px solid var(--line); }
.form-panel fieldset:last-of-type { margin-bottom: 28px; }
legend { margin-bottom: 14px; font-size: 18px; font-weight: 600; }
.field-grid { display: grid; gap: 14px; }
.field-grid.three { grid-template-columns: repeat(3, 1fr); }
.field-grid.four { grid-template-columns: repeat(3, 1fr); }
.field-grid label, .file-field { display: grid; gap: 8px; color: #5b5b5b; font-size: 14px; font-weight: 500; }
input { width: 100%; min-height: 46px; padding: 0 13px; border: 1px solid var(--line); border-radius: 0; color: var(--ink); background: #fff; font-size: 16px; font-weight: 500; }
input:hover { border-color: #989898; }
input[type=file] { padding: 10px; font-size: 13px; }

.deposit-fields { display: grid; gap: 9px; }
.row-labels, .deposit-field-row { display: grid; grid-template-columns: 24px repeat(4, 1fr); gap: 9px; align-items: center; }
.row-labels { color: var(--muted); font-size: 12px; font-weight: 500; }
.deposit-field-row strong { color: var(--blue); font-size: 14px; text-align: center; }
.deposit-cell { display: grid; gap: 8px; min-width: 0; }
.deposit-cell span { display: none; color: #5b5b5b; font-size: 14px; font-weight: 500; }
.mobile-row-label { display: none; }
.deposit-field-row input { min-height: 42px; }
.participant-fields { display: grid; gap: 14px; }
.participant-field { display: grid; grid-template-columns: 34px 1fr; gap: 12px; padding: 16px; background: var(--bg); }
.participant-number { padding-top: 14px; color: var(--blue); font-size: 14px; font-weight: 700; }
.participant-field .file-field { grid-column: 2; margin-top: 3px; }

.generate-button { width: 100%; min-height: 54px; border: 1px solid var(--blue); border-radius: 50px; color: #fff; background: var(--blue); cursor: pointer; font-size: 17px; font-weight: 600; }
.generate-button:hover { color: var(--blue); background: #fff; }
.generate-button:disabled, .secondary-button:disabled { cursor: wait; opacity: .65; }
.generate-button span { margin-left: 8px; font-size: 21px; }
.message { min-height: 24px; margin: 16px 2px 0; color: #28743b; font-size: 14px; font-weight: 600; }
.export-frame { position: fixed; top: 0; left: -2200px; width: 1920px; height: 1080px; border: 0; pointer-events: none; }

.pin-gate { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr); place-items: center; padding: 32px 20px; background: var(--bg); }
.pin-gate[hidden], .app-shell[hidden] { display: none !important; }
.pin-card { width: 100%; min-width: 0; max-width: 440px; padding: 40px; background: var(--surface); }
.pin-logo { width: 154px; margin-bottom: 30px; filter: invert(1); }
.pin-card h1 { margin: 0; font-size: 34px; font-weight: 600; letter-spacing: -.04em; }
.pin-card p:not(.eyebrow) { margin: 14px 0 30px; color: #5b5b5b; line-height: 1.4; }
.pin-card form { display: grid; gap: 10px; }
.pin-card label { color: #5b5b5b; font-size: 14px; font-weight: 500; }
.pin-card input { min-height: 54px; text-align: center; letter-spacing: .35em; font-size: 24px; }
.pin-card button { min-height: 54px; margin-top: 8px; border: 1px solid var(--blue); border-radius: 50px; color: #fff; background: var(--blue); cursor: pointer; font-weight: 600; }
.pin-card button:hover { color: var(--blue); background: #fff; }
.pin-card button span { margin-left: 8px; font-size: 21px; }
.pin-card small { min-height: 18px; color: var(--red); font-size: 13px; font-weight: 600; text-align: center; }

.archive-upload { display: grid; grid-template-columns: 1fr auto; gap: 14px; align-items: end; }
.archive-upload .file-field { min-width: 0; }
.archive-actions { display: grid; gap: 9px; align-items: end; }
.action-message, .form-message { min-height: 20px; margin: 0; color: #28743b; font-size: 14px; font-weight: 600; line-height: 1.35; }
.action-message:empty, .form-message:empty { display: none; }
.action-message.is-error, .form-message.is-error { color: var(--red); }
.archive-add-help { margin-top: 12px; }
.archive-clear { display: flex; justify-content: space-between; align-items: end; gap: 20px; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }
.archive-clear-copy { min-width: 0; }
.archive-clear-copy strong { display: block; font-size: 16px; font-weight: 600; }
.archive-clear-copy .field-help { margin-top: 7px; }
.archive-clear-action { display: grid; gap: 9px; flex: 0 0 auto; min-width: 220px; }
.secondary-button { min-height: 46px; padding: 0 19px; border: 1px solid var(--ink); border-radius: 50px; color: #fff; background: var(--ink); cursor: pointer; font-size: 14px; font-weight: 600; white-space: nowrap; }
.secondary-button:hover { color: var(--ink); background: #fff; }
.secondary-button span { margin-left: 6px; font-size: 17px; }
.danger-button { border-color: var(--red); color: #fff; background: var(--red); }
.danger-button:hover { color: var(--red); border-color: var(--red); background: #fff; }
.archive-status { min-height: 20px; margin: 14px 0 0; color: #5b5b5b; font-size: 14px; font-weight: 500; }
.archive-status.is-error { color: var(--red); }
.field-help { display: block; margin-top: 9px; color: var(--muted); font-size: 13px; line-height: 1.4; }

@media (max-width: 900px) {
  .app-shell { width: min(720px, calc(100vw - 32px)); }
  .app-header { padding: 28px; }
  .app-header h1 { font-size: 36px; }
  .archive-upload { grid-template-columns: 1fr; }
  .archive-clear { align-items: stretch; }
}

@media (max-width: 700px) {
  body { font-size: 16px; }
  .app-shell { width: calc(100vw - 24px); padding-top: 12px; }
  .app-header { display: block; padding: 24px 20px; }
  .header-logo { margin-bottom: 22px; }
  .app-header h1 { font-size: 32px; }
  .offline-badge { display: inline-flex; margin-top: 22px; }
  .tabs { overflow-x: auto; }
  .tab { flex: 1 0 auto; padding: 0 16px; font-size: 14px; }
  .form-panel { padding: 20px 16px; }
  .panel-heading h2 { font-size: 27px; }
  .field-grid.three, .field-grid.four { grid-template-columns: 1fr; }
  .row-labels { display: none; }
  .deposit-field-row { grid-template-columns: 1fr; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); }
  .deposit-field-row:last-child { border-bottom: 0; }
  .deposit-field-row strong { text-align: left; }
  .desktop-row-label { display: none; }
  .mobile-row-label { display: inline; }
  .deposit-cell span { display: block; }
  .archive-actions { align-items: stretch; }
  .archive-actions .secondary-button { width: 100%; }
  .archive-clear { display: block; }
  .archive-clear-action { min-width: 0; margin-top: 14px; }
  .archive-clear .secondary-button { width: 100%; }
}

@media (max-width: 480px) {
  .pin-card { padding: 28px 20px; }
  .participant-field { grid-template-columns: 28px 1fr; padding: 12px; }
  .participant-field .field-grid { grid-template-columns: 1fr; }
  .participant-field .file-field { grid-column: 2; }
  .panel-heading { display: block; }
  .template-size { display: block; margin-top: 8px; }
}
