/* app.css — clickdummy-only additive helpers.
   Uses ONLY tokens/vocabulary from crm-shell.css + theme-brand.css.
   Nothing here overrides shell classes; it adds layout + a few widgets
   the base shell doesn't ship (role switch, NBA rows, kanban, dialog, toast). */

/* ── Root scroll layout ─────────────────────────────────────── */
body { overflow: hidden; }
#app { height: 100vh; display: flex; flex-direction: column; }

/* topstrip content */
.topstrip .ts-demo {
  margin-left: 8px; background: rgba(255,255,255,.18); color: #fff;
  font-weight: 700; letter-spacing: .06em; padding: 1px 7px; border-radius: 10px; font-size: 10px;
}
.topstrip .ts-right { margin-left: auto; display: flex; align-items: center; gap: 14px; opacity: .92; }

/* ── App header: role switch + search ───────────────────────── */
.app-header__brandsep { width: 1px; height: 18px; background: var(--line); margin: 0 4px; }
.app-header__sub { font-size: 12px; color: var(--ink-2); font-weight: 500; }
.spacer { margin-left: auto; }

.ansicht { display: flex; align-items: center; gap: 8px; }
.ansicht__label { font-size: 11px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.role-switch {
  position: relative; display: flex; align-items: center; gap: 10px;
  border: 1px solid var(--muted); background: var(--surface); border-radius: var(--radius);
  padding: 5px 10px; font-size: 13px; font-weight: 500; color: var(--primary); cursor: pointer; min-width: 300px;
}
.role-switch .rs-avatar { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-size: 10px; font-weight: 700; }
.role-switch .rs-caret { margin-left: auto; color: var(--ink-3); }
.role-menu {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 50;
  background: var(--surface); border: 1px solid var(--muted); border-radius: var(--radius);
  box-shadow: var(--shadow-md); overflow: hidden;
}
.role-menu > div { padding: 9px 12px; font-size: 13px; color: var(--ink-1); display: flex; align-items: center; gap: 8px; }
.role-menu > div:hover { background: var(--surface-3); color: var(--primary); }

.searchbox {
  display: flex; align-items: center; gap: 8px; background: var(--surface-3);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 10px; width: 240px; color: var(--ink-2);
}
.searchbox input { border: 0; background: transparent; outline: none; flex: 1; font: inherit; font-size: 13px; color: var(--primary); }
.searchbox .kbd { font-size: 10px; color: var(--ink-3); border: 1px solid var(--muted); border-radius: 3px; padding: 0 4px; }
.iconbtn { width: 32px; height: 32px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); cursor: pointer; }

