/* Core Variables & Design System */
:root {
  --font-title: 'Prompt', 'Inter', sans-serif;
  --font-body: 'Prompt', 'Inter', sans-serif;

  /* Color Palette based on Screenshot */
  --primary-hue: 265;
  --primary: hsl(var(--primary-hue), 70%, 50%);
  --primary-dark: #4c1d95; /* Deep purple */
  --primary-light: #f3e8ff; /* Lavender */
  
  --accent-pink: #ec4899;
  --accent-pink-gradient: linear-gradient(135deg, #f472b6, #db2777);

  --success: #059669;
  --success-light: #d1fae5;
  
  --danger: #dc2626;
  --danger-light: #fee2e2;

  --bg-app: #fdfafb;
  --bg-card: rgba(255, 255, 255, 0.9);
  --border-card: rgba(255, 255, 255, 0.6);
  --border-subtle: #eae2f8;

  --text-main: #1e1b4b; /* Dark purple-blue */
  --text-muted: #6b7280;

  --shadow-sm: 0 2px 4px rgba(0,0,0,0.02), 0 1px 2px rgba(0,0,0,0.01);
  --shadow-md: 0 4px 6px -1px rgba(109, 40, 217, 0.05), 0 2px 4px -1px rgba(109, 40, 217, 0.03);
  --shadow-lg: 0 10px 25px -5px rgba(109, 40, 217, 0.08), 0 8px 10px -6px rgba(109, 40, 217, 0.04);
  --shadow-glow: 0 0 15px 1px rgba(192, 132, 252, 0.3);
  
  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 24px;
}

/* Reset & Global Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-body);
  color: var(--text-main);
  background-color: var(--bg-app);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  padding: 30px 20px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  transition: background-color 0.8s ease; /* Smooth page background transition */
}

/* Fallback / Default Variables */
:root {
  --theme-bubble-1: #fbcfe8;
  --theme-bubble-2: #e9d5ff;
  --theme-bubble-3: #ccfbf1;
}

/* --- Background Themes per Day of the Thai Week --- */
/* Sunday: Red / Rose */
body.theme-sunday {
  --bg-app: #fff1f2;
  --theme-bubble-1: #fecdd3;
  --theme-bubble-2: #ffe4e6;
  --theme-bubble-3: #ffd1d1;
}
/* Monday: Yellow */
body.theme-monday {
  --bg-app: #fefce8;
  --theme-bubble-1: #fef08a;
  --theme-bubble-2: #fef9c3;
  --theme-bubble-3: #fffbeb;
}
/* Tuesday: Pink */
body.theme-tuesday {
  --bg-app: #fdf2f8;
  --theme-bubble-1: #fbcfe8;
  --theme-bubble-2: #fce7f3;
  --theme-bubble-3: #fae8ff;
}
/* Wednesday: Green */
body.theme-wednesday {
  --bg-app: #f0fdf4;
  --theme-bubble-1: #bbf7d0;
  --theme-bubble-2: #dcfce7;
  --theme-bubble-3: #e8f5e9;
}
/* Thursday: Orange / Peach */
body.theme-thursday {
  --bg-app: #fff7ed;
  --theme-bubble-1: #fed7aa;
  --theme-bubble-2: #ffedd5;
  --theme-bubble-3: #ffe0b2;
}
/* Friday: Blue / Sky */
body.theme-friday {
  --bg-app: #f0f9ff;
  --theme-bubble-1: #bae6fd;
  --theme-bubble-2: #e0f2fe;
  --theme-bubble-3: #e1f5fe;
}
/* Saturday: Purple / Violet */
body.theme-saturday {
  --bg-app: #faf5ff;
  --theme-bubble-1: #e9d5ff;
  --theme-bubble-2: #f3e8ff;
  --theme-bubble-3: #f3e5f5;
}

/* Floating background circles for glassmorphism */
.bg-bubble {
  position: absolute;
  border-radius: 50%;
  filter: blur(85px);
  z-index: -1;
  opacity: 0.35;
  transition: opacity 0.5s ease;
}
.bubble-1 {
  width: 450px;
  height: 450px;
  background: radial-gradient(circle, var(--theme-bubble-1) 0%, transparent 70%);
  top: -100px;
  left: -100px;
}
.bubble-2 {
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, var(--theme-bubble-2) 0%, transparent 70%);
  bottom: -50px;
  right: -50px;
}
.bubble-3 {
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, var(--theme-bubble-3) 0%, transparent 70%);
  top: 35%;
  left: 25%;
}

