:root {
  --color-primary: #4f46e5;
  --color-primary-dark: #4338ca;
  --color-accent: #f59e0b;
  --color-bg: #f7f7fb;
  --color-surface: #ffffff;
  --color-text: #1f2333;
  --color-text-muted: #6b7280;
  --color-border: #e5e7eb;
  --color-success: #16a34a;
  --color-danger: #dc2626;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 4px 14px rgba(30, 30, 60, 0.07);
  --shadow-hover: 0 10px 30px rgba(30, 30, 60, 0.12);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: linear-gradient(180deg, #eef0ff 0%, #f7f7fb 320px);
  color: var(--color-text);
  min-height: 100vh;
}

a { color: var(--color-primary); text-decoration: none; }

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

/* ---- Topbar ---- */
.topbar {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  max-width: 1100px;
  margin: 0 auto;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--color-text);
}
.brand-emoji { font-size: 1.5rem; }
.topnav { display: flex; align-items: center; gap: 18px; }
.topnav a {
  color: var(--color-text-muted);
  font-weight: 500;
  font-size: 0.95rem;
}
.topnav a.active, .topnav a:hover { color: var(--color-primary); }
.user-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--color-bg);
  border-radius: 999px;
  padding: 6px 12px 6px 6px;
  font-size: 0.9rem;
}
.avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem; font-weight: 700;
}

/* ---- Hero ---- */
.hero {
  padding: 36px 0 8px;
}
.hero h1 {
  font-size: 1.8rem;
  margin: 0 0 6px;
}
.hero p { color: var(--color-text-muted); margin: 0; }

/* ---- Filter bar ---- */
.filterbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 22px 0 26px;
}
.filter-chip {
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--color-text-muted);
}
.filter-chip.active {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}
.filter-chip:hover { border-color: var(--color-primary); }

/* ---- Product grid ---- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 20px;
  padding-bottom: 60px;
}
.card {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.2s ease, transform 0.2s ease;
  position: relative;
}
.card:hover { box-shadow: var(--shadow-hover); transform: translateY(-2px); }
.card.reserved { opacity: 0.55; }
.card.reserved.mine { opacity: 1; }

.card-image {
  aspect-ratio: 4/3;
  background: #f1f2fb url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24"></svg>') center/cover;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.card-image img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-image .placeholder { font-size: 2.4rem; opacity: 0.3; }

.card-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}
.card-category {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-primary);
  font-weight: 600;
}
.card-title { font-size: 1.02rem; font-weight: 600; margin: 0; line-height: 1.35; }
.card-desc { font-size: 0.87rem; color: var(--color-text-muted); line-height: 1.5; flex: 1; }
.card-price { font-weight: 600; color: var(--color-text); font-size: 0.92rem; }

.card-footer {
  padding: 0 16px 16px;
  display: flex;
  gap: 8px;
  align-items: center;
}

.badge {
  position: absolute;
  top: 12px; left: 12px;
  background: rgba(31,35,51,0.85);
  color: #fff;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  z-index: 2;
}
.badge.mine { background: var(--color-success); }

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: filter 0.15s ease, background 0.15s ease;
  text-decoration: none;
}
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-secondary { background: var(--color-bg); color: var(--color-text); border: 1px solid var(--color-border); }
.btn-secondary:hover { border-color: var(--color-primary); color: var(--color-primary); }
.btn-danger { background: #fef2f2; color: var(--color-danger); }
.btn-danger:hover { background: #fee2e2; }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 12px; font-size: 0.8rem; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.link-btn { background:none;border:none;color:var(--color-primary);font-weight:600;cursor:pointer;padding:0;font-size:0.85rem;}

/* ---- Forms ---- */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.auth-card {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-hover);
  padding: 40px;
  width: 100%;
  max-width: 400px;
}
.auth-card h1 { font-size: 1.4rem; margin: 0 0 4px; text-align: center; }
.auth-card .sub { text-align: center; color: var(--color-text-muted); font-size: 0.88rem; margin-bottom: 24px; }

.form-group { margin-bottom: 16px; }
label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 6px; }
input[type=text], input[type=email], input[type=password], input[type=url], input[type=number], textarea, select {
  width: 100%;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  font-size: 0.92rem;
  font-family: inherit;
  background: #fff;
  color: var(--color-text);
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,0.12);
}
textarea { resize: vertical; min-height: 90px; }

.panel {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 24px;
}
.panel h2 { margin-top: 0; font-size: 1.15rem; }

table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--color-border); }
th { color: var(--color-text-muted); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; }
tr:last-child td { border-bottom: none; }

.role-badge {
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
}
.role-badge.admin { background: #ede9fe; color: #6d28d9; }
.role-badge.user { background: #e0f2fe; color: #0369a1; }

.status-badge {
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
}
.status-badge.pending { background: #fef3c7; color: #92400e; }
.status-badge.accepted { background: #dcfce7; color: #166534; }

/* ---- Flash messages ---- */
.flash {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 18px;
  font-size: 0.9rem;
  font-weight: 500;
}
.flash.success { background: #dcfce7; color: #166534; }
.flash.error { background: #fee2e2; color: #991b1b; }
.flash.info { background: #dbeafe; color: #1e40af; }

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--color-text-muted);
}
.empty-state .emoji { font-size: 3rem; margin-bottom: 12px; }

.admin-tabs { display: flex; gap: 6px; margin-bottom: 24px; flex-wrap: wrap; }
.admin-tabs a {
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--color-text-muted);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
}
.admin-tabs a.active { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }

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

.form-row { display: flex; gap: 14px; flex-wrap: wrap; }
.form-row > * { flex: 1; min-width: 180px; }

.footer-note {
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.8rem;
  padding: 20px 0 40px;
}

.image-preview {
  width: 100%;
  max-width: 220px;
  border-radius: var(--radius-sm);
  margin-top: 8px;
  border: 1px solid var(--color-border);
}

.icon-btn {
  background: none; border: none; cursor: pointer; color: var(--color-text-muted); font-size: 1rem;
}
.icon-btn:hover { color: var(--color-danger); }

.hamburger { display: none; }

@media (max-width: 720px) {
  .topnav { gap: 12px; }
  .topnav span.divider { display: none; }
  .hero h1 { font-size: 1.4rem; }
  .auth-card { padding: 28px 22px; }
}
