/* 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 .label-short { display: none; }

.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: auto;
  min-height: 0;
  background: #fff;
}
html.embed .app,
body.embed .app {
  min-height: 0;
  height: auto;
  overflow: hidden;
}
html.embed .main,
body.embed .main {
  overflow: hidden;
  padding-bottom: 12px;
}

/* Phone embed: short labels, two columns, rows that fit. No sideways scroll. */
@media (max-width: 720px) {
  html.embed .topbar,
  body.embed .topbar {
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 8px;
    padding: 10px 12px;
  }
  html.embed .brand-block,
  body.embed .brand-block {
    min-width: 0;
    flex: 1 1 160px;
  }
  html.embed .brand-sub,
  body.embed .brand-sub {
    max-width: none;
  }
  html.embed .kpi-five,
  body.embed .kpi-five {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px;
  }
  html.embed .kpi:last-child,
  body.embed .kpi:last-child {
    grid-column: 1 / -1;
    justify-self: center;
    width: calc(50% - 4px);
  }
  html.embed .kpi,
  body.embed .kpi {
    min-height: 0;
    padding: 8px 10px;
  }
  html.embed .kpi .label-full,
  body.embed .kpi .label-full { display: none; }
  html.embed .kpi .label-short,
  body.embed .kpi .label-short { display: inline; }
  html.embed .kpi .label,
  body.embed .kpi .label {
    letter-spacing: 0.04em;
    line-height: 1.2;
    white-space: nowrap;
  }
  html.embed .kpi .value,
  body.embed .kpi .value { font-size: 18px; }
  html.embed .panel-hd,
  body.embed .panel-hd {
    flex-wrap: wrap;
    align-items: flex-start;
  }
  html.embed .panel-hd .meta,
  body.embed .panel-hd .meta { display: none; }
  html.embed .source-chips,
  body.embed .source-chips { gap: 6px; margin-bottom: 8px; }
  html.embed .chip,
  body.embed .chip { font-size: 11px; padding: 4px 8px; }
  html.embed table.data,
  body.embed table.data { min-width: 0; width: 100%; }
  html.embed table.data thead,
  body.embed table.data thead { display: none; }
  html.embed table.data tr,
  body.embed table.data tr {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }
  html.embed table.data td:nth-child(-n+3),
  body.embed table.data td:nth-child(-n+3) { display: none; }
  html.embed table.data td:nth-child(4),
  body.embed table.data td:nth-child(4) {
    flex: 1;
    min-width: 0;
    padding-left: 0;
  }
  html.embed table.data td:nth-child(5),
  body.embed table.data td:nth-child(5) { flex: none; }
  html.embed .hint,
  body.embed .hint { display: none; }
}

/* Connected sources bar (matches hockey demo chips) */
.src-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: -2px; }
.src-label { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-dim); margin-right: 4px; }
.src-chips { display: contents; }
.src-bar.off .src-chips { display: none; }
.src-chip { display: inline-flex; align-items: center; gap: 7px; background: #fff; border: 1px solid var(--border-soft); border-radius: 999px; padding: 4px 11px 4px 7px; font-size: 11px; color: var(--text-dim); }
.src-chip img { height: 22px; width: auto; max-width: 72px; object-fit: contain; border-radius: 4px; flex: none; }
.src-chip em { font-style: normal; font-weight: 600; color: var(--text); margin-left: 4px; }
.src-toggle { border: 1px solid rgba(76,66,114,.25); background: rgba(76,66,114,.08); color: var(--accent); border-radius: 999px; padding: 2px 10px; font-size: 11px; font-weight: 600; line-height: 1.6; cursor: pointer; margin-left: 2px; font-family: inherit; }
.src-bar.off .src-toggle { background: #fff; color: var(--text-dim); border-color: var(--border); }

/* ---- Restaurant morning briefing ---- */
.rb-row { display: grid; gap: 14px; }
.rb-row-a { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); }
.rb-row-b { grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); }
@media (max-width: 980px) { .rb-row-a, .rb-row-b { grid-template-columns: 1fr; } }
.rb-row .panel { display: flex; flex-direction: column; min-width: 0; }
.rb-scroll { overflow-x: auto; }
.rb-chart { position: relative; height: 260px; }
.rb-attn { display: flex; flex-direction: column; gap: 8px; }
.rb-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border: 1px solid var(--border-soft); border-radius: 8px; background: var(--bg-card-2); transition: opacity .2s, background .2s; }
.rb-item.done { opacity: .55; background: #fff; }
.rb-item.done .rb-item-title { text-decoration: line-through; }
.rb-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--warn); }
.rb-dot.err { background: var(--danger); }
.rb-dot.ok { background: var(--good); }
.rb-item-main { flex: 1; min-width: 0; text-align: left; border: 0; background: transparent; padding: 0; display: flex; flex-direction: column; gap: 2px; color: var(--text); }
.rb-item-main:hover .rb-item-title { color: var(--accent); }
.rb-item-title { font-weight: 600; font-size: 13px; }
.rb-item-sub { font-size: 11px; color: var(--text-dim); }
.rb-item-sub b { font-weight: 600; color: var(--accent); }
.rb-act { flex: none; border: 1px solid var(--border); background: #fff; color: var(--text-dim); border-radius: 7px; padding: 5px 10px; font-size: 11px; font-weight: 600; }
.rb-act:hover { border-color: var(--accent); color: var(--accent); }
.rb-act.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.rb-item.done .rb-act { background: rgba(5,150,105,.1); border-color: rgba(5,150,105,.3); color: var(--good); }
td.rb-bad { color: var(--danger); font-weight: 600; }
tr.rb-total td { border-top: 2px solid var(--border); font-weight: 600; }
.rb-hint { padding: 8px 12px 10px; margin: 0; }
@media (max-width: 720px) { .rb-item { align-items: flex-start; } .rb-chart { height: 220px; } }
