/* Author: nintech-sudo
   Project: Mail Proxy Gateway (MPGW)
   Custom CSS: Font Be Vietnam Pro + Icon to rõ nét + Header tables thường + Chữ nhỏ nhất 13px */

@import url('https://fonts.googleapis.com/css2?family=Be+Vietnam+Pro:ital,wght@0,300;0,400;0,500;0,600;0,700;1,400;1,600&display=swap');

:root {
  --tblr-font-sans-serif: 'Be Vietnam Pro', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --tblr-primary: #f59f00;
  --tblr-primary-rgb: 245, 159, 0;
  --tblr-orange: #f59f00;
}

/* Quy định cỡ chữ toàn trang - chữ nhỏ nhất là 13px */
html,
body {
  font-family: var(--tblr-font-sans-serif);
  font-size: 14px;
  letter-spacing: -0.01em;
  background-color: #f6f8fb;
  color: #1e293b;
  -webkit-font-smoothing: antialiased;
}

/* Đảm bảo không có chữ nào nhỏ hơn 13px */
small,
.small,
.form-text,
.text-muted.small,
.stat-card-title,
.hr-text,
.page-pretitle,
.badge,
.btn-sm,
.form-control-sm,
.form-select-sm {
  font-size: 13px !important;
}

/* ==========================================================================
   Toast Notifications: Nằm dưới thanh top header bar
   ========================================================================== */
#mgwui-toasts,
.toast-container {
  top: 70px !important;
  right: 24px !important;
  z-index: 1080 !important;
}

.toast {
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(8px);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.12), 0 8px 10px -6px rgba(0, 0, 0, 0.08);
  border-radius: 8px;
  border: 1px solid #e9ecef;
}

/* ==========================================================================
   Icon Sizing: Đảm bảo toàn bộ icon Tabler to rõ nét, cân đối, không bị nhỏ
   ========================================================================== */
.ti,
[class^="ti-"],
[class*=" ti-"] {
  font-size: 1.18rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: -0.125em;
}

/* Icon trong menu Sidebar */
.navbar-vertical .nav-link-icon,
.navbar-vertical .nav-link-icon .ti {
  font-size: 1.35rem !important;
  width: 1.35rem;
  height: 1.35rem;
  margin-right: 0.75rem;
}

/* Icon trong Card Header & Tiêu đề */
.card-title .ti,
.card-header .ti {
  font-size: 1.3rem !important;
}

/* Icon trong ô nhập liệu Input */
.input-icon-addon .ti {
  font-size: 1.25rem !important;
  color: #64748b;
}

/* Icon trong nút bấm (Button) */
.btn .ti {
  font-size: 1.15rem !important;
}

/* Icon trong các nút thao tác bảng (Sync, Edit, Delete, View) */
.btn-group .btn .ti,
.btn-sync .ti,
.btn-edit .ti,
.btn-del .ti,
.btn-view .ti,
.btn-cancel .ti {
  font-size: 1.2rem !important;
}

