/* DataMxx dashboard shell — ธีมฟ้า–ส้ม + sidebar (ใช้ร่วมทุกหน้า Sales) */
:root {
  color-scheme: light;
  --color-background: #eef9fb;
  --color-on-background: #0f172a;
  --color-surface: #ffffff;
  --color-surface-container-lowest: #ffffff;
  --color-surface-container-low: #e0f7fb;
  --color-surface-container: #cffafe;
  --color-surface-bright: #ffffff;
  --color-surface-container-highest: #dff3f7;
  --color-primary: #0891b2;
  --color-secondary: #f97316;
  --color-on-surface: #1e293b;
  --color-on-surface-variant: #64748b;
  --color-outline: #b6dbe4;
  --color-outline-variant: #d7edf2;
  --loading-spin: #f97316;
  --loading-track: rgba(249, 115, 22, 0.14);
  --sidebar-gradient-from: #0891b2;
  --sidebar-gradient-to: #ea580c;
  --sidebar-width: 280px;
  --sidebar-collapsed-width: 5rem;
  --sidebar-float-gap: 0.875rem;
  --sidebar-float-radius: 1.5rem;
  --sidebar-rail-offset: calc(var(--sidebar-float-gap) + var(--sidebar-width));
  --sidebar-rail-offset-collapsed: calc(var(--sidebar-float-gap) + var(--sidebar-collapsed-width));
  --topbar-float-gap: var(--sidebar-float-gap);
  --topbar-float-radius: 1.25rem;
  --admin-subsidebar-width: 15.5rem;
  --admin-subsidebar-gap: 0.625rem;
  --admin-subsidebar-rail: calc(var(--admin-subsidebar-width) + var(--admin-subsidebar-gap));
  --shadow-soft: 0 4px 24px -4px rgba(15, 23, 42, 0.08), 0 16px 46px -18px rgba(8, 145, 178, 0.24), 0 12px 40px -20px rgba(234, 88, 12, 0.18);
  --radius-xl: 1.25rem;
  --radius-2xl: 1.5rem;
  --dm-dd-chrome-border: var(--color-outline-variant);
  --dm-dd-surface: var(--color-surface-bright);
  --dm-dd-placeholder: var(--color-on-surface-variant);
  --dm-dd-item-hover: var(--color-surface-container-low);
  --dm-dd-radius: 0.8125rem;
  --scrollbar-size: 10px;
  --scrollbar-track: #ebebeb;
  --scrollbar-thumb: color-mix(in srgb, var(--loading-spin) 36%, #cfc7bc);
  --scrollbar-thumb-hover: color-mix(in srgb, var(--loading-spin) 52%, #c4bbb0);
}
html.dark {
  color-scheme: dark;
  --color-background: #07151b;
  --color-on-background: #f1f5f9;
  --color-surface: #0f2028;
  --color-surface-container-lowest: #081319;
  --color-surface-container-low: #0f2b35;
  --color-surface-container: #123744;
  --color-surface-bright: #142a34;
  --color-surface-container-highest: #1d4858;
  --color-primary: #22d3ee;
  --color-secondary: #fb923c;
  --color-on-surface: #f1f5f9;
  --color-on-surface-variant: #a3c9d4;
  --color-outline: #2f6575;
  --color-outline-variant: #244856;
  --loading-spin: #fb923c;
  --loading-track: rgba(251, 146, 60, 0.18);
  --sidebar-gradient-from: #075985;
  --sidebar-gradient-to: #7c2d12;
  --shadow-soft: 0 8px 32px -8px rgba(0, 0, 0, 0.55), 0 18px 54px -24px rgba(34, 211, 238, 0.18);
  --scrollbar-track: #0f2028;
  --scrollbar-thumb: color-mix(in srgb, var(--loading-spin) 38%, #155e75);
  --scrollbar-thumb-hover: color-mix(in srgb, var(--loading-spin) 55%, #0e7490);
}

.layout-main {
  position: relative;
  isolation: isolate;
  overflow: visible;
  background: transparent;
}

.layout-main > main {
  position: relative;
  z-index: 1;
}

.layout-main > header,
.layout-main > #app-topbar,
.sales-app-main > #app-topbar {
  position: sticky;
  top: var(--topbar-float-gap);
  z-index: 55;
  flex-shrink: 0;
  margin: var(--topbar-float-gap) var(--topbar-float-gap) 0;
  width: auto;
  border-radius: var(--topbar-float-radius) !important;
  border: 1px solid color-mix(in srgb, var(--color-outline-variant) 82%, #fed7aa 18%) !important;
  background: color-mix(in srgb, var(--color-surface-bright) 90%, transparent) !important;
  box-shadow: 0 14px 40px -22px rgba(15, 23, 42, 0.22);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

html.dark .layout-main > header,
html.dark .layout-main > #app-topbar,
html.dark .sales-app-main > #app-topbar {
  border-color: color-mix(in srgb, var(--color-outline-variant) 78%, transparent) !important;
  background:
    linear-gradient(
      90deg,
      color-mix(in srgb, var(--color-surface-bright) 92%, transparent),
      color-mix(in srgb, var(--color-surface-container-low) 88%, transparent) 58%,
      color-mix(in srgb, #7c2d12 18%, transparent)
    ) !important;
  box-shadow: 0 16px 44px -24px rgba(0, 0, 0, 0.55);
}

.surface-panel {
  border-radius: var(--radius-2xl);
  border: 1px solid color-mix(in srgb, var(--color-outline-variant) 78%, transparent);
  background: color-mix(in srgb, var(--color-surface-bright) 86%, transparent);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
html.dark .surface-panel {
  border-color: color-mix(in srgb, var(--color-outline-variant) 80%, transparent);
}

.product-brand-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.product-brand-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 2.5rem;
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--color-outline-variant) 85%, transparent);
  background: color-mix(in srgb, var(--color-surface-bright) 90%, transparent);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--color-on-surface-variant);
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.product-brand-tab:hover {
  border-color: color-mix(in srgb, #ea580c 35%, var(--color-outline-variant));
  color: var(--color-on-surface);
}

.product-brand-tab.is-active {
  border-color: color-mix(in srgb, #ea580c 55%, transparent);
  background: color-mix(in srgb, #fff7ed 88%, var(--color-surface-bright));
  color: #c2410c;
  box-shadow: 0 1px 0 color-mix(in srgb, #ea580c 18%, transparent);
}

html.dark .product-brand-tab.is-active {
  background: color-mix(in srgb, #7c2d12 22%, var(--color-surface-container-low));
  color: #fdba74;
}

.product-brand-tab__count {
  display: inline-flex;
  min-width: 1.35rem;
  justify-content: center;
  padding: 0.05rem 0.35rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--color-outline-variant) 22%, transparent);
  font-size: 0.6875rem;
  font-weight: 700;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.product-brand-tab.is-active .product-brand-tab__count {
  background: color-mix(in srgb, #ea580c 16%, transparent);
  color: inherit;
}

.product-brand-tab[data-product-brand="nnn"].is-active {
  border-color: color-mix(in srgb, #2563eb 55%, transparent);
  background: color-mix(in srgb, #eff6ff 88%, var(--color-surface-bright));
  color: #1d4ed8;
}

html.dark .product-brand-tab[data-product-brand="nnn"].is-active {
  background: color-mix(in srgb, #1e3a8a 28%, var(--color-surface-container-low));
  color: #93c5fd;
}

.kpi-accent {
  border-left: 4px solid var(--loading-spin);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.5rem;
  border-radius: 999px;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.net-bar-track {
  height: 6px;
  border-radius: 999px;
  background: var(--loading-track);
  overflow: hidden;
  margin-top: 6px;
}
.net-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--loading-spin), color-mix(in srgb, var(--loading-spin) 72%, white));
  transition: width 0.25s ease-out;
}
html.dark .net-bar-fill {
  background: linear-gradient(90deg, var(--loading-spin), color-mix(in srgb, var(--loading-spin) 55%, transparent));
}

/* ซ่อนเมนู/เนื้อหาจนกว่า page access จะ filter เสร็จ — กัน flash หน้าที่ไม่มีสิทธิ */
html.page-access-pending #app-sidebar nav,
html.page-access-pending #app-sidebar .nav-side-group,
html.page-access-pending .rwd-bottom-nav,
html.page-access-pending .rwd-home-grid,
html.page-access-pending .rwd-main,
html.page-access-pending .sales-app-main {
  visibility: hidden;
}

html.page-access-ready #app-sidebar nav,
html.page-access-ready #app-sidebar .nav-side-group,
html.page-access-ready .rwd-bottom-nav,
html.page-access-ready .rwd-home-grid,
html.page-access-ready .rwd-main,
html.page-access-ready .sales-app-main {
  visibility: visible;
}

#app-sidebar {
  display: flex;
  flex-direction: column;
  width: var(--sidebar-width);
  min-height: 100vh;
  min-height: 100dvh;
  background: linear-gradient(
    180deg,
    var(--sidebar-gradient-from) 0%,
    var(--sidebar-gradient-to) 100%
  );
  transition:
    transform 0.28s cubic-bezier(0.4, 0, 0.2, 1),
    width 0.28s cubic-bezier(0.4, 0, 0.2, 1),
    border-radius 0.28s cubic-bezier(0.4, 0, 0.2, 1),
    box-shadow 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

#app-sidebar > nav {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
}

#app-sidebar > .sidebar-footer {
  flex-shrink: 0;
}

.sidebar-brand-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: 1;
  min-width: 0;
}

.sidebar-brand-toggle-btn {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: none;
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.25);
  backdrop-filter: blur(4px);
}
.sidebar-brand-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.32);
}
.sidebar-brand-toggle-btn .material-symbols-outlined {
  font-size: 26px;
}

.sidebar-brand-text {
  display: block;
  min-width: 0;
  flex: 1;
  text-decoration: none;
  color: inherit;
}
.sidebar-brand-text:hover .sidebar-brand-title {
  color: #fff;
}
.sidebar-brand-copy {
  min-width: 0;
  padding: 0.1rem 0;
}
.sidebar-brand-title {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: "IBM Plex Sans Thai", "IBM Plex Sans", system-ui, sans-serif;
  font-size: 1.0625rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: #fff;
  text-shadow: 0 1px 3px rgba(15, 23, 42, 0.18);
}
.sidebar-brand-subtitle {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 0.2rem;
  font-size: 0.625rem;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.72);
}
@media (max-width: 1023px) {
  #app-sidebar,
  #app-sidebar.app-sidebar-shell {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: var(--sidebar-width);
    min-height: 100vh;
    min-height: 100dvh;
    border-radius: 0;
    box-shadow: 8px 0 40px -12px rgba(194, 65, 12, 0.45);
    z-index: 70;
    overflow-x: hidden;
    overflow-y: auto;
  }

  #app-sidebar:not(.is-open) {
    transform: translateX(-100%);
  }
  #sidebar-overlay.is-visible {
    opacity: 1;
    pointer-events: auto;
  }
}
#sidebar-overlay {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.nav-side-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border-radius: 1rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.82);
  transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1), background-color 0.22s cubic-bezier(0.25, 1, 0.5, 1), color 0.22s ease, box-shadow 0.22s ease;
  will-change: transform;
}
.nav-side-link:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  transform: translateX(4px);
}
.nav-side-link.active {
  background: #fff;
  color: #0e7490;
  box-shadow: 0 8px 28px -10px rgba(8, 145, 178, 0.52), 0 10px 28px -16px rgba(234, 88, 12, 0.38);
  transform: scale(1.02);
}
html.dark .nav-side-link.active {
  color: #0e7490;
  box-shadow: 0 8px 28px -8px rgba(0, 0, 0, 0.55);
}
.nav-side-link .material-symbols-outlined {
  font-size: 22px;
  opacity: 0.95;
}

