:root {
  --bg-canvas: #dfeef8;
  --surface-card: rgba(244, 250, 255, 0.82);
  --surface-elevated: rgba(255, 255, 255, 0.92);
  --border-cyan: rgba(125, 211, 252, 0.75);
  --border-glow: rgba(56, 189, 248, 0.85);
  --neon-cyan: #0284c7;
  --sky-cyan: #0369a1;
  --royal-blue: #2563eb;
  --emerald: #10b981;
  --emerald-light: #047857;
  --amber: #f59e0b;
  --amber-light: #b45309;
  --crimson: #ef4444;
  --crimson-light: #b91c1c;
  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;
  --radius-lg: 14px;
  --radius-md: 10px;
  --radius-sm: 8px;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-canvas);
  background-image:
    radial-gradient(circle at 18% 12%, rgba(255, 255, 255, 0.9) 0%, transparent 38%),
    radial-gradient(circle at 85% 20%, rgba(186, 230, 253, 0.7) 0%, transparent 42%),
    radial-gradient(circle at 50% 90%, rgba(224, 242, 254, 0.85) 0%, transparent 50%),
    linear-gradient(rgba(56, 189, 248, 0.09) 1px, transparent 1px),
    linear-gradient(90deg, rgba(56, 189, 248, 0.09) 1px, transparent 1px),
    linear-gradient(135deg, #d8ebf7 0%, #ebf5fc 48%, #d4e9f7 100%);
  background-size: 100% 100%, 100% 100%, 100% 100%, 32px 32px, 32px 32px, 100% 100%;
  background-attachment: fixed;
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.45;
}

/* Scrollbars */
::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}
::-webkit-scrollbar-track {
  background: rgba(224, 242, 254, 0.6);
}
::-webkit-scrollbar-thumb {
  background: rgba(56, 189, 248, 0.45);
  border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(2, 132, 199, 0.7);
}

.hidden {
  display: none !important;
}

/* Auth & Initial Setup Fullscreen Overlay */
.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

/* Futuristic Frosted HUD Glass Cards */
.glass-card {
  position: relative;
  background: linear-gradient(165deg, rgba(255, 255, 255, 0.88) 0%, rgba(235, 246, 255, 0.76) 100%);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid rgba(147, 197, 253, 0.75);
  border-radius: var(--radius-lg);
  box-shadow:
    0 10px 30px rgba(15, 23, 42, 0.06),
    0 2px 8px rgba(14, 165, 233, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.95);
}

/* HUD Tech Top Glow Line & Corner Brackets on Cards */
.glass-card::before {
  content: '';
  position: absolute;
  top: -1px;
  left: 22px;
  right: 22px;
  height: 2px;
  background: linear-gradient(90deg, transparent 0%, rgba(56, 189, 248, 0.75) 20%, rgba(255, 255, 255, 0.95) 50%, rgba(56, 189, 248, 0.75) 80%, transparent 100%);
  pointer-events: none;
  border-radius: 2px;
}

.glass-card::after {
  content: '';
  position: absolute;
  inset: 6px;
  border-radius: 10px;
  pointer-events: none;
  background:
    linear-gradient(to right, rgba(100, 116, 139, 0.35) 2px, transparent 2px) 0 100% / 10px 10px no-repeat,
    linear-gradient(to top, rgba(100, 116, 139, 0.35) 2px, transparent 2px) 0 100% / 10px 10px no-repeat,
    linear-gradient(to left, rgba(100, 116, 139, 0.35) 2px, transparent 2px) 100% 100% / 10px 10px no-repeat,
    linear-gradient(to top, rgba(100, 116, 139, 0.35) 2px, transparent 2px) 100% 100% / 10px 10px no-repeat,
    linear-gradient(to right, rgba(56, 189, 248, 0.45) 2px, transparent 2px) 0 0 / 10px 10px no-repeat,
    linear-gradient(to bottom, rgba(56, 189, 248, 0.45) 2px, transparent 2px) 0 0 / 10px 10px no-repeat;
}

.auth-card {
  width: 100%;
  max-width: 480px;
  padding: 32px;
}

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

.polygon-emblem {
  width: 42px;
  height: 42px;
  border-radius: 11px;
  background: linear-gradient(135deg, rgba(224, 242, 254, 0.95), rgba(186, 230, 253, 0.85));
  border: 1.5px solid rgba(56, 189, 248, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 16px rgba(56, 189, 248, 0.35), inset 0 1px 0 #ffffff;
  color: #0284c7;
  flex-shrink: 0;
}

.brand-title {
  font-size: 1.12rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #0f172a;
}

.brand-subtitle {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: #64748b;
  text-transform: uppercase;
}

/* App Shell */
.app-shell {
  display: grid;
  grid-template-columns: 245px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: linear-gradient(180deg, rgba(235, 246, 254, 0.9) 0%, rgba(220, 238, 250, 0.84) 100%);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-right: 1px solid rgba(147, 197, 253, 0.75);
  box-shadow: 4px 0 24px rgba(14, 116, 144, 0.06);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 30;
}

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-top: 8px;
  flex: 1;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 14px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: transparent;
  color: #334155;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s ease;
  text-align: left;
}

