/* Components + page styles. Colours come only from tokens.css. */

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--topbar-h);
  background: var(--bb-black); color: var(--bb-white);
  display: flex; align-items: center; gap: 16px; padding: 0 16px 0 0;
}
.brand { height: 100%; display: flex; align-items: center; gap: 10px; background: var(--bb-white); padding: 0 14px; text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand img { height: 40px; width: 40px; object-fit: contain; }
.logo-fallback { display: flex; flex-direction: column; line-height: 1; text-align: center; }
.logo-fallback b { color: var(--bb-red); font-size: 15px; letter-spacing: .08em; }
.logo-fallback span { color: var(--bb-black); font-size: 7.5px; letter-spacing: .14em; font-weight: 700; border-top: 1.5px solid var(--bb-red); padding-top: 2px; margin-top: 2px; }
.topbar__title { font-weight: 600; font-size: 13px; color: var(--bb-grey-200); white-space: nowrap; }
.topbar__search { flex: 1; max-width: 460px; position: relative; }
.topbar__search input {
  width: 100%; height: 34px; border-radius: 6px; border: 1px solid #2a2d31;
  background: #1a1c1f; color: var(--bb-white); padding: 0 12px 0 34px;
}
.topbar__search input::placeholder { color: var(--bb-grey-400); }
.topbar__search svg { position: absolute; left: 10px; top: 9px; width: 16px; height: 16px; color: var(--bb-grey-400); }
.search-results {
  position: absolute; top: 40px; left: 0; right: 0; background: var(--bb-white); color: var(--bb-ink);
  border-radius: var(--radius); box-shadow: var(--shadow-3); max-height: 360px; overflow: auto; padding: 6px;
}
.search-results a { display: flex; gap: 10px; padding: 8px 10px; border-radius: 6px; color: var(--bb-ink); align-items: center; }
.search-results a:hover, .search-results a:focus { background: var(--bb-grey-50); text-decoration: none; }
.topbar__spacer { flex: 1; }
.topbar a.toplink { color: var(--bb-grey-200); font-size: 13px; white-space: nowrap; }
.topbar select { height: 32px; background: #1a1c1f; color: var(--bb-white); border: 1px solid #2a2d31; border-radius: 6px; padding: 0 8px; max-width: 210px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--bb-red); color: var(--bb-white); display: grid; place-items: center; font-weight: 700; font-size: 12px; border: 0; cursor: pointer; }
.menu { position: absolute; right: 12px; top: 52px; background: var(--bb-white); color: var(--bb-ink); border-radius: var(--radius); box-shadow: var(--shadow-3); padding: 6px; min-width: 220px; z-index: 40; }
.menu button { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 9px 12px; border-radius: 6px; cursor: pointer; }
.menu button:hover { background: var(--bb-grey-50); }
@media (max-width: 1100px) { .topbar__title, .toplink--hide { display: none; } }

/* ---------- Side nav ---------- */
.sidenav { width: var(--sidenav-w); flex-shrink: 0; background: var(--bb-white); border-right: 1px solid var(--bb-grey-200); padding: 14px 10px; position: sticky; top: var(--topbar-h); height: calc(100vh - var(--topbar-h)); overflow: auto; }
.sidenav h6 { margin: 14px 10px 6px; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--bb-grey-600); }
.sidenav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 6px; color: var(--bb-ink); font-weight: 500; }
.sidenav a svg { width: 18px; height: 18px; color: var(--bb-grey-600); }
.sidenav a:hover { background: var(--bb-grey-50); text-decoration: none; }
.sidenav a.is-active { background: var(--bb-red-tint); color: var(--bb-red-dark); }
.sidenav a.is-active svg { color: var(--bb-red); }
@media (max-width: 900px) { .sidenav { display: none; } }

