:root {
  --detail-bg: #f4f7fb;
  --detail-panel: #ffffff;
  --detail-ink: #092754;
  --detail-muted: #607593;
  --detail-line: #d8e2ef;
  --detail-brand: #0b4bad;
  --detail-green: #19a463;
  --detail-orange: #f0a52b;
  --detail-red: #e33434;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--detail-ink);
  background: var(--detail-bg);
  font-family: "Noto Sans JP", "Yu Gothic UI", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

.detail-page {
  width: min(1340px, calc(100% - 40px));
  margin: 30px auto 50px;
}

.breadcrumbs {
  margin: 0 0 20px;
  color: var(--detail-muted);
}

.detail-top-navigation {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
  margin-bottom: 20px;
}

.detail-top-navigation .breadcrumbs {
  margin-bottom: 0;
}

.cross-navigation-link {
  display: inline-flex;
  flex: 0 0 auto;
  gap: 9px;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 8px 16px;
  border: 1px solid var(--detail-brand);
  border-radius: 7px;
  color: var(--detail-brand);
  background: #fff;
  font-weight: 800;
  text-decoration: none;
  transition: background-color 0.15s ease, box-shadow 0.15s ease;
}

.cross-navigation-link:hover,
.cross-navigation-link:focus-visible {
  background: #f2f7ff;
  box-shadow: 0 0 0 3px rgb(15 82 168 / 12%);
}

.cross-navigation-icon {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.breadcrumbs a {
  color: #396a9f;
}

.breadcrumbs span {
  margin: 0 8px;
}

.detail-title {
  margin: 0;
  font-size: clamp(2rem, 4vw, 2.6rem);
}

.policy-heading {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 14px 0 20px;
  flex-wrap: wrap;
}

.policy-heading .heading-label {
  color: var(--detail-muted);
  font-weight: 700;
}

.policy-heading strong {
  font-size: clamp(1.8rem, 4vw, 2.7rem);
  letter-spacing: 0.04em;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  border: 1px solid #aaddbc;
  border-radius: 999px;
  padding: 7px 13px;
  color: #0a8248;
  background: #eaf8ef;
  font-weight: 700;
}

.status-badge::before {
  content: "✓";
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  margin-right: 7px;
  border-radius: 50%;
  color: white;
  background: var(--detail-green);
}

.status-badge.inactive {
  border-color: #d2d9e3;
  color: #607084;
  background: #f3f5f8;
}

.status-badge.inactive::before {
  content: "－";
  background: #7b8a9c;
}

.notice {
  margin-bottom: 18px;
  padding: 17px 20px;
  border: 1px solid #f2b24b;
  border-radius: 11px;
  color: #aa5e00;
  background: #fffaf0;
  font-weight: 800;
}

.notice::before {
  content: "▲";
  margin-right: 12px;
  color: #eb8a00;
}

.notice.info {
  border-color: #c8d9f4;
  color: #1855a6;
  background: #f1f6ff;
}

.notice.info::before {
  content: "i";
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  margin-right: 11px;
  border-radius: 50%;
  color: #fff;
  background: var(--detail-brand);
  font-family: Georgia, serif;
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
  gap: 18px;
}

.detail-card,
.action-panel,
.ai-summary {
  border: 1px solid var(--detail-line);
  border-radius: 12px;
  background: var(--detail-panel);
  box-shadow: 0 8px 20px rgba(23, 55, 97, 0.07);
}

.detail-card {
  padding: 25px;
}

.card-title {
  margin: 0 0 20px;
  font-size: 1.25rem;
}

.info-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
  border: 1px solid var(--detail-line);
  border-radius: 10px;
}

.info-table th,
.info-table td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--detail-line);
  text-align: left;
}

.info-table th {
  width: 42%;
  background: #fbfdff;
}

.info-table tr:last-child th,
.info-table tr:last-child td {
  border-bottom: 0;
}

.text-warn {
  color: #d97900;
  font-weight: 700;
}

.text-danger {
  color: #d63333;
  font-weight: 700;
}

