:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --surface: #ffffff;
  --surface-soft: #eef7f7;
  --ink: #172026;
  --muted: #63717a;
  --line: #d7e1e5;
  --brand: #1b5e7b;
  --brand-strong: #0d3a50;
  --accent: #c0392b;
  --danger: #a63d40;
  --shadow: 0 18px 44px rgba(23, 32, 38, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family:
    -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", "Yu Gothic UI",
    sans-serif;
}

button,
input,
select {
  font: inherit;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 112px;
  padding: 28px clamp(18px, 4vw, 56px);
  background: var(--brand-strong);
  color: #fff;
}

.app-header h1 {
  margin: 4px 0 0;
  font-size: clamp(26px, 4vw, 42px);
  line-height: 1.15;
  letter-spacing: 0;
}

.header-meta {
  margin: 10px 0 0;
  color: rgba(255, 255, 255, 0.78);
  font-size: 14px;
  font-weight: 700;
}

.header-link {
  flex: 0 0 auto;
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: 6px;
  color: #fff;
  padding: 10px 14px;
  text-decoration: none;
  font-size: 14px;
  font-weight: 900;
}

.header-link:hover {
  background: rgba(255, 255, 255, 0.1);
}

.eyebrow {
  margin: 0;
  color: inherit;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
  opacity: 0.78;
}

.status-pill {
  flex: 0 0 auto;
  border: 1px solid rgba(255, 255, 255, 0.36);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 700;
}

.app-shell {
  width: min(1220px, calc(100% - 32px));
  margin: 24px auto 48px;
}

.tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.tab-button {
  min-width: 112px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 10px 16px;
  font-weight: 800;
}

.tab-button.is-active {
  background: var(--brand);
  color: #fff;
}

.view {
  display: none;
}

.view.is-active {
  display: block;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin: 26px 0 18px;
}

.section-heading h2 {
  margin: 4px 0 0;
  font-size: clamp(24px, 3vw, 34px);
  letter-spacing: 0;
}

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

.order-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 18px;
  align-items: start;
}

.form-section,
.summary-panel,
.receipt-panel,
.admin-stats,
.table-wrap {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.form-section {
  grid-column: 1;
  padding: 22px;
}

.form-section h3,
.summary-panel h3 {
  margin: 0 0 16px;
  font-size: 20px;
  letter-spacing: 0;
}

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

label {
  display: grid;
  gap: 7px;
  color: #24323a;
  font-size: 14px;
  font-weight: 800;
}

input,
select {
  width: 100%;
  min-height: 44px;
  border: 1px solid #c8d5da;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 10px 12px;
}

input:focus,
select:focus,
button:focus-visible {
  outline: 3px solid rgba(0, 109, 119, 0.24);
  outline-offset: 2px;
}

.pickup-grid {
  max-width: 620px;
}

.slot-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.slot-chip {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--surface-soft);
}

.slot-chip strong {
  display: block;
  font-size: 14px;
}

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

.products-header {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: start;
}

