/* SafeOp Admin & Dealer Portal theme.
   Its own look, deliberately different from the customer app (§5.1 asks for
   "a slightly different visual treatment ... but the same SafeOp
   branding"): SafeOp's logo and green, on a light, minimal layout with ink
   text and Plus Jakarta Sans. */

:root {
  --ink: #0f1b2d;          /* text, primary buttons */
  --ink-2: #334155;
  --muted: #64748b;
  --faint: #94a3b8;
  --line: #e7ebf0;
  --line-strong: #d7dde5;
  --canvas: #f6f7f9;       /* page background */
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --brand: #3cb183;        /* SafeOp logo green */
  --brand-ink: #1f7a59;
  --brand-soft: #e8f6f0;
  --focus: rgba(60, 177, 131, 0.28);
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(15, 27, 45, 0.04);
  --shadow: 0 1px 2px rgba(15, 27, 45, 0.04), 0 4px 16px -6px rgba(15, 27, 45, 0.08);
  --sidebar-width: 248px;

  --bs-body-font-family: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --bs-body-font-size: 0.9375rem;
  --bs-body-color: var(--ink);
  --bs-body-bg: var(--canvas);
  --bs-border-color: var(--line);
  --bs-link-color: var(--ink);
  --bs-link-color-rgb: 15, 27, 45;
  --bs-link-hover-color: var(--brand-ink);
  --bs-link-hover-color-rgb: 31, 122, 89;
  --bs-secondary-color: var(--muted);
  --bs-emphasis-color: var(--ink);
}

body { font-weight: 450; min-height: 100vh; -webkit-font-smoothing: antialiased; letter-spacing: -0.003em; }
h1, h2, h3, h4, h5, h6 { color: var(--ink); font-weight: 700; letter-spacing: -0.02em; }
h1 { font-size: 1.6rem; }
.text-secondary { color: var(--muted) !important; }
a { text-underline-offset: 3px; }
.code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 0.88em; letter-spacing: 0; }