.nav-side-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav-side-group-toggle {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.85rem 1rem;
  border: none;
  border-radius: 1rem;
  background: transparent;
  font-size: 0.875rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.82);
  cursor: pointer;
  text-align: left;
  transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1), background-color 0.22s cubic-bezier(0.25, 1, 0.5, 1), color 0.22s ease;
}
.nav-side-group-toggle:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  transform: translateX(4px);
}
.nav-side-group.has-active > .nav-side-group-toggle {
  color: #fff;
}
.nav-side-chevron {
  margin-left: auto;
  font-size: 20px;
  opacity: 0.75;
  transition: transform 0.2s ease;
}
.nav-side-group.is-open .nav-side-chevron {
  transform: rotate(180deg);
}
.nav-side-sub {
  display: none;
  flex-direction: column;
  gap: 2px;
  padding-left: 0.35rem;
  margin: 0 0 0.15rem 1.35rem;
  border-left: 2px solid rgba(255, 255, 255, 0.22);
}
.nav-side-group.is-open .nav-side-sub {
  display: flex;
}
.nav-side-sublink {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.65rem 0.85rem 0.65rem 0.75rem;
  border-radius: 0.85rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.78);
  transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1), background-color 0.22s cubic-bezier(0.25, 1, 0.5, 1), color 0.22s ease;
}
.nav-side-sublink:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  transform: translateX(3px);
}
.nav-side-sublink.active {
  background: #fff;
  color: #0e7490;
  box-shadow: 0 6px 20px -10px rgba(8, 145, 178, 0.45);
}
.nav-side-sublink .material-symbols-outlined {
  font-size: 20px;
  opacity: 0.95;
}

/* ==========================================
   PREMIUM GPU-ACCELERATED MICRO-INTERACTIONS
   ========================================== */

/* การ์ดแผงหน้าจอ & KPI ยกตัวแบบสมูท */
#sap-exec-dashboard article,
#kpi-classic-row article {
  transition: transform 0.28s cubic-bezier(0.25, 1, 0.5, 1), box-shadow 0.28s cubic-bezier(0.25, 1, 0.5, 1), border-color 0.28s ease;
  will-change: transform, box-shadow;
}
#sap-exec-dashboard article:hover,
#kpi-classic-row article:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 32px -4px rgba(15, 23, 42, 0.08), 0 20px 48px -16px rgba(8, 145, 178, 0.22), 0 18px 42px -22px rgba(234, 88, 12, 0.22);
  border-color: color-mix(in srgb, var(--color-primary) 32%, var(--color-outline-variant));
}
html.dark #sap-exec-dashboard article:hover,
html.dark #kpi-classic-row article:hover {
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.48);
}

/* ปุ่มยุบตัวเมื่อคลิก และลอยขึ้นเล็กน้อยเมื่อ Hover (ไม่กระตุก) */
button,
.sales-pill-tab,
.sales-filter-panel__btn-secondary,
#theme-toggle {
  transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1), background-color 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}
button:hover,
.sales-pill-tab:hover,
#theme-toggle:hover {
  transform: translateY(-2px);
}
button:active,
.sales-pill-tab:active,
#theme-toggle:active {
  transform: scale(0.96) translateY(0);
}

/* เอฟเฟกต์ Fade-in-up หรูหรา ไร้อาการแลคเมื่อเปิดหน้าเว็บ */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.surface-panel,
main > section,
#sap-exec-dashboard,
#kpi-classic-row > article,
#sales-filter-panel {
  animation: fadeInUp 0.48s cubic-bezier(0.215, 0.61, 0.355, 1) both;
  will-change: transform, opacity;
}

