* {
  box-sizing: border-box;
}

html {
  width: 100%;
  overflow-x: hidden;
}

:root {
  --bg: #eef3f6;
  --panel: #ffffff;
  --panel-soft: #f7fafc;
  --text: #1d2a35;
  --muted: #607080;
  --line: #d8e1e8;
  --primary: #145c72;
  --primary-strong: #0f4657;
  --accent: #2f7d57;
  --warning: #b7791f;
  --danger: #b42318;
  --danger-soft: #fff1f0;
  --warning-soft: #fff8e6;
  --success-soft: #edf8f1;
}

body {
  margin: 0;
  width: 100%;
  min-height: 100vh;
  overflow-x: hidden;
  font-family: "UD Digi Kyokasho N-R", "UD Digi Kyokasho NP-R", "BIZ UDPGothic", "Yu Gothic UI", "Meiryo", sans-serif;
  background: var(--bg);
  color: var(--text);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
  line-height: 1.25;
  white-space: normal;
}

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

button:disabled {
  cursor: not-allowed;
  background: #a9bac4;
}

.shell {
  width: min(1440px, 100%);
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 22px 28px;
  background: #123646;
  color: #fff;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}

.help-link,
.admin-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: 999px;
  color: #fff;
  font-weight: 700;
  text-decoration: none;
  background: rgba(255, 255, 255, 0.1);
}

.help-link:focus,
.help-link:hover,
.admin-link:focus,
.admin-link:hover {
  background: rgba(255, 255, 255, 0.18);
}

.admin-link[hidden] {
  display: none;
}

.language-toggle {
  display: inline-flex;
  flex: 0 0 auto;
  gap: 4px;
  padding: 4px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.language-button {
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: #dcebf1;
  font-size: 13px;
}

.language-button:hover {
  border-color: rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.14);
}

.language-button.active {
  background: #fff;
  color: var(--primary);
}

.eyebrow {
  margin: 0 0 4px;
  color: #a8d7e6;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 26px;
  line-height: 1.2;
}

h2 {
  font-size: 18px;
  line-height: 1.3;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(360px, 520px) minmax(500px, 1fr);
  gap: 16px;
  padding: 16px;
}

.booking-panel,
.review-panel,
.calendar-panel {
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.booking-panel {
  grid-row: span 2;
  padding: 18px;
}

.review-panel,
.calendar-panel {
  padding: 18px;
}

.section-heading {
  display: grid;
  gap: 4px;
  margin-bottom: 14px;
}

.section-heading p {
  color: var(--muted);
  font-size: 13px;
}

.section-heading.inline {
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 16px;
}

.field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.field.missing span {
  color: var(--danger);
}

.field.missing input,
.field.missing select,
.field.missing textarea {
  border-color: var(--danger);
  background: #fff8f7;
  outline: 2px solid #ffd7d4;
}

.field span {
  color: #304757;
  font-size: 13px;
  font-weight: 700;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-width: 0;
  min-height: 40px;
  border: 1px solid #b9c7d2;
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 9px 10px;
}

.field select {
  overflow: hidden;
  text-overflow: ellipsis;
}

.field textarea {
  min-height: 104px;
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--primary);
  outline: 3px solid #d6eef5;
}

