@import url('https://fonts.googleapis.com/css2?family=Bai+Jamjuree:wght@300;400;500;600;700&display=swap');

:root {
  --primary: #6366f1;
  --primary-light: #818cf8;
  --primary-dark: #4f46e5;
  --accent: #0891b2;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --bg: #f8fafc;
  --bg-card: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
  --shadow-hover: 0 12px 32px rgba(99, 102, 241, 0.12);
  --radius: 16px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Bai Jamjuree', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at 20% 10%, rgba(99, 102, 241, 0.05) 0%, transparent 50%),
              radial-gradient(circle at 80% 90%, rgba(6, 182, 212, 0.04) 0%, transparent 50%);
  z-index: -1;
}

/* Container */
.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 48px 32px;
}

.container-wide {
  max-width: 1200px;
}

/* Header */
h1 {
  font-size: 32px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.5px;
}

.period {
  color: var(--text-muted);
  font-size: 15px;
  margin-top: 6px;
  margin-bottom: 32px;
}

/* Cards */
.cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 32px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  position: relative;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  border-radius: var(--radius) var(--radius) 0 0;
}

.card:nth-child(1)::before { background: linear-gradient(90deg, #6366f1, #818cf8); }
.card:nth-child(2)::before { background: linear-gradient(90deg, #10b981, #34d399); }
.card:nth-child(3)::before { background: linear-gradient(90deg, #8b5cf6, #a78bfa); }
.card:nth-child(4)::before { background: linear-gradient(90deg, #f59e0b, #fbbf24); }

.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.card span {
  display: block;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.card strong {
  font-size: 22px;
  font-weight: 700;
}

.blue { color: #4f46e5; }
.green { color: #059669; }
.purple { color: #7c3aed; }
.orange { color: #d97706; }

/* Panels */
.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  margin-bottom: 24px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

h2 {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 24px;
  color: var(--text);
}

/* Chart */
.chart {
  height: 200px;
  display: flex;
  align-items: flex-end;
  gap: 16px;
  padding: 10px 40px 0;
}

.bar {
  flex: 1;
  background: linear-gradient(180deg, var(--primary-light), var(--primary));
  border-radius: 8px 8px 0 0;
  min-height: 8px;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.bar:hover {
  background: linear-gradient(180deg, #06b6d4, var(--primary));
  transform: scaleY(1.03);
  transform-origin: bottom;
}

.months {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 16px;
  padding: 12px 40px 0;
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
}

/* Table */
thead tr {
  border-bottom: 1px solid var(--border);
}

th {
  text-align: center;
  color: #000000;
  font-weight: 500;
  font-size: 12px;
  padding: 10px 6px;
  letter-spacing: 0.3px;
  border: 1px solid #000000;
  background: var(--bg);
  white-space: normal;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

th:first-child {
  text-align: left;
  white-space: normal;
}

td {
  padding: 10px 6px;
  font-size: 13px;
  border: 1px solid #000000;
  text-align: center;
  color: #000000;
}

td:first-child {
  text-align: left;
  font-weight: 500;
}

tr:last-child td {
  border-bottom: 1px solid #000000;
}

/* Menu Page */
.menu-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 24px;
  margin-top: 40px;
}

.menu-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 48px 28px;
  text-decoration: none;
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.menu-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.04), rgba(6, 182, 212, 0.03));
  opacity: 0;
  transition: opacity 0.3s ease;
}

.menu-card:hover::before {
  opacity: 1;
}

.menu-card:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-hover);
  border-color: rgba(99, 102, 241, 0.3);
}

.menu-icon {
  font-size: 52px;
  margin-bottom: 20px;
  width: 80px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 20px;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.icon-daily {
  color: #6366f1;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(99, 102, 241, 0.05));
}

.icon-monthly {
  color: #0891b2;
  background: linear-gradient(135deg, rgba(8, 145, 178, 0.1), rgba(8, 145, 178, 0.05));
}

.icon-customers {
  color: #7c3aed;
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.1), rgba(124, 58, 237, 0.05));
}

.icon-map {
  color: #059669;
  background: linear-gradient(135deg, rgba(5, 150, 105, 0.1), rgba(5, 150, 105, 0.05));
}

.icon-waste {
  color: #e11d48;
  background: linear-gradient(135deg, rgba(225, 29, 72, 0.1), rgba(225, 29, 72, 0.05));
}

.icon-employees {
  color: #d97706;
  background: linear-gradient(135deg, rgba(217, 119, 6, 0.12), rgba(217, 119, 6, 0.05));
}

.menu-card:hover .menu-icon {
  transform: scale(1.08);
}

.menu-card:hover .icon-daily {
  box-shadow: 0 8px 20px rgba(99, 102, 241, 0.2);
}

.menu-card:hover .icon-monthly {
  box-shadow: 0 8px 20px rgba(8, 145, 178, 0.2);
}

.menu-card:hover .icon-customers {
  box-shadow: 0 8px 20px rgba(124, 58, 237, 0.2);
}

.menu-card:hover .icon-map {
  box-shadow: 0 8px 20px rgba(5, 150, 105, 0.2);
}

.menu-card:hover .icon-waste {
  box-shadow: 0 8px 20px rgba(225, 29, 72, 0.2);
}

.menu-card:hover .icon-employees {
  box-shadow: 0 8px 20px rgba(217, 119, 6, 0.2);
}

.menu-card h2 {
  margin: 0 0 10px;
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}

.menu-card p {
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.5;
}

/* Back Link */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 24px;
  color: var(--primary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: 8px;
  background: rgba(99, 102, 241, 0.06);
  border: 1px solid rgba(99, 102, 241, 0.15);
  transition: all 0.2s ease;
}

.back-link:hover {
  background: rgba(99, 102, 241, 0.12);
  color: var(--primary-dark);
  transform: translateX(-2px);
}

/* Animations */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.container > * {
  animation: fadeInUp 0.4s ease forwards;
}

.container > :nth-child(2) { animation-delay: 0.08s; }
.container > :nth-child(3) { animation-delay: 0.16s; }
.container > :nth-child(4) { animation-delay: 0.24s; }
.container > :nth-child(5) { animation-delay: 0.32s; }

/* Page Layout - Sidebar */
.page-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  padding: 32px 24px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.sidebar h1 {
  font-size: 24px;
  margin-top: 16px;
}

.sidebar .period {
  margin-bottom: 32px;
}

.sidebar .back-link {
  margin-bottom: 8px;
}

.sidebar-top {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 8px;
}

.sidebar-top .back-link {
  margin-bottom: 0;
}

.btn-toggle-sidebar,
.btn-show-sidebar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  background: rgba(99, 102, 241, 0.06);
  color: var(--primary);
  border-radius: 10px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-toggle-sidebar:hover,
.btn-show-sidebar:hover {
  background: rgba(99, 102, 241, 0.12);
  border-color: rgba(99, 102, 241, 0.35);
}

.btn-show-sidebar {
  position: fixed;
  top: 24px;
  left: 16px;
  z-index: 40;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.12);
  display: none;
}

.page-layout.sidebar-hidden .btn-show-sidebar {
  display: inline-flex;
}

.page-layout.sidebar-hidden {
  grid-template-columns: 1fr;
}

.page-layout.sidebar-hidden .sidebar {
  display: none;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sidebar-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 16px;
  border: none;
  background: transparent;
  border-radius: 10px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
}

.sidebar-btn:hover {
  color: var(--text);
  background: rgba(99, 102, 241, 0.04);
}

.sidebar-btn.active {
  background: rgba(99, 102, 241, 0.08);
  color: var(--primary);
  font-weight: 600;
}

.sidebar-btn svg {
  flex-shrink: 0;
}

.main-content {
  padding: 40px 48px;
  flex: 1;
  min-width: 0;
}

/* Tabs (inline style for other pages) */
.tabs {
  display: inline-flex;
  gap: 4px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 5px;
  margin-bottom: 28px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.tab-btn {
  padding: 12px 32px;
  border: none;
  background: transparent;
  border-radius: 8px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.tab-btn:hover {
  color: var(--text);
  background: rgba(99, 102, 241, 0.04);
}

.tab-btn.active {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
  animation: fadeInUp 0.3s ease;
  overflow: visible;
  height: auto;
  min-height: 200px;
}

/* Forms */
.goal-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-group input {
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-family: inherit;
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-group input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

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

.form-row-5 {
  grid-template-columns: repeat(5, 1fr);
}

.table-wrapper {
  overflow-x: auto;
  width: 100%;
}

#allProductsTable {
  table-layout: auto !important;
  width: max-content !important;
  min-width: 100%;
  border-collapse: collapse;
}

#allProductsTable th,
#allProductsTable td {
  white-space: nowrap;
  padding: 8px 10px;
  min-width: 72px;
}

#allProductsTable th.all-products-name-col,
#allProductsTable td:first-child {
  min-width: 160px;
  max-width: 220px;
  position: sticky;
  left: 0;
  z-index: 2;
  background: #fff;
}

#allProductsTable thead th.all-products-name-col {
  z-index: 3;
  background: var(--bg, #f8fafc);
}

#allProductsTable th.all-products-col {
  min-width: 88px;
}

#allProductsTable th.all-products-sum-col,
#allProductsTable td.all-products-sum-col {
  min-width: 88px;
  font-weight: 700;
  background: rgba(16, 185, 129, 0.08);
}

#allProductsTable th.all-products-group-head {
  background: #eef2ff;
  font-weight: 700;
  text-align: center;
  border-bottom: 1px solid #c7d2fe;
}

#allProductsTable th.all-products-group-sum-col,
#allProductsTable td.all-products-group-sum-col {
  min-width: 88px;
  font-weight: 700;
  background: rgba(99, 102, 241, 0.08);
}

.all-products-type-filter-row {
  display: flex;
  align-items: stretch;
  gap: 8px;
}

.all-products-type-filter-row .zone-multiselect {
  flex: 1;
  min-width: 0;
}

.btn-view-selected-types {
  flex-shrink: 0;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(99, 102, 241, 0.08);
  color: var(--primary);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.btn-view-selected-types:hover {
  background: rgba(99, 102, 241, 0.14);
  border-color: rgba(99, 102, 241, 0.35);
}

.selected-types-list {
  margin: 0;
  padding: 0 0 0 22px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 6px 16px;
  font-size: 14px;
  color: #0f172a;
  line-height: 1.45;
}

.selected-types-list li {
  padding: 2px 0;
}

.product-group-modal {
  width: min(920px, 96vw);
  max-height: 88vh;
}

.product-group-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.product-group-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 14px;
  min-height: 360px;
}

.product-group-side,
.product-group-main {
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #fff;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.product-group-side-head,
.product-group-main-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid #e2e8f0;
  background: #f8fafc;
}

.btn-add-group {
  border: none;
  background: rgba(99, 102, 241, 0.1);
  color: var(--primary);
  border-radius: 8px;
  padding: 6px 10px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.product-group-list,
.product-group-products {
  overflow: auto;
  padding: 8px;
  flex: 1;
}

.product-group-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  border: none;
  background: transparent;
  border-radius: 8px;
  padding: 10px 10px;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  color: var(--text);
}

.product-group-item:hover {
  background: rgba(99, 102, 241, 0.06);
}

.product-group-item.active {
  background: rgba(99, 102, 241, 0.12);
  color: var(--primary);
  font-weight: 600;
}

.product-group-item-name {
  flex: 1;
  min-width: 0;
}

.product-group-item-count {
  font-size: 12px;
  color: var(--text-muted);
  background: #f1f5f9;
  border-radius: 999px;
  padding: 2px 8px;
}

.product-group-item-del {
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  color: #dc2626;
  font-size: 16px;
  line-height: 1;
}

.product-group-item-del:hover {
  background: rgba(220, 38, 38, 0.1);
}

.product-group-name-input {
  width: min(220px, 100%);
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
}

.product-group-hint,
.product-group-empty {
  margin: 0;
  padding: 10px 14px;
  color: var(--text-muted);
  font-size: 13px;
}

.product-group-other {
  color: #94a3b8;
  font-size: 12px;
}

.product-group-footer {
  display: flex;
  justify-content: flex-end;
}

@media (max-width: 800px) {
  .product-group-layout {
    grid-template-columns: 1fr;
  }
}

.app-toast-host {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(420px, calc(100vw - 24px));
  pointer-events: none;
}

.app-toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 14px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.16);
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.app-toast.show {
  opacity: 1;
  transform: translateY(0);
}

.app-toast-success {
  border-color: rgba(16, 185, 129, 0.35);
  background: linear-gradient(180deg, #ecfdf5 0%, #ffffff 55%);
}

.app-toast-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.app-toast-success .app-toast-icon {
  background: rgba(16, 185, 129, 0.15);
  color: #059669;
}

.app-toast-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.app-toast-title {
  font-size: 14px;
  color: #0f172a;
}

.app-toast-message {
  font-size: 13px;
  color: #475569;
  line-height: 1.4;
}

.app-toast-close {
  border: none;
  background: transparent;
  color: #94a3b8;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
}

.app-toast-close:hover {
  color: #64748b;
}

#allProductsTable .district-row td:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  background: rgba(99, 102, 241, 0.12);
}

#allProductsTable .district-row td:not(:first-child) {
  background: rgba(99, 102, 241, 0.06);
}

#allProductsTable .total-row td:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  background: #fff;
}

/* Filter Row */
.filter-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.filter-row-5 {
  grid-template-columns: minmax(0, 2.2fr) repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.filter-row-5 .zone-filter-group,
.filter-row-5 .zone-filter-group select {
  min-width: 0;
  width: 100%;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.filter-group label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
}

.filter-group input,
.filter-group select {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  transition: border-color 0.2s ease;
}

.filter-group select {
  cursor: pointer;
}

.filter-group input:focus,
.filter-group select:focus {
  outline: none;
  border-color: var(--primary);
}

.filter-range {
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-range select {
  flex: 1;
  min-width: 72px;
}

.filter-range-sep {
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

/* Zone multi-select checkbox dropdown */
.zone-filter-group {
  min-width: 280px;
}

.zone-filter-group select {
  min-width: 280px;
}

.zone-multiselect {
  position: relative;
}

.searchable-select {
  position: relative;
  width: 100%;
}

.searchable-select-native {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

.searchable-select-input {
  width: 100%;
  padding: 10px 36px 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") no-repeat right 12px center;
  box-sizing: border-box;
}

.searchable-select-input:focus {
  outline: none;
  border-color: #93c5fd;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.searchable-select.is-open .searchable-select-input {
  border-color: #93c5fd;
}

.searchable-select-list {
  position: absolute;
  z-index: 40;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 280px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.12);
  padding: 6px;
}

.searchable-select-option {
  display: block;
  width: 100%;
  padding: 9px 12px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}

.searchable-select-option:hover,
.searchable-select-option.is-active {
  background: #eff6ff;
  color: #1d4ed8;
}

.searchable-select-option.is-selected {
  background: #dbeafe;
  font-weight: 600;
}

.searchable-select-empty {
  padding: 12px;
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
}

.zone-multiselect-toggle {
  width: 100%;
  padding: 10px 36px 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.2s ease;
  position: relative;
}

.zone-multiselect-toggle::after {
  content: '▾';
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 12px;
}

.zone-multiselect-toggle:hover,
.zone-multiselect-toggle.open {
  border-color: var(--primary);
}

.zone-multiselect-panel {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 100;
  min-width: 100%;
  max-height: 320px;
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 6px 0;
}

.zone-multiselect-search-wrap {
  padding: 6px 10px 8px;
  position: sticky;
  top: 0;
  background: var(--bg-card);
  z-index: 2;
}

.zone-multiselect-search {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
}

.zone-multiselect-search:focus {
  outline: none;
  border-color: rgba(99, 102, 241, 0.45);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

.zone-check-empty {
  padding: 12px 14px;
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
}

.zone-check-list {
  border-top: 1px solid var(--border);
  margin-top: 4px;
  padding-top: 4px;
}

.zone-check-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.zone-check-item.is-search-hidden {
  display: none !important;
}

.year-zone-selected-products {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 8px 10px;
  margin: 0 0 12px;
  padding: 10px 12px;
  background: #f8fafc;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 12px;
}

.year-zone-selected-label {
  font-size: 12px;
  font-weight: 700;
  color: #475569;
  padding-top: 4px;
  flex-shrink: 0;
}

.year-zone-selected-empty {
  font-size: 12px;
  color: #94a3b8;
  padding-top: 4px;
}

.year-zone-selected-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.year-zone-selected-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid rgba(14, 116, 144, 0.25);
  background: #ecfeff;
  color: #0e7490;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
}

.year-zone-selected-chip.is-all {
  cursor: default;
  background: #f1f5f9;
  border-color: rgba(15, 23, 42, 0.1);
  color: #334155;
}

.year-zone-selected-chip:not(.is-all):hover {
  background: #cffafe;
}

.zone-check-item:hover {
  background: rgba(99, 102, 241, 0.06);
}

.zone-check-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--primary);
  cursor: pointer;
  flex-shrink: 0;
}

.zone-check-all {
  font-weight: 600;
}

table {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid #000000;
  table-layout: auto;
  font-size: 13px;
}

.btn-primary {
  padding: 14px 32px;
  background: var(--primary);
  color: #ffffff;
  border: none;
  border-radius: 10px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  width: auto;
  align-self: flex-start;
}

.btn-primary:hover {
  background: var(--primary-dark);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
  transform: translateY(-1px);
}

/* Goal Board */
.goal-board {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.goal-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  transition: box-shadow 0.2s ease;
}

.goal-item:hover {
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

.goal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.goal-header h3 {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
}

.goal-date {
  font-size: 13px;
  color: var(--text-muted);
}

.goal-progress {
  width: 100%;
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 8px;
}

.goal-progress-bar {
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--primary), var(--primary-light));
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.goal-progress-bar.complete {
  background: linear-gradient(90deg, #10b981, #34d399);
}

.goal-stats {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-muted);
}

.goal-stats .current {
  font-weight: 600;
  color: var(--primary);
}

.text-muted {
  color: var(--text-muted);
  text-align: center;
  padding: 24px;
}

/* Action Buttons */
.action-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 20px;
}

.btn-export, .btn-print {
  padding: 10px 20px;
  border: 1px solid #000000;
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-export {
  background: #10b981;
  color: #ffffff;
  border-color: #10b981;
}

.btn-export:hover {
  background: #059669;
}

.btn-print {
  background: #6366f1;
  color: #ffffff;
  border-color: #6366f1;
}

.btn-print:hover {
  background: #4f46e5;
}

.btn-refresh {
  padding: 10px 20px;
  border: 1px solid #0891b2;
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  background: #0891b2;
  color: #ffffff;
}

.btn-refresh:hover {
  background: #0e7490;
}

.btn-missing-scans,
.btn-missing-scans {
  padding: 10px 20px;
  border: 1px solid #e11d48;
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  background: #e11d48;
  color: #ffffff;
}

.btn-missing-scans:hover,
.btn-missing-scans:hover {
  background: #be123c;
}

.btn-missing-scans:disabled {
  opacity: 0.55;
  cursor: default;
}

.unit-toggle {
  display: inline-flex;
  margin-left: auto;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #cbd5e1;
}

.unit-toggle-btn {
  padding: 10px 18px;
  border: none;
  background: #f1f5f9;
  color: #64748b;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.unit-toggle-btn:hover {
  background: #e2e8f0;
}

.unit-toggle-btn.active {
  background: #6366f1;
  color: #ffffff;
}

.unit-toggle-btn.active:hover {
  background: #4f46e5;
}

.filter-zone-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.filter-group-zone select {
  min-width: 120px;
}

.btn-inactive-cust {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border: 1px solid #f59e0b;
  border-radius: 8px;
  background: #fffbeb;
  color: #92400e;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn-inactive-cust:hover:not(:disabled) {
  background: #fef3c7;
  border-color: #d97706;
}

.btn-inactive-cust:disabled {
  opacity: 0.65;
  cursor: wait;
}

.btn-stock-unchecked {
  border-color: #f97316;
  background: #fff7ed;
  color: #9a3412;
}

.btn-stock-unchecked:hover:not(:disabled) {
  background: #ffedd5;
  border-color: #ea580c;
}

.btn-stock-checked {
  border-color: #22c55e;
  background: #f0fdf4;
  color: #166534;
}

.btn-stock-checked:hover:not(:disabled) {
  background: #dcfce7;
  border-color: #16a34a;
}

.stock-checked-badge {
  background: #16a34a;
}

.stock-unchecked-modal .stock-unchecked-icon {
  background: #fff7ed;
  color: #ea580c;
}

.stock-checked-modal .stock-checked-icon {
  background: #f0fdf4;
  color: #16a34a;
}

.inactive-meta-chip-ok {
  background: #dcfce7 !important;
  color: #166534 !important;
}

.stock-unchecked-item {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.stock-unchecked-district {
  margin-left: auto;
  padding: 2px 8px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #64748b;
  font-size: 12px;
  font-weight: 500;
}

.btn-stock-unchecked-open {
  margin-left: 4px;
  padding: 4px 10px;
  border: 1px solid #fdba74;
  border-radius: 6px;
  background: #ffffff;
  color: #9a3412;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.btn-stock-unchecked-open:hover {
  background: #fff7ed;
  border-color: #f97316;
}

.inactive-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: #ef4444;
  color: #ffffff;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
  animation: inactiveOverlayIn 0.2s ease;
}

.modal-overlay[hidden] {
  display: none;
}

@keyframes inactiveOverlayIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes inactiveModalIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-panel {
  width: min(640px, 100%);
  max-height: min(80vh, 720px);
  display: flex;
  flex-direction: column;
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.2);
}

.inactive-modal {
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.22);
  animation: inactiveModalIn 0.25s ease;
}

