:root {
  color-scheme: light;
  --bg: #f7f3ef;
  --surface: #fffdfb;
  --ink: #24211f;
  --muted: #756d66;
  --line: #e5ddd5;
  --accent: #b74258;
  --accent-strong: #973448;
  --ok: #25745a;
  --warn: #a36614;
  --danger: #b4292f;
  --blue: #315f8f;
  --shadow: 0 14px 36px rgba(50, 38, 30, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0) 240px),
    var(--bg);
  color: var(--ink);
  font-family: "Yu Gothic", "Hiragino Kaku Gothic ProN", Meiryo, system-ui, sans-serif;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(100%, 980px);
  margin: 0 auto;
  padding: 18px 14px 32px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 2px 16px;
}

.store-name {
  margin: 0 0 4px;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 700;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 25px;
  line-height: 1.25;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
  cursor: pointer;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.metric {
  min-width: 0;
  padding: 12px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.metric-label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 2px;
}

.metric strong {
  font-size: 25px;
  line-height: 1;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 251, 0.72);
  position: sticky;
  top: 0;
  z-index: 2;
  backdrop-filter: blur(10px);
}

.tab {
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  cursor: pointer;
}

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

.toolbar {
  display: grid;
  grid-template-columns: 1fr 150px;
  gap: 8px;
  margin: 12px 0;
}

.search-field,
.select-field {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.search-field span,
.select-field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 8px 10px;
}

.view {
  display: none;
}

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

.section-heading {
  display: grid;
  gap: 4px;
  margin: 4px 0 12px;
}

.section-heading h2 {
  font-size: 18px;
}

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

.item-list,
.stocktake-list,
.history-list {
  display: grid;
  gap: 10px;
}

.inventory-card,
.stocktake-card,
.history-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 8px 24px rgba(50, 38, 30, 0.08);
}

.inventory-card {
  padding: 12px;
}

.item-main {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: start;
}

.item-title {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.item-title strong {
  font-size: 16px;
  line-height: 1.35;
}

.item-meta {
  color: var(--muted);
  font-size: 12px;
}

.status {
  align-self: start;
  border-radius: 999px;
  padding: 5px 9px;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.status.ok {
  background: var(--ok);
}

.status.low {
  background: var(--warn);
}

.status.order {
  background: var(--danger);
}

.stock-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 12px 0;
}

.stock-box {
  min-width: 0;
  padding: 9px;
  border-radius: 8px;
  background: #f4eee8;
}

.stock-box span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.stock-box strong {
  display: block;
  margin-top: 2px;
  font-size: 18px;
}

.action-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.action-row button,
.order-button,
.done-button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-weight: 800;
  cursor: pointer;
}

.action-row .use {
  color: var(--danger);
}

.action-row .add {
  color: var(--ok);
}

.order-button {
  color: var(--blue);
}

.order-button.is-marked {
  background: #f8e8ec;
  border-color: #e0a9b6;
  color: var(--accent-strong);
}

.stocktake-card {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.stocktake-form {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 8px;
  align-items: end;
}

.diff {
  min-width: 72px;
  padding: 10px 8px;
  border-radius: 8px;
  background: #edf3f7;
  color: var(--blue);
  font-weight: 900;
  text-align: center;
}

.done-button.is-done {
  background: var(--ok);
  color: #fff;
}

.history-card {
  display: grid;
  gap: 4px;
  padding: 12px;
}

.history-card time {
  color: var(--muted);
  font-size: 12px;
}

.empty-state {
  display: grid;
  gap: 4px;
  padding: 28px 14px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.empty-state strong {
  color: var(--ink);
}

@media (min-width: 760px) {
  .app-shell {
    padding-top: 28px;
  }

  h1 {
    font-size: 32px;
  }

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

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

@media (max-width: 420px) {
  .app-shell {
    padding-inline: 10px;
  }

  .toolbar {
    grid-template-columns: 1fr;
  }

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

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

  .action-row {
    grid-template-columns: repeat(2, 1fr);
  }
}