.contract-period {
  display: flex;
  justify-content: space-between;
  gap: 20px;
}

.date-block {
  display: grid;
  gap: 4px;
}

.date-block:last-child {
  text-align: right;
}

.date-label {
  color: var(--detail-muted);
  font-size: 0.85rem;
}

.date-value {
  font-size: 1.05rem;
  font-weight: 800;
}

.contract-track {
  height: 7px;
  margin: 18px 8px 28px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--detail-green), #377cc5);
}

.decision-panel {
  padding: 17px 18px 14px;
  border: 1px solid #c9d8ea;
  border-radius: 12px;
  background: #f8fbff;
}

.decision-panel h3 {
  margin: 0;
  font-size: 1.05rem;
}

.decision-caption {
  margin: 5px 0 36px;
  color: var(--detail-muted);
  font-size: 0.82rem;
}

.timeline {
  position: relative;
  height: 152px;
  margin: 0 8px;
}

.timeline-line {
  position: absolute;
  top: 56px;
  right: 0;
  left: 0;
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(
    90deg,
    var(--detail-green) 0 var(--early-position),
    var(--detail-orange) var(--early-position) 100%
  );
}

.decision-panel.urgent .timeline-line,
.decision-panel.expired .timeline-line {
  background: linear-gradient(
    90deg,
    var(--detail-green) 0 var(--early-position),
    var(--detail-orange) var(--early-position) var(--today-position),
    var(--detail-red) var(--today-position) 100%
  );
}

.timeline-marker {
  position: absolute;
  top: 56px;
  left: var(--position);
  transform: translate(-50%, -50%);
  width: 18px;
  height: 18px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: var(--detail-brand);
  box-shadow: 0 0 0 1px rgba(9, 39, 84, 0.1);
}

.timeline-marker.start {
  left: 0;
  background: var(--detail-green);
}

.timeline-marker.end {
  left: 100%;
}

.timeline-marker.today {
  width: 25px;
  height: 25px;
  background: var(--detail-red);
  z-index: 2;
}

.marker-label {
  position: absolute;
  min-width: 115px;
  color: var(--detail-muted);
  font-size: 0.75rem;
  line-height: 1.45;
}

.marker-label strong {
  display: block;
  color: var(--detail-ink);
  font-size: 0.82rem;
}

.marker-label.start-label {
  top: 82px;
  left: 0;
}

.marker-label.deadline-label {
  top: 82px;
  left: var(--early-position);
  transform: translateX(-50%);
  text-align: center;
}

.marker-label.today-label {
  top: -14px;
  left: clamp(58px, var(--today-position), calc(100% - 58px));
  transform: translateX(-50%);
  width: 116px;
  min-width: 0;
  padding: 6px 10px;
  border: 1px solid #eb6969;
  border-radius: 9px;
  color: #c92727;
  background: #fff1f1;
  text-align: center;
  font-weight: 800;
  z-index: 3;
}

.marker-label.end-label {
  top: 82px;
  right: 0;
  text-align: right;
}

.timing-message {
  margin: 4px 0 0;
  padding: 8px 11px;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 800;
}

.timing-message.before {
  color: #315f8d;
  background: #eaf3fc;
}

.timing-message.early {
  color: #0d7d49;
  background: #e9f8ef;
}

.timing-message.urgent,
.timing-message.expired {
  color: #c82f2f;
  background: #fff0f0;
}

.action-panel {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-top: 18px;
  padding: 20px 22px;
  flex-wrap: wrap;
}

.action-panel form {
  margin: 0;
}

.action-panel .spacer {
  flex: 1;
}

.action-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 10px 25px;
  border: 1px solid var(--detail-brand);
  border-radius: 8px;
  color: var(--detail-brand);
  background: #fff;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}

.action-button.primary {
  min-width: 210px;
  color: #fff;
  background: #0a448f;
}

.action-button.danger {
  min-width: 190px;
  border-color: #ed3f3f;
  color: #d92e2e;
}

