:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-subtle: #f1f5f9;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;

  --teal-dark: #064e3b;
  --teal-rail: #093f34;
  --teal-hover: #047857;
  --teal-soft: #ecfdf5;
  --teal-text: #065f46;

  --text: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;

  --success: #16a34a;
  --success-bg: #dcfce7;
  --warning: #d97706;
  --warning-bg: #fef3c7;
  --danger: #dc2626;
  --danger-bg: #fee2e2;
  --info: #0284c7;
  --info-bg: #e0f2fe;

  --radius: 10px;
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.03);
  --shadow-md: 0 10px 25px -5px rgba(15, 23, 42, 0.12);
}

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

body {
  font-family: 'Inter', 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ---------- TOAST ---------- */
.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  padding: 12px 18px;
  border-radius: 10px;
  background: #0f172a;
  color: #fff;
  font-weight: 500;
  font-size: 13px;
  box-shadow: var(--shadow-md);
  max-width: 380px;
}
.toast.success { background: var(--teal-dark); }
.toast.error { background: var(--danger); }

/* ---------- LOGIN ---------- */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(circle at top right, #d1fae5 0%, #f8fafc 45%, #e2e8f0 100%);
}
.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  box-shadow: var(--shadow-md);
}
.login-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-bottom: 24px;
}
.login-logo {
  height: 56px;
  max-width: 180px;
  object-fit: contain;
}
.login-brand h1 {
  font-size: 19px;
  font-weight: 800;
  color: var(--teal-dark);
  letter-spacing: -0.02em;
}
.login-brand p {
  font-size: 12.5px;
  color: var(--text-muted);
}
.login-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* ---------- APP SHELL ---------- */
.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* Slim Forest-Teal Left Rail */
.sidebar {
  width: 92px;
  background: linear-gradient(180deg, var(--teal-dark) 0%, var(--teal-rail) 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px 8px;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 40;
  box-shadow: 2px 0 12px rgba(6, 78, 59, 0.14);
}
.sidebar-top {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-bottom: 14px;
  width: 100%;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}
.sidebar-logo-box {
  width: 44px;
  height: 44px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 5px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.18);
}
.sidebar-logo-box img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.sidebar-role-tag {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #a7f3d0;
  background: rgba(255, 255, 255, 0.1);
  padding: 2px 7px;
  border-radius: 99px;
}

.sidebar-nav {
  flex: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
  scrollbar-width: none;
}
.sidebar-nav::-webkit-scrollbar { display: none; }

.rail-btn {
  width: 100%;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.78);
  padding: 9px 4px;
  border-radius: 9px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  transition: all 0.16s ease;
  position: relative;
  font-family: inherit;
}
.rail-btn svg {
  width: 19px;
  height: 19px;
  flex-shrink: 0;
}
.rail-btn span {
  font-size: 10.5px;
  font-weight: 500;
  line-height: 1.15;
  text-align: center;
  max-width: 78px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rail-btn:hover {
  background: rgba(255, 255, 255, 0.11);
  color: #fff;
}
.rail-btn.active {
  background: rgba(255, 255, 255, 0.18);
  color: #ffffff;
  font-weight: 600;
  box-shadow: inset 3px 0 0 #34d399;
}
.rail-btn .rail-badge {
  position: absolute;
  top: 5px;
  right: 11px;
  background: #ef4444;
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  min-width: 15px;
  height: 15px;
  line-height: 15px;
  border-radius: 99px;
  padding: 0 4px;
}

.sidebar-bottom {
  width: 100%;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

/* Main Workspace */
.main-wrap {
  flex: 1;
  margin-left: 92px;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100vh;
  overflow: hidden;
}

.impersonation-banner {
  background: linear-gradient(90deg, #b45309, #d97706);
  color: #fff;
  padding: 8px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
}
.impersonation-left {
  display: flex;
  align-items: center;
  gap: 8px;
}
.imp-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #fef08a;
  box-shadow: 0 0 0 3px rgba(254, 240, 138, 0.35);
}

/* Topbar */
.topbar {
  height: 62px;
  flex-shrink: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: relative;
  z-index: 30;
}
.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.mobile-menu-btn {
  display: none;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 16px;
  cursor: pointer;
}
.page-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.015em;
}
.page-subtitle {
  font-size: 11.5px;
  color: var(--text-muted);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}
.topbar-search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 6px 10px;
  width: 240px;
}
.topbar-search svg {
  width: 15px;
  height: 15px;
  color: var(--text-muted);
  flex-shrink: 0;
}
.topbar-search input {
  border: none;
  background: transparent;
  outline: none;
  width: 100%;
  font-size: 12.5px;
  color: var(--text);
}
.topbar-search kbd {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  background: #fff;
  border: 1px solid var(--border);
  padding: 1px 5px;
  border-radius: 4px;
}