.inactive-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 22px 18px;
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 55%, #4338ca 100%);
  color: #ffffff;
}

.inactive-modal-header-main {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.inactive-modal-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.16);
  flex-shrink: 0;
}

.inactive-modal-header h3 {
  margin: 0 0 4px;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.inactive-modal-desc {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.82);
}

.inactive-modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
  flex-shrink: 0;
}

.inactive-modal-close:hover {
  background: rgba(255, 255, 255, 0.24);
  transform: scale(1.04);
}

.inactive-modal-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px 20px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}

.inactive-meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  color: #334155;
  font-size: 13px;
}

.inactive-meta-label {
  color: #64748b;
  font-size: 12px;
}

.inactive-meta-chip-accent {
  background: #fef2f2;
  border-color: #fecaca;
  color: #b91c1c;
}

.inactive-modal-body {
  overflow: auto;
  padding: 16px 20px 20px;
  background: linear-gradient(180deg, #f8fafc 0%, #ffffff 120px);
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}

.inactive-modal-body::-webkit-scrollbar {
  width: 8px;
}

.inactive-modal-body::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 999px;
}

.inactive-district-card {
  margin-bottom: 12px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
  overflow: hidden;
}

.inactive-district-card:last-child {
  margin-bottom: 0;
}

.inactive-district-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: linear-gradient(90deg, #f8fafc 0%, #ffffff 100%);
  border-bottom: 1px solid #f1f5f9;
}

.inactive-district-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(99, 102, 241, 0.1);
  color: #4f46e5;
  flex-shrink: 0;
}

.inactive-district-info h4 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: #0f172a;
}

.inactive-district-count {
  font-size: 12px;
  color: #64748b;
}

.inactive-list {
  list-style: none;
  margin: 0;
  padding: 6px 0;
}

.inactive-list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  font-size: 14px;
  color: #334155;
  transition: background 0.15s ease;
}

.inactive-list-item:hover {
  background: #f8fafc;
}

.inactive-list-item + .inactive-list-item {
  border-top: 1px solid #f1f5f9;
}

.inactive-item-index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  padding: 0 6px;
  border-radius: 6px;
  background: #eef2ff;
  color: #4f46e5;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.inactive-item-name {
  line-height: 1.45;
}

.inactive-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  text-align: center;
}

.inactive-empty-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  margin-bottom: 16px;
  border-radius: 50%;
  background: #ecfdf5;
  color: #059669;
}

.inactive-empty-title {
  margin: 0 0 6px;
  font-size: 16px;
  font-weight: 600;
  color: #0f172a;
}

.inactive-empty-text {
  margin: 0;
  font-size: 13px;
  color: #64748b;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px 0;
}

.modal-header h3 {
  margin: 0;
  font-size: 18px;
}

