:root {
  --primary: #38bdf8;
  --primary-dark: #0284c7;
  --secondary: #0f172a;
  --bg: #f0f9ff;
  --white: #ffffff;
  --muted: #64748b;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, sans-serif;
  background: linear-gradient(180deg, #e0f2fe 0%, var(--bg) 40%, #f8fafc 100%);
  color: var(--secondary);
}

.container { width: min(1100px, 95%); margin: 1rem auto 2rem; }
.topbar, .admin-header {
  background: var(--white);
  padding: 12px 16px;
  border-bottom: 1px solid #dbeafe;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand img { width: 48px; height: 48px; object-fit: cover; border-radius: 10px; }
.brand h1 { margin: 0; font-size: 1.2rem; }

button, .cart-btn, a {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 10px 14px;
  text-decoration: none;
  cursor: pointer;
  transition: transform .15s ease, background .2s ease;
}
.cart-btn {
  font-size: 1rem;
  font-weight: 700;
}
button:hover, .cart-btn:hover, a:hover { transform: translateY(-1px); background: var(--primary-dark); }
button.secondary { background: #94a3b8; }
button.danger { background: #ef4444; }

.hero-banner {
  background: linear-gradient(135deg, rgba(56,189,248,.18), rgba(2,132,199,.22));
  border: 1px solid #bae6fd;
  border-radius: 16px;
  padding: 18px;
  margin-bottom: 1rem;
}
.hero-banner h2 { margin: 0 0 8px; }
.hero-banner p { margin: 0; color: #334155; }

.categories {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.cat-filter { background: #e0f2fe; color: #075985; }
.cat-filter.active { background: var(--primary); color: #fff; }

.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 14px;
}
.product-card {
  background: var(--white);
  border-radius: 14px;
  box-shadow: 0 3px 12px rgba(15, 23, 42, 0.08);
  padding: 12px;
  border: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.product-media {
  width: 100%;
  height: 170px;
  border-radius: 10px;
  overflow: hidden;
  background: #f8fafc;
  display: grid;
  place-items: center;
}
.product-card img {
  width: 100%;
  height: 170px;
  object-fit: contain;
  display: block;
}
.product-media.is-placeholder {
  background: linear-gradient(135deg, #e2e8f0, #cbd5e1);
  display: grid;
  place-items: center;
}
.product-media.is-placeholder span {
  color: #334155;
  font-weight: 600;
  font-size: 0.9rem;
}
.product-thumbs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
}
.product-thumb {
  padding: 0;
  border: 2px solid transparent;
  border-radius: 8px;
  background: #fff;
  flex: 0 0 auto;
  width: 48px;
  height: 48px;
  overflow: hidden;
}
.product-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.product-thumb.active {
  border-color: var(--primary);
}
.product-card h3 { margin: 8px 0 0; }
.product-card p {
  color: var(--muted);
  margin: 0;
  line-height: 1.45;
  min-height: 40px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.product-card.hidden { display: none; }
.meta { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }
.product-card.no-description .meta { margin-top: 4px; }
.empty-products {
  grid-column: 1 / -1;
  background: #fff;
  border-radius: 12px;
  padding: 14px;
  text-align: center;
  color: var(--muted);
}

.cart-panel {
  position: fixed;
  inset-inline-start: -100%;
  top: 0;
  width: min(420px, 100%);
  height: 100vh;
  background: #fff;
  padding: 16px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.15);
  transition: 0.25s ease;
  z-index: 30;
}
.cart-panel.open { inset-inline-start: 0; }
.cart-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid #e2e8f0;
}
.cart-total { margin: 12px 0; font-weight: 700; }
.cart-panel input, .cart-panel textarea {
  width: 100%;
  margin-bottom: 8px;
  padding: 10px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
}
.cart-actions {
  display: grid;
  gap: 8px;
  margin-top: 6px;
}
.cart-actions button {
  width: 100%;
}

.card {
  background: #fff;
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 14px;
  box-shadow: 0 3px 12px rgba(15, 23, 42, 0.08);
}
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.kpi-grid { margin-bottom: 14px; }
.kpi-card p { margin: 0; font-size: 1.8rem; font-weight: 700; color: var(--primary-dark); }
.quick-links .card h4 { margin: 0 0 6px; color: var(--secondary); }
.quick-links .card p { margin: 0; color: var(--muted); }
.grid-form, .inline-form { display: grid; gap: 8px; }
input, select, textarea {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 10px;
}

table { width: 100%; border-collapse: collapse; }
th, td {
  border-bottom: 1px solid #e2e8f0;
  text-align: right;
  padding: 10px;
  vertical-align: middle;
}
.price-chip {
  display: inline-block;
  background: #e0f2fe;
  color: #0c4a6e;
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 600;
}
.status-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 600;
}
.status-badge.active { background: #dcfce7; color: #166534; }
.status-badge.frozen { background: #fee2e2; color: #991b1b; }
.empty-cell { text-align: center; color: var(--muted); padding: 18px; }
.hint-text { color: var(--muted); font-size: .9rem; }
.thumb { width: 56px; height: 56px; border-radius: 8px; object-fit: cover; }
.theme-swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.theme-swatches span {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px #cbd5e1;
}
.alert { padding: 10px; border-radius: 8px; margin-bottom: 10px; }
.alert.success { background: #dcfce7; color: #166534; }
.alert.error { background: #fee2e2; color: #991b1b; }
.alert { border: 1px solid transparent; }
.alert.success { border-color: #86efac; }
.alert.error { border-color: #fca5a5; }

.toast-stack {
  position: fixed;
  right: 14px;
  bottom: 14px;
  z-index: 70;
  display: grid;
  gap: 8px;
}
.toast {
  background: #0f172a;
  color: #fff;
  padding: 10px 14px;
  border-radius: 10px;
  box-shadow: 0 8px 25px rgba(15, 23, 42, 0.2);
  transform: translateY(10px);
  opacity: 0;
  transition: .2s ease;
  max-width: min(92vw, 320px);
  font-size: .92rem;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.warn { background: #b45309; }

.admin-header nav { display: flex; gap: 8px; flex-wrap: wrap; }
.admin-nav a.active {
  background: var(--primary-dark);
}
.admin-user-bar {
  background: #ffffffc9;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 8px 12px;
  margin-bottom: 10px;
}
.role-badge {
  display: inline-block;
  margin-inline-start: 8px;
  background: #e0f2fe;
  color: #075985;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: .8rem;
}
.login-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
}
.login-card {
  width: min(430px, 92%);
  background: #fff;
  border-radius: 14px;
  padding: 1.2rem;
  border: 1px solid #dbeafe;
  box-shadow: 0 12px 35px rgba(15, 23, 42, 0.14);
}
.login-brand {
  text-align: center;
  margin-bottom: 12px;
}
.login-brand h2 {
  margin: 6px 0 4px;
}
.login-brand p {
  margin: 0;
  color: var(--muted);
  font-size: .92rem;
}
.login-icon {
  width: 54px;
  height: 54px;
  margin: 0 auto;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  font-size: 1.5rem;
  box-shadow: 0 8px 20px rgba(2, 132, 199, .25);
}
.login-form {
  display: grid;
  gap: 8px;
}
.password-wrap {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}
.toggle-pass {
  white-space: nowrap;
  padding: 10px 12px;
}

@media (max-width: 768px) {
  .brand h1 { font-size: 1rem; }
  .admin-header nav a, .admin-header nav button { font-size: 0.85rem; padding: 8px 10px; }
  .topbar, .admin-header { align-items: flex-start; }
}