/* Animated Floating Background Cats */
.floating-cats-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  pointer-events: none;
  z-index: -1;
}

.floating-cat {
  position: absolute;
  opacity: 0.05;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.floating-cat img {
  width: 100%;
  height: auto;
  user-select: none;
}

@keyframes floatSlow {
  0% { transform: translate(0, 0) rotate(0deg) scale(1); }
  50% { transform: translate(30px, -40px) rotate(15deg) scale(1.08); }
  100% { transform: translate(0, 0) rotate(0deg) scale(1); }
}

@keyframes floatMedium {
  0% { transform: translate(0, 0) rotate(0deg) scale(1); }
  50% { transform: translate(-35px, -60px) rotate(-12deg) scale(0.92); }
  100% { transform: translate(0, 0) rotate(0deg) scale(1); }
}

@keyframes floatDrift {
  0% { transform: translate(0, 0) rotate(0deg) scale(1); }
  50% { transform: translate(45px, 25px) rotate(8deg) scale(1.05); }
  100% { transform: translate(0, 0) rotate(0deg) scale(1); }
}

.cat-float-1 {
  width: 110px;
  top: 10%;
  left: 3%;
  animation: floatSlow 22s ease-in-out infinite;
}

.cat-float-2 {
  width: 130px;
  top: 55%;
  left: 6%;
  animation: floatMedium 28s ease-in-out infinite;
  animation-delay: 2s;
}

.cat-float-3 {
  width: 115px;
  top: 20%;
  right: 4%;
  animation: floatDrift 25s ease-in-out infinite;
  animation-delay: 4s;
}

.cat-float-4 {
  width: 125px;
  top: 70%;
  right: 5%;
  animation: floatSlow 32s ease-in-out infinite;
  animation-delay: 1s;
}

/* App Main Container */
.app-container {
  width: 100%;
  max-width: 1100px;
  background: white;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Header - EXACT SCREENSHOT STYLE */
.app-header {
  background: linear-gradient(90deg, #fdf2f8, #f5f3ff); /* Light pinkish-purple */
  border-radius: var(--radius-md);
  padding: 16px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  border: 1px solid #fae8ff;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.logo-wrapper {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid white;
  background-color: white;
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}

.brand-logo {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.title-wrapper h1 {
  font-family: var(--font-title);
  font-size: 1.45rem;
  color: var(--primary-dark);
  font-weight: 600;
}

.last-update {
  font-size: 0.82rem;
  color: #701a75;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
  font-weight: 500;
}

/* Mode display matching screenshot */
.btn-mode {
  border: none;
  padding: 8px 18px;
  border-radius: 8px;
  font-family: var(--font-title);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.25s ease;
}

.btn-mode.mode-guest {
  background-color: #f3f4f6;
  color: #4b5563;
  border: 1px solid #e5e7eb;
}
.btn-mode.mode-guest:hover {
  background-color: #e5e7eb;
}

/* Green "โหมดแก้ไข" matching screenshot */
.btn-mode.mode-admin {
  background-color: #d1fae5 !important;
  color: #065f46 !important;
  border: 1px solid #a7f3d0;
  font-weight: 600;
}
.btn-mode.mode-admin i {
  color: #059669;
}

/* 10-day Timeline Section */
.history-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-bottom: 1px dashed var(--border-subtle);
  padding-bottom: 16px;
}

.section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.title-text-with-cat {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--primary-dark);
}
.title-text-with-cat h2 {
  font-family: var(--font-title);
  font-size: 1.05rem;
  font-weight: 500;
}

.badge-helper {
  font-size: 0.78rem;
  background-color: #f3e8ff;
  color: #7c3aed;
  padding: 2px 8px;
  border-radius: 50px;
  font-weight: 500;
}

.timeline-scroll-container {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 5px 2px 10px 2px;
  scrollbar-width: thin;
  scrollbar-color: #d8b4fe transparent;
}
.timeline-scroll-container::-webkit-scrollbar {
  height: 5px;
}
.timeline-scroll-container::-webkit-scrollbar-thumb {
  background-color: #d8b4fe;
  border-radius: 10px;
}

.timeline-card {
  flex: 0 0 110px;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: var(--radius-sm);
  padding: 8px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  position: relative;
  transition: all 0.25s ease;
  box-shadow: var(--shadow-sm);
}
.timeline-card:hover {
  transform: translateY(-3px);
  border-color: #a78bfa;
  box-shadow: var(--shadow-md);
}
.timeline-card.active {
  background: #fdf4ff;
  border: 1.5px solid #c084fc;
  box-shadow: var(--shadow-glow);
}

/* Card close/delete button */
.btn-card-delete {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background-color: #fee2e2;
  color: #dc2626;
  border: none;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 0.65rem;
  cursor: pointer;
  z-index: 10;
  transition: all 0.2s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  padding: 0;
}

.btn-card-delete:hover {
  background-color: #dc2626;
  color: white;
  transform: scale(1.1);
}

.card-cat-frame {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  overflow: hidden;
  border: 1.5px solid #f3e8ff;
  background-color: #f9fafb;
}
.timeline-card.active .card-cat-frame {
  border-color: #c084fc;
}
.card-cat-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-date {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-main);
}
.card-day-label {
  font-size: 0.62rem;
  color: var(--text-muted);
}
.timeline-card.is-latest::after {
  content: 'ล่าสุด';
  position: absolute;
  top: -6px;
  right: -6px;
  background: var(--accent-pink-gradient);
  color: white;
  font-size: 0.58rem;
  padding: 1px 5px;
  border-radius: 50px;
  font-weight: bold;
}

/* Chatty Cat Banner (Moved above table section as a decoration) */
.cat-on-duty-banner {
  background-color: #faf5ff;
  border: 1px dashed #d8b4fe;
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  align-self: flex-start;
}

.cat-avatar-frame {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  overflow: hidden;
  border: 1.5px solid #d8b4fe;
  background-color: white;
}
.cat-avatar-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cat-speech-bubble {
  color: #6b21a8;
  font-size: 0.85rem;
  font-weight: 500;
}

#txtCatSpeech {
  display: inline-block;
  border-bottom: 1.5px dashed transparent;
  transition: all 0.2s ease;
  padding: 2px 6px;
  border-radius: 4px;
}

