:root {
  --primary: #007A6C;
  --primary-hover: #009688;
  --primary-dark: #02594E;
  --primary-light: #E6F4F1;
  --primary-subtle: #F0FDF4;
  
  --emerald: #059669;
  --emerald-bg: #ECFDF5;
  --amber: #D97706;
  --amber-bg: #FFFBEB;
  --red: #DC2626;
  --red-bg: #FEF2F2;
  --blue: #2563EB;
  --blue-bg: #EFF6FF;

  --bg-page: #F8FAFC;
  --bg-card: #FFFFFF;
  --border: #E2E8F0;
  --border-light: #F1F5F9;

  --text-main: #0F172A;
  --text-secondary: #475569;
  --text-muted: #94A3B8;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-full: 9999px;
}

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

html,
body {
  max-width: 100%;
  overflow-x: clip;
}

body {
  font-family: 'Plus Jakarta Sans', 'Noto Sans SC', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-page);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ========================================================
   HEADER & NAVBAR
   ======================================================== */
.app-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  width: 100%;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.03);
}

.header-container {
  max-width: 1680px;
  width: 100%;
  margin: 0 auto;
  padding: 8px 20px;
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  row-gap: 8px;
  column-gap: 14px;
}

.brand-area {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  min-width: 0;
  order: 1;
}

.brand-logo {
  height: 36px;
  width: auto;
  display: block;
}

.brand-divider {
  width: 1px;
  height: 24px;
  background-color: var(--border);
}

.brand-meta {
  display: flex;
  flex-direction: column;
}

.portal-badge {
  font-size: 13px;
  font-weight: 700;
  color: var(--primary-dark);
  letter-spacing: -0.2px;
}

.portal-sub {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

/* Navigation Tabs — clean full-width second tier so all 8 tabs fit without horizontal scroll */
.nav-tabs {
  order: 3;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 4px;
  background: #F1F5F9;
  padding: 4px;
  border-radius: 14px;
}

.nav-tab {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
}

.nav-tab:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.6);
}

.nav-tab.active {
  background: #FFFFFF;
  color: var(--primary-dark);
  box-shadow: 0 2px 6px rgba(0, 122, 108, 0.12);
}

.tab-icon {
  font-size: 14px;
}

/* Header Action Buttons */
.header-actions {
  order: 2;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  flex-shrink: 0;
}

/* Language Capsule */
.lang-switch-capsule {
  display: inline-flex;
  align-items: center;
  padding: 3px;
  background: #FFFFFF;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-sm);
}

.lang-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: none;
  outline: none;
  background: transparent;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all 0.18s ease;
}

.lang-btn.active {
  background: var(--primary);
  color: #FFFFFF;
  box-shadow: 0 1px 3px rgba(0, 122, 108, 0.3);
}

/* Action Button */
.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 600;
  color: #FFFFFF;
  background: var(--primary);
  border: none;
  border-radius: var(--radius-full);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 122, 108, 0.25);
  transition: all 0.2s ease;
}

.action-btn:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(0, 122, 108, 0.32);
}

.action-btn:active {
  transform: translateY(0);
}

.btn-icon {
  width: 16px;
  height: 16px;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  background: #FFFFFF;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all 0.18s ease;
}

.btn-secondary:hover {
  background: #F8FAFC;
  color: var(--text-main);
  border-color: #CBD5E1;
}

/* ========================================================
   MAIN LAYOUT & PANES
   ======================================================== */
.app-main {
  width: 100%;
  max-width: 1680px;
  margin: 0 auto;
  padding: 18px 20px;
  min-width: 0;
}

.tab-pane {
  display: none;
  animation: fadeIn 0.25s ease-out;
  min-width: 0;
  max-width: 100%;
}

.tab-pane.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Report Header */
.report-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  margin-bottom: 18px;
  gap: 14px;
}

.report-title {
  font-size: 24px;
  font-weight: 800;
  color: var(--primary-dark);
  letter-spacing: -0.5px;
  margin-bottom: 4px;
}

.report-subtitle {
  font-size: 13.5px;
  color: var(--text-secondary);
}

.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--emerald-bg);
  border: 1px solid #A7F3D0;
  color: var(--emerald);
  font-size: 12px;
  font-weight: 600;
  border-radius: var(--radius-full);
}

.pulse-dot {
  width: 8px;
  height: 8px;
  background: var(--emerald);
  border-radius: 50%;
  animation: pulse 1.8s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(5, 150, 105, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(5, 150, 105, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(5, 150, 105, 0); }
}

.badge-alert {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  background: var(--red-bg);
  border: 1px solid #FECACA;
  color: var(--red);
  font-size: 12.5px;
  font-weight: 700;
  border-radius: var(--radius-full);
}

/* ========================================================
   KPI CARDS GRID
   ======================================================== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: #CBD5E1;
}

.kpi-card.highlight {
  border-left: 4px solid var(--primary);
  background: linear-gradient(135deg, #FFFFFF 0%, #F0FDF4 100%);
}

.kpi-card.alert {
  border-left: 4px solid var(--red);
  background: linear-gradient(135deg, #FFFFFF 0%, #FEF2F2 100%);
}

.kpi-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-bottom: 6px;
}

.kpi-value {
  font-size: 26px;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.5px;
  line-height: 1.1;
  margin-bottom: 6px;
}

.kpi-desc {
  font-size: 12px;
  color: var(--text-muted);
}

.kpi-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11.5px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
}

.badge-up { background: var(--emerald-bg); color: var(--emerald); }
.badge-down { background: var(--red-bg); color: var(--red); }
.badge-neutral { background: #F1F5F9; color: var(--text-secondary); }

.text-emerald { color: var(--emerald) !important; }
.text-amber { color: var(--amber) !important; }
.text-red { color: var(--red) !important; }
.text-teal { color: var(--primary) !important; }
.text-blue { color: #2563eb !important; }
.text-muted { color: var(--text-muted) !important; }

/* ========================================================
   CATEGORY CHIPS GRID
   ======================================================== */
.card-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}

.section-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 14px;
}

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

.sub-hint {
  font-size: 12.5px;
  color: var(--text-muted);
}

.category-chips-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}

.cat-chip {
  background: #F8FAFC;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  transition: all 0.18s ease;
}

.cat-chip:hover {
  background: #FFFFFF;
  border-color: var(--primary);
  box-shadow: 0 2px 6px rgba(0, 122, 108, 0.08);
}

