/* 管理画面のみ。色は提供された企業ロゴの緑（#00913a / #22ac38 / #31483a）を基準にする。 */
body.admin-body {
  margin: 0;
  background: #f4f8f5;
}

.admin-page {
  --admin-green: #007331;
  --admin-green-hover: #005b28;
  --admin-green-soft: #e9f6ec;
  --admin-ink: #193126;
  --admin-muted: #586e60;
  --admin-border: #d9e5dc;
  --admin-surface: #fff;
  --admin-page-bg: #f4f8f5;
  --admin-warning: #8b4a0a;
  --admin-radius: 12px;
  box-sizing: border-box;
  min-height: 100vh;
  background: var(--admin-page-bg);
  color: var(--admin-ink);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
  font-size: 15px;
  line-height: 1.65;
}

.admin-page *,
.admin-page *::before,
.admin-page *::after {
  box-sizing: inherit;
}

.admin-page a {
  color: var(--admin-green);
  text-underline-offset: 0.2em;
}

.admin-page a:hover {
  color: var(--admin-green-hover);
}

.admin-page :is(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: 3px solid #22ac38;
  outline-offset: 3px;
}

/* 管理画面共通ヘッダー */
.admin-page__masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 10px max(24px, calc((100vw - 1180px) / 2));
  border-bottom: 1px solid var(--admin-border);
  background: var(--admin-surface);
}

.admin-page__navigation {
  display: flex;
  align-items: center;
  gap: 16px;
}

.admin-page__nav-link {
  font-size: 0.88rem;
  font-weight: 600;
}

.admin-brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  text-decoration: none;
}

.admin-brand__mark {
  display: block;
  flex: 0 0 108px;
  width: 108px;
  height: 52px;
  overflow: hidden;
}

.admin-brand__image {
  display: block;
  width: 108px;
  height: 108px;
  transform: translateY(-28px);
}

.admin-brand__text {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.admin-brand__name {
  color: var(--admin-ink);
  font-size: 1.05rem;
  font-weight: 750;
}

.admin-brand__subtitle {
  margin-top: 4px;
  color: var(--admin-muted);
  font-size: 0.76rem;
}

/* ページとパネル */
.admin-page__content {
  width: min(100%, 1228px);
  margin-inline: auto;
  padding: 36px 24px 64px;
}

.admin-page__header {
  margin-bottom: 28px;
}

.admin-page__eyebrow {
  margin: 0 0 8px;
  color: var(--admin-green);
  font-size: 0.77rem;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.admin-page__title {
  margin: 0;
  font-size: clamp(1.5rem, 2.6vw, 2rem);
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.admin-page__description {
  margin: 8px 0 0;
  color: var(--admin-muted);
}

.admin-page__back {
  display: inline-block;
  margin-bottom: 20px;
  font-size: 0.9rem;
  font-weight: 600;
}

.admin-page__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 20px;
}

.admin-page__meta,
.admin-muted {
  color: var(--admin-muted);
  font-size: 0.85rem;
}

.admin-panel {
  margin-bottom: 20px;
  padding: 24px;
  border: 1px solid var(--admin-border);
  border-radius: var(--admin-radius);
  background: var(--admin-surface);
  box-shadow: 0 2px 10px rgb(22 60 36 / 4%);
}

.admin-panel--narrow {
  max-width: 550px;
}

.admin-panel__header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px 16px;
  margin-bottom: 16px;
}

.admin-panel__title {
  margin: 0;
  font-size: 1.12rem;
  line-height: 1.4;
}

.admin-panel__description {
  margin: 0 0 16px;
  color: var(--admin-muted);
  font-size: 0.9rem;
}

.admin-panel__header .admin-panel__description {
  margin: 0;
}

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

.admin-panel__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

/* ボタンと入力欄 */
.admin-button,
.admin-page a.admin-button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 38px;
  padding: 8px 14px;
  border: 1px solid var(--admin-border);
  border-radius: 7px;
  background: #fff;
  color: var(--admin-ink);
  font: inherit;
  font-size: 0.86rem;
  font-weight: 650;
  line-height: 1.3;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}

.admin-button:hover,
.admin-page a.admin-button:hover {
  background: #f3f7f4;
  color: var(--admin-ink);
}

.admin-button--primary,
.admin-page a.admin-button--primary {
  border-color: var(--admin-green);
  background: var(--admin-green);
  color: #fff;
}

.admin-button--primary:hover,
.admin-page a.admin-button--primary:hover {
  border-color: var(--admin-green-hover);
  background: var(--admin-green-hover);
  color: #fff;
}

.admin-button--secondary,
.admin-page a.admin-button--secondary {
  border-color: #b9d6c1;
  background: var(--admin-green-soft);
  color: #075e2b;
}

.admin-button--secondary:hover,
.admin-page a.admin-button--secondary:hover {
  background: #d9efdf;
  color: #075e2b;
}

.admin-button--warning {
  border-color: #e8c79f;
  background: #fff4e6;
  color: var(--admin-warning);
}

.admin-button--warning:hover {
  background: #ffe9cf;
}

.admin-button--quiet {
  background: transparent;
}

.admin-input {
  width: 100%;
  min-width: 0;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid #bdcec2;
  border-radius: 7px;
  background: #fff;
  color: var(--admin-ink);
  font: inherit;
  font-size: 0.87rem;
}