.btn-group-sm>.btn,
.btn-sm {
  padding: 0.35rem 0.65rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Icon trong Badge */
.badge .ti {
  font-size: 1.05rem !important;
  margin-right: 0.25rem;
}

/* Brand logo icon */
.brand-icon-box .ti {
  font-size: 1.5rem !important;
}

/* ==========================================================================
   Light Sidebar & Navigation
   ========================================================================== */
.navbar-vertical.navbar-light,
.navbar-vertical[data-bs-theme="light"] {
  background-color: #ffffff !important;
  border-right: 1px solid #e9ecef;
}

.navbar-vertical .navbar-brand {
  border-bottom: 1px solid #f1f3f5;
}

.navbar-vertical .nav-link {
  color: #64748b;
  font-size: 14px;
  font-weight: 500;
  border-radius: 8px;
  margin: 3px 10px;
  padding: 0.6rem 0.85rem;
  transition: all 0.15s ease-in-out;
  display: flex;
  align-items: center;
}

.navbar-vertical .nav-link:hover {
  color: #0f172a;
  background-color: #f8fafc;
}

.navbar-vertical .nav-item.active>.nav-link,
.navbar-vertical .nav-link.active {
  color: #f59f00 !important;
  background-color: rgba(245, 159, 0, 0.1) !important;
  font-weight: 600;
  border-left: 3px solid #f59f00;
  border-radius: 0 8px 8px 0;
}

.top-navbar {
  backdrop-filter: blur(8px);
  background-color: rgba(255, 255, 255, 0.98) !important;
  min-height: 56px;
  border-bottom: 1px solid #eef2f6;
}

/* ==========================================================================
   Typography & Monospace
   ========================================================================== */
.mono,
.font-monospace {
  font-family: 'Be Vietnam Pro', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13.5px;
  letter-spacing: -0.01em;
}

/* ==========================================================================
   Cards & Aesthetics
   ========================================================================== */
.card {
  border: 1px solid #e9ecef;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.04), 0 1px 2px 0 rgba(0, 0, 0, 0.02);
  border-radius: 8px;
  background-color: #ffffff;
  transition: box-shadow 0.2s ease;
}

.card:hover {
  box-shadow: 0 4px 12px 0 rgba(0, 0, 0, 0.05);
}

.card-header {
  border-bottom: 1px solid #f1f3f5;
  background-color: transparent;
  padding: 0.85rem 1.25rem;
}

.card-title {
  font-size: 14.5px;
  font-weight: 600;
  color: #1e293b;
}

/* ==========================================================================
   Button Styling: Tinh tế, sang trọng, Soft/Light Tint (Không tô màu đặc full)
   ========================================================================== */
.btn {
  font-weight: 500;
  border-radius: 6px;
  transition: all 0.15s ease-in-out;
}

/* Orange Theme Action Button (Soft Tint) */
.btn-orange,
.btn-primary {
  background-color: rgba(245, 159, 0, 0.1) !important;
  border-color: rgba(245, 159, 0, 0.35) !important;
  color: #d97706 !important;
  font-weight: 600;
  box-shadow: none;
}

.btn-orange:hover,
.btn-primary:hover {
  background-color: rgba(245, 159, 0, 0.2) !important;
  border-color: rgba(245, 159, 0, 0.6) !important;
  color: #b45309 !important;
  box-shadow: 0 2px 6px rgba(245, 159, 0, 0.15);
}

.btn-orange:active,
.btn-primary:active {
  background-color: rgba(245, 159, 0, 0.25) !important;
}

/* Outline Secondary / Neutral Buttons */
.btn-outline-secondary {
  background-color: #ffffff;
  border-color: #e2e8f0;
  color: #475569;
}

.btn-outline-secondary:hover {
  background-color: #f8fafc;
  border-color: #cbd5e1;
  color: #1e293b;
}

.btn-outline-primary {
  background-color: rgba(245, 159, 0, 0.05);
  border-color: rgba(245, 159, 0, 0.3);
  color: #d97706;
}

.btn-outline-primary:hover {
  background-color: rgba(245, 159, 0, 0.15);
  border-color: rgba(245, 159, 0, 0.5);
  color: #b45309;
}

/* Table Action Buttons (Soft Tint, tách rời thanh lịch) */
button.btn-sync {
  background-color: #f0fdf4 !important;
  border: 1px solid #bbf7d0 !important;
  color: #16a34a !important;
  border-radius: 6px !important;
  margin-right: 4px;
}

button.btn-sync:hover {
  background-color: #dcfce7 !important;
  border-color: #86efac !important;
  color: #15803d !important;
}

button.btn-edit {
  background-color: #f8fafc !important;
  border: 1px solid #e2e8f0 !important;
  color: #475569 !important;
  border-radius: 6px !important;
  margin-right: 4px;
}

button.btn-edit:hover {
  background-color: #f1f5f9 !important;
  border-color: #cbd5e1 !important;
  color: #1e293b !important;
}

button.btn-del {
  background-color: #fef2f2 !important;
  border: 1px solid #fecaca !important;
  color: #dc2626 !important;
  border-radius: 6px !important;
}

button.btn-del:hover {
  background-color: #fee2e2 !important;
  border-color: #fca5a5 !important;
  color: #b91c1c !important;
}

.btn-view-error {
  background-color: #fff1f2 !important;
  border: 1px solid #fecdd3 !important;
  color: #e11d48 !important;
  font-weight: 600;
  border-radius: 6px;
}

.btn-view-error:hover {
  background-color: #ffe4e6 !important;
  border-color: #fda4af !important;
  color: #be123c !important;
}

/* Hero Welcome Banner (Welcome back style) */
.card-welcome-hero {
  background: #ffffff;
  border: 1px solid #e9ecef;
  position: relative;
  overflow: hidden;
}

.welcome-metric-item {
  position: relative;
}

.welcome-metric-line {
  height: 3px;
  border-radius: 2px;
  margin-top: 6px;
}

.welcome-metric-line.green {
  background-color: #2fb344;
  width: 60px;
}

.welcome-metric-line.red {
  background-color: #d63939;
  width: 60px;
}

/* Stat Cards */
.stat-card-title {
  font-size: 13px !important;
  font-weight: 600;
  color: #64748b;
  text-transform: none;
  /* Không viết hoa toàn bộ */
  letter-spacing: normal;
}

.stat-card-value {
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.1;
  color: #1e293b;
}

.trend-badge-green {
  color: #2fb344;
  font-size: 13px;
  font-weight: 600;
}

.trend-badge-red {
  color: #d63939;
  font-size: 13px;
  font-weight: 600;
}

.trend-badge-orange {
  color: #f59f00;
  font-size: 13px;
  font-weight: 600;
}

/* Sparklines (SVG Charts) */
.sparkline-box {
  height: 44px;
  width: 100%;
}

.sparkline-svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

/* Radial Gauge / Semi-circle */
.radial-progress-box {
  position: relative;
  width: 140px;
  height: 100px;
  margin: 0 auto;
}

.radial-progress-svg {
  width: 140px;
  height: 100px;
}

.radial-gauge-bg {
  fill: none;
  stroke: #e9ecef;
  stroke-width: 12;
}

.radial-gauge-bar {
  fill: none;
  stroke: #f59f00;
  stroke-width: 12;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.8s ease-in-out;
}

.radial-gauge-val {
  font-size: 1.45rem;
  font-weight: 700;
  color: #1e293b;
  position: absolute;
  top: 48px;
  left: 50%;
  transform: translateX(-50%);
}

/* 4 Mini Colored Square Cards */
.mini-stat-card {
  border-radius: 8px;
  padding: 0.85rem 1rem;
}

.mini-icon-square {
  width: 38px;
  height: 38px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  font-weight: 700;
  color: #ffffff;
}

.bg-mini-orange {
  background-color: #f59f00;
}

.bg-mini-green {
  background-color: #2fb344;
}

.bg-mini-black {
  background-color: #000000;
}

.bg-mini-blue {
  background-color: #1877f2;
}

/* ==========================================================================
   Table & Badges (Header tables KHÔNG viết hoa toàn bộ)
   ========================================================================== */
.card-table thead th,
table thead th,
.table thead th {
  background: #f8fafc;
  color: #475569;
  font-size: 13px !important;
  font-weight: 600;
  text-transform: none !important;
  /* Không viết hoa toàn bộ theo yêu cầu */
  letter-spacing: normal !important;
  border-bottom: 1px solid #e9ecef;
  padding: 0.65rem 0.85rem;
}

.card-table tbody td,
table tbody td,
.table tbody td {
  padding: 0.65rem 0.85rem;
  vertical-align: middle;
  border-bottom: 1px solid #f1f3f5;
  font-size: 13.5px;
}

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

/* Fix table overflow & card container sizing */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.card {
  overflow: hidden;
}

.card .table-responsive {
  overflow-x: auto;
  min-height: 180px;
}

/* Bảng co giãn thông minh gói gọn 100% trong khung hình (Không gây scroll ngang) */
.table-fit-screen {
  table-layout: fixed !important;
  width: 100% !important;
}

.table-fit-screen th,
.table-fit-screen td,
.card-table th,
.card-table td {
  word-break: break-word;
  overflow-wrap: anywhere;
  white-space: normal;
}

/* Giữ cố định kích thước cho các thành phần không bị vỡ dòng quá đà */
.table-fit-screen .no-wrap,
.table-fit-screen .badge,
.table-fit-screen .btn,
.table-fit-screen .btn-group,
.table-fit-screen .status-dot,
.table-fit-screen .bulk-chk-col,
.table-fit-screen .dropdown,
.card-table .no-wrap,
.card-table .badge,
.card-table .btn,
.card-table .btn-group,
.card-table .status-dot,
.card-table .bulk-chk-col,
.card-table .dropdown {
  white-space: nowrap !important;
}

.card-table .dropdown-menu,
.table .dropdown-menu {
  z-index: 1060 !important;
}

/* Allow text selection, hover, and copy across the entire application */
body,
table,
thead,
tbody,
tr,
th,
td,
span,
div,
p,
a,
label,
strong,
b,
code,
pre,
.badge,
.mono,
.font-monospace,
.card,
.card-header,
.card-body,
.card-title,
.table-responsive {
  -webkit-user-select: text !important;
  -moz-user-select: text !important;
  -ms-user-select: text !important;
  user-select: text !important;
}

.cursor-pointer,
.user-sortable-col,
.email-sortable-col {
  cursor: pointer;
}

.badge {
  font-size: 13px !important;
  font-weight: 500;
  padding: 0.3em 0.65em;
  border-radius: 4px;
}

.badge-route-stalwart,
.badge-route-proxy {
  background: #f59f00;
  color: #ffffff;
  font-weight: 600;
  font-size: 13px !important;
  padding: 0.3em 0.65em;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
}

.badge-route-cpanel {
  background: #206bc4;
  color: #ffffff;
  font-weight: 600;
  font-size: 13px !important;
  padding: 0.3em 0.65em;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
}

/* Inline Bulk Action Bar (Positioned below top controls & filters) */
.bulk-bar {
  position: relative !important;
  z-index: 10 !important;
  background: rgba(245, 159, 0, 0.07) !important;
  color: #1e293b !important;
  border-top: 1px solid #e2e8f0 !important;
  border-bottom: 1px solid #e2e8f0 !important;
  border-radius: 0 !important;
  padding: 0.5rem 1.25rem !important;
  white-space: nowrap !important;
  box-shadow: none !important;
  animation: fadeIn 0.15s ease-in-out !important;
}

body.theme-dark .bulk-bar {
  background: rgba(245, 159, 0, 0.12) !important;
  border-color: #334155 !important;
  color: #f8fafc !important;
}

/* ==========================================================================
   Console & Code Editor
   ========================================================================== */
.log-console {
  background: #0f172a;
  color: #e2e8f0;
  font-family: 'Be Vietnam Pro', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.6;
  border-radius: 8px;
  padding: 1rem 1.25rem;
  max-height: 440px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  border: 1px solid #1e293b;
}

.log-console .log-line {
  display: block;
}

.log-console .log-line.err {
  color: #f87171;
  font-weight: 600;
}

.log-console .log-line.ok {
  color: #4ade80;
}

.log-console .log-line.warn {
  color: #fbbf24;
}

.log-console .log-line.info {
  color: #38bdf8;
}

.code-editor {
  font-family: 'Be Vietnam Pro', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13.5px;
  line-height: 1.5;
  min-height: 440px;
  background: #fafbfc;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 0.85rem 1rem;
}

.code-editor:focus {
  background: #ffffff;
  border-color: #f59f00;
  box-shadow: 0 0 0 3px rgba(245, 159, 0, 0.15);
}

/* ==========================================================================
   Dark Mode Support
   ========================================================================== */
body.theme-dark {
  background-color: #0b1320;
  color: #f1f5f9;
}

body.theme-dark .navbar-vertical {
  background-color: #141f32 !important;
  border-right-color: #1e2d42;
}

body.theme-dark .top-navbar {
  background-color: rgba(15, 23, 42, 0.95) !important;
  border-bottom-color: #1e293b;
}

body.theme-dark .card {
  background-color: #141f32;
  border-color: #1e2d42;
}

body.theme-dark .card-welcome-hero {
  background: #141f32;
  border-color: #1e2d42;
}

body.theme-dark .card-title,
body.theme-dark .stat-card-value,
body.theme-dark .radial-gauge-val,
body.theme-dark .page-title {
  color: #f8fafc;
}

body.theme-dark .card-header {
  border-bottom-color: #1e2d42;
}

body.theme-dark .card-table thead th {
  background: #0f172a;
  color: #94a3b8;
  border-bottom-color: #1e2d42;
}

body.theme-dark .card-table tbody td {
  border-bottom-color: #1a273b;
  color: #cbd5e1;
}

body.theme-dark .table-hover tbody tr:hover {
  background-color: #172338;
}

body.theme-dark .radial-gauge-bg {
  stroke: #1e2d42;
}

body.theme-dark .code-editor {
  background: #0f172a;
  color: #e2e8f0;
  border-color: #1e2d42;
}

/* Hide dropdown arrow caret on Action buttons */
.dropdown-toggle-no-caret::after,
.no-caret::after {
  display: none !important;
}

/* ==========================================================================
   Tabler Custom Interactive Light Mode Tooltips (Copyable text)
   ========================================================================== */
.tooltip {
  z-index: 1090 !important;
  pointer-events: auto !important;
}

.tooltip .tooltip-inner {
  max-width: 600px !important;
  background-color: #ffffff !important;
  color: #0f172a !important;
  box-shadow: 0 10px 30px -5px rgba(15, 23, 42, 0.18), 0 0 0 1px rgba(0, 0, 0, 0.08) !important;
  border: 1px solid #cbd5e1 !important;
  border-radius: 6px !important;
  font-family: var(--tblr-font-sans-serif, sans-serif) !important;
  font-size: 12.5px !important;
  font-weight: 500 !important;
  padding: 8px 14px !important;
  line-height: 1.5 !important;
  text-align: left !important;
  white-space: normal !important;
  -webkit-user-select: text !important;
  -moz-user-select: text !important;
  -ms-user-select: text !important;
  user-select: text !important;
  cursor: text !important;
}

.tooltip.bs-tooltip-top .tooltip-arrow::before {
  border-top-color: #cbd5e1 !important;
}

.tooltip.bs-tooltip-bottom .tooltip-arrow::before {
  border-bottom-color: #cbd5e1 !important;
}

.tooltip.bs-tooltip-start .tooltip-arrow::before {
  border-left-color: #cbd5e1 !important;
}

.tooltip.bs-tooltip-end .tooltip-arrow::before {
  border-right-color: #cbd5e1 !important;
}

body.theme-dark .tooltip .tooltip-inner {
  background-color: #1e293b !important;
  color: #f1f5f9 !important;
  border-color: #334155 !important;
  box-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.5) !important;
}