.products-header .muted {
  max-width: 420px;
  margin: 2px 0 0;
  font-size: 13px;
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.product-card {
  display: grid;
  grid-template-rows: 152px auto;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.product-image {
  display: grid;
  place-items: center;
  min-height: 152px;
  background:
    linear-gradient(135deg, rgba(0, 109, 119, 0.12), rgba(214, 107, 47, 0.12)),
    #f5fafb;
  color: var(--brand-strong);
  text-align: center;
  font-weight: 900;
}

.product-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.product-body {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.product-title {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 8px;
}

.product-title h4 {
  margin: 0;
  font-size: 17px;
  line-height: 1.35;
}

.price {
  color: var(--accent);
  font-weight: 900;
  white-space: nowrap;
}

.product-description {
  min-height: 42px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.qty-control {
  display: grid;
  grid-template-columns: 40px 1fr 40px;
  align-items: center;
  min-height: 40px;
  border: 1px solid #c8d5da;
  border-radius: 6px;
  overflow: hidden;
}

.qty-control button {
  height: 40px;
  border: 0;
  background: var(--surface-soft);
  color: var(--brand-strong);
  cursor: pointer;
  font-size: 20px;
  font-weight: 900;
}

.qty-control output {
  text-align: center;
  font-weight: 900;
}

.check-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 16px;
  font-weight: 700;
}

.check-row input {
  width: 20px;
  min-height: 20px;
  margin-top: 2px;
}

.summary-panel {
  position: sticky;
  top: 16px;
  grid-column: 2;
  grid-row: 1 / span 4;
  padding: 22px;
}

.summary-items {
  display: grid;
  gap: 10px;
  min-height: 96px;
  color: var(--muted);
}

.summary-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--ink);
  font-size: 14px;
}

.summary-line {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin: 18px 0;
  border-top: 1px solid var(--line);
  padding-top: 16px;
  font-size: 20px;
}

.primary-button,
.secondary-button,
.danger-button {
  min-height: 44px;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  padding: 10px 16px;
  font-weight: 900;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.7;
}

.primary-button {
  width: 100%;
  background: var(--brand);
  color: #fff;
}

.login-submit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.button-spinner,
.inline-spinner {
  display: none;
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.login-submit.is-loading .button-spinner,
.login-status .inline-spinner {
  display: inline-block;
}

.login-status {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  border: 1px solid rgba(27, 94, 123, 0.24);
  border-radius: 6px;
  background: #eef7f7;
  color: var(--brand-strong);
  padding: 10px 12px;
  font-size: 14px;
  font-weight: 800;
}

.login-status[hidden] {
  display: none;
}

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

.secondary-button {
  background: var(--brand);
  color: #fff;
}

.danger-button {
  background: #f8e7e7;
  color: var(--danger);
}

.small-note {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.receipt-panel {
  margin-top: 18px;
  padding: 22px;
  border-color: rgba(0, 109, 119, 0.36);
  background: #f2fbfa;
}

.receipt-panel h3 {
  margin: 0 0 10px;
}

.receipt-code {
  display: inline-flex;
  margin: 6px 0 12px;
  border-radius: 6px;
  background: var(--brand-strong);
  color: #fff;
  padding: 8px 12px;
  font-size: 22px;
  font-weight: 900;
}

.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.admin-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
}

.stat-card {
  background: #fff;
  padding: 18px;
}

.stat-card span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.stat-card strong {
  display: block;
  margin-top: 4px;
  font-size: 24px;
}

.table-wrap {
  margin-top: 18px;
  overflow-x: auto;
}

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

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 12px 14px;
  text-align: left;
  vertical-align: top;
  font-size: 14px;
}

th {
  background: var(--brand-strong);
  color: #fff;
  white-space: nowrap;
}

.status-group-row td {
  border-bottom: 1px solid #c9d8dd;
  background: #edf5f6;
  color: var(--brand-strong);
  padding: 10px 14px;
}

.status-group-row span {
  margin-right: 8px;
  font-weight: 900;
}

.status-group-row strong {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  background: #fff;
  padding: 2px 9px;
  font-size: 12px;
}

.order-row.is-cancelled {
  opacity: 0.55;
}

td select {
  min-height: 36px;
  padding: 6px 8px;
}

.cancel-order-btn {
  padding: 6px 10px;
  min-height: 0;
  font-size: 13px;
  white-space: nowrap;
}

/* ── 自動更新トグル ── */
.auto-refresh-btn.is-on {
  background: var(--brand);
  color: #fff;
}

.last-updated-label {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  align-self: center;
}

/* ── 選択モードトグル ── */
.secondary-button.is-active-mode {
  background: #e67e22;
  color: #fff;
}

/* ── チェックボックス列 ── */
.col-checkbox {
  width: 40px;
  text-align: center;
  padding: 8px 6px;
}

.checkbox-cell {
  text-align: center;
  vertical-align: middle;
}

.order-checkbox {
  width: 18px;
  min-height: 18px;
  cursor: pointer;
  accent-color: var(--brand);
}

.order-row:has(.order-checkbox:checked) {
  background: rgba(27, 94, 123, 0.06);
}

/* ── 一括操作バー ── */
.bulk-action-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 24px;
  background: var(--brand-strong);
  color: #fff;
  box-shadow: 0 -4px 16px rgba(23, 32, 38, 0.2);
  z-index: 100;
}

