/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f5f7fa;
  color: #1a1a2e;
  line-height: 1.5;
  padding-bottom: 0;
  min-height: 100vh;
}
body.cart-open { overflow: hidden; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; height: auto; }
.container { max-width: 1100px; margin: 0 auto; padding: 0 12px; }

/* ===== HEADER ===== */
.header {
  background: linear-gradient(135deg, #2d6a4f, #40916c);
  color: #fff;
  padding: 12px 0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(0,0,0,0.15);
}
.header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.header__left { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.header__logo { font-size: 1.2rem; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header__subtitle { font-size: 0.75rem; opacity: 0.85; }
.header__right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* ===== BUTTONS ===== */
.btn-primary {
  background: #2d6a4f;
  color: #fff;
  border: none;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  -webkit-appearance: none;
  appearance: none;
}
.btn-primary:hover { background: #1b4332; }
.btn-primary:active { transform: scale(0.98); }
.btn-block { width: 100%; }
.btn-sm {
  background: #e9ecef;
  border: 1px solid #dee2e6;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  -webkit-appearance: none;
  appearance: none;
}
.btn-danger { background: #fee; color: #c00; border-color: #fcc; }

/* ===== CART BUTTON ===== */
.cart-btn {
  background: rgba(255,255,255,0.2);
  color: #fff;
  border: 2px solid rgba(255,255,255,0.3);
  padding: 6px 14px;
  border-radius: 24px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
  -webkit-appearance: none;
  appearance: none;
  white-space: nowrap;
}
.cart-btn:hover { background: rgba(255,255,255,0.3); }
.cart-btn:active { transform: scale(0.96); }
.cart-badge {
  background: #ff6b35;
  color: #fff;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  flex-shrink: 0;
}

/* ===== CABINET LINK ===== */
.cabinet-link {
  color: #fff;
  text-decoration: none;
  padding: 6px 12px;
  border: 2px solid rgba(255,255,255,0.3);
  border-radius: 24px;
  font-weight: 600;
  font-size: 0.85rem;
  transition: all 0.2s;
  white-space: nowrap;
}
.cabinet-link:hover { background: rgba(255,255,255,0.2); }

/* ===== BACK LINK ===== */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: #2d6a4f;
  font-weight: 600;
  font-size: 0.85rem;
  padding: 6px 0;
  text-decoration: none;
}
.back-link:hover { text-decoration: underline; }

.cabinet-card__header {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}
.cabinet-card__header h2 { margin: 0; }

/* ===== STEPS ===== */
.step { display: none; padding: 16px 0; }
.step.active { display: block; }
.step h2 { margin-bottom: 16px; font-size: 1.15rem; }

/* ===== CATEGORIES ===== */
.categories-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
}
.category-card {
  background: #fff;
  border: 2px solid #e9ecef;
  border-radius: 12px;
  padding: 16px 10px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  -webkit-appearance: none;
  appearance: none;
  font-family: inherit;
  font-size: inherit;
}
.category-card:hover {
  border-color: #2d6a4f;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(45,106,79,0.15);
}
.category-card:active { transform: scale(0.96); }
.category-icon { font-size: 2.2rem; line-height: 1; }
.category-name { font-weight: 600; font-size: 0.9rem; }

/* ===== PRODUCTS ===== */
.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}
.product-card {
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  transition: box-shadow 0.2s;
}
.product-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.1); }
.product-card__image {
  height: 160px;
  background: #f0f0f0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  overflow: hidden;
  position: relative;
}
.product-card__image img { width: 100%; height: 100%; object-fit: cover; }
.product-card__image .placeholder-icon { font-size: 3.5rem; opacity: 0.7; }
.product-card__body { padding: 12px; }
.product-card__name { font-size: 1rem; font-weight: 700; margin-bottom: 3px; }
.product-card__desc { font-size: 0.8rem; color: #666; margin-bottom: 10px; line-height: 1.4; }
.product-card__prices {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.price-tag {
  background: #e8f5e9;
  padding: 5px 10px;
  border-radius: 8px;
  font-size: 0.8rem;
  white-space: nowrap;
}
.price-tag strong { color: #2d6a4f; font-size: 0.95rem; }
.product-card__actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.qty-control {
  display: flex;
  align-items: center;
  gap: 3px;
  background: #f8f9fa;
  border-radius: 8px;
  padding: 3px;
}
.qty-control button {
  width: 30px;
  height: 30px;
  border: 1px solid #dee2e6;
  background: #fff;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-appearance: none;
  appearance: none;
  touch-action: manipulation;
}
.qty-control button:hover { background: #e9ecef; }
.qty-control button:active { background: #dee2e6; }
.qty-control input {
  width: 40px;
  text-align: center;
  border: none;
  background: transparent;
  font-weight: 600;
  font-size: 0.9rem;
  -moz-appearance: textfield;
}
.qty-control input::-webkit-outer-spin-button,
.qty-control input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.qty-control .qty-label { font-size: 0.75rem; color: #666; min-width: 22px; }
.add-to-cart-btn {
  background: #2d6a4f;
  color: #fff;
  border: none;
  padding: 8px 14px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.85rem;
  flex: 1;
  min-width: 80px;
  transition: background 0.2s;
  -webkit-appearance: none;
  appearance: none;
  touch-action: manipulation;
}
.add-to-cart-btn:hover { background: #1b4332; }
.add-to-cart-btn:active { transform: scale(0.97); }

/* ===== BACK BUTTON ===== */
.back-btn {
  background: none;
  border: none;
  color: #2d6a4f;
  font-weight: 600;
  cursor: pointer;
  padding: 8px 0;
  margin-bottom: 12px;
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  -webkit-appearance: none;
  appearance: none;
}
.back-btn:hover { text-decoration: underline; }

/* ===== CART SIDEBAR ===== */
.cart-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4);
  z-index: 200;
  display: none;
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}
.cart-overlay.active { display: block; }

.cart-sidebar {
  position: fixed;
  top: 0; right: -100%;
  width: 400px;
  max-width: 100vw;
  height: 100vh;
  height: 100dvh;
  background: #fff;
  z-index: 201;
  display: flex;
  flex-direction: column;
  transition: right 0.3s ease;
  box-shadow: -4px 0 20px rgba(0,0,0,0.1);
}
.cart-sidebar.active { right: 0; }
.cart-sidebar__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid #e9ecef;
  flex-shrink: 0;
}
.cart-sidebar__header h2 { font-size: 1.15rem; }
.cart-close {
  background: rgba(45,106,79,0.1);
  border: 2px solid #2d6a4f;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  color: #2d6a4f;
  padding: 6px 16px;
  border-radius: 20px;
  transition: all 0.2s;
  -webkit-appearance: none;
  appearance: none;
}
.cart-close:hover { background: #2d6a4f; color: #fff; }
.cart-close:active { transform: scale(0.96); }
.cart-sidebar__body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px 20px;
}
.cart-empty { text-align: center; color: #999; padding: 40px 0; font-size: 0.9rem; }
.cart-item {
  display: flex;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid #f0f0f0;
}
.cart-item__info { flex: 1; min-width: 0; }
.cart-item__name { font-weight: 600; font-size: 0.9rem; }
.cart-item__details { font-size: 0.78rem; color: #666; margin: 2px 0; }
.cart-item__price { font-weight: 700; color: #2d6a4f; font-size: 0.9rem; }
.cart-item__remove {
  background: none;
  border: none;
  color: #c00;
  cursor: pointer;
  font-size: 0.85rem;
  padding: 4px 8px;
  -webkit-appearance: none;
  appearance: none;
  touch-action: manipulation;
}
.cart-sidebar__footer {
  padding: 16px 20px;
  border-top: 1px solid #e9ecef;
  flex-shrink: 0;
}
.cart-total {
  display: flex;
  justify-content: space-between;
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 12px;
}

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 300;
  display: none;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}
.modal-overlay.active { display: flex; }
.modal {
  background: #fff;
  border-radius: 16px 16px 0 0;
  width: 100%;
  max-width: 500px;
  max-height: 85vh;
  max-height: 85dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  animation: slideUp 0.3s ease;
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
.modal__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid #e9ecef;
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 1;
}
.modal__header h2 { font-size: 1.1rem; }
.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: #666;
  padding: 4px 8px;
  -webkit-appearance: none;
  appearance: none;
}
.modal__body, .modal__footer { padding: 16px 20px; }
.modal__footer { border-top: 1px solid #e9ecef; }
.modal-success { text-align: center; }
.modal-success .modal__body p { margin-bottom: 8px; }

/* ===== FORM ===== */
.form-group { margin-bottom: 14px; }
.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 5px;
  font-size: 0.85rem;
}
.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 10px 12px;
  border: 2px solid #dee2e6;
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
  transition: border-color 0.2s;
  -webkit-appearance: none;
  appearance: none;
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: #2d6a4f;
}
.form-inline {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.form-inline input, .form-inline select { flex: 1; min-width: 100px; padding: 8px 10px; border: 2px solid #dee2e6; border-radius: 6px; }
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.form-grid .form-group:last-child { grid-column: 1 / -1; }
.form-hint { font-size: 0.78rem; color: #999; margin-top: 6px; text-align: center; }

/* ===== ADMIN ===== */
.admin-page { background: #f0f2f5; }
.admin-nav {
  background: #1a1a2e;
  color: #fff;
  padding: 10px 0;
}
.admin-nav .container { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.admin-nav__brand { font-weight: 800; font-size: 1rem; white-space: nowrap; }
.admin-nav__links { display: flex; gap: 8px; flex-wrap: wrap; }
.admin-nav__links a {
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.8rem;
  transition: background 0.2s;
  white-space: nowrap;
}
.admin-nav__links a:hover, .admin-nav__links a.active { background: rgba(255,255,255,0.1); }
.admin-layout { display: flex; flex-direction: column; gap: 16px; padding: 16px 0; }
.admin-card {
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.admin-card h3 { margin-bottom: 12px; font-size: 1rem; }
.admin-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}
.admin-table th, .admin-table td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid #e9ecef;
  white-space: nowrap;
}
.admin-table th { background: #f8f9fa; font-weight: 700; font-size: 0.75rem; text-transform: uppercase; color: #666; }
.admin-table tr:hover td { background: #f8f9fa; }

/* ===== STATUS ===== */
.status {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}
.status-pending { background: #fff3cd; color: #856404; }
.status-confirmed { background: #cce5ff; color: #004085; }
.status-delivered { background: #d4edda; color: #155724; }
.status-cancelled { background: #f8d7da; color: #721c24; }

/* ===== LOGIN ===== */
.admin-login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #1a1a2e, #16213e);
  padding: 16px;
}
.login-box {
  background: #fff;
  padding: 32px 24px;
  border-radius: 16px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}
.login-box h1 { text-align: center; margin-bottom: 20px; font-size: 1.2rem; }
.alert { padding: 10px; border-radius: 8px; margin-bottom: 14px; font-size: 0.85rem; }
.alert-error { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }

/* ===== SUCCESS PAGE ===== */
.success-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 16px;
}
.success-card {
  background: #fff;
  padding: 32px 20px;
  border-radius: 16px;
  max-width: 500px;
  width: 100%;
  text-align: center;
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
}
.success-icon { font-size: 3.5rem; margin-bottom: 12px; }
.success-card h1 { margin-bottom: 12px; font-size: 1.3rem; }
.success-card p { margin-bottom: 6px; font-size: 0.9rem; }
.success-card hr { margin: 16px 0; border: none; border-top: 1px solid #e9ecef; }
.success-card .btn-primary { display: inline-block; margin-top: 12px; }
.order-items-list { list-style: none; text-align: left; }
.order-items-list li {
  padding: 8px 0;
  border-bottom: 1px solid #f0f0f0;
  font-size: 0.85rem;
}

/* ===== COMPOSITION TOGGLE ===== */
.comp-toggle {
  background: none;
  border: 1px dashed #2d6a4f;
  color: #2d6a4f;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.78rem;
  margin-bottom: 8px;
  transition: all 0.2s;
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
}
.comp-toggle:hover { background: #e8f5e9; }
.comp-detail { font-size: 0.82rem; }
.comp-detail > div { border-bottom: 1px solid #e9ecef; padding: 3px 0; }
.comp-detail > div:last-child { border-bottom: none; }

/* ===== LOADING ===== */
.loading::after {
  content: '';
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid #e9ecef;
  border-top-color: #2d6a4f;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-left: 8px;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== TOAST NOTIFICATION ===== */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #2d6a4f;
  color: #fff;
  padding: 10px 24px;
  border-radius: 24px;
  font-size: 0.9rem;
  font-weight: 600;
  z-index: 400;
  opacity: 0;
  transition: all 0.3s ease;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  white-space: nowrap;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ===== MOBILE BOTTOM BAR ===== */
.mobile-bottom-bar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #fff;
  border-top: 1px solid #e9ecef;
  z-index: 150;
  padding: 8px 12px;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.08);
}
.mobile-bottom-bar__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.mobile-bottom-bar .cart-btn-mobile {
  background: #2d6a4f;
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  justify-content: center;
  -webkit-appearance: none;
  appearance: none;
}
.mobile-bottom-bar .cart-btn-mobile:active { transform: scale(0.97); }
.mobile-bottom-bar .cart-badge-mobile {
  background: #ff6b35;
  color: #fff;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
}
.mobile-bottom-bar .cabinet-link-mobile {
  color: #2d6a4f;
  font-weight: 600;
  font-size: 0.85rem;
  padding: 8px 12px;
  border: 2px solid #2d6a4f;
  border-radius: 12px;
  white-space: nowrap;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .container { padding: 0 10px; }
  .header { padding: 14px 0; }
  .header__logo { font-size: 1rem; }
  .header__subtitle { display: none; }
  .header__right .cabinet-link { display: none; }
  .cart-btn { padding: 8px 14px; font-size: 0.85rem; min-height: 40px; }
  .cart-btn span.cart-btn-text { display: none; }
  
  .categories-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .category-card { padding: 14px 8px; }
  .category-icon { font-size: 2rem; }
  .category-name { font-size: 0.82rem; }
  
  .products-grid { grid-template-columns: 1fr; gap: 10px; }
  .product-card__image { height: 140px; }
  .product-card__body { padding: 10px; }
  .product-card__name { font-size: 0.95rem; }
  .product-card__prices { gap: 6px; }
  .price-tag { font-size: 0.75rem; padding: 4px 8px; }
  .price-tag strong { font-size: 0.85rem; }
  
  .qty-control button { width: 28px; height: 28px; font-size: 0.9rem; }
  .qty-control input { width: 36px; font-size: 0.85rem; }
  .add-to-cart-btn { font-size: 0.8rem; padding: 8px 10px; min-width: 60px; }
  
  .step h2 { font-size: 1rem; }
  
  .cart-sidebar { width: 100vw; }
  .cart-sidebar__header { padding: 14px 16px; }
  .cart-sidebar__header h2 { font-size: 1rem; }
  .cart-sidebar__body { padding: 10px 16px; }
  .cart-sidebar__footer { padding: 14px 16px; }
  
  .modal { border-radius: 16px 16px 0 0; max-height: 90vh; max-height: 90dvh; }
  .modal__header { padding: 14px 16px; }
  .modal__body, .modal__footer { padding: 14px 16px; }
  
  .form-grid { grid-template-columns: 1fr; }
  .form-inline { flex-direction: column; align-items: stretch; }
  .form-inline input, .form-inline select { min-width: auto; }
  
  .admin-nav__brand { font-size: 0.85rem; }
  .admin-nav__links a { font-size: 0.75rem; padding: 3px 8px; }
  .admin-card { padding: 12px; }
  .admin-table { font-size: 0.75rem; }
  .admin-table th, .admin-table td { padding: 6px 8px; }
  
  .success-card { padding: 24px 16px; }
  .success-icon { font-size: 3rem; }
  
  .mobile-bottom-bar { display: block; }
  body.has-mobile-bar { padding-bottom: 64px; }
}

@media (max-width: 380px) {
  .categories-grid { grid-template-columns: repeat(2, 1fr); gap: 6px; }
  .category-card { padding: 10px 6px; }
  .category-icon { font-size: 1.6rem; }
  .product-card__image { height: 120px; }
  .header__logo { font-size: 0.9rem; }
  .cart-btn { padding: 4px 10px; font-size: 0.75rem; }
}

/* ===== DESKTOP OVERRIDES ===== */
@media (min-width: 769px) {
  .modal-overlay {
    align-items: center;
    padding: 16px;
  }
  .modal {
    border-radius: 16px;
    max-height: 90vh;
    animation: fadeIn 0.2s ease;
  }
  @keyframes fadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
  }
  .mobile-bottom-bar { display: none !important; }
  body.has-mobile-bar { padding-bottom: 0; }
}
