/* ===== Reset & Base ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --teal: #3d9b8f;
  --teal-dark: #2d7d73;
  --teal-light: #e8f5f3;
  --dark: #2a2a2a;
  --text: #333;
  --text-light: #666;
  --text-muted: #999;
  --bg: #f5f5f5;
  --white: #fff;
  --border: #e0e0e0;
  --border-light: #eee;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 -2px 12px rgba(0, 0, 0, 0.12);
  --radius: 8px;
  --radius-lg: 24px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

html {
  font-family: var(--font);
  font-size: 16px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}

body {
  overflow-x: hidden;
}

@supports (padding: env(safe-area-inset-bottom)) {
  body {
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }
}

button, a {
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100vh;
  background: var(--white);
}

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

a:hover {
  color: var(--teal-dark);
}

img {
  max-width: 100%;
  height: auto;
}

/* ===== App Shell ===== */
.app-header {
  background: var(--white);
  border-bottom: 1px solid var(--border-light);
  position: sticky;
  top: 0;
  z-index: 100;
}

.app-header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.app-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.app-logo-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.app-logo-icon i {
  font-size: 1.4rem;
  color: var(--dark);
}

.app-logo-text h1 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--dark);
  line-height: 1.2;
}

.app-logo-text span {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.2;
}

.header-nav {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-nav a,
.header-nav button {
  font-family: inherit;
  font-size: 0.85rem;
  line-height: inherit;
  color: var(--text-light);
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px 12px;
  border-radius: var(--radius);
  transition: background 0.2s, color 0.2s;
}

.header-nav a:hover,
.header-nav button:hover {
  background: var(--teal-light);
  color: var(--teal);
}

.header-nav .btn-login {
  background: var(--teal);
  color: var(--white);
  font-weight: 600;
  padding: 8px 16px;
}

.header-nav .btn-login:hover {
  background: var(--teal-dark);
  color: var(--white);
}

/* Logout form styling */
.header-nav form {
  display: inline;
}

.header-nav form button {
  font-family: inherit;
  font-size: 0.85rem;
  line-height: inherit;
  color: var(--text-light);
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px 12px;
  border-radius: var(--radius);
}

.header-nav form button:hover {
  background: #fde8e8;
  color: #c0392b;
}

/* ===== Toolbar (categories + search + total + order btn) ===== */
.toolbar {
  background: var(--white);
  border-bottom: 1px solid var(--border-light);
  padding: 12px 20px;
}

.toolbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.category-tabs {
  display: flex;
  gap: 0;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 2px solid var(--teal);
  flex-shrink: 0;
}

.category-tab {
  padding: 8px 20px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  background: var(--white);
  color: var(--text-light);
  border: none;
  transition: background 0.2s, color 0.2s;
  white-space: nowrap;
}

.category-tab:not(:last-child) {
  border-right: 1px solid var(--teal);
}

.category-tab.active {
  background: var(--teal);
  color: var(--white);
}

.category-tab:hover:not(.active) {
  background: var(--teal-light);
  color: var(--teal);
}

.search-box {
  flex: 1;
  min-width: 200px;
  position: relative;
}

.search-box input {
  width: 100%;
  padding: 10px 40px 10px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
  background: var(--white);
}

.search-box input:focus {
  border-color: var(--teal);
}

.search-box .search-icon {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.search-box .search-icon i {
  font-size: 0.95rem;
}

.total-display {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.95rem;
  color: var(--text);
  flex-shrink: 0;
  white-space: nowrap;
}

.total-display .total-label {
  color: var(--text-muted);
}

.total-display .total-value {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--dark);
}

.total-display .total-limit {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.btn-order {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  background: var(--dark);
  color: var(--white);
  border: none;
  border-radius: var(--radius-lg);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
  white-space: nowrap;
}

.btn-order:hover {
  background: #444;
}

.btn-order i {
  font-size: 1rem;
  color: var(--white);
}

/* ===== Product Grid ===== */
.products-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px 20px;
  padding-bottom: 100px;
}

.products-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
}

.product-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--border-light);
  border-right: 1px solid var(--border-light);
  background: var(--white);
  transition: background 0.15s;
}

.product-card:hover {
  background: #fafafa;
}