#txtCatSpeech[contenteditable="true"]:hover {
  border-bottom-color: #c084fc;
  cursor: text;
  background-color: rgba(243, 232, 255, 0.4);
}

#txtCatSpeech[contenteditable="true"]:focus {
  outline: none;
  border-bottom: 1.5px solid #8b5cf6;
  background-color: #f3e8ff;
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

/* Main Table Section */
.table-section {
  background: white;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0; /* Align subheader to the borders */
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
}

/* Subheader bar - Centered and Clean layout */
.table-header-bar {
  background-color: #eae2f8;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  border-bottom: 1.5px solid #d8b4fe;
  min-height: 44px;
}

.active-date-badge {
  background-color: #c084fc;
  color: #4c1d95;
  padding: 10px 24px;
  font-family: var(--font-title);
  font-weight: 600;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: center;
  justify-self: start;
  height: 100%;
}

.active-date-badge input {
  background: transparent;
  border: none;
  color: inherit;
  font-family: inherit;
  font-weight: inherit;
  font-size: inherit;
  width: 110px;
  text-align: center;
  outline: none;
  cursor: default;
}

body.admin-mode .active-date-badge input {
  cursor: text;
  border-bottom: 1.5px dashed rgba(76, 29, 149, 0.4);
}

body.admin-mode .active-date-badge input:focus {
  border-bottom: 2px solid #4c1d95;
}

.order-source-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  grid-column: 2;
  font-family: var(--font-title);
  font-size: 0.98rem;
  font-weight: 600;
  color: #4c1d95;
}

.order-source-container input {
  background: transparent;
  border: none;
  color: #4c1d95;
  font-weight: 700;
  font-size: 0.98rem;
  width: 32px;
  padding: 0;
  text-align: left;
}
.order-source-container input:focus {
  outline: none;
  background-color: white;
  border-bottom: 2px solid #c084fc;
}

/* Product Table */
.table-scroll-wrapper {
  overflow-x: auto;
}

.product-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.product-table th {
  background-color: #faf5ff; /* Light lavender-gray header */
  color: #991b1b; /* Dark crimson red matching screenshot */
  font-family: var(--font-title);
  font-weight: 500;
  font-size: 0.92rem;
  padding: 12px 14px;
  border-bottom: 1.5px solid #d8b4fe;
  user-select: none;
}

.product-table td {
  padding: 8px 12px;
  border-bottom: 1px solid #f3e8ff;
}

.product-table tbody tr {
  transition: background-color 0.15s ease;
}
.product-table tbody tr:hover {
  background-color: #faf5ff;
}

