<style>
/* ======================================================================
   BASE RESET + BODY
   ====================================================================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background: #0f172a;
  color: #e2e8f0;
  font-family: "Inter", sans-serif;
  overflow-x: hidden;
}

html, body {
  width: 100%;
}

/* ======================================================================
   LAYOUT CHÍNH
   ====================================================================== */
.tms-shell {
  display: flex;
  height: 100vh;
  max-width: 100vw;
  overflow: hidden;
}

/* ======================================================================
   SIDEBAR
   ====================================================================== */
.tms-sidebar {
  width: 260px;
  background: #0b1120;
  border-right: 1px solid #1e293b;
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
}

.tms-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 22px;
}

.tms-logo-mark {
  width: 38px;
  height: 38px;
  background: #1e40af;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-weight: bold;
  font-size: 20px;
}

.tms-logo-text-main {
  font-size: 15px;
  font-weight: 600;
}

.tms-logo-text-sub {
  font-size: 11px;
  opacity: 0.6;
}

/* MENU SIDEBAR */
.tms-sidebar-section-title {
  font-size: 13px;
  margin-bottom: 8px;
  padding-left: 6px;
  opacity: 0.65;
}

.tms-menu {
  list-style: none;
  margin-bottom: 18px;
}

.tms-menu-item {
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  color: #cbd5e1;
}

.tms-menu-item:hover {
  background: #1e293b;
}

.tms-menu-item.active {
  background: #1e40af;
  color: #fff;
}

.tms-menu-item-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.tms-menu-item-icon {
  opacity: 0.85;
}

.tms-menu-badge {
  background: #10b981;
  padding: 2px 6px;
  font-size: 10px;
  border-radius: 4px;
  color: #012b19;
  font-weight: 600;
}

.tms-sidebar-footer {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid #1e293b;
  font-size: 12px;
  opacity: 0.75;
}

.tms-sidebar-footer .label {
  margin-right: 4px;
}

/* ======================================================================
   MAIN CONTENT
   ====================================================================== */
.tms-main {
  flex: 1;
  padding: 14px 18px 18px;
  overflow-y: auto;
  overflow-x: hidden;
}

/* HEADER */
.tms-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  margin-bottom: 16px;
  gap: 8px;
}

.tms-header-title {
  font-size: 22px;
  font-weight: 600;
}

.tms-header-chip {
  background: #1e40af;
  padding: 3px 7px;
  margin-left: 8px;
  border-radius: 6px;
  font-size: 11px;
}

.tms-header-subtitle {
  font-size: 13px;
  opacity: 0.7;
  margin-top: 4px;
}

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

.tms-pill {
  background: #1e293b;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 13px;
}

.tms-select {
  padding: 4px 8px;
  background: #1e293b;
  border: 1px solid #334155;
  color: #e2e8f0;
  border-radius: 6px;
  font-size: 13px;
}

.tms-avatar {
  background: #334155;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* ======================================================================
   KPI ROW – AUTO GRID
   ====================================================================== */
.tms-kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.tms-kpi-card {
  background: #1e293b;
  padding: 14px;
  border-radius: 10px;
  border: 1px solid #334155;
}

.tms-kpi-top {
  display: flex;
  justify-content: space-between;
}

.tms-kpi-label {
  opacity: 0.75;
  font-size: 13px;
}

.tms-kpi-value {
  font-size: 26px;
  margin: 4px 0;
}

.tms-kpi-trend {
  font-size: 12px;
  color: #10b981;
}

.tms-kpi-trend.down {
  color: #ef4444;
}

.tms-kpi-sub {
  opacity: 0.6;
  font-size: 12px;
}

/* ======================================================================
   PANELS
   ====================================================================== */
.tms-panel {
  background: #1e293b;
  border-radius: 10px;
  border: 1px solid #334155;
  margin-bottom: 18px;
}

.tms-panel-header {
  padding: 14px 16px;
  border-bottom: 1px solid #334155;
  display: flex;
  justify-content: space-between;
}

.tms-panel-title {
  font-size: 16px;
  font-weight: 600;
}

.tms-panel-subtitle {
  font-size: 13px;
  opacity: 0.7;
  margin-top: 4px;
}

.tms-panel-body {
  padding: 16px;
}

/* ======================================================================
   2 COLUMN LAYOUT (SLA + HOURLY)
   ====================================================================== */
.tms-section-2col {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1.2fr);
  gap: 16px;
}

