:root {
  color-scheme: light;
  font-family:
    "Hiragino Kaku Gothic ProN", "Yu Gothic", "Meiryo", sans-serif;
  background: #f4f1e8;
  color: #1f2937;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(244, 241, 232, 0.96)),
    #f4f1e8;
}

button {
  font: inherit;
}

.page {
  max-width: 1180px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 16px;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 12px;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
  min-height: 0;
}

.page-title {
  min-width: 0;
}

.eyebrow {
  margin: 0 0 4px;
  font-size: 16px;
  font-weight: 700;
  color: #b45309;
}

h1 {
  margin: 0;
  font-size: clamp(24px, 4vw, 34px);
  line-height: 1.1;
}

.reload-button {
  min-width: 100px;
  min-height: 52px;
  border: none;
  border-radius: 14px;
  background: #1d4ed8;
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  box-shadow: 0 10px 24px rgba(29, 78, 216, 0.2);
  padding: 0 18px;
  white-space: nowrap;
}

.reload-button:disabled {
  opacity: 0.6;
}

.status-panel {
  padding: 14px 18px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 24px;
  align-items: center;
}

.status-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: 0;
  font-size: 16px;
}

.status-row strong {
  font-size: clamp(24px, 3.4vw, 32px);
}

.status-message {
  grid-column: 1 / -1;
  margin: 4px 0 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: #dbeafe;
  color: #1e3a8a;
  font-size: 16px;
  font-weight: 700;
}

.status-message[data-type="error"] {
  background: #fee2e2;
  color: #b91c1c;
}

.items-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  min-height: 0;
  grid-auto-rows: 1fr;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  align-content: start;
}

.summary-card {
  display: grid;
  gap: 10px;
  padding: 18px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.1);
}

.summary-item-name {
  margin: 0;
  font-size: 24px;
  line-height: 1.1;
}

.summary-item-count {
  margin: 0;
  font-size: clamp(38px, 6vh, 52px);
  font-weight: 800;
  text-align: center;
  line-height: 1;
}

.summary-item-sales {
  margin: 0;
  text-align: center;
  font-size: 20px;
  font-weight: 700;
  color: #b45309;
}

/* 集計ページは閲覧用途のため縦スクロールを許可（入力ページの overflow:hidden を打ち消す） */
.summary-body {
  overflow-y: auto;
}

.summary-page {
  display: block;
  min-height: auto;
}

.status-row-sales strong {
  color: #b45309;
}

.panel {
  margin-top: 12px;
  padding: 16px 18px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

.panel-title {
  margin: 0 0 12px;
  font-size: 18px;
  font-weight: 700;
}

.panel-empty,
.panel-note {
  margin: 8px 0 0;
  font-size: 13px;
  color: #6b7280;
}

.hourly-chart {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 180px;
  padding: 4px 2px 0;
  overflow-x: auto;
}

.bar-col {
  display: flex;
  flex: 1 0 40px;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  height: 100%;
}

.bar {
  width: 100%;
  max-width: 44px;
  min-height: 3px;
  border-radius: 6px 6px 0 0;
  background: #1d4ed8;
}

.bar-value {
  font-size: 13px;
  font-weight: 700;
}

.bar-label {
  font-size: 12px;
  color: #6b7280;
  white-space: nowrap;
}

.cash-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.cash-row label {
  font-size: 16px;
  font-weight: 700;
}

.cash-row input {
  flex: 1;
  min-width: 0;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid rgba(15, 23, 42, 0.2);
  border-radius: 12px;
  background: #fff;
  font-size: 20px;
  text-align: right;
}

.cash-result {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 16px;
  margin: 14px 0 0;
  font-size: 15px;
  color: #4b5563;
}

.cash-result strong {
  font-size: 24px;
  color: #1f2937;
}

.cash-delta[data-sign="plus"] {
  color: #15803d;
}

.cash-delta[data-sign="minus"] {
  color: #b91c1c;
}

.item-card {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 8px;
  min-height: 0;
  padding: 14px 16px 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.1);
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition:
    transform 0.08s ease,
    background 0.15s ease,
    box-shadow 0.15s ease;
}

