/* ============================================================
   TACTICAL -- Editorial Intensity theme (The Digital Headhunter brand system)
   Dark-canvas only for now -- light mode is a deliberate later pass.
   ============================================================ */
:root {
  --bg: #060608;
  --surface: #0c0c10;
  --surface2: #101014;
  --border: rgba(255, 255, 255, 0.08);
  --border-soft: rgba(255, 255, 255, 0.05);

  --crimson: #c9394f;
  --crimson-dim: rgba(201, 57, 79, 0.12);
  --steel: #5b9bbf;
  --steel-dim: rgba(91, 155, 191, 0.12);
  --green: #2ea86e;
  --green-dim: rgba(46, 168, 110, 0.12);
  --gold: #d4a843;
  --gold-dim: rgba(212, 168, 67, 0.12);
  --warn: #e8963c;
  --warn-dim: rgba(232, 150, 60, 0.12);

  --white: #f0f0f0;
  --silver: #d8d8d8;
  --dim: #8a8a8f;
  --dim2: #606066;

  /* Chart-only data hues -- never reused as status/semantic colors elsewhere */
  --data-violet: #8f7ad1;
  --data-teal: #45ab9e;
  --data-terracotta: #d17a63;
  --data-rose: #c97a9a;

  --radius: 8px;
  --font-display: 'Unbounded', sans-serif;
  --font-body: 'DM Sans', sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  font-weight: 300;
  margin: 0;
  background: var(--bg);
  color: var(--white);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: var(--font-display);
  text-wrap: balance;
}

/* ---------- Login page (index.html) -- kept simple, still on-brand ---------- */
.page-center {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.4);
  padding: 36px;
  width: 100%;
  max-width: 380px;
}

.card h1 {
  font-size: 18px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: -0.01em;
  margin: 0 0 20px;
}

label {
  display: block;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--dim);
  margin-top: 16px;
}

input {
  width: 100%;
  padding: 11px 12px;
  margin-top: 6px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--white);
  font-family: var(--font-body);
  font-size: 15px;
}

input:focus-visible {
  outline: 2px solid var(--steel);
  outline-offset: 1px;
}

button {
  width: 100%;
  margin-top: 20px;
  padding: 12px;
  background: var(--steel);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
}

button:hover {
  background: #4d87a8;
  transform: translateY(-1px);
}

button.secondary {
  background: var(--surface2);
  color: var(--silver);
  border: 1px solid var(--border);
}

button.secondary:hover {
  background: #16161c;
  transform: none;
  border-color: rgba(255, 255, 255, 0.2);
}

.error-message {
  margin-top: 14px;
  padding: 10px 12px;
  background: var(--crimson-dim);
  color: var(--crimson);
  border: 1px solid rgba(201, 57, 79, 0.3);
  border-radius: 6px;
  font-size: 13px;
  display: none;
}

@media (max-width: 480px) {
  .card { padding: 24px; }
}

/* ---------- Dashboard shell ---------- */
.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 28px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.dashboard-header button {
  width: auto;
  margin: 0;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-brand .brand-mark {
  width: 28px;
  height: auto;
  display: block;
  flex-shrink: 0;
}

.header-brand .brand-name {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

#welcomeText {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--dim);
  font-weight: 500;
  letter-spacing: 0.02em;
}

/* Client identity chip -- logo falls back to initials on a neutral surface until one's uploaded */
.client-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 30px;
  padding: 6px 16px 6px 6px;
}

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--surface2);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  color: var(--dim);
  overflow: hidden;
  flex-shrink: 0;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.client-chip .name {
  font-size: 13px;
  color: var(--silver);
  font-weight: 500;
}

.dashboard-body {
  padding: 32px 28px 60px;
  max-width: 1180px;
  margin: 0 auto;
}

.viewing-as-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 28px;
  background: var(--surface);
  color: var(--silver);
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}

.viewing-as-banner select {
  padding: 6px 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--white);
  font-family: var(--font-mono);
  font-size: 12px;
  margin-right: 12px;
}

