/* ============================================================
   Foot Traffic Analytics — iViu Insights
   app.css  (matches partner portal visual language)
   ============================================================ */

/* ── CSS Custom Properties ─────────────────────────────────── */
:root {
  --header-height: 0px;
  --footer-height: 44px;
  --selector-height: 56px;
  --tab-height: 44px;
  --ink: #0f172a;
  --ink-muted: #475569;
  --brand: #2189D0;
  --brand-dark: #1a72b8;
  --surface: #f8fafc;
  --card: #ffffff;
  --accent: #F07F21;
  --input-bg: #ffffff;
  --input-border: #b8d8f0;
}

body[data-theme="dark"] {
  --ink: #e2e8f0;
  --ink-muted: #94a3b8;
  --surface: #0b1220;
  --card: #111827;
  --input-bg: #0b1220;
  --input-border: #1f2937;
}

/* ── Base ──────────────────────────────────────────────────── */
html {
  min-width: 1024px;
}

body {
  background: var(--surface);
  color: var(--ink);
  font-family: "Roboto", "Gill Sans", "Trebuchet MS", sans-serif;
  font-size: 0.88rem;
  min-height: 100vh;
  padding-top: calc(var(--header-height) + var(--selector-height) + var(--tab-height));
  padding-bottom: calc(var(--footer-height) + 1.5rem);
}

/* ── Selector bar brand ────────────────────────────────────── */
.fta-selector-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-shrink: 0;
}

.fta-selector-divider {
  width: 1px;
  height: 28px;
  background: rgba(33, 137, 208, 0.25);
  flex-shrink: 0;
}

.header-logo {
  height: 30px;
  width: auto;
}

.header-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
}

/* ── Footer ────────────────────────────────────────────────── */
.page-footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 0.6rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(248, 250, 252, 0.85);
  color: var(--ink-muted);
  font-size: 0.85rem;
  backdrop-filter: blur(12px);
  border-top: 1px solid rgba(15, 23, 42, 0.08);
  z-index: 1070;
  min-height: var(--footer-height);
}

.page-footer .theme-toggle {
  position: absolute;
  left: 1.5rem;
  top: 50%;
  transform: translateY(-50%);
}

.page-footer .site-version {
  position: absolute;
  right: 1.5rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

body[data-theme="dark"] .page-footer {
  background: rgba(15, 23, 42, 0.85);
  border-top-color: rgba(148, 163, 184, 0.2);
}

body[data-theme="dark"] .page-footer .theme-toggle {
  border-color: rgba(152, 160, 169, 0.6);
  color: #98a0a9;
}

/* ── Selector bar ──────────────────────────────────────────── */
.fta-selector-bar {
  position: fixed;
  top: var(--header-height);
  left: 0;
  right: 0;
  height: var(--selector-height);
  z-index: 1080;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 1.5rem;
  background: var(--card);
  border-top: 2px solid var(--brand);
  border-bottom: 1px solid rgba(33, 137, 208, 0.18);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}

body[data-theme="dark"] .fta-selector-bar {
  background: #0f172a;
  border-bottom-color: rgba(33, 137, 208, 0.22);
}

.fta-select {
  height: 32px;
  padding: 0.25rem 0.6rem;
  border: 1px solid var(--input-border);
  border-radius: 0.375rem;
  background: var(--input-bg);
  color: var(--ink);
  font-family: "Roboto", "Gill Sans", "Trebuchet MS", sans-serif;
  font-size: 0.82rem;
  max-width: 220px;
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s;
}

.fta-select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(33, 137, 208, 0.18);
}

.fta-select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── Location search typeahead ─────────────────────────────── */
.fta-customer-loc-select {
  height: 32px;
  padding: 0 0.6rem;
  border: 1px solid var(--input-border);
  border-radius: 0.375rem;
  background: var(--input-bg);
  color: var(--ink);
  font-size: 0.82rem;
  min-width: 200px;
  max-width: 320px;
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s;
}
.fta-customer-loc-select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(33, 137, 208, 0.18);
}
body[data-theme="dark"] .fta-customer-loc-select {
  background: #1e293b;
  border-color: #334155;
  color: #e2e8f0;
}
.fta-loc-search-wrap {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 260px;
  max-width: 360px;
  flex: 1 1 260px;
  margin-left: auto;
}

.fta-loc-search-icon {
  position: absolute;
  left: 8px;
  color: var(--ink-muted);
  font-size: 13px;
  pointer-events: none;
}

.fta-loc-search-input {
  height: 32px;
  width: 100%;
  padding: 0.25rem 2rem 0.25rem 1.8rem;
  border: 1px solid var(--input-border);
  border-radius: 0.375rem;
  background: var(--input-bg);
  color: var(--ink);
  font-family: "Roboto", "Gill Sans", "Trebuchet MS", sans-serif;
  font-size: 0.82rem;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.fta-loc-search-input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(33, 137, 208, 0.18);
}

.fta-loc-search-input.has-value {
  border-color: var(--brand);
  font-weight: 500;
}

body[data-theme="dark"] .fta-loc-search-input {
  background: var(--input-bg);
  color: var(--ink);
}

.fta-loc-clear-btn {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--ink-muted);
  cursor: pointer;
  padding: 2px 4px;
  line-height: 1;
  font-size: 12px;
}
.fta-loc-clear-btn:hover { color: var(--ink); }

.fta-loc-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 2000;
  background: var(--card);
  border: 1px solid var(--input-border);
  border-radius: 0.375rem;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.14);
  list-style: none;
  margin: 0;
  padding: 4px 0;
  max-height: 280px;
  overflow-y: auto;
  display: none;
}

.fta-loc-dropdown.open { display: block; }