#kpi-classic-row > article:nth-child(1) { animation-delay: 0.04s; }
#kpi-classic-row > article:nth-child(2) { animation-delay: 0.08s; }
#kpi-classic-row > article:nth-child(3) { animation-delay: 0.12s; }
#sales-results-section { animation-delay: 0.16s; }
#sales-filter-panel { animation-delay: 0.08s; }


.dm-dd {
  position: relative;
  width: 100%;
  z-index: 1;
}

.dm-dd.is-open {
  z-index: 130;
}

.year-dd.is-open {
  z-index: 130;
}

.dm-dd-shell {
  position: relative;
  z-index: 0;
  border-radius: var(--dm-dd-radius);
  border: 1px solid var(--dm-dd-chrome-border);
  background: var(--dm-dd-surface);
  overflow: visible;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
}

html.dark .dm-dd-shell {
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}

.dm-dd.is-open > .dm-dd-shell > .dm-dd-sep {
  display: none !important;
}

.dm-dd-shell > ul.dm-dd-panel,
.year-dd > ul.year-dd-panel,
.year-dd .dm-dd-shell > ul.year-dd-panel {
  position: absolute;
  left: -1px;
  width: calc(100% + 2px);
  box-sizing: border-box;
  top: calc(100% + 2px);
  z-index: 140;
  margin: 0;
  border-radius: var(--dm-dd-radius);
  border: 1px solid var(--dm-dd-chrome-border);
  background: var(--dm-dd-surface);
  box-shadow:
    var(--shadow-soft),
    0 18px 50px -12px rgba(15, 23, 42, 0.14);
}

html.dark .dm-dd-shell > ul.dm-dd-panel,
html.dark .year-dd > ul.year-dd-panel,
html.dark .year-dd .dm-dd-shell > ul.year-dd-panel {
  box-shadow:
    0 14px 42px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(255, 255, 255, 0.06);
}

.dm-dd-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  width: 100%;
  min-height: 48px;
  padding: 0.75rem 1rem;
  margin: 0;
  border: none;
  background: transparent;
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--color-on-surface);
  cursor: pointer;
  text-align: left;
}

.dm-dd-trigger:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.dm-dd-value.is-placeholder {
  color: var(--dm-dd-placeholder);
}

.dm-dd-chevron,
.year-dd-chevron {
  flex-shrink: 0;
  font-size: 22px;
  line-height: 1;
  color: var(--color-outline);
  transition: transform 0.2s ease;
}

.dm-dd.is-open .dm-dd-chevron {
  transform: none;
}

.year-dd.is-open .year-dd-chevron {
  transform: rotate(180deg);
}

.dm-dd-sep,
.year-dd-sep {
  height: 0;
  border-top: 1px solid var(--dm-dd-chrome-border);
  margin: 0;
}

.dm-dd-panel,
.year-dd-panel {
  list-style: none;
  margin: 0;
  padding: 0.35rem 0.45rem 0.5rem;
  max-height: min(55vh, 320px);
  overflow-x: hidden;
  overflow-y: auto;
}

.dm-dd-header,
.year-dd-header {
  padding: 0.35rem 0.75rem 0.45rem;
  margin: 0 0.25rem 0.15rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--dm-dd-placeholder);
  list-style: none;
}

.dm-dd-option,
.year-dd-option {
  display: block;
  width: calc(100% - 4px);
  margin: 2px auto;
  padding: 0.65rem 0.85rem;
  border: none;
  border-radius: 10px;
  background: transparent;
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--color-on-surface);
  cursor: pointer;
  text-align: left;
  transition: background 0.12s ease;
}

.dm-dd-option:hover,
.dm-dd-option:focus-visible,
.year-dd-option:hover,
.year-dd-option:focus-visible {
  background: var(--dm-dd-item-hover);
  outline: none;
}

.dm-dd-option.is-active,
.year-dd-option.is-active {
  background: var(--color-surface-container);
  font-weight: 600;
}

html.dark .dm-dd-option:hover,
html.dark .dm-dd-option:focus-visible,
html.dark .year-dd-option:hover,
html.dark .year-dd-option:focus-visible {
  background: rgba(255, 255, 255, 0.08);
}

html.dark .dm-dd-option.is-active,
html.dark .year-dd-option.is-active {
  background: rgba(255, 255, 255, 0.11);
}

.dm-dd-native-slot {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.dm-dd-trigger:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--color-outline) 35%, transparent);
}

.auth-session-widget {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: fit-content;
  max-width: 100%;
  flex: 0 0 auto;
  align-self: flex-end;
  z-index: 80;
}

.auth-session-anchor {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: fit-content;
  max-width: 100%;
}

