:root {
  --ink: #22313a;
  --muted: #667781;
  --line: #d8e1e5;
  --surface: #f5f8f9;
  --panel: #ffffff;
  --primary: #244c5a;
  --primary-dark: #193943;
  --accent: #d77a3d;
  --danger: #9d2b34;
  --ok: #1f6a3a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--surface);
  font-family: "Yu Gothic", "Meiryo", system-ui, sans-serif;
  line-height: 1.6;
}

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

.site-header {
  background: var(--primary);
  color: #fff;
}

.site-header__inner,
.page {
  width: min(1160px, calc(100% - 32px));
  margin: 0 auto;
}

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  gap: 16px;
}

.brand {
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  text-decoration: none;
}

.nav {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav a,
.nav button {
  color: #fff;
  background: transparent;
  border: 0;
  font: inherit;
  cursor: pointer;
  text-decoration: none;
}

.page {
  padding: 28px 0 48px;
}

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

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

h1 {
  margin: 0 0 18px;
  font-size: 28px;
}

h2 {
  margin: 0 0 14px;
  font-size: 20px;
}

.muted {
  color: var(--muted);
}

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

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

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

label {
  font-weight: 700;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  font: inherit;
  background: #fff;
}

.password-field {
  display: flex;
  align-items: stretch;
  gap: 6px;
}

.password-field input {
  flex: 1;
}

.password-toggle {
  min-width: 52px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  color: var(--primary);
  background: #eaf2f4;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.password-toggle.is-visible {
  color: #fff;
  background: var(--primary);
}

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

.checks {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin: 8px 0 18px;
}

.checks label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
}

.checks input {
  width: auto;
}

.button,
button.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  padding: 8px 14px;
  color: #fff;
  background: var(--primary);
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

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

.button--secondary {
  color: var(--primary);
  background: #eaf2f4;
}

.button--secondary:hover {
  background: #dbe9ed;
}

.table-wrap {
  overflow-x: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

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

th {
  background: #eef4f6;
  white-space: nowrap;
}

.events {
  display: grid;
  gap: 14px;
}

.event-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.event-card__head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 4px 10px;
  color: var(--primary);
  background: #eaf2f4;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.badge--closed {
  color: var(--muted);
  background: #edf0f1;
}

.badge--danger {
  color: var(--danger);
  background: #fae6e8;
}

.badge--ok {
  color: var(--ok);
  background: #e4f2e9;
}