body[data-theme="dark"] .fta-loc-dropdown {
  background: #1e293b;
  border-color: rgba(33, 137, 208, 0.3);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

.fta-loc-option {
  padding: 7px 12px;
  cursor: pointer;
  font-size: 0.82rem;
  line-height: 1.35;
  color: var(--ink);
  border-bottom: 1px solid rgba(33, 137, 208, 0.06);
}

.fta-loc-option:last-child { border-bottom: none; }

.fta-loc-option:hover,
.fta-loc-option[aria-selected="true"] {
  background: rgba(33, 137, 208, 0.1);
}

body[data-theme="dark"] .fta-loc-option:hover,
body[data-theme="dark"] .fta-loc-option[aria-selected="true"] {
  background: rgba(33, 137, 208, 0.2);
}

.fta-loc-option-name {
  font-weight: 500;
  color: var(--ink);
}

.fta-loc-option-customer {
  font-size: 0.76rem;
  color: var(--ink-muted);
  margin-top: 1px;
}

.fta-loc-id {
  font-size: 0.72rem;
  font-weight: 400;
  color: var(--ink-muted);
  margin-left: 0.35rem;
}

.fta-loc-clientid {
  font-size: 0.72rem;
  color: var(--ink-muted);
  margin-left: 0.2rem;
}

.fta-loc-option-hint {
  font-size: 0.76rem;
  color: var(--ink-muted);
  font-style: italic;
  padding: 6px 12px;
}

mark.fta-match {
  background: transparent;
  color: var(--brand);
  font-weight: 600;
  padding: 0;
}

.fta-date-group {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.fta-date-input {
  height: 32px;
  padding: 0.25rem 0.5rem;
  border: 1px solid var(--input-border);
  border-radius: 0.375rem;
  background: var(--input-bg);
  color: var(--ink);
  font-family: "Roboto", "Gill Sans", "Trebuchet MS", sans-serif;
  font-size: 0.82rem;
  outline: none;
  transition: border-color 0.15s;
}

.fta-date-input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(33, 137, 208, 0.18);
}

.fta-date-sep {
  color: var(--ink-muted);
  font-weight: 600;
}

.fta-apply-btn {
  white-space: nowrap;
}

/* ── Tab bar ───────────────────────────────────────────────── */
.fta-tab-bar {
  position: fixed;
  top: calc(var(--header-height) + var(--selector-height));
  left: 0;
  right: 0;
  height: var(--tab-height);
  z-index: 1070;
  display: flex;
  align-items: stretch;
  padding: 0 1rem;
  background: var(--card);
  border-bottom: 2px solid var(--brand);
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.08);
  overflow-x: auto;
}

body[data-theme="dark"] .fta-tab-bar {
  background: #111827;
}

.fta-tabs {
  display: flex;
  align-items: stretch;
  height: 100%;
  gap: 1px;
}

.fta-tab {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  height: 100%;
  padding: 0 1rem;
  border: none;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  background: transparent;
  font-family: "Roboto", "Gill Sans", "Trebuchet MS", sans-serif;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--ink-muted);
  cursor: pointer;
  transition: color 0.15s, border-bottom-color 0.15s, background 0.15s;
  white-space: nowrap;
  border-radius: 4px 4px 0 0;
}

.fta-tab:hover {
  color: var(--ink);
  background: rgba(33, 137, 208, 0.07);
}

.fta-tab.active {
  color: var(--brand);
  font-weight: 600;
  background: rgba(33, 137, 208, 0.06);
  border-bottom-color: var(--brand);
}

/* ── Content area ──────────────────────────────────────────── */
.fta-content {
  padding: 1.25rem 1.5rem;
}

.fta-view {
  /* views are shown/hidden by js */
}

/* ── Alert ─────────────────────────────────────────────────── */
.fta-alert {
  margin-bottom: 1rem;
  border-radius: 0.5rem;
}

/* ── Cards ─────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 0.75rem;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
  color: var(--ink);
}

body[data-theme="dark"] .card {
  border-color: rgba(148, 163, 184, 0.12);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
}

.fta-card-kpi {
  border-left: 4px solid var(--brand);
}

.fta-card-header {
  background: transparent;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--ink);
  border-bottom: 1px solid rgba(15, 23, 42, 0.07);
  padding: 0.65rem 1rem;
}

body[data-theme="dark"] .fta-card-header {
  border-bottom-color: rgba(148, 163, 184, 0.1);
}

.fta-header-sub {
  font-weight: 400;
  font-size: 0.78rem;
  color: var(--ink-muted);
}

.card-body {
  color: var(--ink);
}

/* ── KPI values ────────────────────────────────────────────── */
.fta-kpi-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.3rem;
}

.fta-kpi-value {
  font-size: 1.9rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1;
}

.fta-kpi-delta {
  font-size: 0.8rem;
  margin-top: 0.25rem;
}

