/* Performance Dashboard — styles layered on Bootstrap 5.3.
   Tokens: canvas, surface, ink, muted, line, accent, up, down. */

@font-face { font-family: "IBM Plex Sans"; font-weight: 400; font-style: normal; font-display: swap; src: url("../lib/fonts/ibm-plex-sans-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-weight: 500; font-style: normal; font-display: swap; src: url("../lib/fonts/ibm-plex-sans-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-weight: 600; font-style: normal; font-display: swap; src: url("../lib/fonts/ibm-plex-sans-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-weight: 700; font-style: normal; font-display: swap; src: url("../lib/fonts/ibm-plex-sans-latin-700-normal.woff2") format("woff2"); }

:root,
[data-bs-theme="light"] {
  --canvas: #f3f5f8;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --ink: #16202c;
  --muted: #5d6a79;
  --line: #e1e6ed;
  --line-strong: #cdd5df;
  --accent: #1f5fbf;
  --accent-soft: #e8f0fb;
  --up: #17794a;
  --down: #b4232f;
  --warn: #8a5a00;
  --shadow: 0 1px 2px rgba(22, 32, 44, .05);
  --bs-body-bg: var(--canvas);
  --bs-body-color: var(--ink);
  --bs-primary: #1f5fbf;
  --bs-primary-rgb: 31, 95, 191;
  --bs-link-color: #1f5fbf;
  --bs-link-color-rgb: 31, 95, 191;
  --bs-border-color: var(--line);
  --bs-secondary-color: var(--muted);
}
[data-bs-theme="dark"] {
  --canvas: #0e131a;
  --surface: #151c25;
  --surface-2: #1a2330;
  --ink: #e5eaf0;
  --muted: #98a4b3;
  --line: #263141;
  --line-strong: #344256;
  --accent: #5b9bff;
  --accent-soft: #1a2a44;
  --up: #45c286;
  --down: #ff7a85;
  --warn: #e3b341;
  --shadow: none;
  --bs-body-bg: var(--canvas);
  --bs-body-color: var(--ink);
  --bs-primary: #5b9bff;
  --bs-primary-rgb: 91, 155, 255;
  --bs-link-color: #7fb0ff;
  --bs-link-color-rgb: 127, 176, 255;
  --bs-border-color: var(--line);
  --bs-secondary-color: var(--muted);
}

body {
  font-family: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: .9375rem;
  background: var(--canvas);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
.num, .data-table td.num, .kpi-value, .data-table td.text-end { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.skip-link { position: absolute; left: 1rem; top: .5rem; z-index: 2000; background: var(--surface); padding: .5rem 1rem; border-radius: .375rem; }
.btn-primary { --bs-btn-bg: var(--accent); --bs-btn-border-color: var(--accent); --bs-btn-hover-bg: #194f9f; --bs-btn-hover-border-color: #194f9f; --bs-btn-active-bg: #164689; }
[data-bs-theme="dark"] .btn-primary { --bs-btn-color: #0e131a; --bs-btn-hover-color: #0e131a; --bs-btn-hover-bg: #7fb0ff; --bs-btn-hover-border-color: #7fb0ff; --bs-btn-active-bg: #7fb0ff; }
.btn-outline-primary { --bs-btn-color: var(--accent); --bs-btn-border-color: var(--accent); --bs-btn-hover-bg: var(--accent); --bs-btn-hover-border-color: var(--accent); }
.btn .bi + span { margin-left: .4rem; }
.btn-icon { width: 2.25rem; height: 2.25rem; display: inline-flex; align-items: center; justify-content: center; padding: 0; border-radius: .5rem; color: var(--muted); font-size: 1.15rem; }
.btn-icon:hover { background: var(--surface-2); color: var(--ink); }

/* ------------------------------------------------------------------ shell */
.app-shell { display: flex; min-height: 100vh; }
.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.sidebar { width: 250px; flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--line); padding: 1rem .75rem; }
@media (min-width: 992px) {
  .sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; }
}
.sidebar-brand { display: flex; align-items: center; gap: .6rem; padding: .25rem .5rem 1rem; font-weight: 600; font-size: 1rem; }
.brand-mark { width: 2rem; height: 2rem; border-radius: .5rem; background: var(--accent); color: #fff; display: inline-flex; align-items: center; justify-content: center; }
[data-bs-theme="dark"] .brand-mark { color: #0e131a; }
.sidebar-section { font-size: .75rem; color: var(--muted); padding: 1rem .75rem .35rem; font-weight: 500; }
.sidebar .nav-link { display: flex; align-items: center; gap: .65rem; color: var(--ink); padding: .5rem .75rem; border-radius: .45rem; font-size: .9rem; }
.sidebar .nav-link .bi { color: var(--muted); font-size: 1rem; }
.sidebar .nav-link:hover { background: var(--surface-2); }
.sidebar .nav-link.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.sidebar .nav-link.active .bi { color: var(--accent); }

.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 1020; }
.topbar-row { display: flex; align-items: center; gap: .75rem; padding: .7rem 1.5rem; }
.page-title { font-size: 1.2rem; font-weight: 600; margin: 0; flex: 1; letter-spacing: -.01em; }
.topbar-actions { display: flex; align-items: center; gap: .5rem; }
.content { padding: 1.5rem; display: flex; flex-direction: column; gap: 1rem; max-width: 1600px; width: 100%; }
.content > .row, #pageBody > .row { --bs-gutter-y: 1rem; }
#pageBody { display: flex; flex-direction: column; gap: 1rem; }

/* ------------------------------------------------------------------ filters */
.filter-bar, .content-filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .6rem 1rem; }
.filter-bar { padding: .6rem 1.5rem .8rem; border-top: 1px solid var(--line); background: var(--surface-2); }
.content-filters { margin-bottom: 1rem; }
.fb-group { display: flex; flex-direction: column; gap: .2rem; min-width: 9rem; }
.fb-group.grow { flex: 1; min-width: 14rem; }
.fb-group label { font-size: .75rem; color: var(--muted); font-weight: 500; }
.fb-actions { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.fb-summary { flex-basis: 100%; font-size: .8rem; color: var(--muted); }
.fb-summary strong { color: var(--ink); font-weight: 600; }

/* ------------------------------------------------------------------ panels */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: .6rem; padding: 1.1rem 1.25rem; box-shadow: var(--shadow); }
.panel + .panel { margin-top: 1rem; }
.col-xl-4 > .panel + .panel, .d-flex.flex-column > .panel + .panel { margin-top: 0; }
.panel h2 { font-size: 1rem; font-weight: 600; margin: 0 0 .75rem; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; margin-bottom: .75rem; }
.panel-head h2 { margin: 0; }
.h-sub { font-size: .85rem; font-weight: 600; color: var(--muted); margin: 0 0 .5rem; }
.panel-note { font-size: .8rem; color: var(--muted); margin: .5rem 0 0; }
.panel > .panel-note:first-of-type { margin-top: -.4rem; margin-bottom: .75rem; }
.note-list { padding-left: 1.1rem; margin: 0; font-size: .875rem; }
.note-list li + li { margin-top: .5rem; }
.chart-box { position: relative; height: 300px; }
.chart-box.short { height: 220px; }
.chart-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; color: var(--muted); font-size: .875rem; padding: 1rem; }
.loading { color: var(--muted); font-size: .875rem; padding: .5rem 0; }
.prose { max-width: 75ch; }
.prose li + li { margin-top: .35rem; }

/* ------------------------------------------------------------------ KPI tiles: the one expressive element */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(205px, 1fr)); gap: 1rem; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-top: 3px solid var(--line-strong); border-radius: .6rem; padding: .9rem 1rem .85rem; display: flex; flex-direction: column; gap: .15rem; box-shadow: var(--shadow); min-height: 9.2rem; }
.kpi.is-up { border-top-color: var(--up); }
.kpi.is-down { border-top-color: var(--down); }
.kpi-label { font-size: .8rem; color: var(--muted); font-weight: 500; display: flex; align-items: center; gap: .3rem; }
.kpi-info { border: 0; background: none; color: var(--muted); padding: 0; line-height: 1; font-size: .8rem; }
.kpi-value { font-size: 1.85rem; font-weight: 600; letter-spacing: -.02em; line-height: 1.15; margin-top: .15rem; }
.kpi-value.is-na { color: var(--muted); font-size: 1.35rem; font-weight: 500; }
.kpi-change { font-size: .85rem; font-weight: 600; }
.kpi-change.up { color: var(--up); } .kpi-change.down { color: var(--down); } .kpi-change.flat { color: var(--muted); }
.kpi-compare { font-size: .78rem; color: var(--muted); }
.kpi-note { font-size: .72rem; color: var(--muted); margin-top: auto; padding-top: .35rem; }

/* ------------------------------------------------------------------ tables */
.data-table { --bs-table-bg: transparent; font-size: .85rem; margin-bottom: 0; }
.data-table thead th { font-size: .75rem; font-weight: 600; color: var(--muted); border-bottom-width: 1px; border-color: var(--line-strong); white-space: nowrap; background: var(--surface); }
.data-table td { border-color: var(--line); vertical-align: middle; }
.data-table th.sortable { cursor: pointer; user-select: none; }
.data-table th.sortable:hover { color: var(--ink); }
.data-table th[aria-sort="ascending"]::after { content: " ▲"; font-size: .65rem; }
.data-table th[aria-sort="descending"]::after { content: " ▼"; font-size: .65rem; }
.data-table .na { color: var(--muted); }
.post-title { max-width: 26rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.platform-dot { display: inline-block; width: .55rem; height: .55rem; border-radius: 50%; margin-right: .4rem; vertical-align: middle; }
.chg-up { color: var(--up); } .chg-down { color: var(--down); }
.mini-list { list-style: none; padding: 0; margin: 0; }
.mini-list li { display: flex; gap: .75rem; justify-content: space-between; align-items: baseline; padding: .5rem 0; border-bottom: 1px solid var(--line); font-size: .85rem; }
.mini-list li:last-child { border-bottom: 0; }
.mini-list .meta { font-size: .75rem; color: var(--muted); }
.mini-list .val { font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.mini-list button.link { border: 0; background: none; padding: 0; text-align: left; color: var(--ink); }
.mini-list button.link:hover { color: var(--accent); text-decoration: underline; }

.big-stat { font-size: 1.7rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: .3rem 1rem; font-size: .85rem; margin: 0 0 .75rem; }
.facts dt { color: var(--muted); font-weight: 500; }
.facts dd { margin: 0; }

/* ------------------------------------------------------------------ platform tabs */
.platform-tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); overflow-x: auto; }
.platform-tab { padding: .55rem 1rem; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; font-weight: 500; }
.platform-tab:hover { color: var(--ink); }
.platform-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ------------------------------------------------------------------ empty states */
.empty-state { text-align: center; padding: 3.5rem 1rem; background: var(--surface); border: 1px dashed var(--line-strong); border-radius: .6rem; }
.empty-state.compact { padding: 2rem 1rem; border: 0; }
.empty-state .bi { font-size: 2.2rem; color: var(--muted); }
.empty-state h2 { font-size: 1.15rem; margin: .75rem 0 .35rem; }
.empty-state p { color: var(--muted); max-width: 46ch; margin: 0 auto 1rem; }

/* ------------------------------------------------------------------ import wizard */
.wizard-steps { display: flex; list-style: none; padding: 0; margin: 0; gap: .25rem; counter-reset: step; overflow-x: auto; }
.wizard-steps li { flex: 1; min-width: 7.5rem; font-size: .8rem; color: var(--muted); padding: .5rem .25rem; border-top: 3px solid var(--line); counter-increment: step; }
.wizard-steps li::before { content: counter(step) ". "; font-weight: 600; }
.wizard-steps li.done { border-top-color: var(--up); color: var(--ink); }
.wizard-steps li.active { border-top-color: var(--accent); color: var(--accent); font-weight: 600; }
.wizard-nav { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.dropzone { border: 2px dashed var(--line-strong); border-radius: .6rem; padding: 2.25rem 1rem; text-align: center; cursor: pointer; background: var(--surface-2); margin-bottom: 1rem; }
.dropzone .bi { font-size: 2rem; color: var(--accent); }
.dropzone.is-over { border-color: var(--accent); background: var(--accent-soft); }
.file-list, .queue, .sample-list { list-style: none; padding: 0; margin: 0 0 1rem; }
.file-list li { display: flex; justify-content: space-between; gap: .5rem; padding: .45rem .1rem; border-bottom: 1px solid var(--line); font-size: .85rem; }
.queue li { padding: .45rem 0; border-bottom: 1px solid var(--line); font-size: .82rem; display: flex; gap: .5rem; align-items: flex-start; }
.queue li.current { font-weight: 600; }
.queue .bi { margin-top: .1rem; }
.sample-list li { font-size: .8rem; padding: .2rem 0; word-break: break-all; }
.preview-table { max-height: 360px; overflow: auto; border: 1px solid var(--line); border-radius: .4rem; }
.preview-table table { font-size: .78rem; margin: 0; }
.preview-table th { position: sticky; top: 0; background: var(--surface-2); white-space: nowrap; }
.preview-table td { white-space: nowrap; max-width: 16rem; overflow: hidden; text-overflow: ellipsis; }
.mapping-table td:first-child { font-weight: 500; }
.mapping-table .sample { font-size: .75rem; color: var(--muted); max-width: 16rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mapping-table select { min-width: 14rem; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.stat { border: 1px solid var(--line); border-radius: .5rem; padding: .6rem .75rem; }
.stat .v { font-size: 1.35rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat .l { font-size: .75rem; color: var(--muted); }
.stat.bad .v { color: var(--down); } .stat.good .v { color: var(--up); } .stat.warn .v { color: var(--warn); }
.diff-table td, .diff-table th { font-size: .78rem; }
.strategy { border: 1px solid var(--line); border-radius: .5rem; padding: .75rem 1rem; margin-bottom: 1rem; }
.strategy legend { font-size: .9rem; font-weight: 600; float: none; margin-bottom: .35rem; }
.saved-menu { min-width: 20rem; }

.badge.status-completed { background: var(--accent-soft); color: var(--accent); }
.badge.status-replaced { background: #fff4d6; color: #7a5200; }
.badge.status-removed { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.badge.status-uploaded, .badge.status-validated { background: #fff4d6; color: #7a5200; }
.badge.status-failed { background: #fde3e5; color: var(--down); }
[data-bs-theme="dark"] .badge.status-uploaded, [data-bs-theme="dark"] .badge.status-validated { background: #3a2f12; color: var(--warn); }
[data-bs-theme="dark"] .badge.status-failed { background: #3c1a1f; }

/* ------------------------------------------------------------------ report preview */
.report { background: var(--surface); border: 1px solid var(--line); border-radius: .6rem; padding: 2rem 2.25rem; }
.report-head h2 { font-size: 1.5rem; font-weight: 600; margin: 0; letter-spacing: -.01em; }
.report-head .period { color: var(--muted); margin-top: .25rem; }
.report section { margin-top: 1.75rem; }
.report h3 { font-size: 1.05rem; font-weight: 600; border-bottom: 2px solid var(--accent); padding-bottom: .35rem; margin-bottom: .85rem; }
.report .summary { background: var(--surface-2); border-left: 3px solid var(--accent); padding: .9rem 1.1rem; max-width: 80ch; }
.report .insight { margin-bottom: .6rem; }
.report .evidence { display: block; font-size: .8rem; color: var(--muted); }

/* ------------------------------------------------------------------ auth */
.auth-body { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.5rem; }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line); border-radius: .75rem; padding: 2rem; box-shadow: var(--shadow); }
.auth-brand { display: flex; align-items: center; gap: .6rem; font-weight: 600; margin-bottom: 1.5rem; }
.auth-title { font-size: 1.3rem; font-weight: 600; margin-bottom: 1rem; }

/* ------------------------------------------------------------------ responsive */
@media (max-width: 991.98px) {
  .sidebar.offcanvas-lg { width: 270px; }
  .topbar-row { padding: .6rem 1rem; }
  .filter-bar { padding: .6rem 1rem .75rem; }
  .content { padding: 1rem; }
}
@media (max-width: 575.98px) {
  .fb-group { min-width: calc(50% - .5rem); flex: 1; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }
  .kpi { min-height: 8rem; padding: .75rem; }
  .kpi-value { font-size: 1.4rem; }
  .chart-box { height: 240px; }
  .report { padding: 1.25rem; }
  .page-title { font-size: 1.05rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* ------------------------------------------------------------------ print (report preview) */
@media print {
  .sidebar, .topbar, .no-print, .toast-container { display: none !important; }
  .content { padding: 0; }
  .report { border: 0; padding: 0; }
  body { background: #fff; }
}

/* ------------------------------------------------------------------ import: one card per platform */
.platform-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 1rem; }
@media (min-width: 1200px) { .platform-cards { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
.pcard { border: 1px solid var(--line); border-radius: .6rem; padding: 1rem; display: flex; flex-direction: column; gap: .7rem; background: var(--surface); }
.pcard.has-file { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.pcard-head { display: flex; align-items: center; gap: .6rem; }
.pcard-head h3 { font-size: 1rem; font-weight: 600; margin: 0; }
.pcard-icon { width: 2.1rem; height: 2.1rem; border-radius: .5rem; display: inline-flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--pc) 14%, transparent); color: var(--pc); font-size: 1.1rem; }
[data-bs-theme="dark"] .pcard-icon { color: color-mix(in srgb, var(--pc) 60%, white); }
.pcard-facts { display: grid; grid-template-columns: 1fr 1fr; gap: .45rem .75rem; font-size: .8rem; margin: 0; }
.pcard-facts > div { min-width: 0; }
.pcard-facts > div.wide { grid-column: 1 / -1; }
.pcard-facts dt { color: var(--muted); font-weight: 500; font-size: .72rem; }
.pcard-facts dd { margin: 0; font-variant-numeric: tabular-nums; }
.pcard-drop { border: 2px dashed var(--line-strong); border-radius: .5rem; padding: .9rem .6rem; text-align: center; font-size: .82rem; cursor: pointer; background: var(--surface-2); }
.pcard-drop.is-over { border-color: var(--accent); background: var(--accent-soft); }
.pcard.has-file .pcard-drop { border-style: solid; border-color: var(--accent); background: var(--accent-soft); }
.pcard-drop .file-chip { display: flex; justify-content: space-between; align-items: center; gap: .4rem; text-align: left; }
.pcard-drop .file-chip + .file-chip { margin-top: .35rem; }
.pcard-drop .file-chip > span { word-break: break-all; min-width: 0; }
.pcard-drop .file-chip button { border: 0; background: none; color: var(--down); padding: 0; font-size: .78rem; white-space: nowrap; flex-shrink: 0; }
.sample-list.columns { columns: 2 18rem; }
.type-table td, .type-table th { font-size: .82rem; }
.choice-box { border: 1px solid var(--warn); border-radius: .5rem; padding: .75rem 1rem; margin-bottom: 1rem; }
.choice-box legend { font-size: .9rem; font-weight: 600; float: none; margin-bottom: .35rem; }
