/* Self-hosted IBM Plex fonts (file:// friendly). */
@font-face {
  font-family: "IBM Plex Sans";
  src: url("../assets/fonts/IBMPlexSans-Regular.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Sans";
  src: url("../assets/fonts/IBMPlexSans-Medium.woff2") format("woff2");
  font-style: normal;
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Sans";
  src: url("../assets/fonts/IBMPlexSans-SemiBold.woff2") format("woff2");
  font-style: normal;
  font-weight: 600 699;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("../assets/fonts/IBMPlexMono-Regular.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("../assets/fonts/IBMPlexMono-Medium.woff2") format("woff2");
  font-style: normal;
  font-weight: 500;
  font-display: swap;
}

/* TriLumen Systems — POS · Books Sync Before/After (light BI theme) */
:root {
  --bg: #f4f6f9;
  --bg-elev: #ffffff;
  --bg-card: #ffffff;
  --bg-card-2: #f8fafc;
  --border: #d7dee8;
  --border-soft: #e4e9f0;
  --text: #1a2332;
  --text-dim: #5a6a80;
  --text-mute: #7a8799;
  --accent: #4C4272;
  --accent-2: #7C70B8;
  --accent-3: #d97706;
  --danger: #dc2626;
  --good: #059669;
  --warn: #ca8a04;
  --chip: #eef2f7;
  --row-hover: rgba(76, 66, 114, 0.06);
  --row-active: rgba(124, 112, 184, 0.08);
  --shadow: 0 1px 3px rgba(26, 35, 50, 0.06), 0 4px 16px rgba(26, 35, 50, 0.04);
  --radius: 10px;
  --font: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

.redact {
  display: inline-block;
  height: .82em;
  width: 4.8em;
  background: #000;
  border-radius: 1px;
  vertical-align: -.06em;
}
.redact-client { width: 12em; height: .92em; }
.redact-footer { width: 9em; height: .78em; }
.redact-inline { width: 5.5em; height: .78em; margin: 0 .15em; }

html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-2); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

.app {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 50;
}
.brand-block { display: flex; flex-direction: column; gap: 2px; min-width: 220px; }
.brand-kicker {
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-mute);
}
.brand-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.brand-sub {
  color: var(--text-dim);
  font-size: 11px;
  max-width: 340px;
  transition: color .2s;
}
.app[data-mode="after"] .brand-sub { color: var(--accent); }

.topbar-center { flex: 1; display: flex; align-items: center; }

.controls-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.seg {
  display: inline-flex; background: var(--bg-card-2); border: 1px solid var(--border);
  border-radius: 8px; padding: 2px; gap: 2px;
}
.seg button {
  border: none; background: transparent; color: var(--text-dim);
  padding: 5px 14px; border-radius: 6px; font-size: 12px; font-weight: 500;
}
.seg button.active {
  background: #ffffff;
  color: var(--accent-2);
  box-shadow: 0 1px 2px rgba(26, 35, 50, 0.08);
  border: 1px solid var(--border-soft);
  font-weight: 600;
}
.app[data-mode="before"] .seg button[data-mode="before"].active {
  color: var(--danger);
}
.app[data-mode="after"] .seg button[data-mode="after"].active {
  color: var(--good);
}

.badge-sample {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(217, 119, 6, 0.1);
  color: var(--accent-3);
  border: 1px solid rgba(217, 119, 6, 0.3);
  padding: 4px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.04em;
  text-transform: uppercase;
}
.badge-sample::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent-3);
}

.logo-wrap {
  display: flex; flex-direction: column; align-items: flex-end; gap: 4px;
  margin-left: auto;
  flex-shrink: 0;
}
.logo-wrap img {
  width: 180px;
  height: auto;
  max-height: 40px;
  display: block;
  object-fit: contain;
  object-position: right center;
}

/* Main */
.main {
  flex: 1;
  padding: 14px 18px 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
}

.panel {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex; flex-direction: column;
  min-height: 0;
}
.panel-hd {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 10px 14px;
  border-bottom: 1px solid var(--border-soft);
  background: var(--bg-card-2);
  border-radius: var(--radius) var(--radius) 0 0;
}
.panel-hd h2 {
  margin: 0; font-size: 13px; font-weight: 600; letter-spacing: -0.01em;
}
.panel-hd .meta { color: var(--text-mute); font-size: 11px; }
.panel-bd { padding: 14px 16px; flex: 1; }