.fta-kpi-delta .positive { color: #22c55e; }
.fta-kpi-delta .negative { color: #ef4444; }

/* delta spans emitted by fmtDelta() */
span.positive { color: #22c55e; }
span.negative { color: #ef4444; }

/* ── Tables ────────────────────────────────────────────────── */
.fta-table thead th {
  background: var(--brand);
  color: #fff;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
  border: none;
  padding: 0.4rem 0.65rem;
}

body[data-theme="dark"] .fta-table thead th {
  background: #1a6caa;
  color: #e2f0fb;
}

.fta-table tbody td {
  white-space: nowrap;
  vertical-align: middle;
  color: var(--ink);
  border-bottom: 1px solid rgba(15, 23, 42, 0.06);
  padding: 0.35rem 0.65rem;
}

body[data-theme="dark"] .fta-table tbody td {
  border-bottom-color: rgba(148, 163, 184, 0.1);
}

.fta-table tbody tr:hover td {
  background: rgba(33, 137, 208, 0.06);
}

body[data-theme="dark"] .fta-table tbody tr:hover td {
  background: rgba(33, 137, 208, 0.1);
}

/* Bootstrap table dark mode overrides */
body[data-theme="dark"] .table {
  --bs-table-bg: transparent;
  --bs-table-hover-bg: rgba(33, 137, 208, 0.1);
  --bs-table-color: var(--ink);
  color: var(--ink);
}

/* ── Form controls (dark mode) ────────────────────────────── */
.form-control,
.form-select {
  background: var(--input-bg);
  border-color: var(--input-border);
  color: var(--ink);
  font-family: "Roboto", "Gill Sans", "Trebuchet MS", sans-serif;
  font-size: 0.88rem;
}

.form-control:focus,
.form-select:focus {
  background: var(--input-bg);
  border-color: var(--brand);
  color: var(--ink);
  box-shadow: 0 0 0 0.2rem rgba(33, 137, 208, 0.25);
}

body[data-theme="dark"] .form-control,
body[data-theme="dark"] .form-control:focus,
body[data-theme="dark"] .form-select,
body[data-theme="dark"] .form-select:focus {
  background-color: var(--input-bg);
  color: var(--ink);
  border-color: var(--input-border);
}

body[data-theme="dark"] .text-muted {
  color: var(--ink-muted) !important;
}

/* ── Brand button ──────────────────────────────────────────── */
.btn-brand {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.btn-brand:hover,
.btn-brand:focus {
  background: var(--brand-dark);
  border-color: var(--brand-dark);
  color: #fff;
}

/* ── Heatmap bar ───────────────────────────────────────────── */
.heat-bar {
  height: 14px;
  border-radius: 3px;
  background: linear-gradient(to right, #fff5f0, #d73027);
  min-width: 30px;
}

body[data-theme="dark"] .heat-bar {
  background: linear-gradient(to right, #1e2d3d, #ef4444);
}

/* ── Journey ───────────────────────────────────────────────── */
.fta-journey-list {
  max-height: 480px;
  overflow-y: auto;
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 6px;
  padding: 0.5rem;
  background: var(--card);
}

body[data-theme="dark"] .fta-journey-list {
  border-color: rgba(148, 163, 184, 0.15);
}

.fta-journey-list .device-item {
  cursor: pointer;
  padding: 0.4rem 0.6rem;
  border-radius: 5px;
  margin-bottom: 2px;
  font-size: 0.82rem;
  color: var(--ink);
  transition: background 0.12s;
}

.fta-journey-list .device-item:hover,
.fta-journey-list .device-item.active {
  background: rgba(33, 137, 208, 0.1);
}

.fta-journey-timeline {
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 6px;
  min-height: 340px;
  padding: 0.75rem;
  overflow-y: auto;
  max-height: 480px;
  background: var(--card);
}

body[data-theme="dark"] .fta-journey-timeline {
  border-color: rgba(148, 163, 184, 0.15);
}

.fta-journey-step {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  margin-bottom: 0.5rem;
  font-size: 0.82rem;
  color: var(--ink);
}

.fta-journey-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--brand);
  margin-top: 4px;
  flex-shrink: 0;
}

.fta-journey-line {
  width: 2px;
  height: 22px;
  background: rgba(33, 137, 208, 0.25);
  margin-left: 4px;
  flex-shrink: 0;
}

/* ── Badges ────────────────────────────────────────────────── */
.badge-customer  { background: var(--brand);  color: #fff; border-radius: 4px; padding: 2px 6px; font-size: 0.75rem; }
.badge-employee  { background: #6f42c1; color: #fff; border-radius: 4px; padding: 2px 6px; font-size: 0.75rem; }
.badge-passerby  { background: #6c757d; color: #fff; border-radius: 4px; padding: 2px 6px; font-size: 0.75rem; }
.badge-poi       { background: var(--accent);  color: #fff; border-radius: 4px; padding: 2px 6px; font-size: 0.75rem; }
.badge-excluded  { background: #dc3545; color: #fff; border-radius: 4px; padding: 2px 6px; font-size: 0.75rem; }

/* ── Loading overlay ──────────────────────────────────────── */
.fta-loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(235, 240, 248, 0.55);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

.fta-loading-card {
  width: 152px;
  height: 152px;
  border-radius: 50%;
  background: #f4f6fa;
  box-shadow:
    6px 6px 18px rgba(160,175,200,0.40),
   -6px -6px 18px rgba(255,255,255,0.90),
    0 0 0 14px rgba(255,255,255,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

/* Spinning two-tone arc */
.fta-loading-card::before {
  content: '';
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 5px solid transparent;
  border-top-color: #2189D0;
  border-right-color: #2189D0;
  border-bottom-color: #e08020;
  border-left-color: transparent;
  animation: fta-spin 1.1s cubic-bezier(0.5,0.1,0.5,0.9) infinite;
}

/* Outer glow ring (static) */
.fta-loading-card::after {
  content: '';
  position: absolute;
  inset: -14px;
  border-radius: 50%;
  border: 1px solid rgba(180,200,230,0.35);
  pointer-events: none;
}

.fta-loading-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.fta-loading-text {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: #5a6a80;
  user-select: none;
}

.fta-loading-msg {
  background: rgba(255,255,255,0.88);
  border: 1px solid rgba(33,137,208,0.22);
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 0.70rem;
  color: #4a5a72;
  text-align: center;
  max-width: 280px;
  line-height: 1.6;
  box-shadow: 0 2px 8px rgba(100,130,180,0.12);
}
.fta-loading-msg span {
  font-size: 0.64rem;
  color: #7a8a9a;
}
.fta-loading-daterange {
  font-size: 0.68rem;
  color: #2189d0;
  font-weight: 600;
}
.fta-loading-cancel {
  margin-top: 4px;
  padding: 2px 12px;
  font-size: 0.65rem;
  border: 1px solid #aab4c4;
  border-radius: 4px;
  background: transparent;
  color: #4a5a72;
  cursor: pointer;
}
.fta-loading-cancel:hover {
  background: rgba(33,137,208,0.08);
  border-color: #2189d0;
  color: #2189d0;
}

@keyframes fta-spin {
  to { transform: rotate(360deg); }
}

/* ── Inline spinner (kept for narrow contexts) ─────────────── */
.fta-spinner {
  display: inline-block;
  width: 1rem;
  height: 1rem;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: fta-spin 0.6s linear infinite;
}

/* ── Theme toggle ──────────────────────────────────────────── */
.theme-toggle {
  border-radius: 999px;
}

/* ── Utility ───────────────────────────────────────────────── */
.cursor-pointer { cursor: pointer; }

/* ══════════════════════════════════════════════════════════
   Live View — Canvas Radar / Pings / Topo
   ══════════════════════════════════════════════════════════ */

.fta-live-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 16px;
  max-width: 700px;
  margin: 0 auto;
}

/* Canvas panel (inside split layout, max-width constraint overridden) */
.fta-live-canvas-wrap {
  position: relative;
  width: 100%;
  max-width: none;
  min-height: 280px;
  background: #dce8f0;
  overflow: hidden;
  border-radius: 4px;
  font-family: 'Courier New', Courier, monospace;
}
body[data-theme="dark"] .fta-live-canvas-wrap {
  background: #0b1a28;
}

/* Canvas fills the wrapper */
.fta-live-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* Scan overlay title */
.fta-live-title {
  position: absolute;
  bottom: 18px;
  left: 14px;
  top: auto;
  font-size: 9px;
  letter-spacing: .08em;
  color: #4a6e84;
  text-transform: uppercase;
  pointer-events: none;
  z-index: 2;
}
body[data-theme="dark"] .fta-live-title {
  color: #4c7fa0;
}

/* Compass — top-right */
.fta-live-compass {
  position: absolute;
  top: 8px;
  right: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  color: #4a6e84;
  pointer-events: none;
  z-index: 2;
}
body[data-theme="dark"] .fta-live-compass {
  color: #4c7fa0;
}
.fta-live-compass-n {
  font-size: 9px;
  letter-spacing: .1em;
  line-height: 1.2;
  text-transform: uppercase;
}
.fta-live-compass-ring {
  color: inherit;
}

/* Corner brackets (targeting reticle) */
.fta-live-corner {
  position: absolute;
  width: 18px;
  height: 18px;
  border-color: #F07F21;
  border-style: solid;
  border-width: 0;
  pointer-events: none;
  z-index: 3;
}
.fta-live-corner-tl { top: 6px;  left: 6px;  border-top-width: 2px;  border-left-width: 2px; }
.fta-live-corner-tr { top: 6px;  right: 6px; border-top-width: 2px;  border-right-width: 2px; }
.fta-live-corner-bl { bottom: 6px; left: 6px;  border-bottom-width: 2px; border-left-width: 2px; }
.fta-live-corner-br { bottom: 6px; right: 6px; border-bottom-width: 2px; border-right-width: 2px; }

/* Info panel — bottom-left */
.fta-live-info {
  position: absolute;
  bottom: 28px;
  left: 12px;
  font-size: 9px;
  line-height: 1.6;
  color: #2c4a60;
  pointer-events: none;
  z-index: 2;
}
body[data-theme="dark"] .fta-live-info {
  color: #7aadca;
}
.fta-live-loc-name {
  font-size: 10px;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: .07em;
  margin-bottom: 2px;
}
.fta-live-counts {
  margin-bottom: 4px;
}

/* Legend rows */
.fta-live-legend { margin-top: 2px; }
.fta-live-legend-row { display: flex; align-items: center; gap: 5px; }
.fta-live-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.fta-live-dot.dot-alert  { background: #F07F21; }
.fta-live-dot.dot-breach { background: #FF4444; }

/* Status bar — bottom */
.fta-live-statusbar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 24px;
  background: rgba(33,137,208,.12);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 8px;
  letter-spacing: .15em;
  text-transform: uppercase;
  color: #2189D0;
  pointer-events: none;
  z-index: 2;
}
body[data-theme="dark"] .fta-live-statusbar {
  background: rgba(33,137,208,.18);
  color: #5ab0d8;
}

/* Tooltip */
.fta-live-tooltip {
  position: absolute;
  background: rgba(0,0,0,.75);
  color: #fff;
  font-size: 10px;
  padding: 3px 7px;
  border-radius: 3px;
  pointer-events: none;
  display: none;
  z-index: 10;
}

/* Controls row */
.fta-live-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: 640px;
  padding: 4px 0;
}

.fta-live-toggle-label {
  font-family: 'Courier New', Courier, monospace;
  font-size: 11px;
  letter-spacing: .06em;
  color: var(--ink-muted);
}

/* Mode buttons */
.fta-live-mode-btns {
  display: flex;
  gap: 0;
}
.fta-live-mode-btn {
  background: transparent;
  border: 1px solid var(--brand);
  color: var(--brand);
  font-family: 'Courier New', Courier, monospace;
  font-size: 11px;
  letter-spacing: .05em;
  padding: 4px 12px;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.fta-live-mode-btn:first-child { border-radius: 3px 0 0 3px; }
.fta-live-mode-btn:last-child  { border-radius: 0 3px 3px 0; }
.fta-live-mode-btn + .fta-live-mode-btn { border-left: none; }
.fta-live-mode-btn:hover  { background: var(--brand); color: #fff; }
.fta-live-mode-btn.active { background: var(--brand); color: #fff; }

body[data-theme="dark"] .fta-live-mode-btn {
  border-color: var(--brand);
  color: var(--brand);
}
body[data-theme="dark"] .fta-live-mode-btn:hover,
body[data-theme="dark"] .fta-live-mode-btn.active {
  background: var(--brand);
  color: #fff;
}

.fta-live-mode-btn:first-child { border-radius: 3px 0 0 3px; }
.fta-live-mode-btn:last-child  { border-radius: 0 3px 3px 0; }
.fta-live-mode-btn + .fta-live-mode-btn { border-left: none; }
.fta-live-mode-btn:hover  { background: var(--brand); color: #fff; }
.fta-live-mode-btn.active { background: var(--brand); color: #fff; }

body[data-theme="dark"] .fta-live-mode-btn {
  border-color: var(--brand);
  color: var(--brand);
}
body[data-theme="dark"] .fta-live-mode-btn:hover,
body[data-theme="dark"] .fta-live-mode-btn.active {
  background: var(--brand);
  color: #fff;
}

.fta-live-device-count {
  font-size: 12px;
  color: var(--ink-muted);
}

/* ============================================================
   Live view split layout
   ============================================================ */
.fta-live-split {
  display: flex;
  flex-direction: row;
  gap: 12px;
  height: calc(100vh - 120px);
  min-height: 480px;
}

/* Canvas side takes remaining space */
.fta-live-split .fta-live-canvas-wrap {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* Right metrics panel */
.fta-live-metrics {
  width: 220px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow-y: auto;
}

.live-metrics-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--brand);
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
  margin-bottom: 2px;
}

.live-metric-card {
  background: var(--surface-alt, rgba(0,0,0,0.04));
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 8px 10px;
}
body[data-theme="dark"] .live-metric-card {
  background: rgba(255,255,255,0.04);
}

.live-metric-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-bottom: 4px;
}

.live-metric-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--brand);
  line-height: 1.1;
}

.live-metric-card--zones .live-metric-value {
  font-size: 13px;
}

/* Zone breakdown list */
.live-zone-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 4px;
}
.live-zone-row {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
}
.live-zone-name {
  flex: 0 0 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink);
  font-size: 10px;
}
.live-zone-bar {
  flex: 1;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}
.live-zone-bar span {
  display: block;
  height: 100%;
  background: var(--brand);
  border-radius: 3px;
  transition: width 0.3s;
}
.live-zone-count {
  flex: 0 0 24px;
  text-align: right;
  font-size: 10px;
  font-weight: 600;
  color: var(--ink-muted);
}

/* Auto-refresh badge */
.live-updated-ago {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #00be96;
  text-transform: uppercase;
}
@keyframes livePulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.45; }
}
.live-pulsing {
  animation: livePulse 2s ease-in-out infinite;
}

/* Gear button in selector bar */
.fta-gear-btn {
  flex-shrink: 0;
  margin-left: 6px;
}

/* ============================================================
   Heatmap canvas panel
   ============================================================ */
#heatmapZoneToolbar {
  margin-bottom: 8px;
}
#heatmapZoneSelect {
  font-size: 0.82rem;
}
.heatmap-canvas-wrap {
  width: 100%;
  min-height: 280px;
  background: #090f18;
  border-radius: 6px;
  margin-bottom: 14px;
  overflow: hidden;
  position: relative;
}
.heatmap-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* Fit-to-view button overlaid on any canvas container */
.fta-canvas-fit-btn {
  position: absolute;
  bottom: 8px;
  right: 8px;
  z-index: 10;
  background: rgba(0,0,0,0.45);
  border: 1px solid rgba(255,255,255,0.25);
  color: #fff;
  font-size: 12px;
  padding: 4px 7px;
  border-radius: 4px;
  cursor: pointer;
  line-height: 1;
  opacity: 0.65;
  transition: opacity 0.15s;
}
.fta-canvas-fit-btn:hover { opacity: 1; background: rgba(0,0,0,0.75); }


/* ============================================================
   Zone drill-in detail panel
   ============================================================ */
.zd-kpi-row {
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}
.zd-kpi-row:last-of-type {
  border-bottom: none;
}
.zd-kpi-label {
  font-size: 10px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 2px;
}
.zd-kpi-value {
  font-size: 22px;
  font-weight: 700;
  font-family: 'Courier New', monospace;
  color: var(--ink);
}

/* ============================================================
   Preferences modal
   ============================================================ */
.fta-modal-content {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
}
.fta-modal-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
}
.fta-modal-footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 10px 16px;
}
.fta-pref-tabs {
  border-bottom: 1px solid var(--border);
  padding: 0 12px;
}
.fta-pref-tabs .nav-link {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-muted);
  border-radius: 4px 4px 0 0;
  padding: 7px 14px;
}
.fta-pref-tabs .nav-link.active {
  color: var(--brand);
  border-color: var(--border) var(--border) var(--surface);
  background: var(--surface);
}
.fta-pref-tab-content {
  padding: 18px 20px;
  min-height: 200px;
}
.fta-pref-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.fta-pref-label {
  flex: 0 0 180px;
  font-size: 13px;
  color: var(--ink);
  margin-bottom: 0;
}
.fta-pref-range {
  flex: 1;
}
.fta-pref-val {
  flex: 0 0 52px;
  font-size: 12px;
  font-weight: 600;
  color: var(--brand);
  text-align: right;
}
.fta-pref-select {
  flex: 1;
  font-size: 13px;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border);
}
.fta-pref-section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--brand);
  margin-bottom: 8px;
  margin-top: 0;
}
.fta-pref-check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 13px;
}

