/* ==========================================================================
   SiteChat · ExTrack Design System & Premium UI Token Overrides
   ========================================================================== */

:root {
  --font-family: var(--font, 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);
  --sidebar-w: 252px;
  --body-bg: #f8fafc;
  --bg-surface: #ffffff;
  --bg-surface-secondary: #f1f5f9;
  --border-color: #e2e8f0;
  --border-color-light: #f1f5f9;
  --text: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --primary: #1ABB9C;
  --primary-lt: rgba(26, 187, 156, 0.1);
  --primary-dk: #169f85;
  --green: #10b981;
  --green-lt: rgba(16, 185, 129, 0.1);
  --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.06), 0 1px 2px 0 rgba(0, 0, 0, 0.04);
  --shadow-card: 0 1px 3px 0 rgba(0, 0, 0, 0.05), 0 0 0 1px #e2e8f0;
  --radius: 8px;
  --radius-lg: 12px;
}

/* Dark / Black Theme Overrides */
:root[data-theme="dark"],
[data-theme="dark"],
body[data-theme="dark"],
html[data-theme="dark"] {
  --body-bg: #090e17;
  --bg-surface: #111927;
  --bg-surface-secondary: #172235;
  --border-color: rgba(255, 255, 255, 0.09);
  --border-color-light: rgba(255, 255, 255, 0.05);
  --border-translucent: rgba(255, 255, 255, 0.08);
  --text: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-disabled: #475569;
  --primary-lt: rgba(26, 187, 156, 0.18);
  --green-lt: rgba(16, 185, 129, 0.18);
  --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.5), 0 1px 2px 0 rgba(0, 0, 0, 0.4);
  --shadow-card: 0 1px 3px 0 rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.08);
  --sidebar-bg: #0d131f;
  --sidebar-border: rgba(255, 255, 255, 0.07);
}

[data-theme="dark"] select option,
[data-theme="dark"] .form-control option {
  background: var(--bg-surface);
  color: var(--text);
}

/* Base Body & Layout Fixes */
body {
  font-family: var(--font-family);
  color: var(--text);
  background: var(--body-bg);
  -webkit-font-smoothing: antialiased;
}

/* ==================== Sidebar Layout & Navigation ==================== */
.sidebar {
  position: fixed !important;
  top: 0 !important;
  bottom: 0 !important;
  left: 0 !important;
  width: var(--sidebar-w, 252px) !important;
  background: var(--sidebar-bg, #1a2332) !important;
  display: flex !important;
  flex-direction: column !important;
  z-index: 100 !important;
  border-right: 1px solid var(--sidebar-border, rgba(255, 255, 255, 0.08)) !important;
  transition: width 0.2s cubic-bezier(0.2, 0, 0, 1), transform 0.22s ease !important;
  overflow: hidden !important;
}

/* Fixed Sidebar Header */
.sidebar-brand {
  height: 56px !important;
  min-height: 56px !important;
  padding: 0 16px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  border-bottom: 1px solid var(--sidebar-border, rgba(255, 255, 255, 0.08)) !important;
  flex-shrink: 0 !important;
}

.brand-main-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.sidebar-brand .brand-icon {
  background: linear-gradient(135deg, var(--primary), var(--primary-dk, #169f85));
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(26, 187, 156, 0.3);
}

.sidebar-brand .brand-name {
  color: #ffffff;
  font-size: 14.5px;
  font-weight: 700;
  letter-spacing: -0.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-brand .brand-name small {
  color: #94a3b8;
  font-size: 11px;
  font-weight: 500;
  display: block;
}

.sidebar-collapse-btn {
  background: transparent;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  padding: 6px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.sidebar-collapse-btn:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
}

/* Scrollable Nav List with Scroll Shadows */
.sidebar-nav {
  flex: 1 1 0% !important;
  min-height: 0 !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  padding: 8px 0 16px !important;
  /* Dynamic scroll shadows */
  background:
    linear-gradient(#1a2332 30%, rgba(26, 35, 50, 0)),
    linear-gradient(rgba(26, 35, 50, 0), #1a2332 70%) 0 100%,
    radial-gradient(farthest-side at 50% 0, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0)),
    radial-gradient(farthest-side at 50% 100%, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0)) 0 100%;
  background-repeat: no-repeat;
  background-color: var(--sidebar-bg, #1a2332);
  background-size: 100% 20px, 100% 20px, 100% 8px, 100% 8px;
  background-attachment: local, local, scroll, scroll;
}

.sidebar-nav::-webkit-scrollbar {
  width: 4px !important;
}

.sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.16) !important;
  border-radius: 4px !important;
}

.sidebar-nav::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3) !important;
}

.nav-group {
  margin-bottom: 8px;
}

.nav-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px 4px;
  cursor: pointer;
  user-select: none;
  transition: opacity 0.15s ease;
}