/* KPIs */
.kpi-grid {
  display: grid;
  gap: 10px;
}
.kpi-five { grid-template-columns: repeat(5, 1fr); }
@media (max-width: 980px) {
  .kpi-five { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 720px) {
  .kpi-five { grid-template-columns: repeat(2, 1fr); }
  .topbar { flex-wrap: wrap; }
  .logo-wrap { order: -1; width: 100%; flex-direction: row; justify-content: flex-end; align-items: center; }
  .logo-wrap img { width: 160px; }
}

.kpi {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: var(--shadow);
  min-height: 88px;
  display: flex; flex-direction: column; gap: 4px;
  transition: border-color .2s, box-shadow .2s;
}
.kpi.worse { border-color: rgba(220, 38, 38, 0.35); }
.kpi.better { border-color: rgba(5, 150, 105, 0.35); }
.kpi .label {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-mute); font-weight: 600;
}
.kpi .value {
  font-size: 22px; font-weight: 600; letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  transition: color .2s;
}
.kpi .value.flip { animation: valueFlip .35s ease; }
@keyframes valueFlip {
  0% { opacity: 0.3; transform: translateY(4px); }
  100% { opacity: 1; transform: translateY(0); }
}
.kpi .delta {
  font-size: 11px; font-family: var(--mono); color: var(--text-dim);
  display: flex; gap: 6px; align-items: center; margin-top: auto;
}
.kpi .delta .up { color: var(--good); }
.kpi .delta .down { color: var(--danger); }
.kpi .delta .flat { color: var(--text-mute); }
.kpi .delta .arrow-mark { font-weight: 600; }

/* Bottom board */
.source-chips {
  display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px;
}
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--chip);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  color: var(--text-dim);
}
.chip.bad {
  background: rgba(220, 38, 38, 0.06);
  border-color: rgba(220, 38, 38, 0.2);
  color: var(--danger);
}
.chip.good {
  background: rgba(5, 150, 105, 0.08);
  border-color: rgba(5, 150, 105, 0.22);
  color: var(--good);
}
.chip .chip-icon { font-size: 13px; }

table.data {
  width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums;
}
table.data th {
  text-align: left; font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-mute); font-weight: 600;
  padding: 8px 8px; border-bottom: 1px solid var(--border);
  background: var(--bg-elev);
}
table.data th.num, table.data td.num { text-align: right; }
table.data td {
  padding: 8px 8px; border-bottom: 1px solid var(--border-soft);
  color: var(--text);
}
table.data tr.clickable { cursor: pointer; transition: background .12s; }
table.data tbody tr.clickable:hover { background: var(--row-hover); }
table.data tbody tr.active { background: var(--row-active); }
table.data .mono { font-family: var(--mono); font-size: 12px; }
table.data .sub { color: var(--text-mute); font-size: 11px; display: block; }

.status {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600;
}
.status.ok { background: rgba(5, 150, 105, 0.12); color: var(--good); }
.status.err { background: rgba(220, 38, 38, 0.1); color: var(--danger); }
.status.warn { background: rgba(202, 138, 4, 0.12); color: var(--warn); }
.status .check { font-size: 12px; }

.hint {
  color: var(--text-mute); font-size: 11px; margin-top: 10px;
}

/* Drawer */
.drawer-backdrop {
  position: fixed; inset: 0; background: rgba(26, 35, 50, 0.35);
  opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 80;
}
.drawer-backdrop.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; height: 100%; width: min(400px, 100%);
  background: var(--bg-elev); border-left: 1px solid var(--border);
  box-shadow: -8px 0 28px rgba(26, 35, 50, 0.12);
  transform: translateX(105%); transition: transform .25s ease;
  z-index: 90; display: flex; flex-direction: column;
}
.drawer.open { transform: translateX(0); }
.drawer-hd {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 16px 18px; border-bottom: 1px solid var(--border);
  background: var(--bg-card-2);
}
.drawer-hd h3 { margin: 0; font-size: 15px; }
.drawer-hd .id { font-family: var(--mono); color: var(--accent-3); font-size: 12px; margin-top: 4px; }
.drawer-close {
  background: var(--chip); border: 1px solid var(--border); color: var(--text);
  width: 32px; height: 32px; border-radius: 8px; font-size: 16px;
}
.drawer-bd { padding: 16px 18px; overflow: auto; flex: 1; }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 8px 12px; margin-bottom: 14px; }
.kv .k { color: var(--text-mute); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
.kv .v { font-weight: 500; }
.drawer-note {
  background: var(--chip);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.5;
}
#drawerBody { display: flex; flex-direction: column; height: 100%; min-height: 0; }

.footer-note {
  text-align: center; color: var(--text-mute); font-size: 10px;
  padding: 8px 18px 16px; letter-spacing: 0.04em;
}

/* Embed mode: hide TriLumen wordmark + footer; unstick chrome; keep 5 KPIs on one row */
html.embed .logo-wrap,
body.embed .logo-wrap,
html.embed .footer-note,
body.embed .footer-note {
  display: none !important;
}
html.embed .topbar,
body.embed .topbar {
  position: static !important;
  top: auto !important;
  padding-right: 16px;
  backdrop-filter: none;
  background: #fff;
}
html.embed .kpi-five,
body.embed .kpi-five {
  grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
  gap: 8px;
}
html.embed .kpi .label,
body.embed .kpi .label {
  font-size: 10px;
}
html.embed .kpi .value,
body.embed .kpi .value {
  font-size: 20px;
}
html.embed,
body.embed {
  overflow: hidden;
  height: 100%;
  background: #fff;
}
html.embed .app,
body.embed .app {
  min-height: 100%;
  height: 100%;
  overflow: hidden;
}
html.embed .main,
body.embed .main {
  overflow: hidden;
  padding-bottom: 12px;
}