.item-card:active {
  transform: scale(0.98);
}

.item-card.is-pending {
  opacity: 0.5;
  pointer-events: none;
}

.item-card.flash-plus {
  background: #dcfce7;
  box-shadow: 0 0 0 3px #16a34a;
}

.item-card.flash-minus {
  background: #fee2e2;
  box-shadow: 0 0 0 3px #dc2626;
}

.item-name {
  margin: 0;
  min-height: 0;
  padding-right: 56px;
  font-size: 24px;
  line-height: 1.1;
}

.item-count {
  margin: 0;
  align-self: center;
  font-size: clamp(34px, 6vh, 44px);
  font-weight: 800;
  text-align: center;
  line-height: 1;
}

.plus-hint {
  margin: 0;
  justify-self: center;
  display: inline-flex;
  align-items: center;
  font-size: 18px;
  font-weight: 800;
  color: #16a34a;
}

.plus-hint::before {
  content: "＋";
  margin-right: 2px;
}

.minus-button {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 1px solid rgba(15, 23, 42, 0.15);
  background: #f3f4f6;
  color: #6b7280;
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.minus-button:active {
  background: #fee2e2;
  color: #b91c1c;
}

.minus-button:disabled {
  opacity: 0.35;
}

@media (max-width: 820px) {
  .page {
    min-height: auto;
  }

  .page-header,
  .status-panel {
    grid-template-columns: 1fr;
  }

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

  .reload-button {
    width: 100%;
  }

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

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

@media (max-height: 800px) {
  .page {
    padding: 12px;
    gap: 10px;
  }

  .eyebrow {
    font-size: 14px;
  }

  .status-panel {
    padding: 12px 14px;
  }

  .status-row {
    font-size: 15px;
  }

  .item-card {
    gap: 8px;
    padding: 12px 14px 14px;
  }

  .summary-card {
    gap: 8px;
    padding: 16px;
  }

  .item-count {
    font-size: clamp(30px, 5.2vh, 40px);
  }

  .summary-item-count {
    font-size: clamp(34px, 5.2vh, 46px);
  }

  .minus-button {
    width: 52px;
    height: 52px;
    font-size: 26px;
  }
}

@media (orientation: landscape) and (max-height: 820px) {
  body {
    overflow: hidden;
  }

  .page {
    max-width: 1024px;
    min-height: 100svh;
    padding: 8px 10px;
    gap: 6px;
  }

  .page-header {
    align-items: center;
  }

  .eyebrow {
    margin-bottom: 1px;
    font-size: 12px;
  }

  h1 {
    font-size: clamp(20px, 3.4vw, 28px);
  }

  .reload-button {
    min-width: 88px;
    min-height: 42px;
    font-size: 15px;
    border-radius: 12px;
    padding: 0 14px;
  }

  .status-panel {
    padding: 8px 10px;
    gap: 2px 14px;
  }

  .status-row {
    font-size: 13px;
  }

  .status-row strong {
    font-size: clamp(18px, 2.7vw, 24px);
  }

  .status-message {
    margin-top: 0;
    padding: 6px 8px;
    font-size: 13px;
  }

  .items-grid {
    gap: 6px;
  }

  .summary-grid {
    gap: 6px;
  }

  .item-card {
    gap: 4px;
    padding: 8px 10px 10px;
    border-radius: 14px;
  }

  .summary-card {
    gap: 6px;
    padding: 12px;
    border-radius: 14px;
  }

  .item-name {
    padding-right: 42px;
    font-size: 24px;
  }

  .summary-item-name {
    font-size: 22px;
  }

  .item-count {
    font-size: clamp(24px, 4vh, 32px);
  }

  .summary-item-count {
    font-size: clamp(30px, 4.4vh, 40px);
  }

  .minus-button {
    top: 8px;
    right: 8px;
    width: 40px;
    height: 40px;
    font-size: 20px;
  }

  .plus-hint {
    font-size: 15px;
  }
}
