:root {
  --roast: #2C1A0E;
  --roast-2: #3D2512;
  --paper: #FBF7F2;
  --surface: #FFFFFF;
  --line: #E8DDD4;
  --muted: #7A6E66;
  --leaf: #B8620A;
  --leaf-dark: #954E07;
  --cherry: #C93A32;
  --font-display: "Unbounded", "Onest", system-ui, sans-serif;

  /* Bootstrap token overrides */
  --bs-body-font-family: "Onest", system-ui, -apple-system, "Segoe UI", sans-serif;
  --bs-body-color: var(--roast);
  --bs-body-color-rgb: 35, 26, 21;
  --bs-body-bg: var(--paper);
  --bs-secondary-color: var(--muted);
  --bs-border-color: var(--line);
  --bs-link-color: var(--leaf);
  --bs-link-color-rgb: 47, 93, 70;
  --bs-link-hover-color: var(--leaf-dark);
  --bs-link-hover-color-rgb: 36, 74, 55;
  --bs-primary: var(--leaf);
  --bs-primary-rgb: 47, 93, 70;
  --bs-border-radius: .625rem;
  --bs-border-radius-sm: .5rem;
  --bs-border-radius-lg: .875rem;
}

body { line-height: 1.55; -webkit-font-smoothing: antialiased; }

h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -.01em;
}

:focus-visible { outline: 3px solid rgba(47, 93, 70, .45); outline-offset: 2px; }

/* ---------- Buttons & forms ---------- */
.btn { font-weight: 500; }
.btn-action { white-space: nowrap; }

.btn-primary {
  --bs-btn-bg: var(--leaf); --bs-btn-border-color: var(--leaf);
  --bs-btn-hover-bg: var(--leaf-dark); --bs-btn-hover-border-color: var(--leaf-dark);
  --bs-btn-active-bg: #1C3A2B; --bs-btn-active-border-color: #1C3A2B;
  --bs-btn-disabled-bg: var(--leaf); --bs-btn-disabled-border-color: var(--leaf);
  --bs-btn-focus-shadow-rgb: 47, 93, 70;
}
.btn-outline-primary, .btn-outline-success {
  --bs-btn-color: var(--leaf); --bs-btn-border-color: var(--leaf);
  --bs-btn-hover-bg: var(--leaf); --bs-btn-hover-border-color: var(--leaf);
  --bs-btn-active-bg: var(--leaf-dark); --bs-btn-active-border-color: var(--leaf-dark);
  --bs-btn-focus-shadow-rgb: 47, 93, 70;
}
.btn-outline-secondary {
  --bs-btn-color: var(--roast); --bs-btn-border-color: #BFC3B8;
  --bs-btn-hover-bg: var(--roast); --bs-btn-hover-border-color: var(--roast); --bs-btn-hover-color: #fff;
  --bs-btn-active-bg: var(--roast); --bs-btn-active-border-color: var(--roast); --bs-btn-active-color: #fff;
  --bs-btn-focus-shadow-rgb: 35, 26, 21;
}
.btn-outline-danger {
  --bs-btn-color: var(--cherry); --bs-btn-border-color: var(--cherry);
  --bs-btn-hover-bg: var(--cherry); --bs-btn-hover-border-color: var(--cherry);
  --bs-btn-active-bg: #A82D27; --bs-btn-active-border-color: #A82D27;
  --bs-btn-focus-shadow-rgb: 201, 58, 50;
}
.btn-dark {
  --bs-btn-bg: var(--roast); --bs-btn-border-color: var(--roast);
  --bs-btn-hover-bg: var(--roast-2); --bs-btn-hover-border-color: var(--roast-2);
  --bs-btn-active-bg: var(--roast-2); --bs-btn-active-border-color: var(--roast-2);
}