.cat-chip-name {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 4px;
}

.cat-chip-meta {
  font-size: 12px;
  color: var(--text-secondary);
  display: flex;
  justify-content: space-between;
}

/* ========================================================
   DATA TABLES
   ======================================================== */
.table-container-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  margin-bottom: 24px;
}

.table-toolbar {
  padding: 16px 20px;
  background: #FFFFFF;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.search-box {
  position: relative;
  min-width: 180px;
  flex: 1;
  max-width: 380px;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-muted);
}

.search-box input {
  width: 100%;
  padding: 8px 12px 8px 36px;
  font-size: 13.5px;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  outline: none;
  background: #F8FAFC;
  transition: all 0.18s ease;
}

.search-box input:focus {
  background: #FFFFFF;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 122, 108, 0.12);
}

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

.custom-select {
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: #FFFFFF;
  color: var(--text-main);
  outline: none;
  cursor: pointer;
  transition: all 0.18s ease;
}

.custom-select:focus {
  border-color: var(--primary);
}

.btn-chip {
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: #FFFFFF;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.18s ease;
}

.btn-chip:hover {
  background: #F8FAFC;
  color: var(--text-main);
}

.btn-chip.active {
  background: var(--primary-light);
  color: var(--primary-dark);
  border-color: var(--primary);
}

.table-info-counter {
  font-size: 12.5px;
  color: var(--text-muted);
  font-weight: 500;
}

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

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  text-align: left;
}

.data-table th {
  background: #F8FAFC;
  color: var(--text-secondary);
  font-weight: 700;
  font-size: 11.5px;
  line-height: 1.3;
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
  white-space: normal;
  vertical-align: bottom;
  word-break: break-word;
  user-select: none;
}

.data-table td {
  padding: 9px 8px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
  overflow-wrap: anywhere;
}

.data-table tbody tr {
  transition: background-color 0.12s ease;
}

.data-table tbody tr:hover {
  background-color: #F8FAFC;
}

#products-master-table {
  table-layout: fixed;
}

#products-master-table th,
#products-master-table td {
  padding: 8px 5px;
  font-size: 11.5px;
  overflow: hidden;
  text-overflow: ellipsis;
}

#products-master-table th {
  white-space: normal;
  line-height: 1.25;
  vertical-align: bottom;
  word-break: break-word;
}

#products-master-table td {
  white-space: nowrap;
}

#products-master-table .product-name-link {
  white-space: normal;
  word-break: break-word;
}

/* Editable Cell (display only, edited through the floating editor) */
.editable-cell {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  max-width: 100%;
  padding: 2px 4px;
  border-radius: var(--radius-sm);
  border: 1px dashed transparent;
  transition: all 0.18s ease;
}

.editable-cell:hover {
  background: #F8FAFC;
  border-color: #94A3B8;
}

.editable-cell .cell-display {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cell-edit-btn {
  flex: none;
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: none;
  border-radius: 5px;
  background: transparent;
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
  opacity: 0.35;
  transition: all 0.15s ease;
}

.editable-cell:hover .cell-edit-btn,
.cell-edit-btn:focus-visible {
  opacity: 1;
  background: var(--amber-bg);
}

.cell-edit-btn:hover {
  background: #FEF3C7;
  transform: scale(1.12);
}

/* Tags in Table */
.tag-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-size: 11.5px;
  font-weight: 600;
}

.tag-badge.normal { background: #ECFDF5; color: #047857; }
.tag-badge.warning { background: #FFFBEB; color: #B45309; }
.tag-badge.danger { background: #FEF2F2; color: #B91C1C; }

/* ========================================================
   WEEKLY INSIGHTS & TWO COLUMN LAYOUT
   ======================================================= */
.insights-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
}

.insight-card {
  background: #F8FAFC;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 18px;
  transition: all 0.2s ease;
  position: relative;
}

.insight-card:hover {
  background: #FFFFFF;
  border-color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.insight-num-badge {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 24px;
  height: 24px;
  background: var(--primary-light);
  color: var(--primary-dark);
  border-radius: 50%;
  font-size: 12px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}

.insight-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 6px;
  padding-right: 28px;
}

.insight-summary {
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 10px;
}

.insight-body {
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.insight-body strong {
  color: var(--text-main);
}

.weekly-two-column-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 20px;
}

@media (max-width: 1024px) {
  .weekly-two-column-grid {
    grid-template-columns: 1fr;
  }
}

.card-inner-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
  padding: 16px 20px 0;
  margin-bottom: 12px;
}

.checkout-breakdown-card .card-inner-title {
  padding: 0;
  margin-bottom: 16px;
}

.payment-metrics-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.metric-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: #F8FAFC;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.metric-row .m-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
}

.metric-row .m-val {
  font-size: 14px;
  font-weight: 700;
  color: var(--primary-dark);
}

.metric-row .m-val small {
  font-size: 11.5px;
  color: var(--text-secondary);
  font-weight: 500;
}

/* ========================================================
   MODAL DIALOG
   ======================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop.active {
  display: flex;
  animation: modalFade 0.2s ease-out;
}

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

.modal-box {
  background: #FFFFFF;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 640px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

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

.modal-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--primary-dark);
}

.modal-close {
  background: transparent;
  border: none;
  font-size: 24px;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  background: #F8FAFC;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

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

.form-group label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
}

.form-control {
  width: 100%;
  padding: 8px 12px;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 122, 108, 0.1);
}

textarea.form-control {
  min-height: 60px;
  resize: vertical;
}

/* ========================================================
   TOAST NOTIFICATION
   ======================================================== */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: #0F172A;
  color: #FFFFFF;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toastIn 0.25s ease-out;
}

@keyframes toastIn {
  from { transform: translateY(10px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ========================================================
   LOGIN VIEW & USER AUTH BADGE
   ======================================================== */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 20%, #E6F4F1 0%, #F8FAFC 70%);
  padding: 24px;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9999;
}

.login-lang-corner {
  position: absolute;
  top: 24px;
  right: 28px;
}

.login-card {
  width: 100%;
  max-width: 440px;
  background: #ffffff;
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 40px -15px rgba(0, 122, 108, 0.15), 0 0 0 1px rgba(0, 122, 108, 0.12);
  padding: 40px 36px 36px;
  display: flex;
  flex-direction: column;
  animation: loginFadeUp 0.35s ease-out;
}

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

.login-brand-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-bottom: 26px;
}

.login-brand-logo {
  height: 56px;
  width: auto;
  margin-bottom: 14px;
}

.login-title {
  font-size: 21px;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.02em;
}

.login-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 6px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.login-field label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
}

