:root {
  --bg: #fbfaf7;
  --panel: #ffffff;
  --ink: #192522;
  --muted: #66736f;
  --line: #d9e0dc;
  --accent: #25635a;
  --accent-strong: #174940;
  --warning: #fff1b8;
  --danger: #b42318;
  --danger-bg: #ffe5e1;
  --shadow: 0 8px 24px rgba(25, 37, 34, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

body {
  margin: 0;
  min-height: 100%;
  padding-bottom: 82px;
  background:
    linear-gradient(180deg, rgba(37, 99, 90, 0.08), transparent 220px),
    var(--bg);
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
.primary,
.secondary,
.wide-link {
  min-height: 48px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 12px 16px;
  font-weight: 700;
}

button {
  cursor: pointer;
}

input,
select,
textarea {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  background: #fff;
  color: var(--ink);
}

textarea {
  resize: vertical;
  line-height: 1.45;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 14px;
}

label > input,
label > select,
label > textarea {
  color: var(--ink);
  font-size: 16px;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  font-size: 30px;
  line-height: 1.08;
}

h2 {
  margin-bottom: 12px;
  font-size: 20px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 58px;
  padding: max(10px, env(safe-area-inset-top)) 16px 10px;
  border-bottom: 1px solid rgba(217, 224, 220, 0.8);
  background: rgba(251, 250, 247, 0.94);
  backdrop-filter: blur(12px);
}

.brand {
  font-size: 18px;
  font-weight: 800;
}

.icon-button {
  min-height: 38px;
  padding: 8px 10px;
  background: transparent;
  border-color: var(--line);
}

.page {
  width: min(760px, 100%);
  margin: 0 auto;
  padding: 18px 16px 28px;
}

.bottom-nav {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding: 8px 10px max(8px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
}

.bottom-nav a {
  min-height: 48px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: var(--accent-strong);
  font-size: 14px;
  font-weight: 800;
}

.bottom-nav a:active {
  background: #e6f0ec;
}

.hero-app {
  padding: 12px 0 22px;
}

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

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

.quick-stats div,
.panel,
.order-card,
.product-row,
.list-card,
.login-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.quick-stats div {
  padding: 14px;
}

.quick-stats strong {
  display: block;
  font-size: 28px;
}

.quick-stats span {
  color: var(--muted);
}

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

.tile {
  min-height: 108px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  font-size: 19px;
  font-weight: 800;
  box-shadow: var(--shadow);
}

.tile span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.tile.action {
  background: var(--accent);
  color: #fff;
}

.tile.action span {
  color: rgba(255, 255, 255, 0.76);
}

.section-head {
  margin-bottom: 16px;
}

.section-head p {
  margin-bottom: 0;
  color: var(--muted);
}

.section-head.split {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.stack {
  display: grid;
  gap: 14px;
}

.stack.compact {
  gap: 12px;
}

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

.primary {
  background: var(--accent);
  color: #fff;
}

.primary:active {
  background: var(--accent-strong);
}

.secondary,
.wide-link {
  display: inline-grid;
  place-items: center;
  border-color: var(--line);
  background: #fff;
  color: var(--accent-strong);
}

.secondary.full,
.wide-link {
  width: 100%;
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.filters {
  display: grid;
  grid-template-columns: 1fr 130px auto;
  gap: 8px;
  margin-bottom: 14px;
}

.order-card {
  margin-bottom: 14px;
  padding: 14px;
}

.raw-text {
  margin-bottom: 14px;
  padding: 12px;
  border-radius: 8px;
  background: #eef1ef;
  white-space: pre-wrap;
  line-height: 1.45;
}

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

.panel {
  margin-bottom: 14px;
  padding: 14px;
}

.item-row {
  display: grid;
  grid-template-columns: 1fr 86px 78px;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.item-row.needs-review {
  background: var(--warning);
  border-color: #d7ad2c;
}

.fragment,
.warning {
  grid-column: 1 / -1;
  margin: 0;
  font-size: 13px;
}

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

.warning,
.error {
  color: var(--danger);
  font-weight: 700;
}

.empty {
  padding: 20px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.list-card {
  display: grid;
  gap: 4px;
  margin-bottom: 10px;
  padding: 14px;
}

.list-card span,
.list-card small,
.product-row span {
  color: var(--muted);
}

.summary-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.summary-row small {
  grid-column: 1 / -1;
  color: var(--muted);
}

.receipt-row {
  display: grid;
  grid-template-columns: 1fr 70px;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.receipt-row label,
.receipt-row b {
  grid-column: 1 / -1;
}

.total-line {
  padding: 14px;
  border-radius: 8px;
  background: #e6f0ec;
  font-size: 22px;
  font-weight: 800;
  text-align: right;
}

.product-row {
  display: grid;
  gap: 10px;
  margin-bottom: 10px;
  padding: 14px;
}

.quick-edit {
  display: grid;
  grid-template-columns: 1fr 1fr 58px;
  gap: 8px;
  align-items: end;
}

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

.status-row button {
  border-color: var(--line);
  background: #fff;
}

.check {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
}

.check input {
  width: 22px;
  min-height: 22px;
}

.login-body {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 20px;
}

.login-panel {
  width: min(420px, 100%);
  padding: 22px;
}

@media (max-width: 520px) {
  .tile-grid,
  .form-grid,
  .filters,
  .button-row,
  .quick-edit {
    grid-template-columns: 1fr;
  }

  .item-row {
    grid-template-columns: 1fr 86px;
  }

  .item-row label:first-child {
    grid-column: 1 / -1;
  }

  h1 {
    font-size: 28px;
  }
}