.viewing-as-banner .back-link {
  color: var(--steel);
  font-weight: 600;
  text-decoration: none;
  font-size: 13px;
}

.viewing-as-banner .back-link:hover {
  text-decoration: underline;
}

/* ---------- Page-level sync header: staff-only status badge + client-facing freshness note ---------- */
.sync-header {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 28px;
}

.freshness-note {
  margin: 0;
  max-width: 640px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--dim);
}

/* ---------- All-systems sync badge (page-level; gold only when every source is fresh) ---------- */
.all-synced-badge {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px 8px 10px;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border-radius: 30px;
}

.all-synced-badge.ok {
  color: var(--gold);
  background: var(--gold-dim);
  border: 1px solid rgba(212, 168, 67, 0.3);
  box-shadow: 0 0 24px rgba(212, 168, 67, 0.12);
}

.all-synced-badge.warn {
  color: var(--warn);
  background: var(--warn-dim);
  border: 1px solid rgba(232, 150, 60, 0.3);
}

.all-synced-badge strong {
  font-weight: 600;
}

/* ---------- Section headers ---------- */
.eyebrow {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.eyebrow .dash {
  width: 18px;
  height: 1px;
  background: var(--theme, var(--steel));
}

.eyebrow span {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--theme, var(--steel));
}

.channel {
  --theme: var(--steel);
  --theme-dim: var(--steel-dim);
  margin-bottom: 48px;
}

.channel.theme-crimson { --theme: var(--crimson); --theme-dim: var(--crimson-dim); }
.channel.theme-green { --theme: var(--green); --theme-dim: var(--green-dim); }

.section-title {
  font-size: 22px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: -0.01em;
  margin: 0 0 20px;
}

.subsection-title {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--dim);
  margin: 36px 0 16px;
}

/* ---------- Sync status (glow-dot language shared by the badge above and every status pill) ---------- */
.glow-dot {
  position: relative;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 10px 1px currentColor;
  flex-shrink: 0;
  display: inline-block;
}

.glow-dot.pulsing::after {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 1px solid currentColor;
  opacity: 0.6;
  animation: orbPing 2.4s ease-out infinite;
}

@keyframes orbPing {
  0% { transform: scale(0.6); opacity: 0.7; }
  100% { transform: scale(2.4); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .glow-dot.pulsing::after { animation: none; }
}

.last-synced-bar {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--green);
  margin-bottom: 16px;
}

.last-synced-bar .glow-dot { color: var(--green); }

.stale-banner {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  padding: 8px 14px 8px 10px;
  background: var(--warn-dim);
  color: var(--warn);
  border: 1px solid rgba(232, 150, 60, 0.3);
  border-radius: 30px;
  font-family: var(--font-mono);
  font-size: 12px;
}

.stale-banner .glow-dot { color: var(--warn); }

/* ---------- Stat tiles ---------- */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 18px 18px;
  overflow: hidden;
  transition: transform 0.25s, border-color 0.25s, box-shadow 0.25s;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--theme, var(--steel)), transparent);
  opacity: 0.4;
  transition: opacity 0.3s;
}

.stat-card:hover {
  transform: translateY(-3px);
  border-color: color-mix(in srgb, var(--theme, var(--steel)) 35%, transparent);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.4), 0 0 0 1px color-mix(in srgb, var(--theme, var(--steel)) 15%, transparent);
}

.stat-card:hover::before { opacity: 1; }

.stat-card .stat-value {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 28px;
  color: var(--white);
  font-variant-numeric: tabular-nums;
  margin-bottom: 6px;
}

.stat-card .stat-label {
  font-size: 11px;
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: 0.09em;
}

/* "Not tracked" (e.g. HeyReach leads) reads as genuinely different from a real zero */
.stat-card.is-na {
  opacity: 0.5;
  border-style: dashed;
}

.stat-card.is-na::before { display: none; }