.nav-group-header:hover {
  opacity: 0.85;
}

.nav-label {
  padding: 0;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #94a3b8; /* high-contrast label */
}

.nav-group-chev {
  color: #94a3b8;
  transition: transform 0.2s cubic-bezier(0.2, 0, 0, 1);
}

.nav-group.group-collapsed .nav-group-chev {
  transform: rotate(-90deg);
}

.nav-group.group-collapsed .nav-group-items {
  display: none !important;
}

/* Tightened nav-link items (~35px height) */
.nav-link {
  display: flex !important;
  align-items: center !important;
  gap: 10px !important;
  height: 35px !important;
  min-height: 35px !important;
  padding: 0 12px !important;
  margin: 1px 8px !important;
  border-radius: 6px !important;
  color: #cbd5e1 !important; /* brighter inactive text for WCAG AA contrast */
  font-size: 12.5px !important;
  font-weight: 500 !important;
  text-decoration: none !important;
  transition: all 0.12s ease !important;
}

.nav-link:hover {
  color: #ffffff !important;
  background: rgba(255, 255, 255, 0.08) !important;
}

.nav-link.active {
  color: #ffffff !important;
  background: rgba(26, 187, 156, 0.22) !important;
  border: 1px solid rgba(26, 187, 156, 0.45) !important;
  font-weight: 600 !important;
}

.nav-link.active .icon {
  color: #2dd4bf !important;
  opacity: 1 !important;
}

.nav-link .icon {
  opacity: 0.85;
  flex-shrink: 0;
  width: 17px;
  height: 17px;
}

/* Fixed User Footer */
.sidebar-footer {
  height: 56px !important;
  min-height: 56px !important;
  padding: 0 12px !important;
  display: flex !important;
  align-items: center !important;
  border-top: 1px solid var(--sidebar-border, rgba(255, 255, 255, 0.08)) !important;
  flex-shrink: 0 !important;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.12s ease;
}

.sidebar-user:hover {
  background: rgba(255, 255, 255, 0.06);
}

.sidebar-user-info {
  flex: 1;
  min-width: 0;
}

