:root {
  --ink: #2b3142;
  --muted: #7d7895;
  --line: #eadff6;
  --paper: #fff8fe;
  --surface: #ffffff;
  --ritsumei: #e5f8ff;
  --kuyo: #f2ecff;
  --new: #e4fbf3;
  --off: #fff1f8;
  --accent: #83c7dc;
  --accent-strong: #5f8fca;
  --accent-soft: #f4ecff;
  --pink: #ffddeb;
  --lavender: #eee6ff;
  --blue: #e2f8ff;
  --danger: #bf5a74;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 0%, #ffe4f0 0, transparent 28%),
    radial-gradient(circle at 92% 4%, #dff8ff 0, transparent 30%),
    linear-gradient(180deg, #fff7fd 0, #f9fbff 260px, #ffffff 100%);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic", sans-serif;
  font-weight: 500;
}

.app-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 24px clamp(16px, 4vw, 44px) 18px;
  border-bottom: 1px solid rgba(234, 223, 246, .86);
  background: rgba(255, 250, 254, .82);
  backdrop-filter: blur(14px);
}

.eyebrow {
  margin: 0 0 4px;
  color: #8d78c8;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(23px, 4vw, 38px);
  font-weight: 700;
  letter-spacing: 0;
}

main {
  width: min(1220px, 100%);
  margin: 0 auto;
  padding: 18px clamp(10px, 3vw, 28px) 60px;
}

.toolbar {
  display: grid;
  grid-template-columns: 120px minmax(220px, 1fr) 230px auto;
  gap: 12px;
  align-items: end;
  padding: 14px 0;
}

.advanced-import {
  display: grid;
  grid-template-columns: minmax(160px, 220px) minmax(160px, 220px) auto minmax(180px, 1fr);
  gap: 12px;
  align-items: end;
  padding: 0 0 14px;
}

.import-status {
  align-self: center;
  color: #8d78c8;
  font-size: 13px;
  font-weight: 650;
}

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

select, input, textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid #bdd9e1;
  border-radius: 7px;
  background: rgba(255, 255, 255, .94);
  color: var(--ink);
  font: inherit;
  padding: 8px 10px;
  box-shadow: 0 1px 0 rgba(141, 120, 200, .06);
}

textarea {
  min-height: 180px;
  resize: vertical;
  line-height: 1.55;
}

.button {
  min-height: 42px;
  border: 1px solid #bdd9e1;
  border-radius: 7px;
  padding: 8px 14px;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
  background: #fff;
  color: var(--ink);
}

.button.primary {
  border-color: #8bbfdb;
  background: linear-gradient(180deg, #a9dff0, #82b9df);
  color: #fff;
}

.button.primary:hover { background: var(--accent-strong); }
.button.secondary:hover { background: #fff1f8; }

.header-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.summary-band {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, .82);
  overflow: hidden;
  box-shadow: 0 12px 28px rgba(151, 127, 192, .11);
}

.summary-band > div {
  padding: 16px 18px;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255,255,255,.98), rgba(249,239,255,.82));
}

.summary-band > div:last-child { border-right: 0; }

.summary-label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.summary-band strong {
  display: block;
  margin-top: 3px;
  font-size: clamp(26px, 5vw, 40px);
  font-weight: 700;
  color: #213241;
}

.ceremony-info {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 18px 0 10px;
}

.ceremony-info h2 {
  margin-bottom: 4px;
  font-size: clamp(21px, 4vw, 32px);
  font-weight: 700;
}

.ceremony-info p {
  margin-bottom: 0;
  color: var(--muted);
  font-weight: 650;
}

.status-pill {
  border: 1px solid #b7dfe8;
  border-radius: 999px;
  padding: 6px 12px;
  background: #f8f1ff;
  white-space: nowrap;
  font-weight: 650;
}

.cards {
  display: grid;
  gap: 10px;
}

.hall-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, .9);
  overflow: hidden;
  box-shadow: 0 10px 24px rgba(151, 127, 192, .09);
}