.modal-close {
  border: none;
  background: transparent;
  color: #64748b;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}

.modal-close:hover {
  color: #0f172a;
}

.modal-subtitle {
  margin: 8px 20px 0;
  color: #64748b;
  font-size: 13px;
}

.modal-body {
  overflow: auto;
  padding: 16px 20px 20px;
}

/* Loading Bar */
.loading-bar {
  padding: 16px;
  text-align: center;
}

.loading-progress {
  width: 100%;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 10px;
}

.loading-progress::after {
  content: '';
  display: block;
  width: 30%;
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary-light));
  border-radius: 2px;
  animation: loadingSlide 1.2s ease-in-out infinite;
}

@keyframes loadingSlide {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(400%); }
}

.loading-text {
  font-size: 13px;
  color: var(--text-muted);
}

.loading-bar-cust {
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f8fafc;
}

.btn-delete {
  padding: 4px 10px;
  background: rgba(239, 68, 68, 0.08);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-delete:hover {
  background: rgba(239, 68, 68, 0.15);
}

/* District grouping */
.district-row td {
  background: rgba(99, 102, 241, 0.06);
  font-weight: 600;
  font-size: 13px;
  color: #000000;
  padding: 8px 14px !important;
  text-align: left !important;
  border: 1px solid #000000;
}

.customer-indent {
  padding-left: 20px !important;
}

.customer-no-purchase {
  background: rgba(245, 158, 11, 0.2) !important;
}

/* Table input cells */
.input-cell {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  text-align: center;
  background: #fff;
}

.input-cell:focus {
  outline: none;
  border-color: var(--primary);
}

.input-locked {
  background: #f1f5f9 !important;
  color: #1e293b;
  cursor: not-allowed;
}

.btn-edit {
  margin-top: 6px;
  padding: 4px 10px;
  background: rgba(245, 158, 11, 0.1);
  color: #d97706;
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: 6px;
  font-size: 11px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s ease;
  display: block;
  width: 100%;
}

.btn-edit:hover {
  background: rgba(245, 158, 11, 0.2);
}

.btn-cancel {
  margin-top: 4px;
  padding: 4px 10px;
  background: rgba(239, 68, 68, 0.1);
  color: #dc2626;
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 6px;
  font-size: 11px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s ease;
  display: block;
  width: 100%;
}

.btn-cancel:hover {
  background: rgba(239, 68, 68, 0.2);
}

.select-cell {
  width: 100%;
  padding: 10px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: inherit;
  font-size: 13px;
  background: #fff;
  cursor: pointer;
}

.select-cell:focus {
  outline: none;
  border-color: var(--primary);
}

/* Schedule Toggle */
.schedule-toggle {
  display: flex;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.toggle-option {
  flex: 1;
  padding: 8px 10px;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.schedule-toggle.input-locked .toggle-option {
  cursor: not-allowed;
  opacity: 0.7;
}

.cell-empty {
  background: rgba(239, 68, 68, 0.15) !important;
}

/* Total row */
.total-row td {
  background: rgba(99, 102, 241, 0.08) !important;
  font-weight: 700;
  border-top: 2px solid #000000;
}

/* Sum column (every 6 days) */
.sum-col {
  background: rgba(16, 185, 129, 0.1) !important;
  font-weight: 600 !important;
  color: #059669 !important;
  min-width: 60px !important;
  width: 60px !important;
}

.sum-col-data {
  background: rgba(16, 185, 129, 0.06) !important;
  font-weight: 600;
  color: #059669;
  min-width: 60px !important;
  width: 60px !important;
}

/* Login Page */
.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 48px 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow);
  text-align: center;
  animation: fadeInUp 0.5s ease forwards;
}

.login-title {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}

.login-subtitle {
  font-size: 15px;
  color: var(--text-muted);
  margin-bottom: 32px;
}

.login-input-group {
  margin-bottom: 20px;
}

.login-input-group input {
  width: 100%;
  padding: 14px 18px;
  border: 1px solid var(--border);
  border-radius: 12px;
  font-family: inherit;
  font-size: 16px;
  color: var(--text);
  background: var(--bg);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  text-align: center;
  letter-spacing: 4px;
}

.login-input-group input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.login-btn {
  width: 100%;
  padding: 14px 32px;
  background: var(--primary);
  color: #ffffff;
  border: none;
  border-radius: 12px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.login-btn:hover {
  background: var(--primary-dark);
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.3);
  transform: translateY(-1px);
}

.login-btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.login-loading {
  margin-top: 16px;
  text-align: center;
}

.login-loading .loading-progress {
  margin-bottom: 8px;
}

.login-loading .loading-text {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
}

.login-error {
  margin-top: 16px;
  color: var(--danger);
  font-size: 14px;
  font-weight: 500;
}

.home-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 8px;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.btn-logout {
  padding: 12px 16px;
  border: 1px solid rgba(239, 68, 68, 0.25);
  background: rgba(239, 68, 68, 0.06);
  color: var(--danger);
  border-radius: 10px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.sidebar-footer .btn-logout {
  width: 100%;
}

.btn-logout:hover {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.4);
}

/* Responsive */
@media (max-width: 900px) {
  .cards { grid-template-columns: repeat(2, 1fr); }
  .menu-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 600px) {
  .container { padding: 24px 16px; }
  h1 { font-size: 26px; }
  .cards { grid-template-columns: 1fr; }
  .menu-grid { grid-template-columns: 1fr; }
  .chart, .months { padding-left: 10px; padding-right: 10px; }
  .card strong { font-size: 18px; }
  .form-row { grid-template-columns: 1fr; }
  .tabs { flex-direction: column; }
  .page-layout { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .main-content { padding: 24px 16px; }
}

/* Print */
@media print {

#stockTable th:first-child,
#stockTable td:first-child,
#dailyTable th:first-child,
#dailyTable td:first-child {
  min-width: 130px;
}

/* Board Table */
.board-title {
  text-align: center !important;
  width: 100%;
}

.board-title-text {
  font-size: 18px;
  font-weight: 700;
  text-align: center !important;
  margin-bottom: 4px;
}

.board-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  text-align: center !important;
  margin-bottom: 16px;
  font-weight: 600;
}

.board-table {
  table-layout: auto !important;
  width: auto !important;
  max-width: 100%;
}

#boardTable {
  width: auto !important;
  table-layout: auto !important;
}

#boardTable th,
#boardTable td {
  padding: 8px 10px;
  white-space: nowrap;
  font-size: 15px;
  min-width: unset !important;
}

#boardTable th:first-child,
#boardTable td:first-child {
  min-width: unset !important;
  width: auto !important;
  text-align: center;
}

#boardTable th:nth-child(2),
#boardTable td:nth-child(2) {
  min-width: unset !important;
  width: auto !important;
}

.board-separator td {
  border-bottom: 3px solid #000000 !important;
}

.board-has-sale td:nth-child(4) {
  background: #fce7f3 !important;
  color: #be185d;
  font-weight: 700;
}

.board-sold-cell {
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.board-sold-cell:hover {
  filter: brightness(0.95);
}

.board-waste-cell {
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
  color: #b45309;
}

.board-waste-cell:hover {
  filter: brightness(0.95);
}

.text-red {
  color: #ef4444 !important;
  font-weight: 600;
}

.text-green {
  color: #10b981 !important;
  font-weight: 600;
}

}

/* Day sales detail modal */
.day-sales-modal {
  width: min(860px, 95vw);
  max-height: 88vh;
}

/* Modal ซ้อนชั้นที่ 2 (รายลูกค้าของวันที่) — ต้องอยู่เหนือ modal รายวัน */
.modal-overlay-nested {
  z-index: 1100;
  background: rgba(15, 23, 42, 0.45);
}

.modal-overlay-nested .modal-panel {
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  animation: nestedModalIn .16s ease-out;
}

@keyframes nestedModalIn {
  from { opacity: 0; transform: translateY(-8px) scale(.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.day-sales-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.day-sales-summary-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 12px 14px;
}

.day-sales-summary-card .label {
  display: block;
  font-size: 12px;
  color: #64748b;
  margin-bottom: 4px;
}

.day-sales-summary-card .value {
  font-size: 18px;
  font-weight: 700;
  color: #0f172a;
}

.day-sales-summary-card.is-return .value {
  color: #be185d;
}

.day-sales-summary-card.is-net .value {
  color: #0f766e;
}

.day-sales-section {
  margin-bottom: 18px;
}

.day-sales-section h4 {
  margin: 0 0 8px;
  font-size: 15px;
  color: #0f172a;
}

.day-sales-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.day-sales-table th,
.day-sales-table td {
  padding: 8px 10px;
  border-bottom: 1px solid #e2e8f0;
  text-align: left !important;
}

.day-sales-table th {
  background: #f1f5f9;
  font-weight: 600;
  color: #334155;
}

.day-sales-table td.num,
.day-sales-table th.num {
  text-align: left !important;
  font-variant-numeric: tabular-nums;
}

.day-sales-table .return-qty {
  color: #be185d;
  font-weight: 700;
}

.day-sales-empty {
  text-align: center;
  color: #94a3b8;
  padding: 16px;
}

.map-placeholder {
  margin-top: 8px;
  color: var(--text-muted);
  font-size: 15px;
}

.map-page {
  padding-top: 20px;
}

.map-page .panel {
  margin-bottom: 0;
}

.map-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: calc(100vh - 64px);
  padding: 20px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96) 0%, rgba(248, 250, 252, 0.98) 100%);
  border: 1px solid rgba(226, 232, 240, 0.9);
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.06);
}

.map-panel > h2 {
  display: none;
}

.map-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.map-toolbar-copy h2 {
  margin: 4px 0 0;
  font-size: 26px;
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.map-toolbar-desc {
  margin-top: 6px;
  max-width: 54ch;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.5;
}

.map-kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(99, 102, 241, 0.1);
  color: #4338ca;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.map-kicker-route {
  background: rgba(8, 145, 178, 0.12);
  color: #0e7490;
}

.map-kicker-verify {
  background: rgba(234, 88, 12, 0.12);
  color: #c2410c;
}

.map-kicker-verify .map-kicker-dot {
  box-shadow: 0 0 0 4px rgba(234, 88, 12, 0.14);
}

.verify-swatch-pin {
  background: #0d9488 !important;
  box-shadow: 0 0 0 2px rgba(13, 148, 136, 0.25) !important;
}

.verify-swatch-bill {
  background: #ea580c !important;
  box-shadow: 0 0 0 2px rgba(234, 88, 12, 0.22) !important;
}

.verify-swatch-line {
  background: #6366f1 !important;
  border-radius: 2px !important;
}

.verify-dist-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  font-family: 'Bai Jamjuree', sans-serif;
}

.verify-dist-chip.is-ok {
  background: #ecfdf5;
  color: #047857;
}

.verify-dist-chip.is-far {
  background: #fff7ed;
  color: #c2410c;
}

.verify-dist-chip.is-missing {
  background: #fef2f2;
  color: #b91c1c;
}

.verify-view-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.verify-view-chip {
  border: 1px solid rgba(15, 23, 42, 0.12);
  background: #fff;
  color: #334155;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 700;
  font-family: 'Bai Jamjuree', sans-serif;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.verify-view-chip:hover {
  border-color: rgba(194, 65, 12, 0.35);
  color: #c2410c;
}

.verify-view-chip.is-active {
  background: #fff7ed;
  border-color: rgba(234, 88, 12, 0.4);
  color: #c2410c;
}

.verify-marker-wrap {
  background: transparent !important;
  border: none !important;
}

.verify-marker-wrap.is-dimmed {
  opacity: 0.28;
  filter: grayscale(0.35);
}

.verify-marker {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 46px;
  padding: 3px 8px 4px;
  border-radius: 10px;
  border: 2px solid #fff;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.22);
  line-height: 1.05;
  font-family: 'Bai Jamjuree', sans-serif;
  white-space: nowrap;
}

.verify-marker-pin {
  background: #0d9488;
  color: #fff;
}

.verify-marker-bill {
  background: #ea580c;
  color: #fff;
  border-radius: 6px;
}

.verify-marker.is-selected {
  transform: scale(1.08);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.35), 0 6px 16px rgba(15, 23, 42, 0.28);
}

.verify-marker-kind {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.02em;
  opacity: 0.92;
}

.verify-marker-num {
  font-size: 13px;
  font-weight: 800;
}

.verify-distance-pill {
  border-color: rgba(79, 70, 229, 0.35) !important;
  color: #4338ca !important;
  font-size: 12px !important;
}

.verify-result-item.is-active {
  background: #fff7ed;
  border-color: rgba(234, 88, 12, 0.28);
}

.verify-result-item.is-active .route-order-num {
  background: #ea580c;
  color: #fff;
}

.map-kicker-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.12);
}