/* Dark mode adjustments for modal */
body[data-theme="dark"] .fta-modal-content {
  background: #0d1e30;
  color: #d0e8f8;
  border-color: #1e3a56;
}
body[data-theme="dark"] .fta-modal-header,
body[data-theme="dark"] .fta-modal-footer {
  background: #0d1e30;
  border-color: #1e3a56;
}
body[data-theme="dark"] .fta-pref-tabs .nav-link.active {
  background: #0d1e30;
  border-color: #1e3a56 #1e3a56 #0d1e30;
}
body[data-theme="dark"] .fta-pref-select {
  background: #101e2e;
  color: #d0e8f8;
  border-color: #1e3a56;
}
body[data-theme="dark"] .live-metric-card {
  border-color: #1e3a56;
}
body[data-theme="dark"] .fta-live-metrics {
  background: #0d1e30;
  border-color: #1e3a56;
}


/* ── Live view: canvas column wrapper ─────────────────────────────────────── */
.fta-live-canvas-col {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
/* When inside the column, canvas-wrap should stretch vertically */
.fta-live-canvas-col .fta-live-canvas-wrap {
  flex: 1;
}

/* ── Live view: top control bar ───────────────────────────────────────────── */
.fta-live-topbar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 4px 2px;
  border-bottom: 1px solid var(--border);
}