.ai-summary {
  position: relative;
  margin-top: 16px;
  padding: 23px 28px 23px 46px;
}

.ai-summary::before {
  content: "";
  position: absolute;
  top: 22px;
  bottom: 22px;
  left: 23px;
  width: 4px;
  border-radius: 4px;
  background: #2166b1;
}

.ai-summary h2 {
  margin: 0 0 9px;
  font-size: 1.1rem;
}

.ai-summary p {
  margin: 0;
  color: var(--detail-muted);
  white-space: pre-wrap;
  line-height: 1.7;
}

.ai-suggestion-summary {
  color: #314d73;
  font-weight: 700;
}

.ai-suggestion-section {
  margin-top: 18px;
}

.ai-suggestion-section h3 {
  margin: 0 0 10px;
  color: #183963;
  font-size: 0.98rem;
}

.ai-action-list,
.ai-caution-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.ai-action-list li {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 11px;
  align-items: start;
  padding: 13px 15px;
  border: 1px solid #d7e4f5;
  border-radius: 9px;
  background: #f8fbff;
}

.ai-action-number {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  color: #fff;
  background: var(--detail-brand);
  font-weight: 900;
}

.ai-action-list p {
  margin: 0;
  color: #27466f;
  white-space: normal;
  overflow-wrap: anywhere;
}

.ai-caution-section {
  padding: 13px 15px;
  border: 1px solid #f0c879;
  border-radius: 9px;
  background: #fffaf0;
}

.ai-caution-list {
  gap: 8px;
}

.ai-caution-list li {
  position: relative;
  padding-left: 19px;
  color: #8a5a00;
  line-height: 1.65;
}

.ai-caution-list li::before {
  content: "・";
  position: absolute;
  left: 0;
  font-weight: 900;
}

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

.policy-ai-summary-item {
  display: grid;
  gap: 8px;
  align-content: start;
  min-width: 0;
  padding: 15px 17px;
  border: 1px solid #d7e4f5;
  border-radius: 9px;
  background: #f8fbff;
}

.policy-ai-caution {
  border-color: #f0c879;
  background: #fffaf0;
}

.policy-ai-label {
  width: fit-content;
  padding: 4px 11px;
  border-radius: 999px;
  color: #fff;
  background: var(--detail-brand);
  font-size: 0.84rem;
  font-weight: 900;
}

.policy-ai-caution .policy-ai-label {
  background: #d97900;
}

.policy-ai-summary-item p {
  margin: 0;
  color: #27466f;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.7;
}

.policy-ai-caution p {
  color: #8a5a00;
}

.alert {
  margin: 14px 0;
  padding: 11px 14px;
  border-radius: 9px;
}

.alert.success {
  color: #0b5a2d;
  background: #edf9f2;
}

.alert.error {
  color: #8a1f1f;
  background: #fff2f2;
}

.accident-detail-page {
  width: min(1340px, calc(100% - 40px));
}

.accident-header {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-end;
  margin-bottom: 22px;
}

.accident-heading {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 14px;
}

.accident-heading .heading-label {
  color: var(--detail-muted);
  font-weight: 700;
}

.accident-heading strong {
  font-size: 1.75rem;
}

.accident-header-actions {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.accident-header-actions form,
.accident-ai-area form {
  margin: 0;
}

.accident-layout {
  display: grid;
  grid-template-columns: minmax(360px, 0.72fr) minmax(0, 1.45fr);
  gap: 18px;
  align-items: stretch;
}

.accident-info-card,
.accident-history-card {
  min-width: 0;
}

.inline-status {
  display: inline-block;
  padding: 4px 12px;
  border: 1px solid #9bdab7;
  border-radius: 999px;
  color: #0a8248;
  background: #eaf8ef;
  font-size: 0.9rem;
  font-weight: 800;
}

.inline-status.inactive {
  border-color: #d2d9e3;
  color: #607084;
  background: #f3f5f8;
}

.history-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.history-item {
  position: relative;
  padding: 0 0 18px 30px;
}

.history-item:not(:last-child)::before {
  content: "";
  position: absolute;
  top: 18px;
  bottom: -2px;
  left: 8px;
  width: 2px;
  background: #1d5ec4;
}

.history-dot {
  position: absolute;
  top: 15px;
  left: 1px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #1359bd;
}

.history-entry {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr) 68px;
  gap: 16px;
  align-items: start;
  padding: 16px 18px;
  border: 1px solid var(--detail-line);
  border-radius: 9px;
  background: #fff;
}