.input-with-icon {
  position: relative;
  display: flex;
  align-items: center;
}

.input-icon-left {
  position: absolute;
  left: 14px;
  color: var(--text-muted);
  font-size: 15px;
  pointer-events: none;
}

.login-input {
  width: 100%;
  padding: 12px 14px 12px 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 14px;
  color: var(--text-main);
  background: #fdfdfd;
  transition: all 0.2s ease;
  outline: none;
}

.login-input:focus {
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(0, 122, 108, 0.14);
}

.toggle-password-btn {
  position: absolute;
  right: 12px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 16px;
  padding: 4px;
  transition: color 0.15s ease;
}

.toggle-password-btn:hover {
  color: var(--text-main);
}

.login-error-alert {
  display: none;
  background: #FEF2F2;
  border: 1px solid #FCA5A5;
  color: #B91C1C;
  font-size: 13px;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  align-items: center;
  gap: 8px;
}

.btn-submit-login {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  padding: 12px 20px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(0, 122, 108, 0.25);
  margin-top: 4px;
}

.btn-submit-login:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(0, 122, 108, 0.3);
}

.btn-submit-login:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.login-footer-note {
  margin-top: 24px;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

/* User Profile Badge in Header */
.user-profile-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--primary-light);
  border: 1px solid rgba(0, 122, 108, 0.18);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 600;
  color: var(--primary-dark);
}

.user-name {
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-logout {
  background: transparent;
  border: none;
  color: var(--red);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: all 0.15s ease;
}

.btn-logout:hover {
  background: #FEF2F2;
}

/* ========================================================
   4-WEEK TREND CHART MODAL & CLICKABLE DATA CONTROLS
   ======================================================== */
.chart-modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(8px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s ease-out;
}

.chart-modal-card {
  width: 100%;
  max-width: 720px;
  background: #ffffff;
  border-radius: var(--radius-lg);
  box-shadow: 0 25px 50px -12px rgba(20, 120, 60, 0.25), 0 0 0 1px rgba(20, 120, 60, 0.12);
  padding: 26px 30px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: modalScaleUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.chart-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chart-title-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chart-icon-box {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: #E6F4F1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: #14783c;
  flex-shrink: 0;
}

.chart-modal-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.01em;
}

.chart-modal-sub {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.btn-close-chart {
  background: #f1f5f9;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 15px;
  font-weight: 700;
  transition: all 0.15s ease;
}

.btn-close-chart:hover {
  background: #e2e8f0;
  color: var(--text-main);
  transform: scale(1.08);
}

.chart-stats-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  background: #F8FAFC;
  border: 1px solid var(--border-light);
  padding: 10px 14px;
  border-radius: var(--radius-md);
}

.stat-pill {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-pill-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
}

.stat-pill-val {
  font-size: 15px;
  font-weight: 800;
  color: var(--text-main);
}

.chart-canvas-wrapper {
  position: relative;
  height: 260px;
  width: 100%;
}

.chart-modal-footer {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  background: #E6F4F1;
  border: 1px solid rgba(20, 120, 60, 0.18);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 12.5px;
  color: #02594E;
  line-height: 1.5;
}

/* Clickable Interactive Indicators on Controls */
.kpi-card {
  cursor: pointer;
  position: relative;
  transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

.kpi-card:hover {
  transform: translateY(-3px);
  border-color: rgba(20, 120, 60, 0.4);
  box-shadow: 0 10px 24px -4px rgba(20, 120, 60, 0.15);
}

.kpi-card .chart-hint-badge {
  position: absolute;
  top: 10px;
  right: 12px;
  font-size: 13px;
  opacity: 0.45;
  transition: all 0.2s ease;
  pointer-events: none;
}

.kpi-card:hover .chart-hint-badge {
  opacity: 1;
  transform: scale(1.15);
}

.cat-chip {
  cursor: pointer;
  position: relative;
  transition: all 0.2s ease;
}

.cat-chip:hover {
  transform: translateY(-2px);
  border-color: #14783c;
  box-shadow: 0 4px 14px rgba(20, 120, 60, 0.15);
}

.cat-progress-item {
  cursor: pointer;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  transition: all 0.18s ease;
}

.cat-progress-item:hover {
  background-color: #E6F4F1;
  transform: translateX(3px);
}

/* ========================================================
   EXPIRY COLOR CODING & BADGES (3-TIER & OVERDUE)
   ======================================================== */
.text-green-expiry {
  color: #16a34a !important;
  font-weight: 700 !important;
}

.text-blue-expiry {
  color: #2563eb !important;
  font-weight: 700 !important;
}

.text-yellow-expiry {
  color: #d97706 !important;
  font-weight: 700 !important;
}

.text-orange-expiry {
  color: #ea580c !important;
  font-weight: 700 !important;
}

.text-red-expired {
  color: #dc2626 !important;
  font-weight: 700 !important;
}

.badge-green {
  background: #f0fdf4 !important;
  color: #15803d !important;
  border: 1px solid #bbf7d0 !important;
}

.badge-blue {
  background: #eff6ff !important;
  color: #1d4ed8 !important;
  border: 1px solid #bfdbfe !important;
}

.badge-yellow {
  background: #fefce8 !important;
  color: #b45309 !important;
  border: 1px solid #fef08a !important;
}

.badge-orange {
  background: #fff7ed !important;
  color: #c2410c !important;
  border: 1px solid #fed7aa !important;
}

.badge-red {
  background: #fef2f2 !important;
  color: #b91c1c !important;
  border: 1px solid #fca5a5 !important;
}

/* ========================================================
   TABLE SORTING HEADERS
   ======================================================== */
.sortable-th {
  cursor: pointer !important;
  user-select: none;
  position: relative;
  transition: background 0.15s ease, color 0.15s ease;
}

.sortable-th:hover {
  background: rgba(20, 120, 60, 0.08) !important;
  color: var(--primary-dark) !important;
}

.sort-icon {
  display: inline-block;
  margin-left: 5px;
  font-size: 10px;
  line-height: 1;
  letter-spacing: -0.5px;
  color: #94a3b8;
  opacity: 0.75;
  transition: all 0.15s ease;
  vertical-align: middle;
}

.sortable-th:hover .sort-icon {
  opacity: 1;
  color: var(--primary);
}

.sortable-th.sorted-asc .sort-icon {
  opacity: 1;
  color: #14783c;
  font-weight: 800;
}

.sortable-th.sorted-desc .sort-icon {
  opacity: 1;
  color: #14783c;
  font-weight: 800;
}

/* ========================================================
   CATEGORY PIE CHARTS 4-GRID (FAST & SLOW MOVING)
   ======================================================== */
.cat-charts-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-top: 18px;
}

@media (max-width: 1280px) {
  .cat-charts-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 640px) {
  .cat-charts-grid {
    grid-template-columns: 1fr;
  }
}

.cat-pie-card {
  background: var(--bg-card, #ffffff);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: var(--radius-md, 10px);
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.cat-pie-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0,0,0,0.08);
}

.cat-pie-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary, #0f172a);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-align: center;
  width: 100%;
}