.form-control, .form-select { border-color: #CFD3C8; }
.form-control:focus, .form-select:focus {
  border-color: var(--leaf);
  box-shadow: 0 0 0 .2rem rgba(47, 93, 70, .2);
}

/* Quantity stepper (see includes/_qty.html + static/js/app.js) */
.qty {
  display: inline-flex; align-items: stretch; min-height: 2.5rem;
  border: 1px solid #CFD3C8; border-radius: var(--bs-border-radius);
  background: #fff; overflow: hidden;
}
.qty button {
  width: 2.2rem; border: 0; background: transparent;
  color: var(--roast); font-size: 1.15rem; line-height: 1;
}
.qty button:hover { background: var(--paper); }
.qty input {
  width: 2.6rem; padding: 0; border: 0; background: transparent;
  text-align: center; font-weight: 600; -moz-appearance: textfield;
}
.qty input::-webkit-outer-spin-button,
.qty input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.qty input:focus { outline: none; }
.qty:focus-within { border-color: var(--leaf); box-shadow: 0 0 0 .2rem rgba(47, 93, 70, .2); }

/* ---------- Navbar ---------- */
.site-nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1030;
  padding-block: .7rem; background: var(--roast);
}
.site-nav .navbar-brand {
  display: flex; align-items: center; gap: .6rem;
  font-family: var(--font-display); font-weight: 700; font-size: 1.1rem; color: #fff;
}
.site-nav .navbar-brand img { border-radius: 6px; }
.site-logo { height: 42px; width: auto; border-radius: 8px; object-fit: cover; object-position: center; }
.site-nav .nav-link {
  padding: .45rem .8rem; border-radius: 8px; color: rgba(255, 255, 255, .72);
}
.site-nav .nav-link:hover { color: #fff; }
.site-nav .nav-link.active { color: #fff; background: rgba(255, 255, 255, .13); }
.site-nav .navbar-text { color: rgba(255, 255, 255, .6); font-size: .9rem; }
.site-nav .navbar-collapse { gap: .5rem; }

main.container { padding-block: 2rem 4rem; padding-top: 5.5rem; }

/* ---------- Page heading ---------- */
.page-head { margin-bottom: 1.5rem; }
.page-head h1 { margin: 0 0 .4rem; font-size: clamp(1.6rem, 1rem + 2vw, 2.3rem); }
.page-head p { margin: 0; max-width: 46ch; color: var(--muted); }
.back { display: inline-block; margin-bottom: 1rem; color: var(--muted); text-decoration: none; }
.back:hover { color: var(--roast); }

/* ---------- Category chips ---------- */
.chips {
  display: flex; gap: .5rem; margin-bottom: 1.75rem; padding-bottom: .25rem;
  overflow-x: auto; scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; padding: .45rem 1rem; border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); color: var(--roast); font-size: .95rem; font-weight: 500; text-decoration: none;
}
.chip:hover { border-color: var(--roast); color: var(--roast); }
.chip.active { background: var(--roast); border-color: var(--roast); color: #fff; }

.pill {
  display: inline-block; padding: .2rem .7rem; border-radius: 999px;
  background: #E8E6E1; color: var(--roast); font-size: .82rem; font-weight: 500;
}

/* ---------- Product card ---------- */
.product {
  display: flex; flex-direction: column; height: 100%; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
}
.product__media { position: relative; display: block; aspect-ratio: 4 / 3; overflow: hidden; background: #D9D5CC; }
.product__media img { width: 100%; height: 100%; object-fit: cover; transition: transform .4s ease; }
.product__media:hover img { transform: scale(1.04); }
.product__cat {
  position: absolute; top: .75rem; left: .75rem;
  background: rgba(255, 255, 255, .92);
}
.price-tag {
  position: absolute; left: 0; bottom: .9rem;
  display: inline-flex; align-items: baseline; gap: .3rem;
  padding: .45rem .85rem .45rem 1.7rem;
  background: var(--cherry); color: #fff; border-radius: 0 10px 10px 0;
  font-family: var(--font-display); font-weight: 600; font-size: .95rem;
}
.price-tag::before {
  content: ""; position: absolute; left: .7rem; top: 50%;
  width: .5rem; height: .5rem; margin-top: -.25rem; border-radius: 50%;
  background: #fff; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .2);
}
.price-tag small { font-family: var(--bs-body-font-family); font-size: .72rem; font-weight: 500; opacity: .9; }

.product__body { flex: 1; padding: 1rem 1.1rem .5rem; }
.product__title { margin: 0 0 .35rem; font-size: 1.05rem; line-height: 1.3; }
.product__title a { color: var(--roast); text-decoration: none; }
.product__title a:hover { color: var(--leaf); }
.product__desc { margin: 0; color: var(--muted); font-size: .92rem; }
.product__foot { padding: .75rem 1.1rem 1.1rem; }
.product__foot .login-hint { display: block; text-align: center; font-weight: 500; text-decoration: none; }

.buy { display: flex; flex-wrap: wrap; gap: .5rem; }
.buy .btn { flex: 1; min-height: 2.5rem; }

/* ---------- Panels & tables (staff pages, cart) ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.panel > .table { margin: 0; }
.panel.empty { padding: 2rem 1.5rem; text-align: center; }
.panel.empty p { margin-bottom: 1rem; color: var(--muted); }

.table { --bs-table-bg: transparent; --bs-table-border-color: var(--line); }
.table > :not(caption) > * > * { padding: .85rem 1rem; }
.table thead th {
  background: #F6F7F2; color: var(--muted); font-size: .85rem; font-weight: 600; white-space: nowrap;
}
.table tbody tr:last-child td { border-bottom: 0; }
.order-link { font-weight: 600; text-decoration: none; }

/* ---------- Status pills ---------- */
.status {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-width: 7.5rem; padding: .25rem .7rem;
  border-radius: 999px; font-size: .82rem; font-weight: 600; white-space: nowrap;
}
.status::before { content: ""; width: .5rem; height: .5rem; border-radius: 50%; background: currentColor; }
.status--new      { background: #E2EBF8; color: #24518F; }
.status--progress { background: #FBEBC6; color: #7A5200; }
.status--ready    { background: #D5EEDD; color: #1B6240; }
.status--done     { background: #E8E6E1; color: #59554F; }
.status--canceled { background: #F8DBD8; color: #9B241E; }

/* ---------- Cart ---------- */
.cart { display: grid; gap: 1.5rem; align-items: start; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 992px) {
  .cart { grid-template-columns: minmax(0, 1fr) 340px; }
  .cart-summary { position: sticky; top: 5.5rem; }
}
.cart-row {
  display: grid; align-items: center; gap: .75rem 1rem; padding: 1rem 1.1rem;
  border-bottom: 1px solid var(--line);
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "info remove" "qty cost";
}
.cart-row:last-child { border-bottom: 0; }
@media (min-width: 768px) {
  .cart-row {
    grid-template-columns: minmax(0, 1fr) auto 7rem auto;
    grid-template-areas: "info qty cost remove";
  }
}
.cart-row__info { grid-area: info; display: flex; align-items: center; gap: .9rem; min-width: 0; }
.cart-row__img { width: 56px; height: 56px; border-radius: 10px; object-fit: cover; flex: none; }
.cart-row__name { color: var(--roast); font-weight: 600; text-decoration: none; }
.cart-row__name:hover { color: var(--leaf); }
.cart-row__qty { grid-area: qty; display: flex; gap: .5rem; }
.cart-row__cost { grid-area: cost; text-align: right; font-weight: 600; white-space: nowrap; }
.cart-row__remove { grid-area: remove; }
.cart-summary { padding: 1.25rem; }
.cart-total { font-family: var(--font-display); font-weight: 600; font-size: 1.35rem; }

/* ---------- Order list & order "ticket" ---------- */
.order-row {
  display: flex; align-items: center; gap: .75rem;
  padding: .75rem 1.25rem; background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px;
}
.order-row + .order-row { margin-top: .6rem; }
.order-row:hover { border-color: var(--roast); }
.order-row__link {
  flex: 1; display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  color: inherit; text-decoration: none; min-width: 0;
}
.order-row__link:hover { color: inherit; }
.order-row__no { font-family: var(--font-display); font-weight: 600; }
.order-row__date { margin-left: .6rem; color: var(--muted); font-size: .9rem; }
.order-row__side { display: flex; align-items: center; gap: 1rem; font-weight: 600; flex-shrink: 0; }

.ticket {
  max-width: 560px; margin-inline: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
}
.ticket__head {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem;
  padding: 1.5rem 1.5rem 1rem;
}
.ticket__head h1 { margin: 0; font-size: 1.4rem; }
.ticket__date { margin-top: .3rem; color: var(--muted); font-size: .9rem; }
.ticket__items { margin: 0; padding: .5rem 1.5rem 1.5rem; list-style: none; }
.ticket__items li { display: flex; align-items: baseline; gap: .5rem; padding: .35rem 0; }
.ticket__items .leader { flex: 1; border-bottom: 2px dotted var(--line); transform: translateY(-.2rem); }
.ticket__cut { position: relative; border-top: 2px dashed var(--line); }
.ticket__cut::before, .ticket__cut::after {
  content: ""; position: absolute; top: -11px; width: 22px; height: 22px;
  border-radius: 50%; background: var(--paper); border: 1px solid var(--line);
}
.ticket__cut::before { left: -11px; clip-path: inset(0 0 0 50%); }
.ticket__cut::after  { right: -11px; clip-path: inset(0 50% 0 0); }
.ticket__foot {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding: 1.25rem 1.5rem 1.5rem;
}
.ticket__total { font-family: var(--font-display); font-weight: 600; font-size: 1.25rem; }

/* ---------- Product detail ---------- */
.detail { display: grid; gap: 1.5rem; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 768px) { .detail { grid-template-columns: 1fr 1fr; gap: 2.5rem; align-items: start; } }
.detail__img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 14px; }
.detail__info h1 { margin: .75rem 0 1rem; font-size: clamp(1.6rem, 1rem + 2vw, 2.2rem); }
.detail__price { margin: 1.25rem 0 .25rem; font-family: var(--font-display); font-weight: 600; font-size: 1.6rem; }

/* ---------- Pagination ---------- */
.pagination {
  --bs-pagination-color: var(--roast); --bs-pagination-bg: var(--surface);
  --bs-pagination-border-color: var(--line);
  --bs-pagination-hover-color: var(--roast); --bs-pagination-hover-bg: var(--paper);
  --bs-pagination-hover-border-color: var(--line);
  --bs-pagination-focus-color: var(--roast); --bs-pagination-focus-bg: var(--paper);
  --bs-pagination-active-bg: var(--roast); --bs-pagination-active-border-color: var(--roast);
  --bs-pagination-active-color: #fff; --bs-pagination-disabled-bg: transparent;
  gap: .25rem;
}
.page-item .page-link { margin-left: 0; border-radius: 10px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}

/* ---------- Role picker (staff_users) ---------- */
.role-form { display: inline-flex; align-items: center; gap: .4rem; margin: 0; }
.role-select {
  width: auto; padding: .3rem 2rem .3rem .85rem;
  border: 1px solid transparent; border-radius: 999px;
  background-color: #E8E6E1; background-position: right .7rem center;
  font-size: .85rem; font-weight: 500; cursor: pointer;
}
.role-select:hover { border-color: var(--roast); }
.role-form.is-dirty .role-select { border-color: var(--leaf); background-color: #fff; }
.role-form .btn { padding-inline: .9rem; border-radius: 999px; }
.role-form.is-armed:not(.is-dirty) .btn { display: none; }

/* ---------- Icon button (open details) ---------- */
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2rem; height: 2rem; background: #fff; color: var(--roast);
  border: 1px solid #BFC3B8; border-radius: var(--bs-border-radius); text-decoration: none;
}
.icon-btn:hover { background: var(--roast); border-color: var(--roast); color: #fff; }

/* ---------- Stock hint under the quantity stepper ---------- */
.qty button.is-maxed { color: #B4B8AD; cursor: not-allowed; }
.qty button.is-maxed:hover { background: transparent; }
.qty-hint { flex: 0 0 100%; margin: 0; font-size: .85rem; color: var(--muted); }
.qty-hint.is-limit { color: var(--cherry); font-weight: 500; }

/* ---------- Active orders card grid ---------- */
.orders-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}
.order-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.order-card__head {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--line);
  background: #F9FAF6;
  flex-wrap: wrap;
}
.order-card__no {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
}
.order-card__time { font-size: .85rem; font-weight: 600; color: var(--roast); }
.order-card__body { padding: .875rem 1rem; flex: 1; }
.order-card__row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-size: .9rem;
  padding: .2rem 0;
}
.order-card__items {
  margin-top: .6rem;
  padding-top: .6rem;
  border-top: 1px dashed var(--line);
  font-size: .85rem;
  color: var(--muted);
  line-height: 1.65;
}
.order-card__foot {
  display: flex;
  gap: .5rem;
  padding: .75rem 1rem;
  border-top: 1px solid var(--line);
}
.order-card__foot .flex-1 { flex: 1; }

/* ---------- Mobile ---------- */
@media (max-width: 575px) {
  main.container { padding-inline: .875rem; padding-top: 5rem; padding-bottom: 2.5rem; }

  /* page-head with inline button — wrap на мобільному */
  .page-head.d-flex { flex-wrap: wrap; gap: .5rem; align-items: center; }

  /* ticket padding */
  .ticket__head { padding: 1rem 1rem .75rem; }
  .ticket__items { padding-inline: 1rem; }
  .ticket__foot { padding: 1rem; }

  /* order-row — деталі під назвою */
  .order-row__link { flex-direction: column; align-items: flex-start; gap: .35rem; }
  .order-row__side { flex-wrap: wrap; gap: .4rem; }
  .order-row__date { margin-left: 0; }

  /* cart row */
  .cart-row__img { width: 48px; height: 48px; }
}

@media (max-width: 991px) {
  /* ховаємо email в navbar на мобільному */
  .site-nav .navbar-text { display: none; }
}
