:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #dfe3ea;
  --text: #18202c;
  --muted: #5b6576;
  --primary: #0f766e;
  --primary-hover: #0d5e58;
  --accent: #ecfdf5;
  --warn-bg: #fef3c7;
  --warn-text: #92400e;
  --danger-bg: #fee2e2;
  --danger-text: #991b1b;
  --ok-bg: #dcfce7;
  --ok-text: #166534;
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.4;
}

.topbar {
  background: #0f172a;
  color: #f8fafc;
  border-bottom: 1px solid #1e293b;
}

.topbar-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.brand h1 {
  margin: 0;
  font-size: 1.15rem;
}

.subtitle {
  margin: 0;
  font-size: 0.82rem;
  color: #cbd5e1;
}

.topbar-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.country-picker {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
}

.country-picker select {
  background: #1e293b;
  color: #f8fafc;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 0.9rem;
}

.wal-badge {
  font-size: 0.78rem;
  padding: 5px 10px;
  border-radius: 999px;
  background: #14532d;
  color: #bbf7d0;
  border: 1px solid #166534;
}

.tabs {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  gap: 6px;
}

.tab-btn {
  background: transparent;
  border: none;
  color: #cbd5e1;
  padding: 10px 16px;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 3px solid transparent;
}

.tab-btn.active {
  color: #fff;
  border-bottom-color: #2dd4bf;
}

.container {
  max-width: 1280px;
  margin: 20px auto;
  padding: 0 20px 40px;
}

.tab-panel {
  display: none;
}

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

.catalog-layout {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 20px;
  align-items: start;
}

.toolbar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

#search-input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  background: var(--surface);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 0.84rem;
  cursor: pointer;
}

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

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
}

.product-card, .card, .cart-panel, .order-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}

.product-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
}

.product-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  font-size: 0.76rem;
  color: var(--muted);
}

.product-title {
  margin: 4px 0 2px;
  font-size: 1rem;
}

.product-unit {
  font-size: 0.82rem;
  color: var(--muted);
}

.product-desc {
  font-size: 0.83rem;
  color: var(--muted);
  margin: 6px 0 0;
}

.product-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  border-top: 1px solid #eef1f5;
  padding-top: 10px;
}

.price {
  font-size: 1.08rem;
  font-weight: 700;
  color: var(--text);
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-ok { background: var(--ok-bg); color: var(--ok-text); }
.badge-warn { background: var(--warn-bg); color: var(--warn-text); }
.badge-danger { background: var(--danger-bg); color: var(--danger-text); }

.btn-primary, .btn-secondary, .btn-small {
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  padding: 10px 14px;
  font-size: 0.94rem;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

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

.btn-secondary {
  background: #e2e8f0;
  color: var(--text);
  padding: 8px 12px;
  font-size: 0.86rem;
}

.btn-small {
  background: var(--primary);
  color: #fff;
  padding: 6px 10px;
  font-size: 0.82rem;
}

.btn-small:disabled {
  background: #cbd5e1;
  cursor: not-allowed;
}

.cart-panel {
  position: sticky;
  top: 16px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.panel-header h2 {
  margin: 0;
  font-size: 1.08rem;
}

.pill {
  background: var(--accent);
  color: var(--primary);
  border: 1px solid #99f6e4;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
}

.cart-list {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cart-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid #eef1f5;
  font-size: 0.88rem;
}

.qty-controls {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.qty-btn {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #f8fafc;
  cursor: pointer;
  font-weight: 700;
}

.totals-box {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 12px;
}

.total-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.88rem;
  margin-bottom: 4px;
}

.grand-total {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid #cbd5e1;
  font-size: 1rem;
}

.order-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.order-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.84rem;
  font-weight: 600;
}

.order-form input, .order-form textarea, .orders-filters select, .stock-table input {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: inherit;
}

.receipt {
  margin-top: 12px;
  padding: 12px;
  border-radius: 8px;
  background: var(--ok-bg);
  color: var(--ok-text);
  font-size: 0.88rem;
}

.orders-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.orders-toolbar h2 {
  margin: 0;
}

.orders-filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.orders-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.order-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.order-items {
  margin: 8px 0;
  padding-left: 18px;
  font-size: 0.88rem;
}

.order-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.admin-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 20px;
  align-items: start;
}

.table-wrap {
  overflow-x: auto;
}

.stock-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.stock-table th, .stock-table td {
  padding: 8px 6px;
  border-bottom: 1px solid #eef1f5;
  text-align: left;
}

.stock-table input {
  width: 95px;
}

.subcard {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 10px;
}

.subcard h3 {
  margin: 0 0 8px;
  font-size: 0.88rem;
}

.np-country-rows {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.np-row {
  display: grid;
  grid-template-columns: 1fr 110px 90px;
  gap: 8px;
  align-items: center;
  font-size: 0.85rem;
}

.empty-state, .hint {
  color: var(--muted);
  font-size: 0.88rem;
}

.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: #0f172a;
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 0.9rem;
  z-index: 1000;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

.toast.error {
  background: #991b1b;
}

.hidden {
  display: none !important;
}

@media (max-width: 960px) {
  .catalog-layout, .admin-grid {
    grid-template-columns: 1fr;
  }
  .cart-panel {
    position: static;
  }
}
