:root {
  --brand-cyan: #2FE3E9;
  --brand-blue: #2F7BFF;
  --brand-violet: #6C2BFF;
  --brand-magenta: #FF2F92;
  --bg-0: #040816;
  --bg-1: #071127;
  --bg-2: #0B1733;
  --panel: rgba(10, 20, 45, 0.93);
  --panel-2: rgba(13, 25, 54, 0.95);
  --border: rgba(90, 130, 220, 0.18);
  --text: #EAF1FF;
  --muted: #98A8C7;

  --radius-lg: 18px;
  --radius-md: 12px;
  --shadow-lg: 0 20px 46px rgba(2, 7, 20, 0.58);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--text);
  font-family: Inter, "Segoe UI", Roboto, Arial, sans-serif;
  min-height: 100vh;
  background: linear-gradient(165deg, var(--bg-0), var(--bg-1) 48%, var(--bg-2));
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -2;
  background-image:
    repeating-linear-gradient(0deg, rgba(255,255,255,0.034) 0 1px, transparent 1px 40px),
    repeating-linear-gradient(90deg, rgba(255,255,255,0.034) 0 1px, transparent 1px 40px),
    radial-gradient(140% 85% at 52% 112%, rgba(47,123,255,0.11), transparent 72%);
  opacity: .22;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  background: radial-gradient(120% 70% at 50% 120%, rgba(108,43,255,0.08), transparent 78%);
  opacity: .11;
}

.app-layout {
  position: relative;
  z-index: 0;
  isolation: isolate;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
}

.app-layout::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    radial-gradient(900px 420px at 80% -10%, rgba(47,123,255,0.1), transparent 68%),
    radial-gradient(860px 420px at 102% 8%, rgba(108,43,255,0.1), transparent 72%),
    repeating-linear-gradient(0deg, rgba(180, 205, 255, 0.075) 0 1px, transparent 1px 36px),
    repeating-linear-gradient(90deg, rgba(180, 205, 255, 0.075) 0 1px, transparent 1px 36px);
  opacity: .44;
}

.app-sidebar {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  border-right: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(7,13,29,0.92), rgba(8,14,34,0.88));
}

.brand {
  display: block;
  margin-bottom: 12px;
  padding: 9px 9px 7px;
  border: 1px solid rgba(120, 158, 236, 0.10);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(7, 14, 31, 0.94), rgba(6, 12, 28, 0.92));
  box-shadow: inset 0 0 0 1px rgba(14, 28, 58, 0.35), inset 0 -5px 12px rgba(2, 8, 22, 0.20);
}
.brand img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: 150px;
  object-fit: contain;
  object-position: left center;
}
.brand h1 { margin: 0; font-size: 20px; line-height: 1.1; color: var(--text); }
.brand p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.brand-gradient { color: var(--text); }

.sidebar-nav, .top-nav {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.sidebar-nav a,
.top-nav a,
.menu-link,
.button-link {
  color: var(--text);
  text-decoration: none;
  border: 1px solid rgba(120, 158, 236, 0.14);
  border-radius: 11px;
  padding: 10px 13px;
  background: rgba(255,255,255,0.02);
  font-weight: 700;
  font-size: 13px;
  transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease, background-color .2s ease, filter .2s ease;
}

.sidebar-nav a.active,
.top-nav a.active,
.menu-link.active {
  border-color: rgba(88, 129, 216, 0.30);
  box-shadow: inset 0 0 0 1px rgba(76, 117, 208, 0.18);
  background: rgba(48, 74, 132, 0.24);
}


.sidebar-footer {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid rgba(120, 158, 236, 0.10);
}

.sidebar-footer a,
.sidebar-footer .menu-link,
.sidebar-footer .button-link {
  display: block;
  color: var(--text);
  text-decoration: none;
}

.main-shell {
  position: relative;
  z-index: 1;
  padding: 18px 24px 40px;
  background: transparent;
}
.utility-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.utility-bar h2 { margin: 0; font-size: 28px; color: var(--text); }
.utility-bar p { margin: 4px 0 0; color: var(--muted); }

.card, .panel, .login-card, .modal {
  background: var(--panel);
  border: 1px solid rgba(120, 158, 236, 0.24);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(2px);
}

input, select, textarea, button { font: inherit; }
input, select, textarea {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid rgba(90, 130, 220, 0.3);
  color: var(--text);
  border-radius: var(--radius-md);
  padding: 10px 12px;
}

input[type="date"] {
  color-scheme: dark;
}

/* Keep calendar glyph visible on dark backgrounds across Chrome/WebKit variants. */
input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(1) brightness(2.2) contrast(1.15) drop-shadow(0 0 0.01px rgba(255,255,255,0.95)) !important;
  opacity: 1 !important;
  cursor: pointer;
}