.admin-input::placeholder {
  color: #6b8073;
}

.admin-link {
  font-size: 0.86rem;
  font-weight: 650;
}

/* ステータスの意味は色だけに依存させず、ラベルも併記する。 */
.status-badge,
.anchor-badge {
  display: inline-block;
  padding: 3px 9px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: #eef1ef;
  color: #40554a;
  font-size: 0.77rem;
  font-weight: 700;
  white-space: nowrap;
}

.status-badge--published,
.status-badge--selected,
.anchor-badge--anchored {
  border-color: #bce4c7;
  background: #e4f7e9;
  color: #14602e;
}

.status-badge--confirmed,
.status-badge--info,
.anchor-badge--pending {
  border-color: #bfd5eb;
  background: #eaf3fe;
  color: #215582;
}

.status-badge--draft {
  border-color: #eed6ac;
  background: #fff5df;
  color: #89550b;
}

.status-badge--superseded,
.anchor-badge--none {
  border-color: #dbe1dd;
  background: #f2f4f2;
  color: #516258;
}

.anchor-badge--failed {
  border-color: #efc6c8;
  background: #fff0f1;
  color: #982c36;
}

/* 版一覧・差分表 */
.table-scroll {
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid var(--admin-border);
  border-radius: 8px;
}

.version-table,
.diff-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.version-table {
  min-width: 1120px;
}

.version-table th,
.version-table td,
.diff-table th,
.diff-table td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--admin-border);
  vertical-align: top;
}

.version-table thead,
.diff-table thead {
  background: #f1f6f2;
  color: #40574a;
  font-size: 0.8rem;
}

.version-table th {
  white-space: nowrap;
}

.version-table tbody tr:last-child td,
.diff-table tbody tr:last-child > * {
  border-bottom: 0;
}

.version-table tbody tr:hover,
.diff-table tbody tr:hover {
  background: #fbfdfb;
}

.version-table__number,
.version-table__date,
.sku-list__code {
  font-variant-numeric: tabular-nums;
}

.version-table__number {
  font-weight: 750;
  white-space: nowrap;
}

.version-table__date {
  min-width: 145px;
  font-size: 0.82rem;
}

.version-table__note {
  min-width: 160px;
  max-width: 220px;
  overflow-wrap: anywhere;
  color: var(--admin-muted);
  font-size: 0.85rem;
}

.version-table__actions {
  min-width: 295px;
}

.version-action-form {
  margin-top: 9px;
}

.version-action-form:first-child {
  margin-top: 0;
}

.version-action-form__label {
  display: block;
  margin-bottom: 5px;
  color: var(--admin-muted);
  font-size: 0.77rem;
}

.version-action-form__controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.version-action-form__controls .admin-input {
  flex: 1;
}

.version-action-form__controls .admin-button {
  flex: 0 0 auto;
}

.diff-table {
  min-width: 660px;
}

.diff-table__key {
  min-width: 160px;
  color: var(--admin-ink);
  font-size: 0.87rem;
  font-weight: 650;
}

.diff-table__value {
  max-width: 400px;
  margin: 0;
  overflow: auto;
  color: var(--admin-ink);
  font: 0.81rem/1.65 ui-monospace, SFMono-Regular, Consolas, monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* JSON プレビューと SKU 一覧 */
.json-preview {
  margin: 0;
  max-height: 65vh;
  overflow: auto;
  padding: 18px;
  border: 1px solid #d7e4d9;
  border-radius: 8px;
  background: #f7faf8;
}

.json-preview__content {
  color: #233b2d;
  font: 0.85rem/1.7 ui-monospace, SFMono-Regular, Consolas, monospace;
  tab-size: 2;
}

.sku-list,
.tenant-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.sku-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.sku-list__item {
  display: flex;
  align-items: baseline;
  gap: 9px;
  padding: 9px 12px;
  border: 1px solid var(--admin-border);
  border-radius: 8px;
  background: #f9fcfa;
}

.sku-list__code {
  font-weight: 700;
}

.sku-list__meta {
  color: var(--admin-muted);
  font-size: 0.79rem;
}

.tenant-list__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--admin-border);
}

.tenant-list__item:last-child {
  border-bottom: 0;
}

.tenant-list__name {
  font-weight: 650;
}

body.admin-body [data-flash-type] {
  max-width: 1180px;
  margin: 14px auto 0;
  padding: 10px 16px;
  border: 1px solid #b9d6c1;
  border-radius: 8px;
  background: #e9f6ec;
  color: #075e2b;
}

body.admin-body [data-flash-type="alert"] {
  border-color: #efc6c8;
  background: #fff0f1;
  color: #982c36;
}

@media (max-width: 680px) {
  .admin-page__masthead {
    gap: 8px;
    padding: 8px 16px;
  }

  .admin-brand__name {
    font-size: 0.88rem;
  }

  .admin-brand__mark {
    flex-basis: 84px;
    width: 84px;
  }

  .admin-brand__image {
    width: 84px;
    height: 84px;
    transform: translateY(-20px);
  }

  .admin-page__nav-link {
    font-size: 0.78rem;
  }

  .admin-page__content {
    padding: 24px 14px 48px;
  }

  .admin-panel {
    padding: 16px;
  }

  .admin-page__footer,
  .tenant-list__item {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .sku-list__item {
    flex-wrap: wrap;
  }
}