/* ======================================================================
   SLA DONUT + LEGEND
   ====================================================================== */
.tms-sla-layout {
  display: flex;
  gap: 20px;
}

.tms-sla-donut {
  width: 180px;
}

.tms-sla-legend {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.tms-sla-legend-item {
  display: flex;
  gap: 10px;
  align-items: center;
}

.tms-sla-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.sla-on-time { background: #10b981; }
.sla-late { background: #ef4444; }
.sla-not-delivered { background: #fbbf24; }

.tms-sla-legend-sub {
  opacity: 0.7;
  font-size: 12px;
}

/* ======================================================================
   TABLES
   ====================================================================== */
.table-wrapper {
  max-height: 240px;
  overflow-y: auto;
  overflow-x: hidden;
}

.tms-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.tms-table th {
  text-align: left;
  padding: 10px;
  background: #0f172a;
  font-size: 12px;
  border-bottom: 1px solid #334155;
}

.tms-table td {
  padding: 8px 10px;
  border-bottom: 1px solid #1e293b;
}

/* ======================================================================
   ALERT LIST
   ====================================================================== */
.tms-alert-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.tms-alert-list li {
  background: #0f172a;
  padding: 10px 12px;
  border-radius: 8px;
  border-left: 4px solid #fbbf24;
}

/* ======================================================================
   FOOTER
   ====================================================================== */
.tms-footer {
  opacity: 0.5;
  font-size: 12px;
  padding: 10px;
  margin-top: 10px;
}

/* ======================================================================
   RESPONSIVE FIXES — 1366px
   ====================================================================== */
@media (max-width: 1366px) {
  .tms-main {
    padding: 10px 12px 14px;
  }

  .tms-section-2col {
    grid-template-columns: 1fr; /* Stack dọc */
  }

  .tms-sla-layout {
    flex-direction: column;
    align-items: center;
  }

  .tms-header-right {
    justify-content: flex-start;
  }
}

/* ======================================================================
   RESPONSIVE — 900px
   ====================================================================== */
@media (max-width: 900px) {
  .tms-kpi-row {
    grid-template-columns: 1fr;
  }

  .tms-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .tms-sla-layout {
    flex-direction: column;
  }

  .tms-section-2col {
    grid-template-columns: 1fr;
  }
}

/* ======================================================================
   LIGHT MODE (kích hoạt bằng class body.tms-light)
   ====================================================================== */

body.tms-light {
  background: #f3f4f6;
  color: #0f172a;
}

/* Sidebar */
body.tms-light .tms-sidebar {
  background: #ffffff;
  border-right: 1px solid #e5e7eb;
}

body.tms-light .tms-logo-mark {
  background: #1d4ed8;
  color: #ffffff;
}

body.tms-light .tms-logo-text-main {
  color: #0f172a;
}

body.tms-light .tms-logo-text-sub {
  color: #6b7280;
}

body.tms-light .tms-sidebar-section-title {
  color: #6b7280;
}

body.tms-light .tms-menu-item {
  color: #111827;
}

body.tms-light .tms-menu-item:hover {
  background: #e5e7eb;
}

body.tms-light .tms-menu-item.active {
  background: #1d4ed8;
  color: #ffffff;
}

body.tms-light .tms-sidebar-footer {
  border-top-color: #e5e7eb;
  color: #6b7280;
}

/* Main background */
body.tms-light .tms-main {
  background: #f3f4f6;
}

/* Header & pill */
body.tms-light .tms-header-title {
  color: #111827;
}

body.tms-light .tms-header-subtitle {
  color: #6b7280;
}

body.tms-light .tms-header-chip {
  background: #e0f2fe;
  color: #0369a1;
}

body.tms-light .tms-pill {
  background: #e5e7eb;
  color: #111827;
}

body.tms-light .tms-select {
  background: #ffffff;
  border-color: #d1d5db;
  color: #111827;
}

body.tms-light .tms-avatar {
  background: #e5e7eb;
  color: #111827;
}

/* KPI card & panel */
body.tms-light .tms-kpi-card,
body.tms-light .tms-panel {
  background: #ffffff;
  border-color: #e5e7eb;
}

body.tms-light .tms-panel-header {
  border-bottom-color: #e5e7eb;
}

body.tms-light .tms-kpi-label {
  color: #6b7280;
}

body.tms-light .tms-kpi-value {
  color: #111827;
}

body.tms-light .tms-kpi-sub {
  color: #6b7280;
}

/* SLAs */
body.tms-light .tms-sla-note {
  color: #6b7280;
}

/* Tables */
body.tms-light .tms-table th {
  background: #f9fafb;
  border-bottom-color: #e5e7eb;
  color: #6b7280;
}

body.tms-light .tms-table td {
  border-bottom-color: #f3f4f6;
  color: #111827;
}

body.tms-light .table-wrapper {
  border-radius: 8px;
}

/* Alert list */
body.tms-light .tms-alert-list li {
  background: #fef9c3;
  border-left-color: #facc15;
  color: #854d0e;
}

/* Footer */
body.tms-light .tms-footer {
  color: #9ca3af;
}

/* Toast */
body.tms-light .tms-toast {
  background: #111827;
  color: #f9fafb;
}

/* ======================================================================
   THEME TOGGLE BUTTON
   ====================================================================== */

.tms-theme-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
}

.tms-theme-toggle:hover {
  filter: brightness(1.05);
}

/* ======================================================================
   VIEW: BẢN ĐỒ CỬA HÀNG
   ====================================================================== */

.tms-map-layout {
  display: grid;
  grid-template-columns: 2fr 1.1fr;
  gap: 16px;
  min-height: 420px;
}

.tms-map-main {
  position: relative;
}

.tms-map-canvas {
  width: 100%;
  height: 100%;
  min-height: 420px;
  border-radius: 10px;
  background: radial-gradient(circle at top, #1e293b 0, #020617 55%);
  border: 1px solid #1f2937;
}

/* Hint overlay trên bản đồ */
.tms-map-hint {
  position: absolute;
  left: 12px;
  bottom: 12px;
  background: rgba(15, 23, 42, 0.85);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
  display: inline-block;
}

/* SIDE PANEL */
.tms-map-sidepanel {
  background: #0f172a;
  border-radius: 10px;
  border: 1px solid #334155;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tms-map-tab-title {
  margin-top: 8px;
  font-size: 12px;
  opacity: 0.65;
}

.tms-map-list {
  max-height: 160px;
  overflow-y: auto;
  border: 1px solid #1f2937;
  border-radius: 6px;
}

.tms-map-store-item {
  padding: 6px 8px;
  border-bottom: 1px solid #1f2937;
  font-size: 12px;
  display: flex;
  justify-content: space-between;
}

.tms-map-store-item:last-child {
  border-bottom: none;
}

.tms-map-store-main {
  display: flex;
  flex-direction: column;
}

.tms-map-store-code {
  font-weight: 600;
}

.tms-map-store-meta {
  font-size: 11px;
  opacity: 0.75;
}

.tms-map-store-action {
  font-size: 11px;
  padding: 3px 6px;
  border-radius: 999px;
  background: #1e40af;
  color: white;
}
/* ==========================================================
   BẢN ĐỒ FULL WIDTH + TOOLBAR TRÊN 1 HÀNG (ĐÃ ĐỒNG NHẤT)
   ========================================================== */

/* Toolbar map: 5 ô fill full chiều ngang, cùng style */
.tms-map-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: #020617;
  border: 1px solid #1f2937;
  border-radius: 8px;
  margin-bottom: 12px;
}

/* Mặc định: các item không bị bóp quá nhỏ */
.tms-map-toolbar > * {
  flex-shrink: 0;
}

/* 1. Client pill – cỡ trung bình */
.tms-map-toolbar .tms-pill:first-child {
  flex: 1.1;
  min-width: 170px;
}

/* 2. Level – hơi nhỏ hơn Client */
.tms-map-toolbar #filterLevel {
  flex: 0.9;
  min-width: 130px;
}

/* 3. Search – 1 trong 2 ô dài nhất */
.tms-map-toolbar #storeMapSearch {
  flex: 2;
  min-width: 260px;
}

/* 4. Dropdown "Cửa hàng chưa có tọa độ" – cũng là ô dài nhất */
.tms-map-toolbar #assignDropdown {
  flex: 2;
  min-width: 260px;
}