.history-entry time {
  font-weight: 800;
}

.history-entry p {
  min-width: 0;
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.6;
}

.history-edit-toggle {
  grid-column: 3;
  grid-row: 1;
  width: 68px;
  box-sizing: border-box;
  padding: 7px 13px;
  border: 1px solid var(--detail-brand);
  border-radius: 7px;
  color: var(--detail-brand);
  font-weight: 800;
  text-align: center;
  cursor: pointer;
  background: #fff;
}

.history-edit-form {
  grid-column: 1 / 3;
  display: grid;
  gap: 8px;
  width: 100%;
  min-width: 0;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--detail-line);
}

.history-edit-form[hidden] {
  display: none;
}

.history-add {
  margin-top: 8px;
  padding-top: 20px;
  border-top: 1px solid var(--detail-line);
}

.history-add h3 {
  margin: 0 0 14px;
  font-size: 1.08rem;
}

.history-add-form {
  display: grid;
  gap: 9px;
}

.history-add-form label,
.history-edit-form label {
  font-weight: 800;
}

.history-add-form input[type="datetime-local"],
.history-add-form textarea,
.history-edit-form input,
.history-edit-form textarea {
  box-sizing: border-box;
  width: 100%;
  padding: 11px 13px;
  border: 1px solid #afbdd0;
  border-radius: 7px;
  color: var(--detail-ink);
  background: #fff;
}

.history-edit-form input[type="datetime-local"] {
  width: min(100%, 250px);
}

.history-edit-form textarea {
  min-width: 0;
}

.history-add-form textarea,
.history-edit-form textarea {
  resize: vertical;
}

.history-checkbox {
  display: flex;
  gap: 9px;
  align-items: center;
  margin-top: 4px;
}

.history-checkbox input {
  width: 18px;
  height: 18px;
  accent-color: var(--detail-brand);
}

.history-note {
  margin: 0;
  padding: 10px 13px;
  border: 1px solid #c8d9f4;
  border-radius: 7px;
  color: #1855a6;
  background: #f1f6ff;
  font-size: 0.88rem;
  line-height: 1.55;
}

.history-submit {
  width: 100%;
  margin-top: 2px;
}

.action-button.compact {
  justify-self: start;
  min-width: 0;
}

.history-empty {
  margin-bottom: 18px;
  padding: 16px;
  border: 1px dashed #bdcadb;
  border-radius: 9px;
  color: var(--detail-muted);
}

.history-empty p {
  margin: 0;
  white-space: pre-wrap;
}

.history-empty p + p {
  margin-top: 10px;
}

.accident-ai-area {
  margin-top: 18px;
}

.ai-trigger {
  background: #fff;
}

.accident-ai-summary {
  margin-top: 12px;
}

.accident-ai-summary h2 span {
  color: var(--detail-muted);
  font-size: 0.85rem;
  font-weight: 700;
}

.registration-page .detail-card {
  min-width: 0;
}

.registration-form {
  display: grid;
  gap: 18px;
}

.form-field {
  display: grid;
  gap: 7px;
}

.form-field label {
  color: #183963;
  font-weight: 800;
}

.form-field input,
.form-field textarea {
  width: 100%;
  min-height: 46px;
  padding: 11px 13px;
  border: 1px solid #afbdd0;
  border-radius: 7px;
  color: var(--detail-ink);
  background: #fff;
  font: inherit;
}

.form-field textarea {
  min-height: 128px;
  resize: vertical;
  line-height: 1.6;
}