.map-kicker-route .map-kicker-dot {
  box-shadow: 0 0 0 4px rgba(8, 145, 178, 0.14);
}

.map-refresh-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.map-control-card {
  padding: 16px;
  border-radius: 18px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  border: 1px solid rgba(226, 232, 240, 0.95);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.04);
}

.map-filters {
  margin-bottom: 0;
}

.map-control-card .map-filters {
  margin-bottom: 12px;
}

.map-stats-bar,
.map-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
}

.map-stat-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid #e2e8f0;
  color: #334155;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
}

.map-stat-chip strong {
  font-weight: 800;
  color: #0f172a;
}

.map-stat-chip-primary {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.12), rgba(37, 99, 235, 0.08));
  border-color: rgba(99, 102, 241, 0.2);
  color: #3730a3;
}

.map-stat-chip-primary strong {
  color: #312e81;
}

.map-stat-chip-muted {
  background: #f8fafc;
  color: #64748b;
}

.map-stat-chip-ok {
  background: #ecfdf5;
  border-color: #a7f3d0;
  color: #047857;
}

.map-stat-chip-bad {
  background: #fef2f2;
  border-color: #fecaca;
  color: #b91c1c;
}

.map-status-key {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed #e2e8f0;
}

.map-status-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #64748b;
  font-size: 12px;
  font-weight: 600;
}

.map-status-swatch {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.12);
}

.map-status-swatch.is-pending {
  background: #94a3b8;
}

.map-status-swatch.is-ok {
  background: #10b981;
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.25);
}

.map-status-swatch.is-bad {
  background: #ef4444;
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.22);
}

.map-boundary-toggles {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed #e2e8f0;
}

.map-boundary-label {
  font-size: 12px;
  font-weight: 800;
  color: #475569;
  margin-right: 2px;
}

.map-boundary-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid #e2e8f0;
  color: #334155;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.map-boundary-toggle:has(input:checked) {
  background: #ecfeff;
  border-color: rgba(8, 145, 178, 0.35);
  color: #0e7490;
}

.map-boundary-toggle input {
  width: 14px;
  height: 14px;
  accent-color: #0891b2;
  cursor: pointer;
}

.map-boundary-status {
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
}

.map-boundary-status.is-error {
  color: #b91c1c;
}

/* Store stock card */
#stockCardTable {
  table-layout: auto !important;
  width: max-content !important;
  min-width: 100%;
  border-collapse: collapse;
}

#stockCardTable th,
#stockCardTable td {
  white-space: nowrap;
  padding: 8px 10px;
  min-width: 64px;
  text-align: center;
}

#stockCardTable th.stock-card-date-col,
#stockCardTable td:first-child {
  min-width: 72px;
  position: sticky;
  left: 0;
  z-index: 2;
  background: #fff;
  text-align: left;
}

#stockCardTable thead th.stock-card-date-col {
  z-index: 3;
  background: var(--bg, #f8fafc);
  vertical-align: middle;
}

#stockCardTable th.stock-card-type-head {
  background: #eef2ff;
  font-weight: 700;
  text-align: center;
  border-bottom: 1px solid #c7d2fe;
}

#stockCardTable .stock-card-group-box {
  border-top: 3px solid #1e293b;
  border-left: 3px solid #1e293b;
  border-right: 3px solid #1e293b;
}

#stockCardTable .stock-card-group-start {
  border-left: 3px solid #1e293b;
}

#stockCardTable .stock-card-group-end {
  border-right: 3px solid #1e293b;
}

#stockCardTable .stock-card-group-bottom {
  border-bottom: 3px solid #1e293b;
}

#stockCardTable th.stock-card-sub-col {
  font-size: 12px;
  font-weight: 600;
  background: #f8fafc;
}

#stockCardTable td.stock-card-sub-change {
  background: rgba(251, 191, 36, 0.08);
}

#stockCardTable td.stock-card-sub-sale {
  background: rgba(59, 130, 246, 0.06);
}

#stockCardTable td.stock-card-sub-remain,
#stockCardTable th.stock-card-sub-remain {
  background: rgba(14, 165, 233, 0.08);
}

#stockCardTable td.stock-card-sub-total,
#stockCardTable th.stock-card-sub-total {
  background: rgba(16, 185, 129, 0.08);
  font-weight: 700;
}

#stockCardTable .total-row td:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  background: #fff;
}

.sales-map-wrap {
  position: relative;
  flex: 1;
  min-height: 560px;
}

.map-expand-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 1000;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border: 1px solid rgba(226, 232, 240, 0.95);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.96);
  color: #0f172a;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.12);
  cursor: pointer;
  backdrop-filter: blur(8px);
  transition: transform 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.map-expand-btn:hover {
  transform: translateY(-1px);
  background: #fff;
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.16);
}

.map-expand-btn .map-expand-icon-close[hidden],
.map-expand-btn .map-expand-icon-open[hidden] {
  display: none;
}

.sales-map-wrap.is-expanded {
  position: fixed;
  inset: 0;
  z-index: 2000;
  min-height: 100vh;
  padding: 0;
  background: #0f172a;
}

.sales-map-wrap.is-expanded .sales-map {
  min-height: 100vh;
  height: 100vh;
  border: none;
  border-radius: 0;
}

.sales-map-wrap.is-expanded .map-expand-btn {
  top: 16px;
  right: 16px;
  background: #fff;
}

.sales-map-wrap.is-expanded .map-expand-label::before {
  content: none;
}

body.map-expanded-open {
  overflow: hidden;
}

.sales-map {
  width: 100%;
  height: 100%;
  min-height: 560px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 20px;
  overflow: hidden;
  background:
    radial-gradient(circle at top left, rgba(99, 102, 241, 0.08), transparent 40%),
    #e2e8f0;
  z-index: 1;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65);
}

.map-legend {
  margin: 0;
  padding: 16px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  border: 1px solid rgba(226, 232, 240, 0.95);
  border-radius: 18px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.04);
}

.map-legend-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.map-legend-title {
  margin: 0;
  font-size: 14px;
  font-weight: 800;
  color: #0f172a;
}

.map-legend-subtitle {
  margin-top: 4px;
  font-size: 12px;
  color: #64748b;
}

.map-legend-total {
  flex-shrink: 0;
  padding: 6px 10px;
  border-radius: 999px;
  background: #eef2ff;
  color: #4338ca;
  font-size: 12px;
  font-weight: 700;
}

.map-legend-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
}

.map-legend-item {
  display: grid;
  grid-template-columns: 14px 1fr auto;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 9px 11px;
  background: #fff;
  border: 1px solid #e8eef5;
  border-radius: 12px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.map-legend-item:hover {
  border-color: rgba(99, 102, 241, 0.28);
  box-shadow: 0 6px 16px rgba(99, 102, 241, 0.08);
}

.map-legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.14);
}

.map-legend-label {
  font-size: 13px;
  font-weight: 700;
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.map-legend-count {
  font-size: 12px;
  font-weight: 700;
  color: #64748b;
  white-space: nowrap;
}

.route-workspace {
  display: grid;
  grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
  gap: 14px;
  align-items: stretch;
  flex: 1;
  min-height: 560px;
}

.route-workspace .route-order-list[hidden] + .route-map-wrap,
.route-workspace:has(.route-order-list[hidden]) {
  grid-template-columns: 1fr;
}

.route-map-wrap {
  min-height: 560px;
}

.map-boundary-tooltip {
  background: rgba(15, 23, 42, 0.92) !important;
  border: none !important;
  border-radius: 10px !important;
  color: #fff !important;
  padding: 8px 10px !important;
  font-family: 'Bai Jamjuree', sans-serif !important;
  font-size: 12px !important;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.28) !important;
}

.map-boundary-tooltip::before {
  border-top-color: rgba(15, 23, 42, 0.92) !important;
}

.route-marker-num {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border-radius: 999px;
  background: linear-gradient(135deg, #4f46e5, #2563eb);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  border: 2px solid #fff;
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.34);
  cursor: pointer;
}

.route-order-list {
  margin: 0;
  min-height: 0;
  height: 100%;
}

.route-order-card {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-height: min(72vh, 720px);
  background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
  border: 1px solid rgba(226, 232, 240, 0.95);
  border-radius: 20px;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.06);
  overflow: hidden;
}

.route-order-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  background: linear-gradient(135deg, rgba(8, 145, 178, 0.1), rgba(37, 99, 235, 0.06));
  border-bottom: 1px solid rgba(226, 232, 240, 0.9);
}

.route-order-card-head-main {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.route-order-card-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: #fff;
  color: #0e7490;
  border: 1px solid rgba(8, 145, 178, 0.16);
  box-shadow: 0 2px 8px rgba(8, 145, 178, 0.08);
}

.route-order-card-title {
  font-size: 13px;
  font-weight: 800;
  color: #0f172a;
  font-family: 'Bai Jamjuree', sans-serif;
}

.route-order-card-subtitle {
  margin-top: 1px;
  font-size: 11px;
  color: #64748b;
}

.route-order-count {
  flex-shrink: 0;
  padding: 4px 8px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid rgba(8, 145, 178, 0.16);
  color: #0e7490;
  font-size: 11px;
  font-weight: 700;
  box-shadow: none;
}

.route-order-head-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.route-order-distance-total {
  padding: 4px 8px;
  border-radius: 999px;
  background: #eef2ff;
  border: 1px solid rgba(99, 102, 241, 0.18);
  color: #4338ca;
  font-size: 11px;
  font-weight: 800;
}

.route-order-row {
  display: contents;
}

.route-order-maps-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid rgba(8, 145, 178, 0.22);
  background: #ecfeff;
  color: #0e7490;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.route-order-maps-btn:hover {
  background: #cffafe;
  border-color: rgba(8, 145, 178, 0.4);
  color: #0f766e;
}

.route-order-segment {
  display: grid;
  grid-template-columns: 18px 1fr auto;
  align-items: center;
  gap: 6px;
  margin: 0 6px 4px 14px;
}

.route-order-segment-line {
  width: 2px;
  height: 12px;
  justify-self: center;
  border-radius: 999px;
  background: linear-gradient(#67e8f9, #6366f1);
}

.route-order-segment-km {
  padding: 2px 8px;
  border-radius: 999px;
  background: #eef2ff;
  color: #4338ca;
  font-size: 10px;
  font-weight: 800;
  width: fit-content;
  font-family: 'Bai Jamjuree', sans-serif;
}

.route-order-segment-maps {
  color: #0e7490;
  font-size: 11px;
  font-weight: 800;
  text-decoration: none;
}

.route-order-segment-maps:hover {
  text-decoration: underline;
}

.map-stat-chip-distance {
  background: #eef2ff;
  border-color: rgba(99, 102, 241, 0.22);
  color: #4338ca;
}

.route-distance-label {
  background: transparent;
  border: none;
}

.route-distance-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(37, 99, 235, 0.25);
  color: #1d4ed8;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
  box-shadow: 0 6px 14px rgba(37, 99, 235, 0.16);
}

.route-popup-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.route-popup-field-distance .route-popup-value {
  color: #4338ca;
  font-weight: 800;
}

.map-popup-btn-secondary {
  background: #ecfeff !important;
  color: #0e7490 !important;
  border: 1px solid rgba(8, 145, 178, 0.25) !important;
}

.map-popup-btn-secondary:hover {
  background: #cffafe !important;
}

.route-order-scroll {
  flex: 1;
  max-height: none;
  overflow: auto;
  padding: 8px;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}

.route-order-scroll::-webkit-scrollbar {
  width: 6px;
}

.route-order-scroll::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 999px;
}

.route-order-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px;
  margin-bottom: 4px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  cursor: pointer;
  text-align: left;
  font-family: 'Bai Jamjuree', sans-serif;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.route-order-item:last-child {
  margin-bottom: 0;
}

.route-order-item:hover {
  border-color: rgba(8, 145, 178, 0.22);
  background: linear-gradient(180deg, #ffffff 0%, #f0fdfa 100%);
  box-shadow: 0 4px 12px rgba(8, 145, 178, 0.08);
}

.route-order-item:active {
  transform: none;
}

.route-order-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.route-order-shop {
  font-size: 13px;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.25;
  font-family: 'Bai Jamjuree', sans-serif;
}

.route-order-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}

.route-order-district {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 999px;
  background: #ecfeff;
  color: #0e7490;
  font-size: 10px;
  font-weight: 700;
}

.route-order-time {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 999px;
  background: #eef2ff;
  color: #4338ca;
  font-size: 10px;
  font-weight: 700;
}