.errors {
  margin: 0 0 18px;
  padding: 12px 16px;
  color: var(--danger);
  background: #fae6e8;
  border-radius: 8px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

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

.stall-block {
  margin: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.stall-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.stall-grid .field--full {
  grid-column: auto;
}

.image-preview {
  width: min(220px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: #fff;
}

.image-preview img {
  display: block;
  width: 100%;
  height: 140px;
  object-fit: contain;
  border-radius: 6px;
  background: #eef4f6;
}

.id-thumbnail-link {
  display: inline-flex;
  flex-direction: column;
  gap: 6px;
  width: 96px;
  text-decoration: none;
  font-weight: 700;
}

.id-thumbnail {
  display: block;
  width: 100%;
  height: 58px;
  object-fit: contain;
  border-radius: 6px;
  background: #eef4f6;
  border: 1px solid var(--line);
}

@media (max-width: 720px) {
  .site-header__inner,
  .toolbar,
  .event-card__head {
    align-items: flex-start;
    flex-direction: column;
  }

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

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

.print-body {
  background: #e9eef0;
  color: #111;
  font-family: "Yu Gothic", "Meiryo", system-ui, sans-serif;
}

.print-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  padding: 16px;
}

.print-sheet {
  width: 297mm;
  min-height: 200mm;
  margin: 0 auto 18px;
  padding: 12mm;
  background: #fff;
  border: 1px solid #cfd8dc;
  page-break-after: always;
}

.print-sheet__header {
  display: grid;
  grid-template-columns: 1fr 1.4fr 1fr;
  align-items: end;
  gap: 12px;
  margin-bottom: 8mm;
}

.print-sheet__header h1 {
  margin: 0;
  text-align: center;
  font-size: 28px;
  letter-spacing: 0;
}

.print-sheet__event {
  font-size: 18px;
  font-weight: 700;
}

.print-sheet__org {
  text-align: right;
  font-size: 15px;
  font-weight: 700;
}

.print-form {
  width: 100%;
  min-width: 0;
  margin-bottom: 7mm;
  border-collapse: collapse;
  table-layout: fixed;
  background: #fff;
}

.print-form th,
.print-form td {
  border: 1.5px solid #111;
  padding: 5px 6px;
  color: #111;
  background: #fff;
  font-size: 12px;
  line-height: 1.35;
  vertical-align: middle;
  word-break: break-word;
}

.print-form th {
  width: 23mm;
  text-align: center;
  font-weight: 700;
}

.print-form__representative th:first-child {
  width: 20mm;
}

.print-form--stalls th {
  height: 9mm;
}

.print-form--stalls td {
  height: 18mm;
}

.print-form--stalls th:nth-child(1),
.print-form--stalls td:nth-child(1) {
  width: 16mm;
}

.print-form--stalls th:nth-child(2),
.print-form--stalls td:nth-child(2) {
  width: 26mm;
}

.print-form--stalls th:nth-child(5),
.print-form--stalls td:nth-child(5) {
  width: 52mm;
}

.print-form--stalls th:nth-child(8),
.print-form--stalls td:nth-child(8),
.print-form--stalls th:nth-child(9),
.print-form--stalls td:nth-child(9) {
  width: 30mm;
}

.print-form__no {
  text-align: center;
  font-weight: 700;
}

.print-notes {
  display: grid;
  grid-template-columns: 1fr 32mm;
  gap: 8mm;
  min-height: 22mm;
}

.print-notes > div {
  border: 1.5px solid #111;
  padding: 6px;
  background: #fff;
}

.print-stamp-box {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  font-weight: 700;
}

@page {
  size: A4 landscape;
  margin: 7mm;
}

@media print {
  body.print-body {
    background: #fff;
  }

  .print-actions {
    display: none;
  }

  .print-sheet {
    width: auto;
    min-height: 0;
    margin: 0;
    padding: 0;
    border: 0;
  }
}

.festival-print-body {
  background: #dfe5e7;
  color: #111;
}

.festival-sheet {
  width: 210mm;
  min-height: 297mm;
  margin: 0 auto 18px;
  padding: 9mm 10mm;
  background: #fff;
  border: 1px solid #cfd8dc;
  page-break-after: always;
}

.festival-header {
  display: flex;
  flex-direction: column;
  gap: 3mm;
  margin-bottom: 6mm;
}

.festival-header h1 {
  margin: 0;
  text-align: center;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 0;
}

.festival-header__left {
  display: flex;
  align-items: baseline;
  gap: 8mm;
  width: 100%;
  padding-left: 8mm;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.35;
}

.festival-header__left span:last-child {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
}

.festival-form {
  width: 100%;
  min-width: 0;
  border-collapse: collapse;
  table-layout: fixed;
  background: #fff;
}

.festival-applicant-table {
  margin-bottom: 6mm;
}

.festival-stalls-table {
  margin-top: 0;
}

.festival-form th,
.festival-form td {
  border: 1.4px solid #111;
  padding: 0;
  color: #111;
  background: #fff;
  vertical-align: middle;
}

.festival-applicant-row {
  height: 27mm;
}

.festival-stall-row {
  height: 25mm;
}

.festival-applicant-label {
  width: 20mm;
  text-align: center;
  font-size: 14px;
}

.festival-stall-no {
  width: 14mm;
  text-align: center;
  font-size: 11px;
  vertical-align: top;
}

.festival-stall-no span {
  display: block;
  border-bottom: 1.4px solid #111;
  padding: 3px 0;
}

.festival-stall-no strong {
  display: block;
  padding-top: 5mm;
  font-size: 13px;
}

.festival-item-cell {
  width: 24mm;
  position: relative;
}

.festival-item-cell .festival-vertical-label {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 7mm;
  border-right: 1.4px solid #111;
  writing-mode: vertical-rl;
  text-orientation: upright;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 500;
}

.festival-item-name {
  margin-left: 7mm;
  padding: 7mm 3mm 2mm;
  font-size: 15px;
  font-weight: 700;
  min-height: 100%;
}

.festival-applicant-name-cell {
  width: 66mm;
}

.festival-stall-name-cell {
  width: 54mm;
}

.festival-applicant-subline,
.festival-applicant-mainline,
.festival-stall-subline,
.festival-stall-mainline {
  display: grid;
  grid-template-columns: 12mm 1fr;
  min-height: 9mm;
}

.festival-applicant-mainline,
.festival-stall-mainline {
  min-height: 15mm;
}

.festival-applicant-subline span,
.festival-applicant-mainline span,
.festival-stall-subline span,
.festival-stall-mainline span {
  display: flex;
  align-items: center;
  justify-content: center;
  border-right: 1.4px solid #111;
  font-size: 11px;
  font-weight: 700;
}

.festival-applicant-subline,
.festival-stall-subline {
  border-bottom: 1.4px solid #111;
}

.festival-applicant-subline strong,
.festival-applicant-mainline strong,
.festival-stall-subline strong,
.festival-stall-mainline strong {
  display: flex;
  align-items: center;
  padding: 0 3mm;
  font-size: 15px;
}

.festival-applicant-address-cell {
  width: 59mm;
  position: relative;
}

.festival-stall-address-cell {
  width: 56mm;
  position: relative;
}

.festival-applicant-vertical-label,
.festival-stall-vertical-label {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 6mm;
  border-right: 1.4px solid #111;
  writing-mode: vertical-rl;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
}

.festival-applicant-address-text,
.festival-stall-address-text {
  margin-left: 7mm;
  padding: 9mm 3mm 2mm;
  font-size: 14px;
  font-weight: 700;
}

.festival-applicant-contact-cell,
.festival-stall-contact-cell {
  width: 36mm;
}

.festival-applicant-phone,
.festival-applicant-birth,
.festival-stall-phone,
.festival-stall-birth {
  display: grid;
  grid-template-columns: 9mm 1fr;
}

.festival-applicant-phone,
.festival-stall-phone {
  min-height: 10mm;
  border-bottom: 1.4px solid #111;
}

.festival-applicant-birth,
.festival-stall-birth {
  min-height: 15mm;
}

.festival-applicant-phone span,
.festival-applicant-birth span,
.festival-stall-phone span,
.festival-stall-birth span {
  display: flex;
  align-items: center;
  justify-content: center;
  border-right: 1.4px solid #111;
  font-size: 10px;
  font-weight: 700;
  line-height: 1.15;
}

.festival-applicant-phone strong,
.festival-applicant-birth strong,
.festival-stall-phone strong,
.festival-stall-birth strong {
  display: flex;
  align-items: center;
  padding: 0 2mm;
  font-size: 12px;
  line-height: 1.45;
}

@page {
  size: A4 portrait;
  margin: 7mm;
}

@media print {
  .festival-print-body {
    background: #fff;
  }

  .festival-sheet {
    width: auto;
    min-height: 0;
    margin: 0;
    padding: 0;
    border: 0;
  }
}
