:root {
  --bg: #f4f6f4;
  --card: #ffffff;
  --text: #1a2e1a;
  --muted: #5c6b5c;
  --primary: #1b7a3d;
  --primary-dark: #145c2e;
  --accent: #e8f5e9;
  --danger: #c62828;
  --border: #d5e0d5;
  --shadow: 0 2px 12px rgba(20, 60, 30, 0.08);
  --radius: 14px;
  --nav-h: 60px;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100%;
}
a { color: var(--primary); text-decoration: none; }
button, input, select, textarea { font: inherit; }

.app-shell {
  max-width: 720px;
  margin: 0 auto;
  padding: 12px 12px calc(var(--nav-h) + 20px);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}
.topbar h1 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
}
.badge {
  font-size: 0.7rem;
  background: var(--accent);
  color: var(--primary-dark);
  padding: 4px 8px;
  border-radius: 999px;
}

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

.label {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 4px;
  font-weight: 600;
}
.input, .select, .textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  outline: none;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(27, 122, 61, 0.15);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: 12px;
  padding: 12px 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.05s;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; width: 100%; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--accent); color: var(--primary-dark); width: 100%; }
.btn-danger { background: #ffebee; color: var(--danger); }
.btn-ghost { background: transparent; color: var(--muted); padding: 8px; }
.btn-sm { padding: 8px 10px; font-size: 0.85rem; width: auto; }

.row { display: flex; gap: 8px; }
.row > * { flex: 1; }
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.product-list {
  max-height: 220px;
  overflow-y: auto;
  margin-top: 8px;
}
.product-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.product-item:active, .product-item:hover { background: var(--accent); }
.product-item .name { font-weight: 600; }
.product-item .meta { font-size: 0.8rem; color: var(--muted); }

.cart-line {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.cart-line .title { font-weight: 600; }
.cart-line .sub { font-size: 0.8rem; color: var(--muted); }
.cart-actions { display: flex; gap: 6px; align-items: center; }

.total-bar {
  position: sticky;
  bottom: calc(var(--nav-h) + 8px);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow);
  z-index: 5;
}
.total-bar .amount {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--primary);
}

.nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: var(--nav-h);
  background: #fff;
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 20;
}
.nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  color: var(--muted);
  font-weight: 600;
  gap: 2px;
}
.nav a.active { color: var(--primary); }
.nav .ico { font-size: 1.15rem; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 40;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.modal {
  background: #fff;
  width: 100%;
  max-width: 720px;
  border-radius: 20px 20px 0 0;
  padding: 16px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal h2 { margin: 0 0 12px; font-size: 1.1rem; }
.hidden { display: none !important; }

.steps { font-size: 0.8rem; }
.steps .ok { color: var(--primary); }
.steps .error { color: var(--danger); }
.steps .info { color: var(--muted); }

.tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  margin-bottom: 12px;
}
.tab {
  white-space: nowrap;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
}
.tab.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.toast {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: #1a2e1a;
  color: #fff;
  padding: 10px 16px;
  border-radius: 10px;
  z-index: 50;
  font-size: 0.9rem;
  max-width: 90%;
}
.toast.error { background: var(--danger); }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.table th, .table td {
  text-align: left;
  padding: 8px 4px;
  border-bottom: 1px solid var(--border);
}

@media (min-width: 768px) {
  .app-shell { padding-top: 20px; }
  .product-list { max-height: 320px; }
}