.topbar-credit-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  background: linear-gradient(135deg, #064e3b 0%, #047857 100%);
  border: 1px solid #065f46;
  color: #ffffff;
  padding: 6px 14px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 600;
  box-shadow: 0 2px 10px rgba(6, 78, 59, 0.24);
  cursor: pointer;
}
.credit-pill-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #34d399;
  box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.28);
}
.topbar-credit-pill strong {
  font-size: 14px;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.18);
  padding: 1px 8px;
  border-radius: 99px;
}

.icon-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 12px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 12.5px;
  cursor: pointer;
  position: relative;
}
.icon-pill-btn svg { width: 15px; height: 15px; }
.icon-pill-btn:hover { background: var(--surface-subtle); color: var(--teal-dark); }

.icon-circle-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
}
.icon-circle-btn svg { width: 17px; height: 17px; }
.icon-circle-btn:hover { background: var(--surface-subtle); color: var(--teal-dark); }

.bell-badge, .notif-dot {
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  border-radius: 99px;
  padding: 1px 5px;
  min-width: 17px;
  text-align: center;
}
.bell-badge {
  position: absolute;
  top: -4px;
  right: -3px;
}

.user-avatar-btn {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 4px 10px 4px 5px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
}
.user-avatar-btn:hover { background: var(--surface-subtle); }
.avatar-circle {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--teal-dark);
  color: #fff;
  font-size: 11.5px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.avatar-circle.sm { width: 32px; height: 32px; font-size: 11px; background: #0f766e; }
.user-btn-meta {
  display: flex;
  flex-direction: column;
  text-align: left;
  line-height: 1.2;
}
.user-btn-meta strong { font-size: 12px; color: var(--text); }
.user-btn-meta small { font-size: 10.5px; color: var(--text-muted); }
.chev { width: 14px; height: 14px; color: var(--text-muted); }

/* Dropdown Popovers */
.popover-anchor { position: relative; }
.dropdown-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 280px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  z-index: 60;
  overflow: hidden;
}
.user-popover { width: 220px; }
.popover-header {
  padding: 12px 14px;
  background: var(--surface-subtle);
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}
.popover-header strong { font-size: 13px; color: var(--text); }
.popover-header small { font-size: 11px; color: var(--text-muted); }
.popover-item {
  width: 100%;
  text-align: left;
  padding: 10px 14px;
  border: none;
  background: transparent;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
}
.popover-item:hover { background: var(--surface-subtle); }
.popover-item.danger { color: var(--danger); }
.popover-divider { height: 1px; background: var(--border); }

.notif-row {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
}
.notif-row:hover { background: var(--surface-subtle); }
.notif-row:last-child { border-bottom: none; }

/* Content & Footer */
.content-area {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px 32px;
  max-width: 1520px;
  width: 100%;
  margin: 0 auto;
}
.app-footer {
  flex-shrink: 0;
  padding: 10px 24px;
  text-align: center;
  font-size: 11.5px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  background: var(--surface);
}

