:root {
  --bg: #f4f6f9;
  --card-bg: #ffffff;
  --primary: #1e6f5c;
  --primary-dark: #16543f;
  --accent: #ff8c42;
  --text: #22303f;
  --muted: #6b7785;
  --border: #e1e6eb;
  --danger: #d64545;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Segoe UI', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

header.topbar {
  background: var(--primary);
  color: white;
  padding: 16px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

header.topbar h1 {
  font-size: 20px;
  margin: 0;
}

header.topbar a {
  color: white;
  text-decoration: none;
  background: rgba(255,255,255,0.15);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 14px;
}
header.topbar a:hover { background: rgba(255,255,255,0.28); }

.layout {
  display: flex;
  gap: 20px;
  padding: 20px;
  max-width: 1300px;
  margin: 0 auto;
  align-items: flex-start;
}

.products-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
}

.product-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 14px;
  text-align: center;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease;
  user-select: none;
}
.product-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 16px rgba(0,0,0,0.08);
  border-color: var(--primary);
}
.product-card.out-of-stock {
  opacity: 0.45;
  cursor: not-allowed;
}
.product-card .emoji { font-size: 42px; }
.product-card .name { font-weight: 600; margin-top: 8px; font-size: 15px; }
.product-card .price { color: var(--primary); font-weight: 700; margin-top: 4px; }
.product-card .stock { color: var(--muted); font-size: 12px; margin-top: 4px; }

.cart-panel {
  width: 340px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  position: sticky;
  top: 20px;
}
.cart-panel h2 { margin-top: 0; font-size: 17px; }
.cart-items { max-height: 340px; overflow-y: auto; margin-bottom: 12px; }
.cart-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  gap: 8px;
}
.cart-item .info { font-size: 14px; }
.cart-item .info .sub { color: var(--muted); font-size: 12px; }
.cart-item .qty-controls { display: flex; align-items: center; gap: 6px; }
.cart-item button.mini {
  width: 26px; height: 26px; border-radius: 50%; border: none;
  background: var(--border); cursor: pointer; font-weight: bold;
}
.cart-item button.remove { background: none; border: none; color: var(--danger); cursor: pointer; font-size: 16px; }

.cart-total {
  display: flex;
  justify-content: space-between;
  font-size: 18px;
  font-weight: 700;
  padding: 10px 0;
  border-top: 2px solid var(--border);
}

.btn {
  display: inline-block;
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 10px;
  background: var(--primary);
  color: white;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 10px;
}
.btn:hover { background: var(--primary-dark); }
.btn:disabled { background: #a9b3ba; cursor: not-allowed; }
.btn.secondary { background: var(--border); color: var(--text); }
.btn.secondary:hover { background: #d2d8de; }
.btn.danger { background: var(--danger); }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.modal-box {
  background: white; border-radius: var(--radius); padding: 26px;
  width: 300px; text-align: center;
}
.modal-box .emoji { font-size: 48px; }
.modal-box h3 { margin: 10px 0 4px; }
.qty-stepper {
  display: flex; align-items: center; justify-content: center; gap: 16px;
  margin: 20px 0;
}
.qty-stepper button {
  width: 46px; height: 46px; border-radius: 50%; border: none;
  background: var(--primary); color: white; font-size: 22px; cursor: pointer;
}
.qty-stepper span { font-size: 28px; font-weight: 700; min-width: 40px; }

table.admin-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card-bg);
  border-radius: var(--radius);
  overflow: hidden;
}
table.admin-table th, table.admin-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-size: 14px;
}
table.admin-table th { background: #eef2f4; }
table.admin-table input {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
}
.admin-panel {
  max-width: 1000px;
  margin: 20px auto;
  padding: 0 20px;
}
.new-product-form {
  display: grid;
  grid-template-columns: 80px 2fr 1fr 1fr auto;
  gap: 8px;
  background: var(--card-bg);
  padding: 16px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  align-items: end;
}
.new-product-form label { font-size: 12px; color: var(--muted); display: block; margin-bottom: 4px; }
.new-product-form input {
  width: 100%;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
}
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: white; padding: 12px 20px; border-radius: 8px;
  font-size: 14px; z-index: 200; opacity: 0; transition: opacity .25s;
}
.toast.show { opacity: 1; }