/* Sticky first column (Product Code) for horizontal scrolling context */
.product-table th:first-child,
.product-table td:first-child {
  position: sticky;
  left: 0;
  z-index: 5; /* Keep above scrolled cells */
  box-shadow: 2px 0 5px rgba(109, 40, 217, 0.05); /* Subtle right shadow to separate columns */
}

.product-table th:first-child {
  background-color: #faf5ff; /* Match default th header color */
  border-right: 1.5px solid #d8b4fe !important;
}

.product-table td:first-child {
  background-color: white; /* Opaque white background to hide content scrolling underneath */
  border-right: 1.5px solid #f3e8ff !important;
}

/* Cells inputs */
.input-cell {
  width: 100%;
  border: 1px solid transparent;
  background-color: transparent;
  padding: 6px 8px;
  border-radius: 4px;
  font-size: 0.95rem;
  color: #111827;
  transition: all 0.2s ease;
  font-family: var(--font-body);
}

.input-cell.code-field {
  font-weight: 600;
}

.input-cell:disabled {
  color: #111827;
  opacity: 1;
  cursor: not-allowed;
}

.input-cell:not(:disabled) {
  border-color: #e9d5ff;
  background-color: #faf8ff;
  text-align: center;
}
.input-cell.code-field:not(:disabled) {
  text-align: left;
}
.input-cell:not(:disabled):focus {
  outline: none;
  border-color: #c084fc;
  background-color: white;
  box-shadow: 0 0 0 2px rgba(192, 132, 252, 0.15);
}

/* Actions Column & Delete Trash bin */
.col-action {
  width: 50px;
  text-align: center;
}
.product-table th.col-action {
  text-align: center;
}

.btn-delete-row {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  font-size: 0.95rem;
  transition: all 0.15s ease;
  display: inline-flex;
  justify-content: center;
  align-items: center;
}
.btn-delete-row:hover {
  background-color: var(--danger-light);
  transform: scale(1.1);
}

/* Empty Banner */
.table-empty-banner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 30px;
  color: var(--text-muted);
}

/* Actions Buttons Row - Pill shape like screenshot */
.actions-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}
.actions-left, .actions-right {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

/* Pill buttons based on screenshot colors */
.btn {
  border: 1px solid transparent;
  border-radius: 50px; /* Pill shaped */
  padding: 8px 18px;
  font-family: var(--font-title);
  font-weight: 500;
  font-size: 0.88rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}
.btn:hover {
  transform: translateY(-1.5px);
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

/* Purple text/border for Add Row */
.btn-secondary {
  background-color: white;
  color: #7e22ce;
  border-color: #d8b4fe;
}
.btn-secondary:hover {
  background-color: #faf5ff;
}

/* Red text/border for Clear All */
.btn-danger {
  background-color: white;
  color: #dc2626;
  border-color: #fecaca;
}
.btn-danger:hover {
  background-color: #fef2f2;
}

/* Blue text/border for Export JPEG */
.btn-export-jpeg {
  background-color: white;
  color: #1d4ed8;
  border-color: #bfdbfe;
}
.btn-export-jpeg:hover {
  background-color: #eff6ff;
}

/* Pink text/border for Export PDF */
.btn-export-pdf {
  background-color: white;
  color: #db2777;
  border-color: #fbcfe8;
}
.btn-export-pdf:hover {
  background-color: #fdf2f8;
}

/* Pink Gradient for Save Data */
.btn-primary {
  background: linear-gradient(135deg, #ec4899, #db2777);
  color: white;
  box-shadow: 0 4px 10px rgba(219, 39, 119, 0.2);
}
.btn-primary:hover {
  filter: brightness(1.05);
}

.btn-block {
  width: 100%;
  justify-content: center;
}

/* Footer */
.app-footer {
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border-subtle);
  padding-top: 12px;
  font-weight: 500;
}

/* Modal Styling */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(76, 29, 149, 0.35);
  backdrop-filter: blur(5px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}
.modal-box {
  background: white;
  border-radius: var(--radius-md);
  padding: 24px;
  width: 100%;
  max-width: 380px;
  position: relative;
  box-shadow: var(--shadow-lg);
  transform: translateY(15px);
  transition: transform 0.3s ease;
}
.modal-overlay.open .modal-box {
  transform: translateY(0);
}

.modal-close-btn {
  position: absolute;
  top: 14px;
  right: 14px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.15rem;
}
.modal-close-btn:hover {
  color: var(--danger);
}

.modal-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
  margin-bottom: 20px;
}
.cat-modal-avatar {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid #f3e8ff;
  background-color: #f9fafb;
}
.cat-modal-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.modal-header h3 {
  font-family: var(--font-title);
  color: var(--primary-dark);
  font-size: 1.15rem;
}
.modal-header p {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.modal-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.form-group label {
  font-size: 0.8rem;
  font-weight: 600;
}
.input-with-icon {
  position: relative;
}
.input-with-icon i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.88rem;
}
.input-with-icon input {
  width: 100%;
  padding: 8px 12px 8px 36px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 0.9rem;
  font-family: var(--font-body);
}
.input-with-icon input:focus {
  outline: none;
  border-color: #c084fc;
  box-shadow: 0 0 0 2px rgba(192, 132, 252, 0.15);
}

.error-message {
  color: var(--danger);
  font-size: 0.78rem;
  font-weight: 500;
  text-align: center;
}

/* Toast alert messages */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 2000;
}
.toast {
  background: white;
  border-left: 4px solid var(--primary);
  border-radius: 6px;
  padding: 10px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  font-size: 0.88rem;
  min-width: 240px;
}
.toast.toast-success { border-left-color: var(--success); }
.toast.toast-success i { color: var(--success); }
.toast.toast-error { border-left-color: var(--danger); }
.toast.toast-error i { color: var(--danger); }
.toast.toast-info i { color: var(--primary); }
.toast-content { flex: 1; }