/* ---------- Buttons ---------- */
.btn { border-radius: 8px; font-weight: 600; font-size: 0.875rem; padding: 0.5rem 0.95rem; letter-spacing: -0.005em; }
.btn-sm { padding: 0.3rem 0.65rem; font-size: 0.8rem; }
.btn-primary {
  --bs-btn-bg: var(--ink); --bs-btn-border-color: var(--ink);
  --bs-btn-hover-bg: #1d2b40; --bs-btn-hover-border-color: #1d2b40;
  --bs-btn-active-bg: #000; --bs-btn-active-border-color: #000;
  --bs-btn-disabled-bg: var(--faint); --bs-btn-disabled-border-color: var(--faint);
  --bs-btn-focus-shadow-rgb: 60, 177, 131;
  box-shadow: 0 1px 2px rgba(15, 27, 45, 0.18);
}
.btn-outline-secondary {
  --bs-btn-color: var(--ink); --bs-btn-bg: var(--surface); --bs-btn-border-color: var(--line-strong);
  --bs-btn-hover-color: var(--ink); --bs-btn-hover-bg: var(--surface-2); --bs-btn-hover-border-color: var(--faint);
  --bs-btn-active-color: var(--ink); --bs-btn-active-bg: var(--canvas); --bs-btn-active-border-color: var(--faint);
}
.btn-outline-danger { --bs-btn-color: #b42318; --bs-btn-border-color: #f1c4bf; --bs-btn-hover-bg: #fef3f2; --bs-btn-hover-color: #b42318; --bs-btn-hover-border-color: #e5a29a; --bs-btn-bg: var(--surface); }
.btn-danger { --bs-btn-bg: #c0392b; --bs-btn-border-color: #c0392b; --bs-btn-hover-bg: #a93226; --bs-btn-hover-border-color: #a93226; }
.btn-link { color: var(--muted); }
.btn i { margin-right: 0.35rem; }
.btn-group > .btn { border-radius: 8px; }
.btn-group > .btn:not(:last-child) { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.btn-group > .btn:not(:first-child) { border-top-left-radius: 0; border-bottom-left-radius: 0; }

/* ---------- Layout ---------- */
.portal-sidebar {
  width: var(--sidebar-width);
  background: var(--surface) !important;
  border-right: 1px solid var(--line);
  padding: 1.25rem 0.85rem 1rem;
}
@media (min-width: 992px) {
  .portal-sidebar { position: fixed; top: 0; bottom: 0; left: 0; overflow-y: auto; }
  .dev-banner ~ .d-flex .portal-sidebar { top: 28px; }
  .portal-content { margin-left: var(--sidebar-width); }
}
.portal-content { min-width: 0; min-height: 100vh; }
.portal-sidebar__brand { display: flex; align-items: center; justify-content: space-between; padding: 0.15rem 0.6rem 1.35rem; }
.portal-sidebar__brand img { height: 36px; width: auto; }
.portal-sidebar__area {
  display: flex; align-items: center; gap: 0.5rem;
  margin: 0 0.25rem 1rem; padding: 0.55rem 0.7rem;
  background: var(--canvas); border: 1px solid var(--line); border-radius: var(--radius);
  font-size: 0.8rem; font-weight: 600; color: var(--ink-2);
}
.portal-sidebar__area .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand); flex: none; box-shadow: 0 0 0 3px var(--brand-soft); }
.portal-sidebar__area span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.portal-nav .nav-link {
  position: relative; display: flex; align-items: center; gap: 0.7rem;
  color: var(--ink-2); font-weight: 550; font-size: 0.875rem;
  border-radius: 8px; padding: 0.5rem 0.65rem; margin-bottom: 2px;
}
.portal-nav .nav-link i { font-size: 1.05rem; width: 1.2rem; text-align: center; color: var(--faint); transition: color .15s; }
.portal-nav .nav-link:hover { background: var(--canvas); color: var(--ink); }
.portal-nav .nav-link:hover i { color: var(--ink-2); }
.portal-nav .nav-link.active { background: var(--brand-soft); color: var(--brand-ink); font-weight: 650; }
.portal-nav .nav-link.active i { color: var(--brand); }
.portal-nav .nav-section {
  font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.09em;
  color: var(--faint); padding: 1.1rem 0.65rem 0.4rem;
}
.portal-sidebar__foot { margin-top: auto; padding: 1rem 0.6rem 0; font-size: 0.75rem; color: var(--faint); }

.portal-topbar {
  position: sticky; top: 0; z-index: 10;
  background: rgba(246, 247, 249, 0.85); backdrop-filter: saturate(160%) blur(8px);
  border-bottom: 1px solid var(--line); min-height: 60px;
}
.portal-topbar__title { font-weight: 600; font-size: 0.875rem; color: var(--muted); }
.portal-topbar__title strong { color: var(--ink); font-weight: 650; }
.portal-user { display: flex; align-items: center; gap: 0.55rem; padding: 0.25rem 0.6rem 0.25rem 0.25rem; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); }
.portal-avatar {
  width: 28px; height: 28px; border-radius: 50%; background: var(--ink); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.75rem;
}

.portal-main { padding: 1.75rem 1.25rem 3rem; max-width: 1240px; }
@media (min-width: 1200px) { .portal-main { padding: 2.25rem 2.75rem 3.5rem; } }

.portal-logo { height: 40px; width: auto; align-self: flex-start; }

/* ---------- Page header ---------- */
.page-header { margin-bottom: 1.75rem; }
.page-header h1 { margin-bottom: 0.3rem; }
.page-header p { font-size: 0.9rem; }
.page-back { display: inline-flex; align-items: center; gap: 0.35rem; color: var(--muted); text-decoration: none; font-size: 0.8rem; font-weight: 600; margin-bottom: 0.6rem; }
.page-back:hover { color: var(--ink); }
.page-eyebrow { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--brand-ink); margin-bottom: 0.35rem; }