/* ---------- CARDS & GRIDS ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-xs);
}
.card-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.card-title {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--text);
}
.card-sub {
  font-size: 12px;
  color: var(--text-muted);
}

.section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin: 18px 0 9px;
}
.section-label:first-child { margin-top: 0; }

.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.grid-5 { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.grid-6 { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; }
.grid-7 { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 10px; }
.grid-8 { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 8px; }
.grid-9 { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 8px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.grid-charts { display: grid; grid-template-columns: 1.5fr 1fr; gap: 14px; margin-top: 14px; }

/* Individual KPI Card */
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow-xs);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  transition: border-color 0.15s, transform 0.15s;
}
.kpi-card.clickable { cursor: pointer; }
.kpi-card.clickable:hover { border-color: var(--teal-dark); transform: translateY(-1px); }
.kpi-meta small {
  display: block;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.kpi-meta .kpi-val {
  font-size: 24px;
  font-weight: 800;
  color: var(--text);
  line-height: 1.1;
  letter-spacing: -0.02em;
}
.kpi-meta .kpi-foot {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  display: block;
}
.kpi-icon {
  width: 38px;
  height: 38px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  flex-shrink: 0;
  background: var(--surface-subtle);
  color: var(--teal-dark);
}
.kpi-icon.green { background: var(--success-bg); color: var(--success); }
.kpi-icon.amber { background: var(--warning-bg); color: var(--warning); }
.kpi-icon.red { background: var(--danger-bg); color: var(--danger); }
.kpi-icon.blue { background: var(--info-bg); color: var(--info); }
.kpi-icon.teal { background: var(--teal-soft); color: var(--teal-dark); }

/* Active / Inactive / Banned Progress Cards */
.status-bar-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-xs);
  cursor: pointer;
}
.status-bar-card:hover { border-color: var(--teal-dark); }
.status-bar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.status-bar-top span { font-size: 12.5px; font-weight: 600; color: var(--text-secondary); }
.status-bar-val { font-size: 26px; font-weight: 800; color: var(--text); margin-bottom: 10px; }
.progress-track {
  width: 100%;
  height: 7px;
  border-radius: 99px;
  background: var(--surface-subtle);
  overflow: hidden;
  margin-bottom: 6px;
}
.progress-fill { height: 100%; border-radius: 99px; transition: width 0.3s ease; }
.progress-fill.green { background: #16a34a; }
.progress-fill.slate { background: #64748b; }
.progress-fill.red { background: #dc2626; }
.status-bar-pct { font-size: 11px; color: var(--text-muted); }

/* Compact Summary Tile */
.mini-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  cursor: pointer;
  transition: border-color 0.15s;
}
.mini-tile:hover, .mini-tile.active-filter {
  border-color: var(--teal-dark);
  background: #f0fdf9;
}
.mini-tile small {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}
.mini-tile strong {
  display: block;
  font-size: 21px;
  font-weight: 800;
  color: var(--text);
  margin-top: 3px;
}

/* Soft Color Tinted Card Themes */
.tint-teal { background: linear-gradient(135deg, #f0fdfa 0%, #ffffff 100%); border-color: #99f6e4; }
.tint-teal small { color: #0f766e; }
.tint-teal .kpi-val, .tint-teal strong { color: #064e3b; }

.tint-green { background: linear-gradient(135deg, #ecfdf5 0%, #ffffff 100%); border-color: #a7f3d0; }
.tint-green small { color: #15803d; }
.tint-green .kpi-val, .tint-green strong { color: #14532d; }

.tint-blue { background: linear-gradient(135deg, #eff6ff 0%, #ffffff 100%); border-color: #bfdbfe; }
.tint-blue small { color: #1d4ed8; }
.tint-blue .kpi-val, .tint-blue strong { color: #1e3a8a; }

.tint-amber { background: linear-gradient(135deg, #fffbeb 0%, #ffffff 100%); border-color: #fde68a; }
.tint-amber small { color: #b45309; }
.tint-amber .kpi-val, .tint-amber strong { color: #78350f; }

.tint-orange { background: linear-gradient(135deg, #fff7ed 0%, #ffffff 100%); border-color: #fed7aa; }
.tint-orange small { color: #c2410c; }
.tint-orange .kpi-val, .tint-orange strong { color: #7c2d12; }

.tint-red { background: linear-gradient(135deg, #fef2f2 0%, #ffffff 100%); border-color: #fecaca; }
.tint-red small { color: #b91c1c; }
.tint-red .kpi-val, .tint-red strong { color: #7f1d1d; }

.tint-slate { background: linear-gradient(135deg, #f1f5f9 0%, #ffffff 100%); border-color: #cbd5e1; }
.tint-slate small { color: #475569; }
.tint-slate .kpi-val, .tint-slate strong { color: #0f172a; }

.tint-indigo { background: linear-gradient(135deg, #eef2ff 0%, #ffffff 100%); border-color: #c7d2fe; }
.tint-indigo small { color: #4338ca; }
.tint-indigo .kpi-val, .tint-indigo strong { color: #312e81; }

.tint-cyan { background: linear-gradient(135deg, #ecfeff 0%, #ffffff 100%); border-color: #a5f3fc; }
.tint-cyan small { color: #0e7490; }
.tint-cyan .kpi-val, .tint-cyan strong { color: #164e63; }

.tint-purple { background: linear-gradient(135deg, #faf5ff 0%, #ffffff 100%); border-color: #e9d5ff; }
.tint-purple small { color: #7e22ce; }
.tint-purple .kpi-val, .tint-purple strong { color: #581c87; }

.mini-tile.active-filter {
  box-shadow: 0 0 0 2px rgba(6, 78, 59, 0.35);
  border-color: var(--teal-dark);
}

.toolbar-inline-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.toolbar-search-input {
  width: 250px !important;
  padding: 6px 11px !important;
  font-size: 12.5px !important;
  border-radius: 8px;
}

/* ---------- ANNOUNCEMENT STRIP ---------- */
.announcement-strip {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  border-left: 4px solid var(--teal-dark);
  border-radius: 10px;
  padding: 11px 16px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.announcement-strip.WARNING { background: #fffbeb; border-color: #fde68a; border-left-color: #d97706; }
.announcement-strip.URGENT { background: #fef2f2; border-color: #fecaca; border-left-color: #dc2626; }

/* ---------- BUTTONS & INPUTS ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 600;
  font-family: inherit;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  white-space: nowrap;
}
.btn-primary { background: var(--teal-dark); color: #fff; }
.btn-primary:hover { background: var(--teal-hover); }
.btn-secondary { background: #fff; color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--surface-subtle); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-white { background: #fff; color: #0f172a; }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 7px; }
.btn-full { width: 100%; }

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 12px;
}
.form-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}
input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="date"],
input[type="search"],
select,
textarea {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--teal-dark);
  box-shadow: 0 0 0 3px rgba(6, 78, 59, 0.1);
}
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }

.error-box {
  background: var(--danger-bg);
  color: var(--danger);
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 12.5px;
  margin-bottom: 12px;
  font-weight: 500;
}

/* ---------- BADGES ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-success { background: var(--success-bg); color: #15803d; }
.badge-warning { background: var(--warning-bg); color: #b45309; }
.badge-danger { background: var(--danger-bg); color: #b91c1c; }
.badge-info { background: var(--info-bg); color: #0369a1; }
.badge-muted { background: var(--surface-subtle); color: var(--text-secondary); }
.badge-teal { background: var(--teal-soft); color: var(--teal-dark); }

/* ---------- SPLIT WORKSPACE (Left Filters + Right Dark-Teal Table) ---------- */
.workspace-split {
  display: grid;
  grid-template-columns: 245px 1fr;
  gap: 16px;
  align-items: start;
}
.filters-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  position: sticky;
  top: 0;
}
.filters-card h4 {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.filter-group { margin-bottom: 14px; }
.filter-group label {
  display: block;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.filter-chip-col {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.filter-chip {
  text-align: left;
  padding: 6px 10px;
  border-radius: 7px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
}
.filter-chip:hover { background: var(--surface-subtle); color: var(--text); }
.filter-chip.active {
  background: var(--teal-soft);
  color: var(--teal-dark);
  font-weight: 700;
  border-color: #a7f3d0;
}

/* ---------- DATA TABLE (Dark Teal Header) ---------- */
.table-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: visible;
  box-shadow: var(--shadow-xs);
}
.table-toolbar {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.table-scroll {
  overflow-x: auto;
  max-height: calc(100vh - 295px);
  overflow-y: auto;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.8px;
}
.data-table thead th {
  position: sticky;
  top: 0;
  z-index: 12;
  background: var(--teal-dark);
  color: #ffffff;
  font-weight: 600;
  font-size: 11.8px;
  text-align: left;
  padding: 11px 13px;
  white-space: nowrap;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.08);
}
.data-table thead th:first-child { border-top-left-radius: 0; }
.data-table tbody td {
  padding: 11px 13px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tbody tr:hover { background: #f8fafc; }
.data-table tbody tr:last-child td { border-bottom: none; }

.user-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-cell-info strong { display: block; font-size: 13px; color: var(--text); font-weight: 600; }
.user-cell-info small { display: block; font-size: 11.5px; color: var(--text-muted); }

/* Clickable Preview Name Link */
.name-preview-btn {
  border: none;
  background: transparent;
  padding: 0;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  color: var(--teal-dark);
  cursor: pointer;
  text-align: left;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.name-preview-btn:hover {
  color: var(--teal-hover);
  text-decoration: underline;
}
.name-preview-eye {
  opacity: 0.45;
  font-size: 11px;
  transition: opacity 0.15s;
}
.name-preview-btn:hover .name-preview-eye {
  opacity: 1;
}

/* Inline Row Icon Actions */
.action-icons-row {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
}
.icon-act-btn {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.14s ease;
  padding: 0;
}
.icon-act-btn svg { width: 14px; height: 14px; }
.icon-act-btn:hover { background: var(--teal-soft); color: var(--teal-dark); border-color: #a7f3d0; }
.icon-act-btn.edit:hover { background: var(--info-bg); color: #0369a1; border-color: #bae6fd; }
.icon-act-btn.key:hover { background: var(--teal-soft); color: var(--teal-dark); border-color: #a7f3d0; }
.icon-act-btn.warn:hover { background: var(--warning-bg); color: #b45309; border-color: #fde68a; }
.icon-act-btn.ok { color: #15803d; }
.icon-act-btn.ok:hover { background: var(--success-bg); border-color: #bbf7d0; }
.icon-act-btn.danger:hover { background: var(--danger-bg); color: var(--danger); border-color: #fecaca; }

.ticket-attach-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  padding: 5px 9px;
  border-radius: 7px;
  font-size: 11.5px;
  font-weight: 600;
  text-decoration: none;
  background: rgba(15, 23, 42, 0.06);
  color: var(--teal-dark);
}
.chat-bubble.mine .ticket-attach-link {
  background: rgba(255, 255, 255, 0.16);
  color: #ffffff;
}
.reply-attach-label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0 11px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--surface-subtle);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.reply-attach-label:hover { background: #e2e8f0; color: var(--text); }
.reply-attach-label.has-file {
  background: var(--teal-soft);
  border-color: #a7f3d0;
  color: var(--teal-dark);
}

/* Row Action Menu (⋮) */
.row-menu-wrap { position: relative; display: inline-block; }
.dots-btn {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.dots-btn:hover { background: var(--surface-subtle); color: var(--teal-dark); }
.row-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  width: 195px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-md);
  z-index: 50;
  padding: 4px;
}
.row-dropdown button {
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  padding: 8px 10px;
  border-radius: 7px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
}
.row-dropdown button:hover { background: var(--surface-subtle); }
.row-dropdown button.danger { color: var(--danger); }
.row-dropdown button.danger:hover { background: var(--danger-bg); }

/* Table Pagination Footer */
.table-pagination {
  padding: 11px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 12.5px;
  color: var(--text-muted);
}
.pagination-controls { display: flex; align-items: center; gap: 8px; }
.pagination-controls select { width: auto; padding: 4px 8px; font-size: 12px; }

/* ---------- SUPPORT TICKETS SPLIT PANE ---------- */
.tickets-shell {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 14px;
  min-height: 540px;
}
.ticket-list-pane {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.ticket-list-head {
  padding: 14px;
  border-bottom: 1px solid var(--border);
}
.segmented-pills {
  display: inline-flex;
  background: var(--surface-subtle);
  padding: 3px;
  border-radius: 8px;
  gap: 2px;
}
.seg-btn {
  border: none;
  background: transparent;
  padding: 5px 11px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  border-radius: 6px;
  cursor: pointer;
}
.seg-btn.active {
  background: var(--teal-dark);
  color: #fff;
}
.ticket-items {
  flex: 1;
  overflow-y: auto;
  max-height: 520px;
}
.ticket-item {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.12s;
}
.ticket-item:hover { background: #f8fafc; }
.ticket-item.active { background: var(--teal-soft); border-left: 3px solid var(--teal-dark); }
.ticket-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.ticket-item-subject {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.ticket-chat-pane {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.ticket-chat-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.ticket-messages-scroll {
  flex: 1;
  padding: 16px 18px;
  overflow-y: auto;
  max-height: 400px;
  background: #f8fafc;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.chat-bubble {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.45;
  border: 1px solid var(--border);
  background: #fff;
}
.chat-bubble.mine {
  align-self: flex-end;
  background: var(--teal-dark);
  color: #fff;
  border-color: var(--teal-dark);
}
.chat-bubble-meta {
  font-size: 11px;
  opacity: 0.78;
  margin-bottom: 4px;
  font-weight: 600;
}
.ticket-reply-bar {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  background: #fff;
}

/* ---------- SETTINGS HORIZONTAL TABS ---------- */
.settings-tabs {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.settings-tab-btn {
  padding: 10px 16px;
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
}
.settings-tab-btn.active {
  color: var(--teal-dark);
  border-bottom-color: var(--teal-dark);
}

/* ---------- MODALS ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(2px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-dialog {
  width: 100%;
  max-width: 580px;
  max-height: 90vh;
  background: var(--surface);
  border-radius: 14px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-dialog.wide {
  max-width: 780px;
}
.modal-dialog.xl {
  max-width: 960px;
}

.inquiry-followup-split {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 18px;
  align-items: start;
}

.readonly-info-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  user-select: none;
  cursor: default;
}

.readonly-info-card * {
  cursor: default;
}

.readonly-info-card a {
  cursor: pointer;
}

.ro-field {
  margin-bottom: 12px;
}
.ro-field:last-child {
  margin-bottom: 0;
}
.ro-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-muted);
  margin-bottom: 3px;
}
.ro-val {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  word-break: break-word;
  line-height: 1.45;
}

@media (max-width: 820px) {
  .inquiry-followup-split {
    grid-template-columns: 1fr;
  }
}

.followup-timeline {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 250px;
  overflow-y: auto;
  padding-right: 4px;
}
.followup-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-left: 3px solid var(--teal-dark);
  border-radius: 8px;
  padding: 9px 12px;
}
.followup-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
  font-size: 11.5px;
  color: var(--text-muted);
}
.modal-header {
  padding: 14px 18px;
  background: var(--teal-dark);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h3 { font-size: 15px; font-weight: 700; }
.modal-close {
  border: none;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  cursor: pointer;
}
.modal-body {
  padding: 18px;
  overflow-y: auto;
}

.whitelabel-preview-box {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  background: linear-gradient(135deg, #f0fdf4 0%, #ffffff 100%);
  margin-bottom: 14px;
}
.license-key-box {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 11.5px;
  background: var(--surface-subtle);
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  word-break: break-all;
  margin: 8px 0;
}

.code-chip {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 11.5px;
  background: var(--surface-subtle);
  padding: 2px 6px;
  border-radius: 5px;
  color: var(--teal-dark);
}

/* ---------- RESPONSIVE ---------- */
@media (max-width: 1150px) {
  .grid-7, .grid-6, .grid-8, .grid-9 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .workspace-split { grid-template-columns: 1fr; }
  .filters-card { position: static; }
  .grid-charts { grid-template-columns: 1fr; }
  .tickets-shell { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .sidebar { transform: translateX(-100%); transition: transform 0.2s; }
  .sidebar.mobile-open { transform: translateX(0); }
  .main-wrap { margin-left: 0; }
  .mobile-menu-btn { display: inline-flex; }
  .topbar-search { display: none; }
  .hide-sm { display: none; }
  .grid-4, .grid-3, .grid-5, .grid-6, .grid-8, .grid-9, .grid-2, .form-grid-2, .form-grid-3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 540px) {
  .grid-4, .grid-3, .grid-5, .grid-6, .grid-7, .grid-8, .grid-9, .grid-2, .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; }
}