.bulk-action-bar[hidden] {
  display: none;
}

.bulk-count {
  font-weight: 800;
  font-size: 14px;
  white-space: nowrap;
}

.bulk-status-label {
  color: #fff;
  font-size: 14px;
  font-weight: 800;
}

.bulk-status-label select {
  background: #fff;
  color: var(--ink);
  min-height: 36px;
  padding: 6px 10px;
  border-radius: 6px;
  border: 0;
}

.bulk-action-bar .primary-button {
  background: #fff;
  color: var(--brand-strong);
  flex-shrink: 0;
}

.bulk-action-bar .secondary-button {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.4);
  flex-shrink: 0;
}

/* ── Feature 1: 商品集計 ── */
.product-summary-section {
  margin-top: 12px;
}

.product-summary-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.product-summary-label {
  font-size: 12px;
  font-weight: 900;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  margin-right: 4px;
}

.product-chip {
  display: flex;
  align-items: baseline;
  gap: 6px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 14px;
}

.product-chip-name {
  font-size: 13px;
  color: var(--muted);
}

.product-chip-qty {
  font-size: 22px;
  color: var(--brand-strong);
  font-weight: 900;
}

/* ── 商品写真管理 ── */
.product-image-manager {
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 18px;
}

.product-image-header {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 16px;
  margin-bottom: 14px;
}

.product-image-header h3 {
  margin: 4px 0 0;
  font-size: 20px;
}

.product-image-note {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.product-image-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.product-image-card {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr);
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfd;
  padding: 12px;
}