body.theme-dark .tooltip.bs-tooltip-top .tooltip-arrow::before {
  border-top-color: #334155 !important;
}

body.theme-dark .tooltip.bs-tooltip-bottom .tooltip-arrow::before {
  border-bottom-color: #334155 !important;
}

/* ==========================================================================
   Proxy Routing Specific UI Components & Polish
   ========================================================================== */
.traffic-pills-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 3px 0;
}

.traffic-pill-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.traffic-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 8px;
  font-size: 12px !important;
  font-family: inherit;
  border: 1px solid transparent;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
  min-width: 175px;
  max-width: 235px;
}

.traffic-pill strong {
  font-family: var(--tblr-font-monospace, monospace);
  letter-spacing: -0.2px;
}

.traffic-pill.imap.active-glow {
  background-color: rgba(32, 107, 196, 0.12);
  color: #1d61b3;
  border-color: rgba(32, 107, 196, 0.28);
  box-shadow: 0 1px 3px rgba(32, 107, 196, 0.12);
}

.traffic-pill.pop3.active-glow {
  background-color: rgba(66, 153, 225, 0.12);
  color: #2b6cb0;
  border-color: rgba(66, 153, 225, 0.28);
  box-shadow: 0 1px 3px rgba(66, 153, 225, 0.12);
}