/* ── Live view: visualization mode overlay — now inline in topbar ─────────── */
.fta-live-mode-overlay {
  display: none; /* removed from canvas; buttons now live in the topbar */
}
body[data-theme="light"] .fta-live-mode-overlay {
  background: rgba(220, 232, 245, 0.82);
  border-color: rgba(33,137,208,0.25);
}
.fta-live-toggle-label {
  font-size: 9px;
  letter-spacing: 0.10em;
  color: var(--ink-muted);
  white-space: nowrap;
}
/* Topbar separator between controls and viz buttons */
.fta-live-viz-sep {
  display: inline-block;
  width: 1px;
  height: 18px;
  background: var(--border);
  margin: 0 4px;
  vertical-align: middle;
}

/* ── Live view: device dwell list ─────────────────────────────────────────── */
.live-metric-card--dwell .live-metric-label { margin-bottom: 6px; }
.live-dwell-list {
  display: flex;
  flex-direction: column;
  max-height: 220px;
  overflow-y: auto;
  gap: 0;
}
.live-dwell-row {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 0;
  border-bottom: 1px solid var(--border);
  font-size: 10px;
}
.live-dwell-row:last-child { border-bottom: none; }
.live-dwell-udid {
  flex: 0 0 66px;
  font-family: 'Courier New', monospace;
  font-size: 9px;
  color: var(--ink-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.live-dwell-dty {
  flex: 0 0 32px;
  font-size: 9px;
  color: var(--ink-muted);
  text-align: center;
}
.live-dwell-time {
  flex: 1;
  text-align: right;
  font-weight: 700;
  font-size: 11px;
  color: var(--brand);
}
.live-dwell-empty {
  font-size: 10px;
  color: var(--ink-muted);
  padding: 4px 0;
  text-align: center;
}

/* ── Live view: device reveal list ───────────────────────────────────────── */
.live-metric-card--reveal .live-metric-label { margin-bottom: 6px; }
.live-reveal-list {
  display: flex;
  flex-direction: column;
  max-height: 260px;
  overflow-y: auto;
  gap: 0;
}
.live-reveal-row {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 0;
  border-bottom: 1px solid var(--border);
  font-size: 10px;
}
.live-reveal-row:last-child { border-bottom: none; }
.live-reveal-udid {
  flex: 0 0 70px;
  font-family: 'Courier New', monospace;
  font-size: 9px;
  color: var(--ink-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.live-reveal-dty {
  flex: 0 0 30px;
  font-size: 8px;
  font-weight: 700;
  text-align: center;
  border-radius: 3px;
  padding: 1px 2px;
  color: #fff;
}
.live-reveal-mfg {
  flex: 1;
  font-size: 9px;
  color: var(--ink-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.live-reveal-dot {
  flex: 0 0 8px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ── Count report: clickable day rows ─────────────────────────────────────── */
#tblCountsBody tr.counts-day-row { cursor: pointer; }
#tblCountsBody tr.counts-day-row:hover td { background: rgba(33,137,208,0.07); }
#tblCountsBody tr.counts-day-row .counts-day-cell {
  color: var(--brand);
  font-weight: 600;
}
body[data-theme="dark"] #tblCountsBody tr.counts-day-row:hover td {
  background: rgba(33,137,208,0.12);
}

/* ── Counts table: conversion/frequency columns ───────────────────────────── */
th.counts-conv-col,
td.counts-conv-col {
  background: rgba(0, 180, 120, 0.04);
  color: var(--ink);
}
th.counts-conv-col {
  white-space: nowrap;
  font-size: 11px;
  cursor: help;
}
td.counts-conv-col { text-align: right; }
body[data-theme="dark"] th.counts-conv-col,
body[data-theme="dark"] td.counts-conv-col {
  background: rgba(0, 200, 140, 0.06);
}

/* ── Dashboard KPI sub-label (small text under value) ─────────────────────── */
.fta-kpi-sub {
  font-size: 11px;
  color: var(--ink-muted);
  margin-top: 2px;
  min-height: 14px;
}

/* ── Location info bar ─────────────────────────────────────────────────────── */
.fta-loc-info-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 14px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 10px;
  font-size: 12px;
  color: var(--ink);
  flex-wrap: wrap;
}
.fta-loc-info-bar .fa-map-marker { color: var(--brand); margin-right: 2px; }
.loc-info-piece { display: inline-flex; align-items: center; gap: 4px; }
.loc-info-city-state { color: var(--ink-muted); }
.loc-info-sep { color: var(--border); user-select: none; }
.fta-loc-info-bar #ftaEnvWeather {
  margin-left: 2px;
  padding: 2px 10px;
}
.loc-info-type-badge {
  padding: 1px 6px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  background: rgba(120,120,120,0.12);
}
.loc-type-presence {
  background: rgba(255,193,7,0.15);
  color: #856404;
}
body[data-theme="dark"] .loc-type-presence {
  background: rgba(255,193,7,0.2);
  color: #ffc107;
}
.loc-type-positioning {
  background: rgba(13,110,253,0.12);
  color: #0d6efd;
}
body[data-theme="dark"] .loc-type-positioning {
  background: rgba(13,110,253,0.2);
  color: #6ea8fe;
}

/* ── Dashboard day selector row ────────────────────────────────────────────── */
.fta-dashboard-day-row { padding: 6px 0 0; }
.fta-section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--brand);
  border-left: 3px solid var(--brand);
  padding-left: 8px;
  letter-spacing: .03em;
}

/* ── Dashboard environment bar (day / weather / timezone) ─────────────────── */
.fta-env-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.fta-env-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 12px;
  background: rgba(33, 137, 208, 0.08);
  color: var(--ink);
}
.fta-env-item i {
  color: var(--brand);
}
#ftaEnvWeather i {
  color: #f59e0b;
}
body[data-theme="dark"] .fta-env-item {
  background: rgba(33, 137, 208, 0.16);
}
body[data-theme="dark"] #ftaEnvWeather i {
  color: #fbbf24;
}

