:root {
  --off-white: #FAF3E9;
  --mahogany: #4A2A22;
  --teak: #8B5A3C;
  --rattan: #A9744F;
  --mango: #F5B942;
  --mango-dark: #E0A22E;
  --leaf-green: #2E6B3E;
  --slate: #383D3A;
  --card-white: #FFFFFF;

  --font-display: "Fraunces", serif;
  --font-body: "Nunito Sans", sans-serif;
  --font-mono: "IBM Plex Mono", monospace;
}

html {
  scroll-behavior: smooth;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--off-white);
  font-family: var(--font-body);
  color: var(--mahogany);
  -webkit-font-smoothing: antialiased;
}

/* ---------- Store Signboard Header ---------- */

.store-sign {
  background:
    radial-gradient(ellipse at 20% 20%, rgba(255,255,255,0.03), transparent 60%),
    radial-gradient(ellipse at 80% 70%, rgba(255,255,255,0.025), transparent 55%),
    linear-gradient(180deg, var(--slate), #2c302d);
  color: #f2ede2;
  padding: 1.8rem 1.25rem 1.4rem;
  text-align: center;
  border-bottom: 6px solid var(--rattan);
}

.sign-board { max-width: 680px; margin: 0 auto; }

.sign-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--mango);
  margin: 0 0 0.35rem;
}

.sign-title {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 600;
  font-size: clamp(1.6rem, 5vw, 2.5rem);
  margin: 0;
  letter-spacing: 0.01em;
  line-height: 1.15;
}

.sign-tagline {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.88rem;
  opacity: 0.85;
  margin: 0.4rem 0 0;
}

.header-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1.2rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}