.card-top {
  width: 100%;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  border: 0;
  background: linear-gradient(90deg, #fff8fd 0%, #f4fbff 52%, #f6f0ff 100%);
  padding: 13px 16px 9px;
  color: inherit;
  cursor: pointer;
  text-align: left;
}

.hall-name {
  display: inline;
  font-size: 21px;
  font-weight: 700;
}

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

.hall-main {
  display: grid;
  gap: 2px;
}

.manager-name {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.range {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border: 1px solid #ffc5d2;
  border-radius: 999px;
  padding: 2px 12px;
  background: linear-gradient(180deg, #ffffff, #fff0f4);
  font-size: 18px;
  font-weight: 700;
  white-space: nowrap;
  color: #c94158;
}

.card-stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 1px;
  background: var(--line);
  border-top: 1px solid var(--line);
}

.stat {
  background: #fffafd;
  padding: 9px 12px;
  min-width: 0;
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.stat strong {
  font-size: 22px;
  font-weight: 700;
}

.card-detail {
  border-top: 1px solid var(--line);
  background: #fff;
}

.detail-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}

.section-title {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  padding: 8px 12px;
  font-weight: 700;
}

.section-title.ritsumei { background: var(--ritsumei); }
.section-title.kuyo { background: var(--kuyo); }

.person-row {
  display: grid;
  grid-template-columns: 44px minmax(120px, 1fr) 74px 54px;
  gap: 8px;
  align-items: center;
  min-height: 44px;
  padding: 5px 12px;
  border-top: 1px solid #f0e4f8;
}

.person-row.ritsumei { background: color-mix(in srgb, var(--ritsumei) 58%, white); }
.person-row.kuyo { background: color-mix(in srgb, var(--kuyo) 62%, white); }
.person-row.inactive {
  background: var(--off);
  color: #8a7184;
}

.row-index {
  color: var(--muted);
  font-weight: 650;
}

.person-name {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  font-size: 18px;
  font-weight: 650;
}

.person-name span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge-new {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  border-radius: 999px;
  background: var(--new);
  color: #0f725a;
  font-size: 13px;
  font-weight: 700;
}

.number-input {
  min-height: 36px;
  padding: 4px 7px;
  text-align: center;
  font-weight: 700;
  color: #c94158;
}

.number-view {
  text-align: center;
  font-size: 20px;
  font-weight: 700;
  color: #c94158;
}

.person-row.inactive .number-view {
  color: #9a7d91;
}

.deliver {
  display: flex;
  justify-content: center;
}

.deliver input {
  width: 22px;
  min-height: 22px;
  accent-color: var(--accent);
}

dialog {
  width: min(720px, calc(100% - 24px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
}

dialog::backdrop { background: rgba(31, 41, 51, .28); }

.dialog-body { padding: 16px; }

.dialog-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.dialog-header h2 { margin-bottom: 0; }

.icon-button {
  border: 0;
  background: transparent;
  font-size: 30px;
  line-height: 1;
  cursor: pointer;
}

.hint {
  color: var(--muted);
  font-weight: 700;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
}

@media (max-width: 760px) {
  .app-header {
    display: block;
  }

  .header-actions {
    justify-content: stretch;
    margin-top: 14px;
  }

  .header-actions .button { flex: 1; }

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

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

  .summary-band {
    grid-template-columns: repeat(2, 1fr);
  }

  .summary-band > div {
    border-bottom: 1px solid var(--line);
  }

  .ceremony-info {
    display: block;
  }

  .status-pill {
    display: inline-block;
    margin-top: 10px;
  }

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

  .card-top {
    align-items: flex-start;
  }

  .range {
    font-size: 18px;
  }

  .person-row {
    grid-template-columns: 30px minmax(98px, 1fr) 54px 34px;
    gap: 5px;
    padding: 4px 8px;
    min-height: 40px;
  }

  .person-name {
    font-size: 16px;
  }

  .number-view {
    font-size: 18px;
  }
}

@media print {
  @page {
    size: A4 portrait;
    margin: 8mm;
  }

  * {
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  .app-header, .toolbar, .detail-actions, dialog {
    display: none !important;
  }

  body {
    background: #ffffff;
  }

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

  .summary-band {
    box-shadow: none;
    page-break-after: avoid;
  }

  .summary-band > div {
    padding: 7px 10px;
  }

  .summary-band strong {
    font-size: 23px;
  }

  .ceremony-info {
    padding: 0 0 6px;
  }

  .ceremony-info h2 {
    font-size: 20px;
    margin-bottom: 2px;
  }

  .ceremony-info p,
  .status-pill,
  .manager-name,
  .summary-label,
  .stat span {
    font-size: 10px;
  }

  .status-pill {
    padding: 3px 8px;
  }

  .cards {
    gap: 4px;
  }

  .hall-card {
    break-inside: avoid;
    margin-bottom: 0;
    box-shadow: none;
  }

  .card-top {
    padding: 6px 8px 4px;
  }

  .hall-name {
    font-size: 15px;
  }

  .range {
    min-height: 22px;
    padding: 1px 8px;
    font-size: 13px;
  }

  .card-stats {
    grid-template-columns: repeat(5, 1fr);
  }

  .stat {
    padding: 4px 7px;
  }

  .stat strong {
    font-size: 15px;
  }

  .card-detail {
    display: none !important;
  }

  .hall-card.is-open .card-detail {
    display: block !important;
    break-before: page;
    page-break-before: always;
    border-top: 0;
  }

  .hall-card.is-open .card-detail::before {
    content: attr(data-print-title);
    display: block;
    margin-bottom: 5px;
    padding: 5px 8px;
    border: 1px solid #ffc5d2;
    border-radius: 6px;
    background: #fff3f7;
    color: #c94158;
    font-size: 18px;
    font-weight: 700;
  }

  .section-title {
    position: static;
    padding: 4px 8px;
    font-size: 12px;
  }

  .person-row {
    grid-template-columns: 24px minmax(90px, 1fr) 44px 28px;
    min-height: 22px;
    gap: 4px;
    padding: 2px 7px;
  }

  .person-name {
    font-size: 11px;
  }

  .row-index,
  .badge-new {
    font-size: 10px;
  }

  .badge-new {
    min-width: 18px;
    height: 18px;
  }

  .number-view {
    font-size: 12px;
  }

  .deliver input {
    width: 14px;
    min-height: 14px;
  }

  body.printing-detail .summary-band,
  body.printing-detail .ceremony-info,
  body.printing-detail .hall-card:not(.is-open),
  body.printing-detail .hall-card.is-open > .card-top,
  body.printing-detail .hall-card.is-open > .card-stats {
    display: none !important;
  }

  body.printing-detail .hall-card.is-open .card-detail {
    display: block !important;
    break-before: auto;
    page-break-before: auto;
  }
}
