:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --ink: #14161a;
  --ink-2: #4a5160;
  --muted: #8a91a0;
  --line: #e4e7ec;
  --accent: #ff5a1f;
  --accent-soft: #fff0ea;
  --read: #2f6fed;
  --read-soft: #eaf1ff;
  --write: #d9480f;
  --write-soft: #fff1e8;
  --ok: #138a52;
  --ok-soft: #e7f6ee;
  --bad: #c62a2a;
  --bad-soft: #fdecec;
  --warn: #b26b00;
  --warn-soft: #fff6e0;
  --radius: 12px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.45 Inter, system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}
h2 { font-size: 15px; margin: 0; font-weight: 600; }
.muted { color: var(--muted); font-size: 12.5px; }

/* ---------- topbar ---------- */
.topbar {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 14px 24px; background: var(--ink); color: #fff;
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; gap: 12px; align-items: center; }
.logo {
  width: 36px; height: 36px; border-radius: 10px; background: var(--accent);
  display: grid; place-items: center; font-weight: 700; font-size: 18px;
}
.brand-name { font-weight: 700; font-size: 17px; letter-spacing: -.01em; }
.brand-sub { font-size: 12.5px; color: #b8bdc8; }
.mock { color: #ffb08f; }
.status { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.badge { font-size: 12px; font-weight: 600; padding: 5px 10px; border-radius: 999px; background: #2a2e36; }
.badge.rw { background: var(--write); }
.badge.ro { background: var(--read); }
.live { display: inline-flex; gap: 6px; align-items: center; font-size: 12px; color: #b8bdc8; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #777; }
.live.on .dot { background: #2fd07a; box-shadow: 0 0 0 0 rgba(47,208,122,.6); animation: ping 2s infinite; }
@keyframes ping { 70% { box-shadow: 0 0 0 8px rgba(47,208,122,0); } 100% { box-shadow: 0 0 0 0 rgba(47,208,122,0); } }

.adminbar {
  display: flex; gap: 16px; align-items: center; padding: 10px 24px;
  background: var(--warn-soft); border-bottom: 1px solid #f0dfb8; flex-wrap: wrap;
}
.switch { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; }
.btn { font: inherit; padding: 6px 12px; border-radius: 8px; border: 1px solid var(--line); background: #fff; cursor: pointer; }
.btn:hover { border-color: var(--ink-2); }

/* ---------- layout ---------- */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 20px; padding: 20px 24px; align-items: start; }
main { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.grid2 { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 20px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; gap: 8px; }

/* ---------- KPIs ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.kpi .label { font-size: 12.5px; color: var(--ink-2); }
.kpi .value { font-size: 24px; font-weight: 700; letter-spacing: -.02em; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: 12px; color: var(--muted); }
.kpi.bad .value { color: var(--bad); }

/* ---------- board ---------- */
.board { display: grid; grid-template-columns: repeat(6, minmax(150px, 1fr)); gap: 10px; overflow-x: auto; padding-bottom: 4px; }
.col { background: var(--bg); border-radius: 10px; padding: 8px; min-height: 120px; }
.col-head { display: flex; justify-content: space-between; font-size: 12px; font-weight: 600; color: var(--ink-2); padding: 2px 4px 8px; }
.col-head { gap: 6px; }
.col-head span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.col-head .sum { color: var(--muted); font-weight: 500; font-variant-numeric: tabular-nums; white-space: nowrap; }
.deal { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin-bottom: 8px; transition: transform .3s; }
.deal .t { font-weight: 600; font-size: 12.5px; line-height: 1.3; }
.deal .c { font-size: 12px; color: var(--ink-2); margin-top: 2px; }
.deal .m { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; font-size: 12px; }
.deal .v { font-weight: 600; font-variant-numeric: tabular-nums; }
.tag { font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--bg); color: var(--ink-2); white-space: nowrap; }
.tag.stale { background: var(--warn-soft); color: var(--warn); }
.tag.bad { background: var(--bad-soft); color: var(--bad); }
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.ai { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.col.won .deal { border-color: #bfe6d1; }
.col.lost .deal { opacity: .6; }

/* ---------- tables ---------- */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.table td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .sub { color: var(--muted); font-size: 12px; }

.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 8px 0; border-bottom: 1px solid var(--line); display: flex; gap: 10px; align-items: flex-start; }
.list li:last-child { border-bottom: 0; }
.list .meta { font-size: 12px; color: var(--muted); }
.ic { width: 26px; height: 26px; border-radius: 8px; flex: none; display: grid; place-items: center; font-size: 13px; background: var(--bg); }

/* ---------- highlight-animatie ---------- */
.flash { animation: flash 2.4s ease-out; }
@keyframes flash {
  0% { background: #ffe1d3; box-shadow: 0 0 0 3px var(--accent); }
  100% { box-shadow: 0 0 0 0 transparent; }
}
tr.flash td { animation: flashrow 2.4s ease-out; }
@keyframes flashrow { 0% { background: #ffe1d3; } 100% { background: transparent; } }

/* ---------- feed ---------- */
.side { position: sticky; top: 84px; display: flex; flex-direction: column; max-height: calc(100vh - 104px); min-width: 0; }
.feed {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  min-height: 0; flex: 1; display: flex; flex-direction: column; overflow: hidden;
}
.feed-head { padding: 16px 16px 10px; border-bottom: 1px solid var(--line); }
.feed-head p { margin: 4px 0 0; }
.log { list-style: none; margin: 0; padding: 8px; overflow-y: auto; }
.log li { padding: 10px; border-radius: 10px; margin-bottom: 6px; border: 1px solid var(--line); }
.log li.new { animation: slidein .4s ease-out; }
@keyframes slidein { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
.log li.read { background: var(--read-soft); border-color: #d3e1fd; }
.log li.write { background: var(--write-soft); border-color: #fbd5bf; }
.log li.err { background: var(--bad-soft); border-color: #f5c6c6; }
.log .row { display: flex; justify-content: space-between; gap: 8px; font-size: 11.5px; }
.log .kind { font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.log li.read .kind { color: var(--read); }
.log li.write .kind { color: var(--write); }
.log li.err .kind { color: var(--bad); }
.log .tool { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11.5px; color: var(--ink-2); }
.log .sum { margin-top: 4px; font-size: 13px; }
.log details { margin-top: 4px; }
.log summary { cursor: pointer; font-size: 11.5px; color: var(--muted); }
.log pre { font-size: 11px; background: rgba(255,255,255,.7); padding: 6px; border-radius: 6px; overflow-x: auto; margin: 4px 0 0; }
.log-empty { padding: 28px 20px; text-align: center; color: var(--muted); font-size: 13px; }
.pulse { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); margin: 0 auto 10px; animation: ping2 1.6s infinite; }
@keyframes ping2 { 0% { box-shadow: 0 0 0 0 rgba(255,90,31,.5); } 100% { box-shadow: 0 0 0 12px rgba(255,90,31,0); } }

.foot { text-align: center; color: var(--muted); font-size: 12px; padding: 8px 24px 28px; }

/* ---------- responsive ---------- */
@media (max-width: 1200px) {
  .layout { grid-template-columns: 1fr; }
  .side { position: static; max-height: none; order: -1; }
  .feed { max-height: 420px; }
}
@media (max-width: 800px) {
  .layout { padding: 16px; }
  .topbar { padding: 12px 16px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid2 { grid-template-columns: 1fr; }
  .board { grid-template-columns: repeat(6, 200px); }
  .hide-sm { display: none; }
}