.product-card[data-hidden="true"] {
  display: none;
}

.product-image {
  width: 60px;
  height: 60px;
  border-radius: var(--radius);
  object-fit: contain;
  flex-shrink: 0;
  background: var(--bg);
  border: 1px solid var(--border-light);
}

.product-image-placeholder {
  width: 60px;
  height: 60px;
  border-radius: var(--radius);
  background: var(--border-light);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--text-muted);
}

.product-image-placeholder i {
  font-size: 1.25rem;
}

.product-info {
  flex: 1;
  min-width: 0;
}

.product-name {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.product-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.product-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.qty-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--teal);
  background: var(--white);
  color: var(--teal);
  font-size: 1.2rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s;
  padding: 0;
  line-height: 1;
}

.qty-btn:hover {
  background: var(--teal);
  color: var(--white);
}

.qty-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.qty-btn:disabled:hover {
  background: var(--white);
  color: var(--teal);
}

.qty-value {
  font-size: 1.15rem;
  font-weight: 600;
  min-width: 24px;
  text-align: center;
  color: var(--dark);
}

/* ===== Sticky Bottom Bar (Mobile) ===== */
.bottom-bar {
  display: none;
}

/* ===== Reset Button (Desktop) ===== */
.reset-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  background: var(--dark);
  color: var(--white);
  border: none;
  border-radius: var(--radius);
  font-size: 0.85rem;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: background 0.2s;
  z-index: 50;
}

.reset-btn:hover {
  background: #444;
}

.reset-btn i {
  font-size: 0.9rem;
  color: var(--white);
}

/* ===== Flash Messages ===== */
.flash {
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px 20px;
}

.flash-alert {
  background: #fde8e8;
  color: #c0392b;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 0.9rem;
}

.flash-notice {
  background: #e8f5e9;
  color: #2e7d32;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 0.9rem;
}

/* ===== Auth Pages (Login, Signup) ===== */
.auth-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--bg);
}

.auth-card {
  background: var(--white);
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow);
}

.auth-card .auth-logo {
  text-align: center;
  margin-bottom: 32px;
}

.auth-card .auth-logo i {
  font-size: 2.5rem;
  color: var(--teal);
}

.auth-card .auth-logo h2 {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--dark);
  margin-top: 12px;
}

.auth-card .auth-logo p {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 6px;
}

.form-group input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
}

.form-group input:focus {
  border-color: var(--teal);
}

.password-field-wrapper {
  position: relative;
}

.password-field-wrapper input {
  padding-right: 44px;
}

.password-toggle {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: color 0.2s;
}

.password-toggle:hover {
  color: var(--teal);
}

.password-toggle i {
  font-size: 1.1rem;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.btn-primary {
  width: 100%;
  padding: 12px;
  background: var(--teal);
  color: var(--white);
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  margin-top: 8px;
}

.btn-primary:hover {
  background: var(--teal-dark);
}

.auth-links {
  margin-top: 20px;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.auth-links a {
  color: var(--teal);
  font-weight: 500;
}

.auth-error {
  background: #fde8e8;
  color: #c0392b;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 0.85rem;
  margin-bottom: 16px;
}

/* ===== Account / Settings Pages ===== */
.settings-container {
  max-width: 700px;
  margin: 0 auto;
  padding: 32px 20px;
}

.settings-header {
  margin-bottom: 28px;
}

.settings-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--dark);
}

.settings-header p {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.settings-card {
  background: var(--white);
  border-radius: 12px;
  padding: 24px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.settings-card h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--dark);
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-light);
}

.settings-info {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
}

.settings-info:not(:last-child) {
  border-bottom: 1px solid var(--border-light);
}

.settings-info .info-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  min-width: 100px;
}

.settings-info .info-value {
  font-size: 0.95rem;
  color: var(--text);
  font-weight: 500;
}

.settings-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}

.btn-settings {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--white);
  color: var(--text);
  text-align: center;
}

.btn-settings:hover {
  border-color: var(--teal);
  color: var(--teal);
}

.btn-danger {
  color: #c0392b;
  border-color: #fde8e8;
  background: #fef5f5;
}

.btn-danger:hover {
  background: #fde8e8;
  color: #c0392b;
  border-color: #c0392b;
}