.auth-session-trigger {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border: 1px solid var(--color-outline-variant);
  border-radius: 1rem;
  background: var(--color-surface-bright);
  padding: 0.375rem 0.45rem 0.375rem 0.375rem;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
  cursor: pointer;
  font: inherit;
  color: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.auth-session-trigger:hover,
.auth-session-widget.is-menu-open .auth-session-trigger {
  border-color: color-mix(in srgb, #2563eb 28%, var(--color-outline-variant));
  box-shadow: 0 4px 14px -8px rgba(37, 99, 235, 0.35);
}

.auth-session-chevron {
  font-size: 1.25rem;
  color: var(--color-on-surface-variant);
  transition: transform 0.15s ease;
}

.auth-session-widget.is-menu-open .auth-session-chevron {
  transform: rotate(180deg);
}

.auth-profile-menu.hidden,
.auth-profile-menu[hidden] {
  display: none !important;
  pointer-events: none !important;
}

.auth-profile-menu-backdrop {
  position: fixed;
  inset: 0;
  z-index: 190;
  border: none;
  padding: 0;
  margin: 0;
  background: rgba(15, 23, 42, 0.35);
  backdrop-filter: blur(2px);
  cursor: default;
}

.auth-profile-menu-backdrop.hidden,
.auth-profile-menu-backdrop[hidden] {
  display: none !important;
}

.auth-profile-menu {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  left: auto;
  z-index: 120;
  min-width: 15.5rem;
  padding: 0.35rem;
  border-radius: 0.85rem;
  border: 1px solid #e2e8f0;
  background: #fff;
  box-shadow:
    0 12px 32px -12px rgba(15, 23, 42, 0.22),
    0 4px 12px -4px rgba(15, 23, 42, 0.08);
}

.auth-profile-menu--floating {
  position: fixed !important;
  z-index: 200 !important;
  margin: 0;
}

.auth-profile-menu-slot {
  display: none !important;
}

html.dark .auth-profile-menu {
  border-color: var(--color-outline-variant);
  background: var(--color-surface-bright);
}

.auth-profile-menu__item {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 0.65rem;
  border: none;
  border-radius: 0.55rem;
  background: transparent;
  padding: 0.62rem 0.75rem;
  font-size: 0.9375rem;
  font-weight: 500;
  line-height: 1.25;
  color: #1e293b;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.12s ease;
}

html.dark .auth-profile-menu__item {
  color: var(--color-on-surface);
}

.auth-profile-menu__item .material-symbols-outlined {
  font-size: 1.35rem;
  color: #475569;
}

.auth-profile-menu__item:hover,
.auth-profile-menu__item:focus-visible {
  background: #f8fafc;
  outline: none;
}

html.dark .auth-profile-menu__item:hover,
html.dark .auth-profile-menu__item:focus-visible {
  background: var(--color-surface-container-low);
}

.auth-profile-menu__item--signout {
  margin-top: 0.15rem;
  color: #9f1239;
}

.auth-profile-menu__item--signout .material-symbols-outlined {
  color: #9f1239;
}

.auth-profile-menu__item--signout:hover,
.auth-profile-menu__item--signout:focus-visible {
  background: #fff1f2;
  color: #881337;
}

.auth-session-avatar {
  display: flex;
  height: 2.25rem;
  width: 2.25rem;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  border-radius: 0.75rem;
  background: linear-gradient(135deg, #06b6d4, #0ea5e9 48%, #f97316);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 800;
  box-shadow: inset 0 -8px 18px rgba(124, 45, 18, 0.16);
}

.auth-session-copy {
  min-width: 0;
  line-height: 1.1;
}

.auth-session-name {
  display: block;
  max-width: 11rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--color-on-surface);
}

.auth-session-code {
  display: block;
  margin-top: 0.12rem;
  max-width: 8.5rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.64rem;
  font-weight: 700;
  color: var(--color-on-surface-variant);
}

.row-draft {
  box-shadow: inset 3px 0 0 rgba(245, 158, 11, 0.55);
}
html.dark .row-draft {
  box-shadow: inset 3px 0 0 rgba(251, 191, 36, 0.45);
}

/* ข้อความโหลดแบบคลื่น (ตัวอักษรสลับ opacity) */
.dm-wave-loading {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0;
  font-family: "IBM Plex Sans", "IBM Plex Sans Thai", system-ui, sans-serif;
  font-weight: 700;
  font-size: 0.8125rem;
  letter-spacing: 0.06em;
  line-height: 1.2;
  min-height: 1.25rem;
  vertical-align: middle;
}

.dm-wave-loading__ch {
  display: inline-block;
  min-width: 0.02em;
  animation: dm-wave-loading-ch 1.08s ease-in-out infinite;
  animation-delay: calc(var(--dm-wave-i, 0) * 0.09s);
  opacity: 0.32;
  color: var(--loading-spin);
  text-shadow: 0 0 0 transparent;
}

@keyframes dm-wave-loading-ch {
  0%,
  100% {
    opacity: 0.32;
    transform: translateY(0);
    text-shadow: none;
  }
  40% {
    opacity: 1;
    transform: translateY(-1px);
    text-shadow: 0 0 12px color-mix(in srgb, var(--loading-spin) 35%, transparent);
  }
}

@media (prefers-reduced-motion: reduce) {
  .dm-wave-loading__ch {
    animation: none;
    opacity: 0.88;
    transform: none;
    text-shadow: none;
  }
}

html.dark .dm-wave-loading__ch {
  color: color-mix(in srgb, var(--loading-spin) 92%, white);
}

/* Sales list — ตารางผลลัพธ์ (IBM Plex + zebra + hover โทนส้มอ่อน) */
.sales-table-wrap {
  position: relative;
  padding: 0 1rem 1rem;
}

@media (min-width: 640px) {
  .sales-table-wrap {
    padding: 0 1.25rem 1.25rem;
  }
}

.sales-table {
  font-family: "IBM Plex Sans", "IBM Plex Sans Thai", system-ui, sans-serif;
  font-size: 0.8125rem;
  line-height: 1.58;
  font-feature-settings: "tnum" 1, "lnum" 1;
  -webkit-font-smoothing: antialiased;
}

.sales-table thead th {
  font-family: "IBM Plex Sans", "IBM Plex Sans Thai", system-ui, sans-serif;
  font-weight: 600;
  font-size: 0.6875rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  vertical-align: middle;
  color: var(--color-on-surface-variant);
  border-bottom: 1px solid color-mix(in srgb, var(--color-outline-variant) 65%, transparent);
  box-shadow: inset 0 -1px 0 color-mix(in srgb, var(--color-primary) 26%, var(--loading-spin) 14%);
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--color-surface-container-highest) 76%, var(--color-surface-bright)) 0%,
    color-mix(in srgb, var(--color-surface-container-highest) 96%, var(--color-surface-bright)) 100%
  );
}

html.dark .sales-table thead th {
  color: var(--color-on-surface-variant);
  box-shadow: inset 0 -1px 0 color-mix(in srgb, var(--loading-spin) 32%, transparent);
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--color-surface-container-highest) 92%, transparent) 0%,
    color-mix(in srgb, var(--color-surface-container-highest) 98%, transparent) 100%
  );
}

.sales-table tbody td {
  vertical-align: top;
  transition: background-color 0.14s ease, color 0.14s ease;
  border-bottom: 1px solid color-mix(in srgb, var(--color-outline-variant) 45%, transparent);
}

.sales-table tbody tr:nth-child(even) td {
  background-color: color-mix(in srgb, var(--color-surface-container-low) 46%, var(--color-surface-bright));
}

html.dark .sales-table tbody tr:nth-child(even) td {
  background-color: color-mix(in srgb, var(--color-surface-container-low) 45%, transparent);
}

.sales-table tbody tr:hover td {
  background-color: color-mix(in srgb, var(--color-primary) 10%, var(--color-surface-bright)) !important;
}

html.dark .sales-table tbody tr:hover td {
  background-color: color-mix(in srgb, var(--loading-spin) 12%, var(--color-surface-container-lowest)) !important;
}

.sales-table .sales-table-doclink {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-weight: 600;
  font-size: 0.8125rem;
  letter-spacing: -0.015em;
}

.sales-table .sales-table-num {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 0.8125rem;
}

.sales-table .sales-table-muted {
  font-size: 0.75rem;
  line-height: 1.45;
  color: var(--color-on-surface-variant);
}

/* lg+: sidebar ลอยไม่ชิดขอบ (fixed + margin); คอลัมน์ขวาเลื่อนแยก */
@media (min-width: 1024px) {
  .sales-app-root {
    min-height: 100vh;
    min-height: 100dvh;
  }

  .sales-app-root > #app-sidebar,
  #app-sidebar.fixed,
  #app-sidebar.app-sidebar-shell {
    position: fixed;
    top: var(--sidebar-float-gap) !important;
    bottom: var(--sidebar-float-gap) !important;
    left: var(--sidebar-float-gap) !important;
    right: auto !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: calc(100vh - (var(--sidebar-float-gap) * 2));
    max-height: calc(100dvh - (var(--sidebar-float-gap) * 2));
    overflow: hidden;
    border-radius: var(--sidebar-float-radius);
    box-shadow: 0 18px 48px -16px rgba(15, 23, 42, 0.38);
    overscroll-behavior: contain;
    z-index: 70;
  }

  .sales-app-main {
    margin-left: var(--sidebar-rail-offset);
    width: calc(100% - var(--sidebar-rail-offset));
    max-width: none;
    min-height: 100vh;
    min-height: 100dvh;
    height: 100vh;
    height: 100dvh;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    display: flex;
    flex-direction: column;
    background: var(--color-background);
    transition:
      margin-left 0.28s cubic-bezier(0.4, 0, 0.2, 1),
      width 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  }

  #app-sidebar.is-collapsed {
    width: var(--sidebar-collapsed-width) !important;
    min-width: var(--sidebar-collapsed-width) !important;
    max-width: var(--sidebar-collapsed-width) !important;
  }

  #app-sidebar.is-collapsed > div:first-child {
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }

  #app-sidebar.is-collapsed .sidebar-brand-row {
    flex: none;
    width: 100%;
    justify-content: center;
  }

  #app-sidebar.is-collapsed .sidebar-brand-toggle-btn {
    margin: 0;
  }

  #app-sidebar.is-collapsed .sidebar-brand-text {
    display: none !important;
  }

  #app-sidebar.is-collapsed a.flex.min-w-0 > .min-w-0,
  #app-sidebar.is-collapsed .nav-side-link > span:not(.material-symbols-outlined),
  #app-sidebar.is-collapsed .nav-side-group-label,
  #app-sidebar.is-collapsed .nav-side-chevron,
  #app-sidebar.is-collapsed .nav-side-sub,
  #app-sidebar.is-collapsed .mt-auto,
  #app-sidebar.is-collapsed .sidebar-lme-footer {
    display: none !important;
  }

  #app-sidebar.is-collapsed .nav-side-group-toggle {
    justify-content: center;
    padding-left: 0.75rem;
    padding-right: 0.75rem;
    gap: 0;
  }

  #app-sidebar.is-collapsed .nav-side-group-toggle[title]:hover::after {
    content: attr(title);
    position: absolute;
    left: calc(100% + 8px);
    top: 50%;
    transform: translateY(-50%);
    z-index: 80;
    white-space: nowrap;
    padding: 0.35rem 0.6rem;
    border-radius: 0.5rem;
    background: rgba(15, 23, 42, 0.92);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 600;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  }

  #app-sidebar.is-collapsed .nav-side-group-toggle {
    position: relative;
  }

  #app-sidebar.is-collapsed .nav-side-link {
    justify-content: center;
    padding-left: 0.75rem;
    padding-right: 0.75rem;
    gap: 0;
  }

  #app-sidebar.is-collapsed .nav-side-link {
    position: relative;
  }

  #app-sidebar.is-collapsed .nav-side-link[title]:hover::after {
    content: attr(title);
    position: absolute;
    left: calc(100% + 8px);
    top: 50%;
    transform: translateY(-50%);
    z-index: 80;
    white-space: nowrap;
    padding: 0.35rem 0.6rem;
    border-radius: 0.5rem;
    background: rgba(15, 23, 42, 0.92);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 600;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  }

  .sales-app-root.sidebar-is-collapsed .sales-app-main {
    margin-left: var(--sidebar-rail-offset-collapsed);
    width: calc(100% - var(--sidebar-rail-offset-collapsed));
  }

  .sales-app-main > .layout-main {
    display: flex;
    flex-direction: column;
    flex: 0 0 auto;
    width: 100%;
  }

  /* ให้เนื้อหาสูงตามข้อมูลจริง แล้วให้ sales-app-main เป็นคนเลื่อน */
  .sales-app-main > .layout-main > main {
    flex-grow: 0;
  }
}