@media (max-width: 1100px) {
  .route-workspace {
    grid-template-columns: 1fr;
  }

  .route-order-card {
    max-height: 320px;
  }

  .sales-map-wrap,
  .sales-map,
  .route-map-wrap {
    min-height: 480px;
  }
}

@media (max-width: 720px) {
  .map-panel {
    padding: 14px;
  }

  .map-toolbar-copy h2 {
    font-size: 22px;
  }

  .map-control-card {
    padding: 12px;
  }

  .sales-map-wrap,
  .sales-map,
  .route-map-wrap {
    min-height: 420px;
  }

  .map-expand-label {
    display: none;
  }

  .map-expand-btn {
    padding: 10px;
  }
}


.route-order-bill {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 6px;
  background: #f1f5f9;
  color: #475569;
  font-size: 10px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  font-family: 'Bai Jamjuree', sans-serif;
}

.route-order-cancel-badge,
.route-popup-cancel-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 999px;
  background: #fef2f2;
  color: #b91c1c;
  font-size: 10px;
  font-weight: 700;
}

.route-order-item.is-cancelled {
  border-color: rgba(185, 28, 28, 0.18);
  background: linear-gradient(180deg, #fff 0%, #fff7f7 100%);
}

.route-order-item.is-cancelled .route-order-num {
  background: linear-gradient(135deg, #f87171, #dc2626);
}

.route-marker-num.is-cancelled {
  background: linear-gradient(135deg, #f87171, #dc2626);
  box-shadow: 0 6px 16px rgba(220, 38, 38, 0.32);
}

.route-order-chevron {
  display: none;
}

.route-order-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 26px;
  padding: 0 6px;
  border-radius: 999px;
  background: linear-gradient(135deg, #0d9488, #0891b2);
  color: #fff;
  font-weight: 800;
  font-size: 11px;
  font-family: 'Bai Jamjuree', sans-serif;
  box-shadow: 0 4px 10px rgba(8, 145, 178, 0.24);
}

.route-popup-header .map-popup-title {
  margin-top: 6px;
}

.route-popup-body {
  padding-top: 14px !important;
}

.route-popup-order-large {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  border-radius: 12px;
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  box-shadow: 0 6px 14px rgba(37, 99, 235, 0.24);
}

.route-popup-items {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.route-popup-item {
  padding: 14px;
  border-radius: 14px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  border: 1px solid rgba(226, 232, 240, 0.95);
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.04);
}

.route-popup-item-top {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.route-popup-item-title {
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.route-popup-shop {
  margin-top: 2px;
  font-size: 15px;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.35;
}

.route-popup-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.route-popup-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid #eef2f7;
}

.route-popup-label {
  font-size: 11px;
  font-weight: 600;
  color: #94a3b8;
  letter-spacing: 0.03em;
}

.route-popup-value {
  font-size: 13px;
  font-weight: 700;
  color: #0f172a;
}

.route-popup-bill {
  font-variant-numeric: tabular-nums;
  color: #334155;
}

.map-popup-route-order {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  padding: 0 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.2);
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 8px;
}

.map-popup-card-wrapper.leaflet-popup {
  margin-bottom: 14px;
  font-family: 'Bai Jamjuree', sans-serif;
}

.map-popup-card-wrapper .leaflet-popup-content-wrapper {
  padding: 0;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.18);
  border: 1px solid rgba(226, 232, 240, 0.95);
  font-family: 'Bai Jamjuree', sans-serif !important;
}

.map-popup-card-wrapper .leaflet-popup-content {
  margin: 0;
  width: 280px !important;
  line-height: 1.4;
  font-family: 'Bai Jamjuree', sans-serif !important;
}

.map-popup-card,
.map-popup-card *,
.route-popup-card,
.route-popup-card *,
.leaflet-tooltip,
.map-boundary-tooltip,
.modal-overlay,
.modal-overlay *,
.modal-panel,
.modal-panel * {
  font-family: 'Bai Jamjuree', sans-serif !important;
}

.map-page,
.map-page * {
  font-family: 'Bai Jamjuree', sans-serif;
}

.map-popup-card-wrapper .leaflet-popup-close-button {
  top: 10px;
  right: 10px;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: #64748b !important;
  font-size: 20px !important;
  line-height: 26px !important;
  text-align: center;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.12);
}

.map-popup-card-wrapper .leaflet-popup-close-button:hover {
  background: #fff;
  color: #0f172a !important;
}

.map-popup-card-wrapper .leaflet-popup-tip {
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.12);
}

.map-popup-card {
  overflow: hidden;
  background: #fff;
}

.map-popup-header {
  padding: 16px 18px 14px;
  background: linear-gradient(135deg, var(--zone-color), color-mix(in srgb, var(--zone-color) 78%, #111827));
  color: #fff;
}

.map-popup-zone {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.28);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.4px;
}

.map-popup-title {
  margin: 10px 0 0;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.35;
  color: #fff;
}

.map-popup-body {
  padding: 14px 16px 16px;
}

.map-popup-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}

.map-popup-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(8, 145, 178, 0.12);
  color: #0891b2;
  flex-shrink: 0;
}

.map-popup-row-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.map-popup-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  color: #94a3b8;
}

.map-popup-value {
  display: block;
  font-size: 15px;
  font-weight: 700;
  color: #0f172a;
}

.map-popup-coords-box {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

.map-popup-coord-item {
  padding: 10px 12px;
  border-radius: 12px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
}

.map-popup-coord-item code {
  display: block;
  margin-top: 4px;
  font-family: Consolas, 'Courier New', monospace;
  font-size: 12px;
  font-weight: 600;
  color: #334155;
  word-break: break-all;
}

.map-popup-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.map-popup-check-actions {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.map-popup-copy,
.map-popup-btn,
.map-popup-verify,
.map-popup-reject {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 12px;
  border-radius: 10px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.map-popup-verify {
  border: 1px solid #86efac;
  background: #f0fdf4;
  color: #047857;
}

.map-popup-verify:hover {
  background: #dcfce7;
  border-color: #4ade80;
}

.map-popup-verify.is-verified {
  background: #059669;
  border-color: #059669;
  color: #fff;
  cursor: default;
}

.map-popup-verify.is-verified svg {
  stroke: #fff;
}

.map-popup-reject {
  border: 1px solid #fca5a5;
  background: #fef2f2;
  color: #b91c1c;
}

.map-popup-reject:hover {
  background: #fee2e2;
  border-color: #f87171;
}

.map-popup-reject.is-rejected {
  background: #dc2626;
  border-color: #dc2626;
  color: #fff;
  cursor: default;
}

.map-popup-reject.is-rejected svg {
  stroke: #fff;
}

.map-popup-copy {
  border: 1px solid #e2e8f0;
  background: #fff;
  color: #475569;
}

.map-popup-copy:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
}

.map-popup-copy.is-copied {
  background: #ecfdf5;
  border-color: #86efac;
  color: #047857;
}

.map-popup-card-wrapper a.map-popup-btn,
.map-popup-card-wrapper .map-popup-btn {
  border: none;
  background: linear-gradient(135deg, #0891b2, #0e7490);
  color: #000 !important;
  box-shadow: 0 8px 18px rgba(8, 145, 178, 0.28);
}

.map-popup-card-wrapper a.map-popup-btn:hover,
.map-popup-card-wrapper a.map-popup-btn:visited,
.map-popup-card-wrapper a.map-popup-btn:active,
.map-popup-card-wrapper .map-popup-btn:hover {
  color: #000 !important;
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(8, 145, 178, 0.34);
}

.map-popup-card-wrapper .map-popup-btn svg {
  stroke: #000;
}

/* Monthly sales matrix — Excel-style layout */
.matrix-header {
  text-align: center;
  margin-bottom: 16px;
}

.matrix-title {
  font-size: 22px;
  font-weight: 700 !important;
  color: #000;
  margin: 0;
}

.waste-matrix-sheet {
  overflow-x: auto;
  margin-top: 12px;
}

#wasteByShopTable {
  table-layout: auto;
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
}

#wasteByShopTable th,
#wasteByShopTable td {
  white-space: nowrap;
  padding: 8px 10px;
  min-width: 72px;
  text-align: center;
}

#wasteByShopTable th.waste-shop-col,
#wasteByShopTable td:first-child {
  min-width: 160px;
  max-width: 240px;
  position: sticky;
  left: 0;
  z-index: 2;
  background: #fff;
  text-align: left;
}

#wasteByShopTable th.waste-district-col,
#wasteByShopTable td.waste-district-cell {
  min-width: 110px;
  max-width: 160px;
  position: sticky;
  left: 160px;
  z-index: 2;
  background: #fff;
  text-align: left;
  font-weight: 600;
  color: #334155;
}

#wasteByShopTable thead th.waste-shop-col,
#wasteByShopTable thead th.waste-district-col {
  z-index: 3;
  background: var(--bg, #f8fafc);
}

#wasteByShopTable .waste-total-row td:first-child {
  background: #fff;
}

#wasteByShopTable .waste-total-row td:nth-child(2) {
  position: sticky;
  left: 160px;
  z-index: 2;
  background: #fff;
}

#wasteByShopTable .district-row td:first-child {
  background: rgba(99, 102, 241, 0.06);
}

#wasteByShopTable td.empty-cell {
  background: transparent;
}

#wasteByShopTable td.waste-qty-cell {
  cursor: pointer;
}

#wasteByShopTable td.waste-qty-cell:hover {
  background: rgba(225, 29, 72, 0.08);
}

#wasteDailyTable {
  table-layout: auto;
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
}

#wasteDailyTable th,
#wasteDailyTable td {
  white-space: nowrap;
  padding: 8px 10px;
  min-width: 72px;
  text-align: center;
}

#wasteDailyTable th.waste-date-col,
#wasteDailyTable td:first-child {
  min-width: 110px;
  position: sticky;
  left: 0;
  z-index: 2;
  background: #fff;
  text-align: left;
}

#wasteDailyTable thead th.waste-date-col {
  z-index: 3;
  background: var(--bg, #f8fafc);
}

#wasteDailyTable .waste-total-row td:first-child {
  background: #fff;
}

#wasteDailyTable td.empty-cell {
  background: transparent;
}

#wasteDailyTable td.waste-qty-cell {
  cursor: pointer;
}

#wasteDailyTable td.waste-qty-cell:hover {
  background: rgba(225, 29, 72, 0.08);
}

#wasteDailyTable td.waste-date-cell {
  cursor: pointer;
  font-weight: 700;
  color: #0f172a;
}

#wasteDailyTable td.waste-date-cell:hover {
  background: rgba(225, 29, 72, 0.08);
}

#employeesTable {
  table-layout: auto;
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
}

#employeesTable th,
#employeesTable td {
  white-space: nowrap;
  padding: 10px 14px;
  border: 1px solid #334155;
  text-align: left;
}

#employeesTable thead th {
  background: var(--bg, #f8fafc);
  font-weight: 700;
}

#employeesTable th.emp-sticky-col,
#employeesTable td.emp-sticky-col {
  position: sticky;
  left: 0;
  z-index: 2;
  background: #fff;
}

#employeesTable thead th.emp-sticky-col {
  z-index: 3;
  background: var(--bg, #f8fafc);
}

#employeesTable td.emp-enable.is-on {
  color: #047857;
  font-weight: 700;
}

#employeesTable td.emp-enable.is-off {
  color: #94a3b8;
}

#employeeScanTable,
#employeeScanTable {
  table-layout: auto;
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
}

#employeeScanTable th,
#employeeScanTable td,
#employeeScanTable th,
#employeeScanTable td {
  padding: 10px 14px;
  border: 1px solid #334155;
  text-align: left;
  white-space: nowrap;
}

#employeeScanTable td.scan-times-cell,
#employeeScanTable td.scan-times-cell {
  white-space: normal;
  min-width: 280px;
  max-width: 560px;
  line-height: 1.45;
}

#employeeScanTable td.scan-count-cell,
#employeeScanTable td.scan-count-cell {
  text-align: center;
  font-weight: 700;
}

#employeeScanTable th.scan-slot-head,
#employeeScanTable td.scan-slot-cell,
#employeeScanTable th.scan-slot-head,
#employeeScanTable td.scan-slot-cell {
  text-align: center;
  font-variant-numeric: tabular-nums;
  min-width: 96px;
}

#employeeScanTable .scan-date-row td,
#employeeScanTable .scan-date-row td {
  background: #fff1f2;
  color: #9f1239;
  font-weight: 700;
}