.cat-pie-canvas-wrap {
  position: relative;
  width: 100%;
  max-width: 210px;
  height: 200px;
  margin: 0 auto;
}

.cat-pie-footer {
  width: 100%;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed var(--border-color, #e2e8f0);
  font-size: 11.5px;
  color: var(--text-muted, #64748b);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Nav Tab Compact Fit for 6 Tabs */
.nav-tab {
  padding: 6px 12px;
  font-size: 12.5px;
}

/* ========================================================
   DIMENSION SWITCHER PILLS
   ======================================================== */
.dimension-switcher-pills {
  display: inline-flex;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 3px;
  gap: 3px;
}

.dim-pill {
  border: none;
  background: transparent;
  color: #475569;
  font-size: 12.5px;
  font-weight: 600;
  padding: 6px 13px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.dim-pill:hover {
  color: #0f172a;
  background: rgba(20, 120, 60, 0.08);
}

.dim-pill.active {
  background: #14783c;
  color: #ffffff;
  box-shadow: 0 1px 3px rgba(20, 120, 60, 0.3);
}

/* ========================================================
   WEEKLY OPS ENHANCEMENTS & EDITABLE NOTE BOXES
   ======================================================== */
.weekly-chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 20px;
  display: flex;
  flex-direction: column;
}

.weekly-chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 10px;
}

.weekly-chart-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.weekly-chart-desc {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 2px;
}

.chart-canvas-wrap {
  position: relative;
  width: 100%;
  min-height: 260px;
}

.section-note-box {
  margin-top: 16px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-md);
  padding: 14px 16px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.section-note-box:focus-within {
  border-color: #94a3b8;
  box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.05);
  background: #ffffff;
}

.note-box-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.note-box-title {
  font-size: 13px;
  font-weight: 600;
  color: #334155;
  display: flex;
  align-items: center;
  gap: 6px;
}

.note-box-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.note-save-status {
  font-size: 12px;
  color: #64748b;
  transition: all 0.2s;
}

.note-save-status.saved {
  color: #059669;
  font-weight: 600;
}

.note-save-status.saving {
  color: #d97706;
}

.note-save-status.dirty {
  color: #6366f1;
}

.btn-save-note {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #0f172a;
  color: #ffffff;
  border: none;
  border-radius: 6px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-save-note:hover {
  background: #334155;
  transform: translateY(-1px);
}

.btn-save-note:active {
  transform: translateY(0);
}

.note-textarea {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 9px 12px;
  font-size: 13px;
  line-height: 1.6;
  color: #0f172a;
  background: #ffffff;
  resize: vertical;
  min-height: 64px;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.note-textarea:focus {
  outline: none;
  border-color: #007a6c;
  box-shadow: 0 0 0 2px rgba(0, 122, 108, 0.15);
}

.chart-legend-simple {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 12px;
  color: var(--text-secondary);
}

.legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-right: 5px;
}

.legend-line {
  display: inline-block;
  width: 14px;
  height: 3px;
  border-radius: 2px;
  background: var(--primary);
  margin-right: 5px;
}

/* ========================================================
   BADGES & TABLE CELL DISPLAY
   ======================================================== */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 9px;
  border-radius: var(--radius-full);
  font-size: 11.5px;
  font-weight: 700;
  line-height: 1.4;
  white-space: nowrap;
}

.badge-emerald {
  background: var(--emerald-bg);
  color: var(--emerald);
}

.badge-amber {
  background: var(--amber-bg);
  color: var(--amber);
}

.badge-neutral {
  background: #F1F5F9;
  color: var(--text-secondary);
}

.product-cell-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.35;
}

.product-cell-sub {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 2px;
  line-height: 1.4;
}

.category-pill {
  display: inline-block;
  padding: 3px 9px;
  background: #F1F5F9;
  color: var(--text-secondary);
  border-radius: var(--radius-full);
  font-size: 11.5px;
  font-weight: 600;
}

.text-indigo {
  color: #4F46E5;
}

/* ========================================================
   FLOATING FIELD EDITOR (unified edit popover)
   ======================================================== */
.field-popover {
  position: fixed;
  z-index: 3000;
  width: 272px;
  background: #FFFFFF;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  animation: popIn 0.14s ease-out;
}

@keyframes popIn {
  from { opacity: 0; transform: translateY(-4px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.field-popover-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.field-popover-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--primary-dark);
}

.field-popover-close {
  border: none;
  background: transparent;
  font-size: 18px;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0 2px;
}

.field-popover-close:hover {
  color: var(--text-main);
}

.field-popover-hint {
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.45;
}

.field-popover-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-popover-input {
  width: 100%;
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text-main);
  background: #F8FAFC;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.field-popover-input:focus {
  background: #FFFFFF;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 122, 108, 0.12);
}

.field-popover-textarea {
  resize: vertical;
  min-height: 78px;
  line-height: 1.55;
}

.field-popover-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 2px;
}

.field-popover-actions .btn-secondary,
.field-popover-actions .action-btn {
  padding: 6px 14px;
  font-size: 12.5px;
}

.shake {
  animation: shakeAnim 0.25s ease-in-out 2;
}

