/* 全画面共通の色、余白、フォーム、一覧、モーダル、レスポンシブ表示を定義します。 */
:root {
  /* システム全体の基本色。各機能で個別の色を直接指定せず、この値を使用します。 */
  --color-page: #f5f7f9;
  --color-surface: #ffffff;
  --color-text: #1f2933;
  --color-text-muted: #52606d;
  --color-text-subtle: #627282;
  --color-border: #cbd5df;
  --color-border-subtle: #d8dee6;
  --color-border-light: #e4e8ee;
  --color-primary: #0f766e;
  --color-primary-hover: #0b5f59;
  --color-danger: #b42318;
  --color-danger-hover: #8f1c13;
  --color-secondary: #eef2f6;
  --color-secondary-hover: #dfe6ed;
  --color-focus: #2563eb;

  /* システム全体のサイズ。通常操作と一覧内操作の2段階に限定します。 */
  --font-size-body: 14px;
  --font-size-label: 13px;
  --control-height: 38px;
  --table-action-height: 32px;
  --radius-control: 6px;
  --radius-panel: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--color-page);
  color: var(--color-text);
  font-family: "Yu Gothic", "Meiryo", system-ui, sans-serif;
  font-size: var(--font-size-body);
}

body.modal-open {
  overflow: hidden;
}

body.page-loading {
  overflow: hidden;
}

.page-loading-backdrop {
  align-items: center;
  background: rgba(31, 41, 51, 0.48);
  bottom: 0;
  display: flex;
  justify-content: center;
  left: 0;
  position: fixed;
  right: 0;
  top: 0;
  z-index: 1000;
}

.page-loading-backdrop[hidden] {
  display: none;
}

.page-loading-panel {
  align-items: center;
  background: #ffffff;
  border: 1px solid #d8dee6;
  border-radius: 8px;
  box-shadow: 0 16px 44px rgba(31, 41, 51, 0.18);
  color: #1f2933;
  display: flex;
  font-weight: 700;
  gap: 12px;
  min-width: 180px;
  padding: 18px 22px;
}

.page-loading-spinner {
  animation: page-loading-spin 0.8s linear infinite;
  border: 3px solid #d8dee6;
  border-top-color: #1f4e78;
  border-radius: 999px;
  height: 24px;
  width: 24px;
}

@keyframes page-loading-spin {
  to {
    transform: rotate(360deg);
  }
}

a {
  color: inherit;
}

.app-header {
  align-items: center;
  background: #ffffff;
  border-bottom: 1px solid #d8dee6;
  display: flex;
  gap: 24px;
  min-height: 56px;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  font-weight: 700;
  text-decoration: none;
}

.app-header nav {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 14px;
}

.app-header nav a {
  color: #52606d;
  text-decoration: none;
}

.menu-toggle {
  align-items: center;
  align-self: center;
  background: #eef2f6;
  border: 1px solid #cbd5df;
  border-radius: 6px;
  display: none;
  gap: 4px;
  height: 38px;
  justify-content: center;
  margin-left: auto;
  min-height: 38px;
  min-width: 42px;
  padding: 0;
  width: 42px;
}

.menu-toggle span {
  background: #1f2933;
  border-radius: 999px;
  display: block;
  height: 2px;
  width: 18px;
}

.login-user {
  align-items: center;
  display: flex;
  gap: 12px;
  margin-left: auto;
}

.login-user span {
  color: #52606d;
  font-size: 13px;
  white-space: nowrap;
}

.login-user form {
  margin: 0;
}

.login-user button {
  background: #52606d;
  min-height: 32px;
  min-width: 100px;
  padding: 6px 10px;
}

.page {
  margin: 0 auto;
  max-width: 1280px;
  padding: 24px;
}

.page-title {
  margin-bottom: 16px;
}

.page-title h1 {
  font-size: 28px;
  margin: 0 0 6px;
}

.page-title p {
  color: #627282;
  margin: 0;
}