.stat-card.is-na .stat-value {
  font-weight: 500;
  color: var(--dim);
}

/* ---------- Panels (charts, tables) ---------- */
.chart-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
}

.chart-container h3 {
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--dim);
  margin: 0 0 16px;
}

.empty-state, .error-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 30px;
  text-align: center;
  color: var(--dim);
}

.error-box {
  color: var(--crimson);
  border-color: rgba(201, 57, 79, 0.25);
}

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

.filter-bar label {
  display: inline;
  margin: 0;
  font-size: 12px;
  color: var(--dim);
}

.filter-bar select, .filter-bar input[type="date"] {
  padding: 7px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--silver);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.filter-bar select:focus-visible, .filter-bar input:focus-visible {
  outline: 2px solid var(--theme, var(--steel));
  outline-offset: 1px;
}

/* ---------- Chart legend (drives Chart.js dataset visibility) ---------- */
.chart-legend {
  display: flex;
  gap: 14px;
  margin: 0 0 16px;
  flex-wrap: wrap;
}

.legend-chip {
  display: flex;
  align-items: center;
  gap: 7px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--silver);
  cursor: pointer;
  padding: 5px 10px 5px 8px;
  border-radius: 20px;
  border: 1px solid transparent;
  background: none;
  transition: all 0.15s;
}

.legend-chip:hover { background: rgba(255, 255, 255, 0.04); }

.legend-chip .swatch {
  width: 9px;
  height: 9px;
  border-radius: 2px;
  flex-shrink: 0;
}

.legend-chip.off {
  color: var(--dim2);
  opacity: 0.55;
}

.legend-chip.off .swatch { opacity: 0.35; }

.chart-note {
  font-size: 11px;
  color: var(--dim2);
  margin: -6px 0 16px;
}

/* ---------- Tables ---------- */
.table-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px;
  margin-bottom: 24px;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  white-space: nowrap;
}

.data-table th, .data-table td {
  text-align: left;
  padding: 14px 16px;
}

.data-table th {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--dim2);
  border-bottom: 1px solid var(--border);
  user-select: none;
  font-weight: 600;
}

.data-table td {
  color: var(--silver);
  border-top: 1px solid var(--border-soft);
}

.data-table tbody tr:first-child td { border-top: none; }

.inline-edit-input {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--white);
  padding: 6px 8px;
  font-family: var(--font-body);
  font-size: 13px;
}

.detail-row td {
  background: var(--surface2);
  color: var(--dim2);
  font-size: 12px;
}

.detail-row td:first-child {
  padding-left: 32px;
  font-family: var(--font-mono);
}

/* ---------- Modal dialog (change password) ---------- */
.modal {
  background: var(--surface);
  color: var(--white);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px;
  width: min(380px, calc(100vw - 40px));
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
}

.modal::backdrop {
  background: rgba(0, 0, 0, 0.65);
}

.modal h2 {
  margin: 0 0 4px;
  font-size: 16px;
}

.modal .modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.modal .modal-actions button {
  margin-top: 0;
}

.form-message {
  display: none;
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 13px;
}

.form-message.error {
  display: block;
  background: var(--crimson-dim);
  color: var(--crimson);
  border: 1px solid rgba(201, 57, 79, 0.3);
}

.form-message.success {
  display: block;
  background: rgba(46, 168, 110, 0.12);
  color: var(--green);
  border: 1px solid rgba(46, 168, 110, 0.3);
}

/* Small text-style link-button (e.g. "Forgot your password?" on the login card) */
.link-button {
  width: auto;
  margin-top: 16px;
  padding: 0;
  background: none;
  border: none;
  color: var(--dim);
  font-family: var(--font-body);
  font-size: 13px;
  letter-spacing: 0;
  text-transform: none;
  text-decoration: underline;
}

.link-button:hover {
  background: none;
  color: var(--silver);
  transform: none;
}

.filter-bar .filter-note {
  font-size: 12px;
  color: var(--dim);
}