.sidebar-user-info .name {
  color: #ffffff;
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

.sidebar-user-info .role {
  color: #94a3b8;
  font-size: 11px;
  line-height: 1.2;
}

/* Rail / Collapsed Sidebar Mode (Width: 68px) */
body.sidebar-rail {
  --sidebar-w: 68px !important;
}

body.sidebar-rail .sidebar,
.sidebar.sidebar-collapsed {
  width: 68px !important;
}

body.sidebar-rail .sidebar-brand .brand-name,
body.sidebar-rail .nav-label,
body.sidebar-rail .nav-group-chev,
body.sidebar-rail .nav-link .nav-text,
body.sidebar-rail .sidebar-user-info,
body.sidebar-rail .sidebar-user .more-btn,
.sidebar.sidebar-collapsed .sidebar-brand .brand-name,
.sidebar.sidebar-collapsed .nav-label,
.sidebar.sidebar-collapsed .nav-group-chev,
.sidebar.sidebar-collapsed .nav-link .nav-text,
.sidebar.sidebar-collapsed .sidebar-user-info,
.sidebar.sidebar-collapsed .sidebar-user .more-btn {
  display: none !important;
}

body.sidebar-rail .sidebar-brand,
.sidebar.sidebar-collapsed .sidebar-brand {
  justify-content: center !important;
  padding: 0 !important;
}

body.sidebar-rail .sidebar-brand .brand-icon,
.sidebar.sidebar-collapsed .sidebar-brand .brand-icon {
  margin: 0 auto;
}

body.sidebar-rail .sidebar-collapse-btn,
.sidebar.sidebar-collapsed .sidebar-collapse-btn {
  position: absolute;
  top: 14px;
  right: 6px;
}

body.sidebar-rail .nav-group-header,
.sidebar.sidebar-collapsed .nav-group-header {
  padding: 6px 0;
  justify-content: center;
}

body.sidebar-rail .nav-link,
.sidebar.sidebar-collapsed .nav-link {
  justify-content: center !important;
  padding: 0 !important;
  margin: 2px 8px !important;
  width: calc(100% - 16px) !important;
}

body.sidebar-rail .sidebar-user,
.sidebar.sidebar-collapsed .sidebar-user {
  justify-content: center !important;
  padding: 6px 0 !important;
}

body.sidebar-rail .main {
  margin-inline-start: 68px !important;
}

body.sidebar-rail .topbar {
  inset-inline-start: 68px !important;
}

/* Tooltip on Collapsed Rail items */
.sidebar.sidebar-collapsed .nav-link[data-tooltip],
body.sidebar-rail .nav-link[data-tooltip] {
  position: relative;
}

.sidebar.sidebar-collapsed .nav-link[data-tooltip]:hover::after,
body.sidebar-rail .nav-link[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  background: #0f172a;
  color: #ffffff;
  font-size: 11.5px;
  font-weight: 500;
  padding: 5px 10px;
  border-radius: 5px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 1000;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

/* ==================== Topbar Styling ==================== */
.topbar {
  position: fixed !important;
  top: 0 !important;
  left: var(--sidebar-w, 252px) !important;
  right: 0 !important;
  height: 56px !important;
  z-index: 90 !important;
  background: var(--bg-surface) !important;
  border-bottom: 1px solid var(--border-color) !important;
  display: flex !important;
  justify-content: space-between !important;
  align-items: center !important;
  padding: 0 24px !important;
  transition: left 0.2s cubic-bezier(0.2, 0, 0, 1) !important;
}

.topbar-site-picker {
  position: relative;
  display: inline-flex;
  align-items: center;
  margin-right: 14px;
}

.site-picker-icon {
  position: absolute;
  left: 12px;
  font-size: 13px;
  pointer-events: none;
  opacity: 0.85;
}

.topbar-site-select {
  appearance: none;
  -webkit-appearance: none;
  background: var(--bg-surface-secondary);
  color: var(--text);
  border: 1px solid var(--border-color);
  border-radius: var(--radius, 8px);
  padding: 7px 30px 7px 32px;
  font-family: var(--font-family);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  transition: all 0.15s ease;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
  max-width: 240px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-site-select:hover {
  background: var(--bg-surface);
  border-color: var(--primary);
}

.topbar-site-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-lt);
}

.site-picker-arrow {
  position: absolute;
  right: 11px;
  pointer-events: none;
  color: var(--text-muted);
}

/* Main Container Offset */
.main {
  margin-left: var(--sidebar-w, 252px) !important;
  padding-top: 60px !important;
  min-height: 100vh !important;
  background: var(--body-bg);
}

.page-wrapper {
  padding: 30px 36px 60px !important;
  max-width: 1440px;
  margin: 0 auto;
}

/* Typography & Header */
.page-header {
  margin-bottom: 26px;
}

.page-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 18px;
}

.page-pretitle {
  text-transform: uppercase;
  letter-spacing: 0.6px;
  font-size: 11px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 4px;
}

.page-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.35px;
  margin: 0;
  line-height: 1.25;
}

/* Premium Card Design */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg, 12px);
  box-shadow: var(--shadow, 0 1px 3px rgba(0,0,0,0.04), 0 4px 10px rgba(0,0,0,0.02));
  transition: box-shadow 0.2s cubic-bezier(0.16, 1, 0.3, 1), transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.2s ease;
  overflow: hidden;
  position: relative;
}

.card:hover {
  border-color: var(--border-color-hover, var(--border-color));
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.05);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-color-light, rgba(0,0,0,0.06));
  background: var(--bg-surface);
}