.field-help {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.form-link-note {
  margin: 0;
}

.form-link-note a {
  color: var(--primary);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.example-help {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.example-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.example-button {
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid #b9c7d2;
  background: #fff;
  color: #254557;
  font-size: 13px;
  line-height: 1.25;
}

.example-button:hover {
  background: #f2f6f8;
}

.example-button span {
  color: var(--muted);
  font-size: 12px;
}

.lookup-results {
  display: grid;
  gap: 4px;
  max-height: 180px;
  overflow-y: auto;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-soft);
}

.lookup-option {
  display: grid;
  gap: 2px;
  min-height: 44px;
  padding: 7px 8px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: #fff;
  color: var(--text);
  text-align: left;
  font-weight: 600;
}

.lookup-option:hover {
  border-color: #b9c7d2;
  background: #eef8fb;
}

.lookup-option span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

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

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 18px;
}

.actions button,
.section-heading.inline > button {
  padding: 0 14px;
}

button.secondary {
  border: 1px solid #b9c7d2;
  background: #fff;
  color: #254557;
}

button.secondary:hover {
  background: #f2f6f8;
}

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

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

.checkbox-field {
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px;
}

.checkbox-field input {
  width: 18px;
  min-height: 18px;
  padding: 0;
}

.blockout-list-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.blockout-list-table {
  min-width: 520px;
}

.result-panel {
  margin-top: 14px;
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 14px;
  line-height: 1.55;
}

.result-panel.neutral {
  background: var(--panel-soft);
  color: var(--muted);
}

.result-panel.ok {
  background: var(--success-soft);
  border-color: #a7d7b6;
  color: #14532d;
}

.result-panel.warn {
  background: var(--warning-soft);
  border-color: #efcd81;
  color: #704600;
}

.result-panel.bad {
  background: var(--danger-soft);
  border-color: #f0aaa4;
  color: #842016;
}

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

.candidate-table {
  width: 100%;
  min-width: 640px;
  border-collapse: collapse;
  font-size: 14px;
}

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

.candidate-table th {
  background: #e6f0f4;
  color: #173747;
  font-size: 13px;
}

.th-ja,
.th-en {
  display: block;
  line-height: 1.2;
  white-space: nowrap;
}

.th-en {
  color: #496579;
  font-size: 12px;
  font-weight: 700;
}

.candidate-table tr:last-child td {
  border-bottom: 0;
}

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

.tag {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0 3px;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
}

.tag.ok {
  background: #dcfce7;
  color: #14532d;
}

.tag.bad {
  background: #fee2e2;
  color: #7f1d1d;
}

.tag.warn {
  background: var(--warning-soft);
  color: #704600;
}

.table-note {
  display: inline-block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.25;
}

.table-note.warn {
  color: #704600;
}

.row-action {
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid #f0aaa4;
  background: #fff;
  color: var(--danger);
  font-size: 13px;
  line-height: 1.2;
}

.row-action:hover {
  background: #fff1f0;
}

.month-controls {
  display: grid;
  grid-template-columns: 40px minmax(112px, auto) 40px;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.calendar-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.legend-item::before {
  content: "";
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border-left: 4px solid var(--primary);
  background: #eef8fb;
}

.legend-item.pending::before {
  border-left-color: var(--warning);
  background: #fff8e6;
}

.legend-item.approved::before {
  border-left-color: var(--accent);
  background: #edf8f1;
}

.legend-item.conflict::before {
  border-left-color: var(--danger);
  background: #fff1f0;
}

.legend-item.blockout::before {
  border-left-color: #6b7280;
  background: #f1f5f9;
}

.icon-button {
  width: 40px;
  min-height: 40px;
  padding: 0;
  border: 1px solid #b9c7d2;
  background: #fff;
  color: var(--primary);
  font-size: 28px;
  line-height: 1;
}

.icon-button:hover {
  background: #f2f8fa;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}

.weekday-head,
.day-cell {
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.weekday-head {
  min-height: 34px;
  display: grid;
  place-items: center;
  background: #e6f0f4;
  color: #173747;
  font-size: 12px;
  font-weight: 800;
}

.day-cell {
  min-height: 116px;
  padding: 7px;
  background: #fff;
}

.day-cell.outside {
  background: #f3f6f8;
  color: #92a0aa;
}

.date-number {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 800;
}

.booking-item {
  display: grid;
  gap: 2px;
  width: 100%;
  min-height: 0;
  margin-bottom: 5px;
  padding: 6px;
  border-left: 4px solid var(--primary);
  border-radius: 5px;
  background: #eef8fb;
  color: #15313f;
  font-size: 12px;
  line-height: 1.25;
  text-align: left;
  cursor: pointer;
}

.booking-item.pending {
  border-left-color: var(--warning);
  background: #fff8e6;
}

.booking-item.approved {
  border-left-color: var(--accent);
  background: #edf8f1;
}

.booking-item.conflict {
  border-left-color: var(--danger);
  background: #fff1f0;
}

.booking-item.blockout {
  border-left-color: #6b7280;
  background: #f1f5f9;
  color: #334155;
}

.booking-item:hover {
  box-shadow: inset 0 0 0 1px rgba(20, 92, 114, 0.2);
  filter: brightness(0.98);
}

.calendar-more-button {
  width: 100%;
  min-height: 32px;
  margin-top: 2px;
  padding: 5px 6px;
  border: 1px solid #b9c7d2;
  border-radius: 5px;
  background: #fff;
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
}

.calendar-more-button:hover {
  background: #f2f8fa;
}

.booking-detail-dialog {
  width: min(520px, calc(100% - 32px));
  padding: 0;
  border: 0;
  border-radius: 8px;
  box-shadow: 0 22px 60px rgba(17, 37, 47, 0.22);
}

.admin-dialog {
  width: min(780px, calc(100% - 32px));
  max-height: calc(100vh - 32px);
  padding: 0;
  border: 0;
  border-radius: 8px;
  box-shadow: 0 22px 60px rgba(17, 37, 47, 0.22);
}

.admin-dialog::backdrop {
  background: rgba(10, 28, 38, 0.45);
}

.admin-dialog .admin-panel {
  max-height: calc(100vh - 32px);
  overflow: auto;
  padding: 20px;
  background: #fff;
}

.booking-detail-dialog::backdrop {
  background: rgba(10, 28, 38, 0.45);
}

.booking-detail-card {
  display: grid;
  gap: 16px;
  padding: 20px;
  background: #fff;
}

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

.booking-detail-header h2 {
  margin: 0;
  color: #173747;
  font-size: 20px;
}

.detail-close-button {
  width: 36px;
  min-height: 36px;
  padding: 0;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  font-size: 22px;
  line-height: 1;
}

.detail-close-button:hover {
  background: #f2f8fa;
}

.booking-detail-body {
  display: grid;
  gap: 12px;
}

.booking-detail-summary {
  margin: 0;
  padding: 10px 12px;
  border-radius: 6px;
  background: #f2f8fa;
  color: #173747;
  font-weight: 800;
}

.outlook-body-preview {
  display: grid;
  gap: 8px;
}

.outlook-body-preview p {
  margin: 0;
  color: var(--text);
  line-height: 1.5;
}

.outlook-body-preview strong {
  color: #173747;
}

@media (max-width: 1060px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .booking-panel {
    grid-row: auto;
  }
}

@media (max-width: 720px) {
  body {
    background: #f5f8fa;
  }

  .shell {
    width: 100%;
    max-width: 100%;
  }

  .topbar,
  .section-heading.inline {
    align-items: flex-start;
    grid-template-columns: 1fr;
    min-width: 0;
  }

  .topbar {
    flex-direction: column;
    gap: 10px;
    padding: 18px 16px;
  }

  .topbar-actions {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
  }

  .help-link,
  .admin-link {
    width: 100%;
  }

  .language-toggle {
    width: 100%;
  }

  .language-button {
    flex: 1;
  }

  h1 {
    font-size: 22px;
  }

  h2 {
    font-size: 17px;
  }

  .workspace {
    width: 100%;
    max-width: 100%;
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
    padding: 8px;
  }

  .booking-panel,
  .review-panel,
  .calendar-panel {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    padding: 14px;
    border-radius: 6px;
  }

  .section-heading {
    margin-bottom: 12px;
  }

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

  .actions button,
  .section-heading.inline > button {
    width: 100%;
  }

  .reservation-form {
    grid-template-columns: minmax(0, 1fr);
  }

  .field,
  .field input,
  .field select,
  .field textarea {
    max-width: 100%;
    min-width: 0;
  }

  .example-buttons {
    display: grid;
    grid-template-columns: 1fr;
  }

  .example-button {
    min-height: 44px;
    padding: 4px 6px;
    font-size: 12px;
  }

  .candidate-table-wrap {
    max-width: 100%;
  }

  .candidate-table {
    min-width: 560px;
    font-size: 13px;
  }

  .candidate-table th,
  .candidate-table td {
    padding: 8px;
  }

  .month-controls {
    width: 100%;
    grid-template-columns: 40px 1fr 40px;
  }

  .calendar-grid {
    min-width: 0;
    width: 100%;
  }

  .calendar-panel {
    overflow-x: visible;
  }

  .weekday-head {
    min-height: 30px;
    font-size: 11px;
  }

  .day-cell {
    min-height: 88px;
    padding: 4px;
  }

  .date-number {
    margin-bottom: 4px;
    font-size: 11px;
  }

  .booking-item {
    gap: 1px;
    margin-bottom: 4px;
    padding: 4px;
    border-left-width: 3px;
    font-size: 10px;
    line-height: 1.2;
    overflow-wrap: anywhere;
  }

  .calendar-legend {
    gap: 6px;
  }

  .legend-item {
    font-size: 11px;
  }
}
