/* Bright Loop Admin: system font stack, light and dark, responsive, no third-party assets. */
:root {
  --bg: #f5f5f7; --panel: #ffffff; --panel-2: #fafafc; --text: #1d1d1f; --muted: #6e6e73; --line: #e3e3e8; --line-2: #d2d2d7;
  --accent: #0a6cff; --accent-ink: #ffffff; --accent-soft: #e8f0ff; --ok: #1a7f37; --ok-soft: #e6f4ea; --warn: #9a6700; --warn-soft: #fff4d6;
  --bad: #c62828; --bad-soft: #fde8e8; --info: #6f42c1; --info-soft: #f1eafd; --grey-soft: #eeeef2;
  --c1: #0a6cff; --c2: #9aa4b2; --c3: #1a9e5c; --c4: #e07b00; --c5: #b04ad6;
  --radius: 12px; --shadow: 0 1px 2px rgba(0,0,0,.06), 0 2px 10px rgba(0,0,0,.04);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0f1012; --panel: #1a1b1e; --panel-2: #202125; --text: #f2f2f4; --muted: #a1a1aa; --line: #2c2d31; --line-2: #3a3b40;
  --accent: #4c9bff; --accent-ink: #0b0b0c; --accent-soft: #14284a; --ok: #4cc272; --ok-soft: #12301d; --warn: #e6b74a; --warn-soft: #3a2d0b;
  --bad: #ff6b6b; --bad-soft: #3d1515; --info: #b794f6; --info-soft: #2a1f42; --grey-soft: #26272b;
  --c1: #4c9bff; --c2: #6b7280; --c3: #4cc272; --c4: #f0a040; --c5: #cf8af0; --shadow: none; color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1012; --panel: #1a1b1e; --panel-2: #202125; --text: #f2f2f4; --muted: #a1a1aa; --line: #2c2d31; --line-2: #3a3b40;
    --accent: #4c9bff; --accent-ink: #0b0b0c; --accent-soft: #14284a; --ok: #4cc272; --ok-soft: #12301d; --warn: #e6b74a; --warn-soft: #3a2d0b;
    --bad: #ff6b6b; --bad-soft: #3d1515; --info: #b794f6; --info-soft: #2a1f42; --grey-soft: #26272b;
    --c1: #4c9bff; --c2: #6b7280; --c3: #4cc272; --c4: #f0a040; --c5: #cf8af0; --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
h1 { font-size: 26px; line-height: 1.2; margin: 0 0 4px; letter-spacing: -.01em; }
h2 { font-size: 17px; margin: 0 0 10px; }
h3 { font-size: 14px; margin: 0 0 8px; }
p { margin: 0 0 8px; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 8px; top: 8px; background: var(--panel); padding: 8px; z-index: 100; }
.boot { padding: 48px; text-align: center; color: var(--muted); }
[hidden] { display: none !important; }

/* layout */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.side { background: var(--panel); border-right: 1px solid var(--line); position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 14px 10px 24px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 10px 14px; font-weight: 650; font-size: 15px; }
.brand img { width: 26px; height: 26px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px; color: var(--text); font-size: 13.5px; }
.nav a:hover { background: var(--grey-soft); text-decoration: none; }
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav .dot { width: 6px; height: 6px; border-radius: 3px; background: var(--line-2); flex: none; }
.nav a[aria-current="page"] .dot { background: var(--accent); }
.main { min-width: 0; display: flex; flex-direction: column; }
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px; padding: 10px 20px; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: saturate(1.6) blur(14px); border-bottom: 1px solid var(--line); }
.top .search { flex: 1; max-width: 560px; position: relative; }
.top .search input { width: 100%; }
.top .spacer { flex: 1; }
.menu-btn { display: none; }
.content { padding: 22px 24px 60px; max-width: 1480px; width: 100%; }
.pagehead { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.pagehead .sub { color: var(--muted); }
.banner { padding: 10px 14px; border-radius: 10px; margin-bottom: 14px; border: 1px solid var(--line); background: var(--panel); }
.banner.mock { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); font-weight: 600; }
.banner.warn { background: var(--warn-soft); border-color: transparent; }
.banner.info { background: var(--accent-soft); border-color: transparent; }