#employeeScanTable thead th,
#employeeScanTable thead th {
  background: var(--bg, #f8fafc);
  font-weight: 700;
}

#employeeScanTable th.emp-sticky-col,
#employeeScanTable td.emp-sticky-col,
#employeeScanTable th.emp-sticky-col,
#employeeScanTable td.emp-sticky-col {
  position: sticky;
  left: 0;
  z-index: 2;
  background: #fff;
}

#employeeScanTable thead th.emp-sticky-col,
#employeeScanTable thead th.emp-sticky-col {
  z-index: 3;
  background: var(--bg, #f8fafc);
}

.waste-modal-overlay,
.waste-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 5000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(15, 23, 42, 0.64);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  animation: wasteModalOverlayIn 0.2s ease;
}

.waste-modal-overlay[hidden],
.waste-modal-overlay[hidden] {
  display: none !important;
}

.missing-scan-modal {
  width: min(560px, 94vw);
}

.missing-scan-list {
  width: 100%;
  border-collapse: collapse;
}

.missing-scan-list th,
.missing-scan-list td {
  padding: 10px 12px;
  border: 1px solid #334155;
  text-align: left;
}

.missing-scan-list th {
  background: #fff1f2;
  color: #9f1239;
}

.missing-scan-count {
  font-weight: 700;
}

.leave-cycle-label {
  margin: 0 0 16px;
  color: var(--text-muted);
  font-size: 14px;
}

.filter-row .leave-emp-filter {
  grid-column: span 2;
}

.leave-day {
  margin-bottom: 14px;
  border: 1px solid #334155;
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
}

.leave-day.is-today {
  border-color: #e11d48;
}

.leave-day-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: #fff1f2;
}

.leave-day-head strong {
  margin-right: 10px;
}

.leave-day-head span {
  color: #9f1239;
  font-size: 13px;
}

.leave-add-btn,
.leave-remove-btn {
  border: 1px solid #e11d48;
  border-radius: 8px;
  padding: 6px 12px;
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
}

.leave-add-btn {
  background: #e11d48;
  color: #fff;
}

.leave-add-btn:hover {
  background: #be123c;
}

.leave-remove-btn {
  background: #fff;
  color: #e11d48;
}

.leave-remove-btn:hover {
  background: #fff1f2;
}

.leave-day-table {
  width: 100%;
  border-collapse: collapse;
}

.leave-day-table th,
.leave-day-table td {
  padding: 8px 12px;
  border-top: 1px solid #e2e8f0;
  text-align: left;
}

.leave-day-table th {
  background: #f8fafc;
  font-size: 13px;
}

.leave-check-cell {
  width: 64px;
  text-align: center;
}

.leave-off-check {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.leave-empty {
  color: var(--text-muted);
}

.leave-actions {
  width: 72px;
}

@keyframes wasteModalOverlayIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes wasteModalIn {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.waste-modal {
  width: min(620px, 94vw);
  max-height: min(84vh, 760px);
  display: flex;
  flex-direction: column;
  background: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 22px;
  box-shadow: 0 28px 80px rgba(15, 23, 42, 0.38);
  overflow: hidden;
  animation: wasteModalIn 0.24s ease;
}

.waste-modal.is-wide {
  width: min(1680px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  height: calc(100vh - 32px);
}

.waste-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 22px 16px;
  background:
    radial-gradient(circle at 100% 0%, rgba(244, 63, 94, 0.12), transparent 42%),
    linear-gradient(180deg, #fff7f8 0%, #ffffff 100%);
  border-bottom: 1px solid #f1f5f9;
}

.waste-modal-heading {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  min-width: 0;
}

.waste-modal-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: linear-gradient(160deg, #fb7185, #e11d48);
  color: #ffffff;
  box-shadow: 0 8px 18px rgba(225, 29, 72, 0.28);
  flex-shrink: 0;
}

.waste-modal-header h3 {
  margin: 0 0 8px;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: #0f172a;
}

.waste-modal-sub {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0;
}

.waste-modal-meta-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.waste-modal-meta-label {
  flex-shrink: 0;
  min-width: 42px;
  color: #64748b;
  font-size: 13px;
  font-weight: 600;
}

.waste-modal-meta-value {
  color: #0f172a;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.35;
  word-break: break-word;
}

.waste-modal-meta-product {
  color: #9f1239;
}

.waste-modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #ffffff;
  color: #64748b;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  flex-shrink: 0;
}

.waste-modal-close:hover {
  background: #f8fafc;
  color: #0f172a;
  border-color: #cbd5e1;
}

.waste-modal-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 18px 20px 20px;
  background: #ffffff;
}

.waste-modal-empty {
  margin: 0;
  padding: 28px 8px;
  text-align: center;
  color: var(--text-muted);
}

.waste-modal-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.waste-modal-stat {
  padding: 12px 14px;
  border: 1px solid #eef2f7;
  border-radius: 14px;
  background: #f8fafc;
}

.waste-modal-stat-label {
  display: block;
  margin-bottom: 4px;
  color: #64748b;
  font-size: 12px;
  font-weight: 600;
}

.waste-modal-stat-value {
  display: block;
  color: #0f172a;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.waste-modal-stat-value small {
  font-size: 12px;
  font-weight: 600;
  color: #94a3b8;
}

.waste-modal-stat-value.is-waste {
  color: #e11d48;
}

.waste-modal-table-wrap {
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  overflow: auto;
}

.waste-modal-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.waste-modal-table.is-matrix {
  width: max-content;
  min-width: 100%;
}

.waste-modal-table.is-matrix th,
.waste-modal-table.is-matrix td {
  white-space: nowrap;
  min-width: 72px;
}

.waste-modal-table.is-matrix th:first-child,
.waste-modal-table.is-matrix td:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  background: #fff;
  min-width: 160px;
}

.waste-modal-table.is-matrix thead th:first-child {
  z-index: 2;
  background: #f8fafc;
}

.waste-modal-table.is-matrix tbody tr:hover td:first-child {
  background: #fdf2f8;
}

.waste-modal-table.is-matrix tfoot td:first-child {
  background: #fff1f2;
}

.waste-modal-table th,
.waste-modal-table td {
  padding: 11px 14px;
  text-align: right;
  border: 1px solid #334155;
  font-variant-numeric: tabular-nums;
}

.waste-modal-table th:first-child,
.waste-modal-table td:first-child,
.waste-modal-table th.waste-modal-district,
.waste-modal-table td.waste-modal-district,
.waste-modal-table th.waste-modal-product,
.waste-modal-table td.waste-modal-product {
  text-align: left;
}

.waste-modal-table thead th {
  background: #f8fafc;
  color: #334155;
  font-size: 13px;
  font-weight: 700;
}

.waste-modal-table tbody td {
  color: #0f172a;
  font-size: 15px;
  font-weight: 700;
}

.waste-modal-table tbody td:first-child {
  color: #1e293b;
  font-weight: 600;
}

.waste-modal-table tbody tr:hover td {
  background: #fdf2f8;
}

.waste-modal-table tfoot td {
  background: #fff1f2;
  border-bottom: none;
  color: #9f1239;
  font-weight: 700;
}

@media (max-width: 640px) {
  .waste-modal-stats {
    grid-template-columns: 1fr;
  }

  .waste-modal-stat-value {
    font-size: 18px;
  }
}

.waste-matrix-table {
  border-collapse: collapse;
  width: max-content;
  min-width: 100%;
  font-size: 13px;
  background: #fff;
}

.waste-matrix-table th,
.waste-matrix-table td {
  border: 1px solid #000;
  padding: 6px 8px;
  text-align: center;
  vertical-align: middle;
  white-space: nowrap;
}

.waste-matrix-table thead th {
  font-weight: 700;
  background: #fff;
}

.waste-zone-col {
  font-weight: 700;
  text-align: center !important;
  min-width: 110px;
}

.waste-corner {
  position: relative;
  min-width: 110px;
  height: 56px;
  padding: 0 !important;
  overflow: hidden;
  background: #fff !important;
}

.waste-corner::after {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    to top right,
    transparent calc(50% - 1px),
    #000 calc(50% - 1px),
    #000 calc(50% + 1px),
    transparent calc(50% + 1px)
  );
  pointer-events: none;
  z-index: 0;
}

.waste-corner-product,
.waste-corner-zone {
  position: absolute;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  z-index: 1;
}

.waste-corner-product {
  top: 6px;
  right: 8px;
}

.waste-corner-zone {
  left: 8px;
  bottom: 6px;
}

.waste-total-row td,
.waste-standard-row td {
  font-weight: 700;
}

.waste-standard-row td {
  background: #fafafa;
}

.waste-pct-cell {
  cursor: pointer;
}

.waste-pct-cell:hover {
  background: #f1f5f9;
}

.matrix-wrapper {
  background: #fff;
  padding: 8px 0 16px;
}

.matrix-sheet {
  display: block;
  width: 2116px;
  min-width: 2116px;
}

#distTableContent {
  display: block;
}

.matrix-block {
  display: block;
  width: 2116px;
}

.matrix-gap {
  display: block;
  width: 2116px;
  height: 3em;
  min-height: 48px;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  box-sizing: content-box;
}

.matrix-table {
  border-collapse: collapse;
  font-size: 14px;
  font-weight: 700;
  table-layout: fixed;
  width: 2116px !important;
  background: #fff;
  color: #000;
}

.matrix-table th,
.matrix-table td {
  border: 1px solid #000;
  padding: 6px 5px;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  background: #fff;
  font-weight: 700 !important;
}

.matrix-table strong {
  font-weight: 700 !important;
}

.matrix-product-col {
  background: #fff;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.25;
  white-space: normal;
  word-break: break-word;
  vertical-align: middle;
}

.matrix-sub-col {
  font-size: 13px;
  font-weight: 700;
  background: #fff;
  white-space: nowrap;
  vertical-align: middle;
}

.matrix-zone-col {
  background: #fff;
  font-weight: 700;
  text-align: center !important;
  position: sticky;
  left: 0;
  z-index: 2;
  width: 100px;
  min-width: 100px;
  max-width: 100px;
  white-space: nowrap;
  padding: 6px 6px;
}

.matrix-table thead th {
  background: #fff;
  font-weight: 700;
  color: #000;
}

.matrix-empty-col {
  background: #fff;
  width: 72px;
  min-width: 72px;
  max-width: 72px;
}

.matrix-net {
  font-weight: 700;
}

/* คอลัมน์ที่กดดูข้อมูลรายวันได้ — คอลัมน์ "เสีย" และ "ขายสุทธิ" */
.matrix-day-cell {
  cursor: pointer;
  transition: background-color .12s ease;
}

.matrix-day-cell:hover {
  background: #eef2ff;
}

.matrix-day-cell:hover strong {
  text-decoration: underline;
  text-decoration-style: dashed;
  text-underline-offset: 2px;
}

.matrix-day-cell:active {
  background: #e0e7ff;
}

/* คอลัมน์ "เสีย" — สีแดงให้แยกจากคอลัมน์ "ขายสุทธิ" */
.matrix-day-waste strong {
  color: #dc2626;
}

.matrix-day-waste:hover {
  background: #fef2f2;
}

.matrix-day-waste:active {
  background: #fee2e2;
}

/* แถววันที่ใน modal — กดดูรายลูกค้าได้ */
.matrix-day-row {
  cursor: pointer;
  transition: background-color .12s ease;
}

.matrix-day-row:hover {
  background: #eef2ff;
}

.matrix-day-row:hover td:first-child {
  text-decoration: underline;
  text-decoration-style: dashed;
  text-underline-offset: 2px;
}

.matrix-day-row td {
  transition: background-color .12s ease;
}

/* คอลัมน์ % ต่ำกว่า 90 → พื้นแดงเตือนว่ายอดขายไม่ถึงเป้า */
.matrix-pct-low {
  background: #dc2626 !important;
}

.matrix-pct-low strong {
  color: #fff !important;
}

.matrix-total-row td {
  background: #fff;
  font-weight: 700;
}

.matrix-total-row .matrix-empty-col {
  background: #fff;
}

.matrix-footer {
  margin-top: 20px;
  margin-left: 100px;
  width: 2016px;
}

.matrix-footer-row-gap {
  display: block;
  width: 100%;
  height: 16px;
  min-height: 16px;
}

.matrix-footer-table {
  border-collapse: collapse;
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  background: #fff;
  table-layout: fixed;
  width: 100%;
}