/* 5. Nút Gán / Lưu tọa độ – nhỏ nhất */
.tms-map-toolbar #btnAssignSelect {
  flex: 0.7;
  min-width: 110px;
}

/* Giao diện control thống nhất (giống Search) */
.tms-map-toolbar #storeMapSearch,
.tms-map-toolbar #filterLevel,
.tms-map-toolbar .tms-dropdown-btn,
.tms-map-toolbar #btnAssignSelect {
  height: 32px;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid #334155;
  background: #1e293b;
  color: #e5e7eb;
  font-size: 13px;
}

/* Nút Gán / Lưu tọa độ */
.tms-map-toolbar #btnAssignSelect {
  cursor: pointer;
  white-space: nowrap;
}

.tms-map-toolbar #btnAssignSelect:hover {
  background: #111827;
}

/* Map canvas giữ nguyên */
.tms-map-canvas-full {
  width: 100%;
  height: calc(100vh - 225px);
  border-radius: 12px;
  overflow: hidden;          /* để bo góc mà không cắt tile */
  background: #ffffff;       /* nền trắng giống trang test */
  border: 1px solid #1f2937;
  position: relative;
}

/* Light mode */
body.tms-light .tms-map-toolbar {
  background: #ffffff;
  border-color: #d1d5db;
}