.nav-btn svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  stroke: #475569;
}

.nav-btn:hover {
  color: #0f172a;
  background: rgba(255, 255, 255, 0.65);
  border-color: rgba(125, 211, 252, 0.6);
}

.nav-btn.active {
  background: linear-gradient(90deg, rgba(186, 230, 253, 0.75) 0%, rgba(240, 249, 255, 0.95) 100%);
  color: #0f172a;
  font-weight: 700;
  border-color: rgba(56, 189, 248, 0.85);
  box-shadow:
    0 4px 16px rgba(56, 189, 248, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.nav-btn.active svg {
  stroke: #0284c7;
}

.sidebar-footer {
  padding-top: 14px;
  border-top: 1px solid rgba(147, 197, 253, 0.6);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Main Workspace & Executive Topbar */
.main-area {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 25;
  background: linear-gradient(90deg, rgba(235, 246, 254, 0.9) 0%, rgba(242, 249, 255, 0.88) 100%);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(147, 197, 253, 0.75);
  box-shadow: 0 4px 20px rgba(14, 116, 144, 0.05);
  padding: 10px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 280px;
}

.ai-pill-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 13px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 600;
  color: #0f766e;
  background: linear-gradient(135deg, rgba(204, 251, 241, 0.85), rgba(224, 242, 254, 0.9));
  border: 1px solid rgba(45, 212, 191, 0.55);
  box-shadow: inset 0 1px 0 #ffffff;
  white-space: nowrap;
}

.quick-search-wrap {
  position: relative;
  flex: 1;
  max-width: 400px;
}

.quick-search-input {
  width: 100%;
  padding: 8px 14px 8px 36px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(125, 211, 252, 0.85);
  color: #0f172a;
  font-size: 0.83rem;
  outline: none;
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.04);
  transition: all 0.2s ease;
}

.quick-search-input::placeholder {
  color: #64748b;
}

.quick-search-input:focus {
  border-color: #0284c7;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.35);
}

.quick-search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  color: #64748b;
  pointer-events: none;
}

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

@keyframes pulseBeacon {
  0% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  }
  70% {
    transform: scale(1);
    box-shadow: 0 0 0 7px rgba(16, 185, 129, 0);
  }
  100% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
  }
}

.status-beacon-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 13px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(254, 249, 195, 0.75), rgba(220, 252, 231, 0.85));
  border: 1px solid rgba(134, 239, 172, 0.75);
  font-size: 0.78rem;
  font-weight: 600;
  color: #1e293b;
  box-shadow: inset 0 1px 0 #ffffff;
}

.beacon-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #10b981;
  animation: pulseBeacon 2s infinite;
}

.beacon-dot.idle {
  background: #f59e0b;
}

.beacon-dot.inactive {
  background: #ef4444;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 700;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.18s ease;
  white-space: nowrap;
  color: #0f172a;
}

.btn-electric {
  background: linear-gradient(180deg, #e0f7fa 0%, #ccfbf1 100%);
  border-color: #5eead4;
  color: #0f766e;
  box-shadow: 0 2px 8px rgba(20, 184, 166, 0.15), inset 0 1px 0 #ffffff;
}
.btn-electric:hover {
  background: linear-gradient(180deg, #ccfbf1 0%, #99f6e4 100%);
  box-shadow: 0 4px 12px rgba(20, 184, 166, 0.25);
}

.btn-emerald {
  background: linear-gradient(180deg, #d1fae5 0%, #a7f3d0 100%);
  border-color: #34d399;
  color: #065f46;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.18), inset 0 1px 0 #ffffff;
}
.btn-emerald:hover {
  background: linear-gradient(180deg, #a7f3d0 0%, #6ee7b7 100%);
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.28);
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.8);
  border-color: rgba(147, 197, 253, 0.75);
  color: #334155;
  box-shadow: inset 0 1px 0 #ffffff;
}
.btn-ghost:hover {
  color: #0f172a;
  border-color: #38bdf8;
  background: #ffffff;
}

.btn-danger {
  background: rgba(254, 226, 226, 0.85);
  border-color: rgba(248, 113, 113, 0.65);
  color: #b91c1c;
}

.btn-sm {
  padding: 5px 11px;
  font-size: 0.76rem;
}

.profile-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 4px 12px 4px 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(147, 197, 253, 0.75);
  box-shadow: inset 0 1px 0 #ffffff;
}

.avatar-circle {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #38bdf8, #0284c7);
  color: #ffffff;
  font-weight: 800;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.avatar-online-dot {
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
  border: 1.5px solid #ffffff;
}

.profile-meta {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.profile-name {
  font-size: 0.78rem;
  font-weight: 700;
  color: #0f172a;
}

.profile-role {
  font-size: 0.65rem;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Content Container */
.view-container {
  padding: 20px 24px 48px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.section-title {
  font-size: 1.45rem;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-subtitle {
  font-size: 0.85rem;
  color: #334155;
  margin-top: 2px;
}

/* KPI Grid & Sparkline Graphics */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
}

.kpi-card {
  padding: 16px 18px 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 6px;
  position: relative;
  overflow: hidden;
  min-height: 132px;
}

.kpi-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  z-index: 2;
}

.kpi-label {
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #1e293b;
}

.kpi-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}
.kpi-card.cyan .kpi-dot {
  background: #38bdf8;
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.8);
}
.kpi-card.emerald .kpi-dot {
  background: #10b981;
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.8);
}
.kpi-card.amber .kpi-dot {
  background: #f59e0b;
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.8);
}
.kpi-card.crimson .kpi-dot {
  background: #ef4444;
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.8);
}