.messages {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.message {
  border-radius: 6px;
  padding: 10px 12px;
}

.message.success {
  background: #e6f4ea;
  border: 1px solid #b7dfc1;
}

.message.error {
  background: #fdecea;
  border: 1px solid #f2b8b5;
}

.menu-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

.menu-card {
  background: #ffffff;
  border: 1px solid #d8dee6;
  border-radius: 8px;
  display: grid;
  gap: 8px;
  min-height: 112px;
  padding: 18px;
  text-decoration: none;
}

.menu-card strong {
  font-size: 18px;
}

.menu-card span {
  color: #627282;
  font-size: 14px;
  line-height: 1.6;
}

.panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-panel);
  margin-bottom: 18px;
  padding: 18px;
}

.form-grid {
  align-items: end;
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(12, minmax(0, 1fr));
}

.form-grid > * {
  min-width: 0;
}

/*
 * 登録・修正フォームの横幅を、入力できる内容の長さと入力種別から決めます。
 * 12列を基準にすることで、機能ごとに個別のpx幅を持たず、同じ項目特性なら同じ横幅になります。
 */
.form-grid > label,
.venue-details > label {
  grid-column: span 3;
  min-width: 0;
}

/* selectは短い区分・マスタ選択を基本とし、標準3列幅にします。長い候補はfield-width-*で上書きします。 */
.form-grid > label:has(> select),
.venue-details > label:has(> select) {
  grid-column: span 3;
}

/* 時刻・短いコード・郵便番号など、10文字以内の項目です。 */
.form-grid > label:has(> input[maxlength="5"]),
.form-grid > label:has(> input[maxlength="10"]),
.venue-details > label:has(> input[maxlength="5"]),
.venue-details > label:has(> input[maxlength="10"]) {
  grid-column: span 2;
}

/* 市区町村・区分・電話番号など、20〜30文字程度の項目です。 */
.form-grid > label:has(> input[maxlength="20"]),
.form-grid > label:has(> input[maxlength="30"]),
.venue-details > label:has(> input[maxlength="20"]),
.venue-details > label:has(> input[maxlength="30"]) {
  grid-column: span 3;
}

/* 担当者名・メール・URLなど、中程度の文字列項目です。 */
.form-grid > label:has(> input[maxlength="50"]),
.venue-details > label:has(> input[maxlength="50"]),
.form-grid > label:has(> input[type="password"]) {
  grid-column: span 4;
}

/* 施設名・取引先名・住所など、長めの文字列項目です。 */
.form-grid > label:has(> input[maxlength="100"]),
.venue-details > label:has(> input[maxlength="100"]) {
  grid-column: span 6;
}

/* イベント名と長文入力は行全体を使用します。 */
.form-grid > label:has(> input[maxlength="200"]),
.form-grid > label:has(> textarea),
.venue-details > label:has(> textarea) {
  grid-column: 1 / -1;
}

/* 日付・日時・年月・数値は入力形式が判別できる標準幅へ揃えます。 */
.form-grid > label:has(> input[type="date"]),
.form-grid > label:has(> input[type="datetime-local"]),
.form-grid > label:has(> input[type="month"]),
.form-grid > label:has(> input[type="number"]),
.venue-details > label:has(> input[type="number"]) {
  grid-column: span 3;
}

/* 選択ダイアログ付きの表示欄は、名称を省略しすぎないよう半幅を確保します。 */
.form-grid > label:has(> .select-display) {
  grid-column: span 6;
}

/* data-linkage等でフォーム直下に置かれる操作ボタンの幅です。 */
.form-grid > button {
  grid-column: span 2;
  justify-self: start;
}

/* 個別画面で明示的に微調整する場合に使う共通幅クラスです。 */
.field-width-xs {
  grid-column: span 2 !important;
  min-width: 0;
}

.field-width-sm {
  grid-column: span 3 !important;
  min-width: 0;
}

.field-width-md {
  grid-column: span 4 !important;
  min-width: 0;
}

.field-width-lg {
  grid-column: span 6 !important;
  min-width: 0;
}

.field-width-full {
  grid-column: 1 / -1 !important;
  min-width: 0;
}

.search-grid {
  align-items: end;
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  margin-bottom: 24px;
}

/* 検索欄も登録フォームと同じ幅体系にし、文字検索だけを少し広くします。 */
.search-grid > label {
  grid-column: span 4;
  min-width: 0;
}

.search-grid > label:has(> select),
.search-grid > label:has(> input[type="number"]),
.search-grid > label:has(> input[type="date"]) {
  grid-column: span 3;
}

.search-grid > label:has(> .input-with-button) {
  grid-column: span 4;
}

