/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: #f0f2f5; color: #333; }

/* --- Visually hidden (screen-reader only) --- */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* --- Login page --- */
.login-body {
  font-family: 'IBM Plex Sans', system-ui, sans-serif;
  color: #1d2433;
  background: #f0f2f5;
  min-height: 100vh;
}
.login-page {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 32px 20px;
}
.login-card {
  position: relative; display: flex;
  width: 100%; max-width: 440px;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.1);
  overflow: hidden;
}
.login-card__rail {
  flex: 0 0 6px;
  background: linear-gradient(180deg, #052049 0%, #0a3060 60%, #18a3ac 100%);
}
.login-card__inner {
  flex: 1; padding: 48px 44px 40px;
}
.login-eyebrow {
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.18em; text-transform: uppercase;
  color: #6b7280; margin-bottom: 14px;
}
.login-title {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 400; font-size: 38px; line-height: 1.05;
  color: #052049; margin-bottom: 14px;
  letter-spacing: -0.01em;
}
.login-title em {
  font-style: italic; font-weight: 300;
  color: #0a3060;
}
.login-lede {
  font-size: 14px; line-height: 1.55; color: #4a5263;
  margin-bottom: 32px; max-width: 36ch;
}

.sso-section { margin-bottom: 8px; }
.sso-btn {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; padding: 16px 20px;
  background: #052049; color: #fff;
  border: none; border-radius: 4px;
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 15px; font-weight: 500; letter-spacing: 0.01em;
  text-decoration: none; cursor: pointer;
  box-shadow: 0 8px 20px -8px rgba(5,32,73,0.45);
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}
.sso-btn:hover {
  background: #0a3060;
  transform: translateY(-1px);
  box-shadow: 0 12px 28px -8px rgba(5,32,73,0.55);
}
.sso-btn:hover .sso-btn__arrow { transform: translateX(4px); }
.sso-btn:focus-visible {
  outline: 2px solid #18a3ac; outline-offset: 3px;
}
.sso-btn__arrow {
  font-size: 18px; line-height: 1;
  transition: transform 160ms ease;
  color: #9bd6db;
}
.password-toggle {
  margin-top: 24px; padding: 0;
  background: none; border: none; cursor: pointer;
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 13px; color: #6b7280;
  text-decoration: underline; text-underline-offset: 3px;
  text-decoration-color: rgba(107,114,128,0.4);
  transition: color 120ms ease, text-decoration-color 120ms ease;
}
.password-toggle:hover {
  color: #052049;
  text-decoration-color: #052049;
}

.password-section {
  /* When SSO is enabled, JS hides this; when SSO is disabled, this is the default. */
}
.password-section.is-collapsed { display: none; }
.password-section.is-tucked {
  margin-top: 28px; padding-top: 24px;
  border-top: 1px solid rgba(5,32,73,0.10);
}

.field { display: block; margin-bottom: 14px; }
.field__label {
  display: block;
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: #6b7280; margin-bottom: 6px;
}
.field input {
  width: 100%; padding: 11px 13px;
  border: 1px solid #d6dbe3; border-radius: 4px;
  background: #fff;
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 14px; color: #1d2433;
  transition: border-color 120ms ease, box-shadow 120ms ease, background 120ms ease;
}
.field input:focus {
  outline: none;
  border-color: #052049;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(5,32,73,0.12);
}
.password-submit {
  width: 100%; padding: 12px;
  background: #fff; color: #052049;
  border: 1.5px solid #052049; border-radius: 4px;
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 14px; font-weight: 500; cursor: pointer;
  margin-top: 4px;
  transition: background 120ms ease, color 120ms ease;
}
.password-submit:hover { background: #052049; color: #fff; }
.error {
  color: #b3261e; font-size: 13px; margin-top: 10px;
}

@media (max-width: 480px) {
  .login-card__inner { padding: 36px 28px 32px; }
  .login-title { font-size: 32px; }
}

/* --- Entry page --- */
.topbar {
  background: #052049; color: #fff; padding: 12px 24px;
  display: flex; justify-content: space-between; align-items: center;
}
.brand { font-weight: bold; font-size: 16px; }
.user-info { font-size: 13px; }
.user-info a { color: #4fc3f7; text-decoration: underline; }

.entry-page { min-height: 100vh; }
.entry-card {
  max-width: 700px; margin: 40px auto; background: #fff;
  padding: 32px; border-radius: 8px; box-shadow: 0 1px 6px rgba(0,0,0,0.08);
}
.entry-card h2 { margin-bottom: 16px; color: #333; font-size: 18px; }
.url-row { display: flex; gap: 8px; margin-bottom: 12px; }
.url-row input { flex: 1; padding: 10px 12px; border: 1px solid #ddd; border-radius: 4px; font-size: 14px; }
.url-row button {
  padding: 10px 20px; background: #052049; color: #fff;
  border: none; border-radius: 4px; font-size: 14px; cursor: pointer; white-space: nowrap;
}
.url-row button:hover { background: #0a3060; }
.date-row { display: flex; gap: 16px; align-items: center; }
.recent { margin-top: 16px; font-size: 13px; color: #999; }
.recent a { color: #052049; text-decoration: underline; cursor: pointer; }

/* --- Overlay page --- */
.overlay-page { min-height: 100vh; background: #1a1a2e; }
.overlay-topbar {
  background: #052049; color: #fff; padding: 10px 16px;
  display: flex; justify-content: space-between; align-items: center; font-size: 13px;
}
.overlay-left { display: flex; gap: 16px; align-items: center; }
.overlay-url { color: #aaa; max-width: 400px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.overlay-right { display: flex; gap: 12px; align-items: center; }
.overlay-right a { color: #4fc3f7; text-decoration: none; }
.separator { color: #555; }

.legend {
  background: #0d1b2a; padding: 8px 16px;
  display: flex; gap: 8px; align-items: center; font-size: 12px; color: #aaa;
}
.gradient-bar {
  width: 80px; height: 10px; border-radius: 4px;
  background: linear-gradient(90deg, #3498db, #2ecc71, #f1c40f, #e67e22, #e74c3c);
}
.legend-spacer { width: 40px; }
.legend-hint { margin-left: auto; }

.error-banner {
  background: #2c1810; color: #e67e22; padding: 10px 16px;
  font-size: 13px; text-align: center;
}

.page-container {
  margin: 12px; background: #fff; border-radius: 4px;
  overflow: auto; max-height: calc(100vh - 220px);
}
.page-container .loading { padding: 40px; text-align: center; color: #999; }
.page-iframe {
  height: calc(100vh - 120px); border: none; display: block;
  min-width: 100%;
}

/* --- Tooltip --- */
.tooltip {
  position: absolute; background: #222; color: #fff;
  padding: 10px 14px; border-radius: 6px; font-size: 12px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.4); z-index: 10000;
  pointer-events: none; max-width: 360px;
}
.tooltip-name { font-weight: bold; margin-bottom: 2px; }
.tooltip-url { color: #aaa; font-size: 11px; word-break: break-all; }
.tooltip-region { color: #aaa; font-size: 11px; }
.tooltip-clicks { margin-top: 6px; }
.tooltip-clicks strong { color: #e74c3c; }

/* --- Filter controls --- */
.filters-group {
  background: #f8f9fa; border: 1px solid #e9ecef; border-radius: 6px;
  padding: 12px 14px; margin-top: 14px;
}
.filters-label {
  font-size: 11px; text-transform: uppercase; color: #595959;
  font-weight: 600; letter-spacing: 0.5px; margin-bottom: 8px;
}
.filters-row {
  display: flex; gap: 12px; align-items: center; margin-bottom: 6px;
}
.filters-row label { font-size: 12px; color: #666; }
.filters-row input[type="date"] {
  padding: 4px 6px; border: 1px solid #ddd; border-radius: 3px; font-size: 12px;
}
.filter-select {
  padding: 4px 6px; border: 1px solid #ddd; border-radius: 3px;
  font-size: 12px; background: #fff;
}
.compare-row {
  display: flex; gap: 8px; align-items: center;
}
.compare-toggle {
  font-size: 12px; color: #595959; white-space: nowrap; cursor: pointer;
}
.compare-row input[type="date"] {
  padding: 4px 6px; border: 1px solid #ddd; border-radius: 3px; font-size: 12px;
}
.compare-row input:disabled {
  opacity: 0.4;
}

/* --- Top pages --- */
.top-pages-card {
  max-width: 700px; margin: 16px auto 40px; background: #fff;
  padding: 24px 32px; border-radius: 8px; box-shadow: 0 1px 6px rgba(0,0,0,0.08);
}
.top-pages-title { font-size: 16px; color: #333; margin-bottom: 10px; }
.top-tabs {
  display: flex; gap: 4px; border-bottom: 1px solid #ddd; margin-bottom: 12px;
}
.top-tab {
  background: none; border: none; padding: 8px 14px;
  font-size: 14px; color: #666; cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.top-tab:hover { color: #333; }
.top-tab.active { color: #052049; border-bottom-color: #052049; font-weight: 600; }
.path-filter {
  width: 100%; padding: 8px 12px; border: 1px solid #ddd; border-radius: 4px;
  font-size: 13px; background: #fafafa; margin-bottom: 12px;
}
.top-pages-table .pdf-file { color: #052049; text-decoration: underline; word-break: break-all; }
.top-pages-table .pdf-name { font-size: 11px; color: #777; margin-top: 2px; }
.top-pages-table {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
.top-pages-table th {
  text-align: left; padding: 8px; border-bottom: 2px solid #ddd;
  font-size: 12px; color: #666; text-transform: uppercase;
}
.top-pages-table th.num, .top-pages-table td.num { text-align: right; }
.top-pages-table td { padding: 8px; border-bottom: 1px solid #eee; }
.top-pages-table tbody tr {
  cursor: pointer; transition: background 0.1s;
}
.top-pages-table tbody tr:hover { background: #f0f7ff; }
.top-pages-table .page-link { color: #052049; text-decoration: underline; }
.top-pages-table .top-element { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; color: #555; }
.top-pages-empty { font-size: 13px; color: #999; padding: 16px 0; }

/* --- Overlay device dropdown --- */
.overlay-select {
  background: #1a1a2e; color: #fff; border: 1px solid #555;
  border-radius: 4px; padding: 2px 6px; font-size: 12px;
}

/* --- Top navigation --- */
.nav-left { display: flex; align-items: center; gap: 16px; }
.topbar-nav { display: flex; gap: 4px; }
.topbar-site {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 4px 4px 10px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.22);
  border-radius: 4px;
}
.topbar-site:hover { background: rgba(255,255,255,0.14); border-color: rgba(255,255,255,0.38); }
.topbar-site-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px;
  color: rgba(255,255,255,0.7); font-weight: 600;
}
.topbar-site-select {
  background: transparent; color: #fff; border: 0;
  font-size: 13px; padding: 2px 4px; cursor: pointer;
  appearance: none; -webkit-appearance: none;
  padding-right: 18px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%23ffffff' d='M0 0l5 6 5-6z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 4px center;
}
.topbar-site-select:focus { outline: 2px solid #4fc3f7; outline-offset: 2px; }
.topbar-site-select option { color: #052049; background: #fff; }
.nav-link {
  color: rgba(255,255,255,0.85); text-decoration: none; font-size: 13px;
  padding: 4px 10px; border-radius: 4px;
}
.nav-link:hover { color: #fff; background: rgba(255,255,255,0.15); }
.nav-link.active { color: #fff; font-weight: 600; border-bottom: 2px solid #fff; }

/* --- PRN page --- */
.prn-page { min-height: 100vh; }

.prn-card {
  max-width: 800px; margin: 40px auto 0; background: #fff;
  padding: 24px 32px; border-radius: 8px; box-shadow: 0 1px 6px rgba(0,0,0,0.08);
}
.prn-card h2 { font-size: 16px; color: #333; margin-bottom: 12px; }

.prn-form-row { display: flex; gap: 8px; align-items: end; }
.prn-form-row .field { flex: 1; }
.prn-form-row .field-small { width: 80px; }
.prn-form-row label { display: block; font-size: 11px; color: #666; margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.3px; }
.prn-form-row input {
  width: 100%; padding: 8px 12px; border: 1px solid #ddd;
  border-radius: 4px; font-size: 14px;
}
.prn-form-row button {
  padding: 8px 20px; background: #052049; color: #fff;
  border: none; border-radius: 4px; font-size: 14px;
  cursor: pointer; white-space: nowrap;
}
.prn-form-row button:hover { background: #0a3060; }

.prn-error {
  color: #c0392b; font-size: 13px; margin-top: 8px;
}

.prn-section {
  max-width: 800px; margin: 16px auto 0; background: #fff;
  padding: 24px 32px; border-radius: 8px; box-shadow: 0 1px 6px rgba(0,0,0,0.08);
}
.prn-section:last-child { margin-bottom: 40px; }
.prn-section-title {
  font-size: 14px; font-weight: 600; color: #333; margin-bottom: 10px;
}
.prn-section-title.active { color: #28a745; }

.prn-table {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
.prn-table th {
  text-align: left; padding: 6px 8px; border-bottom: 2px solid #ddd;
  font-size: 11px; color: #666; text-transform: uppercase;
}
.prn-table th.num, .prn-table td.num { text-align: right; }
.prn-table td { padding: 6px 8px; border-bottom: 1px solid #eee; }
.prn-table .page-url { color: #052049; }
.prn-table .action-stop { color: #c0392b; cursor: pointer; text-decoration: underline; font-size: 12px; border: none; background: none; }
.prn-table .action-stop:hover { color: #e74c3c; }
.prn-table .action-retrack { color: #6c63ff; cursor: pointer; text-decoration: underline; font-size: 12px; border: none; background: none; }
.prn-table .action-retrack:hover { color: #8b83ff; }

.prn-empty { font-size: 13px; color: #999; padding: 8px 0; }
.prn-loading { font-size: 13px; color: #999; padding: 16px 0; }

/* --- View mode toggle --- */
.view-toggle {
  display: inline-flex; border: 1px solid #555; border-radius: 4px; overflow: hidden;
}
.view-btn {
  background: transparent; color: #aaa; border: none; padding: 2px 10px;
  font-size: 12px; cursor: pointer; border-right: 1px solid #555;
}
.view-btn:last-child { border-right: none; }
.view-btn:hover { color: #fff; }
.view-btn.active { background: #052049; color: #fff; font-weight: 600; }
.layer-btn {
  background: transparent; color: #aaa; border: none; padding: 2px 10px;
  font-size: 12px; cursor: pointer; border-right: 1px solid #555;
}
.layer-btn:last-of-type { border-right: none; }
.layer-btn:hover { color: #fff; }
.layer-btn.active { background: #052049; color: #fff; font-weight: 600; }
.layer-btn:disabled { color: #555; cursor: not-allowed; }
.sub-btn {
  background: transparent; color: #aaa; border: 1px solid #555; padding: 1px 7px;
  font-size: 11px; cursor: pointer; border-radius: 3px; margin-left: 4px;
}
.sub-btn.active { background: #052049; color: #fff; }
.sub-btn:hover { color: #fff; }
#raw-clicks-sub { margin-left: 6px; }

/* --- PRN info line in legend --- */
.prn-info { color: #aaa; font-size: 12px; }

/* --- Snapshot banner --- */
.snapshot-banner {
  background: #1a1508; color: #d4a017; padding: 8px 16px;
  font-size: 12px; text-align: center;
}

/* --- Mouse heatmap canvas --- */
.mouse-heatmap-canvas {
  position: absolute; top: 0; left: 0; pointer-events: none; z-index: 9998;
}

/* --- UX friction indicator --- */
.friction-outline {
  outline: 2px dashed #e67e22 !important;
  outline-offset: 1px;
}

/* --- PRN heatmap link --- */
.prn-table .action-heatmap {
  color: #052049; cursor: pointer; text-decoration: underline;
  font-size: 12px;
}
.prn-table .action-heatmap:hover { color: #0a3060; }

/* --- Unmatched comp-click rows panel --- */
.unmatched-panel { margin: 16px 0; padding: 12px 16px; background: #2a2a3e;
  border-left: 4px solid #ff4081; border-radius: 4px; font-size: 14px; color: #eee; }
.unmatched-panel summary { cursor: pointer; font-weight: 600; color: #fff;
  padding: 8px 0; user-select: none; font-size: 15px; line-height: 1.5;
  min-height: 24px; }
.unmatched-panel summary::marker { color: #ff80ab; }
.unmatched-panel summary:hover { color: #ff80ab; }
.unmatched-panel summary .count { color: #ff80ab; margin-left: 4px; }
.unmatched-panel .rows { margin-top: 10px; max-height: 260px; overflow-y: auto;
  background: #1f1f2e; padding: 6px 10px; border-radius: 3px; }
.unmatched-panel[open] .rows { max-height: 60vh; }
.unmatched-panel .row { display: grid; grid-template-columns: 140px 1fr 70px;
  gap: 12px; padding: 10px 4px; border-bottom: 1px solid #3a3a4e; align-items: baseline; }
.unmatched-panel .row:last-child { border-bottom: none; }
.unmatched-panel .comp { color: #ff80ab; font-family: ui-monospace, monospace; font-size: 12px; }
.unmatched-panel .name { color: #eee; }
.unmatched-panel .count { text-align: right; font-variant-numeric: tabular-nums; color: #fff; font-weight: 600; }

.overlay-site {
  opacity: 0.6;
  font-size: 0.85em;
  margin-right: 0.5em;
}

/* --- Intro panel --- */
.intro-card {
  max-width: 700px; margin: 40px auto 16px; background: #fff;
  padding: 18px 32px; border-radius: 8px; box-shadow: 0 1px 6px rgba(0,0,0,0.08);
  border-left: 4px solid #052049;
}
.intro-card summary {
  cursor: pointer; font-size: 15px; font-weight: 600;
  color: #052049; text-transform: uppercase; letter-spacing: 0.5px;
  list-style: revert; /* keep the browser's default disclosure triangle */
}
.intro-card summary:focus-visible {
  outline: 2px solid #052049; outline-offset: 2px;
}
.intro-card[open] summary { margin-bottom: 12px; }
.intro-card .intro-body p {
  font-size: 13px; color: #333; line-height: 1.55; margin-bottom: 10px;
}
.intro-card .intro-body p:last-child { margin-bottom: 0; }
.intro-card .intro-body strong { color: #052049; }

/* --- Top pages sortable headers --- */
.top-pages-table th.sortable { cursor: pointer; user-select: none; }
.top-pages-table th.sortable:hover { color: #333; }
.top-pages-table th.sortable.active::after {
  content: '▼'; margin-left: 4px; font-size: 10px;
}
.top-pages-table th.sortable.active[data-sort-dir="asc"]::after { content: '▲'; }
.top-pages-table td.num.dim { color: #999; }

/* Focusable skip link — visually revealed when it receives keyboard focus. */
.skip-link {
  position: absolute; left: 8px; top: -40px;
  background: #052049; color: #fff; padding: 8px 14px;
  border-radius: 4px; z-index: 100;
  transition: top 120ms ease;
}
.skip-link:focus { top: 8px; outline: 2px solid #18a3ac; outline-offset: 2px; }

.report-header { padding: 24px 32px; }
.report-meta { color: #4a5263; font-size: 14px; }
.report-status { padding: 16px 32px; color: #4a5263; }
.report-summary { display: flex; gap: 10px; padding: 0 32px 16px; }
.report-summary .stat { padding: 4px 10px; border-radius: 4px; border: 1px solid #c7ccd6; font-size: 13px; color: #1d2433; }

.table-wrap { padding: 0 32px 40px; overflow-x: auto; }
#diff-table { width: 100%; border-collapse: collapse; font-size: 14px; }
#diff-table th, #diff-table td {
  text-align: left; padding: 10px 12px; border-bottom: 1px solid #e1e4ea; vertical-align: top;
}
#diff-table thead th { background: #f0f2f5; color: #1d2433; font-weight: 600; }

.change { font-weight: 600; }
.change--added   { color: #1a7f37; }
.change--removed { color: #b42318; }
.change--modified{ color: #0a3060; }
.change--added::before    { content: "＋ "; }
.change--removed::before  { content: "－ "; }
.change--modified::before { content: "✎ "; }

.field-changes { margin: 0; padding-left: 18px; }
.npi { color: #5f6571; font-size: 12px; }