.kpi-body-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
  z-index: 2;
  margin: 2px 0;
}

.kpi-value {
  font-size: 2.35rem;
  font-weight: 800;
  line-height: 1;
  color: #0f172a;
  letter-spacing: -0.02em;
}

.kpi-sparkline {
  width: 135px;
  height: 52px;
  flex-shrink: 0;
  overflow: visible;
}

.kpi-foot-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  z-index: 2;
}

.kpi-foot {
  font-size: 0.76rem;
  font-weight: 500;
  color: #334155;
}

.hud-stripes {
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 1px;
  color: rgba(56, 189, 248, 0.65);
  user-select: none;
}

/* Dashboard Dual Split Row */
.dashboard-split-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
  gap: 16px;
}

/* Tables & Grids */
.panel-card {
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.panel-title {
  font-size: 1.05rem;
  font-weight: 800;
  color: #0f172a;
  display: flex;
  align-items: center;
  gap: 8px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

table.crm-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.83rem;
}

table.crm-table th {
  text-align: left;
  padding: 9px 12px;
  color: #334155;
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  border-top: 1px solid rgba(148, 163, 184, 0.28);
  border-bottom: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(219, 234, 254, 0.45);
  white-space: nowrap;
}

table.crm-table td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.22);
  color: #0f172a;
  vertical-align: middle;
}

table.crm-table tbody tr:hover {
  background: rgba(186, 230, 253, 0.32);
}

/* Status & State Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
}

.badge-cyan {
  background: rgba(186, 230, 253, 0.75);
  color: #0369a1;
  border: 1px solid rgba(56, 189, 248, 0.6);
}

.badge-emerald {
  background: rgba(167, 243, 208, 0.8);
  color: #047857;
  border: 1px solid rgba(16, 185, 129, 0.55);
}

.badge-amber {
  background: rgba(253, 230, 138, 0.85);
  color: #b45309;
  border: 1px solid rgba(245, 158, 11, 0.55);
}

.badge-crimson {
  background: rgba(254, 202, 202, 0.88);
  color: #b91c1c;
  border: 1px solid rgba(248, 113, 113, 0.75);
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.22);
}

.badge-muted {
  background: rgba(226, 232, 240, 0.85);
  color: #475569;
  border: 1px solid rgba(148, 163, 184, 0.5);
}

/* Filter Bar */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* Forms & Inputs */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group.full {
  grid-column: 1 / -1;
}

label.form-label {
  font-size: 0.76rem;
  font-weight: 700;
  color: #334155;
}

.form-control {
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(125, 211, 252, 0.85);
  color: #0f172a;
  font-size: 0.84rem;
  outline: none;
  font-family: inherit;
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.03);
}

.form-control:focus {
  border-color: #0284c7;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.3);
}

textarea.form-control {
  min-height: 82px;
  resize: vertical;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-window {
  width: 100%;
  max-width: 720px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  background: linear-gradient(165deg, rgba(255, 255, 255, 0.96) 0%, rgba(238, 248, 255, 0.94) 100%);
}

.modal-window.wide {
  max-width: 960px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(147, 197, 253, 0.7);
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 800;
  color: #0f172a;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 14px;
  border-top: 1px solid rgba(147, 197, 253, 0.7);
}

/* Stale Lead Alert Banner */
.stale-alert-card {
  border: 1px solid rgba(252, 165, 165, 0.85);
}

/* Toast Notification */
.toast-container {
  position: fixed;
  bottom: 22px;
  right: 22px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  padding: 12px 18px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.96);
  border: 1.5px solid #0284c7;
  color: #0f172a;
  font-size: 0.84rem;
  font-weight: 600;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.15);
}

.toast.error {
  border-color: #ef4444;
  color: #b91c1c;
}

.lead-summary-banner {
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: rgba(224, 242, 254, 0.65);
  border: 1px solid rgba(125, 211, 252, 0.85);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 0.82rem;
}

.timeline-item {
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(147, 197, 253, 0.65);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

@media (max-width: 920px) {
  .app-shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: relative;
    height: auto;
  }
  .dashboard-split-grid {
    grid-template-columns: 1fr;
  }
}