.traffic-pill.smtp.active-glow {
  background-color: rgba(247, 103, 7, 0.12);
  color: #c93b00;
  border-color: rgba(247, 103, 7, 0.28);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(247, 103, 7, 0.14);
}

.traffic-pill.jmap.active-glow {
  background-color: rgba(174, 62, 201, 0.12);
  color: #862e9c;
  border-color: rgba(174, 62, 201, 0.28);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(174, 62, 201, 0.14);
}

.traffic-pill.inactive {
  background-color: #f8fafc;
  color: #94a3b8;
  border-color: #e2e8f0;
  opacity: 0.75;
}

.traffic-pill.inactive:hover {
  opacity: 1;
}

.traffic-pill:hover {
  transform: translateY(-1px);
}

.badge-route-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 8px;
  font-family: var(--tblr-font-monospace, monospace);
  font-size: 12.5px !important;
  font-weight: 600;
  background-color: #f0f7ff;
  color: #0054a6;
  border: 1px solid #c0dfff;
  box-shadow: 0 1px 2px rgba(0, 84, 166, 0.06);
  transition: all 0.2s ease;
}

.badge-route-pill:hover {
  background-color: #e2f1ff;
  border-color: #a0d1ff;
  box-shadow: 0 2px 5px rgba(0, 84, 166, 0.12);
}