.product-image-preview {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border-radius: 6px;
  background: linear-gradient(135deg, #e5f2f2, #f4f0eb);
  overflow: hidden;
}

.product-image-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.product-image-fields {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.product-image-fields strong {
  font-size: 14px;
}

.product-image-fields label {
  font-size: 12px;
}

.product-image-fields input {
  min-height: 38px;
  font-size: 13px;
}

/* ── Feature 5: 注文詳細モーダル ── */
.order-detail-dialog {
  max-width: min(640px, calc(100vw - 32px));
  width: 100%;
}

.detail-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.detail-dialog-header h3 {
  margin: 0;
  font-size: 20px;
}

.dialog-close-btn {
  border: 0;
  background: var(--surface-soft);
  color: var(--muted);
  border-radius: 6px;
  width: 36px;
  height: 36px;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.dialog-close-btn:hover {
  background: var(--line);
}

.detail-list {
  gap: 12px 16px;
}

.detail-actions {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
}

/* 行クリック可能なカーソル */
.order-row {
  cursor: pointer;
}

.order-row:hover td {
  background: rgba(27, 94, 123, 0.03);
}

/* ── エラー表示 ── */
.form-error {
  padding: 10px 14px;
  border-radius: 6px;
  background: #fde8e8;
  color: var(--danger);
  font-size: 14px;
  font-weight: 700;
  border: 1px solid rgba(166, 61, 64, 0.3);
  margin-bottom: 12px;
}

.field-error {
  margin-top: 6px;
  color: var(--danger);
  font-size: 13px;
  font-weight: 700;
}

input[aria-invalid="true"],
select[aria-invalid="true"] {
  border-color: var(--danger);
  outline-color: rgba(166, 61, 64, 0.24);
}

/* ── 確認モーダル ── */
dialog {
  border: none;
  border-radius: 12px;
  padding: 0;
  box-shadow: var(--shadow);
  max-width: min(480px, calc(100vw - 32px));
  width: 100%;
}

.submission-dialog {
  max-width: min(560px, calc(100vw - 32px));
}

dialog::backdrop {
  background: rgba(23, 32, 38, 0.5);
}

.dialog-inner {
  padding: 28px;
}

.dialog-inner h3 {
  margin: 0 0 18px;
  font-size: 20px;
}

.dialog-body {
  margin-bottom: 24px;
}

.confirm-list {
  display: grid;
  grid-template-columns: 5em 1fr;
  gap: 10px 16px;
  margin: 0;
  font-size: 14px;
}

.confirm-list dt {
  color: var(--muted);
  font-weight: 800;
}

.confirm-list dd {
  margin: 0;
}

.dialog-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.dialog-actions .secondary-button {
  background: var(--surface-soft);
  color: var(--ink);
  border: 1px solid var(--line);
}

.submission-status {
  display: grid;
  gap: 16px;
}

.submission-status h3 {
  margin: 0;
  font-size: 24px;
  line-height: 1.25;
}

.submission-kicker {
  margin: 0;
  color: var(--brand-strong);
  font-size: 13px;
  font-weight: 900;
}

.submission-message {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.submission-spinner {
  width: 44px;
  height: 44px;
  border: 4px solid rgba(0, 109, 119, 0.18);
  border-top-color: var(--brand-strong);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

.submission-order-number {
  margin: 0;
}

.submission-close-button {
  width: 100%;
}

.submission-status.is-error .receipt-header {
  margin-bottom: 0;
}

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

/* ── 商品プレースホルダー ── */
.product-placeholder {
  font-size: 64px;
  line-height: 1;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.12));
}

/* ── 注文完了パネル強化 ── */
.receipt-header {
  margin-bottom: 16px;
}

.receipt-header h3 {
  margin: 0 0 4px;
  font-size: 22px;
}

.receipt-subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.receipt-order-number {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 0 0 20px;
}

.receipt-label {
  font-size: 13px;
  font-weight: 800;
  color: var(--muted);
}

.receipt-detail {
  padding: 14px 0;
  border-top: 1px solid rgba(27, 94, 123, 0.2);
  border-bottom: 1px solid rgba(27, 94, 123, 0.2);
  margin-bottom: 16px;
}

.receipt-detail p {
  margin: 0 0 8px;
  font-size: 14px;
}

.receipt-detail p:last-child {
  margin-bottom: 0;
}

.receipt-notice {
  background: rgba(27, 94, 123, 0.06);
  border-radius: 6px;
  padding: 12px 14px;
}

.receipt-screenshot-note {
  margin: 0 0 8px;
  font-weight: 700;
  font-size: 14px;
  color: var(--brand-strong);
}

.receipt-phone-note {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.7;
}

/* ── スロットチップ視認性 ── */
.slot-chip.is-low {
  border-color: var(--accent);
  background: rgba(192, 57, 43, 0.06);
}

.slot-chip.is-low span {
  color: var(--accent);
  font-weight: 700;
}

.slot-chip.is-full {
  border-color: rgba(166, 61, 64, 0.4);
  background: #f8e7e7;
  opacity: 0.75;
}

.slot-chip.is-full span {
  color: var(--danger);
}

.slot-badge {
  display: inline-block;
  margin-top: 4px;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}

/* ── 時間帯別集計 ── */
.stat-slot-section {
  grid-column: 1 / -1;
  padding: 16px 18px;
  background: var(--surface-soft);
  border-top: 1px solid var(--line);
}

.stat-slot-heading {
  margin: 0 0 12px;
  font-size: 14px;
  color: var(--muted);
  font-weight: 800;
}

.stat-slot-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.stat-slot-card {
  padding: 10px 12px;
  border-radius: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 13px;
}

.stat-slot-card span {
  display: block;
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
  margin-bottom: 2px;
}

.stat-slot-card strong {
  display: block;
  font-size: 18px;
  margin-bottom: 2px;
}

.stat-slot-card small {
  font-size: 11px;
  color: var(--muted);
}

.stat-slot-card.is-low strong,
.stat-slot-card.is-low small {
  color: var(--accent);
}

.stat-slot-card.is-full {
  background: #f8e7e7;
  border-color: rgba(166, 61, 64, 0.3);
}

.stat-slot-card.is-full strong,
.stat-slot-card.is-full small {
  color: var(--danger);
}

/* ── 検索ボックス ── */
.admin-search {
  min-height: 38px;
  width: 220px;
  padding: 6px 12px;
  border: 1px solid #c8d5da;
  border-radius: 6px;
  background: #fff;
  font-size: 14px;
}

.admin-search:focus {
  outline: 3px solid rgba(0, 109, 119, 0.24);
  outline-offset: 2px;
}

/* ── 日付フィルター ── */
.filter-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 800;
  color: var(--ink);
}

.filter-label select {
  min-height: 38px;
  width: auto;
  padding: 6px 10px;
}

/* ── 注文番号・受取・お客様セル ── */
.order-number-text {
  display: block;
  font-size: 16px;
  letter-spacing: 0.02em;
}

.order-meta {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

.pickup-date-text {
  display: block;
  font-weight: 700;
}

.pickup-slot-text {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.customer-name {
  display: block;
  font-size: 15px;
}

.customer-kana {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.contact-link {
  display: block;
  font-size: 13px;
  margin-top: 3px;
  color: var(--brand);
  text-decoration: none;
  word-break: break-all;
}

.contact-link:hover {
  text-decoration: underline;
}

.total-amount {
  font-size: 15px;
  white-space: nowrap;
}

.memo-text {
  font-size: 13px;
  color: var(--muted);
}

/* ── ステータス色分け ── */
.status-select-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-select-wrap::before {
  content: "";
  flex-shrink: 0;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--muted);
}

.status-select-wrap.is-warning::before  { background: #e67e22; }
.status-select-wrap.is-accepted::before { background: var(--brand); }
.status-select-wrap.is-preparing::before { background: #e67e22; }
.status-select-wrap.is-ready::before    { background: #27ae60; }
.status-select-wrap.is-delivered::before { background: #95a5a6; }

/* ステータスグループ行のラベル色 */
.status-group-label { font-weight: 900; }
.status-group-label.is-warning  { color: #c0392b; }
.status-group-label.is-accepted { color: var(--brand-strong); }
.status-group-label.is-preparing { color: #d35400; }
.status-group-label.is-ready    { color: #1e8449; }
.status-group-label.is-delivered { color: var(--muted); }
.status-group-label.is-cancelled { color: var(--muted); }

.order-status-label {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  border: 1px solid #d2dce0;
  border-radius: 6px;
  background: #f7fafb;
  padding: 6px 10px;
  font-size: 13px;
  font-weight: 800;
}

.order-status-label.is-cancelled {
  color: var(--danger);
  background: #fff4f4;
}

/* ── 印刷用（管理画面の予約一覧をキレイに印刷するための調整） ── */
@media print {
  .app-header,
  .toolbar,
  .admin-stats .stat-slot-section,
  td select,
  .cancel-order-btn,
  #loginView {
    display: none !important;
  }

  body {
    background: #fff;
    font-size: 11pt;
    color: #000;
  }

  .app-shell {
    width: 100%;
    margin: 0;
  }

  .section-heading {
    margin: 0 0 12pt;
  }

  .section-heading h2 {
    font-size: 16pt;
  }

  .table-wrap {
    border: none;
    box-shadow: none;
    overflow: visible;
    margin-top: 0;
  }

  table {
    min-width: 0;
    width: 100%;
    font-size: 10pt;
  }

  th {
    background: #333 !important;
    color: #fff !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  th, td {
    padding: 6pt 8pt;
    border-bottom: 0.5pt solid #ccc;
  }

  tr {
    page-break-inside: avoid;
  }
}

@media (max-width: 980px) {
  .order-layout {
    grid-template-columns: 1fr;
  }

  .summary-panel {
    position: static;
    grid-column: 1;
    grid-row: auto;
  }

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

  .product-image-grid {
    grid-template-columns: 1fr;
  }

  .slot-list,
  .admin-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stat-slot-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .app-header,
  .section-heading,
  .products-header {
    align-items: stretch;
    flex-direction: column;
  }

  .app-shell {
    width: min(100% - 20px, 1220px);
    margin-top: 14px;
  }

  .tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }

  .tab-button {
    min-width: 0;
  }

  .field-grid,
  .product-grid,
  .product-image-grid,
  .slot-list,
  .admin-stats {
    grid-template-columns: 1fr;
  }

  .product-image-header {
    align-items: stretch;
    flex-direction: column;
  }

  .product-image-card {
    grid-template-columns: 88px minmax(0, 1fr);
  }

  .form-section,
  .summary-panel {
    padding: 16px;
  }
}

@media (max-width: 760px) {
  .table-wrap {
    border: 0;
    background: transparent;
    box-shadow: none;
    overflow: visible;
  }

  table,
  tbody,
  tr,
  td {
    display: block;
  }

  table {
    min-width: 0;
  }

  thead {
    display: none;
  }

  .status-group-row {
    margin: 18px 0 8px;
  }

  .status-group-row:first-child {
    margin-top: 0;
  }

  .status-group-row td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border: 1px solid #c9d8dd;
    border-radius: 8px;
  }

  .order-row {
    max-width: 540px;
    margin-bottom: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    box-shadow: var(--shadow);
    overflow: hidden;
  }

  .order-row td {
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr);
    gap: 12px;
    border-bottom: 1px solid var(--line);
    padding: 10px 12px;
    overflow-wrap: anywhere;
  }

  .order-row td:last-child {
    border-bottom: 0;
  }

  .order-row td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
  }

  .order-row td[data-label="注文番号"] {
    grid-template-columns: 1fr;
    background: #f7fafb;
  }

  .order-row td[data-label="注文番号"]::before {
    content: none;
  }

  .order-row td[data-label="注文番号"] strong {
    font-size: 18px;
  }

  .order-row td select,
  .order-row td button {
    width: 100%;
  }

  /* モバイルでの検索ボックス */
  .admin-search {
    width: 100%;
    order: -1;
  }

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

  .filter-label {
    justify-content: space-between;
  }

  .filter-label select {
    width: auto;
    flex: 1;
    margin-left: 8px;
  }

  /* ステータスドットをモバイルカードでも表示 */
  .status-select-wrap {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  /* モバイルではチェックボックス列を非表示 */
  .col-checkbox,
  .checkbox-cell {
    display: none !important;
  }

  /* 一括バーをモバイル対応 */
  .bulk-action-bar {
    padding: 10px 16px;
    gap: 8px;
  }

  .bulk-status-label select {
    flex: 1;
  }

  /* 詳細モーダルをモバイル対応 */
  .order-detail-dialog {
    max-width: 100vw;
    max-height: 90vh;
    border-radius: 12px 12px 0 0;
    margin: auto auto 0;
    overflow-y: auto;
  }
}

/* ── 受取枠残数ビュー ── */
.slot-status-outer {
  margin-bottom: 16px;
}

.slot-status-outer .stat-slot-section {
  grid-column: unset;
  border-top: none;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.slot-status-outer .date-slots-group + .date-slots-group {
  margin-top: 12px;
}

/* ── 受取日別サマリー ── */
.date-summary-section {
  margin-bottom: 16px;
}

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

.date-summary-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 16px;
}

.date-summary-heading {
  font-size: 14px;
  font-weight: 800;
  margin: 0 0 6px;
  color: var(--text);
}

.date-summary-counts {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
}

.date-summary-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
}

.date-summary-badge {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  background: var(--surface-soft);
  color: var(--muted);
}

.date-summary-badge.is-accepting  { background: #e8f5e9; color: #2e7d32; }
.date-summary-badge.is-preparing  { background: #e3f2fd; color: #1565c0; }
.date-summary-badge.is-ready      { background: #fff3e0; color: #e65100; }
.date-summary-badge.is-delivered  { background: #f3e5f5; color: #6a1b9a; }
.date-summary-badge.is-warning    { background: #fff8e1; color: #f57f17; }
.date-summary-badge.is-cancelled  { background: #f5f5f5; color: #9e9e9e; }

.date-summary-products {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.6;
}

/* ── スタッフメモ編集 ── */
.memo-edit-input {
  width: 100%;
  min-height: 60px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  box-sizing: border-box;
  margin-bottom: 6px;
}

.memo-save-btn {
  font-size: 13px;
  padding: 4px 14px;
}
