@import url('https://fonts.googleapis.com/css2?family=Baloo+2:wght@500;600;700&family=Inter:wght@400;500;600;700&display=swap');

:root {
  --bg: #F6F9F4;
  --surface: #FFFFFF;
  --primary: #6B8F71;
  --primary-dark: #4F6E55;
  --accent: #F2A65A;
  --accent-soft: #FBE3C4;
  --text: #26312A;
  --text-muted: #6B7A70;
  --danger: #E2725B;
  --danger-soft: #FBE2DC;
  --border: #E1E8DE;
  --radius: 14px;
}

html[data-theme="dark"] {
  --bg: #1A211C;
  --surface: #232B25;
  --primary: #8FB495;
  --primary-dark: #B9D9BD;
  --accent: #F2A65A;
  --accent-soft: #4A3A22;
  --text: #F0F4EE;
  --text-muted: #A7B5A5;
  --danger: #E2725B;
  --danger-soft: #4A2A24;
  --border: #384038;
}

html[data-theme="dark"] .stage-0-6 { background: #2E4530; color: #B9E0BE; }
html[data-theme="dark"] .stage-6-12 { background: #4A3A22; color: #F2C384; }
html[data-theme="dark"] .stage-12\+ { background: #4A3324; color: #E8B18D; }
html[data-theme="dark"] .stage-diger { background: #33362F; color: #C4C7BE; }
html[data-theme="dark"] .banner { background: #4A3A22; color: #F2C384; }

body { transition: background-color .2s ease, color .2s ease; }
.card, header.topbar, .surface { transition: background-color .2s ease, border-color .2s ease; }

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, sans-serif;
  padding-bottom: 76px;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3, .brand-title {
  font-family: 'Baloo 2', 'Inter', sans-serif;
  font-weight: 700;
  color: var(--primary-dark);
  margin: 0;
}

header.topbar {
  background: var(--surface);
  padding: 16px 18px 14px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

header.topbar h1 {
  font-size: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
}

header.topbar .subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

main {
  padding: 14px;
  max-width: 640px;
  margin: 0 auto;
}

nav.tabs {
  display: flex;
  gap: 6px;
  padding: 0 14px 12px;
  max-width: 640px;
  margin: 0 auto;
}

nav.tabs button {
  flex: 1;
  padding: 9px 6px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
}

nav.tabs button.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
}

.brand-group-label {
  font-family: 'Baloo 2', sans-serif;
  font-weight: 600;
  font-size: 15px;
  color: var(--primary-dark);
  margin: 18px 0 8px;
}
.brand-group-label:first-child { margin-top: 0; }

.product-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.product-row:last-child { border-bottom: none; }

.product-info { flex: 1; min-width: 0; }
.product-name { font-weight: 600; font-size: 14.5px; }
.product-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.stage-badge {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  margin-right: 6px;
  white-space: nowrap;
}
.stage-0-6 { background: #DCEAD9; color: #3E5B43; }
.stage-6-12 { background: var(--accent-soft); color: #8C5A1E; }
.stage-12\+ { background: #E9D3C0; color: #7A4A2A; }
.stage-diger { background: #EAEAE6; color: #6B6B60; }

input.count-input {
  width: 62px;
  padding: 8px 6px;
  text-align: center;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 15px;
  font-family: inherit;
}

.btn {
  display: inline-block;
  padding: 12px 18px;
  border-radius: 10px;
  border: none;
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 14.5px;
  cursor: pointer;
}
.btn-primary { background: var(--primary); color: #fff; width: 100%; }
.btn-accent { background: var(--accent); color: #fff; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 7px 12px; font-size: 13px; }

.alert-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--danger-soft);
  margin-bottom: 8px;
  font-size: 13.5px;
}
.alert-item.ok { background: #EEF3EA; }

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 30px 10px;
  font-size: 14px;
}

.form-row { margin-bottom: 12px; }
.form-row label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 5px;
}
.form-row input, .form-row select {
  width: 100%;
  padding: 10px;
  border-radius: 9px;
  border: 1px solid var(--border);
  font-family: inherit;
  font-size: 14.5px;
  background: var(--surface);
}

.order-card { margin-bottom: 12px; }
.order-date { font-size: 12.5px; color: var(--text-muted); margin-bottom: 8px; }
.order-item { font-size: 13.5px; padding: 4px 0; }

.toast {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--primary-dark);
  color: #fff;
  padding: 11px 18px;
  border-radius: 10px;
  font-size: 13.5px;
  z-index: 100;
  opacity: 0;
  transition: opacity .25s;
  pointer-events: none;
}
.toast.show { opacity: 1; }

.theme-toggle {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 6px 12px;
  font-size: 12.5px;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
}

.row-between { display: flex; justify-content: space-between; align-items: center; }

.pin-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 20px;
}
.pin-screen input {
  font-size: 22px;
  letter-spacing: 6px;
  text-align: center;
  padding: 14px;
  width: 180px;
  border-radius: 10px;
  border: 1px solid var(--border);
}

a.admin-link {
  font-size: 12px;
  color: var(--text-muted);
  text-decoration: none;
}

.scanner-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(38,49,42,0.55);
  z-index: 200;
  align-items: flex-end;
  justify-content: center;
}
.scanner-modal.show { display: flex; }
.scanner-box {
  background: var(--surface);
  width: 100%;
  max-width: 640px;
  border-radius: 18px 18px 0 0;
  padding: 16px;
  max-height: 85vh;
  overflow-y: auto;
}
#scanner-reader { border-radius: 10px; overflow: hidden; }
#scanner-reader video { border-radius: 10px; }

.scan-highlight {
  animation: scanFlash 1.1s ease;
}
@keyframes scanFlash {
  0% { background: var(--accent-soft); }
  100% { background: transparent; }
}

.search-input {
  width: 100%;
  padding: 11px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  font-family: inherit;
  font-size: 14.5px;
  background: var(--surface);
  margin-bottom: 10px;
}