.field-hint {
  margin: 0;
  color: var(--detail-muted);
  font-size: 0.86rem;
  line-height: 1.55;
}

.field-error {
  margin: 0;
  color: var(--detail-red);
  font-size: 0.9rem;
  font-weight: 800;
}

.registration-preview {
  margin-top: 18px;
}

.registration-accident-grid {
  grid-template-columns: minmax(360px, 0.72fr) minmax(0, 1.45fr);
}

.policy-search-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px;
  gap: 10px;
  align-items: end;
}

.policy-search-form .compact-search {
  width: 100%;
  min-width: 0;
  padding-right: 14px;
  padding-left: 14px;
}

.search-policy-note {
  margin-bottom: 12px;
  padding: 10px 13px;
  border: 1px solid #c8d9f4;
  border-radius: 7px;
  color: #1855a6;
  background: #f1f6ff;
  font-weight: 800;
}

.policy-result-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.policy-result {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 14px 16px;
  border: 1px solid var(--detail-line);
  border-radius: 9px;
  background: #fff;
}

.policy-result.selected {
  border-color: #8fc4ad;
  background: #f1fbf6;
}

.policy-result-main {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.policy-result-main strong,
.policy-result-number {
  color: var(--detail-ink);
  font-size: 1.04rem;
  font-weight: 900;
}

.policy-result-main p {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 0;
  color: var(--detail-muted);
  font-size: 0.87rem;
}

.select-policy-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 7px 14px;
  border: 1px solid var(--detail-brand);
  border-radius: 7px;
  color: var(--detail-brand);
  background: #fff;
  font-weight: 800;
  text-decoration: none;
}

.select-policy-button.selected {
  border-color: #74bd9b;
  color: #0a8248;
  background: #eaf8ef;
}

.selected-policy-card {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
  padding: 18px;
  border: 1px solid #9bdab7;
  border-radius: 10px;
  background: #effcf6;
}

.selected-policy-card.empty-selection {
  border-color: #cbd9eb;
  background: #f8fbff;
}

.selected-policy-label {
  display: inline-flex;
  width: fit-content;
  padding: 5px 13px;
  border: 1px solid #9bdab7;
  border-radius: 999px;
  color: #0a8248;
  background: #eaf8ef;
  font-weight: 800;
}

.selected-policy-card strong {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 1.25rem;
}

.selected-policy-card p {
  margin: 0;
  color: var(--detail-muted);
}

.accident-registration-form {
  margin-top: 16px;
}

.registration-inner-actions {
  margin-top: 20px;
  box-shadow: none;
}

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

  .action-panel .spacer {
    display: none;
  }

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

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

@media (max-width: 620px) {
  .detail-top-navigation {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }

  .cross-navigation-link {
    align-self: flex-end;
  }

  .detail-page {
    width: min(100% - 20px, 1340px);
    margin-top: 16px;
  }

  .detail-card {
    padding: 17px;
  }

  .info-table th,
  .info-table td {
    display: block;
    width: 100%;
  }

  .info-table th {
    padding-bottom: 5px;
  }

  .info-table td {
    padding-top: 5px;
  }

  .marker-label {
    min-width: 92px;
    font-size: 0.68rem;
  }

  .marker-label strong {
    font-size: 0.72rem;
  }

  .accident-detail-page {
    width: min(100% - 20px, 1340px);
  }

  .accident-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .accident-header-actions {
    width: 100%;
  }

  .accident-header-actions form {
    flex: 1;
  }

  .accident-header-actions .action-button {
    width: 100%;
    min-width: 0;
  }

  .history-entry {
    grid-template-columns: minmax(0, 1fr) 68px;
  }

  .history-entry time,
  .history-entry p {
    grid-column: 1;
  }

  .history-edit-toggle {
    grid-column: 2;
    grid-row: 1;
  }

  .history-edit-form {
    grid-column: 1 / -1;
  }

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

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

  .policy-ai-summary-grid {
    grid-template-columns: 1fr;
  }
}