/* Sales list — แผงช่วงโหลด & ตัวกรอง (ธีมสว่าง / มืด) */
#sales-filter-panel {
  color-scheme: light;
  border-color: color-mix(in srgb, var(--color-outline-variant) 90%, var(--loading-spin) 10%);
  background: var(--color-surface-bright);
  box-shadow: var(--shadow-soft);
  overflow: visible !important;
  position: relative !important;
  z-index: 50 !important;
  will-change: opacity !important;
}

html.dark #sales-filter-panel {
  color-scheme: dark;
  border-color: color-mix(in srgb, var(--color-outline) 50%, var(--loading-spin) 15%);
  background: var(--color-surface-container-lowest);
  overflow: visible !important;
  position: relative !important;
  z-index: 50 !important;
  will-change: opacity !important;
}

#sales-filter-panel .sales-filter-panel__header {
  border-bottom: 1px solid var(--color-outline-variant);
  background: linear-gradient(
    90deg,
    color-mix(in srgb, var(--color-surface-container-low) 85%, var(--color-surface-bright)) 0%,
    var(--color-surface-bright) 72%
  );
}

html.dark #sales-filter-panel .sales-filter-panel__header {
  background: linear-gradient(
    90deg,
    color-mix(in srgb, var(--loading-spin) 16%, var(--color-surface-container-lowest)) 0%,
    var(--color-surface-container-lowest) 70%
  );
}

#sales-filter-panel .sales-filter-panel__body {
  background: var(--color-surface-bright);
}

html.dark #sales-filter-panel .sales-filter-panel__body {
  background: color-mix(in srgb, var(--color-surface-container-lowest) 94%, var(--color-surface-bright) 6%);
}

/* ยกเลิกพื้นเข้มจาก Tailwind Forms ในโหมดมืด — ใช้ token เดียวกับ dropdown อื่น */
#sales-filter-panel select.sales-filter-select {
  appearance: none;
  background-color: var(--color-surface-bright) !important;
  color: var(--color-on-surface) !important;
  border: 1px solid var(--color-outline-variant) !important;
  border-radius: var(--dm-dd-radius);
  padding: 0.65rem 1rem;
  font-size: 0.9375rem;
  font-weight: 500;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}

html.dark #sales-filter-panel select.sales-filter-select {
  border-color: var(--color-outline) !important;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}

#sales-filter-panel .dm-dd-shell {
  background: var(--dm-dd-surface);
  border-color: var(--dm-dd-chrome-border);
}

html.dark #sales-filter-panel .dm-dd-trigger {
  color: var(--color-on-surface);
}

html.dark #sales-filter-panel .dm-dd-chevron {
  color: var(--color-on-surface-variant);
}

#sales-filter-panel .sales-filter-panel__btn-secondary {
  border-color: color-mix(in srgb, var(--color-outline-variant) 65%, var(--loading-spin) 35%);
  background: color-mix(in srgb, var(--color-surface-container-low) 55%, var(--color-surface-bright));
  color: var(--color-on-surface);
}

#sales-filter-panel .sales-filter-panel__btn-secondary:hover {
  background: color-mix(in srgb, var(--color-surface-container-low) 75%, var(--color-surface-bright));
}

html.dark #sales-filter-panel .sales-filter-panel__btn-secondary {
  border-color: color-mix(in srgb, var(--loading-spin) 32%, var(--color-outline));
  background: color-mix(in srgb, var(--loading-spin) 10%, var(--color-surface-container-low));
}

html.dark #sales-filter-panel .sales-filter-panel__btn-secondary:hover {
  background: color-mix(in srgb, var(--loading-spin) 18%, var(--color-surface-container));
}

#sales-filter-panel .sales-filter-panel__api {
  border-color: var(--color-outline-variant);
  background: color-mix(in srgb, var(--color-surface-container-low) 40%, var(--color-surface-bright));
}

html.dark #sales-filter-panel .sales-filter-panel__api {
  border-color: var(--color-outline);
  background: color-mix(in srgb, var(--color-surface-container) 28%, var(--color-surface-container-lowest));
}

#sales-filter-panel .sales-filter-panel__input {
  background: var(--color-surface-bright);
  color: var(--color-on-surface);
  border-color: var(--color-outline-variant);
}

html.dark #sales-filter-panel .sales-filter-panel__input {
  background: var(--color-surface-bright);
  border-color: var(--color-outline);
  color: var(--color-on-surface);
}

#sales-filter-panel #api-url-clear {
  background: var(--color-surface-bright);
  color: var(--color-on-surface);
  border-color: var(--color-outline-variant);
}

html.dark #sales-filter-panel #api-url-clear:hover {
  background: var(--color-surface-container-low);
}

/* ==========================================
   PREMIUM NATIVE DATE INPUT STYLING
   ========================================== */