input[type="date"]::-webkit-clear-button,
input[type="date"]::-webkit-inner-spin-button {
  filter: invert(1) brightness(2.2) contrast(1.15) !important;
  opacity: 1 !important;
}

button, .btn {
  border-radius: var(--radius-md);
  border: 1px solid rgba(47, 227, 233, 0.28);
  color: var(--text);
  background: rgba(9, 20, 44, 0.88);
  padding: 10px 14px;
  font-weight: 700;
  cursor: pointer;
  transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease, filter .2s ease, background-color .2s ease;
}

button[type="submit"], .btn-primary, #refreshBtn, #exportBtn, #retryBtn, .button-link {
  border: 1px solid rgba(108, 43, 255, 0.5);
  color: #04142d;
  background: linear-gradient(120deg, var(--brand-cyan), var(--brand-violet));
}

.panel { padding: 20px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.meta, .muted, .hint, .sub { color: var(--muted); }

@media (hover: hover) {
  .menu-link:hover,
  .button-link:hover,
  button:hover,
  .btn:hover {
    transform: translateY(-1px);
    filter: brightness(1.03);
    box-shadow: 0 8px 20px rgba(4, 12, 30, 0.34);
  }
}

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; position: relative; z-index:1; }
.login-card { width: min(1050px, 96vw); display:grid; grid-template-columns: 1fr 1fr; overflow:hidden; }
.login-hero { padding: 44px 38px; background: linear-gradient(150deg, rgba(47,227,233,.10), rgba(108,43,255,.06), rgba(47,123,255,.06)); }
.login-hero img { width: min(360px, 100%); }
.login-hero h1 { margin: 22px 0 10px; font-size: 34px; color: var(--text); }
.login-form { padding: 38px; display:flex; align-items:center; }
.login-form form { width: 100%; }
.login-form label { display:block; margin: 0 0 6px; color: var(--muted); font-size: 13px; }
.login-form input { margin-bottom: 12px; }
.error { color: #fca5a5; margin-top: 8px; }

.page-grid { display:grid; gap:14px; grid-template-columns: 1.15fr .85fr; align-items: start; }

@media (max-width: 1020px) {
  .app-layout { grid-template-columns: 1fr; }
  .app-sidebar { border-right: 0; border-bottom: 1px solid var(--border); }
  .sidebar-nav, .top-nav { flex-direction: row; flex-wrap: wrap; }
  .brand img { max-width: 100%; height: 120px; }
  .login-card { grid-template-columns: 1fr; }
  .page-grid { grid-template-columns: 1fr; }
}

.leads-table { width:100%; border-collapse: collapse; font-size:13px; }
.leads-table th, .leads-table td { border-bottom:1px solid rgba(90,130,220,.24); padding: 10px 8px; text-align:left; vertical-align: top; }
.banner { margin:10px 0; padding:10px 12px; border-radius:10px; display:none; }
.banner.error { display:flex; justify-content:space-between; gap:8px; border:1px solid var(--brand-magenta); background:rgba(255,47,146,.12); }
.empty-state { margin:18px 0; padding:14px; border:1px dashed rgba(90,130,220,.35); border-radius:12px; }
.badge { display:inline-block; border:1px solid rgba(90,130,220,.45); border-radius:999px; padding:2px 8px; font-size:12px; text-transform:uppercase; }
.badge.INTERESTED { border-color: var(--brand-cyan); color: #9bf8ff; }
.badge.WARM { border-color: var(--brand-violet); color: #c9b7ff; }
.badge.FOLLOW_UP { border-color: var(--brand-blue); color: #b8d7ff; background: rgba(47,123,255,.12); }
.badge.COLD { border-color:#94a3b8; color:#cbd5e1; }
.badge.DO_NOT_CONTACT { border-color:var(--brand-magenta); color:#f9a8d4; }
.settings-section { border:1px solid var(--border); border-radius:12px; margin-top:12px; background:rgba(255,255,255,.02); }
.settings-section summary { cursor:pointer; padding:12px; font-weight:700; }
.settings-body {
  padding: 6px 14px 16px;
  display: grid;
  gap: 14px;
}

@media (prefers-reduced-motion: reduce) {
  .menu-link,
  .button-link,
  button,
  .btn {
    transition: none !important;
    transform: none !important;
    animation: none !important;
  }
}
.settings-body > div,
.settings-block {
  display: grid;
  gap: 8px;
}
.settings-subsection {
  border: 1px solid rgba(90, 130, 220, 0.24);
  border-radius: 10px;
  background: rgba(255,255,255,.02);
}
.settings-subsection summary {
  padding: 10px 12px;
  font-weight: 600;
  color: #d6e1f7;
}
.settings-subsection .settings-block {
  padding: 2px 12px 12px;
}
.settings-body textarea {
  min-height: 180px;
  line-height: 1.5;
  resize: none;
  overflow-y: hidden;
}
.settings-actions { display:flex; gap:12px; align-items:center; margin-top:14px; }
.switch-field {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
  width: fit-content;
}
.switch-field input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}
.switch-label {
  color: var(--text);
}
.switch-track {
  position: relative;
  width: 42px;
  height: 24px;
  border-radius: 999px;
  border: 1px solid rgba(90, 130, 220, 0.45);
  background: rgba(9, 20, 44, 0.88);
  transition: background .2s ease, border-color .2s ease;
}
.switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: #cbd5e1;
  transition: transform .2s ease, background .2s ease;
}
.switch-field input[type="checkbox"]:checked + .switch-track {
  background: linear-gradient(120deg, var(--brand-cyan), var(--brand-violet));
  border-color: rgba(108, 43, 255, 0.6);
}
.switch-field input[type="checkbox"]:checked + .switch-track .switch-thumb {
  transform: translateX(18px);
  background: #071127;
}
.switch-field input[type="checkbox"]:focus-visible + .switch-track {
  outline: 2px solid rgba(47, 227, 233, 0.85);
  outline-offset: 2px;
}
.switch-field.is-disabled {
  cursor: not-allowed;
  opacity: 0.65;
}
.switch-field input[type="checkbox"]:disabled + .switch-track {
  border-color: rgba(148, 163, 184, 0.35);
  background: rgba(30, 41, 59, 0.7);
}
.switch-field input[type="checkbox"]:disabled + .switch-track .switch-thumb {
  background: rgba(203, 213, 225, 0.8);
}
input[readonly] {
  color: #d6e1f7;
  background: rgba(255, 255, 255, 0.03);
  border-color: rgba(90, 130, 220, 0.22);
}
.status-pill {
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.status-led {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #f87171;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.12), 0 0 10px rgba(248, 113, 113, 0.42);
  flex: 0 0 auto;
}
.status-pill.is-connected .status-led {
  background: #34d399;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.1), 0 0 10px rgba(52, 211, 153, 0.4);
}
.status-pill.is-not-connected .status-led,
.status-pill.is-unknown .status-led {
  background: #f87171;
}
.status-led.is-pulsing,
.status-pill .status-led {
  animation: statusPulse 1.9s ease-in-out infinite;
}
@keyframes statusPulse {
  0% { transform: scale(1); opacity: 0.9; }
  50% { transform: scale(1.16); opacity: 1; }
  100% { transform: scale(1); opacity: 0.9; }
}