/* Admin Only visibility classes */
.admin-only-element {
  display: none !important;
}
body.admin-mode .admin-only-element {
  display: inline-flex !important;
}
body.admin-mode table .admin-only-element {
  display: table-cell !important;
}

@keyframes slide-in {
  from { transform: translateX(120%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Table Filter Bar styles */
.table-filter-bar {
  background-color: #faf5ff;
  border-bottom: 1px solid #e9d5ff;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.filter-group-search, .filter-group-branch {
  position: relative;
  display: flex;
  align-items: center;
}

.filter-group-search i, .filter-group-branch i {
  position: absolute;
  left: 12px;
  color: #7c3aed;
  font-size: 0.85rem;
}

.filter-group-search input {
  padding: 6px 12px 6px 34px;
  border: 1px solid #d8b4fe;
  border-radius: 6px;
  font-family: var(--font-body);
  font-size: 0.85rem;
  width: 240px;
  color: var(--text-main);
  transition: all 0.2s ease;
}
.filter-group-search input:focus {
  outline: none;
  border-color: #c084fc;
  box-shadow: 0 0 0 2px rgba(192, 132, 252, 0.15);
}

.filter-group-branch select {
  padding: 6px 28px 6px 34px;
  border: 1px solid #d8b4fe;
  border-radius: 6px;
  font-family: var(--font-body);
  font-size: 0.85rem;
  color: var(--text-main);
  background-color: white;
  cursor: pointer;
  outline: none;
  transition: all 0.2s ease;
  appearance: none;
  -webkit-appearance: none;
}
.filter-group-branch select:focus {
  border-color: #c084fc;
  box-shadow: 0 0 0 2px rgba(192, 132, 252, 0.15);
}

/* Custom arrow for select */
.filter-group-branch::after {
  content: '\f107';
  font-family: 'Font Awesome 6 Free';
  font-weight: 900;
  position: absolute;
  right: 12px;
  pointer-events: none;
  color: #7c3aed;
  font-size: 0.85rem;
}

/* Custom Checkbox Toggle */
.filter-group-checkbox {
  display: flex;
  align-items: center;
}

.checkbox-container {
  display: flex;
  align-items: center;
  position: relative;
  padding-left: 24px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  color: #6b21a8;
  user-select: none;
}

.checkbox-container input {
  position: absolute;
  opacity: 0;
  cursor: pointer;
  height: 0;
  width: 0;
}

.checkmark {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  left: 0;
  height: 16px;
  width: 16px;
  background-color: white;
  border: 1.5px solid #c084fc;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.checkbox-container:hover input ~ .checkmark {
  background-color: #faf5ff;
}

.checkbox-container input:checked ~ .checkmark {
  background-color: #c084fc;
  border-color: #c084fc;
}

.checkmark::after {
  content: "";
  position: absolute;
  display: none;
}

.checkbox-container input:checked ~ .checkmark::after {
  display: block;
}

.checkbox-container .checkmark::after {
  left: 5px;
  top: 2px;
  width: 4px;
  height: 8px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* Print/Export Styling overrides */
@media print {
  body {
    background: white;
    padding: 0;
  }
  .app-container {
    border: none;
    box-shadow: none;
    background: transparent;
    padding: 0;
  }
  .bg-bubble, .btn, .btn-mode, .actions-container, .modal-overlay, .toast-container, .timeline-scroll-container, .section-title, .cat-on-duty-banner, .table-filter-bar {
    display: none !important;
  }
  .history-section {
    display: none !important;
  }
  .table-section {
    border: none;
    box-shadow: none;
    padding: 0;
  }
  .product-table th {
    background-color: #faf5ff !important;
    color: #991b1b !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .input-cell {
    border: none !important;
    background: transparent !important;
  }
}

/* Responsive Design for Tablets and Mobile Devices */
@media (max-width: 768px) {
  body {
    padding: 12px 8px;
  }

  .app-container {
    padding: 16px 12px;
    gap: 16px;
  }

  /* App Header Optimization */
  .app-header {
    flex-direction: column;
    align-items: stretch;
    padding: 14px;
    gap: 12px;
    text-align: center;
  }
  .header-left {
    flex-direction: column;
    gap: 10px;
  }
  .logo-wrapper {
    width: 48px;
    height: 48px;
  }
  .title-wrapper h1 {
    font-size: 1.2rem;
  }
  .last-update {
    justify-content: center;
  }
  .btn-mode {
    width: 100%;
    justify-content: center;
    padding: 10px;
  }

  /* Timeline Scaling */
  .timeline-scroll-container {
    padding-bottom: 6px;
  }
  .timeline-card {
    flex: 0 0 95px;
    padding: 6px 4px;
  }
  .card-cat-frame {
    width: 38px;
    height: 38px;
  }
  .card-date {
    font-size: 0.72rem;
  }
  .card-day-label {
    font-size: 0.58rem;
  }

  /* Cat Speech Banner full-width */
  .cat-on-duty-banner {
    align-self: stretch;
    width: 100%;
    padding: 8px 12px;
    gap: 10px;
  }
  .cat-avatar-frame {
    width: 38px;
    height: 38px;
  }
  .cat-speech-bubble {
    font-size: 0.8rem;
    line-height: 1.4;
  }

  /* Subheader Bar Stacking */
  .table-header-bar {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 10px;
    background-color: #eae2f8;
  }
  .active-date-badge {
    width: 100%;
    padding: 8px 16px;
    border-radius: 4px;
    text-align: center;
    height: auto;
  }
  .order-source-container {
    width: 100%;
    justify-content: center;
  }

  /* Filters Stacking */
  .table-filter-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 10px;
  }
  .filter-group-search, .filter-group-branch, .filter-group-checkbox {
    width: 100%;
  }
  .filter-group-search input {
    width: 100% !important;
  }
  .filter-group-branch select {
    width: 100% !important;
  }

  /* Table Cell Optimization for horizontal scroll */
  .product-table th, .product-table td {
    padding: 8px 10px;
  }
  .product-table th.col-branch, .product-table td.col-branch {
    min-width: 70px;
    text-align: center;
  }
  .product-table th:first-child, .product-table td:first-child {
    min-width: 110px;
  }
  .input-cell {
    padding: 8px 6px;
    font-size: 0.92rem;
  }

  /* Actions Container Stacking */
  .actions-container {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  .actions-left, .actions-right {
    flex-direction: column;
    width: 100%;
    gap: 8px;
  }
  .actions-left .btn, .actions-right .btn {
    width: 100%;
    justify-content: center;
    padding: 12px;
    font-size: 0.95rem;
  }
}

/* Modal optimizations on extra small mobile screens */
@media (max-width: 480px) {
  .modal-box {
    padding: 18px 14px;
    max-width: 92%;
    border-radius: var(--radius-sm);
  }
  .cat-modal-avatar {
    width: 56px;
    height: 56px;
  }
  .modal-header h3 {
    font-size: 1.05rem;
  }
}

/* Premium Row Highlight Styling */
.product-table tbody tr.highlighted-row {
  background-color: #f3e8ff !important; /* Soft lavender */
}

.product-table tbody tr.highlighted-row td:first-child {
  background-color: #f3e8ff !important;
  border-left: 4px solid #8b5cf6 !important;
  padding-left: 8px !important; /* Adjust padding to keep alignment stable */
}