/* cards and grids */
.grid { display: grid; gap: 14px; }
.kpis { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; min-width: 0; }
.card.flat { box-shadow: none; }
.card > h2 { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.kpi .label { color: var(--muted); font-size: 12.5px; font-weight: 500; }
.kpi .value { font-size: 24px; font-weight: 650; margin: 4px 0 6px; letter-spacing: -.01em; overflow-wrap: anywhere; }
.kpi .value.none { color: var(--muted); font-size: 15px; font-weight: 500; }
.kpi .delta { font-size: 12px; margin-left: 6px; font-weight: 500; }
.delta.up { color: var(--ok); } .delta.down { color: var(--bad); }
.meta { display: inline-flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 11.5px; color: var(--muted); }
.kpi .meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 11.5px; color: var(--muted); }
.kpi .note { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.section { margin-top: 18px; }
dl.kv { display: grid; grid-template-columns: minmax(120px, max-content) 1fr; gap: 6px 14px; margin: 0; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; overflow-wrap: anywhere; }

/* badges */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: var(--grey-soft); color: var(--muted); white-space: nowrap; }
.badge.ok, .badge.real-time, .badge.connected, .badge.active, .badge.met, .badge.published, .badge.completed, .badge.executed { background: var(--ok-soft); color: var(--ok); }
.badge.synced, .badge.configured, .badge.open, .badge.approved, .badge.running, .badge.info { background: var(--accent-soft); color: var(--accent); }
.badge.estimated, .badge.pending, .badge.warning, .badge.pending-configuration, .badge.past_due, .badge.on_hold, .badge.high, .badge.invited, .badge.draft { background: var(--warn-soft); color: var(--warn); }
.badge.manual { background: var(--info-soft); color: var(--info); }
.badge.mock, .badge.bad, .badge.error, .badge.critical, .badge.breached, .badge.suspended, .badge.failed, .badge.urgent, .badge.disabled, .badge.canceled, .badge.rejected { background: var(--bad-soft); color: var(--bad); }