.card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.15px;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-subtitle {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 4px;
  line-height: 1.45;
}

.card-body {
  padding: 24px 26px;
}

.card-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color-light, rgba(0,0,0,0.06));
  background: var(--bg-surface-secondary);
}

/* Stat Cards */
.stat-card-custom {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg, 12px);
  padding: 22px 24px;
  display: flex;
  align-items: flex-start;
  gap: 18px;
  box-shadow: var(--shadow, 0 1px 3px rgba(0,0,0,0.04));
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.stat-card-custom:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(0,0,0,0.08);
}

.stat-icon-box {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-icon-box.teal { background: var(--primary-lt); color: var(--primary); }
.stat-icon-box.blue { background: var(--blue-lt, rgba(6,111,209,0.1)); color: var(--blue, #066fd1); }
.stat-icon-box.yellow { background: var(--yellow-lt, rgba(245,159,0,0.1)); color: var(--yellow, #f59f00); }
.stat-icon-box.purple { background: var(--purple-lt, rgba(174,62,201,0.1)); color: var(--purple, #ae3ec9); }

.stat-metric-val {
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.15;
  letter-spacing: -0.5px;
}

.stat-metric-label {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
  margin-top: 4px;
}

.stat-metric-sub {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 6px;
}

/* Form Controls */
.form-group {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 7px;
}

.form-control, .form-select {
  width: 100%;
  height: 40px;
  font-family: var(--font-family);
  font-size: 13.5px;
  color: var(--text);
  background: var(--bg-surface-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius, 8px);
  padding: 8px 14px;
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.form-control::placeholder {
  color: var(--text-muted);
}

.form-control:focus, .form-select:focus {
  background: var(--bg-surface);
  border-color: var(--primary);
  box-shadow: 0 0 0 3.5px var(--primary-lt);
}

textarea.form-control {
  height: auto;
  resize: vertical;
  min-height: 90px;
  line-height: 1.55;
  padding: 10px 14px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-family: var(--font-family);
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius, 8px);
  padding: 8px 16px;
  height: 38px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  white-space: nowrap;
  line-height: 1;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary-dk, #169f85);
  box-shadow: 0 1px 3px rgba(26, 187, 156, 0.3);
}

.btn-primary:hover {
  background: var(--primary-dk, #169f85);
  box-shadow: 0 3px 8px rgba(26, 187, 156, 0.45);
}

.btn-outline {
  background: var(--bg-surface);
  color: var(--text-secondary);
  border-color: var(--border-color);
  box-shadow: var(--shadow);
}

.btn-outline:hover {
  background: var(--bg-surface-secondary);
  color: var(--text);
  border-color: var(--text-muted);
}

.btn-danger {
  background: var(--red, #d63939);
  color: #fff;
  border-color: #b91c1c;
}

.btn-danger:hover {
  background: #b91c1c;
}

.btn-sm {
  font-size: 12px;
  padding: 6px 12px;
  height: 32px;
  border-radius: var(--radius-sm, 6px);
}

/* Badges & Status */
.badge {
  font-size: 11.5px;
  font-weight: 600;
  padding: 3.5px 9px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  letter-spacing: 0.02em;
}

.badge-teal {
  background: var(--primary-lt);
  color: var(--primary);
}

.badge-blue {
  background: var(--blue-lt, rgba(6,111,209,0.1));
  color: var(--blue, #066fd1);
}

.badge-red {
  background: var(--red-lt, rgba(214,57,57,0.1));
  color: var(--red, #d63939);
}

/* Tables */
.table-responsive {
  overflow-x: auto;
  width: 100%;
}

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

table.table th {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  background: var(--bg-surface-secondary);
  padding: 12px 20px;
  border-bottom: 1px solid var(--border-color);
}

table.table td {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-color-light, rgba(0,0,0,0.06));
  vertical-align: middle;
  color: var(--text);
}

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

table.table tbody tr:hover {
  background: var(--bg-surface-secondary);
}

table.table tbody tr:last-child td {
  border-bottom: none;
}

/* Toggles */
.toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-color-light, rgba(0,0,0,0.06));
}

.toggle-row:last-child {
  border-bottom: none;
}

.toggle-row .label {
  font-size: 13px;
  color: var(--text);
}

.toggle-row .desc {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 2px;
}

.toggle {
  width: 36px;
  height: 20px;
  background: #cbd5e1;
  border-radius: 10px;
  position: relative;
  cursor: pointer;
  transition: background 0.15s ease;
  flex-shrink: 0;
}

[data-theme=dark] .toggle {
  background: #334155;
}

.toggle.on {
  background: var(--primary);
}

.toggle:after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.15s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.toggle.on:after {
  transform: translateX(16px);
}

/* Modals */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.18s ease, visibility 0.18s ease;
}

.modal-backdrop.show {
  opacity: 1;
  visibility: visible;
}

.modal-dialog, .modal {
  background: var(--bg-surface, #ffffff);
  color: var(--text, #1e293b);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: var(--radius-lg, 12px);
  width: 100%;
  max-width: 480px;
  box-shadow: 0 20px 30px -5px rgba(0,0,0,0.2);
  overflow: hidden;
  transform: scale(0.96) translateY(6px);
  transition: transform 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-backdrop.show .modal-dialog,
.modal-backdrop.show .modal {
  transform: scale(1) translateY(0);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color, #e2e8f0);
}

.modal-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.modal-close {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm, 4px);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s, color 0.12s;
}

.modal-close:hover {
  background: var(--bg-surface-secondary);
  color: var(--text);
}

.modal-body {
  padding: 20px;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--border-color, #e2e8f0);
  background: var(--bg-surface-secondary);
}

/* ==========================================================================
   Skeleton Loading Placeholders
   ========================================================================== */
@keyframes skeleton-shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.skeleton {
  background: linear-gradient(90deg, var(--bg-surface-secondary) 25%, var(--border-color) 50%, var(--bg-surface-secondary) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s infinite ease-in-out;
  border-radius: var(--radius-sm, 4px);
  display: inline-block;
}

.skeleton-text {
  height: 14px;
  width: 100%;
  margin-bottom: 8px;
  border-radius: 4px;
}

.skeleton-rect {
  width: 100%;
  height: 42px;
  border-radius: var(--radius, 8px);
}

.skeleton-circle {
  border-radius: 50%;
  width: 36px;
  height: 36px;
}

/* ==========================================================================
   Standardized Empty State Component
   ========================================================================== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 48px 24px;
  width: 100%;
}

.empty-state-icon {
  font-size: 34px;
  margin-bottom: 12px;
  line-height: 1;
  opacity: 0.85;
}

.empty-state-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.empty-state-description {
  font-size: 13px;
  color: var(--text-muted);
  max-width: 420px;
  line-height: 1.5;
  margin-bottom: 18px;
}

.empty-state-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

/* ==========================================================================
   Accessibility & WCAG AA Focus Rings
   ========================================================================== */
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ==========================================================================
   Toast Notifications Host & Types
   ========================================================================== */
.toast-host {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 440px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  padding: 12px 18px;
  border-radius: var(--radius);
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.45;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.25), 0 8px 10px -6px rgba(0, 0, 0, 0.15);
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  animation: toastIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  transition: opacity 0.2s, transform 0.2s;
}

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

.toast.toast-success {
  background: #065f46;
  color: #ecfdf5;
  border: 1px solid #10b981;
}

.toast.toast-error {
  background: #991b1b;
  color: #fef2f2;
  border: 1px solid #ef4444;
}

.toast.toast-warning {
  background: #92400e;
  color: #fffbeb;
  border: 1px solid #f59e0b;
}

/* ==================== Pagination Component ==================== */
.pagination-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 14px 18px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-surface);
  font-size: 13px;
  color: var(--text-muted);
}

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

.pagination-info b {
  color: var(--text);
  font-weight: 600;
}

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

.pagination-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.pagination-btn:hover:not(:disabled) {
  background: var(--border-color);
  border-color: var(--text-muted);
}

.pagination-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
  font-weight: 600;
}

.pagination-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

/* ==================== Sticky Save Bar ==================== */
.sticky-save-bar {
  position: fixed;
  bottom: 24px;
  left: calc(var(--sidebar-w, 252px) + 24px);
  right: 24px;
  max-width: calc(1440px - 48px);
  margin: 0 auto;
  z-index: 99;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.18), 0 8px 10px -6px rgba(0, 0, 0, 0.08);
  border-radius: var(--radius-lg, 12px);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  animation: slideUpSaveBar 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUpSaveBar {
  from {
    transform: translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* ==================== Split Login Screen (SiteChat 2.0) ==================== */
/* ==================== Split Login Screen (Native Reference Match) ==================== */
.login-split-container {
  height: 100vh;
  width: 100vw;
  display: flex;
  background: #FFFFFF;
  font-family: 'Plus Jakarta Sans', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  overflow: hidden;
  position: relative;
}

.sitechat-login-left {
  flex: 1;
  max-width: 50%;
  width: 50%;
  height: 100vh;
  background: #FFFFFF;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  position: relative;
  padding: 24px 40px;
  box-sizing: border-box;
  overflow: hidden;
}

.sitechat-login-inner {
  width: 100%;
  max-width: 360px;
  box-sizing: border-box;
}

.sitechat-brand-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.sitechat-brand-logo {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  object-fit: contain;
  display: block;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.12);
}

.sitechat-brand-text-col {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.sitechat-brand-title {
  font-size: 17px;
  font-weight: 700;
  color: #111827;
  line-height: 1.15;
  letter-spacing: -0.2px;
}

.sitechat-brand-tagline {
  font-size: 11.5px;
  font-weight: 500;
  color: #6B7280;
  margin-top: 1px;
  line-height: 1.2;
}

.sitechat-welcome-heading {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 34px;
  font-weight: 700;
  color: #111827;
  line-height: 1.15;
  margin: 0 0 6px;
  letter-spacing: -0.5px;
}

.sitechat-welcome-sub {
  font-size: 13px;
  color: #6B7280;
  margin: 0 0 20px;
  line-height: 1.45;
  font-weight: 400;
}

.sitechat-form-group {
  margin-bottom: 14px;
}

.sitechat-form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #1F2937;
  margin-bottom: 5px;
}

.sitechat-form-input {
  width: 100%;
  height: 40px;
  padding: 0 14px;
  border: 1px solid #E5E7EB;
  border-radius: 6px;
  font-size: 13.5px;
  color: #111827;
  background: #FFFFFF;
  transition: all 0.15s ease;
  box-sizing: border-box;
  outline: none;
  font-family: inherit;
}

.sitechat-form-input:focus {
  border-color: #00A37A;
  box-shadow: 0 0 0 3px rgba(0, 163, 122, 0.12);
}

.sitechat-password-wrapper {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
}

.sitechat-password-wrapper .sitechat-form-input {
  padding-right: 38px;
}

.sitechat-eye-toggle {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  padding: 4px;
  cursor: pointer;
  color: #9CA3AF;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: color 0.15s ease;
}

.sitechat-eye-toggle:hover {
  color: #4B5563;
}

.sitechat-form-meta-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 12px 0 16px;
}

.sitechat-checkbox-label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: #4B5563;
  cursor: pointer;
  font-weight: 500;
  user-select: none;
}

.sitechat-checkbox {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  accent-color: #00A37A;
  cursor: pointer;
}

.sitechat-forgot-link {
  color: #00A37A;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  transition: color 0.15s ease;
}

.sitechat-forgot-link:hover {
  color: #008F6B;
  text-decoration: underline;
}

.sitechat-submit-btn {
  width: 100%;
  height: 42px;
  background: #00A37A;
  color: #FFFFFF;
  font-size: 14px;
  font-weight: 600;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 3px 10px rgba(0, 163, 122, 0.22);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
}

.sitechat-submit-btn:hover {
  background: #008F6B;
  box-shadow: 0 4px 14px rgba(0, 163, 122, 0.3);
}

.sitechat-login-copyright {
  position: absolute;
  bottom: 20px;
  left: 36px;
  font-size: 11px;
  color: #9CA3AF;
  line-height: 1.4;
  margin: 0;
  user-select: none;
}

/* Right side artwork - Centered floating framed card (Not zoomed in) */
.sitechat-login-right {
  flex: 1;
  max-width: 50%;
  width: 50%;
  height: 100vh;
  background: #08101E;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  box-sizing: border-box;
  overflow: hidden;
  position: relative;
}

.sitechat-hero-card {
  width: 100%;
  max-width: 440px;
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 24px;
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.sitechat-hero-card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  user-select: none;
  pointer-events: none;
}

.login-error-alert {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.25);
  color: #ef4444;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 13.5px;
  margin-bottom: 22px;
  animation: messageIn 0.3s ease;
}

/* ==================== Responsive Drawer & Media Queries ==================== */
.mobile-menu-btn {
  display: none !important;
}

@media (max-width: 900px) {
  .login-split-container {
    flex-direction: column;
    min-height: 100vh;
  }
  .sitechat-login-left {
    max-width: 100%;
    min-height: 100vh;
    padding: 36px 24px;
    justify-content: center;
  }
  .sitechat-login-inner {
    max-width: 400px;
  }
  .sitechat-login-right {
    display: none;
  }
}

@media (max-width: 768px) {
  .sidebar {
    position: fixed !important;
    top: 0 !important;
    bottom: 0 !important;
    left: 0 !important;
    width: 260px !important;
    transform: translateX(-100%);
    transition: transform 0.25s cubic-bezier(0.2, 0, 0, 1) !important;
    z-index: 1000 !important;
  }

  .sidebar.sidebar-mobile-open {
    transform: translateX(0) !important;
    box-shadow: 0 0 32px rgba(0, 0, 0, 0.45) !important;
  }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(3px);
    z-index: 999;
  }

  .topbar {
    left: 0 !important;
    padding: 0 16px !important;
  }

  .mobile-menu-btn {
    display: inline-flex !important;
    margin-right: 8px;
  }

  .main {
    margin-left: 0 !important;
  }

  .page-wrapper {
    padding: 20px 16px 48px !important;
  }

  .sticky-save-bar {
    left: 16px;
    right: 16px;
    bottom: 16px;
  }
}

/* ==================== Account & System Settings Modal (ExOOF Layout) ==================== */
.modal-settings-lg {
  max-width: 1040px !important;
  width: 95vw !important;
  height: 86vh !important;
  max-height: 720px !important;
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden !important;
}

.modal-settings-body {
  display: flex !important;
  flex: 1 !important;
  min-height: 0 !important;
  overflow: hidden !important;
  padding: 0 !important;
}

.settings-modal-sidebar {
  width: 230px !important;
  min-width: 230px !important;
  background: var(--bg-surface-secondary);
  border-right: 1px solid var(--border-color);
  padding: 18px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
}

.settings-tab-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-md, 8px);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.16s ease;
  text-align: left;
  width: 100%;
}

.settings-tab-btn:hover {
  background: var(--bg-surface-hover, var(--border-color-light));
  color: var(--text);
}

.settings-tab-btn.active {
  background: var(--primary-lt, rgba(26, 187, 156, 0.12));
  color: var(--primary);
  border-color: var(--primary-border, var(--primary));
  font-weight: 600;
}

.settings-tab-btn svg {
  flex-shrink: 0;
}

.settings-modal-content {
  flex: 1;
  padding: 24px 28px;
  overflow-y: auto;
  background: var(--bg-surface);
  min-height: 0;
}

@media (max-width: 768px) {
  .modal-settings-body {
    flex-direction: column !important;
  }
  .settings-modal-sidebar {
    width: 100% !important;
    min-width: 100% !important;
    border-right: none !important;
    border-bottom: 1px solid var(--border-color);
    flex-direction: row !important;
    overflow-x: auto;
    padding: 10px 12px;
  }
  .settings-tab-btn {
    white-space: nowrap;
    padding: 8px 12px;
  }
}

/* LLM 2-Column Settings Layout */
.llm-settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, 340px);
  gap: 20px;
  align-items: start;
}

@media (max-width: 980px) {
  .llm-settings-grid {
    grid-template-columns: 1fr;
  }
}