/* ===== Points exceeded ===== */
.points-exceeded .total-value {
  color: #c0392b !important;
}

.points-exceeded .btn-order {
  opacity: 0.5;
  pointer-events: none;
}

/* ===== No Products ===== */
.no-products {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.no-products i {
  font-size: 2.5rem;
  color: var(--border);
  margin-bottom: 12px;
}

.no-products p {
  font-size: 1rem;
}

/* ===== Market Closed ===== */
.market-closed {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-height: calc(100vh - 100px);
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.market-closed i {
  font-size: 2.5rem;
  color: var(--border);
  margin-bottom: 12px;
}

.market-closed p {
  font-size: 1rem;
}

/* ===== Orders Page ===== */
.orders-container {
  max-width: 800px;
}

.order-card {
  padding: 0;
  overflow: hidden;
}

.order-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: var(--bg);
  border-bottom: 1px solid var(--border-light);
}

.order-header-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.order-id {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--dark);
}

.order-date {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.order-status {
  font-size: 0.8rem;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.order-status--pending {
  background: #fff3e0;
  color: #e67e22;
}

.order-status--completed {
  background: #e8f5e9;
  color: #2e7d32;
}

.order-status--cancelled {
  background: #fde8e8;
  color: #c0392b;
}

.order-items {
  padding: 0 24px;
}

.order-item {
  display: flex;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-light);
  gap: 12px;
}

.order-item:last-child {
  border-bottom: none;
}

.order-item-name {
  flex: 1;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
}

.order-item-details {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.order-item-total {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--dark);
  min-width: 70px;
  text-align: right;
}

.order-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-top: 1px solid var(--border-light);
  background: var(--bg);
}

.order-total {
  display: flex;
  align-items: center;
  gap: 8px;
}

.order-total-label {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.order-total-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--dark);
}

.btn-cancel-order {
  display: inline-flex;
  align-items: center;
  padding: 8px 16px;
  background: var(--white);
  color: #c0392b;
  border: 1px solid #c0392b;
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-cancel-order:hover {
  background: #c0392b;
  color: var(--white);
}

.no-orders {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

.no-orders i {
  font-size: 2.5rem;
  color: var(--border);
  margin-bottom: 12px;
}

.no-orders p {
  font-size: 1rem;
  margin-bottom: 16px;
}

/* ===== Order Confirmation Modal ===== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(2px);
}

.modal-overlay.active {
  display: flex;
}

.modal-card {
  background: var(--white);
  border-radius: 16px;
  width: 100%;
  max-width: 480px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
  animation: modal-enter 0.25s ease-out;
}

@keyframes modal-enter {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(8px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
}

.modal-header h2 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--dark);
}

.modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  border-radius: 50%;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.modal-close:hover {
  background: var(--bg);
  color: var(--text);
}

.modal-close i {
  font-size: 1.1rem;
}

.btn-modal-confirm i {
  font-size: 0.9rem;
}

.modal-body {
  padding: 8px 24px;
  overflow-y: auto;
  flex: 1;
}

.modal-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid var(--border-light);
}

.modal-item:last-child {
  border-bottom: none;
}

.modal-item-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.modal-item-name {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.modal-item-details {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.modal-item-total {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--dark);
  white-space: nowrap;
  margin-left: 16px;
}

.modal-footer {
  padding: 20px 24px;
  border-top: 1px solid var(--border-light);
  flex-shrink: 0;
}

.modal-total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.modal-total-label {
  font-size: 0.95rem;
  color: var(--text-muted);
}

.modal-total-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--dark);
}

.modal-actions {
  display: flex;
  gap: 10px;
}

.btn-modal-cancel {
  flex: 1;
  padding: 12px;
  background: var(--white);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-modal-cancel:hover {
  border-color: var(--text-muted);
  background: var(--bg);
}

.btn-modal-confirm {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px;
  background: var(--teal);
  color: var(--white);
  border: none;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-modal-confirm:hover {
  background: var(--teal-dark);
}

/* ===== Hamburger Button (hidden on desktop) ===== */
.hamburger-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text);
  margin-left: auto;
  border-radius: var(--radius);
  -webkit-tap-highlight-color: transparent;
}

.hamburger-btn:hover {
  background: var(--bg);
}