.matrix-footer-table td {
  border: 1px solid #000;
  padding: 9px 5px;
  text-align: center;
  vertical-align: middle;
  white-space: nowrap;
  font-weight: 700 !important;
  color: #000;
  overflow: hidden;
  text-overflow: ellipsis;
}

.matrix-footer-table td.matrix-footer-first {
  border-left: none;
}

.matrix-footer-label {
  font-weight: 700;
}

.matrix-footer-value {
  font-weight: 700;
}

.matrix-summary {
  display: flex;
  justify-content: center;
  gap: 32px;
  flex-wrap: nowrap;
  margin-bottom: 12px;
}

.matrix-zone-totals {
  display: flex;
  justify-content: center;
  gap: 0;
  flex-wrap: nowrap;
}

.matrix-box {
  display: inline-flex;
  align-items: stretch;
  justify-content: center;
  border: 1px solid #000;
  font-size: 16px;
  font-weight: 700 !important;
  background: #fff;
  text-align: center;
}

.matrix-box span {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  border-right: 1px solid #000;
  white-space: nowrap;
  text-align: center;
}

.matrix-box strong {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  min-width: 88px;
  text-align: center;
  color: #000;
  font-weight: 700;
}

.matrix-summary .matrix-box span {
  min-width: 148px;
}

.matrix-summary .matrix-box strong {
  min-width: 110px;
}

.matrix-zone-totals .matrix-box span {
  min-width: 64px;
}

.matrix-zone-totals .matrix-box strong {
  min-width: 88px;
}

.board-footer {
  margin-top: 16px;
  padding: 16px;
  background: var(--bg);
  border-radius: 8px;
}

.board-summary {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  font-size: 14px;
  margin-bottom: 8px;
}

.board-summary-col {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 14px;
}

.board-product-name {
  font-size: 24px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 8px;
}

/* Print */
@media print {
  .sidebar, .back-link, .filter-row, .action-buttons, .loading-bar, .btn-show-sidebar, .btn-toggle-sidebar, .waste-modal-overlay, .leave-add-btn, .leave-remove-btn {
    display: none !important;
  }
  .page-layout {
    display: block;
  }
  .main-content {
    padding: 0;
  }
  .panel {
    border: none;
    box-shadow: none;
    padding: 0;
  }
  body {
    background: #fff;
  }
}

/* Competitor stock summary */
.competitor-stats {
  margin: 12px 0 8px;
}

.competitor-brand-rank {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 14px;
}

.competitor-rank-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 170px;
  padding: 8px 10px;
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.competitor-rank-chip:hover {
  border-color: rgba(14, 116, 144, 0.35);
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.08);
}

.competitor-rank-pos {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #ecfeff;
  color: #0e7490;
  font-size: 11px;
  font-weight: 800;
  flex-shrink: 0;
}

.competitor-rank-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  flex: 1;
}

.competitor-rank-main strong {
  font-size: 12px;
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.competitor-rank-bar {
  height: 4px;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
}

.competitor-rank-bar > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #0891b2, #0d9488);
  border-radius: 999px;
}

.competitor-rank-qty {
  font-size: 12px;
  font-weight: 800;
  color: #0f766e;
  flex-shrink: 0;
}

.competitor-table .competitor-sticky-col {
  position: sticky;
  left: 0;
  z-index: 2;
  background: #fff;
  text-align: left !important;
  min-width: 120px;
}

.competitor-table thead .competitor-sticky-col {
  z-index: 3;
}

.competitor-table .competitor-total-col {
  background: #f8fafc;
  font-weight: 700;
}

.competitor-table .competitor-cell-hot {
  background: #ecfdf5;
  color: #047857;
  font-weight: 700;
}

.competitor-table tr.is-filtered-row,
.competitor-table th.is-filtered-col {
  outline: 2px solid rgba(14, 116, 144, 0.25);
}

.competitor-footer-row th,
.competitor-footer-row td {
  border-top: 2px solid #cbd5e1;
  background: #f1f5f9;
}

.competitor-brand-tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  background: #ecfeff;
  color: #0e7490;
  font-size: 12px;
  font-weight: 700;
}

.competitor-table td.num,
.competitor-table th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.competitor-table .competitor-district-row td {
  background: rgba(8, 145, 178, 0.1);
  font-weight: 700;
  color: #0e7490;
}

.competitor-table .competitor-district-row .competitor-sticky-col {
  background: rgba(8, 145, 178, 0.12);
}

.competitor-district-meta {
  font-weight: 600;
  font-size: 12px;
  color: #334155;
}

.competitor-subtotal-row th,
.competitor-subtotal-row td {
  background: #f0fdfa;
  border-top: 1px solid #99f6e4;
}

.competitor-subtotal-row .competitor-sticky-col {
  background: #f0fdfa;
}

.btn-export-chart {
  background: #0f766e !important;
}

.btn-export-chart:hover {
  filter: brightness(1.05);
}

.year-zone-chart-wrap {
  background: #fff;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 14px;
  padding: 16px 16px 8px;
  margin: 0;
}

.year-zone-chart-modal {
  width: min(1100px, calc(100vw - 32px));
  max-width: 1100px;
}

.year-zone-chart-modal-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

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

.year-zone-table .year-zone-sticky {
  position: sticky;
  left: 0;
  z-index: 2;
  background: #fff;
  text-align: left !important;
  min-width: 110px;
}

.year-zone-table thead .year-zone-sticky {
  z-index: 3;
}

.year-zone-month-name {
  font-size: 10px;
  font-weight: 600;
  color: #64748b;
}

.year-zone-table td.num,
.year-zone-table th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ===== Employee add form ===== */
.employee-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}
.employee-form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.employee-form-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main, #1e293b);
}
.employee-form-input {
  padding: 8px 10px;
  border: 2px solid #e1e5e9;
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: 'Bai Jamjuree', sans-serif;
}
.employee-form-input:focus {
  outline: none;
  border-color: #667eea;
}

/* ===== Employee inline editing ===== */
.emp-editable {
  cursor: pointer;
  background: #f8fafc;
}
.emp-editable:hover {
  background: #e0e7ff;
}
.emp-toggle {
  cursor: pointer;
  font-weight: 700;
  text-align: center;
}
.emp-toggle.is-on,
.emp-enable.is-on {
  color: #059669;
}
.emp-toggle.is-off,
.emp-enable.is-off {
  color: #dc2626;
}
.emp-save-btn,
.emp-cancel-btn {
  padding: 4px 10px;
  border: none;
  border-radius: 4px;
  font-size: 0.8rem;
  cursor: pointer;
  font-family: 'Bai Jamjuree', sans-serif;
}
.emp-save-btn {
  background: #10b981;
  color: white;
}
.emp-cancel-btn {
  background: #ef4444;
  color: white;
}

/* ===== Employee row edit button ===== */
.emp-action-col {
  text-align: center;
  white-space: nowrap;
}
.emp-edit-row-btn {
  padding: 6px 12px;
  border: none;
  border-radius: 6px;
  background: linear-gradient(135deg, #667eea, #5568d3);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  font-family: 'Bai Jamjuree', sans-serif;
  box-shadow: 0 3px 8px rgba(102, 126, 234, 0.25);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.emp-edit-row-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 5px 12px rgba(102, 126, 234, 0.4);
}

/* ===== Employee modal footer buttons ===== */
.emp-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid #e2e8f0;
}
.emp-btn-cancel,
.emp-btn-save {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  border: none;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  font-family: 'Bai Jamjuree', sans-serif;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.emp-btn-save {
  background: linear-gradient(135deg, #667eea, #5568d3);
  color: #fff;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.35);
}
.emp-btn-save:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(102, 126, 234, 0.5);
}
.emp-btn-cancel {
  background: #f1f5f9;
  color: #64748b;
  border: 1px solid #e2e8f0;
}
.emp-btn-cancel:hover {
  background: #e2e8f0;
  color: #475569;
  transform: translateY(-1px);
}

/* ===== Employee toast/notification modal ===== */
.employee-toast {
  max-width: 360px;
  border-radius: 16px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
  background: #fff;
}
.employee-toast-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: #f0fdf4;
  margin: 0 auto;
}
.employee-toast-icon svg {
  display: block;
}
#employeeToast[hidden] {
  display: none !important;
}

/* ===== Employee table search ===== */
.employee-search-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 12px 0;
  flex-wrap: wrap;
}
.employee-search-box {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 260px;
  max-width: 480px;
}
.employee-search-box svg {
  position: absolute;
  left: 12px;
  color: #94a3b8;
  pointer-events: none;
}
.employee-search-box input {
  width: 100%;
  padding: 10px 36px 10px 38px;
  border: 2px solid #e2e8f0;
  border-radius: 10px;
  font-size: 0.95rem;
  font-family: 'Bai Jamjuree', sans-serif;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.employee-search-box input:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
}
.employee-search-box button {
  position: absolute;
  right: 8px;
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 50%;
  background: #e2e8f0;
  color: #64748b;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.employee-search-box button:hover {
  background: #cbd5e1;
  color: #475569;
}
.employee-search-count {
  font-size: 0.85rem;
  color: var(--text-muted, #64748b);
}

/* ===== Employee search (ensure exists) ===== */
.employee-search-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 12px 0;
  flex-wrap: wrap;
}
.employee-search-box {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 260px;
  max-width: 480px;
}
.employee-search-box svg {
  position: absolute;
  left: 12px;
  color: #94a3b8;
  pointer-events: none;
}
.employee-search-box input {
  width: 100%;
  padding: 10px 36px 10px 38px;
  border: 2px solid #e2e8f0;
  border-radius: 10px;
  font-size: 0.95rem;
  font-family: 'Bai Jamjuree', sans-serif;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.employee-search-box input:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
}
.employee-search-box button {
  position: absolute;
  right: 8px;
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 50%;
  background: #e2e8f0;
  color: #64748b;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.employee-search-box button:hover {
  background: #cbd5e1;
  color: #475569;
}
.employee-search-count {
  font-size: 0.85rem;
  color: var(--text-muted, #64748b);
}
.emp-action-col {
  text-align: center;
  white-space: nowrap;
}
.emp-edit-row-btn {
  padding: 6px 12px;
  border: none;
  border-radius: 6px;
  background: linear-gradient(135deg, #667eea, #5568d3);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  font-family: 'Bai Jamjuree', sans-serif;
  box-shadow: 0 3px 8px rgba(102, 126, 234, 0.25);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.emp-edit-row-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 5px 12px rgba(102, 126, 234, 0.4);
}
.employee-toast {
  max-width: 360px;
  border-radius: 16px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
  background: #fff;
}
.employee-toast-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: #f0fdf4;
  margin: 0 auto;
}

/* ===== Leave tab search ===== */
.leave-search-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 12px 0;
  flex-wrap: wrap;
}
.leave-search-box {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 260px;
  max-width: 480px;
}
.leave-search-box svg {
  position: absolute;
  left: 12px;
  color: #94a3b8;
  pointer-events: none;
}
.leave-search-box input {
  width: 100%;
  padding: 10px 36px 10px 38px;
  border: 2px solid #e2e8f0;
  border-radius: 10px;
  font-size: 0.95rem;
  font-family: 'Bai Jamjuree', sans-serif;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.leave-search-box input:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
}
.leave-search-box button {
  position: absolute;
  right: 8px;
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 50%;
  background: #e2e8f0;
  color: #64748b;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.leave-search-box button:hover {
  background: #cbd5e1;
  color: #475569;
}
.leave-search-count {
  font-size: 0.85rem;
  color: var(--text-muted, #64748b);
}

/* ===== Work status segments ===== */
.workstatus-segments {
  display: flex;
  gap: 8px;
  margin: 16px 0;
  flex-wrap: wrap;
}
.workstatus-segment {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  border: 2px solid #e2e8f0;
  border-radius: 10px;
  background: #fff;
  color: #64748b;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  font-family: 'Bai Jamjuree', sans-serif;
  transition: all 0.15s ease;
}
.workstatus-segment:hover {
  border-color: #cbd5e1;
  background: #f8fafc;
}
.workstatus-segment.active {
  border-color: #667eea;
  background: linear-gradient(135deg, #667eea, #5568d3);
  color: #fff;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.35);
}
.workstatus-panels {
  margin-top: 12px;
}
.workstatus-panel {
  display: none;
}
.workstatus-panel.active {
  display: block;
}
.workstatus-hint {
  margin: 0 0 12px;
  font-size: 0.9rem;
  color: var(--text-muted, #64748b);
}
.outdoor-form {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  background: #f8fafc;
  padding: 16px;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  margin-bottom: 16px;
}
.outdoor-form .filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 160px;
  flex: 1;
}
.outdoor-form .filter-group label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-main, #1e293b);
}
.outdoor-form .filter-group input,
.outdoor-form .filter-group select {
  padding: 8px 10px;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: 'Bai Jamjuree', sans-serif;
}
.outdoor-list-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.outdoor-list-table th,
.outdoor-list-table td {
  border: 1px solid #e2e8f0;
  padding: 8px 10px;
  text-align: left;
}
.outdoor-list-table th {
  background: #f1f5f9;
  font-weight: 600;
}
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 700;
}
.status-leave {
  background: #fee2e2;
  color: #dc2626;
}
.status-work {
  background: #dcfce7;
  color: #16a34a;
}
.status-outdoor {
  background: #dbeafe;
  color: #2563eb;
}