/* ---------- Page header ---------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { margin: 0; color: var(--bb-grey-600); }
.crumbs { font-size: 12px; color: var(--bb-grey-600); margin-bottom: 4px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 14px;
  border-radius: 6px; border: 1px solid var(--bb-grey-200); background: var(--bb-white);
  color: var(--bb-ink); font-weight: 600; cursor: pointer; white-space: nowrap; text-decoration: none;
}
.btn:hover { background: var(--bb-grey-50); text-decoration: none; }
.btn svg { width: 16px; height: 16px; }
.btn--primary { background: var(--bb-red); border-color: var(--bb-red); color: var(--bb-white); }
.btn--primary:hover { background: var(--bb-red-dark); }
.btn--dark { background: var(--bb-black); border-color: var(--bb-black); color: var(--bb-white); }
.btn--dark:hover { background: var(--bb-ink); }
.btn--ghost { background: transparent; border-color: transparent; }
.btn--sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn--lg { height: 46px; padding: 0 22px; font-size: 15px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ---------- Cards / KPI ---------- */
.card { background: var(--bb-white); border: 1px solid var(--bb-grey-200); border-radius: var(--radius); box-shadow: var(--shadow-1); }
.card__head { padding: 14px 16px; border-bottom: 1px solid var(--bb-grey-200); display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.card__head h3 { margin: 0; }
.card__body { padding: 16px; }
.card--pad { padding: 16px; }
.kpi { padding: 14px 16px; }
.kpi__label { font-size: 12px; color: var(--bb-grey-600); font-weight: 600; }
.kpi__value { font-size: 26px; font-weight: 700; color: var(--bb-black); font-variant-numeric: tabular-nums; line-height: 1.2; margin-top: 4px; }
.kpi__sub { font-size: 12px; color: var(--bb-grey-600); }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--bb-grey-100); color: var(--bb-ink); white-space: nowrap; }
.badge svg { width: 12px; height: 12px; }
.badge--ok { background: var(--ok-tint); color: var(--ok); }
.badge--warn { background: var(--warn-tint); color: var(--warn); }
.badge--crit { background: var(--crit-tint); color: var(--crit); }
.badge--info { background: var(--info-tint); color: var(--info); }
.badge--brand { background: var(--bb-red-tint); color: var(--bb-red-dark); }
.badge--p1 { background: var(--crit); color: var(--bb-white); }
.badge--p2 { background: var(--warn); color: var(--bb-white); }
.badge--p3 { background: var(--info); color: var(--bb-white); }
.badge--p4 { background: var(--bb-grey-600); color: var(--bb-white); }

/* ---------- Tables ---------- */
.table-wrap { overflow: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { position: sticky; top: 0; background: var(--bb-grey-50); text-align: left; font-weight: 600; color: var(--bb-grey-600); font-size: 12px; padding: 9px 12px; border-bottom: 1px solid var(--bb-grey-200); white-space: nowrap; }
.table td { padding: 9px 12px; border-bottom: 1px solid var(--bb-grey-200); vertical-align: middle; }
.table tbody tr:hover { background: var(--bb-grey-50); }
.table tbody tr.is-link { cursor: pointer; }
.table tr.is-selected { background: var(--bb-red-tint); }
.table .r { text-align: right; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 12px; font-weight: 600; color: var(--bb-grey-600); }
.input, select.input, textarea.input { height: 36px; border: 1px solid var(--bb-grey-200); border-radius: 6px; padding: 0 10px; background: var(--bb-white); width: 100%; }
textarea.input { height: auto; padding: 8px 10px; }
.input:focus { border-color: var(--info); box-shadow: var(--focus); outline: none; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--bb-grey-200); margin-bottom: 16px; overflow-x: auto; }
.tabs button { background: none; border: 0; padding: 10px 14px; font-weight: 600; color: var(--bb-grey-600); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button.is-active { color: var(--bb-black); border-color: var(--bb-red); }

/* ---------- Progress / completeness ---------- */
.bar { height: 6px; background: var(--bb-grey-100); border-radius: 999px; overflow: hidden; min-width: 60px; }
.bar > i { display: block; height: 100%; background: var(--ok); }
.bar--warn > i { background: var(--warn); }
.bar--crit > i { background: var(--crit); }

/* ---------- Drawer / modal / toast ---------- */
.overlay { position: fixed; inset: 0; background: var(--overlay); z-index: 50; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(520px, 100vw); background: var(--bb-white); z-index: 51; box-shadow: var(--shadow-3); display: flex; flex-direction: column; animation: slideIn .2s ease; }
.drawer__head { padding: 16px 20px; border-bottom: 1px solid var(--bb-grey-200); display: flex; justify-content: space-between; align-items: center; }
.drawer__body { padding: 20px; overflow: auto; flex: 1; }
@keyframes slideIn { from { transform: translateX(40px); opacity: 0; } }
.toasts { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 70; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: var(--bb-black); color: var(--bb-white); padding: 10px 16px; border-radius: 8px; box-shadow: var(--shadow-3); font-weight: 500; display: flex; gap: 8px; align-items: center; animation: rise .2s ease; max-width: 90vw; }
.toast svg { width: 16px; height: 16px; flex-shrink: 0; }
.toast--ok svg { color: #7ad08f; } .toast--warn svg { color: #ffc266; } .toast--crit svg { color: #ff8a80; }
@keyframes rise { from { transform: translateY(10px); opacity: 0; } }

/* ---------- Timeline ---------- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 14px 22px; }
.timeline li::before { content: ""; position: absolute; left: 5px; top: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--bb-red); }
.timeline li::after { content: ""; position: absolute; left: 8.5px; top: 16px; bottom: 0; width: 1px; background: var(--bb-grey-200); }
.timeline li:last-child::after { display: none; }
.timeline .step { font-size: 11px; font-weight: 700; color: var(--bb-red-dark); text-transform: uppercase; letter-spacing: .05em; }

/* ---------- Misc ---------- */
.empty { text-align: center; padding: 40px 16px; color: var(--bb-grey-600); }
.json { background: var(--bb-black); color: #d8dee4; font-family: var(--mono); font-size: 12px; padding: 12px; border-radius: 6px; overflow: auto; max-height: 260px; white-space: pre; }
.chip-row { display: flex; gap: 6px; flex-wrap: wrap; }
.dl { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; margin: 0; }
.dl dt { color: var(--bb-grey-600); font-size: 13px; }
.dl dd { margin: 0; font-weight: 500; }
.thumb { width: 44px; height: 44px; border-radius: 6px; border: 1px solid var(--bb-grey-200); background: var(--bb-grey-50); flex-shrink: 0; overflow: hidden; }
.thumb svg { width: 100%; height: 100%; }
.pulse { animation: pulse 1.4s ease infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px var(--crit-tint); } }
.skeleton { background: linear-gradient(90deg, var(--bb-grey-100), var(--bb-grey-50), var(--bb-grey-100)); background-size: 200% 100%; animation: shimmer 1s infinite; border-radius: 6px; height: 14px; }
@keyframes shimmer { to { background-position: -200% 0; } }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; align-items: start; }
@media (max-width: 1200px) { .split { grid-template-columns: minmax(0, 1fr); } }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.filters .input { width: auto; min-width: 150px; }

/* ---------- Launchpad ---------- */
.persona { padding: 18px; cursor: pointer; text-align: left; transition: transform .12s, box-shadow .12s; border: 1px solid var(--bb-grey-200); }
.persona:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); border-color: var(--bb-red); }
.persona .who { font-weight: 700; color: var(--bb-black); font-size: 15px; }
.persona .role { color: var(--bb-red-dark); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }

/* ---------- Command centre ---------- */
.alarm { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--bb-grey-200); align-items: center; animation: rise .25s ease; }
.alarm__icon { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--crit-tint); color: var(--crit); }
.alarm__icon svg { width: 16px; height: 16px; }
.map-pin { cursor: pointer; }
.simpanel { position: fixed; right: 16px; bottom: 16px; z-index: 35; width: 300px; background: var(--bb-black); color: var(--bb-white); border-radius: var(--radius-lg); box-shadow: var(--shadow-3); }
.simpanel__head { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; cursor: pointer; font-weight: 600; }
.simpanel__body { padding: 0 14px 14px; display: grid; gap: 8px; }
.simpanel select, .simpanel .input { background: #1a1c1f; border-color: #2a2d31; color: var(--bb-white); }
.simpanel .btn { justify-content: center; }
.simpanel .btn:not(.btn--primary) { background: #1a1c1f; border-color: #2a2d31; color: var(--bb-white); }

/* ---------- Kanban ---------- */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(220px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.kanban__col { background: var(--bb-grey-100); border-radius: var(--radius); padding: 10px; min-height: 200px; }
.kanban__col h4 { display: flex; justify-content: space-between; font-size: 12px; text-transform: uppercase; color: var(--bb-grey-600); letter-spacing: .05em; }
.tcard { background: var(--bb-white); border-radius: 6px; padding: 10px; margin-bottom: 8px; box-shadow: var(--shadow-1); cursor: pointer; border-left: 3px solid var(--bb-grey-200); }
.tcard.p1 { border-left-color: var(--crit); } .tcard.p2 { border-left-color: var(--warn); } .tcard.p3 { border-left-color: var(--info); }

/* ---------- External system (channels) ---------- */
.ext { border-radius: var(--radius); overflow: hidden; border: 1px solid var(--bb-grey-200); background: var(--bb-white); }
.ext__bar { color: var(--bb-white); padding: 10px 16px; display: flex; justify-content: space-between; align-items: center; font-weight: 700; }
.ext__ribbon { font-size: 11px; background: rgba(255, 255, 255, .18); padding: 2px 8px; border-radius: 999px; font-weight: 600; }
.ext--shop .ext__bar { background: var(--ext-shop); }
.ext--oms .ext__bar { background: var(--ext-oms); }
.ext--crm .ext__bar { background: var(--ext-crm); }

/* ---------- Footer ---------- */
.foot-note { font-size: 12px; color: var(--bb-grey-600); }

@media print {
  .topbar, .sidenav, .simpanel, .no-print, .app__footer { display: none !important; }
}
@media (max-width: 600px) {
  .topbar { gap: 8px; padding-right: 8px; }
  .topbar select { max-width: 110px; }
  .app__main { padding: 16px; }
}