.badge-route-pill .ti {
  color: #0070e0;
}

.avatar-email {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}

.avatar-email.routed {
  background-color: #e6fcf5;
  color: #0ca678;
  border: 1px solid #b7f4de;
}

.avatar-email.unrouted {
  background-color: #f8fafc;
  color: #64748b;
  border: 1px solid #e2e8f0;
}

.sortable-col:hover {
  background-color: rgba(0, 0, 0, 0.02);
}

.sortable-col:hover .sort-icon {
  color: #f59f00 !important;
}

.table-routing tbody tr:hover {
  background-color: #f8fafc !important;
}

/* ==========================================================================
   Interactive KPI Cards & Chart Polish
   ========================================================================== */
.kpi-clickable-card {
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  overflow: hidden;
}

.kpi-clickable-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.07), 0 2px 6px rgba(0, 0, 0, 0.04) !important;
  border-color: #cbd5e1 !important;
}

.kpi-clickable-card .card-click-hint {
  opacity: 0;
  transform: translateX(4px);
  transition: all 0.2s ease;
}

.kpi-clickable-card:hover .card-click-hint {
  opacity: 1;
  transform: translateX(0);
}

.chart-bar-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chart-bar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.chart-bar-track {
  flex: 1;
  height: 10px;
  background-color: #f1f5f9;
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}

.chart-bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.5s ease;
}

body.theme-dark .kpi-clickable-card:hover {
  background-color: #1e293b;
  border-color: #334155 !important;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3) !important;
}

body.theme-dark .chart-bar-track {
  background-color: #1e293b;
}

body.theme-dark .traffic-pill.imap {
  background-color: rgba(32, 107, 196, 0.2);
  color: #90cdf4;
  border-color: rgba(32, 107, 196, 0.3);
}

body.theme-dark .traffic-pill.pop3 {
  background-color: rgba(66, 153, 225, 0.2);
  color: #bee3f8;
  border-color: rgba(66, 153, 225, 0.3);
}

body.theme-dark .traffic-pill.smtp {
  background-color: rgba(247, 103, 7, 0.2);
  color: #fbd38d;
  border-color: rgba(247, 103, 7, 0.3);
}

body.theme-dark .traffic-pill.inactive {
  background-color: #1e293b;
  color: #64748b;
  border-color: #334155;
}

body.theme-dark .badge-route-pill {
  background-color: rgba(32, 107, 196, 0.25);
  color: #90cdf4;
  border-color: rgba(32, 107, 196, 0.4);
}

body.theme-dark .avatar-email.routed {
  background-color: rgba(12, 166, 120, 0.2);
  color: #6ee7b7;
  border-color: rgba(12, 166, 120, 0.35);
}

body.theme-dark .avatar-email.unrouted {
  background-color: #1e293b;
  color: #94a3b8;
  border-color: #334155;
}

/* ==========================================================================
   Modern Segmented Filter Tabs & Form Controls
   ========================================================================== */
.segmented-tabs-wrapper {
  display: inline-flex;
  background-color: #f1f5f9;
  padding: 3px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
}