/* ── Print / export buttons ─────────────────────────────────────────────────── */
.fta-print-btn { font-size: 11px; }

/* ── Unavailable tab state for presence locations ──────────────────────────── */
.fta-tab--unavail {
  opacity: 0.45;
  cursor: default;
}
.fta-tab--unavail:hover {
  background: transparent !important;
  color: var(--ink-muted) !important;
}

/* ── Presence location unavailable message panel ───────────────────────────── */
.fta-presence-unavail {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 24px;
  margin-bottom: 16px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--ink);
}
.fta-presence-unavail h5 { margin: 8px 0 6px; font-size: 15px; font-weight: 600; }
.fta-presence-unavail p  { font-size: 13px; color: var(--ink-muted); max-width: 520px; }

/* ── Print styles ────────────────────────────────────────────────────────────── */
@media print {
  .fta-selector-bar,
  .fta-tab-bar,
  .fta-loading-overlay,
  #alertArea,
  #locInfoBar,
  #dataSourceBanner,
  .fta-print-btn,
  .btn-close,
  footer,
  .fta-view.d-none { display: none !important; }

  .fta-content { padding: 0 !important; }
  .card { break-inside: avoid; border: 1px solid #ccc !important; }
  .card-header { background: #f0f0f0 !important; color: #000 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .table { font-size: 10px !important; }
  canvas { max-width: 100% !important; }

  /* Section-targeted print: hide all views except the targeted one */
  body[data-print-section] .fta-view { display: none !important; }
  body[data-print-section="dashboard"] #view-dashboard { display: block !important; }
  body[data-print-section="kpi-table"] #view-dashboard { display: block !important; }
  body[data-print-section="counts"]    #view-counts    { display: block !important; }
  body[data-print-section="zones"]     #view-zones     { display: block !important; }
  body[data-print-section="visitors"]  #view-visitors  { display: block !important; }
  .fta-insight { display: none !important; }
}

/* ── Insight Panels ──────────────────────────────────────────── */
.fta-insight {
  border-left: 3px solid var(--brand);
  background: color-mix(in srgb, var(--brand) 7%, var(--card));
  border-radius: 6px;
  padding: 10px 14px 10px 12px;
  margin-bottom: 14px;
  font-size: 0.82rem;
  line-height: 1.55;
}
body[data-theme="dark"] .fta-insight {
  background: color-mix(in srgb, var(--brand) 10%, var(--card));
}
.fta-insight-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  font-size: 0.78rem;
  letter-spacing: .05em;
  color: var(--brand);
  margin-bottom: 6px;
  text-transform: uppercase;
}
.fta-insight-items {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.fta-insight-item {
  display: flex;
  align-items: baseline;
  gap: 6px;
  color: var(--ink);
}
.fta-insight-item::before {
  content: "›";
  color: var(--brand);
  font-weight: 700;
  flex-shrink: 0;
}
.fta-insight-item .ins-val  { font-weight: 600; }
.fta-insight-item .ins-up   { color: #22a84a; }
.fta-insight-item .ins-down { color: #e03535; }
.fta-insight-item .ins-warn { color: var(--accent); }

/* ── iScout — iViu Insights Venue Analytics Assistant ─────────────────── */
.iscout-btn {
  position: fixed;
  bottom: 22px;
  right: 22px;
  z-index: 1200;
  background: linear-gradient(135deg, var(--brand) 0%, #1558a0 100%);
  color: #fff;
  border-radius: 26px;
  padding: 11px 18px 11px 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(33,137,208,0.5);
  font-weight: 700;
  font-size: 0.9rem;
  user-select: none;
  transition: transform 0.15s, box-shadow 0.15s;
  letter-spacing: 0.02em;
}
.iscout-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 7px 22px rgba(33,137,208,0.6);
}
.iscout-btn-icon { font-size: 1rem; }

/* animated attention dot */
.iscout-dot {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 12px;
  height: 12px;
  background: var(--accent);
  border-radius: 50%;
  border: 2px solid #fff;
  animation: iscout-pulse 2s ease-in-out infinite;
}
@keyframes iscout-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%       { transform: scale(1.35); opacity: 0.7; }
}

.iscout-panel {
  position: fixed;
  bottom: 82px;
  right: 22px;
  z-index: 1199;
  width: 352px;
  max-height: 560px;
  background: var(--card);
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.22), 0 2px 8px rgba(0,0,0,0.1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--input-border);
  animation: iscout-slide-in 0.2s ease-out;
}
@keyframes iscout-slide-in {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0)   scale(1); }
}