.premium-date-input {
  appearance: none !important;
  -webkit-appearance: none !important;
  font-family: "IBM Plex Sans", "IBM Plex Sans Thai", system-ui, sans-serif !important;
  font-size: 0.875rem !important;
  font-weight: 500 !important;
  line-height: 1.25rem !important;
  padding: 0.625rem 0.875rem !important;
  border-radius: 0.875rem !important; /* 14px premium rounded */
  border: 1.5px solid var(--color-outline-variant, #cbd5e1) !important;
  background-color: var(--color-surface-bright, #ffffff) !important;
  color: var(--color-on-surface, #0f172a) !important;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05) !important;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
  outline: none !important;
}

/* Hover state */
.premium-date-input:hover:not(:disabled) {
  border-color: var(--loading-spin, #ea580c) !important;
  box-shadow: 0 4px 12px -4px rgba(234, 88, 12, 0.25) !important;
}

/* Focus-visible & focus states with custom orange glow */
.premium-date-input:focus,
.premium-date-input:focus-visible {
  border-color: var(--loading-spin, #ea580c) !important;
  box-shadow: 0 0 0 4px rgba(234, 88, 12, 0.16), 0 4px 12px -4px rgba(234, 88, 12, 0.2) !important;
}

/* Premium styling for Chromium's native calendar icon inside the input */
.premium-date-input::-webkit-calendar-picker-indicator {
  cursor: pointer !important;
  padding: 4px !important;
  border-radius: 6px !important;
  transition: all 0.2s ease !important;
  /* Filter to convert black native icon into beautiful orange matching var(--loading-spin) */
  filter: invert(48%) sepia(82%) saturate(2462%) hue-rotate(359deg) brightness(97%) contrast(95%) !important;
}

.premium-date-input::-webkit-calendar-picker-indicator:hover {
  background-color: rgba(234, 88, 12, 0.1) !important;
  transform: scale(1.15) !important;
}

/* Dark Mode Overrides */
html.dark .premium-date-input {
  background-color: var(--color-surface-container-lowest, #0f1218) !important;
  border-color: rgba(255, 255, 255, 0.12) !important;
  color: var(--color-on-surface, #f8fafc) !important;
  box-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.4) !important;
}

html.dark .premium-date-input:hover:not(:disabled) {
  border-color: var(--loading-spin, #f97316) !important;
  box-shadow: 0 4px 16px -4px rgba(249, 115, 22, 0.3) !important;
}

html.dark .premium-date-input:focus,
html.dark .premium-date-input:focus-visible {
  border-color: var(--loading-spin, #f97316) !important;
  box-shadow: 0 0 0 4px rgba(249, 115, 22, 0.24), 0 4px 16px -4px rgba(249, 115, 22, 0.3) !important;
}

/* Customize calendar icon to white/bright orange in dark mode */
html.dark .premium-date-input::-webkit-calendar-picker-indicator {
  filter: invert(60%) sepia(93%) saturate(1450%) hue-rotate(358deg) brightness(101%) contrast(105%) !important;
}
html.dark .premium-date-input::-webkit-calendar-picker-indicator:hover {
  background-color: rgba(249, 115, 22, 0.15) !important;
}

/* Sidebar footer — LME London metal prices */
.sidebar-lme-widget {
  border-radius: 1rem;
  padding: 0.75rem 0.85rem;
  background: rgba(255, 255, 255, 0.1);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(6px);
}
.sidebar-lme-widget__head {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.55rem;
  color: rgba(255, 255, 255, 0.92);
}
.sidebar-lme-widget__head .material-symbols-outlined {
  font-size: 1.05rem;
  opacity: 0.9;
}
.sidebar-lme-widget__title {
  flex: 1;
  font-size: 0.625rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.sidebar-lme-widget__refresh {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  padding: 0;
  border: none;
  border-radius: 0.45rem;
  background: rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.85);
  cursor: pointer;
}
.sidebar-lme-widget__refresh:hover {
  background: rgba(255, 255, 255, 0.22);
}
.sidebar-lme-widget__refresh .material-symbols-outlined {
  font-size: 0.95rem;
}
.sidebar-lme-widget__row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.35rem 0;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}
.sidebar-lme-widget__row:first-of-type {
  border-top: none;
  padding-top: 0;
}
.sidebar-lme-widget__label {
  font-size: 0.6875rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.78);
  line-height: 1.35;
  padding-top: 0.1rem;
}
.sidebar-lme-widget__values {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.1rem;
  min-width: 0;
  text-align: right;
}
.sidebar-lme-widget__price {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.8125rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #fff;
}
.sidebar-lme-widget__unit {
  margin-left: 0.25rem;
  font-size: 0.5625rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: rgba(255, 255, 255, 0.55);
}
.sidebar-lme-widget__chg {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.625rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.sidebar-lme-widget__chg.is-up {
  color: #6ee7b7;
}
.sidebar-lme-widget__chg.is-down {
  color: #fca5a5;
}
.sidebar-lme-widget__chg.is-flat {
  color: rgba(255, 255, 255, 0.45);
}
.sidebar-footer {
  margin-top: auto;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.sidebar-admin-settings-btn {
  margin-top: 0.15rem;
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(0, 0, 0, 0.12);
  cursor: pointer;
  text-align: left;
}

.sidebar-admin-settings-btn:hover {
  background: rgba(255, 255, 255, 0.12);
}

.sidebar-admin-settings-btn.is-active {
  background: rgba(255, 255, 255, 0.2);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.22);
}

/* Admin sub-sidebar (เด้งออกจาก Settings — ธีมเดียวกับ sidebar หลัก) */
.admin-subsidebar {
  position: fixed;
  top: var(--sidebar-float-gap);
  left: calc(var(--sidebar-rail-offset) + var(--admin-subsidebar-gap));
  z-index: 68;
  display: flex;
  flex-direction: column;
  width: var(--admin-subsidebar-width);
  height: calc(100vh - (var(--sidebar-float-gap) * 2));
  height: calc(100dvh - (var(--sidebar-float-gap) * 2));
  padding: 0.85rem 0.55rem 1rem;
  border-radius: var(--sidebar-float-radius);
  border: 1px solid rgba(255, 255, 255, 0.2);
  background:
    linear-gradient(
      165deg,
      color-mix(in srgb, var(--sidebar-gradient-from) 88%, #ffffff 12%) 0%,
      color-mix(in srgb, var(--sidebar-gradient-from) 72%, var(--sidebar-gradient-to) 28%) 42%,
      color-mix(in srgb, var(--sidebar-gradient-to) 90%, #1e293b 10%) 100%
    );
  color: #fff;
  box-shadow:
    0 22px 50px -18px rgba(15, 23, 42, 0.48),
    inset 0 1px 0 rgba(255, 255, 255, 0.16);
  overflow: hidden;
  transform: translateX(-10px) scale(0.985);
  opacity: 0;
  pointer-events: none;
  transition:
    transform 0.28s cubic-bezier(0.34, 1.2, 0.64, 1),
    opacity 0.22s ease,
    left 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

.admin-subsidebar::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 120% 80% at 0% 0%, rgba(255, 255, 255, 0.14), transparent 55%),
    radial-gradient(ellipse 90% 60% at 100% 100%, rgba(0, 0, 0, 0.12), transparent 58%);
  pointer-events: none;
}

.admin-subsidebar.is-open {
  transform: translateX(0) scale(1);
  opacity: 1;
  pointer-events: auto;
}

@media (min-width: 1024px) {
  .admin-subsidebar.is-open {
    transition:
      transform 0.28s cubic-bezier(0.34, 1.2, 0.64, 1),
      opacity 0.22s ease,
      left 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .sales-app-root.admin-subsidebar-open .sales-app-main {
    transition:
      margin-left 0.26s cubic-bezier(0.4, 0, 0.2, 1),
      width 0.26s cubic-bezier(0.4, 0, 0.2, 1);
  }
}

.admin-subsidebar.hidden {
  display: none !important;
}

.admin-subsidebar__head {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin: 0 0.45rem 0.75rem;
  padding: 0.65rem 0.7rem 0.8rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}

.admin-subsidebar__head-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.9rem;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  font-size: 1.35rem;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2);
}

.admin-subsidebar__head-copy {
  min-width: 0;
}

.admin-subsidebar__eyebrow {
  margin: 0;
  padding: 0;
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.68);
}

.admin-subsidebar__head-title {
  margin: 0.1rem 0 0;
  font-size: 0.9375rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #fff;
}

.admin-subsidebar__nav {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0 0.35rem;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

.admin-subsidebar__link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.68rem 0.8rem;
  border-radius: 0.85rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.8);
  text-decoration: none;
  transition:
    transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1),
    background-color 0.22s cubic-bezier(0.25, 1, 0.5, 1),
    color 0.22s ease,
    box-shadow 0.22s ease;
}

.admin-subsidebar__link .material-symbols-outlined {
  font-size: 1.25rem;
  font-weight: 300;
  color: rgba(255, 255, 255, 0.9);
  opacity: 0.95;
}

.admin-subsidebar__link:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  transform: translateX(3px);
}

.admin-subsidebar__link.is-active {
  background: #fff;
  color: #0e7490;
  font-weight: 700;
  box-shadow: 0 8px 22px -12px rgba(8, 145, 178, 0.55);
  transform: translateX(2px);
}

.admin-subsidebar__link.is-active .material-symbols-outlined {
  color: #0891b2;
}

html.dark .admin-subsidebar {
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow:
    0 24px 56px -20px rgba(0, 0, 0, 0.65),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

html.dark .admin-subsidebar__link.is-active {
  color: #0e7490;
}

.admin-subsidebar-backdrop {
  position: fixed;
  inset: 0;
  z-index: 67;
  background: rgba(15, 23, 42, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.admin-subsidebar-backdrop.is-visible {
  opacity: 1;
  pointer-events: auto;
}

@media (min-width: 1024px) {
  .sales-app-root.admin-subsidebar-open .sales-app-main {
    margin-left: calc(var(--sidebar-rail-offset) + var(--admin-subsidebar-rail));
    width: calc(100% - var(--sidebar-rail-offset) - var(--admin-subsidebar-rail));
  }

  .sales-app-root.sidebar-is-collapsed.admin-subsidebar-open .sales-app-main {
    margin-left: calc(var(--sidebar-rail-offset-collapsed) + var(--admin-subsidebar-rail));
    width: calc(100% - var(--sidebar-rail-offset-collapsed) - var(--admin-subsidebar-rail));
  }

  #app-sidebar.is-collapsed ~ .admin-subsidebar {
    left: calc(var(--sidebar-rail-offset-collapsed) + var(--admin-subsidebar-gap));
  }
}

@media (max-width: 1023px) {
  .admin-subsidebar {
    top: 0;
    left: 0;
    height: 100vh;
    height: 100dvh;
    width: min(var(--admin-subsidebar-width), 88vw);
    border-radius: 0 1.25rem 1.25rem 0;
    z-index: 75;
    box-shadow: 18px 0 48px -12px rgba(15, 23, 42, 0.45);
  }

  .sales-app-root.admin-subsidebar-open .sales-app-main {
    margin-left: 0;
    width: 100%;
  }
}

.sidebar-lme-widget__status {
  margin: 0.45rem 0 0;
  padding-top: 0.45rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.5625rem;
  line-height: 1.35;
  color: rgba(255, 255, 255, 0.52);
}

/* ── Sales Order Pagination ── */
.so-pagination-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.375rem;
  padding: 0.875rem 1rem 1rem;
  border-top: 1px solid var(--outline-variant, #e2e8f0);
}
.so-page-btn {
  min-width: 2rem;
  height: 2rem;
  padding: 0 0.5rem;
  border-radius: 0.5rem;
  border: 1px solid transparent;
  background: transparent;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--on-surface-variant, #64748b);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  line-height: 1;
}
.so-page-btn:hover:not(:disabled):not(.is-active) {
  background: rgba(var(--primary-rgb, 99, 102, 241), 0.08);
  color: var(--primary, #6366f1);
}
.so-page-btn.is-active {
  background: var(--primary, #6366f1);
  color: #fff;
  border-color: var(--primary, #6366f1);
  font-weight: 700;
  pointer-events: none;
}
.so-page-btn:disabled {
  opacity: 0.35;
  cursor: default;
}
.so-page-ellipsis {
  font-size: 0.875rem;
  color: var(--on-surface-variant, #94a3b8);
  padding: 0 0.125rem;
  user-select: none;
}
.so-page-info {
  margin-left: 0.5rem;
  font-size: 0.75rem;
  color: var(--on-surface-variant, #94a3b8);
  white-space: nowrap;
}

/* ── Unified app top bar (sales_dashboard_shell.js) ── */
.app-topbar {
  --app-topbar-accent: #ea580c;
  --app-topbar-accent-soft: #fff7ed;
}

#app-topbar.app-topbar {
  position: sticky;
  top: var(--topbar-float-gap);
  z-index: 55;
  flex-shrink: 0;
  margin: var(--topbar-float-gap) var(--topbar-float-gap) 0;
  width: auto;
  border-radius: var(--topbar-float-radius);
  border: 1px solid color-mix(in srgb, var(--color-outline-variant) 82%, #fed7aa 18%);
  background: color-mix(in srgb, var(--color-surface-bright) 90%, transparent);
  box-shadow: 0 14px 40px -22px rgba(15, 23, 42, 0.22);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

html.dark #app-topbar.app-topbar {
  border-color: color-mix(in srgb, var(--color-outline-variant) 78%, transparent);
  background: color-mix(in srgb, var(--color-surface-bright) 88%, transparent);
  box-shadow: 0 16px 44px -24px rgba(0, 0, 0, 0.55);
}
.app-topbar-eyebrow {
  color: var(--app-topbar-accent);
}
html.dark .app-topbar-eyebrow {
  color: #fb923c;
}
.app-topbar-menu {
  border-color: color-mix(in srgb, var(--app-topbar-accent) 22%, #fed7aa);
  background: var(--app-topbar-accent-soft);
  color: var(--app-topbar-accent);
}
html.dark .app-topbar-menu {
  border-color: var(--color-outline-variant);
  background: var(--color-surface-container-low);
  color: #fb923c;
}
.app-topbar-title-extra {
  margin-top: 0.25rem;
  font-size: 0.75rem;
  line-height: 1.35;
  color: var(--color-on-surface-variant);
}
.app-topbar-center-host--filled {
  width: 100%;
}
.app-topbar-center .flex.w-full.items-center.gap-3.rounded-2xl {
  border-color: color-mix(in srgb, var(--app-topbar-accent) 18%, #fed7aa) !important;
}
.app-topbar-actions:empty {
  display: none;
}
.app-topbar-tools {
  overflow: visible;
}

.app-topbar-tools .auth-session-widget {
  margin-left: 0.125rem;
}

.app-topbar-inner--profile {
  flex-direction: row !important;
  align-items: center !important;
  flex-wrap: nowrap;
  gap: 0.5rem 0.75rem;
}

.app-topbar-inner--profile .app-topbar-brand {
  flex: 1 1 auto;
  min-width: 0;
}

.app-topbar-inner--profile .app-topbar-title {
  font-size: 1.125rem;
  line-height: 1.3;
}

@media (min-width: 640px) {
  .app-topbar-inner--profile .app-topbar-title {
    font-size: 1.25rem;
  }
}

.app-topbar-inner--profile .app-topbar-tools {
  flex: 0 0 auto;
  width: auto;
  max-width: none;
  margin-left: auto;
  justify-content: flex-end;
  flex-wrap: nowrap;
}

body.profile-route .profile-hub-tabs {
  position: relative;
  z-index: 1;
}

body.profile-route .app-topbar,
body.profile-route #app-topbar.app-topbar {
  z-index: 60;
}

/* ══════════════════════════════════════════════════════════════
   Ambient background (เต็มจอ ฟ้า–ส้ม นิ่ง) + การ์ดลอย
   ══════════════════════════════════════════════════════════════ */
.dm-ambient-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.dm-ambient-bg__base {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 110% 90% at 5% -8%, rgba(8, 145, 178, 0.42), transparent 54%),
    radial-gradient(ellipse 100% 80% at 96% 12%, rgba(249, 115, 22, 0.32), transparent 50%),
    radial-gradient(ellipse 85% 70% at 42% 108%, rgba(34, 211, 238, 0.22), transparent 58%),
    linear-gradient(155deg, #e4f7fb 0%, #eef9fb 32%, #fff4e8 68%, #ffe8d4 100%);
}

html.dark .dm-ambient-bg__base {
  background:
    radial-gradient(ellipse 105% 85% at 10% -10%, rgba(34, 211, 238, 0.32), transparent 52%),
    radial-gradient(ellipse 95% 75% at 90% 18%, rgba(251, 146, 60, 0.28), transparent 48%),
    radial-gradient(ellipse 75% 60% at 48% 108%, rgba(8, 145, 178, 0.18), transparent 55%),
    linear-gradient(180deg, #040c12 0%, #071a24 40%, #1a1008 100%);
}

.dm-ambient-bg__ribbons {
  position: absolute;
  inset: -18%;
  overflow: visible;
}

.dm-ribbon-stage {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transform-origin: 50% 52%;
  will-change: transform;
}

.dm-ribbon-stage--a {
  animation: none;
  transform: rotate(38deg) scale(1.08);
}

.dm-ribbon-stage--b {
  opacity: 0.88;
  animation: none;
  transform: rotate(-18deg) scale(1.12);
}

.dm-ribbon-svg {
  width: 135%;
  height: 135%;
  overflow: visible;
}

.dm-ribbon-bundle {
  transform-origin: 50% 50%;
  will-change: transform;
}

.dm-ribbon-bundle--a {
  animation: none;
  transform: translate3d(0, -0.5%, 0) scale(1.015);
}

.dm-ribbon-bundle--b {
  animation: none;
  transform: translate3d(0, 0.5%, 0) scale(1);
}

html.dark .dm-ribbon-bundle path {
  stroke-width: 1.25;
}

@keyframes dmRibbonSpinA {
  0% { transform: rotate(0deg) scale(1.08); }
  100% { transform: rotate(360deg) scale(1.08); }
}

@keyframes dmRibbonSpinB {
  0% { transform: rotate(12deg) scale(1.12); }
  100% { transform: rotate(-348deg) scale(1.12); }
}

@keyframes dmRibbonDriftA {
  0% { transform: translate3d(-3%, 1%, 0) scale(1); }
  100% { transform: translate3d(3%, -2%, 0) scale(1.03); }
}

@keyframes dmRibbonDriftB {
  0% { transform: translate3d(2%, -1%, 0) scale(1.02); }
  100% { transform: translate3d(-2%, 2%, 0) scale(0.98); }
}

.dm-ambient-bg__orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(42px);
  opacity: 0.72;
  transform: translate3d(0, 0, 0);
  will-change: transform;
}

.dm-ambient-bg__orb--a {
  width: min(28rem, 78vw);
  height: min(28rem, 78vw);
  top: -10%;
  left: -8%;
  background: radial-gradient(circle, rgba(8, 145, 178, 0.55), transparent 66%);
  animation: none;
  transform: translate3d(1.25rem, 0.75rem, 0) scale(1.04);
}

.dm-ambient-bg__orb--b {
  width: min(22rem, 62vw);
  height: min(22rem, 62vw);
  top: 28%;
  right: -8%;
  background: radial-gradient(circle, rgba(249, 115, 22, 0.48), transparent 68%);
  animation: none;
  transform: translate3d(-1rem, 1rem, 0) scale(1.03);
}

.dm-ambient-bg__orb--c {
  width: min(20rem, 56vw);
  height: min(20rem, 56vw);
  bottom: 4%;
  left: 18%;
  background: radial-gradient(circle, rgba(34, 211, 238, 0.4), transparent 70%);
  animation: none;
  transform: translate3d(0.75rem, -0.6rem, 0) scale(1.025);
}

.dm-ambient-bg__sparkles {
  position: absolute;
  inset: 0;
  opacity: 0.65;
  background-image:
    radial-gradient(circle, rgba(255, 255, 255, 0.95) 1px, transparent 1px),
    radial-gradient(circle, rgba(34, 211, 238, 0.8) 1.5px, transparent 1.5px),
    radial-gradient(circle, rgba(251, 146, 60, 0.75) 1px, transparent 1px);
  background-size: 140px 140px, 220px 220px, 180px 180px;
  background-position: 0 0, 60px 40px, 30px 90px;
  animation: none;
  transform: translate3d(6px, -4px, 0);
}

html.dark .dm-ambient-bg__sparkles {
  opacity: 0.5;
}

@media (prefers-reduced-motion: reduce) {
  .dm-ribbon-stage,
  .dm-ribbon-bundle,
  .dm-ambient-bg__orb,
  .dm-ambient-bg__sparkles {
    animation: none !important;
  }
}

@keyframes dmAmbientOrbA {
  0% { transform: translate3d(0, 0, 0) scale(1); }
  100% { transform: translate3d(2.5rem, 1.5rem, 0) scale(1.08); }
}

@keyframes dmAmbientOrbB {
  0% { transform: translate3d(0, 0, 0) scale(1); }
  100% { transform: translate3d(-2rem, 2rem, 0) scale(1.06); }
}

@keyframes dmAmbientOrbC {
  0% { transform: translate3d(0, 0, 0) scale(1); }
  100% { transform: translate3d(1.5rem, -1.25rem, 0) scale(1.05); }
}

@keyframes dmAmbientSparkle {
  0% { opacity: 0.45; transform: translate3d(0, 0, 0); }
  100% { opacity: 0.85; transform: translate3d(12px, -8px, 0); }
}

body.dm-ambient-on {
  --dm-float-shadow:
    0 20px 48px -24px rgba(15, 23, 42, 0.22),
    0 8px 22px -12px rgba(8, 145, 178, 0.14);
  --dm-glass-bg: color-mix(in srgb, var(--color-surface-bright) 84%, transparent);
  background: transparent !important;
}

body.dm-ambient-on .sales-app-root,
body.dm-ambient-on .rwd-app {
  position: relative;
  z-index: 1;
}

body.dm-ambient-on .sales-app-main,
body.dm-ambient-on .layout-main,
body.dm-ambient-on.rwd-body {
  background: transparent !important;
}

@media (min-width: 1024px) {
  body.dm-ambient-on .sales-app-main {
    background: transparent !important;
  }
}

body.dm-ambient-on.rwd-body::before,
body.dm-ambient-on.rwd-body::after,
body.dm-ambient-on .rwd-bg-anim {
  display: none !important;
}

body.dm-ambient-on .surface-panel,
body.dm-ambient-on .layout-main > main > section,
body.dm-ambient-on .layout-main > main > article,
body.dm-ambient-on .cockpit-metric-card,
body.dm-ambient-on .cockpit-panel,
body.dm-ambient-on .oms-filter-bar-wrap,
body.dm-ambient-on .rwd-card,
body.dm-ambient-on .rwd-home-card,
body.dm-ambient-on .rwd-kpi-grid > *,
body.dm-ambient-on .rwd-home-banner {
  box-shadow: var(--dm-float-shadow) !important;
}

body.dm-ambient-on .layout-main > main > section,
body.dm-ambient-on .layout-main > main > article {
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

body.dm-ambient-on .layout-main > main > section[class*="bg-white"],
body.dm-ambient-on .layout-main > main > section[class*="from-white"] {
  background: color-mix(in srgb, #ffffff 76%, transparent) !important;
}

html.dark body.dm-ambient-on .layout-main > main > section[class*="dark:from-surface"] {
  background: color-mix(in srgb, var(--color-surface-bright) 88%, transparent) !important;
}

body.dm-ambient-on .cockpit-metric-card,
body.dm-ambient-on .cockpit-panel {
  background: color-mix(in srgb, var(--color-surface-bright) 88%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

body.dm-ambient-on .rwd-card {
  background: color-mix(in srgb, var(--color-surface-bright) 86%, transparent);
}

.sdv-viewer-page .dm-ambient-bg {
  opacity: 0.45;
}

.sdv-viewer-page .dm-ambient-bg__ribbons {
  opacity: 0.55;
}