/* ===== Outdoor multi-select employee ===== */
.outdoor-emp-group {
  min-width: 240px;
  flex: 2;
}
.outdoor-emp-dropdown {
  position: relative;
}
.outdoor-emp-toggle {
  width: 100%;
  padding: 8px 10px;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  background: #fff;
  font-size: 0.9rem;
  font-family: 'Bai Jamjuree', sans-serif;
  text-align: left;
  cursor: pointer;
}
.outdoor-emp-menu {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 4px;
  max-height: 240px;
  overflow-y: auto;
  background: #fff;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  z-index: 100;
  display: none;
}
.outdoor-emp-menu.open {
  display: block;
}
.outdoor-emp-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  cursor: pointer;
  font-size: 0.9rem;
  border-bottom: 1px solid #f1f5f9;
}
.outdoor-emp-item:hover {
  background: #f8fafc;
}
.outdoor-emp-item input {
  width: 16px;
  height: 16px;
  cursor: pointer;
}
.outdoor-emp-actions {
  display: flex;
  gap: 8px;
  padding: 8px 10px;
  border-top: 1px solid #e2e8f0;
  background: #f8fafc;
}
.outdoor-emp-actions button {
  padding: 4px 10px;
  border: none;
  border-radius: 4px;
  background: #e2e8f0;
  font-size: 0.8rem;
  cursor: pointer;
  font-family: 'Bai Jamjuree', sans-serif;
}

/* ===== Employee-first workstatus ===== */
.workstatus-by-employee {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 20px;
  margin-top: 16px;
  align-items: start;
}
@media (max-width: 900px) {
  .workstatus-by-employee {
    grid-template-columns: 1fr;
  }
}
.emp-picker {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  overflow: hidden;
  max-height: 600px;
  display: flex;
  flex-direction: column;
}
.emp-picker-search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border-bottom: 1px solid #e2e8f0;
  background: #f8fafc;
}
.emp-picker-search input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 0.9rem;
  font-family: 'Bai Jamjuree', sans-serif;
}
.emp-picker-search button {
  border: none;
  background: #e2e8f0;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}
.emp-picker-list {
  overflow-y: auto;
  max-height: 520px;
}
.emp-picker-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  cursor: pointer;
  border-bottom: 1px solid #f1f5f9;
  transition: background 0.15s ease;
}
.emp-picker-item:hover {
  background: #f8fafc;
}
.emp-picker-item.active {
  background: #eef2ff;
  border-left: 4px solid #667eea;
}
.emp-picker-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea, #5568d3);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}
.emp-picker-info {
  flex: 1;
  min-width: 0;
}
.emp-picker-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: #1e293b;
}
.emp-picker-meta {
  font-size: 0.8rem;
  color: #64748b;
}
.emp-calendar-wrap {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 16px;
}
.emp-calendar-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}
.emp-calendar-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #1e293b;
}
.emp-calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
}
.emp-calendar-day {
  aspect-ratio: 1;
  border: 2px solid #e2e8f0;
  border-radius: 10px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  cursor: pointer;
  transition: all 0.15s ease;
  background: #fff;
}
.emp-calendar-day:hover {
  border-color: #667eea;
  transform: translateY(-2px);
}
.emp-calendar-day .day-num {
  font-size: 1.2rem;
  font-weight: 700;
  color: #1e293b;
}
.emp-calendar-day .day-week {
  font-size: 0.75rem;
  color: #64748b;
}
.emp-calendar-day.selected-leave {
  background: #fee2e2;
  border-color: #dc2626;
}
.emp-calendar-day.selected-leave .day-num {
  color: #dc2626;
}
.emp-calendar-day.selected-work {
  background: #dcfce7;
  border-color: #16a34a;
}
.emp-calendar-day.selected-work .day-num {
  color: #16a34a;
}
.emp-calendar-day.selected-outdoor {
  background: #dbeafe;
  border-color: #2563eb;
}
.emp-calendar-day.selected-outdoor .day-num {
  color: #2563eb;
}
.emp-calendar-day.today {
  box-shadow: inset 0 0 0 2px #f59e0b;
}
.emp-calendar-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid #e2e8f0;
}
.emp-outdoor-form {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin: 12px 0;
  padding: 12px;
  background: #f8fafc;
  border-radius: 10px;
}
.emp-outdoor-form .filter-group {
  flex: 1;
  min-width: 180px;
}

/* ===== Leave type select ===== */
.leave-type-group {
  display: flex;
}
.workstatus-segment-select {
  padding: 10px 14px;
  border: 2px solid #667eea;
  border-radius: 10px;
  background: linear-gradient(135deg, #667eea, #5568d3);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: 'Bai Jamjuree', sans-serif;
  cursor: pointer;
  appearance: auto;
}
.workstatus-segment-select option {
  background: #fff;
  color: #1e293b;
}

/* ===== Swap/Move modal ===== */
.employee-modal-body .swap-side,
.employee-modal-body .swap-arrow {
  display: inline-block;
  vertical-align: top;
}
.swap-side {
  width: 42%;
  padding: 12px;
  background: #f8fafc;
  border-radius: 10px;
}
.swap-side h4 {
  margin: 0 0 10px;
  color: #1e293b;
}
.swap-side select {
  width: 100%;
  margin-bottom: 10px;
  padding: 8px;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  font-family: 'Bai Jamjuree', sans-serif;
}
.swap-arrow {
  width: 12%;
  text-align: center;
  font-size: 2rem;
  color: #667eea;
  padding-top: 40px;
}
.swap-preview {
  padding: 8px;
  background: #fff;
  border-radius: 6px;
  font-size: 0.85rem;
  color: #64748b;
  min-height: 36px;
}
.employee-modal-body .filter-group {
  margin-bottom: 12px;
}
.employee-modal-body .filter-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 4px;
  color: #1e293b;
}
.employee-modal-body .filter-group select,
.employee-modal-body .filter-group input {
  width: 100%;
  padding: 8px 10px;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: 'Bai Jamjuree', sans-serif;
}

/* ===== Calendar work day ===== */
.emp-calendar-day.work-day {
  background: #dcfce7;
  border-color: #16a34a;
}
.emp-calendar-day.work-day .day-num {
  color: #16a34a;
}

/* ===== Employee modal overlay / positioning fix ===== */
.employee-modal {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
}
.employee-modal[hidden] {
  display: none;
}
.employee-modal-content {
  width: min(720px, 96vw);
  max-height: min(86vh, 800px);
  display: flex;
  flex-direction: column;
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.22);
  overflow: hidden;
}
.employee-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid #e2e8f0;
}
.employee-modal-header h3 {
  margin: 0;
  font-size: 1.1rem;
  color: #1e293b;
}
.employee-modal-close {
  border: none;
  background: #e2e8f0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  color: #64748b;
}
.employee-modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}
.employee-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid #e2e8f0;
  background: #f8fafc;
}

/* ===== Day action modal ===== */
.day-action-modal {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
}
.day-action-modal[hidden] {
  display: none;
}
.day-action-content {
  width: min(460px, 96vw);
  max-height: min(90vh, 720px);
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.22);
  overflow: hidden;
}
.day-action-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid #e2e8f0;
}
.day-action-header h3 {
  margin: 0;
  font-size: 1.1rem;
  color: #1e293b;
}
.day-action-close {
  border: none;
  background: #e2e8f0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  color: #64748b;
}
.day-action-body {
  padding: 20px;
  overflow-y: auto;
}
.day-action-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.day-action-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 8px;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
  font-family: 'Bai Jamjuree', sans-serif;
  transition: all 0.15s ease;
}
.day-action-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}
.leave-card:hover {
  border-color: #f59e0b;
  background: #fffbeb;
}
.outdoor-card:hover {
  border-color: #2563eb;
  background: #eff6ff;
}
.day-action-icon {
  font-size: 1.6rem;
}
.day-action-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #334155;
}
.day-action-divider {
  text-align: center;
  margin: 16px 0;
  color: #94a3b8;
  font-size: 0.85rem;
  position: relative;
}
.day-action-divider::before,
.day-action-divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 40%;
  height: 1px;
  background: #e2e8f0;
}
.day-action-divider::before { left: 0; }
.day-action-divider::after { right: 0; }
.day-action-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.day-action-btn {
  padding: 12px;
  border: 2px solid #e2e8f0;
  border-radius: 10px;
  background: #f8fafc;
  font-family: 'Bai Jamjuree', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  color: #334155;
}
.day-action-btn:hover {
  background: #f1f5f9;
}
.day-action-footer {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid #e2e8f0;
  background: #f8fafc;
}
.day-action-clear {
  padding: 10px 14px;
  border: none;
  border-radius: 8px;
  background: #fee2e2;
  color: #dc2626;
  font-family: 'Bai Jamjuree', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}
.day-action-cancel {
  padding: 10px 18px;
  border: none;
  border-radius: 8px;
  background: #e2e8f0;
  color: #334155;
  font-family: 'Bai Jamjuree', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

/* ===== Stock card detail modal fixes ===== */
.stock-card-overlay {
  background: rgba(15, 23, 42, 0.65) !important;
  align-items: flex-start !important;
  padding-top: 0 !important;
}
.stock-card-detail-modal {
  max-width: 100vw !important;
  width: 100vw !important;
  max-height: 100vh !important;
  height: 100vh !important;
  border-radius: 0 !important;
  margin: 0 !important;
}
.stock-card-detail-modal .modal-body {
  padding: 12px;
  overflow: auto !important;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
  background: #fff;
  flex: 1;
}
.stock-card-detail-modal .modal-body > div {
  overflow: auto !important;
}
.stock-card-detail-modal table {
  max-width: none;
}
.stock-card-modal-header {
  background: linear-gradient(135deg, #166534 0%, #15803d 100%);
  flex-shrink: 0;
}
.stock-card-modal-header h3 {
  color: #ffffff !important;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}
.stock-card-modal-header p {
  color: #dcfce7 !important;
}
@media (min-width: 1400px) {
  .stock-card-detail-modal {
    max-width: 98vw !important;
    width: 98vw !important;
    max-height: 96vh !important;
    height: 96vh !important;
    border-radius: 12px !important;
    margin: 2vh auto !important;
  }
  .stock-card-overlay {
    align-items: center !important;
    padding-top: 0 !important;
  }
}

/* ===== Stock card panels visible ===== */
#tab-stockcard .panel {
  position: relative;
  height: auto;
  min-height: 300px;
  overflow: visible;
}
#tab-stockcard .panel > div:last-child {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-start;
  min-height: 200px;
  overflow: visible;
}
#tab-stockcard #stockCheckedShopsPanel,
#tab-stockcard #stockUncheckedShopsPanel {
  position: relative;
  height: auto;
  min-height: 150px;
  overflow: visible;
}

/* ===== Stock card table header visible ===== */
#stockCardTableBody table thead tr:first-child th,
#stockCardTableBody table thead tr:nth-child(2) th {
  position: sticky;
  top: 0;
  background: #166534 !important;
  color: #fff !important;
  font-weight: 700;
  white-space: nowrap;
  padding: 10px 6px;
  font-size: 14px;
  border: 1px solid #14532d;
  z-index: 10;
}
#stockCardTableBody table thead tr:nth-child(2) th {
  top: 38px;
  background: #15803d !important;
  font-size: 13px;
  z-index: 9;
}
#stockCardTableBody table th:first-child,
#stockCardTableBody table td:first-child {
  position: sticky;
  left: 0;
  background: #fff;
  z-index: 11;
}
#stockCardTableBody table thead tr:first-child th:first-child {
  z-index: 12;
}