/* forms and buttons */
input, select, textarea { font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line-2); border-radius: 8px; padding: 7px 10px; min-height: 36px; }
textarea { width: 100%; resize: vertical; }
input[type="checkbox"], input[type="radio"] { min-height: auto; width: 16px; height: 16px; accent-color: var(--accent); }
label { display: block; font-size: 13px; color: var(--muted); }
label > input:not([type="checkbox"]):not([type="radio"]), label > select, label > textarea { display: block; width: 100%; margin-top: 4px; color: var(--text); }
label.check { display: flex; align-items: center; gap: 8px; color: var(--text); }
.stack > * + * { margin-top: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 550; min-height: 36px; padding: 6px 14px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--panel); color: var(--text); cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--grey-soft); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, var(--line-2)); }
.btn.small { min-height: 28px; padding: 2px 10px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn { min-width: 36px; padding: 6px 8px; }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 9px; overflow: hidden; }
.seg button { border: 0; border-right: 1px solid var(--line-2); background: var(--panel); padding: 6px 12px; font: inherit; color: var(--text); cursor: pointer; min-height: 34px; }
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; }
.tabs a { padding: 8px 12px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a[aria-current="page"] { color: var(--text); border-color: var(--accent); font-weight: 600; text-decoration: none; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.filters input[type="search"] { min-width: 220px; flex: 1; max-width: 340px; }

/* tables */
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-weight: 600; color: var(--muted); font-size: 12px; background: var(--panel-2); white-space: nowrap; position: sticky; top: 0; }
th button { all: unset; cursor: pointer; display: inline-flex; gap: 4px; align-items: center; }
th button:focus-visible { outline: 2px solid var(--accent); }
tr:last-child td { border-bottom: 0; }
tbody tr.link { cursor: pointer; }
tbody tr.link:hover { background: var(--panel-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 10px; flex-wrap: wrap; color: var(--muted); font-size: 12.5px; }
.state { padding: 28px 16px; text-align: center; color: var(--muted); }
.state.error { color: var(--bad); }
.state .title { font-weight: 600; color: var(--text); margin-bottom: 4px; }
.skeleton { height: 12px; border-radius: 6px; background: linear-gradient(90deg, var(--grey-soft), var(--line), var(--grey-soft)); background-size: 200% 100%; animation: sk 1.2s infinite; margin: 10px 0; }
@keyframes sk { to { background-position: -200% 0; } }

/* charts */
.chart { width: 100%; height: auto; display: block; }
.chart .grid line { stroke: var(--line); }
.chart .axis text { fill: var(--muted); font-size: 10px; }
.chart .s1 { stroke: var(--c1); fill: none; stroke-width: 2; }
.chart .s2 { stroke: var(--c2); fill: none; stroke-width: 1.5; stroke-dasharray: 4 3; }
.chart .s3 { stroke: var(--c3); fill: none; stroke-width: 2; }
.chart .s4 { stroke: var(--c4); fill: none; stroke-width: 2; }
.chart .area { fill: var(--c1); opacity: .08; stroke: none; }
.chart .bar { fill: var(--c1); }
.chart .bar.b2 { fill: var(--c3); }
.chart .pt { fill: var(--c1); opacity: 0; }
.chart .pt:hover { opacity: 1; }
.chart .hit { fill: transparent; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 6px; }
.legend i { display: inline-block; width: 12px; height: 3px; margin-right: 6px; vertical-align: middle; background: var(--c1); }
.legend i.l2 { background: var(--c2); } .legend i.l3 { background: var(--c3); } .legend i.l4 { background: var(--c4); }
.bars .barrow { display: grid; grid-template-columns: minmax(90px, 32%) 1fr 56px; gap: 8px; align-items: center; font-size: 12.5px; padding: 3px 0; }
.bars .track { background: var(--grey-soft); border-radius: 4px; height: 8px; overflow: hidden; }
.bars .fill { background: var(--c1); height: 8px; border-radius: 4px; }
.bars .barrow span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* dialogs, menus, toasts */
dialog { border: 1px solid var(--line); border-radius: 14px; background: var(--panel); color: var(--text); padding: 0; width: min(640px, calc(100vw - 24px)); max-height: calc(100vh - 40px); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(0,0,0,.35); }
dialog .dlg-head { padding: 16px 18px 6px; }
dialog .dlg-body { padding: 6px 18px 12px; overflow-y: auto; max-height: calc(100vh - 200px); }
dialog .dlg-foot { padding: 12px 18px 16px; display: flex; gap: 8px; justify-content: flex-end; border-top: 1px solid var(--line); }
.results { position: absolute; left: 0; right: 0; top: 42px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 40px rgba(0,0,0,.18); max-height: 70vh; overflow-y: auto; padding: 8px; }
.results h4 { margin: 8px 6px 4px; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.results a { display: block; padding: 6px 8px; border-radius: 8px; color: var(--text); }
.results a:hover, .results a:focus { background: var(--grey-soft); text-decoration: none; }
.results a small { display: block; color: var(--muted); }
.toast { position: fixed; right: 16px; bottom: 16px; z-index: 200; background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 10px; max-width: 420px; box-shadow: var(--shadow); }
.toast.err { background: var(--bad); color: #fff; }
.thread .msg { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; background: var(--panel); white-space: pre-wrap; overflow-wrap: anywhere; }
.thread .msg.internal { background: var(--warn-soft); border-color: transparent; }
.thread .msg .who { font-size: 12px; color: var(--muted); margin-bottom: 4px; white-space: normal; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 6px 0 6px 14px; border-left: 2px solid var(--line); position: relative; font-size: 13px; }
.timeline li::before { content: ""; position: absolute; left: -5px; top: 11px; width: 8px; height: 8px; border-radius: 4px; background: var(--accent); }
.pill-list { display: flex; flex-wrap: wrap; gap: 6px; }
.matrix td, .matrix th { font-size: 11.5px; padding: 5px 6px; }
.qr { width: 180px; height: 180px; background: #fff; padding: 6px; border-radius: 8px; }
.qr svg { width: 100%; height: 100%; }
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth { width: min(420px, 100%); }
.auth .brand { justify-content: center; padding-bottom: 6px; }
.public { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.public-card { width: min(460px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 24px; }
.stars { border: 0; padding: 0; margin: 0; display: grid; gap: 6px; }
.star { display: flex; align-items: center; gap: 8px; color: var(--text); }
pre.json { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px; overflow: auto; max-height: 320px; font-size: 12px; white-space: pre-wrap; overflow-wrap: anywhere; }

/* responsive */
@media (max-width: 1100px) { .three { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 50; left: 0; top: 0; width: 270px; transform: translateX(-100%); transition: transform .2s; box-shadow: 0 0 40px rgba(0,0,0,.25); }
  .side.open { transform: none; }
  .menu-btn { display: inline-flex; }
  .two, .three, .form-grid { grid-template-columns: 1fr; }
  .content { padding: 16px 16px 48px; }
  .top { padding: 8px 12px; }
  .top .who { display: none; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi .value { font-size: 20px; }
  h1 { font-size: 22px; }
  .filters input[type="search"] { min-width: 0; max-width: none; width: 100%; }
  dl.kv { grid-template-columns: 1fr; gap: 2px; }
  dl.kv dd { margin-bottom: 8px; }
}
@media (max-width: 420px) { .kpis { grid-template-columns: 1fr; } }

/* print (PDF): only the report */
@media print {
  body { background: #fff; color: #000; }
  #app, .toast, dialog { display: none !important; }
  #print { display: block !important; }
  #print table { font-size: 10px; }
  #print th, #print td { border: 1px solid #999; padding: 3px 5px; }
  #print th { position: static; background: #eee; color: #000; }
}
#print { display: none; }
