/* ------------------------------------------------------------------
   qub — base styles. Mobile-first: rules for narrow screens first,
   then expanded via min-width media queries.
   Palette: warm concrete-grey background, dark graphite header,
   accent — a saturated amber (evokes timber/construction).
   ------------------------------------------------------------------ */

:root {
  --color-bg: #EDEAE3;
  --color-surface: #FFFFFF;
  --color-ink: #23211D;
  --color-muted: #6E6B63;
  --color-accent: #C77A1E;
  --color-accent-ink: #FFFFFF;
  --color-line: #DEDACE;
  --radius: 10px;
  --header-h: 56px;
  --bottomnav-h: 58px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--color-bg);
  color: var(--color-ink);
  padding-bottom: var(--bottomnav-h);
}

a { color: inherit; text-decoration: none; }

/* ---------- Header ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--color-ink);
  color: #fff;
}

.topbar__row {
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
}

.topbar__logo {
  font-weight: 800;
  font-size: 20px;
  letter-spacing: -0.02em;
  flex-shrink: 0;
}
.topbar__logo-accent { color: var(--color-accent); }

.topbar__search {
  flex: 1;
  display: flex;
  background: rgba(255,255,255,0.1);
  border-radius: 8px;
  overflow: hidden;
}
.topbar__search input {
  flex: 1;
  border: 0;
  background: transparent;
  color: #fff;
  padding: 9px 10px;
  font-size: 14px;
  min-width: 0;
}
.topbar__search input::placeholder { color: rgba(255,255,255,0.55); }
.topbar__search button {
  border: 0;
  background: transparent;
  color: rgba(255,255,255,0.85);
  padding: 0 10px;
  cursor: pointer;
}

.topbar__region {
  font-size: 12px;
  color: rgba(255,255,255,0.7);
  white-space: nowrap;
  display: none;
}
@media (min-width: 480px) {
  .topbar__region { display: inline-block; }
}

.topbar__nav {
  display: none;
  gap: 16px;
  align-items: center;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.topbar__nav a { color: rgba(255,255,255,0.8); }
.topbar__nav a:hover { color: #fff; }
@media (min-width: 960px) {
  .topbar__nav { display: flex; }
}

.topbar__auth {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}
.topbar__signin {
  display: inline-block;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  background: var(--color-accent);
  padding: 7px 14px;
  border-radius: 8px;
  white-space: nowrap;
}
.topbar__user-name {
  font-size: 13px;
  font-weight: 600;
  color: rgba(255,255,255,0.9);
  white-space: nowrap;
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar__signout {
  font-size: 12px;
  color: rgba(255,255,255,0.55);
  white-space: nowrap;
  border: 1px solid rgba(255,255,255,0.2);
  padding: 5px 10px;
  border-radius: 7px;
}
.topbar__register {
  font-size: 12px;
  color: rgba(255,255,255,0.7);
  white-space: nowrap;
  border: 1px solid rgba(255,255,255,0.3);
  padding: 6px 11px;
  border-radius: 7px;
}
.topbar__register:hover { color: #fff; border-color: rgba(255,255,255,0.7); }

/* ---------- Content ---------- */

.content { padding: 12px; max-width: 1120px; margin: 0 auto; }

.section-title {
  font-size: 15px;
  font-weight: 700;
  margin: 18px 4px 10px;
  color: var(--color-ink);
}

/* ---------- Category cards (home page) ---------- */

.category-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
@media (min-width: 640px) {
  .category-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 960px) {
  .category-grid { grid-template-columns: repeat(4, 1fr); }
}

.category-card {
  position: relative;
  background: var(--color-surface);
  border-radius: var(--radius);
  border: 1px solid var(--color-line);
  padding: 14px 12px;
  min-height: 92px;
  display: flex;
  align-items: flex-end;
}
.category-card__name {
  font-weight: 700;
  font-size: 14.5px;
}

/* Subcategories: hover menu on desktop, tap-to-expand on mobile */
.category-card__submenu {
  display: none;
  position: absolute;
  left: 0; right: 0; top: 100%;
  background: var(--color-surface);
  border: 1px solid var(--color-line);
  border-radius: var(--radius);
  margin-top: 4px;
  padding: 6px;
  z-index: 10;
  box-shadow: 0 8px 24px rgba(0,0,0,0.08);
}
.category-card__submenu a {
  display: block;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 13.5px;
}
.category-card__submenu a:active,
.category-card__submenu a:hover { background: var(--color-bg); }

.category-card.is-open .category-card__submenu { display: block; }

@media (hover: hover) {
  .category-card:hover .category-card__submenu { display: block; }
}

/* ---------- Product cards ---------- */

.product-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
@media (min-width: 640px) {
  .product-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 960px) {
  .product-grid { grid-template-columns: repeat(4, 1fr); }
}

.product-card {
  background: var(--color-surface);
  border: 1px solid var(--color-line);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.product-card__image {
  aspect-ratio: 1 / 1;
  background: var(--color-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-muted);
  font-size: 12px;
}
.product-card__image img { width: 100%; height: 100%; object-fit: cover; }
.product-card__body { padding: 8px 10px 10px; display: flex; flex-direction: column; gap: 4px; }
.product-card__title { font-size: 13px; font-weight: 600; line-height: 1.25; min-height: 2.5em; }
.product-card__code { font-size: 11px; color: var(--color-muted); }
.product-card__price { font-size: 15px; font-weight: 800; }
.product-card__price--old { font-size: 12px; color: var(--color-muted); text-decoration: line-through; font-weight: 400; }
.product-card__status { font-size: 11px; }
.product-card__status--in { color: #2E7D32; }
.product-card__status--out { color: #B23B3B; }

.btn {
  border: 0;
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  background: var(--color-accent);
  color: var(--color-accent-ink);
  width: 100%;
}
.btn:disabled { background: var(--color-line); color: var(--color-muted); cursor: not-allowed; }
.btn--ghost { background: transparent; border: 1px solid var(--color-line); color: var(--color-ink); }

/* ---------- Bottom mobile navigation ---------- */

.bottomnav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: var(--bottomnav-h);
  background: var(--color-surface);
  border-top: 1px solid var(--color-line);
  display: flex;
  z-index: 30;
  padding-bottom: env(safe-area-inset-bottom);
}
.bottomnav__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 11px;
  color: var(--color-muted);
}
.bottomnav__item span { font-size: 18px; }

@media (min-width: 960px) {
  .bottomnav { display: none; }
  body { padding-bottom: 0; }
}

/* ---------- Forms ---------- */

.form { display: flex; flex-direction: column; gap: 10px; max-width: 420px; }
.form input, .form textarea {
  padding: 10px 12px;
  border: 1px solid var(--color-line);
  border-radius: 8px;
  font-size: 14px;
  background: var(--color-surface);
}

.muted { color: var(--color-muted); font-size: 13px; }
.empty-state { text-align: center; padding: 40px 16px; color: var(--color-muted); }