.pagination {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
  margin: 14px 0;
}

.pagination .disabled {
  color: #7b8794;
  cursor: default;
  opacity: 0.55;
}

.search-pair {
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(120px, 0.7fr) minmax(160px, 1fr);
}

label {
  color: var(--color-text-muted);
  display: grid;
  font-size: var(--font-size-label);
  gap: 6px;
}

input,
select,
textarea {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-control);
  color: var(--color-text);
  font: inherit;
  max-width: 100%;
  min-height: var(--control-height);
  min-width: 0;
  padding: 8px 10px;
}

input[type="number"],
.numeric {
  text-align: right;
}

.readonly-display {
  align-items: center;
  background: #f1f4f7;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-control);
  color: var(--color-text-muted);
  display: flex;
  min-height: var(--control-height);
  padding: 8px 10px;
  width: 100%;
}

textarea {
  max-width: 100%;
  min-height: 92px;
  resize: vertical;
}

button {
  align-self: end;
  background: var(--color-primary);
  border: 0px;
  border-radius: var(--radius-control);
  color: var(--color-surface);
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  line-height: 1.4;
  min-height: var(--control-height);
  padding: 8px 14px;
}

button:hover {
  background: var(--color-primary-hover);
  border-color: var(--color-primary-hover);
  color: var(--color-surface);
}

button.button-link,
button.table-action {
  font: inherit;
}

.button-link,
.table-action {
  align-items: center;
  background: var(--color-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-control);
  color: var(--color-text);
  display: inline-flex;
  font-size: var(--font-size-body);
  font-weight: 700;
  min-height: var(--control-height);
  padding: 8px 12px;
  text-decoration: none;
  justify-content: center;
}

.button-link:hover,
.table-action:hover {
  background: var(--color-secondary-hover);
  border-color: var(--color-border);
}

.primary-link {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: var(--color-surface);
}

.primary-link:hover {
  background: var(--color-primary-hover);
  border-color: var(--color-primary-hover);
}

/* 危険操作は通常ボタン・一覧ボタンのどちらでも必ず同じ赤色にします。 */
button.danger,
.button-link.danger,
.table-action.danger {
  background: var(--color-danger);
  border-color: var(--color-danger);
  color: var(--color-surface);
}

button.danger:hover,
.button-link.danger:hover,
.table-action.danger:hover {
  background: var(--color-danger-hover);
  border-color: var(--color-danger-hover);
}

button:focus-visible,
.button-link:focus-visible,
.table-action:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--color-focus) 30%, transparent);
  outline-offset: 2px;
}

.action-bar {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: flex-start;
  align-items: flex-end;
}

.tabs {
  display: grid;
  gap: 16px;
}

.tab-list {
  align-items: center;
  background: #ffffff;
  border: 1px solid #d8dee6;
  border-radius: 8px;
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  width: fit-content;
}

.tab-button {
  background: transparent;
  border-radius: 6px;
  color: #52606d;
  min-height: 34px;
  padding: 7px 12px;
}

.tab-button.active {
  background: #0f766e;
  color: #ffffff;
}

.section-header-row {
  align-items: flex-end;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 12px;
}

.compact-actions {
  margin-bottom: 0;
}

.inline-form {
  align-items: end;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0;
}

/* 一覧上部のExcel取込・施設取込も、機能間で同じ横幅に揃えます。 */
.inline-form > label:has(> input[type="file"]) {
  flex: 0 1 320px;
  min-width: 260px;
}

.inline-form > label:has(> select) {
  flex: 0 1 220px;
  min-width: 180px;
}

.table-action,
td > form > button.danger {
  font-size: var(--font-size-label);
  min-height: var(--table-action-height);
  min-width: 56px;
  padding: 5px 10px;
}

td > form {
  margin: 0;
}