@keyframes shakeAnim {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* ========================================================
   SECTION NOTE DISPLAY CARDS + EDIT MODAL
   ======================================================== */
.note-icon {
  font-size: 14px;
}

.note-box-label {
  font-size: 13px;
  font-weight: 600;
  color: #334155;
}

.btn-note-edit {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: none;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  background: #FFFFFF;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all 0.18s ease;
}

.btn-note-edit:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary-dark);
}

.note-display-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 13px;
}

.note-display-empty {
  font-size: 12.5px;
  color: var(--text-muted);
  background: #FFFFFF;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.note-block {
  background: #FFFFFF;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.note-block-tag {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--primary-dark);
  margin-bottom: 4px;
}

.note-block-text {
  margin: 0;
  font-size: 13px;
  line-height: 1.65;
  color: var(--text-secondary);
  white-space: pre-wrap;
}

.modal-note-box {
  max-width: 560px;
}

.modal-section-tag {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--primary-dark);
  background: var(--primary-light);
  padding: 3px 9px;
  border-radius: var(--radius-full);
  margin-bottom: 6px;
}

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

.note-field-label {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-main);
}

.note-modal-textarea {
  width: 100%;
  padding: 10px 12px;
  font-size: 13px;
  font-family: inherit;
  line-height: 1.6;
  color: var(--text-main);
  background: #FFFFFF;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  resize: vertical;
  min-height: 96px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.note-modal-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 122, 108, 0.12);
}

.note-modal-save-status {
  margin-right: auto;
  font-size: 12px;
  color: var(--text-muted);
}

.note-modal-save-status.saving {
  color: var(--amber);
  font-weight: 600;
}

.note-modal-save-status.saved {
  color: var(--emerald);
  font-weight: 600;
}

.note-modal-save-status.dirty {
  color: var(--red);
  font-weight: 600;
}

/* ========================================================
   WEEKLY INSIGHTS: DISPLAY CARD + EDIT MODAL
   ======================================================== */
.insight-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.insight-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--primary-dark);
  padding: 4px 10px;
  border-radius: var(--radius-full);
}

.insight-edit-btn {
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: #FFFFFF;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.18s ease;
}

.insight-edit-btn:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  transform: scale(1.08);
}

.modal-insights-box {
  max-width: 720px;
}

.insight-edit-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px;
  background: #F8FAFC;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.insight-edit-group-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--primary-dark);
}

.insight-edit-group .note-field-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-secondary);
}

.field-modal-input,
.field-modal-textarea {
  width: 100%;
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text-main);
  background: #FFFFFF;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field-modal-input:focus,
.field-modal-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 122, 108, 0.12);
}

.field-modal-textarea {
  resize: vertical;
  min-height: 72px;
  line-height: 1.6;
}

/* ========================================================
   REMAINING LAYOUT UTILITIES
   ======================================================== */
.report-header-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.report-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.period-switch {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  max-width: 100%;
  gap: 6px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: #FFFFFF;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
}

.period-switch-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

.period-switch .btn-chip {
  padding: 4px 12px;
  font-size: 12px;
  border-color: transparent;
  background: #F1F5F9;
}

.period-switch .btn-chip.active {
  background: var(--primary);
  color: #FFFFFF;
  border-color: var(--primary);
}

.period-switch .period-step-btn {
  width: 26px;
  height: 26px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  border-radius: 50%;
}

.period-switch .period-step-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.period-weeks-select {
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: #F8FAFC;
  color: var(--text-main);
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  padding: 4px 10px;
  height: 28px;
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.period-weeks-select:hover,
.period-weeks-select:focus {
  border-color: var(--primary);
  background: #FFFFFF;
}

.period-range-badge {
  font-size: 11.5px;
  color: var(--text-muted);
  white-space: nowrap;
  padding-left: 4px;
  border-left: 1px solid var(--border);
}

.period-range-badge:empty {
  display: none;
}

.search-input,
#fast-search-input,
#slow-search-input,
#near-search-input,
#exp-search-input,
#analytics-search-input {
  padding: 8px 14px;
  font-size: 12.5px;
  font-family: inherit;
  color: var(--text-main);
  background: #FFFFFF;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  outline: none;
  min-width: 180px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.search-input:focus,
#fast-search-input:focus,
#slow-search-input:focus,
#near-search-input:focus,
#exp-search-input:focus,
#analytics-search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 122, 108, 0.12);
}

.btn-export {
  font-size: 12.5px;
  padding: 8px 16px;
}

.btn-login-text {
  letter-spacing: 3px;
  font-weight: 700;
}

.tab-text {
  font-size: 12.5px;
  font-weight: 600;
}

.user-avatar-icon {
  font-size: 16px;
  line-height: 1;
}

.weekly-chart-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.category-breakdown-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}

.cat-chip-badge {
  font-size: 11px;
  font-weight: 700;
  color: var(--primary-dark);
  background: var(--primary-light);
  padding: 2px 7px;
  border-radius: var(--radius-full);
}

.cat-chip-sales {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-main);
}

.cat-progress-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.cat-progress-name {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-main);
}

.cat-progress-val {
  font-size: 12px;
  font-weight: 700;
  color: var(--primary-dark);
  white-space: nowrap;
}

.progress-bar-bg {
  width: 100%;
  height: 8px;
  background: #EEF2F7;
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary-hover));
  border-radius: var(--radius-full);
  transition: width 0.4s ease;
}

/* ==========================================================================
   Product Master List (商品总表) Enhancements & Pagination
   ========================================================================== */
.prod-cat-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
}

.cat-summary-chip {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-md);
  padding: 8px 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cat-summary-chip:hover {
  background: #eff6ff;
  border-color: #93c5fd;
  transform: translateY(-1px);
  box-shadow: 0 2px 5px rgba(37, 99, 235, 0.08);
}