body.tms-light .tms-map-toolbar #storeMapSearch,
body.tms-light .tms-map-toolbar #filterLevel,
body.tms-light .tms-map-toolbar .tms-dropdown-btn,
body.tms-light .tms-map-toolbar #btnAssignSelect {
  background: #ffffff;
  color: #111827;
  border-color: #d1d5db;
}

body.tms-light .tms-map-toolbar #btnAssignSelect:hover {
  background: #e5e7eb;
}

body.tms-light .tms-map-canvas-full {
  background: #e5e7eb;
  border-color: #cbd5e1;
}

body.tms-light .tms-map-hint {
  background: rgba(243, 244, 246, 0.95);
  color: #111827;
}

/* LEGEND MAP */
.map-legend {
  position: absolute;
  top: 12px;
  left: 12px;
  background: #fff;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 12px;
  color: #000;
  box-shadow: 0 1px 4px rgba(0,0,0,.2);
  z-index: 9999;
}

.map-legend div {
  display: flex;
  align-items: center;
  gap: 6px;
}

.dot {
  width: 10px;
  height: 16px;
  border-radius: 5px;
  display: inline-block;
}

.dot-lv1 { background: #e74c3c; }
.dot-lv2 { background: #f1c40f; }
.dot-lv3 { background: #2ecc71; }

/* Fix ô vuông trên bản đồ Leaflet */
.leaflet-tile {
  image-rendering: auto !important;
  image-rendering: crisp-edges !important;
  image-rendering: -webkit-optimize-contrast !important;
  background: none !important;
}

/* Gộp 2 định nghĩa .leaflet-container thành 1 */
.leaflet-container {
  background: #ffffff !important;
}

.tms-select-sm {
  height: 30px;
  padding: 4px 8px;
  font-size: 12px;
}

/* ======================================================================
   DROPDOWN CHỌN STORE (dark mode giống Search)
   ====================================================================== */

.tms-dropdown {
  position: relative;
  width: 100%;
}

/* Nút mở dropdown: nền & chữ giống ô Search */
.tms-dropdown-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #1e293b;
  border: 1px solid var(--tms-border, #334155);
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: #e5e7eb;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Menu dropdown */
.tms-dropdown-menu {
  position: absolute;
  top: 105%;
  left: 0;
  width: 100%;
  background: #020617;
  border: 1px solid var(--tms-border, #1f2937);
  border-radius: 6px;
  padding: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  display: none;
  z-index: 9999;
}

.tms-dropdown-menu.open {
  display: block;
}

/* Ô search nhỏ bên trong dropdown */
.tms-dropdown-search {
  width: 100%;
  padding: 5px 8px;
  border-radius: 4px;
  border: 1px solid var(--tms-border, #334155);
  background: #020617;
  color: #e5e7eb;
  font-size: 12px;
  margin-bottom: 6px;
}

/* List cửa hàng: max ~10 dòng → scroll */
.tms-dropdown-list {
  max-height: 240px;   /* ~10 item, dư thì scroll */
  overflow-y: auto;
}

/* Từng cửa hàng trong danh sách: nền đen, chữ trắng */
.tms-dropdown-item {
  padding: 5px 8px;
  cursor: pointer;
  border-radius: 4px;
  font-size: 12px;
  color: #e5e7eb;
  background: #020617;
}

.tms-dropdown-item:hover {
  background: #1e293b;
}

/* Button assign – fallback nếu dùng ngoài toolbar */
#btnAssignSelect {
  height: 32px;
  padding: 4px 10px;
  font-size: 12px;
  flex-shrink: 0;
}

/* Input tìm kiếm to hơn chút cho dễ gõ (giữa toolbar map) */
.tms-input-lg {
  flex: 1;
  min-width: 220px;
  max-width: 380px;
  height: 32px;
  padding: 6px 10px;
  font-size: 13px;
}

/* Light mode cho dropdown */
body.tms-light .tms-dropdown-btn {
  background: #ffffff;
  color: #111827;
  border-color: #d1d5db;
}

body.tms-light .tms-dropdown-menu {
  background: #ffffff;
  border-color: #d1d5db;
  box-shadow: 0 2px 8px rgba(15,23,42,0.15);
}

body.tms-light .tms-dropdown-search {
  background: #ffffff;
  color: #111827;
  border-color: #d1d5db;
}

body.tms-light .tms-dropdown-item {
  background: #ffffff;
  color: #111827;
}

body.tms-light .tms-dropdown-item:hover {
  background: #e5e7eb;
}
/* Label Hoàng Sa – Trường Sa kiểu OpenStreetMap */
.sea-island-label {
  color: #555555;                    /* Xám đậm giống OSM */
  font-family: "Noto Sans", sans-serif;
  font-size: 12px;                   /* Chuẩn OSM size */
  font-weight: 400;                  /* Không đậm */
  opacity: 0.85;                     /* OSM hơi mờ */
  text-shadow: 0 0 2px rgba(255,255,255,0.6);
  white-space: nowrap;
  pointer-events: none;              /* Không cho click */
}

/* Căn giữa marker */
.sea-island-label--hoangsa,
.sea-island-label--truongsa {
  transform: translate(-50%, -50%);
}

/* Light mode vẫn giữ nguyên vì OSM cũng dùng màu xám cho light mode */
body.tms-light .sea-island-label {
  color: #555555;
  opacity: 0.9;
}
/* Wrapper bảng dữ liệu dùng chung với panel */
.tms-datatable-wrapper {
  display: flex;
  flex-direction: column;
}

/* Khung cuộn cho bảng dữ liệu – chiều cao tương đương map */
.tms-datatable-scroll {
  flex: 1;
  overflow: auto;
  max-height: 560px; /* Crixus có thể chỉnh lên/xuống để khớp map */
  border-radius: 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(15, 23, 42, 0.85);
}

/* Table cho bảng dữ liệu */
.tms-data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12px;
  line-height: 1.4;
}

.tms-data-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: rgba(15, 23, 42, 0.98);
  backdrop-filter: blur(8px);
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.3);
  white-space: nowrap;
}

.tms-data-table tbody td {
  padding: 6px 10px;
  border-bottom: 1px solid rgba(30, 41, 59, 0.8);
  white-space: nowrap;
  color: rgba(226, 232, 240, 0.95); /* sáng hơn nền một chút */
  font-size: 12px;
}

/* Hàng rỗng */
.tms-table-empty {
  text-align: center;
  padding: 16px;
  color: rgba(148, 163, 184, 0.9);
}

/* Phần header nhỏ bên trên bảng dữ liệu */
.tms-panel-title-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tms-panel-subtitle {
  font-size: 12px;
  color: rgba(148, 163, 184, 0.9);
}

/* Nhóm nút trên toolbar bảng dữ liệu */
.tms-panel-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Input group thu nhỏ cho search */
.tms-input-group-sm .tms-input {
  padding: 4px 8px;
  font-size: 12px;
}

.tms-input-group-sm .tms-btn {
  padding: 4px 8px;
  font-size: 12px;
}

/* Light theme override nếu có chế độ sáng */
body.tms-light .tms-datatable-scroll {
  background: #ffffff;
  border-color: rgba(15, 23, 42, 0.08);
}

body.tms-light .tms-data-table thead th {
  background: #f8fafc;
  border-bottom-color: rgba(148, 163, 184, 0.4);
}

body.tms-light .tms-data-table tbody td {
  color: #0f172a;
}


</style>