.segmented-tab-btn {
  border: none !important;
  background: transparent !important;
  padding: 5px 14px !important;
  border-radius: 6px !important;
  font-size: 13px !important;
  font-weight: 500 !important;
  color: #64748b !important;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  outline: none !important;
  box-shadow: none !important;
}

.segmented-tab-btn:hover {
  color: #0f172a !important;
  background-color: rgba(255, 255, 255, 0.6) !important;
}

.segmented-tab-btn.active {
  background-color: #ffffff !important;
  color: #0f172a !important;
  font-weight: 600 !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04) !important;
}

.segmented-tab-btn .badge {
  font-size: 11.5px !important;
  padding: 2px 7px !important;
  border-radius: 12px !important;
  font-weight: 600;
}

body.theme-dark .segmented-tabs-wrapper {
  background-color: #1e293b;
  border-color: #334155;
}

body.theme-dark .segmented-tab-btn {
  color: #94a3b8 !important;
}

body.theme-dark .segmented-tab-btn:hover {
  color: #f8fafc !important;
  background-color: rgba(255, 255, 255, 0.08) !important;
}

body.theme-dark .segmented-tab-btn.active {
  background-color: #0f172a !important;
  color: #f8fafc !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4) !important;
}

/* ==========================================================================
   Tabler Input Icon & Search Bar Polish
   ========================================================================== */
.input-icon {
  position: relative;
  width: 100%;
}