.cat-summary-chip.active {
  background: #dbeafe;
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.cat-chip-name {
  font-size: 12px;
  font-weight: 700;
  color: #1e293b;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.cat-chip-count {
  font-size: 11px;
  font-weight: 600;
  color: #64748b;
  background: #e2e8f0;
  padding: 1px 6px;
  border-radius: 10px;
}

.cat-chip-sales {
  font-size: 13px;
  font-weight: 800;
  color: var(--primary);
  margin-top: 2px;
}

.cat-chip-sub {
  font-size: 10.5px;
  color: #64748b;
}

/* Status Badges */
.prod-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 9999px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-fast {
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
}

.badge-slow {
  background: #fffbeb;
  color: #b45309;
  border: 1px solid #fde68a;
}

.badge-near {
  background: #fefce8;
  color: #a16207;
  border: 1px solid #fef08a;
}

.badge-expired {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}

.badge-inverted {
  background: #fff1f2;
  color: #e11d48;
  border: 1px solid #fecdd3;
  font-weight: 700;
}

.badge-high-margin {
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
}

.badge-low-margin {
  background: #f1f5f9;
  color: #64748b;
  border: 1px solid #cbd5e1;
}

.badge-normal {
  background: #eef2ff;
  color: #4338ca;
  border: 1px solid #c7d2fe;
}

/* Pagination Bar */
.pagination-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  border-top: 1px solid #f1f5f9;
  background: #ffffff;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  flex-wrap: wrap;
  gap: 12px;
}

.pagination-info {
  font-size: 12.5px;
  color: #64748b;
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.pagination-btn {
  height: 32px;
  min-width: 32px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-sm);
  color: #334155;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.pagination-btn:hover:not(:disabled) {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: #0f172a;
}

.pagination-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
  font-weight: 700;
  box-shadow: 0 2px 4px rgba(37, 99, 235, 0.25);
}

.pagination-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.page-jump-input {
  width: 50px;
  height: 32px;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-sm);
  text-align: center;
  font-size: 12px;
  color: #1e293b;
  outline: none;
}

.page-jump-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}






/* ============================================================
   数据说明 / 口径披露（不可获得、估算或快照类数据的原因标注）
   ============================================================ */