.hamburger-btn .hamburger-icon,
.hamburger-btn .close-icon {
  font-size: 1.15rem;
  color: var(--text);
}

.hamburger-btn .close-icon {
  display: none;
}

.nav-open .hamburger-btn .hamburger-icon {
  display: none;
}

.nav-open .hamburger-btn .close-icon {
  display: block;
}

/* ===== Responsive ===== */

/* --- Tablet / small desktop --- */
@media (max-width: 1024px) {
  .products-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* --- Mobile (≤768px) --- */
@media (max-width: 768px) {
  .app-header-inner {
    padding: 10px 16px;
    flex-wrap: wrap;
  }

  .hamburger-btn {
    display: flex;
  }

  .header-nav {
    display: none;
    flex-direction: column;
    width: 100%;
    gap: 2px;
    padding-top: 8px;
    border-top: 1px solid var(--border-light);
    margin-top: 8px;
  }

  .nav-open .header-nav {
    display: flex;
  }

  .header-nav a,
  .header-nav button {
    width: 100%;
    text-align: left;
    padding: 12px 16px;
    font-size: 0.95rem;
    min-height: 44px;
    display: flex;
    align-items: center;
  }

  .header-nav form {
    display: block;
    width: 100%;
  }

  .header-nav form button {
    width: 100%;
    text-align: left;
    padding: 12px 16px;
    font-size: 0.95rem;
    min-height: 44px;
    display: flex;
    align-items: center;
  }

  .header-nav .btn-login {
    justify-content: center;
    text-align: center;
  }

  .toolbar {
    padding: 10px 16px;
  }

  .toolbar-inner {
    flex-wrap: wrap;
    gap: 10px;
  }

  .category-tabs {
    order: 1;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
    scrollbar-width: none;
  }

  .category-tabs::-webkit-scrollbar {
    display: none;
  }

  .search-box {
    order: 2;
    flex-basis: 100%;
    min-width: 0;
  }

  .search-box input {
    font-size: 1rem;
    padding: 12px 40px 12px 16px;
  }

  .total-display {
    display: none;
  }

  .desktop-total {
    display: none;
  }

  .desktop-order-btn {
    display: none;
  }

  .reset-btn {
    display: none;
  }

  .products-container {
    padding: 8px 20px;
    padding-bottom: 100px;
  }

  .products-grid {
    grid-template-columns: 1fr;
  }

  .product-card {
    border-right: none;
    padding: 12px 0;
    gap: 10px;
  }

  .product-image,
  .product-image-placeholder {
    width: 52px;
    height: 52px;
  }

  .qty-btn {
    width: 36px;
    height: 36px;
    font-size: 1.2rem;
  }

  .bottom-bar {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--white);
    padding: 14px 20px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    align-items: center;
    justify-content: center;
    gap: 16px;
    box-shadow: var(--shadow-lg);
    z-index: 100;
    border-top: 1px solid var(--border-light);
  }

  .bottom-bar .total-display {
    display: flex;
  }

  .bottom-bar .btn-order {
    padding: 12px 20px;
    min-height: 44px;
  }

  .auth-container {
    padding: 16px;
  }

  .auth-card {
    padding: 28px 24px;
  }

  .settings-container {
    padding: 20px 16px;
  }

  .settings-card {
    padding: 20px;
    border-radius: 10px;
  }

  .settings-info {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .order-header {
    padding: 12px 16px;
  }

  .order-items {
    padding: 0 16px;
  }

  .order-footer {
    padding: 12px 16px;
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
  }

  .order-footer .btn-cancel-order {
    text-align: center;
    justify-content: center;
    min-height: 44px;
  }

  .modal-overlay {
    align-items: flex-end;
    padding: 0;
  }

  .modal-card {
    max-width: 100%;
    max-height: 90vh;
    border-radius: 16px 16px 0 0;
    animation: modal-enter-mobile 0.3s ease-out;
  }

  .modal-footer {
    padding: 16px 20px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  }

  .modal-body {
    padding: 8px 20px;
  }

  .modal-header {
    padding: 16px 20px;
  }

  .btn-modal-confirm,
  .btn-modal-cancel {
    min-height: 44px;
  }

  @keyframes modal-enter-mobile {
    from {
      transform: translateY(100%);
    }
    to {
      transform: translateY(0);
    }
  }

  .flash {
    padding: 8px 16px;
  }
}

/* --- Small phones (≤480px) --- */
@media (max-width: 480px) {
  .app-header-inner {
    padding: 8px 12px;
  }

  .app-logo-icon {
    width: 32px;
    height: 32px;
  }

  .app-logo-icon i {
    font-size: 1.1rem;
  }

  .app-logo-text h1 {
    font-size: 1rem;
  }

  .app-logo-text span {
    font-size: 0.72rem;
  }

  .app-logo {
    gap: 8px;
  }

  .toolbar {
    padding: 8px 12px;
  }

  .category-tab {
    padding: 8px 14px;
    font-size: 0.82rem;
  }

  .search-box input {
    padding: 10px 36px 10px 12px;
  }

  .products-container {
    padding: 4px 16px;
    padding-bottom: 100px;
  }

  .product-card {
    padding: 10px 0;
  }

  .product-image,
  .product-image-placeholder {
    width: 48px;
    height: 48px;
  }

  .product-name {
    font-size: 0.88rem;
  }

  .product-meta {
    font-size: 0.75rem;
  }

  .product-controls {
    gap: 6px;
  }

  .qty-btn {
    width: 34px;
    height: 34px;
    font-size: 1.1rem;
  }

  .qty-value {
    font-size: 1rem;
    min-width: 20px;
  }

  .bottom-bar {
    padding: 12px 16px;
    padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
    gap: 10px;
  }

  .bottom-bar .total-value {
    font-size: 1.2rem;
  }

  .bottom-bar .total-limit {
    font-size: 0.78rem;
  }

  .bottom-bar .btn-order {
    padding: 10px 16px;
    font-size: 0.88rem;
  }

  .auth-container {
    padding: 12px;
  }

  .auth-card {
    padding: 24px 18px;
    border-radius: 12px;
  }

  .auth-card .auth-logo {
    margin-bottom: 24px;
  }

  .auth-card .auth-logo h2 {
    font-size: 1.15rem;
  }

  .form-row {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .form-group input {
    padding: 12px 14px;
    font-size: 1rem;
  }

  .settings-container {
    padding: 16px 12px;
  }

  .settings-header h1 {
    font-size: 1.3rem;
  }

  .settings-card {
    padding: 16px;
  }

  .order-header {
    padding: 10px 12px;
    flex-wrap: wrap;
    gap: 6px;
  }

  .order-items {
    padding: 0 12px;
  }

  .order-item {
    flex-wrap: wrap;
    gap: 4px;
  }

  .order-item-name {
    flex-basis: 100%;
  }

  .order-item-details {
    flex: 1;
  }

  .order-footer {
    padding: 10px 12px;
  }

  .modal-header {
    padding: 14px 16px;
  }

  .modal-body {
    padding: 4px 16px;
  }

  .modal-footer {
    padding: 14px 16px;
    padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  }

  .modal-actions {
    flex-direction: column;
    gap: 8px;
  }

  .flash {
    padding: 6px 12px;
  }
}

/* --- Extra-small phones (≤360px) --- */
@media (max-width: 360px) {
  .app-logo-text h1 {
    font-size: 0.92rem;
  }

  .app-logo-text span {
    display: none;
  }

  .category-tab {
    padding: 7px 10px;
    font-size: 0.78rem;
  }

  .product-image,
  .product-image-placeholder {
    width: 42px;
    height: 42px;
  }

  .product-name {
    font-size: 0.82rem;
  }

  .qty-btn {
    width: 30px;
    height: 30px;
    font-size: 1rem;
    border-width: 1.5px;
  }

  .qty-value {
    font-size: 0.95rem;
    min-width: 18px;
  }

  .bottom-bar .total-value {
    font-size: 1.1rem;
  }

  .bottom-bar .btn-order {
    padding: 10px 12px;
    font-size: 0.82rem;
    gap: 4px;
  }

  .auth-card {
    padding: 20px 14px;
  }

  .btn-primary {
    padding: 12px;
    font-size: 0.95rem;
  }

  .modal-total-value {
    font-size: 1.1rem;
  }
}