/* ── Sidebar extras ─────────────────────────────────────────── */
.nav-item .nav-ic { width: 16px; text-align: center; color: var(--ink-3); font-size: 13px; }
.nav-item.active .nav-ic { color: var(--accent); }
.nav-item .nav-count {
  margin-left: auto; font-size: 11px; font-weight: 600; color: var(--ink-2);
  background: var(--surface-3); border-radius: 10px; padding: 0 7px;
}
.nav-item.active .nav-count { background: var(--accent); color: #fff; }
.nav-item.locked { color: var(--ink-3); cursor: default; }
.nav-item.locked:hover { background: transparent; color: var(--ink-3); }
.nav-item.locked .nav-count { background: transparent; }
.sidebar__user { margin-top: auto; padding: 12px 16px; border-top: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.sidebar__user .avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 11px; flex: none; }
.sidebar__user .u-name { font-size: 13px; font-weight: 600; }
.sidebar__user .u-role { font-size: 11px; color: var(--ink-2); }

/* ── Routed page container (single child of .main-content) ──── */
.route { }               /* flex column fill comes from shell rule */
.page-header__sub { font-size: 12px; color: var(--ink-2); margin-top: 2px; }
.page-header__col { display: flex; flex-direction: column; }
.route-scroll { flex: 1; min-height: 0; overflow: auto; padding: 18px 20px 48px; background: var(--surface-2); }

/* ── Grids ──────────────────────────────────────────────────── */
.grid { display: grid; gap: 14px; margin-bottom: 18px; }
.grid.g2 { grid-template-columns: repeat(2, 1fr); }
.grid.g3 { grid-template-columns: repeat(3, 1fr); }
.grid.g4 { grid-template-columns: repeat(4, 1fr); }
.cols { display: grid; grid-template-columns: 1.5fr 1fr; gap: 16px; align-items: start; }
.section { margin-bottom: 18px; }
.card-hd .hd-meta { margin-left: auto; font-size: 11px; color: var(--ink-2); font-weight: 500; }
.card-hd a.hd-link { margin-left: auto; }

/* ── Tile ───────────────────────────────────────────────────── */
.tile { width: 34px; height: 34px; border-radius: var(--radius); display: grid; place-items: center; font-size: 15px; flex: none; background: var(--accent-tint); color: var(--accent); }
.tile.ok   { background: var(--success-tint); color: var(--success); }
.tile.warn { background: var(--warn-tint); color: var(--warn); }
.tile.bad  { background: var(--danger-tint); color: var(--danger); }

/* ── KPI card wrapper ───────────────────────────────────────── */
.kpi-card { padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; }
.kpi-card .kpi__hint { font-size: 12px; color: var(--ink-2); }
.kpi-card .kpi__top { display: flex; align-items: center; gap: 10px; }
.kpi-card .kpi__top .kpi__label { margin: 0; }

/* ── Next-best-action rows ──────────────────────────────────── */
.nba-row { display: flex; align-items: center; gap: 14px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.nba-row:last-child { border-bottom: 0; }
.nba-num { color: var(--ink-3); font-weight: 700; width: 12px; text-align: center; font-size: 13px; }
.nba-body { flex: 1; min-width: 0; }
.nba-body .t { font-weight: 600; font-size: 13.5px; }
.nba-body .d { color: var(--ink-2); font-size: 12.5px; margin-top: 1px; }
.nba-right { display: flex; align-items: center; gap: 12px; }
.prog { display: flex; align-items: center; gap: 7px; font-size: 11px; color: var(--ink-2); }
.prog .bar { width: 74px; height: 5px; background: var(--surface-3); border-radius: 4px; overflow: hidden; }
.prog .bar span { display: block; height: 100%; background: var(--accent); }

.nba-more { margin: -8px 0 18px; padding: 8px 16px; font-size: 12.5px; font-weight: 500; color: var(--accent); cursor: pointer; }
.nba-more:hover { text-decoration: underline; }

/* ── Collapsible customer summary ───────────────────────────── */
.summary-tbl .sum-cust { cursor: pointer; }
.summary-tbl .sum-cust:hover td { background: var(--surface-3); }
.summary-tbl .sum-cust > td { font-weight: 600; }
.summary-tbl .sum-cust .caret { display: inline-block; transition: transform .12s; color: var(--ink-3); margin-right: 7px; font-size: 9px; }
.summary-tbl .sum-cust .caret.open { transform: rotate(90deg); }
.summary-tbl .sum-cust .pcount { color: var(--ink-3); font-weight: 500; font-size: 12px; margin-left: 8px; }
.summary-tbl .sum-proj > td { color: var(--ink-2); font-weight: 400; }
.summary-tbl .sum-proj:hover td { background: var(--surface-2); }
.summary-tbl .sum-proj .proj-name { padding-left: 32px; }

/* ── Mini KPI strip ─────────────────────────────────────────── */
.mini-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.mini-kpi { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.mini-kpi .v { font-size: 20px; font-weight: 700; line-height: 1.1; }
.mini-kpi .l { font-size: 10.5px; color: var(--ink-2); text-transform: uppercase; letter-spacing: .04em; margin-top: 2px; }

/* ── Customer activity bars ─────────────────────────────────── */
.cust-act { display: flex; flex-direction: column; gap: 11px; margin-top: 16px; }
.cust-row { display: grid; grid-template-columns: 190px 1fr 92px; align-items: center; gap: 12px; }
.cust-row .cn { font-weight: 600; display: flex; align-items: center; gap: 8px; font-size: 13px; }
.cust-row .cn small { color: var(--ink-3); font-weight: 500; }
.stackbar { height: 16px; background: var(--surface-3); border-radius: 8px; overflow: hidden; display: flex; }
.stackbar span { height: 100%; }
.stackbar .done { background: var(--success); }
.stackbar .open { background: var(--accent); }
.cust-row .rt { text-align: right; font-size: 12px; color: var(--ink-2); }

/* ── Donut ──────────────────────────────────────────────────── */
.donut-wrap { display: flex; align-items: center; gap: 22px; }
.donut { width: 140px; height: 140px; border-radius: 50%; position: relative; flex: none; }
.donut::after { content: ''; position: absolute; inset: 22px; background: var(--surface); border-radius: 50%; }
.donut-c { position: absolute; inset: 0; display: grid; place-items: center; z-index: 1; text-align: center; }
.donut-c .n { font-size: 24px; font-weight: 800; line-height: 1; }
.donut-c .t { font-size: 10px; color: var(--ink-2); text-transform: uppercase; letter-spacing: .04em; margin-top: 2px; }
.legend { display: flex; flex-direction: column; gap: 8px; flex: 1; }
.legend .li { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.legend .sw { width: 11px; height: 11px; border-radius: 3px; flex: none; }
.legend .lc { margin-left: auto; font-weight: 600; color: var(--ink-1); }

/* ── Column chart (throughput) ──────────────────────────────── */
.throughput-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 4px; }
.throughput-head .big { font-size: 30px; font-weight: 800; }
.throughput-head span.lbl { color: var(--ink-2); font-size: 13px; }
.delta { font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 12px; }
.delta.up { background: var(--success-tint); color: var(--success); }
.delta.flat { background: var(--surface-3); color: var(--ink-2); }
.motiv { font-size: 13px; color: var(--ink-1); margin-bottom: 12px; }
.colchart { display: flex; align-items: flex-end; gap: 5px; height: 120px; }
.colchart .col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 5px; height: 100%; }
.colchart .col .bar { width: 72%; max-width: 26px; background: var(--accent); border-radius: 4px 4px 0 0; min-height: 3px; }
.colchart .col .bar.z { background: var(--muted-2); }
.colchart .col .cl { font-size: 10px; color: var(--ink-3); }
.colchart .col .cv { font-size: 10px; color: var(--ink-2); font-weight: 600; height: 12px; }
.colchart.dense { gap: 2px; }
.colchart.dense .col .bar { width: 100%; border-radius: 2px 2px 0 0; }

.bars .bar-row:first-child { padding-top: 0; }

/* ── Customer overview ──────────────────────────────────────── */
.cust-card-hd { gap: 12px; flex-wrap: wrap; }
.ring { width: 46px; height: 46px; border-radius: 50%; position: relative; flex: none;
  background: conic-gradient(var(--accent) calc(var(--p) * 1%), var(--surface-3) 0); }
.ring::after { content: ''; position: absolute; inset: 6px; border-radius: 50%; background: var(--surface); }
.ring .rv { position: absolute; inset: 0; display: grid; place-items: center; font-size: 11px; font-weight: 700; z-index: 1; }
.cust-name { font-size: 15px; font-weight: 700; }
.chip.q { background: var(--warn-tint); color: var(--warn); border-color: transparent; }
.cust-cols { display: grid; grid-template-columns: 1.3fr 1fr; gap: 26px; }
.cust-col-h { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-2); font-weight: 700; margin-bottom: 8px; }

.proj-row { padding: 11px 0; border-bottom: 1px solid var(--line); }
.proj-row:last-child { border-bottom: 0; }
.proj-row .pr-top { display: flex; align-items: center; gap: 10px; }
.proj-row .pr-name { font-weight: 600; font-size: 13.5px; }
.proj-row .pr-stage { margin-left: auto; font-size: 12px; color: var(--ink-2); }
.proj-row .pr-prog { display: flex; align-items: center; gap: 10px; margin: 7px 0 5px; }
.proj-row .pr-prog .bar { flex: 1; height: 6px; background: var(--surface-3); border-radius: 4px; overflow: hidden; }
.proj-row .pr-prog .bar span { display: block; height: 100%; background: var(--accent); }
.proj-row .pr-prog .pct { font-size: 12px; font-weight: 600; width: 36px; text-align: right; }
.proj-row .pr-meta { font-size: 12px; color: var(--ink-2); }
.qflag { color: var(--warn); font-weight: 600; }

.q-row { display: flex; align-items: flex-start; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.q-row:last-child { border-bottom: 0; }
.q-ic { width: 22px; height: 22px; border-radius: 50%; background: var(--warn-tint); color: var(--warn); display: grid; place-items: center; font-weight: 700; flex: none; font-size: 12px; }
.q-body { flex: 1; min-width: 0; }
.q-text { font-size: 13px; line-height: 1.4; }
.q-meta { font-size: 11px; margin-top: 3px; }
.q-row .btn, .q-row .stage-pill { flex: none; margin-top: 1px; }

@media (max-width: 1100px) { .cust-cols { grid-template-columns: 1fr; gap: 18px; } }

/* ── Table cell helpers ─────────────────────────────────────── */
.tbl td .t-main { font-weight: 500; color: var(--primary); }
.tbl td .t-sub { font-size: 12px; color: var(--ink-2); margin-top: 1px; }
.tbl .clickable { cursor: pointer; }
.mono { font-family: var(--font-mono); font-size: 12px; color: var(--ink-2); }

/* extra stage-pill shades built from shell tokens */
.stage-pill.pending { background: var(--warn-tint); color: var(--warn); }
.stage-pill.blocked { background: var(--surface-3); color: var(--ink-3); }
.stage-pill.review  { background: color-mix(in srgb, #7c3aed 12%, white); color: #6d28d9; }

/* ── Bars / funnel ──────────────────────────────────────────── */
.bar-row { display: flex; align-items: center; gap: 12px; padding: 7px 0; }
.bar-row .pill { font-size: 12px; font-weight: 500; color: var(--ink-1); min-width: 130px; display: flex; align-items: center; gap: 7px; }
.bar-row .pill .d { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.bar-track { flex: 1; height: 22px; background: var(--surface-3); border-radius: var(--radius); overflow: hidden; }
.bar-track span { display: flex; align-items: center; justify-content: flex-end; height: 100%; padding-right: 8px; color: #fff; font-weight: 600; font-size: 11px; border-radius: var(--radius); background: var(--accent); }
.bar-val { min-width: 32px; text-align: right; font-weight: 600; font-size: 12px; }

/* ── Pipeline mini ──────────────────────────────────────────── */
.pipeline-mini { display: flex; align-items: flex-start; }
.pstep { flex: 1; text-align: center; position: relative; }
.pstep .pc { width: 30px; height: 30px; border-radius: 50%; margin: 0 auto 6px; display: grid; place-items: center; font-weight: 700; font-size: 12px; color: #fff; background: var(--accent); }
.pstep .pc.done { background: var(--success); }
.pstep .pc.todo { background: var(--muted); }
.pstep .pl { font-size: 12px; font-weight: 600; }
.pstep .pn { font-size: 11px; color: var(--ink-2); }
.pstep::after { content:''; position: absolute; top: 15px; left: 50%; width: 100%; height: 2px; background: var(--muted-2); z-index: -1; }
.pstep:last-child::after { display: none; }

/* ── Kanban ─────────────────────────────────────────────────── */
.kanban { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.kcol { background: var(--surface-3); border-radius: var(--radius); padding: 10px; min-height: 160px; }
.kcol h4 { margin: 2px 4px 10px; font-size: 12px; font-weight: 600; color: var(--ink-1); display: flex; align-items: center; gap: 8px; }
.kcol h4 .cnt { background: var(--muted-2); color: var(--ink-2); font-size: 10px; padding: 0 6px; border-radius: 10px; }
.kcard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; margin-bottom: 8px; box-shadow: var(--shadow-sm); cursor: pointer; }
.kcard:hover { border-color: var(--accent); }
.kcard .kmono { font-size: 11px; color: var(--ink-3); font-family: var(--font-mono); }
.kcard .kcp { font-size: 11px; color: var(--ink-2); margin-top: 3px; display: flex; align-items: center; }
.kcard .kt { font-weight: 500; font-size: 12.5px; margin: 5px 0 8px; }

/* ── Customer / project label ───────────────────────────────── */
.cp-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; flex: none; }
.chip.cp { background: var(--surface); border-color: var(--muted-2); color: var(--ink-1); font-weight: 500; }
.chip.cp .cp-dot { margin-right: 5px; }
.meta-grid .v .cp-dot { vertical-align: middle; }
.kcard .kfoot { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--ink-2); }

/* ── Dialog (modal) ─────────────────────────────────────────── */
.dlg-overlay { position: fixed; inset: 0; z-index: 1000; background: rgba(0,0,0,.5); display: flex; align-items: center; justify-content: center; padding: 24px; }
.dlg { background: var(--surface); border-radius: var(--radius-lg); width: 100%; max-width: 600px; max-height: 88vh; overflow: auto; box-shadow: 0 12px 40px rgba(0,0,0,.25); }
.dlg-hd { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.dlg-hd h3 { font-size: 15px; font-weight: 600; }
.dlg-hd .close { margin-left: auto; background: none; border: 0; font-size: 18px; color: var(--ink-2); cursor: pointer; }
.dlg-bd { padding: 18px 20px; }
.dlg-ft { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.form-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stack { display: flex; flex-direction: column; gap: 14px; }

.meta-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 20px; margin-bottom: 6px; }
.meta-grid .k { font-size: 10px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.meta-grid .v { font-size: 13px; margin-top: 2px; }
.detail-h { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); font-weight: 600; margin: 16px 0 8px; }
.timeline { border-left: 2px solid var(--line); padding-left: 14px; }
.timeline .ti { position: relative; padding: 2px 0 12px; }
.timeline .ti::before { content:''; position: absolute; left: -19px; top: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.timeline .ti.muted::before { background: var(--muted); }
.timeline .tt { font-weight: 600; font-size: 13px; }
.timeline .td { font-size: 12px; color: var(--ink-2); }

/* ── Toast ──────────────────────────────────────────────────── */
#toast-root { position: fixed; bottom: 20px; right: 20px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--primary); color: #fff; padding: 11px 16px; border-radius: var(--radius); box-shadow: var(--shadow-md); display: flex; align-items: center; gap: 9px; font-size: 13px; animation: toastin .18s ease; }
.toast .tk { color: #4ade80; }
@keyframes toastin { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

@media (max-width: 1100px) {
  .grid.g3, .grid.g4 { grid-template-columns: repeat(2, 1fr); }
  .kanban { grid-template-columns: repeat(2, 1fr); }
  .cols { grid-template-columns: 1fr; }
}
