:root {
  color-scheme: light;
  --bg: #f7f7f2;
  --surface: #ffffff;
  --surface-2: #eef6f3;
  --ink: #17211f;
  --muted: #62706c;
  --line: #d9e1dd;
  --brand: #0f766e;
  --brand-dark: #0b5f59;
  --gold: #c58b16;
  --danger: #b42318;
  --ok: #177245;
  --shadow: 0 10px 28px rgba(23, 33, 31, 0.1);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

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

button {
  min-height: 44px;
}

.app-root {
  min-height: 100vh;
}

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

.login-panel {
  width: min(100%, 420px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 24px;
}

.reset-panel {
  border-top: 1px solid var(--line);
  margin-top: 18px;
  padding-top: 18px;
}

.reset-panel h2 {
  margin: 0;
  font-size: 1.05rem;
}

.success-text {
  color: var(--ok);
  font-weight: 800;
  margin: 0;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}

.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--brand);
  color: white;
  font-weight: 800;
  letter-spacing: 0;
}

.brand-title {
  margin: 0;
  font-size: 1.35rem;
  line-height: 1.1;
}

.brand-subtitle {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(247, 247, 242, 0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  padding: max(10px, env(safe-area-inset-top)) 14px 10px;
}

.topbar-inner {
  max-width: 1120px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.9rem;
}

.content {
  width: min(100%, 1120px);
  margin: 0 auto;
  padding: 16px 14px 92px;
  flex: 1;
}

.bottom-nav {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 30;
  background: var(--surface);
  border-top: 1px solid var(--line);
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  padding: 7px 7px max(7px, env(safe-area-inset-bottom));
}

.nav-button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 8px;
  min-height: 52px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  text-decoration: none;
}

.nav-button.active {
  background: var(--surface-2);
  color: var(--brand-dark);
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.section-head h2,
.section-head h1 {
  margin: 0;
  font-size: clamp(1.25rem, 2vw, 1.75rem);
}

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

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

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

.grid {
  display: grid;
  gap: 12px;
}

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

.form-row {
  display: grid;
  gap: 7px;
}

.form-row label {
  font-weight: 800;
  font-size: 0.9rem;
}

.field,
.select,
.textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  min-height: 46px;
  padding: 10px 12px;
}

.textarea {
  min-height: 96px;
  resize: vertical;
}

.field:focus,
.select:focus,
.textarea:focus {
  outline: 3px solid rgba(15, 118, 110, 0.16);
  border-color: var(--brand);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.initial-filter {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-weight: 800;
}

.initial-chip {
  min-height: 36px;
  min-width: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--brand-dark);
  font-weight: 900;
  cursor: pointer;
}

.initial-chip.active {
  background: var(--brand);
  border-color: var(--brand);
  color: white;
}

.btn {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: 8px;
  padding: 10px 14px;
  font-weight: 800;
  cursor: pointer;
}

.btn.primary {
  background: var(--brand);
  border-color: var(--brand);
  color: white;
}

.btn.primary:hover {
  background: var(--brand-dark);
}

.btn.warning {
  border-color: rgba(197, 139, 22, 0.38);
  color: #7a4d00;
  background: #fff7e5;
}

.btn.danger {
  border-color: rgba(180, 35, 24, 0.32);
  color: var(--danger);
  background: #fff1f0;
}

.btn.ghost {
  background: transparent;
}

.btn.full {
  width: 100%;
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.stepper {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 14px;
}

.step {
  min-height: 40px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 800;
}

.step.active {
  background: var(--brand);
  border-color: var(--brand);
  color: white;
}

.store-list,
.sku-list,
.order-list,
.compact-list {
  display: grid;
  gap: 10px;
}

.store-card,
.sku-card,
.order-card,
.stat-card,
.compact-row {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 8px;
  padding: 12px;
}

.store-card.selected {
  border-color: var(--brand);
  background: var(--surface-2);
}

.store-card button,
.store-select,
.sku-card button {
  width: 100%;
  text-align: left;
}

.store-select {
  display: block;
  cursor: pointer;
}

.store-radio {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.card-title {
  font-weight: 900;
  margin: 0 0 4px;
}

.card-meta {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0;
}

.quantity-row {
  display: grid;
  grid-template-columns: 44px minmax(74px, 1fr) 44px;
  gap: 8px;
  align-items: center;
  margin-top: 10px;
}

.qty-button {
  min-width: 44px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: 8px;
  font-size: 1.1rem;
  font-weight: 900;
}

.qty-input {
  text-align: center;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--brand-dark);
  font-size: 0.82rem;
  font-weight: 900;
}

.status-pill.new {
  background: #e6f5ef;
  color: var(--ok);
}

.status-pill.ready {
  background: #fff7e5;
  color: #7a4d00;
}

.status-pill.completed {
  background: #eceff3;
  color: #46515c;
}

.status-pill.cancelled {
  background: #fff1f0;
  color: var(--danger);
}

.alert {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface-2);
}

.alert.warning {
  border-color: rgba(197, 139, 22, 0.38);
  background: #fff7e5;
}

.alert.error {
  border-color: rgba(180, 35, 24, 0.32);
  background: #fff1f0;
}

.alert.success {
  border-color: rgba(23, 114, 69, 0.26);
  background: #ecfdf3;
}

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

.summary-list {
  margin: 0;
  padding-left: 18px;
}

.summary-list li {
  margin: 6px 0;
}

.backup-summary {
  width: 100%;
  min-height: 148px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
  color: var(--ink);
  font: 0.92rem/1.45 ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  white-space: pre-wrap;
}

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

.stat-card strong {
  display: block;
  font-size: 1.6rem;
}

.order-card header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.order-card details {
  margin-top: 10px;
}

.order-items {
  margin: 10px 0 0;
  padding-left: 18px;
}

.management-grid {
  display: grid;
  gap: 14px;
}

.install-steps {
  counter-reset: step;
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 8px;
}

.install-steps li {
  counter-increment: step;
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 10px;
  align-items: start;
}

.install-steps li::before {
  content: counter(step);
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--brand);
  color: white;
  font-weight: 900;
}

.toast {
  position: fixed;
  left: 14px;
  right: 14px;
  bottom: 82px;
  z-index: 50;
  min-height: 48px;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 12px 14px;
  background: #17211f;
  color: white;
  border-radius: 8px;
  box-shadow: var(--shadow);
  text-align: center;
}

.toast.show {
  display: flex;
}

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

.desktop-only {
  display: none;
}

@media (min-width: 720px) {
  .content {
    padding-bottom: 32px;
  }

  .bottom-nav {
    position: sticky;
    top: 69px;
    inset: auto;
    width: min(100%, 1120px);
    margin: 0 auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    grid-auto-columns: minmax(140px, max-content);
    justify-content: start;
    padding: 8px;
  }

  .nav-button {
    padding: 0 18px;
  }

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

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

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

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

  .desktop-only {
    display: inline;
  }
}

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