.modal-backdrop {
  align-items: center;
  background: rgba(31, 41, 51, 0.45);
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 24px;
  position: fixed;
  z-index: 30;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-panel {
  background: var(--color-surface);
  border-radius: var(--radius-panel);
  box-shadow: 0 20px 50px rgba(31, 41, 51, 0.24);
  max-height: calc(100vh - 48px);
  max-width: 980px;
  overflow-y: auto;
  padding: 20px;
  width: 100%;
}

.modal-header {
  align-items: center;
  border-bottom: 1px solid #e4e8ee;
  display: flex;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
}

.modal-header h2 {
  font-size: 20px;
  margin: 0;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 18px;
}

.import-modal {
  max-width: 560px;
}

.import-status {
  display: grid;
  gap: 12px;
}

.import-status strong {
  font-size: 18px;
}

.import-status p {
  color: #52606d;
  margin: 0;
}

.import-status strong,
[data-import-result],
[data-import-elapsed],
[data-import-reload] {
  display: none;
}

.import-status progress {
  height: 18px;
  width: 100%;
}

.import-counts {
  color: #52606d;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: space-between;
}

.modal-close {
  background: transparent;
  border: 0;
  color: var(--color-text-muted);
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  min-height: auto;
  padding: 0;
  text-decoration: none;
}

.modal-close:hover {
  background: var(--color-secondary);
  color: var(--color-text);
}


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

.span-1,
.one-column {
  grid-column: span 3;
}

.span-2,
.half-wide {
  grid-column: span 6;
}

.span-3 {
  grid-column: span 9;
}

.third-wide {
  grid-column: span 4;
}

.check {
  align-content: end;
  display: flex;
  gap: 8px;
}

.check input {
  width: auto;
}

.checkline,
.compact-check {
  align-items: flex-end;
  display: inline-flex;
  gap: 8px;
}

.checkline input,
.compact-check input {
  flex: 0 0 auto;
  height: 16px;
  min-height: 16px;
  width: 16px;
}

.input-with-button {
  align-items: center;
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(0, 1fr) auto;
}

.input-with-button .button-link {
  min-width: 72px;
}

.section-heading {
  font-size: 18px;
  margin: 0 0 14px;
}

.empty-text {
  color: #52606d;
  margin: 0;
}

.timeline-groups {
  display: grid;
  gap: 14px;
}

.timeline-group {
  border: 1px solid #e4e8ee;
  border-radius: 8px;
  padding: 14px;
}

.timeline-group h3 {
  font-size: 16px;
  margin: 0 0 10px;
}

.timeline-group h3 span {
  color: #627282;
  font-size: 12px;
  font-weight: 400;
}

.timeline-list {
  display: grid;
  gap: 10px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.timeline-list li {
  border-left: 3px solid #0f766e;
  display: grid;
  gap: 3px;
  padding-left: 10px;
}

.timeline-list time,
.timeline-list span,
.timeline-list small {
  color: #52606d;
  font-size: 13px;
}

.checks {
  border: 1px solid #d8dee6;
  border-radius: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  padding: 12px;
}

.checks label {
  align-items: center;
  display: flex;
  gap: 6px;
  white-space: nowrap;
}

.checks input {
  width: auto;
}

.venue-details {
  border: 1px solid #d8dee6;
  border-radius: 6px;
  gap: 14px;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  padding: 12px;
}

.venue-details legend {
  color: #52606d;
  font-size: 13px;
  font-weight: 700;
  padding: 0 6px;
}

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

.event-form,
.record-form {
  display: grid;
  gap: 16px;
}

.event-form-section,
.form-section {
  background: #f8fafc;
  border: 1px solid #d8dee6;
  border-radius: 8px;
  padding: 16px;
}

.event-form-section h3,
.form-section h3 {
  border-bottom: 1px solid #e4e8ee;
  font-size: 16px;
  margin: 0 0 14px;
  padding-bottom: 10px;
}

.event-form-section .form-grid + .form-grid,
.event-form-section .form-grid + .checks,
.event-form-section .checks + .form-grid,
.form-section .form-grid + .form-grid,
.form-section .form-grid + .checks,
.form-section .checks + .form-grid,
.form-section .checks + .checks {
  margin-top: 14px;
}

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

.event-selector-panel {
  display: grid;
  gap: 14px;
}

.event-selector-panel form {
  margin: 0;
}

.event-selector-field {
  color: #52606d;
  display: grid;
  font-size: 13px;
  gap: 6px;
}

.event-summary {
  align-items: center;
  background: #f8fafc;
  border: 1px solid #e4e8ee;
  border-radius: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  padding: 12px;
}

.event-summary strong {
  font-size: 17px;
}

.event-summary span {
  color: #52606d;
  font-size: 13px;
}

.role-partner-table {
  max-height: none;
}

button[disabled] {
  cursor: not-allowed;
  opacity: 0.55;
}

.picker-modal {
  max-width: 720px;
}

.role-status-row {
  align-items: end;
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(90px, 0.3fr) minmax(180px, 1fr);
}

.role-status-row label {
  white-space: normal;
}

.role-status-row span {
  color: #52606d;
  font-size: 13px;
  font-weight: 700;
  padding-bottom: 10px;
}

.table-scroll {
  max-height: calc(100vh - 160px);
  overflow: auto;
}

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

.telema-running {
  color: #52606d;
  font-weight: 700;
}

.select-display {
  align-items: center;
  border: 1px solid #d8dee6;
  border-radius: 6px;
  display: flex;
  gap: 10px;
  justify-content: space-between;
  min-height: 38px;
  padding: 6px 8px;
}

.select-display span {
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.select-display button {
  flex: 0 0 auto;
}

.picker-filters {
  align-items: end;
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  margin-bottom: 14px;
}

/* 候補モーダルでは都道府県等のselectを短く、名称検索inputを広く表示します。 */
.picker-filters > label {
  grid-column: span 3;
  min-width: 0;
}

.picker-filters > label:has(> input[type="search"]),
.picker-filters > label:has(> input:not([type])) {
  grid-column: span 6;
}

.picker-list {
  border: 1px solid #d8dee6;
  border-radius: 6px;
  display: grid;
  max-height: min(58vh, 560px);
  overflow-y: auto;
}

.picker-item {
  align-items: center;
  background: #ffffff;
  border: 0;
  border-bottom: 1px solid #e4e8ee;
  border-radius: 0;
  color: #1f2933;
  display: flex;
  justify-content: space-between;
  min-height: 44px;
  padding: 10px 12px;
  text-align: left;
}

.picker-item:hover,
.picker-item:focus {
  background: #f8fafc;
}

.picker-item[hidden] {
  display: none;
}

.picker-item small {
  color: #52606d;
  flex: 0 0 auto;
  margin-left: 16px;
}

.picker-status {
  color: #52606d;
  font-size: 13px;
  margin: 8px 0 0;
}

.event-partner-picker-modal {
  max-width: 900px;
}

.partner-status-picker {
  border: 1px solid #d8dee6;
  border-radius: 6px;
  overflow-x: auto;
}

.partner-status-picker-header,
.partner-status-picker-item {
  display: grid;
  grid-template-columns: minmax(240px, 2fr) repeat(3, minmax(100px, 1fr));
  min-width: 620px;
}

.partner-status-picker-header {
  background: #f1f4f7;
  color: #52606d;
  font-size: 13px;
  font-weight: 700;
}

.partner-status-picker-header span,
.partner-status-picker-item span {
  border-right: 1px solid #e4e8ee;
  min-width: 0;
  overflow-wrap: anywhere;
  padding: 10px 12px;
}

.partner-status-picker-header span:last-child,
.partner-status-picker-item span:last-child {
  border-right: 0;
}

.partner-status-picker-list {
  border: 0;
  border-radius: 0;
}

.partner-status-picker-item {
  gap: 0;
  padding: 0;
}

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

.copy-actions span {
  color: #52606d;
  font-weight: 700;
}

.telema-history-panel {
  max-width: min(1480px, calc(100vw - 48px));
}

.history-result-table-wrap {
  border: 1px solid var(--color-border-subtle);
  border-radius: 6px;
  max-height: min(62vh, 720px);
  overflow: auto;
}

.history-result-table {
  min-width: 1280px;
}

.history-result-table th,
.history-result-table td {
  font-size: 13px;
  line-height: 1.5;
  min-width: 120px;
  overflow-wrap: anywhere;
  white-space: normal;
}

.history-result-table th:nth-child(1),
.history-result-table td:nth-child(1) {
  min-width: 180px;
}

.history-result-table th:nth-child(5),
.history-result-table td:nth-child(5) {
  min-width: 320px;
}

table {
  border-collapse: separate;
  border-spacing: 0;
  min-width: 760px;
  width: 100%;
}

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

th {
  background: #f1f4f7;
  color: var(--color-text-muted);
  font-size: var(--font-size-label);
  position: sticky;
  top: 0;
  z-index: 2;
  white-space: nowrap;
}

td {
  font-size: var(--font-size-body);
}

.excel-import-results {
  max-height: min(420px, calc(100vh - 160px));
}

.excel-import-status {
  border-radius: 999px;
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  padding: 5px 8px;
  white-space: nowrap;
}

.excel-import-status-success {
  background: #e6f4ea;
  color: #256c3a;
}

.excel-import-status-skipped {
  background: #eef2f6;
  color: #52606d;
}

.excel-import-status-error {
  background: #fdecea;
  color: #a61b1b;
}

.excel-import-result-error td {
  background: #fff8f7;
}

.excel-import-message {
  min-width: 280px;
  white-space: normal;
}

.history-row {
  cursor: pointer;
}

.history-row:hover,
.history-row:focus {
  background: #f8fafc;
  outline: none;
}

.detail-list {
  display: grid;
  gap: 10px 16px;
  grid-template-columns: minmax(90px, 140px) 1fr;
  margin: 0;
}

.detail-list dt {
  color: #52606d;
  font-weight: 700;
}

.detail-list dd {
  margin: 0;
  min-width: 0;
}

.detail-list pre {
  margin: 0;
}

pre {
  background: #f1f4f7;
  border-radius: 6px;
  overflow-x: auto;
  padding: 12px;
  white-space: pre-wrap;
}

.login-page {
  background: #eef2f6;
}

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

.login-panel {
  background: #ffffff;
  border: 1px solid #d8dee6;
  border-radius: 8px;
  margin: 0 auto;
  max-width: 420px;
  padding: 28px;
  width: 100%;
}

.login-panel h1 {
  font-size: 26px;
  margin: 0 0 8px;
}

.login-panel p {
  color: #627282;
  margin: 0 0 20px;
}

.login-panel form {
  display: grid;
  gap: 14px;
}

.login-panel button {
  width: 100%;
}

/* システム管理画面 */
.admin-summary-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 16px;
}

.system-admin-tabs > .tab-list {
  max-width: 100%;
  overflow-x: auto;
}

.system-admin-tabs .tab-panel[hidden] {
  display: none;
}

.system-admin-tabs label small {
  color: var(--color-text-subtle);
  font-weight: 400;
}

.system-admin-tabs .check-row {
  align-items: center;
  display: flex;
  gap: 8px;
  min-height: var(--control-height);
}

.system-admin-tabs .check-row input {
  flex: 0 0 auto;
  width: auto;
}

.admin-summary-card h2,
.admin-section h2 {
  font-size: 19px;
  margin: 0 0 12px;
}

.admin-section {
  margin-bottom: 16px;
}

.admin-section h3 {
  font-size: 16px;
  margin: 20px 0 10px;
}

.admin-section-heading {
  align-items: flex-start;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  margin-bottom: 14px;
}

.admin-section-heading p {
  color: var(--color-text-subtle);
  margin: -6px 0 0;
}

.compact-details {
  grid-template-columns: minmax(110px, auto) minmax(0, 1fr);
}

.compact-details dd {
  overflow-wrap: anywhere;
}

.comparison-labels {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 24px;
  margin: 12px 0;
}

.admin-table-scroll {
  max-height: 480px;
  padding: 0;
}

.wrap-code {
  overflow-wrap: anywhere;
  white-space: normal;
}

.admin-log-search {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
}

.admin-log-search label {
  display: grid;
  gap: 5px;
}

.admin-keyword {
  grid-column: span 2;
}

.admin-log-actions {
  align-self: end;
  grid-column: span 3;
  margin: 0;
  position: static;
}

.log-downloads {
  border-top: 1px solid var(--color-border-light);
  margin-top: 16px;
  padding-top: 12px;
}

.log-downloads div {
  display: flex;
  gap: 12px;
  margin-top: 7px;
}

.admin-log-results {
  margin-top: 14px;
  max-height: 620px;
  padding: 0;
}

.log-timestamp {
  min-width: 190px;
  white-space: nowrap;
}

.log-detail {
  background: #111827;
  border-radius: 5px;
  color: #e5e7eb;
  font-size: 12px;
  margin: 8px 0 0;
  max-height: 360px;
  max-width: 720px;
  overflow: auto;
  padding: 10px;
  white-space: pre-wrap;
}

@media (max-width: 820px) {
  .app-header {
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    padding: 12px 16px;
  }

  .menu-toggle {
    display: inline-flex;
    flex-direction: column;
  }

  .app-header nav,
  .login-user {
    display: none;
  }

  body.menu-open .app-header nav,
  body.menu-open .login-user {
    display: flex;
  }

  .app-header nav {
    background: #ffffff;
    border-top: 1px solid #e4e8ee;
    flex-direction: column;
    gap: 0;
    order: 3;
    padding-top: 8px;
    width: 100%;
  }

  .app-header nav a {
    border-bottom: 1px solid #e4e8ee;
    padding: 10px 0;
  }

  .login-user {
    align-items: flex-start;
    border-top: 1px solid #e4e8ee;
    flex-direction: column;
    margin-left: 0;
    order: 4;
    padding-top: 10px;
    width: 100%;
  }

  .page {
    padding: 16px;
  }

  .page-title h1 {
    font-size: 23px;
  }

  .panel {
    padding: 14px;
  }

  .form-grid,
  .search-grid,
  .menu-grid,
  .admin-summary-grid,
  .venue-details,
  .picker-filters,
  .role-status-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .admin-section-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .admin-log-search {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .admin-keyword,
  .admin-log-actions {
    grid-column: 1 / -1;
  }

  .form-grid > label,
  .form-grid > button,
  .form-grid > .field-width-xs,
  .form-grid > .field-width-sm,
  .form-grid > .field-width-md,
  .form-grid > .field-width-lg,
  .venue-details > label {
    grid-column: 1 / -1 !important;
  }

  .search-grid > label,
  .picker-filters > label {
    grid-column: 1 / -1 !important;
  }

  .wide,
  .span-1,
  .span-2,
  .span-3,
  .one-column,
  .half-wide,
  .third-wide {
    grid-column: 1 / -1;
  }

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

  .modal-backdrop {
    align-items: stretch;
    padding: 0;
  }

  .modal-panel {
    border-radius: 0;
    max-height: 100dvh;
    max-width: none;
    padding: 16px;
  }

  .modal-header {
    background: #ffffff;
    position: sticky;
    top: -16px;
    z-index: 4;
  }

  .modal-actions,
  .event-form-actions,
  .form-actions {
    position: sticky;
    bottom: -16px;
    background: #ffffff;
    border-top: 1px solid #e4e8ee;
    margin: 0 -16px -16px;
    padding: 12px 16px 16px;
    z-index: 3;
  }

  .table-scroll {
    margin-left: -16px;
    margin-right: -16px;
    max-height: none;
    padding-left: 0;
    padding-right: 0;
  }

  .table-scroll > .pagination {
    padding-left: 14px;
    padding-right: 14px;
  }

  .action-bar,
  .inline-form,
  .telema-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .action-bar > *,
  .inline-form > *,
  .telema-actions > * {
    width: 100%;
  }

  .inline-form > label:has(> input[type="file"]),
  .inline-form > label:has(> select) {
    min-width: 0;
  }

  .tabs,
  .tab-list {
    width: 100%;
  }

  .tab-list {
    overflow-x: auto;
  }

  .tab-button {
    flex: 0 0 auto;
  }

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

  .detail-list dd {
    margin-bottom: 8px;
  }

  .event-form-section,
  .form-section {
    padding: 13px;
  }
}

@media (max-width: 480px) {
  .app-header {
    padding: 10px 12px;
  }

  .brand {
    font-size: 14px;
  }

  .page {
    padding: 12px;
  }

  .panel {
    border-radius: 6px;
    padding: 12px;
  }

  .table-scroll {
    margin-left: -12px;
    margin-right: -12px;
  }

  .input-with-button {
    grid-template-columns: minmax(0, 1fr);
  }

  .input-with-button .button-link,
  .pagination .button-link {
    width: 100%;
  }

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

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

  .checks label {
    white-space: normal;
  }

  .picker-item {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .picker-item small {
    margin-left: 0;
  }

  .event-form-actions > *,
  .form-actions > * {
    flex: 1 1 auto;
  }

  .login-shell {
    padding: 12px;
  }

  .login-panel {
    padding: 20px;
  }

  .admin-log-search {
    grid-template-columns: minmax(0, 1fr);
  }
}
