:root {
  color-scheme: light;
  --bg: #f5f6f2;
  --surface: #ffffff;
  --surface-soft: #eef1ea;
  --surface-strong: #e4e8df;
  --ink: #252b2d;
  --muted: #737d7a;
  --line: #dfe4dc;
  --accent: #24483f;
  --accent-soft: #dbe8df;
  --danger: #9b3a34;
  --danger-soft: #f4e5e2;
  --warning: #9a6a00;
  --shadow: 0 8px 22px rgba(37, 43, 45, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  scroll-padding-bottom: 170px;
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, #fbfcf9 0%, var(--bg) 100%);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(100%, 480px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 22px 14px 120px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  padding: 8px 2px 20px;
}

.eyebrow,
.topbar small,
.metric-card span,
.section-heading span,
.input-group span,
.segmented-pair span,
.stock-entry span,
.stock-entry small,
.product-button span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 650;
}

.eyebrow {
  margin: 0 0 4px;
}

.date-line {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 650;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 3.4rem;
  font-weight: 850;
  line-height: 0.95;
  letter-spacing: 0;
}

h2 {
  font-size: 1.05rem;
  font-weight: 850;
}

.topbar__side {
  display: grid;
  gap: 4px;
  padding-bottom: 4px;
  text-align: right;
}

.topbar__side span {
  font-size: 1rem;
  font-weight: 850;
}

#syncStatus.is-live {
  color: var(--accent);
}

#syncStatus.is-queued {
  color: var(--warning);
}

.tabbar {
  position: sticky;
  top: 0;
  z-index: 4;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
  padding: 6px;
  margin: 0 0 16px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: 999px;
  backdrop-filter: blur(18px);
}

.tab-button {
  min-height: 40px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 850;
}

.tab-button.is-active {
  background: var(--ink);
  color: var(--surface);
}

.tab-panel {
  display: none;
}

.tab-panel.is-active {
  display: grid;
  gap: 14px;
}

.session-card,
.entry-card,
.section-block,
.metric-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.session-card,
.entry-card,
.section-block {
  display: grid;
  gap: 14px;
  padding: 14px;
}

.input-group {
  display: grid;
  gap: 7px;
}

.input-group input,
.filter-row select {
  width: 100%;
  min-width: 0;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-soft);
  color: var(--ink);
  font-size: 1rem;
  font-weight: 800;
  outline: none;
  padding: 0 12px;
}

.segmented-pair {
  display: grid;
  gap: 12px;
}

.segmented-pair > div {
  display: grid;
  gap: 7px;
}

.segmented,
.product-grid,
.size-grid,
.qty-grid,
.filter-row {
  display: grid;
  gap: 8px;
}

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

.action-segmented {
  grid-template-columns: 1fr 1fr;
}

.segment-button,
.size-button,
.qty-button,
.product-button,
.color-button {
  min-width: 0;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--ink);
  font-weight: 850;
}

.segment-button {
  min-height: 46px;
  border-radius: 14px;
}

.segment-button.is-active,
.size-button.is-active,
.qty-button.is-active,
.product-button.is-active,
.color-button.is-active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.action-segmented .segment-button:last-child.is-active {
  border-color: var(--danger);
  background: var(--danger);
}

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

.product-button {
  display: grid;
  gap: 4px;
  min-height: 72px;
  border-radius: 16px;
  padding: 10px 8px;
  text-align: left;
}

.product-button span {
  color: inherit;
  opacity: 0.72;
  line-height: 1.2;
}

.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.section-heading.compact {
  margin-bottom: 8px;
}

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

.color-button {
  display: grid;
  grid-template-columns: 28px 1fr;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  border-radius: 14px;
  padding: 8px 9px;
  text-align: left;
}

.swatch {
  width: 28px;
  height: 28px;
  border: 1px solid rgba(0, 0, 0, 0.16);
  border-radius: 50%;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.4);
}

.entry-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.size-grid,
.qty-grid {
  grid-template-columns: repeat(3, 1fr);
}

.size-button,
.qty-button {
  min-height: 52px;
  border-radius: 15px;
  font-size: 1.05rem;
}

.sticky-action {
  position: sticky;
  bottom: 12px;
  z-index: 5;
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(223, 228, 220, 0.9);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 16px 32px rgba(37, 43, 45, 0.14);
  backdrop-filter: blur(18px);
}

.sticky-action p {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 750;
  line-height: 1.35;
}

.sticky-action__buttons {
  display: grid;
  grid-template-columns: 0.72fr 1fr;
  gap: 8px;
}

.add-button {
  min-height: 56px;
  border: 0;
  border-radius: 16px;
  background: var(--ink);
  color: #fff;
  font-size: 1.05rem;
  font-weight: 900;
}

.add-button.is-remove {
  background: var(--danger);
}

.undo-button {
  min-height: 56px;
  border: 1px solid #e0c5c1;
  border-radius: 16px;
  background: #fff8f7;
  color: var(--danger);
  font-weight: 900;
}

.undo-button:disabled {
  border-color: var(--line);
  background: var(--surface-soft);
  color: #a7afaa;
  cursor: default;
}

.entry-list,
.summary-list {
  display: grid;
  gap: 8px;
}

.stock-entry,
.summary-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border-radius: 14px;
  background: var(--surface-soft);
}

.stock-entry > div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.stock-entry strong,
.stock-entry span,
.stock-entry small {
  overflow-wrap: anywhere;
}

.stock-entry.is-reversal {
  background: var(--danger-soft);
}

.reverse-button {
  min-height: 36px;
  border: 1px solid #e0c5c1;
  border-radius: 999px;
  background: #fff8f7;
  color: var(--danger);
  font-size: 0.8rem;
  font-weight: 850;
  padding: 0 10px;
}

.empty-state {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 650;
  line-height: 1.4;
}

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

.totals-block {
  margin-bottom: 14px;
}

.table-scroll {
  overflow-x: auto;
  border-radius: 14px;
  border: 1px solid var(--line);
}

table {
  width: 100%;
  min-width: 430px;
  border-collapse: collapse;
  background: var(--surface);
  font-size: 0.86rem;
}

th,
td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  text-align: center;
  white-space: nowrap;
}

th:first-child,
td:first-child {
  text-align: left;
}

thead th,
tfoot th,
tfoot td,
.total-cell {
  background: var(--surface-soft);
  font-weight: 900;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.metric-card {
  display: grid;
  gap: 8px;
  min-height: 86px;
  padding: 14px;
}

.metric-card strong {
  font-size: 1.6rem;
  font-weight: 900;
}

.summary-row strong {
  font-size: 1.2rem;
  font-weight: 900;
}

@media (min-width: 420px) {
  .color-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