.data-notes {
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px dashed var(--border-light, #e2e8f0);
  border-radius: 10px;
  background: #f8fafc;
}
.data-note {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  font-size: 12px;
  line-height: 1.6;
  color: #475569;
  padding: 3px 0;
}
.data-note + .data-note { border-top: 1px solid #eef2f7; }
.data-note.warn { color: #b45309; }
.data-note .dn-icon { flex: 0 0 auto; }
.data-notes-title {
  font-size: 12px;
  font-weight: 700;
  color: #334155;
  margin-bottom: 4px;
}

/* 商品名称可点击（全站商品详情悬浮窗入口） */
.product-cell-title.product-clickable,
.product-name-link {
  cursor: pointer;
}
.product-cell-title.product-clickable:hover,
.product-name-link:hover {
  color: var(--primary);
  text-decoration: underline;
}

/* 商品详情悬浮窗 */
.prod-detail-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
@media (max-width: 640px) {
  .prod-detail-grid { grid-template-columns: repeat(2, 1fr); }
}
.prod-detail-item {
  background: var(--bg-soft, #F8FAFC);
  border: 1px solid var(--border-light, #E2E8F0);
  border-radius: 10px;
  padding: 8px 12px;
}
.prod-detail-label {
  font-size: 11px;
  color: var(--text-muted);
}
.prod-detail-val {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
  margin-top: 2px;
}

/* KPI卡内迷你饼图（压仓占总仓比例） */
.kpi-split {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.kpi-mini-pie {
  width: 78px;
  height: 78px;
  flex: 0 0 auto;
  position: relative;
}
.kpi-mini-pie canvas {
  width: 100% !important;
  height: 100% !important;
}
.kpi-mini-pie-center {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
  color: #b91c1c;
  pointer-events: none;
}

/* ========================================================
   PDF EXPORT & PRINT FIDELITY STYLES
   ======================================================== */

.pdf-export-root {
  width: 1180px;
  max-width: 1180px;
  margin: 0;
  padding: 24px 28px 36px;
  background: #ffffff !important;
  color: #0f172a !important;
  font-family: 'Plus Jakarta Sans', 'Noto Sans SC', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
  box-sizing: border-box !important;
  display: block !important;
  position: relative !important;
}

.pdf-export-header {
  display: flex !important;
  justify-content: space-between !important;
  align-items: center !important;
  padding-bottom: 16px !important;
  margin-bottom: 20px !important;
  border-bottom: 2px solid var(--primary, #007A6C) !important;
}

.pdf-header-brand {
  display: flex !important;
  align-items: center !important;
  gap: 14px !important;
}

.pdf-header-logo {
  height: 48px !important;
  width: auto !important;
  display: block !important;
}

.pdf-header-titles {
  display: flex !important;
  flex-direction: column !important;
}

.pdf-header-main-title {
  font-size: 18px !important;
  font-weight: 800 !important;
  color: var(--primary-dark, #02594E) !important;
  letter-spacing: -0.02em !important;
  line-height: 1.2 !important;
}

.pdf-header-sub-title {
  font-size: 11px !important;
  font-weight: 600 !important;
  color: #64748B !important;
  margin-top: 2px !important;
  letter-spacing: 0.05em !important;
  text-transform: uppercase !important;
}

.pdf-header-meta {
  display: flex !important;
  flex-direction: column !important;
  align-items: flex-end !important;
  gap: 3px !important;
  font-size: 11px !important;
  color: #475569 !important;
}

.pdf-meta-badge {
  display: inline-block !important;
  padding: 3px 10px !important;
  background: var(--primary-light, #E6F4F1) !important;
  color: var(--primary-dark, #02594E) !important;
  font-weight: 700 !important;
  font-size: 12px !important;
  border-radius: 6px !important;
  margin-bottom: 2px !important;
  border: 1px solid rgba(0, 122, 108, 0.2) !important;
}

.pdf-meta-row {
  display: flex !important;
  gap: 6px !important;
}

.pdf-meta-row span {
  color: #64748B !important;
}

.pdf-meta-row strong {
  color: #0F172A !important;
  font-weight: 600 !important;
}

.pdf-export-footer {
  margin-top: 30px !important;
  padding-top: 14px !important;
  border-top: 1px solid #E2E8F0 !important;
  display: flex !important;
  justify-content: space-between !important;
  align-items: center !important;
  font-size: 10px !important;
  color: #94A3B8 !important;
}

/* Clean layout in export root */
.pdf-export-root .report-header {
  margin-bottom: 1.25rem !important;
  padding-bottom: 0 !important;
  border-bottom: none !important;
}

.pdf-export-root .report-header-actions,
.pdf-export-root .search-box,
.pdf-export-root .filter-group,
.pdf-export-root .btn-chip,
.pdf-export-root .btn-note-edit,
.pdf-export-root .chart-hint-badge,
.pdf-export-root .pagination-container,
.pdf-export-root .btn-export,
.pdf-export-root button:not(.pdf-allow-button),
.pdf-export-root input,
.pdf-export-root select {
  display: none !important;
}

.pdf-export-root .kpi-card,
.pdf-export-root .kpi-grid,
.pdf-export-root .card-section,
.pdf-export-root .table-container-card,
.pdf-export-root .insight-card,
.pdf-export-root .insights-grid,
.pdf-export-root .section-note-box,
.pdf-export-root .weekly-two-column-grid,
.pdf-export-root tr {
  break-inside: avoid !important;
  page-break-inside: avoid !important;
}

.pdf-export-root .kpi-card {
  box-shadow: 0 1px 3px rgba(0,0,0,0.06) !important;
  border: 1px solid #E2E8F0 !important;
  background: #ffffff !important;
}

.pdf-export-root .table-container-card,
.pdf-export-root .card-section {
  box-shadow: 0 1px 3px rgba(0,0,0,0.06) !important;
  border: 1px solid #E2E8F0 !important;
  background: #ffffff !important;
  margin-bottom: 1.25rem !important;
}

.pdf-export-root table {
  width: 100% !important;
}

.pdf-export-root table thead {
  display: table-header-group !important;
}

.pdf-filter-pill-bar {
  display: flex !important;
  gap: 8px !important;
  margin-bottom: 12px !important;
  flex-wrap: wrap !important;
}

.pdf-filter-pill {
  display: inline-flex !important;
  align-items: center !important;
  gap: 4px !important;
  font-size: 11px !important;
  font-weight: 600 !important;
  color: var(--primary-dark, #02594E) !important;
  background: var(--primary-light, #E6F4F1) !important;
  border: 1px solid rgba(0, 122, 108, 0.2) !important;
  border-radius: 6px !important;
  padding: 3px 8px !important;
}

.pdf-export-root .table-responsive {
  overflow: visible !important;
  max-width: 100% !important;
}

.pdf-export-root .data-table {
  width: 100% !important;
  table-layout: auto !important;
}

.pdf-export-root .data-table th,
.pdf-export-root .data-table td {
  padding: 6px 8px !important;
  font-size: 11px !important;
  line-height: 1.35 !important;
  white-space: normal !important;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* @media print for browser native print / Ctrl+P */
@media print {
  @page {
    size: A4 landscape;
    margin: 8mm;
  }

  body {
    background: #ffffff !important;
    color: #0f172a !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .app-header,
  .login-screen,
  .toast-container,
  .modal-overlay,
  .report-header-actions,
  .search-box,
  .filter-group,
  .btn-chip,
  .btn-note-edit,
  .chart-hint-badge,
  .pagination-container,
  .btn-export,
  #btn-export-pdf {
    display: none !important;
  }

  .tab-pane {
    display: none !important;
  }

  .tab-pane.active {
    display: block !important;
    width: 100% !important;
  }

  .kpi-card,
  .table-container-card,
  .card-section,
  .insight-card,
  .section-note-box,
  .weekly-two-column-grid,
  tr {
    break-inside: avoid !important;
    page-break-inside: avoid !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  table thead {
    display: table-header-group !important;
  }
}



/* ============================================================================
   TAB 8: AI SMART ANALYTICS & REPORT WORKSPACE
   ============================================================================ */
.nav-tab-ai {
  background: linear-gradient(135deg, rgba(0, 122, 108, 0.08), rgba(14, 165, 233, 0.08));
}

.nav-tab-ai.active {
  background: linear-gradient(135deg, var(--primary), #0284C7);
  color: #FFFFFF;
}

.ai-model-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  background: #FFFFFF;
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-main);
}

.ai-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #94A3B8;
  flex-shrink: 0;
}

.ai-status-dot.ready {
  background: #10B981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.18);
}

.ai-status-dot.unconfigured {
  background: #F59E0B;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.18);
}

.ai-workspace-card {
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 4px 20px rgba(15, 23, 42, 0.05);
  min-height: calc(100vh - 230px);
  max-height: calc(100vh - 180px);
  overflow: hidden;
}

.ai-messages-feed {
  flex: 1;
  overflow-y: auto;
  padding: 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  background: #F8FAFC;
}

.ai-welcome-box {
  margin: auto;
  max-width: 820px;
  text-align: center;
  padding: 24px 16px;
}

.ai-welcome-icon {
  width: 58px;
  height: 58px;
  margin: 0 auto 14px;
  border-radius: 16px;
  background: linear-gradient(135deg, #007A6C, #0EA5E9);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  box-shadow: 0 8px 20px rgba(0, 122, 108, 0.22);
}

.ai-welcome-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-main);
  margin: 0 0 8px;
}

.ai-welcome-desc {
  font-size: 13.5px;
  color: var(--text-muted);
  margin: 0 0 22px;
  line-height: 1.6;
}

.ai-quick-prompts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px;
  text-align: left;
}

.ai-prompt-chip {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #FFFFFF;
  color: var(--text-main);
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1.45;
  cursor: pointer;
  text-align: left;
  transition: all 0.16s ease;
  font-family: inherit;
}

.ai-prompt-chip:hover {
  border-color: var(--primary);
  background: #F0FDFA;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 122, 108, 0.1);
}

.ai-prompt-icon {
  font-size: 16px;
  flex-shrink: 0;
  margin-top: 1px;
}

/* Message Rows */
.ai-msg-row {
  display: flex;
  gap: 12px;
  max-width: 100%;
}

.ai-msg-row.user {
  justify-content: flex-end;
}

.ai-msg-avatar {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  flex-shrink: 0;
  background: linear-gradient(135deg, #007A6C, #0EA5E9);
  color: #FFFFFF;
}

.ai-msg-row.user .ai-msg-avatar {
  order: 2;
  background: #1E293B;
}

.ai-msg-bubble {
  max-width: min(960px, 90%);
  border-radius: 14px;
  padding: 14px 18px;
  font-size: 13.5px;
  line-height: 1.65;
  color: var(--text-main);
  background: #FFFFFF;
  border: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
  overflow-x: auto;
}

.ai-msg-row.user .ai-msg-bubble {
  background: var(--primary);
  color: #FFFFFF;
  border-color: var(--primary);
  white-space: pre-wrap;
}

.ai-msg-bubble.ai-error-bubble {
  background: #FEF2F2;
  border-color: #FECACA;
  color: #991B1B;
}

.ai-msg-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
  font-size: 11.5px;
  color: var(--text-muted);
}

.ai-md-content h2,
.ai-md-content h3,
.ai-md-content h4 {
  margin: 10px 0 6px;
  color: var(--text-main);
  font-weight: 700;
}

.ai-md-content h2 { font-size: 15.5px; }
.ai-md-content h3 { font-size: 14.5px; }
.ai-md-content p { margin: 0 0 8px; }
.ai-md-content ul,
.ai-md-content ol { margin: 4px 0 10px; padding-left: 20px; }
.ai-md-content li { margin-bottom: 4px; }
.ai-md-content code {
  background: #F1F5F9;
  color: #02594E;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12px;
}

/* AI Chart Block */
.ai-chart-card {
  margin-top: 14px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #FFFFFF;
}

.ai-chart-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 10px;
}

.ai-chart-canvas-wrap {
  position: relative;
  height: 280px;
  width: 100%;
}

/* AI Data Table Block */
.ai-table-card {
  margin-top: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: #FFFFFF;
}

.ai-table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 14px;
  background: #F8FAFC;
  border-bottom: 1px solid var(--border);
}

.ai-table-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.ai-table-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: #E2E8F0;
  color: #475569;
}

.ai-table-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.ai-mini-btn {
  padding: 4px 10px;
  font-size: 11.5px;
  font-weight: 600;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #FFFFFF;
  color: var(--text-main);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: inherit;
  transition: all 0.15s ease;
}

.ai-mini-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: #F0FDFA;
}

.ai-mini-btn.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #FFFFFF;
}

.ai-mini-btn.primary:hover {
  background: #02594E;
  color: #FFFFFF;
}

.ai-sql-details {
  padding: 8px 14px;
  background: #0F172A;
  color: #E2E8F0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
  white-space: pre-wrap;
  word-break: break-word;
  border-bottom: 1px solid #1E293B;
}

.ai-table-scroll {
  max-height: 360px;
  overflow: auto;
}

.ai-result-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.ai-result-table th {
  position: sticky;
  top: 0;
  background: #02594E;
  color: #FFFFFF;
  font-weight: 600;
  text-align: left;
  padding: 8px 10px;
  white-space: nowrap;
  z-index: 1;
}

.ai-result-table td {
  padding: 7px 10px;
  border-bottom: 1px solid #F1F5F9;
  color: var(--text-main);
  white-space: nowrap;
}

.ai-result-table tr:nth-child(even) td {
  background: #F8FAFC;
}

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

/* Composer */
.ai-composer-bar {
  padding: 14px 20px 12px;
  background: #FFFFFF;
  border-top: 1px solid var(--border);
}

.ai-composer-inner {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.ai-chat-input {
  flex: 1;
  resize: none;
  min-height: 44px;
  max-height: 140px;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  font-family: inherit;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--text-main);
  background: #F8FAFC;
  outline: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.ai-chat-input:focus {
  border-color: var(--primary);
  background: #FFFFFF;
  box-shadow: 0 0 0 3px rgba(0, 122, 108, 0.12);
}

.ai-send-btn {
  height: 44px;
  padding: 0 18px;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.ai-send-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.ai-composer-hint {
  margin-top: 6px;
  font-size: 11.5px;
  color: var(--text-muted);
}

/* Loading indicator */
.ai-typing-indicator {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 13px;
}

.ai-typing-dots {
  display: inline-flex;
  gap: 4px;
}

.ai-typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--primary);
  animation: aiBounce 1.2s infinite ease-in-out;
}

.ai-typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.ai-typing-dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes aiBounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* Settings Modal */
.ai-settings-modal-box {
  max-width: 540px;
  width: 92%;
}

.ai-setting-group {
  margin-bottom: 16px;
}

.ai-key-input-wrap {
  display: flex;
  gap: 8px;
  align-items: center;
}

.ai-key-input-wrap .field-modal-input {
  flex: 1;
}

.ai-toggle-key-btn {
  padding: 8px 10px;
  flex-shrink: 0;
}

.ai-setting-hint {
  margin-top: 5px;
  font-size: 11.5px;
  color: var(--text-muted);
}

.ai-test-result {
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 12.5px;
  font-weight: 600;
  margin-top: 8px;
}

.ai-test-result.ok {
  background: #ECFDF5;
  color: #065F46;
  border: 1px solid #A7F3D0;
}

.ai-test-result.err {
  background: #FEF2F2;
  color: #991B1B;
  border: 1px solid #FECACA;
}

/* Floating Quick Access Button */
.ai-fab-btn {
  position: fixed;
  right: 26px;
  bottom: 26px;
  z-index: 900;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 18px;
  border-radius: var(--radius-full);
  border: none;
  background: linear-gradient(135deg, #007A6C, #0284C7);
  color: #FFFFFF;
  font-size: 13px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 122, 108, 0.34);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.ai-fab-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(0, 122, 108, 0.44);
}

.ai-fab-icon {
  font-size: 17px;
  line-height: 1;
}


/* ============================================================================
   VIEWPORT-FIT & NO-HORIZONTAL-SCROLL RESPONSIVE GUARDRAILS
   ============================================================================ */
.table-container-card,
.card-section,
.kpi-card,
.ai-workspace-card,
.weekly-two-column-grid > *,
.daily-two-col > * {
  min-width: 0;
  max-width: 100%;
}

@media (max-width: 1366px) {
  .header-container {
    padding: 8px 16px;
  }
  .app-main {
    padding: 14px 16px;
  }
  .nav-tab {
    padding: 5px 10px;
    font-size: 12px;
  }
  .tab-text {
    font-size: 12px;
  }
  .kpi-grid {
    grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
    gap: 12px;
  }
  .data-table th,
  .data-table td {
    padding: 8px 6px;
    font-size: 11.5px;
  }
}

@media (max-width: 960px) {
  .brand-meta {
    display: none;
  }
  .brand-divider {
    display: none;
  }
  .header-actions {
    gap: 6px;
  }
  .btn-export {
    padding: 6px 12px;
    font-size: 12px;
  }
  .report-title {
    font-size: 20px;
  }
  .ai-fab-btn {
    right: 16px;
    bottom: 16px;
    padding: 9px 14px;
    font-size: 12px;
  }
}