.sync-status {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  margin: 0;
  opacity: 0.85;
}
.sync-ok { color: #8fd39a; opacity: 1; }
.sync-fail { color: #e08a8a; opacity: 1; }

.btn-header-reset {
  background: rgba(255, 255, 255, 0.12);
  color: #f2ede2;
  border: 1px solid rgba(255, 255, 255, 0.3);
  font-size: 0.75rem;
  padding: 0.4rem 0.85rem;
  border-radius: 6px;
  min-height: 36px;
}
.btn-header-reset:hover {
  background: rgba(255, 255, 255, 0.22);
}

/* ---------- Notices & Toast Slot ---------- */

.notice-slot { max-width: 1240px; margin: 0 auto; padding: 0 1rem; }

.notice {
  margin-top: 1rem;
  padding: 0.75rem 1.1rem;
  border-radius: 6px;
  font-weight: 700;
  font-size: 0.9rem;
  animation: fadeIn 0.2s ease-out;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
.notice-success { background: #e4f2e6; color: var(--leaf-green); border: 1px solid #bfe0c6; }
.notice-error { background: #f7e6e2; color: #9a3b2a; border: 1px solid #eac3b8; }
.notice-info { background: #eaf1f8; color: #2d557a; border: 1px solid #c0d4e8; }

/* ---------- Main Layout Grid ---------- */

.layout {
  max-width: 1240px;
  margin: 0 auto;
  padding: 1.25rem 1rem;
  display: grid;
  grid-template-columns: 1.45fr 1fr;
  gap: 1.25rem;
}

.report-panel { grid-column: 1 / -1; }

.panel {
  background: var(--card-white);
  border-radius: 10px;
  padding: 1.3rem;
  box-shadow: 0 4px 16px rgba(74, 42, 34, 0.07);
  border-top: 4px solid var(--teak);
}

.panel h2 {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--mahogany);
  margin: 0;
  font-size: 1.35rem;
}

.panel-subtitle {
  font-size: 0.8rem;
  color: var(--teak);
  margin: 0.2rem 0 0;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.85rem;
  flex-wrap: wrap;
  margin-bottom: 1.1rem;
}

.panel-header-simple {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.9rem;
}

/* ---------- Catalog Filtering & Components ---------- */

.catalog-filters {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  align-items: center;
}

.category-select, .search-input, .qty-input, .paid-input {
  font-family: var(--font-body);
  border: 1.5px solid #e3d6c6;
  border-radius: 6px;
  padding: 0.55rem 0.8rem;
  font-size: 0.9rem;
  color: var(--mahogany);
  background: var(--off-white);
  outline: none;
  min-height: 42px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.category-select:focus, .search-input:focus, .paid-input:focus {
  border-color: var(--rattan);
  box-shadow: 0 0 0 2px rgba(245, 185, 66, 0.3);
}

.category-select {
  cursor: pointer;
  font-weight: 600;
  max-width: 100%;
}

.search-input { min-width: 180px; }

.catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.85rem;
  max-height: 580px;
  overflow-y: auto;
  padding-right: 0.25rem;
}

.product-card {
  background: var(--off-white);
  border: 1px solid #ecdfce;
  border-radius: 8px;
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.45rem;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}
.product-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(74, 42, 34, 0.08);
}

.product-info-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.product-name {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--mahogany);
  margin: 0;
  line-height: 1.25;
}

.product-price {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--teak);
  margin: 0;
  font-size: 0.95rem;
}

.stock-tag {
  display: inline-block;
  width: fit-content;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
}
.stock-ok { background: #e4f2e6; color: var(--leaf-green); }
.stock-low { background: #fff1d6; color: #a46b0a; border: 1px dashed #f5b942; }
.stock-out { background: #f2e3e0; color: #9a3b2a; }

.product-controls { display: flex; gap: 0.45rem; margin-top: 0.35rem; }
.qty-input { width: 55px; text-align: center; }

/* ---------- Buttons ---------- */

.btn {
  border: none;
  border-radius: 6px;
  font-family: var(--font-body);
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.05s ease, background-color 0.15s ease;
  min-height: 40px;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--mango);
  color: var(--mahogany);
  padding: 0.55rem 0.85rem;
  font-size: 0.88rem;
}
.btn-primary:hover:not(:disabled) { background: var(--mango-dark); }

.btn-add {
  flex: 1;
}

.btn-secondary {
  background: var(--off-white);
  color: var(--mahogany);
  border: 1px solid #d8c8b4;
  padding: 0.45rem 0.8rem;
}
.btn-secondary:hover { background: #eee4d4; }

.btn-subtle {
  background: transparent;
  color: #9a3b2a;
  border: 1px solid #eac3b8;
  padding: 0.3rem 0.65rem;
  font-size: 0.78rem;
  min-height: 32px;
}
.btn-subtle:hover { background: #fdeee9; }

.btn-remove {
  background: transparent;
  color: #9a3b2a;
  border: 1px solid #eac3b8;
  padding: 0.2rem 0.55rem;
  font-size: 1.1rem;
  border-radius: 4px;
  min-height: 32px;
}
.btn-remove:hover { background: #fdeee9; }

.btn-receipt-view {
  background: #f7ede1;
  color: var(--teak);
  border: 1px solid #dfcfbc;
  font-size: 0.75rem;
  padding: 0.3rem 0.6rem;
  border-radius: 4px;
  min-height: 32px;
}
.btn-receipt-view:hover { background: #ebdcc9; }

/* ---------- Cart Panel ---------- */

.cart-slot { min-height: 100px; max-height: 280px; overflow-y: auto; }

.cart-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.cart-table th {
  text-align: left;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--teak);
  border-bottom: 2px solid #ecdfce;
  padding: 0.5rem 0.35rem;
}
.cart-table td { padding: 0.5rem 0.35rem; border-bottom: 1px solid #f2e9dd; }

.cart-summary {
  margin-top: 1.2rem;
  padding-top: 1rem;
  border-top: 2px dashed #ecdfce;
}

.summary-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 1.15rem;
  font-family: var(--font-mono);
  margin-bottom: 0.8rem;
}
.cart-total-amount { color: var(--leaf-green); font-size: 1.4rem; }

.paid-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
}

.paid-input-group {
  display: flex;
  align-items: stretch;
  margin-bottom: 0.9rem;
}
.currency-prefix {
  font-family: var(--font-mono);
  font-weight: 700;
  display: flex;
  align-items: center;
  padding: 0.55rem 0.75rem;
  background: #ecdccb;
  border: 1.5px solid #e3d6c6;
  border-right: none;
  border-radius: 6px 0 0 6px;
  color: var(--mahogany);
}
.paid-input-group .paid-input {
  border-radius: 0 6px 6px 0;
  width: 100%;
}

.btn-checkout {
  width: 100%;
  padding: 0.85rem;
  font-size: 1rem;
  min-height: 48px;
}

/* ---------- Session Report & Analytics ---------- */

.report-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.4rem;
}

.stat-card {
  background: var(--off-white);
  border-radius: 8px;
  padding: 0.9rem 1.15rem;
  border-left: 4px solid var(--mango);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.stat-card-wide {
  grid-column: 1 / -1;
  border-left-color: var(--leaf-green);
}

.stat-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--teak);
  letter-spacing: 0.05em;
}

.stat-value {
  font-family: var(--font-mono);
  font-size: 1.3rem;
  color: var(--mahogany);
}

.best-seller-text {
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 700;
  color: var(--leaf-green);
}

.transactions-heading {
  font-family: var(--font-display);
  font-size: 1.1rem;
  color: var(--teak);
  margin: 0 0 0.8rem;
}

.transactions-list {
  max-height: 380px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.transaction-card {
  border: 1px solid #ecdfce;
  background: #fffdf9;
  border-radius: 8px;
  padding: 0.85rem 1rem;
  font-size: 0.85rem;
}

.transaction-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #f0e6d8;
  padding-bottom: 0.45rem;
  margin-bottom: 0.5rem;
}
.trans-id {
  font-family: var(--font-mono);
  color: var(--mahogany);
  margin-right: 0.6rem;
  font-size: 0.9rem;
}
.trans-date {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--teak);
}

.transaction-details-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.transaction-details-list li {
  display: flex;
  justify-content: space-between;
  font-size: 0.84rem;
}
.detail-item-name { color: var(--mahogany); }
.detail-item-price { font-family: var(--font-mono); color: var(--teak); font-weight: 600; }

.transaction-totals {
  display: flex;
  gap: 1.2rem;
  flex-wrap: wrap;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  margin-top: 0.6rem;
  padding-top: 0.55rem;
  border-top: 1px dashed #ecdccb;
  color: var(--slate);
}

.empty-state { color: #a08d78; font-style: italic; font-size: 0.9rem; }

/* ---------- Mobile Bottom Floating Cart Bar ---------- */

.mobile-cart-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(44, 48, 45, 0.94);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #f2ede2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1.25rem;
  box-shadow: 0 -4px 18px rgba(0, 0, 0, 0.28);
  z-index: 900;
  border-top: 2px solid var(--mango);
  animation: slideUp 0.2s ease-out;
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.mobile-cart-info {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}
.mobile-cart-count {
  font-size: 0.72rem;
  color: #d1c6b8;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.mobile-cart-total {
  font-family: var(--font-mono);
  font-size: 1.25rem;
  color: var(--mango);
}

.btn-mobile-view-cart {
  padding: 0.55rem 1.1rem;
  font-size: 0.9rem;
  text-decoration: none;
  min-height: 42px;
}

/* Hide mobile cart bar on desktop */
@media (min-width: 901px) {
  .mobile-cart-bar {
    display: none !important;
  }
}

/* ---------- Thermal Receipt Modal ---------- */

.receipt-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.receipt-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(30, 20, 15, 0.68);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

.receipt-dialog {
  position: relative;
  z-index: 1001;
  background: #ffffff;
  border-radius: 8px;
  padding: 1.5rem;
  max-width: 400px;
  width: 92%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.35);
  animation: modalPop 0.2s ease-out;
}
@keyframes modalPop {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}

.receipt-close-btn {
  position: absolute;
  top: 0.65rem;
  right: 0.85rem;
  background: transparent;
  border: none;
  font-size: 1.6rem;
  color: #777;
  cursor: pointer;
  line-height: 1;
  padding: 0.2rem 0.5rem;
}
.receipt-close-btn:hover { color: #111; }

.thermal-receipt {
  font-family: var(--font-mono);
  color: #222;
  font-size: 0.82rem;
}

.receipt-header {
  text-align: center;
  margin-bottom: 0.6rem;
}
.receipt-store-name {
  font-family: var(--font-display);
  font-size: 1.25rem;
  margin: 0;
}
.receipt-sub {
  font-size: 0.75rem;
  margin: 0.2rem 0;
  color: #555;
}
.receipt-meta {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0.3rem 0;
  color: #777;
}

.receipt-divider {
  border: none;
  border-top: 1px dashed #777;
  margin: 0.6rem 0;
}

.receipt-info-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: #444;
}

.receipt-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
  margin: 0.4rem 0;
}
.receipt-table th {
  border-bottom: 1px dashed #888;
  padding: 0.35rem 0;
  font-weight: 700;
}
.receipt-table td {
  padding: 0.3rem 0;
}

.receipt-totals-section {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.82rem;
}
.receipt-row {
  display: flex;
  justify-content: space-between;
}
.total-highlight {
  font-weight: 700;
  font-size: 0.95rem;
}

.receipt-footer {
  text-align: center;
  margin-top: 0.8rem;
}
.thank-you {
  font-weight: 700;
  margin: 0 0 0.2rem;
}
.receipt-footer .tagline {
  font-size: 0.7rem;
  color: #666;
  margin: 0;
}

.receipt-actions {
  margin-top: 1.2rem;
  display: flex;
  justify-content: center;
}
.btn-print {
  width: 100%;
  padding: 0.75rem;
  font-size: 0.95rem;
  min-height: 44px;
}

.hidden { display: none !important; }

/* ---------- Responsive Mobile & Split-Screen Viewports ---------- */

@media (max-width: 900px) {
  body {
    padding-bottom: 74px; /* Space for fixed bottom cart bar */
  }
  .layout {
    grid-template-columns: 1fr;
    gap: 1rem;
    padding: 1rem 0.75rem;
  }
}

@media (max-width: 640px) {
  .panel {
    padding: 1.1rem;
  }
  .panel-header {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }
  .catalog-filters {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
  }
  .category-select,
  .search-input {
    width: 100%;
    min-height: 44px;
  }
  .product-controls {
    flex-wrap: nowrap;
  }
  .qty-input {
    min-height: 42px;
  }
  .btn-add {
    min-height: 42px;
  }
}

@media (max-width: 440px) {
  .catalog-grid {
    grid-template-columns: 1fr;
  }
  .sign-title {
    font-size: 1.6rem;
  }
  .receipt-dialog {
    width: 96%;
    padding: 1.1rem;
  }
}

/* ---------- Print Media Query ---------- */

@media print {
  body * {
    visibility: hidden;
  }
  .receipt-modal,
  .receipt-modal * {
    visibility: visible;
  }
  .receipt-modal {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: auto;
    background: transparent;
  }
  .receipt-backdrop,
  .receipt-close-btn,
  .receipt-actions {
    display: none !important;
  }
  .receipt-dialog {
    box-shadow: none;
    border: none;
    width: 100%;
    max-width: 100%;
    padding: 0;
  }
}