.iscout-header {
  background: linear-gradient(135deg, var(--brand) 0%, #1558a0 100%);
  color: #fff;
  padding: 13px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.iscout-header-left { display: flex; align-items: center; gap: 10px; }
.iscout-avatar {
  width: 34px;
  height: 34px;
  background: rgba(255,255,255,0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}
.iscout-title      { font-weight: 800; font-size: 1rem; line-height: 1.2; }
.iscout-ai-badge   { background: rgba(255,255,255,0.25); border-radius: 4px; padding: 1px 5px; font-size: 0.6rem; font-weight: 700; letter-spacing: .06em; vertical-align: middle; }
.iscout-subtitle   { font-size: 0.7rem; opacity: 0.78; }
.iscout-close      { background: none; border: none; color: #fff; font-size: 1.4rem; line-height: 1; cursor: pointer; opacity: 0.75; padding: 0 3px; }
.iscout-close:hover{ opacity: 1; }

.iscout-envbar {
  padding: 8px 12px 9px;
  border-bottom: 1px solid var(--input-border);
  background: color-mix(in srgb, var(--brand) 7%, var(--card));
  flex-shrink: 0;
}
.iscout-envrow {
  font-family: var(--mono);
  font-size: 0.69rem;
  line-height: 1.35;
  letter-spacing: 0.01em;
  color: var(--ink-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.iscout-envrow:first-child {
  color: var(--ink);
  font-weight: 700;
  margin-bottom: 1px;
}

.iscout-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 12px 6px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  min-height: 0;
}
.iscout-msg {
  max-width: 90%;
  padding: 9px 12px;
  border-radius: 12px;
  font-size: 0.8rem;
  line-height: 1.55;
}
.iscout-msg.scout { background: color-mix(in srgb, var(--brand) 9%, var(--card)); align-self: flex-start; border-bottom-left-radius: 4px; }
.iscout-msg.user  { background: var(--brand); color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }
.iscout-msg-time  { font-size: 0.63rem; opacity: 0.5; margin-top: 4px; }

/* "Scouting…" typing indicator */
.iscout-thinking {
  align-self: flex-start;
  padding: 10px 14px;
  background: color-mix(in srgb, var(--brand) 9%, var(--card));
  border-radius: 12px 12px 12px 4px;
  font-size: 0.78rem;
  font-style: italic;
  color: var(--brand);
  display: flex;
  align-items: center;
  gap: 7px;
}
.iscout-thinking-dots span {
  display: inline-block;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--brand);
  animation: iscout-dot-bounce 1.2s ease-in-out infinite;
}
.iscout-thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.iscout-thinking-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes iscout-dot-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40%           { transform: translateY(-5px); opacity: 1; }
}

.iscout-chips {
  padding: 5px 10px 7px;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  flex-shrink: 0;
}
.iscout-chip {
  background: color-mix(in srgb, var(--brand) 9%, var(--card));
  color: var(--brand);
  border: 1px solid color-mix(in srgb, var(--brand) 22%, transparent);
  border-radius: 14px;
  padding: 3px 11px;
  font-size: 0.72rem;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.1s;
}
.iscout-chip:hover { background: color-mix(in srgb, var(--brand) 16%, var(--card)); }

.iscout-input-row {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 10px;
  border-top: 1px solid var(--input-border);
  flex-shrink: 0;
}
.iscout-input {
  flex: 1;
  border: 1px solid var(--input-border);
  border-radius: 20px;
  padding: 7px 13px;
  font-size: 0.8rem;
  background: var(--input-bg);
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s;
}
.iscout-input:focus { border-color: var(--brand); }
.iscout-send {
  background: linear-gradient(135deg, var(--brand) 0%, #1558a0 100%);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 34px; height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.82rem;
  flex-shrink: 0;
  transition: opacity 0.15s;
}
.iscout-send:hover { opacity: 0.88; }

@media (max-width: 480px) {
  .iscout-panel { width: calc(100vw - 16px); right: 8px; bottom: 78px; }
  .iscout-btn   { right: 12px; bottom: 14px; }
}

/* Navigation link buttons inside iScout messages */
.iscout-nav-link {
  display: inline-block;
  margin-top: 7px;
  margin-right: 4px;
  padding: 3px 11px;
  background: rgba(255,255,255,0.18);
  border: 1px solid rgba(255,255,255,0.42);
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
  text-decoration: none;
  letter-spacing: 0.01em;
}
.iscout-nav-link:hover { background: rgba(255,255,255,0.32); border-color: rgba(255,255,255,0.65); }

/* ============================================================
   Trend Analysis View
   ============================================================ */

/* ── Context header ─────────────────────────────────────────── */
.fta-trend-context {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  padding: 0.6rem 1rem;
  margin-bottom: 0.75rem;
  background: var(--card);
  border: 1px solid rgba(33,137,208,0.22);
  border-left: 4px solid var(--brand);
  border-radius: 6px;
  font-size: 0.82rem;
  flex-wrap: wrap;
}
.fta-trend-context-icon {
  color: var(--brand);
  font-size: 1rem;
  margin-top: 2px;
  flex-shrink: 0;
}
.fta-trend-context-body {
  flex: 1;
  min-width: 200px;
}
.fta-trend-context-title {
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 0.2rem;
}
.fta-trend-context-meta {
  color: var(--ink-muted);
  font-size: 0.78rem;
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.fta-trend-pri-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
  background: rgba(13,110,253,0.12);
  color: #1a72b8;
  border: 1px solid rgba(13,110,253,0.25);
  white-space: nowrap;
}
body[data-theme="dark"] .fta-trend-pri-badge {
  background: rgba(33,137,208,0.18);
  color: #60a8e8;
  border-color: rgba(33,137,208,0.3);
}
.fta-trend-cmp-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
  background: rgba(240,127,33,0.12);
  color: #c06018;
  border: 1px solid rgba(240,127,33,0.28);
  white-space: nowrap;
}
body[data-theme="dark"] .fta-trend-cmp-badge {
  background: rgba(240,127,33,0.18);
  color: #f0a060;
  border-color: rgba(240,127,33,0.35);
}

/* ── KPI Comparison Scorecard grid ──────────────────────────── */
.fta-trend-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.65rem;
  margin-bottom: 0;
}
@media (max-width: 1100px) {
  .fta-trend-kpi-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 768px) {
  .fta-trend-kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

.fta-trend-kpi-card {
  background: var(--card);
  border: 1px solid rgba(15,23,42,0.08);
  border-radius: 6px;
  padding: 0.6rem 0.75rem 0.55rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  transition: box-shadow 0.15s;
  position: relative;
}
body[data-theme="dark"] .fta-trend-kpi-card {
  border-color: rgba(255,255,255,0.07);
}
.fta-trend-kpi-card:hover { box-shadow: 0 2px 10px rgba(33,137,208,0.12); }

.fta-trend-kpi-title {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fta-trend-kpi-vals {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.fta-trend-kpi-pri {
  font-size: 1.25rem;
  font-weight: 700;
  color: #2189D0;
  line-height: 1.1;
  min-width: 0;
}
body[data-theme="dark"] .fta-trend-kpi-pri { color: #60b8ee; }

.fta-trend-kpi-cmp {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--accent);
  opacity: 0.85;
  line-height: 1.1;
  min-width: 0;
}

.fta-trend-kpi-delta {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  font-size: 0.70rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  white-space: nowrap;
  margin-left: auto;
  align-self: flex-end;
}
.fta-trend-delta-pos  { background: rgba(25,135,84,0.12);  color: #198754; }
.fta-trend-delta-neg  { background: rgba(220,53,69,0.12);   color: #dc3545; }
.fta-trend-delta-zero { background: rgba(108,117,125,0.1); color: #6c757d; }
body[data-theme="dark"] .fta-trend-delta-pos  { background: rgba(25,135,84,0.20); }
body[data-theme="dark"] .fta-trend-delta-neg  { background: rgba(220,53,69,0.20); }

.fta-trend-kpi-sub {
  font-size: 0.65rem;
  color: var(--ink-muted);
  margin-top: 0.1rem;
}

/* ── Inline legend for charts ───────────────────────────────── */
.fta-trend-legend-inline {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.72rem;
  color: var(--ink-muted);
  flex-wrap: nowrap;
}
.fta-trend-legend-inline .fta-tleg-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.fta-trend-legend-inline .fta-tleg-item {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

/* ── Location search inside trend panel ─────────────────────── */
.fta-trend-loc-input {
  font-size: 0.83rem;
  height: 30px;
}
.fta-trend-loc-wrap .fta-loc-dropdown {
  top: calc(100% + 2px);
  left: 0;
  min-width: 280px;
  max-width: 420px;
}

/* ── Trend summary table variance column ───────────────────── */
.fta-trend-delta-cell { font-weight: 700; white-space: nowrap; }
.fta-trend-delta-cell.pos  { color: #198754; }
.fta-trend-delta-cell.neg  { color: #dc3545; }
.fta-trend-delta-cell.zero { color: #6c757d; }

/* Active preset button highlight */
.fta-trend-preset-active {
  background-color: #2189D0 !important;
  color: #fff !important;
  border-color: #2189D0 !important;
}

/* Location ID badge in dropdown */
.fta-loc-id-badge {
  display: inline-block;
  background: #2189D0;
  color: #fff;
  border-radius: 3px;
  padding: 0 5px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  margin-right: 4px;
  vertical-align: middle;
}

/* ── Trend unified single-line control row ───────────────────── */
.fta-trend-ctrl-row {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 4px;
  overflow-x: auto;
}
.fta-trend-section-lbl {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
  letter-spacing: 0.01em;
}
.fta-trend-ctrl-lbl {
  font-size: 0.72rem;
  font-weight: 700;
  color: #6c757d;
  white-space: nowrap;
  letter-spacing: 0.03em;
}
.fta-trend-date {
  height: 28px !important;
  font-size: 0.78rem !important;
  padding: 2px 6px !important;
}
.fta-trend-ctrl-div {
  width: 1px;
  background: #dee2e6;
  align-self: stretch;
  margin: 0 3px;
  min-height: 28px;
}
body[data-theme="dark"] .fta-trend-ctrl-div { background: #444; }
.fta-preset-btn {
  font-size: 0.78rem !important;
  padding: 2px 8px !important;
  white-space: nowrap;
  height: 28px;
  line-height: 1;
}
.fta-preset-lbl {
  font-size: 0.65rem;
  line-height: 1.1;
  text-align: center;
  color: #6c757d;
  max-width: 72px;
}
.fta-trend-loc-select {
  height: 28px;
  font-size: 0.78rem;
  padding: 2px 6px;
  border: 1px solid var(--input-border);
  border-radius: 0.375rem;
  background: var(--input-bg);
  color: var(--ink);
  min-width: 180px;
  max-width: 280px;
  cursor: pointer;
}
.fta-trend-loc-select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(33,137,208,0.18);
  outline: none;
}
body[data-theme="dark"] .fta-trend-loc-select {
  background: #1e293b;
  border-color: #334155;
  color: #e2e8f0;
}