.input-icon .form-control {
  padding-left: 2.75rem !important;
  padding-right: 2rem !important;
  min-height: 38px;
  font-size: 13.5px;
  border-radius: 6px;
  border: 1px solid #e2e8f0;
  background-color: #ffffff;
  transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.input-icon .form-control:focus {
  border-color: #206bc4 !important;
  box-shadow: 0 0 0 0.2rem rgba(32, 107, 196, 0.15) !important;
}

.input-icon .input-icon-addon {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 2.75rem;
  color: #94a3b8;
  pointer-events: none;
  z-index: 2;
}

.input-icon .input-icon-addon .ti {
  font-size: 1.25rem !important;
}

.input-icon .input-icon-addon.end {
  left: auto;
  right: 0;
  min-width: 2.5rem;
  pointer-events: auto;
  cursor: pointer;
}

.input-icon .input-icon-addon.end:hover .ti {
  color: #ef4444;
}

body.theme-dark .input-icon .form-control {
  background-color: #141f32;
  border-color: #1e2d42;
  color: #f8fafc;
}

body.theme-dark .input-icon .form-control:focus {
  border-color: #3b82f6 !important;
  box-shadow: 0 0 0 0.2rem rgba(59, 130, 246, 0.25) !important;
}

/* Clickable Table Rows */
tr.table-row-clickable {
  cursor: pointer !important;
  user-select: none;
  transition: background-color 0.15s ease;
}

tr.table-row-clickable:hover {
  background-color: rgba(245, 159, 0, 0.06) !important;
}

body.theme-dark tr.table-row-clickable:hover {
  background-color: rgba(245, 159, 0, 0.12) !important;
}

/* Server Flow Banner */
.flow-server-card {
  background-color: #ffffff;
  border: 1px solid #e2e8f0;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

body.theme-dark .flow-server-card {
  background-color: #1e293b;
  border-color: #334155;
}

body.theme-dark .flow-server-card .text-dark {
  color: #f8fafc !important;
}

/* ==========================================================================
   Traffic Monitor UI / UX Redesign
   ========================================================================== */
.traffic-table th,
.traffic-table td {
  white-space: nowrap !important;
  vertical-align: middle;
}

.traffic-table thead th {
  font-size: 12px !important;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #64748b;
  background-color: rgba(248, 250, 252, 0.85);
  border-bottom: 1px solid #e2e8f0;
  padding-top: 0.6rem;
  padding-bottom: 0.6rem;
}

body.theme-dark .traffic-table thead th {
  background-color: rgba(30, 41, 59, 0.7);
  border-bottom-color: #334155;
  color: #94a3b8;
}

.traffic-table tbody tr {
  transition: background-color 0.12s ease-in-out;
}

.traffic-table tbody tr:hover {
  background-color: rgba(241, 245, 249, 0.7) !important;
}

body.theme-dark .traffic-table tbody tr:hover {
  background-color: rgba(30, 41, 59, 0.5) !important;
}

/* Rank Badges */
.traffic-rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  font-size: 11px !important;
  font-weight: 700;
  font-family: var(--tblr-font-monospace, monospace);
  line-height: 1;
}

.traffic-rank-badge.rank-1 {
  background: linear-gradient(135deg, #f59f00, #d97706);
  color: #ffffff !important;
  box-shadow: 0 2px 4px rgba(245, 159, 0, 0.35);
}

.traffic-rank-badge.rank-2 {
  background: linear-gradient(135deg, #94a3b8, #64748b);
  color: #ffffff !important;
  box-shadow: 0 2px 4px rgba(100, 116, 139, 0.25);
}

.traffic-rank-badge.rank-3 {
  background: linear-gradient(135deg, #d97706, #92400e);
  color: #ffffff !important;
  box-shadow: 0 2px 4px rgba(217, 119, 6, 0.25);
}

.traffic-rank-badge.rank-other {
  background: #f1f5f9;
  color: #64748b !important;
  border: 1px solid #e2e8f0;
}

.traffic-rank-badge.rank-danger {
  background: rgba(239, 68, 68, 0.12);
  color: #dc2626 !important;
  border: 1px solid rgba(239, 68, 68, 0.25);
}

body.theme-dark .traffic-rank-badge.rank-other {
  background: #1e293b;
  color: #94a3b8 !important;
  border-color: #334155;
}

body.theme-dark .traffic-rank-badge.rank-danger {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171 !important;
  border-color: rgba(239, 68, 68, 0.4);
}

/* IP Cell & Copy Button */
.ip-cell {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.ip-code {
  font-family: var(--tblr-font-monospace, monospace);
  font-size: 13px !important;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: #1e293b;
}

body.theme-dark .ip-code {
  color: #e2e8f0;
}

.ip-copy-btn {
  opacity: 0.25;
  transition: opacity 0.15s ease, background-color 0.15s ease, transform 0.1s ease;
  padding: 2px 5px !important;
  line-height: 1;
  border-radius: 4px;
}

tr:hover .ip-copy-btn,
.ip-copy-btn:hover {
  opacity: 1 !important;
}

.ip-copy-btn:hover {
  background-color: rgba(100, 116, 139, 0.15) !important;
}

.ip-copy-btn:active {
  transform: scale(0.9);
}

/* Protocol Pills */
.proto-pill {
  display: inline-flex;
  align-items: center;
  font-size: 10.5px !important;
  font-weight: 600;
  padding: 1.5px 6px;
  border-radius: 4px;
  letter-spacing: 0.02em;
  line-height: 1.35;
  text-transform: uppercase;
  border: 1px solid transparent;
  white-space: nowrap;
}

.proto-pill-imap { background: rgba(34, 139, 230, 0.1); color: #1971c2 !important; border-color: rgba(34, 139, 230, 0.25); }
.proto-pill-pop3 { background: rgba(121, 80, 248, 0.1); color: #6741d9 !important; border-color: rgba(121, 80, 248, 0.25); }
.proto-pill-smtp { background: rgba(64, 192, 87, 0.12); color: #2b8a3e !important; border-color: rgba(64, 192, 87, 0.25); }
.proto-pill-submission { background: rgba(253, 126, 20, 0.12); color: #d9480f !important; border-color: rgba(253, 126, 20, 0.25); }
.proto-pill-jmap { background: rgba(230, 73, 128, 0.1); color: #c2255c !important; border-color: rgba(230, 73, 128, 0.25); }
.proto-pill-sieve { background: rgba(18, 184, 134, 0.1); color: #0ca678 !important; border-color: rgba(18, 184, 134, 0.25); }
.proto-pill-http { background: rgba(21, 170, 191, 0.1); color: #0c8599 !important; border-color: rgba(21, 170, 191, 0.25); }
.proto-pill-other { background: rgba(134, 142, 150, 0.1); color: #495057 !important; border-color: rgba(134, 142, 150, 0.25); }

body.theme-dark .proto-pill-imap { background: rgba(34, 139, 230, 0.2); color: #74c0fc !important; border-color: rgba(34, 139, 230, 0.4); }
body.theme-dark .proto-pill-pop3 { background: rgba(121, 80, 248, 0.2); color: #b197fc !important; border-color: rgba(121, 80, 248, 0.4); }
body.theme-dark .proto-pill-smtp { background: rgba(64, 192, 87, 0.2); color: #8ce99a !important; border-color: rgba(64, 192, 87, 0.4); }
body.theme-dark .proto-pill-submission { background: rgba(253, 126, 20, 0.2); color: #ffa94d !important; border-color: rgba(253, 126, 20, 0.4); }
body.theme-dark .proto-pill-jmap { background: rgba(230, 73, 128, 0.2); color: #fcc2d7 !important; border-color: rgba(230, 73, 128, 0.4); }
body.theme-dark .proto-pill-sieve { background: rgba(18, 184, 134, 0.2); color: #63e6be !important; border-color: rgba(18, 184, 134, 0.4); }
body.theme-dark .proto-pill-http { background: rgba(21, 170, 191, 0.2); color: #66d9e8 !important; border-color: rgba(21, 170, 191, 0.4); }
body.theme-dark .proto-pill-other { background: rgba(134, 142, 150, 0.2); color: #ced4da !important; border-color: rgba(134, 142, 150, 0.4); }

/* Spin animation for refresh buttons */
@keyframes ti-spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.ti-spin {
  animation: ti-spin 0.75s linear infinite !important;
  display: inline-block !important;
}

/* ==========================================================================
   User Profile Pill & Topbar User Dropdown (Modern & Clean Design)
   ========================================================================== */
.user-profile-pill {
  display: inline-flex !important;
  align-items: center !important;
  flex-direction: row !important;
  white-space: nowrap !important;
  background: #ffffff !important;
  border: 1px solid #e2e8f0 !important;
  padding: 4px 10px 4px 5px !important;
  border-radius: 9999px !important;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05) !important;
  transition: all 0.15s ease-in-out !important;
  cursor: pointer;
  line-height: 1 !important;
  text-decoration: none !important;
}

.user-profile-pill:hover,
.user-profile-pill:focus,
.user-profile-pill[aria-expanded="true"] {
  background: #f8fafc !important;
  border-color: #cbd5e1 !important;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08) !important;
}

.user-profile-pill .avatar {
  width: 26px !important;
  height: 26px !important;
  font-size: 11px !important;
  font-weight: 700 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  flex-shrink: 0 !important;
}

.user-profile-pill .user-name {
  font-size: 13px !important;
  font-weight: 600 !important;
  color: #1e293b !important;
  margin: 0 4px !important;
}

.user-profile-pill .badge {
  font-size: 10px !important;
  padding: 2px 7px !important;
  line-height: 13px !important;
  font-weight: 700 !important;
  letter-spacing: 0.2px !important;
  border-radius: 9999px !important;
  display: inline-flex !important;
  align-items: center !important;
  vertical-align: middle !important;
}

.top-navbar {
  position: relative !important;
  z-index: 1050 !important;
}

.user-dropdown-menu,
.navbar .dropdown-menu {
  z-index: 99999 !important;
  min-width: 250px !important;
  border: 1px solid rgba(0, 0, 0, 0.08) !important;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.12), 0 8px 10px -6px rgba(0, 0, 0, 0.06) !important;
  border-radius: 12px !important;
  padding: 8px !important;
  margin-top: 8px !important;
}

.user-dropdown-header-card {
  padding: 10px 12px !important;
  margin-bottom: 6px !important;
  border-radius: 8px !important;
  background: #f8fafc !important;
  border: 1px solid #e2e8f0 !important;
  display: flex !important;
  align-items: center !important;
  gap: 10px !important;
  text-transform: none !important;
}

.user-dropdown-header-card .badge {
  font-size: 9px !important;
  padding: 2px 6px !important;
  font-weight: 600 !important;
}

.user-dropdown-menu .dropdown-item {
  border-radius: 6px !important;
  padding: 8px 12px !important;
  font-size: 13px !important;
  font-weight: 500 !important;
  display: flex !important;
  align-items: center !important;
  transition: all 0.12s ease-in-out !important;
}

.user-dropdown-menu .dropdown-item:hover {
  background-color: #f1f5f9 !important;
  color: #0f172a !important;
}

.user-dropdown-menu .dropdown-item.text-danger:hover {
  background-color: #fee2e2 !important;
  color: #ef4444 !important;
}

/* Dark mode overrides */
body.theme-dark .user-profile-pill {
  background: #1e293b !important;
  border-color: #334155 !important;
  color: #f8fafc !important;
}

body.theme-dark .user-profile-pill .user-name {
  color: #f8fafc !important;
}

body.theme-dark .user-profile-pill:hover,
body.theme-dark .user-profile-pill[aria-expanded="true"] {
  background: #334155 !important;
  border-color: #475569 !important;
}

body.theme-dark .user-dropdown-menu {
  background: #1e293b !important;
  border-color: #334155 !important;
}

body.theme-dark .user-dropdown-header-card {
  background: #0f172a !important;
  border-color: #334155 !important;
}

body.theme-dark .user-dropdown-menu .dropdown-item {
  color: #e2e8f0 !important;
}

body.theme-dark .user-dropdown-menu .dropdown-item:hover {
  background: #334155 !important;
  color: #ffffff !important;
}

/* ==========================================================================
   Suspended User / Mailbox Row Highlight (Tô màu đỏ nhạt khi User bị khoá)
   ========================================================================== */
.row-suspended,
tr.row-suspended > td,
tr.table-row-suspended > td {
  background-color: rgba(220, 53, 69, 0.07) !important;
}

tr.row-suspended:hover > td,
tr.table-row-suspended:hover > td {
  background-color: rgba(220, 53, 69, 0.13) !important;
}

body.theme-dark .row-suspended,
body.theme-dark tr.row-suspended > td,
body.theme-dark tr.table-row-suspended > td {
  background-color: rgba(220, 53, 69, 0.15) !important;
}

body.theme-dark tr.row-suspended:hover > td,
body.theme-dark tr.table-row-suspended:hover > td {
  background-color: rgba(220, 53, 69, 0.22) !important;
}

/* Transfer Conflict Banner & Badges */
.banner-transfer-conflict {
  border-left: 4px solid #f59f00;
  background-color: rgba(245, 159, 0, 0.08);
  border-radius: 6px;
}