/* ---------- Cards ---------- */
.card { border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow); background: var(--surface); }
.card > .table-responsive:first-child, .card > .table-responsive:first-child .table { border-top-left-radius: var(--radius-lg); border-top-right-radius: var(--radius-lg); }
.card-footer { background: var(--surface-2) !important; border-top: 1px solid var(--line); border-bottom-left-radius: var(--radius-lg) !important; border-bottom-right-radius: var(--radius-lg) !important; }
.card-section-title { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.stat-card { padding: 1.1rem 1.25rem; }
.stat-card .label { font-size: 0.8rem; color: var(--muted); font-weight: 600; }
.stat-card .value { font-size: 1.75rem; font-weight: 750; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
@media (max-width: 575.98px) { .stat-card .value { font-size: 1.2rem; white-space: nowrap; } }
.link-card { display: flex; gap: 0.9rem; align-items: flex-start; padding: 1.15rem 1.25rem; text-decoration: none; color: var(--ink); transition: border-color .15s, transform .15s; }
.link-card:hover { border-color: var(--line-strong); transform: translateY(-1px); color: var(--ink); }
.link-card .icon { width: 38px; height: 38px; border-radius: 10px; background: var(--brand-soft); color: var(--brand-ink); display: inline-flex; align-items: center; justify-content: center; font-size: 1.15rem; flex: none; }
.link-card .title { font-weight: 700; }
.link-card .text { font-size: 0.83rem; color: var(--muted); }

/* ---------- Tables ---------- */
.table { --bs-table-bg: transparent; margin-bottom: 0; font-size: 0.875rem; }
.table > :not(caption) > * > * { padding: 0.8rem 1rem; border-bottom-color: var(--line); }
@media (max-width: 1199px) { .table > :not(caption) > * > * { padding-left: 0.6rem; padding-right: 0.6rem; } }  /* keep the last column in view on tablets */
@media (max-width: 1199px) { .table-responsive td.text-end:last-child:has(.btn) { position: sticky; right: 0; background: var(--surface); } }  /* row buttons stay reachable */
.table > thead th {
  background: var(--surface-2); color: var(--muted); font-size: 0.7rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.07em; white-space: nowrap; padding-top: 0.65rem; padding-bottom: 0.65rem;
}
.table > tbody > tr:last-child > * { border-bottom: 0; }
.table > tbody > tr { transition: background .12s; }
.table > tbody > tr:hover { background: var(--surface-2); }
.table td { vertical-align: middle; }
.table a.row-link { color: var(--ink); font-weight: 650; text-decoration: none; }
.table a.row-link:hover { color: var(--brand-ink); }
.cell-sub { font-size: 0.78rem; color: var(--muted); }

/* ---------- Forms ---------- */
.form-label { font-weight: 600; font-size: 0.83rem; color: var(--ink-2); margin-bottom: 0.35rem; }
.form-control, .form-select {
  border-radius: 8px; border-color: var(--line-strong); padding: 0.55rem 0.8rem; font-size: 0.9rem;
  box-shadow: var(--shadow-sm); background-color: var(--surface);
}
.form-control::placeholder { color: var(--faint); }
.form-control:focus, .form-select:focus, .form-check-input:focus { border-color: var(--brand); box-shadow: 0 0 0 0.22rem var(--focus); }
.form-text { font-size: 0.78rem; color: var(--muted); }
.form-check-input { border: 1.5px solid var(--faint); width: 1.15em; height: 1.15em; }
.form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }
.invalid-feedback { font-size: 0.78rem; }
.form-section { padding-top: 1.25rem; margin-top: 1.25rem; border-top: 1px dashed var(--line-strong); }
.form-section:first-of-type { border-top: 0; padding-top: 0; margin-top: 0; }

/* ---------- Detail lists ---------- */
.detail-row { padding: 0.65rem 0; }
.detail-row + .detail-row { border-top: 1px solid var(--line); }
.detail-row dt { font-size: 0.83rem; }
.detail-row dd { font-size: 0.875rem; font-weight: 500; }

/* ---------- Alerts ---------- */
.alert { border-radius: var(--radius); border: 1px solid; font-size: 0.875rem; padding: 0.75rem 1rem; }
.alert-success { background: var(--brand-soft); border-color: #c6e9da; color: #155e43; }
.alert-danger { background: #fef3f2; border-color: #f6cfca; color: #9b2c22; }
.alert-warning { background: #fffaeb; border-color: #f5dfa2; color: #7a5300; }
.alert-info { background: #f0f6ff; border-color: #cfe0fb; color: #1e4b8f; }

/* ---------- Status badges: a dot + label, one colour per kind of state ---------- */
.status-badge {
  display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.2rem 0.6rem 0.2rem 0.5rem;
  border-radius: 999px; font-size: 0.75rem; font-weight: 650; white-space: nowrap;
  background: #f1f4f7; color: var(--ink-2); border: 1px solid transparent;
}
.status-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.85; }
.status-invited, .status-pending, .status-due, .status-adjusted { background: #fff7e6; color: #946200; }
.status-account_created, .status-agreement_signed, .status-training_outstanding { background: #eef4ff; color: #2952a3; }
.status-active, .status-accepted, .status-approved, .status-delivered, .status-complete { background: var(--brand-soft); color: var(--brand-ink); }
.status-suspended, .status-expired, .status-revoked, .status-clawed_back, .status-rejected { background: #fef1f0; color: #b42318; }
/* Agreement status (§7.1) */
.status-signed { background: var(--brand-soft); color: var(--brand-ink); }
.status-not_signed { background: #f1f4f7; color: var(--ink-2); }
.status-out_of_date { background: #fff7e6; color: #946200; }

/* Stock (§4.3) */
.status-in_stock { background: var(--brand-soft); color: var(--brand-ink); }
.status-reorder { background: #fff7e6; color: #946200; }
.status-out_of_stock, .status-written_off { background: #fef1f0; color: #b42318; }
/* Order confirmations, Platform Fee invoices and licences */
.status-badge.status-paid, .status-badge.status-licences_active { background: var(--brand-soft); color: var(--brand-ink); }
.status-badge.status-issued, .status-badge.status-licences_due, .status-badge.status-returned { background: #fff7e6; color: #946200; }
.status-badge.status-overdue { background: #fef1f0; color: #b42318; }
.status-badge.status-submitted, .status-badge.status-hardware_in_progress { background: #eef4ff; color: #2952a3; }
.status-badge.status-draft, .status-badge.status-ended, .status-badge.status-void { background: #f1f4f7; color: var(--ink-2); }
.status-with_dealer, .status-on_order, .status-in_progress, .status-allocated, .status-stock_on_order, .status-awaiting_installation, .status-awaiting_payment, .status-submitted, .status-invoiced, .status-paid, .status-po_sent, .status-dispatched { background: #eef4ff; color: #2952a3; }
.scan-flash { padding: 0.75rem 1rem; border-radius: 8px; font-weight: 600; background: var(--surface-2); margin-top: 0.75rem; }
.scan-flash.ok { background: var(--brand-soft); color: var(--brand-ink); }
.scan-flash.warn { background: #fff7e6; color: #946200; }
.scan-flash.bad { background: #fef1f0; color: #b42318; }
.scan-input { font-size: 1.15rem; }
.serial-picker { max-height: 260px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; padding: 0.5rem 0.75rem; }

/* ---------- Tables that become stacked cards on phones ---------- */
@media (max-width: 767.98px) {
  .table-stack thead { display: none; }
  .table-stack, .table-stack tbody, .table-stack tr, .table-stack td { display: block; width: 100%; }
  .table-stack tr { padding: 0.5rem 0; border-bottom: 1px solid var(--line); }
  .table-stack tr:last-child { border-bottom: 0; }
  .table > tbody > tr > td[data-label] { position: relative; padding: 0.3rem 0.85rem 0.3rem 45%; border: 0; text-align: left; white-space: normal; overflow-wrap: anywhere; }
  .table-stack td.text-end[data-label] { text-align: left !important; }
  .table-stack td[data-label]::before { content: attr(data-label); position: absolute; left: 0.85rem; width: calc(45% - 1.25rem); color: var(--muted); font-size: 0.8rem; font-weight: 400; font-family: var(--bs-body-font-family); }
}

/* ---------- Filter chips (segmented) ---------- */
.filter-chips { display: inline-flex; flex-wrap: wrap; gap: 0.25rem; padding: 0.25rem; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-sm); }
.filter-chip { border-radius: 7px; padding: 0.35rem 0.7rem; font-size: 0.8rem; font-weight: 600; color: var(--muted); text-decoration: none; }
.filter-chip span { color: var(--faint); margin-left: 0.25rem; font-variant-numeric: tabular-nums; }
.filter-chip:hover { color: var(--ink); background: var(--canvas); }
.filter-chip.active { background: var(--ink); color: #fff; }
.filter-chip.active span { color: rgba(255, 255, 255, 0.6); }

/* ---------- Tabs (underline) ---------- */
.nav-tabs { border-bottom: 1px solid var(--line); gap: 1.25rem; }
.nav-tabs .nav-link { border: 0; border-bottom: 2px solid transparent; padding: 0.6rem 0.1rem; color: var(--muted); font-weight: 600; font-size: 0.875rem; background: none; margin-bottom: -1px; }
.nav-tabs .nav-link:hover { color: var(--ink); border-bottom-color: var(--line-strong); }
.nav-tabs .nav-link.active { color: var(--ink); border-bottom-color: var(--ink); background: none; }
.nav-tabs .nav-link .count { display: inline-block; min-width: 1.4rem; padding: 0 0.35rem; margin-left: 0.3rem; border-radius: 999px; background: #eef1f5; color: var(--ink-2); font-size: 0.72rem; text-align: center; }

/* ---------- Empty states ---------- */
.empty-state { padding: 3.25rem 1.5rem; text-align: center; }
.empty-state .icon { width: 48px; height: 48px; margin: 0 auto 0.9rem; border-radius: 14px; background: var(--brand-soft); color: var(--brand-ink); display: flex; align-items: center; justify-content: center; font-size: 1.35rem; }
.empty-state .title { font-weight: 700; font-size: 1rem; margin-bottom: 0.3rem; }
.empty-state p { max-width: 440px; margin-left: auto; margin-right: auto; font-size: 0.875rem; }

/* ---------- Public pages (invitation, waiting, suspended, errors) ---------- */
.public-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 2.5rem 1rem;
  background: radial-gradient(1200px 500px at 50% -10%, var(--brand-soft), transparent 60%), var(--canvas); }
.public-card { width: 100%; max-width: 480px; padding: 2.25rem; }
.public-card h1 { font-size: 1.4rem; }

/* ---------- Onboarding (§5.1) ---------- */
.onboarding-top { background: var(--surface); border-bottom: 1px solid var(--line); }
.onboarding-top .meta { font-size: 0.8rem; color: var(--muted); }
.onboarding-steps { display: grid; grid-template-columns: repeat(6, 1fr); gap: 0.4rem; list-style: none; padding: 0; margin: 0; }
.onboarding-steps li { font-size: 0.72rem; font-weight: 600; color: var(--faint); }
.onboarding-steps li .bar { display: block; height: 4px; border-radius: 99px; background: var(--line); margin-bottom: 0.45rem; }
.onboarding-steps li.done { color: var(--muted); }
.onboarding-steps li.done .bar { background: var(--brand); }
.onboarding-steps li.current { color: var(--ink); }
.onboarding-steps li.current .bar { background: var(--ink); }
.onboarding-steps li .num { font-variant-numeric: tabular-nums; margin-right: 0.25rem; opacity: 0.7; }
@media (max-width: 575px) { .onboarding-steps li .label { display: none; } }
.tutorial-num {
  width: 32px; height: 32px; border-radius: 9px; background: var(--brand-soft); color: var(--brand-ink);
  display: inline-flex; align-items: center; justify-content: center; font-weight: 750; font-size: 0.85rem;
}
.tutorial-card { box-shadow: var(--shadow-sm); }
/* Blocking pop-up (re-acceptance, §4.2): dims the whole portal behind it. */
.blocking-backdrop { position: fixed; inset: 0; background: rgba(15, 27, 45, 0.45); backdrop-filter: blur(2px); z-index: 1040; }
.blocking-dialog { position: relative; z-index: 1050; max-width: 880px; margin: 0 auto; box-shadow: 0 24px 60px -12px rgba(15, 27, 45, 0.35); }
.agreement-viewer { border: 1px solid var(--line-strong); border-radius: var(--radius); overflow: hidden; background: var(--surface-2); }
.agreement-viewer iframe { display: block; width: 100%; height: 62vh; min-height: 420px; border: 0; }

/* ---------- Local demo bar ---------- */
.dev-banner { background: #111827; color: #cbd5e1; font-size: 0.75rem; letter-spacing: 0.01em; }
.dev-banner a { color: #fff; }

/* ---------- Email template preview (§7.2) ---------- */
.email-preview { white-space: pre-wrap; overflow-wrap: anywhere; font: 0.85rem/1.55 var(--bs-font-sans-serif); background: #f6f8fa; border: 1px solid var(--line); border-radius: 8px; padding: 0.9rem 1rem; color: var(--ink); }

/* ---------- Stock section tabs: the pages behind one menu item ---------- */
.stock-tabs { display: flex; gap: 0.25rem; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.stock-tabs::-webkit-scrollbar { display: none; }
.stock-tab { padding: 0.6rem 0.9rem; font-size: 0.875rem; font-weight: 600; color: var(--muted); text-decoration: none; white-space: nowrap; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.stock-tab:hover { color: var(--ink); }
.stock-tab.active { color: var(--brand-ink); border-bottom-color: var(--brand); }

/* ---------- Stock overview: to-do list and quick actions ---------- */
.todo-list { list-style: none; margin: 0; padding: 0; }
.todo-list li + li { border-top: 1px solid var(--line); }
.todo-list a { display: flex; align-items: center; gap: 0.75rem; padding: 0.8rem 1rem; color: var(--ink); text-decoration: none; }
.todo-list a:hover { background: var(--canvas); }
.todo-count { min-width: 2.25rem; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; border-radius: 999px; padding: 0.15rem 0.5rem; background: var(--canvas); }
.todo-count.warn { background: #fff4d6; color: #8a5a00; }
.todo-count.bad { background: #fde4e4; color: #a12626; }
.todo-list .bi-chevron-right { margin-left: auto; color: var(--faint); }
.quick-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0.75rem; }
.quick-action { display: flex; align-items: center; gap: 0.6rem; padding: 0.85rem 1rem; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); font-weight: 600; text-decoration: none; box-shadow: var(--shadow-sm); }
.quick-action:hover { border-color: var(--brand); color: var(--brand-ink); }
.quick-action .bi { font-size: 1.15rem; }

/* ---------- Next steps: dashboard list and the bell ---------- */
.todo-dot { width: 0.6rem; height: 0.6rem; border-radius: 50%; background: var(--faint); flex: none; margin: 0 0.8rem; }
.todo-dot.warn { background: #d99a00; }
.todo-dot.bad { background: #d33b3b; }
.portal-bell__count { position: absolute; top: -2px; right: -4px; min-width: 1.1rem; height: 1.1rem; padding: 0 0.25rem; border-radius: 999px; background: #d99a00; color: #fff; font-size: 0.7rem; font-weight: 700; line-height: 1.1rem; text-align: center; }
.portal-bell__count.bad { background: #d33b3b; }
.portal-bell__menu { width: min(360px, calc(100vw - 2rem)); max-height: 70vh; overflow-y: auto; }
.portal-bell__menu .todo-list a { padding: 0.6rem 1rem; font-size: 0.875rem; }

/* ---------- Trace: the reference chain, one step under another ---------- */
.trace { display: grid; gap: 0; max-width: 980px; }
.trace-step { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-sm); }
.trace-step + .trace-step { margin-top: 1.6rem; }
.trace-step + .trace-step::before { content: "\2193"; position: absolute; top: -1.45rem; left: 1.4rem; color: var(--faint); font-size: 1rem; line-height: 1; }
.trace-step__head { display: flex; align-items: center; gap: 0.5rem; padding: 0.7rem 1rem; font-weight: 700; border-bottom: 1px solid var(--line); }
.trace-step__count { margin-left: auto; color: var(--muted); font-weight: 600; font-variant-numeric: tabular-nums; }
.trace-step__body { display: flex; flex-wrap: wrap; gap: 0.5rem; padding: 0.75rem 1rem; }
.trace-item { display: inline-flex; flex-direction: column; padding: 0.45rem 0.7rem; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); text-decoration: none; min-width: 0; max-width: 100%; }
a.trace-item:hover { border-color: var(--brand); color: var(--brand-ink); }
.trace-item .cell-sub { white-space: normal; }
