/* ============================================================
   Map-first UI in the Felt manner: dark top bar, dark glass legend
   on the left, pink accent, zoom at bottom-right.
   ============================================================ */
.header { height: 56px; border-bottom: 1px solid var(--border); background: var(--glass-solid); gap: var(--s-2); padding: 0 var(--s-4); }
.header .brand { font: 700 17px/1 var(--font-sans); letter-spacing: -.01em; gap: var(--s-2); }
.header .brand .logo { width: 24px; height: 24px; background: var(--accent); border-radius: 6px; }
.header .crumb { color: var(--text-3); font-size: 14px; display: flex; align-items: center; gap: 6px; }
.header .crumb b { color: var(--text); font-weight: 500; }
.header .search-wrap { max-width: 360px; }
.header .search-wrap .input { background: var(--bg-muted); border-color: transparent; color: var(--text); }
.header .search-wrap .input::placeholder { color: var(--text-3); }
.header .company-btn { background: transparent; border-color: transparent; padding: 4px 8px; }
.header .company-btn:hover { background: var(--bg-muted); }
.header .company-btn .c-code { background: var(--bg-muted); color: var(--text); font-size: 10px; }
.header .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.header .btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.header .avatar { background: #3b82f6; color: #fff; }
.header .menu { background: var(--surface-raised); }

.rail { background: var(--glass-solid); border-right: 1px solid var(--border); }
.rail a { color: var(--text-3); font-size: 9px; letter-spacing: 0; text-transform: none; }
.rail a:hover { color: var(--text); background: var(--bg-muted); }
.rail a.active { background: var(--ink); color: var(--text-inverse); }
.rail .sep { background: var(--border); }
.rail .count { background: var(--accent); }

/* Legend panel (left) */
.map-stage .x-side { left: 12px; right: auto; top: 12px; bottom: 12px; width: 440px; gap: 0; }
.map-stage .x-side .panel { background: var(--surface); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 12px 40px rgba(0,0,0,.45); }
.map-stage .x-side .lpanel { display: block; flex: 1 1 auto; overflow: auto; padding: 0 20px 16px; scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
.map-stage .x-side .lpanel::-webkit-scrollbar, .sheet-body::-webkit-scrollbar { width: 6px; }
.map-stage .x-side .lpanel::-webkit-scrollbar-thumb, .sheet-body::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
.map-stage .x-side .lpanel::-webkit-scrollbar-track, .sheet-body::-webkit-scrollbar-track { background: transparent; }
.period-bar { padding: 10px 0 2px; }
.period-bar .seg { display: flex; width: 100%; }
.period-bar .seg button { flex: 1; }
.legend-tabs { display: flex; gap: 18px; padding: 12px 20px 10px; margin: 0 -20px 6px; width: calc(100% + 40px); box-sizing: border-box; border-bottom: 1px solid var(--border); background: transparent; }
.legend-tabs button { border: 0; background: none; font: 500 15px/1.2 var(--font-sans); color: var(--text-3); padding: 0 0 6px; margin-bottom: -11px; border-bottom: 2px solid transparent; }
.legend-tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--text); }
.lg-title { font: 600 14px/1.3 var(--font-sans); margin: 18px 0 8px; display: flex; justify-content: space-between; align-items: center; }
.lg-title .btn { font-weight: 500; }
.lg-title .caption { font-weight: 400; }
.lg-cat { display: flex; align-items: center; gap: 12px; padding: 6px 0; font-size: 14px; cursor: pointer; user-select: none; }
.lg-cat i { width: 11px; height: 11px; border-radius: 50%; flex: none; box-shadow: 0 0 0 2px var(--bg-muted); }
.lg-cat.off { opacity: .38; }
.lg-cat .n { margin-left: auto; color: var(--text-3); font-size: 12px; font-variant-numeric: tabular-nums; }
.lg-big { font: 600 32px/1.1 var(--font-sans); letter-spacing: -.02em; margin: 2px 0 4px; font-variant-numeric: tabular-nums; }
.lg-big small { font: 400 14px/1 var(--font-sans); color: var(--text-3); margin-left: 6px; }
.lg-sub { color: var(--text-3); font-size: 13px; }
.hist { display: flex; align-items: flex-end; gap: 2px; height: 72px; margin-top: 10px; }
.hist i { flex: 1; background: var(--accent); min-height: 2px; border-radius: 1px 1px 0 0; }
.hist i.past { background: var(--border-strong); }
.hist-cap { color: var(--accent-text); font-size: 12px; text-align: right; margin-top: 6px; }
.rank { display: flex; flex-direction: column; gap: 10px; }
.rank .row-r { display: flex; justify-content: space-between; font-size: 13.5px; }
.rank .row-r b { font-weight: 500; }
.rank .row-r span { color: var(--text-2); font-variant-numeric: tabular-nums; }
.rank .bar { height: 6px; background: var(--bg-muted); border-radius: 3px; margin-top: 6px; overflow: hidden; }
.rank .bar i { display: block; height: 100%; background: #4fb3ff; border-radius: 3px; }
.lg-row { display: flex; gap: 8px; align-items: center; }
.map-stage .x-side .seg { border-color: var(--border-strong); }
.map-stage .x-side .seg button { color: var(--text-2); }
.map-stage .x-side .seg button[aria-pressed="true"] { background: var(--bg-muted); color: var(--text); }
.map-stage .x-side select.input { background-color: var(--bg-subtle); }
.map-stage .x-side .feed li { border-color: var(--border); }
.map-stage .x-side .feed .f-icon { background: var(--bg-muted); }
.map-stage .x-side .x-search .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.map-stage .x-hide { left: 464px; right: auto; }
.map-stage .x-hide.collapsed { left: 12px; }
.map-stage .leaflet-top.leaflet-right .leaflet-control-zoom { margin: 12px 16px 0 0; }
.stage.sheet-open .map-stage .leaflet-top.leaflet-right { right: 544px; }
.map-stage .float { background: var(--surface); color: var(--text); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border: 1px solid var(--border); box-shadow: 0 10px 30px rgba(0,0,0,.45); }
.map-stage .x-side { background: none !important; border: 0 !important; box-shadow: none !important; backdrop-filter: none !important; -webkit-backdrop-filter: none !important; padding: 0; }
.map-stage .map-legend { left: auto; right: 16px; bottom: 16px; background: var(--surface); color: var(--text); border-color: var(--border); }
.map-stage .leaflet-right .leaflet-control-zoom { margin-right: 16px; margin-bottom: 16px; }
.map-stage .leaflet-control-zoom { border: 1px solid var(--border) !important; background: var(--surface); backdrop-filter: blur(12px); }
.map-stage .leaflet-bar a { background: transparent; color: var(--text); border-bottom-color: var(--border); width: 32px; height: 32px; line-height: 30px; font-size: 20px; font-weight: 400; }
.map-stage .leaflet-bar a:hover { background: var(--bg-muted); }
.map-stage .leaflet-tooltip { background: var(--surface-raised); color: var(--text); border-color: var(--border); }
.map-stage .leaflet-control-attribution { display: none; }
.stickers-hint { left: auto !important; right: 16px !important; bottom: 100px !important; }
/* Oblast labels: big italic uppercase on dark/satellite like Felt region labels */
.oblast-label.on-sat { font: 500 10px/1 var(--font-sans); font-style: normal; letter-spacing: .08em; text-transform: uppercase; color: rgba(255,255,255,.92); text-shadow: 0 1px 2px rgba(0,0,0,.9), 0 0 6px rgba(0,0,0,.6); }
.oblast-label { font: 500 10px/1 var(--font-sans); font-style: normal; letter-spacing: .08em; text-transform: uppercase; color: rgba(24,24,27,.55); }
/* Sheet: slightly inset like a floating document */

@media (max-width: 767px) {
  .map-stage .x-side { left: 12px; right: 12px; width: auto; top: auto; }
  .map-stage .leaflet-bottom.leaflet-right { bottom: calc(42% + 86px); }
  .map-stage .x-tools { top: 12px; right: 12px; left: auto; }
  .map-stage .map-legend { display: none; }
  .map-stage .x-hide { left: auto; right: 12px; }
  .map-stage .x-hide.collapsed { left: auto; }
  .header .crumb { display: none; }
}

.cluster-tip { position: absolute; z-index: 800; pointer-events: none; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 6px 9px; font: 12px/1.4 var(--font-sans); white-space: nowrap; box-shadow: 0 8px 24px rgba(0,0,0,.4); }

/* Sticker popup on the map */
.dot-popup .leaflet-popup-content-wrapper { background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 16px 48px rgba(0,0,0,.5); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); font: 13px/1.45 var(--font-sans); }
.dot-popup .leaflet-popup-content { margin: 14px 16px; }
.dot-popup .leaflet-popup-tip { background: var(--surface); border: 1px solid var(--border); }
.dot-popup .leaflet-popup-close-button { color: var(--text-3); font-size: 20px; padding: 6px 8px 0 0; }
.dp-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; font-weight: 600; font-size: 14px; }
.dp-row { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; border-top: 1px solid var(--border); }
.dp-row span { color: var(--text-3); }
.dp-row b { font-weight: 500; text-align: right; }
.dp-flag { margin-top: 8px; padding: 6px 8px; border-left: 3px solid #ff5a36; background: rgba(255,90,54,.12); border-radius: 6px; font-size: 12px; }
.dp-actions { display: flex; gap: 8px; margin-top: 12px; }
.dp-actions .btn { background: var(--bg-muted); border-color: var(--border-strong); color: var(--text); }
.dp-actions .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.dot-popup .badge { background: var(--bg-muted); color: var(--text); }
.dot-popup .badge.danger { background: rgba(255,90,54,.2); color: #ff8a70; }
.dot-popup .badge.success { background: rgba(57,217,138,.18); color: #5fe3a1; }

.map-stage .leaflet-popup-pane { z-index: 900; }
.map-stage .leaflet-tooltip-pane { z-index: 850; }

/* Leaflet-owned elements (zoom, popups, tips) take the glass tokens too */
.map-stage .leaflet-container { color: inherit; }

/* Embedded CRM pages inside the panel */
.embed { container-type: inline-size; container-name: panel; margin-top: 12px; }
.embed .page-head { display: none; }
.embed .filters-toggle { display: none; }
.embed .filters { display: flex; padding: 0; border: 0; background: none; gap: 8px; }
.embed .filters .field { min-width: 0; flex: 1 1 45%; }
.embed .filters .field.wide { flex-basis: 100%; }
.embed .filters .spacer { display: none; }
.embed .metrics { grid-template-columns: 1fr 1fr; }
.embed .dash-grid, .embed .detail-grid { grid-template-columns: 1fr; }
.embed .card { padding: 14px 16px; }
.embed .tabs { gap: 14px; }
.embed .table-wrap { background: none; }
.mode-seg { display: flex; margin-top: 12px; }
.mode-seg button { flex: 1; }
.header .bell { position: relative; }
.header .bell .count { position: absolute; top: 2px; right: 2px; background: var(--accent); color: #fff; font: 600 9px/1 var(--font-sans); border-radius: 999px; padding: 2px 4px; min-width: 14px; text-align: center; }
.header .product-btn svg { width: 15px; height: 15px; color: var(--text-3); }
@container panel (max-width: 700px) {
  table.table, .table tbody, .table tr, .table td { display: block; }
  .table thead { display: none; }
  .table tr { padding: 10px 12px; border-bottom: 1px solid var(--border); display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; }
  .table td { padding: 0; border: 0; display: flex; flex-direction: column; gap: 1px; }
  .table td::before { content: attr(data-label); font: var(--text-caption); font-size: 10px; color: var(--text-3); }
  .table td.primary { grid-column: span 2; display: block; margin-bottom: 4px; }
  .table td.primary::before { display: none; }
  .table td.num { text-align: left; }
  .table td.hide-m { display: none; }
  .table-foot { flex-direction: column; align-items: flex-start; }
}

/* Map settings (basemap, regions) under the zoom control */
.map-stage .x-mapset { top: 85px; right: 16px; padding: 0; border-radius: 8px; width: 34px; height: 34px; box-sizing: border-box; display: flex; align-items: center; justify-content: center; }
.map-stage .x-mapset .btn { width: 32px; height: 32px; min-height: 32px; border-radius: 7px; border: 0; }
.map-stage .x-mapset .btn svg { width: 17px; height: 17px; }
.map-stage .leaflet-control-zoom { border-radius: 8px !important; }
.map-stage .mapset-pop { position: absolute; top: 0; right: 44px; width: 280px; padding: 12px 14px 14px; background: var(--surface-raised); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 12px 36px rgba(0,0,0,.35); }
.map-stage .mapset-pop .seg { display: flex; }
.map-stage .mapset-pop .seg button { flex: 1; }
.stage.sheet-open .map-stage .x-mapset { right: 560px; }
@media (max-width: 767px) { .map-stage .x-mapset { top: 92px; right: 12px; } .stage.sheet-open .map-stage .x-mapset { display: none; } }

/* Bar-strip chart */
.chart.bars-chart { height: auto; }
.bars-row { padding: 10px 0 4px; }
.bars-head { display: flex; justify-content: space-between; align-items: center; font-size: 13px; margin-bottom: 6px; }
.bars-head span { display: flex; align-items: center; gap: 8px; color: var(--text-2); }
.bars-head span i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.bars-head b { font-weight: 600; font-variant-numeric: tabular-nums; }
.hist.sm { height: 48px; margin-top: 0; }
.hist.sm i { opacity: 1; }
.bars-axis { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-3); margin-top: 6px; }

/* Unified layer/metric rows */
.lg-stats { display: flex; flex-direction: column; }
.lg-stat { display: flex; align-items: center; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--border); cursor: pointer; user-select: none; transition: opacity .12s; }
.lg-stat:last-child { border-bottom: 0; }
.lg-stat i { width: 11px; height: 11px; border-radius: 50%; flex: none; background: var(--c); box-shadow: 0 0 0 2px var(--bg-muted); }
.lg-stat .lbl { flex: 1; font-size: 13.5px; color: var(--text-2); }
.lg-stat .val { font: 600 20px/1.1 var(--font-sans); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.lg-stat .drill { width: 26px; height: 26px; min-height: 0; opacity: .5; }
.lg-stat .drill:hover { opacity: 1; background: var(--bg-muted); }
.lg-stat.off i { background: transparent; box-shadow: inset 0 0 0 2px var(--c); opacity: .75; }
.lg-stat:hover { background: var(--bg-subtle); margin: 0 -8px; padding-left: 8px; padding-right: 8px; border-radius: 6px; }
.embed .metrics { display: none; }
.map-stage .map-legend { display: none; }

/* Hide/show panel button matches the zoom control (32px) */
.map-stage .x-hide { height: 34px; min-height: 34px; box-sizing: border-box; padding: 0 12px 0 9px; border-radius: 8px; font-size: 12.5px; gap: 6px; top: 12px; }
.map-stage .x-hide svg { width: 14px; height: 14px; }

/* Flat sections inside the panel: no inner cards, one title style, one list style */
.embed .card, .embed .card.flat { background: none; border: 0; padding: 0; border-radius: 0; box-shadow: none; }
.embed .card-head { padding: 0; border: 0; }
.embed .section-head, .embed .card-head { margin: 18px 0 8px; }
.embed .section-head h2, .embed .card-head h2 { font: 600 14px/1.3 var(--font-sans); text-transform: none; letter-spacing: 0; }
.embed .section-head a, .embed .card-head a { font-size: 12px; text-transform: none; letter-spacing: 0; }
.embed .stack.gap-6, .embed .dash-grid { gap: 0; }
.embed .dash-grid { margin-top: 0; }
.embed .table-wrap { background: transparent; border-left: 0; border-right: 0; border-radius: 0; }
.embed .bars-row:first-child { padding-top: 0; }
.rank .row-r b { max-width: 70%; }
.rank.red .bar i { background: #ff5a36; }
.rank .row-r span { color: var(--text-3); }
.embed .feed li { padding: 8px 0; }

/* Brand: SVG wordmark recoloured through a mask (navy in light, white in dark) */
.logo-mark { display: inline-block; width: 78px; height: 25px; background: currentColor; -webkit-mask: url(../assets/logo.svg) no-repeat center / contain; mask: url(../assets/logo.svg) no-repeat center / contain; }
.header .brand { color: var(--text); margin-right: 6px; }
:root[data-theme="light"] .header .brand { color: #2B295C; }
.auth-side .logo-mark { width: 110px; height: 36px; color: var(--text); }

.header .u-text { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.15; }
.header .u-company { font-size: 11px; color: var(--text-3); max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 767px) { .header .u-text { display: none; } }

.menu .menu-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 4px 10px; }
.menu .menu-row .menu-title { padding: 0; }
.menu .menu-row .seg button { min-height: 26px; padding: 0 8px; }
.menu .menu-row .seg button svg { width: 13px; height: 13px; }
.menu .menu-row .seg button[aria-pressed="true"] { background: var(--bg-muted); color: var(--text); }

.menu .menu-user { display: flex; align-items: center; gap: 10px; padding: 8px 10px 10px; }
.menu .menu-user .avatar.lg { width: 40px; height: 40px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 13px; }
.menu .menu-user b { font-weight: 600; font-size: 13px; }

/* Header: logo left, product + search centred, alerts + profile right */
.header { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; }
.header .h-left { display: flex; align-items: center; }
.header .h-center { display: flex; align-items: center; gap: 8px; justify-self: center; width: min(640px, 60vw); }
.header .h-center .search-wrap { flex: 1; max-width: none; }
.header .h-center .company-btn { min-width: 0; max-width: 260px; }
.header .h-right { display: flex; align-items: center; gap: 4px; justify-self: end; }
.header .spacer { display: none; }
@media (max-width: 767px) {
  .header { grid-template-columns: auto 1fr auto; }
  .header .h-center { width: auto; justify-self: stretch; }
  .header .h-center .company-btn .c-name { display: none; }
}

/* Modest metric rows (no chart, not interactive) */
.lg-metrics { margin-top: 10px; }
.lg-metric { display: flex; justify-content: space-between; align-items: baseline; padding: 6px 0; font-size: 13px; color: var(--text-2); }
.lg-metric b { font: 500 14px/1.2 var(--font-sans); color: var(--text); font-variant-numeric: tabular-nums; }
/* Chart rows act as layer toggles */
.bars-row .bars-head { cursor: pointer; user-select: none; }
.mapset-pop .lg-stats { margin-top: 2px; }
.mapset-pop .lg-stat { padding: 5px 0; border-bottom: 0; }
.mapset-pop .lg-stat .lbl { font-size: 13px; }
.map-stage .mapset-pop { width: 300px; }

/* Compact tag cards in the panel */
.tag-cards { display: flex; flex-direction: column; margin-top: 8px; }
.tag-card { display: block; padding: 10px 0; border-bottom: 1px solid var(--border); color: var(--text); }
.tag-card:hover { background: var(--bg-subtle); margin: 0 -8px; padding-left: 8px; padding-right: 8px; border-radius: 6px; color: var(--text); }
.tag-card .tc-top { display: flex; align-items: center; gap: 4px; font: 500 13px/1.3 var(--font-mono); }
.tag-card .tc-top .btn { width: 22px; height: 22px; min-height: 0; opacity: .6; }
.tag-card .tc-top .tc-scans { margin-left: auto; font: 500 13px/1.3 var(--font-mono); color: var(--text); white-space: nowrap; font-variant-numeric: tabular-nums; }
.tag-card .tc-mid { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-top: 2px; font-size: 13px; color: var(--text-2); }
.tag-card .tc-mid b { font-weight: 600; color: var(--text); white-space: nowrap; font-variant-numeric: tabular-nums; }
.tag-card .tc-mid b .caption { font-weight: 400; }
.tag-card .tc-bot { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 6px; }
.tag-card .tc-badges { display: flex; gap: 6px; }
.tag-cards .table-foot { border: 0; padding: 10px 0; }

.embed .filters .field:has(input[name=from]), .embed .filters .field:has(input[name=to]) { display: none; }

/* Header actions: larger bell, round avatar profile button */
.header .h-right { gap: 8px; }
.header .bell { width: 38px; height: 38px; }
.header .bell svg { width: 20px; height: 20px; }
.header .bell .count { top: 3px; right: 3px; font-size: 10px; padding: 2px 5px; min-width: 17px; }
.header .profile-btn { width: 38px; height: 38px; border: 0; background: none; padding: 0; border-radius: 50%; display: grid; place-items: center; cursor: pointer; }
.header .profile-btn .avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--accent); color: #fff; font: 600 12px/1 var(--font-sans); border: 2px solid rgba(255,255,255,.15); }
.header .profile-btn:hover .avatar { box-shadow: 0 0 0 3px var(--accent-soft); }

/* Donut chart */
.donut { display: flex; align-items: center; gap: 14px; margin-top: 6px; }
.donut svg { flex: none; }
.donut-total { font: 600 11px var(--font-sans); fill: var(--text); }
.donut-legend { flex: 1; min-width: 0; display: grid; grid-template-columns: 8px 1fr auto auto 18px 1fr auto auto; column-gap: 6px; row-gap: 5px; align-items: center; font-size: 12.5px; }
.donut-legend .dl-row:nth-child(even) > i { justify-self: end; }
.dl-row { display: contents; }
.dl-row i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dl-label { color: var(--text-2); white-space: nowrap; }
.dl-val { font-variant-numeric: tabular-nums; font-weight: 500; text-align: right; overflow: hidden; text-overflow: ellipsis; }
.dl-pct { color: var(--text-3); font-variant-numeric: tabular-nums; font-size: 11px; white-space: nowrap; text-align: right; }

/* Counts on segmented filters */
.seg button .cnt { color: var(--text-3); font-weight: 400; font-size: 11px; margin-left: 2px; font-variant-numeric: tabular-nums; }
.seg button[aria-pressed="true"] .cnt { color: var(--text-2); }
.mode-seg button, .embed #seg button { white-space: nowrap; padding: 0 8px; }
.embed #seg { display: flex; }
.embed #seg button { flex: 1; }

/* Right-side sticker detail panel */
.map-stage .x-detail { top: 12px; right: 60px; bottom: 12px; width: 440px; padding: 14px 16px 16px; overflow: auto; border-radius: 12px; scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
.map-stage .x-detail::-webkit-scrollbar { width: 6px; }
.map-stage .x-detail::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
.xd-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.xd-code { font: 600 15px/1.3 var(--font-mono); }
.xd-badges { display: flex; gap: 6px; margin: 10px 0 12px; }
.xd-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; margin-bottom: 12px; }
.xd-facts div { display: flex; flex-direction: column; gap: 2px; }
.xd-facts span { font-size: 11px; color: var(--text-3); }
.xd-facts b { font-weight: 500; font-size: 13px; }
.xd-actions { display: flex; gap: 8px; margin: 12px 0 4px; }
.xd-actions .btn { flex: 1; }
.xd-timeline li { grid-template-columns: 92px 14px 1fr; font-size: 12.5px; padding: 8px 0; }
.xd-timeline .t-time { font-size: 11.5px; }
.xd-timeline .t-dot { width: 7px; height: 7px; }
.xd-timeline .t-dot.scan { background: #4fb3ff; } .xd-timeline .t-dot.activation { background: #39d98a; } .xd-timeline .t-dot.suspicious { background: #ffb020; } .xd-timeline .t-dot.status { background: #ff5a36; } .xd-timeline .t-dot.complaint { background: #a78bfa; }
.stage.sheet-open .map-stage .x-detail { display: none; }
@media (max-width: 1023px) { .map-stage .x-detail { width: 320px; } }
@media (max-width: 767px) { .map-stage .x-detail { top: auto; left: 12px; right: 12px; bottom: 74px; width: auto; max-height: 46%; z-index: 650; } }

/* Filter tab header: mode dropdown + period icon */
.flt-head { display: flex; justify-content: space-between; align-items: center; margin: 8px 0 4px; }
.flt-mode, .flt-period { position: relative; }
.flt-title { display: flex; align-items: center; gap: 6px; border: 0; background: none; padding: 4px 0; font: 600 16px/1.3 var(--font-sans); color: var(--text); cursor: pointer; }
.flt-title svg { width: 14px; height: 14px; color: var(--text-3); }
.flt-title .cnt { font: 400 13px/1 var(--font-sans); color: var(--text-3); }
.flt-head .pmenu { top: calc(100% + 6px); }
.flt-head .pmenu button .cnt { margin-left: auto; color: var(--text-3); font-size: 12px; }
.flt-period .btn.on { color: var(--accent); }
.flt-period .btn svg { width: 17px; height: 17px; }

.list-count { font-size: 12px; color: var(--text-3); padding: 2px 0 8px; }
.table-wrap .list-count { padding: 8px 0 6px; }

/* Product is chosen in the header: hide it inside embedded filters */
.embed .filters .field:has(select[name=productId]) { display: none; }

/* Series suggestions inside the tag search + selected-series chip */
.series-search { position: relative; }
.series-search .pmenu { left: 0; right: 0; top: calc(100% + 4px); z-index: 20; }
.series-search .pmenu button { align-items: flex-start; }
.chips { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 6px 3px 8px; border-radius: 999px; background: var(--bg-muted); font: 500 12px/1 var(--font-mono); }
.chip svg { width: 12px; height: 12px; color: var(--text-3); }
.chip-x { border: 0; background: none; padding: 2px; display: grid; place-items: center; cursor: pointer; color: var(--text-3); border-radius: 50%; }
.chip-x:hover { background: var(--bg-subtle); color: var(--text); }
.chip-x svg { width: 11px; height: 11px; }

/* Alerts popover under the bell */
.bell-wrap { position: relative; }
.bell-pop { position: absolute; top: calc(100% + 8px); right: 0; width: 400px; max-height: 72vh; overflow: auto; padding: 0; z-index: 1300; scrollbar-width: thin; }
.bell-pop .bell-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px 8px; font-size: 14px; }
.bell-pop .bell-body { padding: 0 14px 10px; margin-top: 0; }
.bell-pop .bell-body .page-head { display: none; }
/* Underline tabs (dashboard style) instead of a segmented control */
.bell-pop .bell-body .seg, .bell-pop .embed #seg { display: flex; justify-content: flex-start; gap: 18px; border: 0; border-bottom: 1px solid var(--border); border-radius: 0; background: none; padding: 0; margin-bottom: 4px; }
.bell-pop .bell-body .seg button, .bell-pop .embed #seg button { flex: none; width: auto; background: none; border: 0; border-bottom: 2px solid transparent; border-radius: 0; margin-bottom: -1px; padding: 0 0 6px; min-height: 0; font: 500 15px/1.2 var(--font-sans); color: var(--text-3); text-transform: none; letter-spacing: 0; }
.bell-pop .bell-body .seg button[aria-pressed="true"], .bell-pop .embed #seg button[aria-pressed="true"] { color: var(--text); border-bottom-color: var(--text); background: none; }
.bell-pop .feed li { align-items: flex-start; }
.bell-pop .feed .f-time { margin-left: auto; }
.bell-pop .bell-body .card { background: none; border: 0; padding: 0; }
.bell-pop .feed li { padding: 8px 0; }
.bell-pop .feed .f-time { font-size: 11px; }
.bell-pop .feed .f-icon { width: 26px; height: 26px; }
@media (max-width: 767px) { .bell-pop { position: fixed; top: 60px; left: 8px; right: 8px; width: auto; } }

/* Narrow sheet: single column everywhere, compact header */
.sheet .detail-grid, .sheet .dash-grid { grid-template-columns: 1fr; gap: 12px; }
.sheet .metrics { grid-template-columns: 1fr 1fr; }
.sheet .page-head { padding-right: 0; flex-direction: column; align-items: flex-start; }
.sheet .page-head > div:first-child { padding-right: 44px; }
.sheet .page-head .actions { width: 100%; }
.sheet .page-head .actions .btn { flex: 1; }
.sheet .stack.gap-6 { gap: 12px; }
.sheet .card { padding: 14px 16px; }
.sheet .form-grid { grid-template-columns: 1fr; }
.sheet .form-grid .span-2 { grid-column: span 1; }
.sheet .table-wrap.keep-table { overflow-x: auto; }
.sheet .product-grid { grid-template-columns: 1fr; }
.sheet .filters .field { min-width: 0; flex: 1 1 45%; }
.sheet .filters .field.wide { flex-basis: 100%; }
@media (max-width: 767px) { .sheet { top: 0; right: 0; bottom: 62px; left: 0; width: auto; border-radius: 0; } }

.stage.sheet-open .cluster-tip { display: none !important; }
.sheet .metrics { grid-template-columns: 1fr 1fr; }
.sheet .metric { min-height: 84px; padding: 12px 14px; }

/* Consumer product page preview (phone frame) */
.pp-wrap { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.pp { width: 100%; max-width: 380px; background: #fff; color: #2B295C; border-radius: 16px; overflow: hidden; border: 1px solid var(--border); box-shadow: 0 12px 36px rgba(0,0,0,.25); font-family: var(--font-sans); }
.pp-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 4px; }
.pp-head .logo-mark { width: 64px; height: 20px; color: #2B295C; }
.pp-head .pp-back svg { width: 18px; height: 18px; color: #9a99b0; }
.pp-head .pp-lang { font-size: 13px; text-decoration: underline; }
.pp-sub { text-align: center; font-size: 11px; color: #8b8aa3; padding-bottom: 10px; }
.pp-banner { display: flex; align-items: center; gap: 12px; padding: 14px 16px; color: #fff; }
.pp-banner svg { width: 28px; height: 28px; flex: none; }
.pp-banner b { display: block; font-size: 18px; line-height: 1.15; }
.pp-banner span { font-size: 12px; opacity: .9; }
.pp-banner.success { background: #5cb85c; } .pp-banner.warning { background: #e0a53a; } .pp-banner.danger { background: #d9534f; } .pp-banner.neutral { background: #8b8aa3; }
.pp-row { display: flex; justify-content: space-between; gap: 12px; padding: 10px 16px; border-bottom: 1px solid #ecebf2; font-size: 12.5px; }
.pp-row span { color: #8b8aa3; } .pp-row b { text-align: right; font-weight: 600; }
.pp-title { padding: 12px 16px 4px; font: 600 15px/1.35 var(--font-sans); color: #2B295C; }
.pp-summary { padding: 0 16px 10px; font-size: 12.5px; color: #4a4968; }
.pp-gallery { padding: 4px 16px 12px; }
.pp-photo { height: 260px; border-radius: 10px; background: linear-gradient(160deg, #f1f0f7, #dedcee); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; color: #9a99b0; font-size: 12px; }
.pp-photo svg { width: 36px; height: 36px; }
.pp-dots { display: flex; justify-content: center; gap: 6px; margin-top: 10px; }
.pp-dots i { width: 6px; height: 6px; border-radius: 50%; background: #d7d6e6; } .pp-dots i.on { background: #2B295C; }
.pp-attrs { border-top: 1px solid #ecebf2; }
.pp-section { padding: 12px 16px; border-bottom: 1px solid #ecebf2; }
.pp-section h3 { font: 600 13px/1.3 var(--font-sans); margin-bottom: 6px; color: #2B295C; }
.pp-section p { font-size: 12.5px; line-height: 1.5; color: #4a4968; white-space: pre-line; }
.pp-foot { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px; font-size: 12px; }
.pp-foot a { color: #8b8aa3; }
.pp-note { text-align: center; }

/* Compact two-row facts block (tag detail) */
.facts2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--r-3); background: var(--surface); }
.facts2 > div { display: flex; flex-direction: column; gap: 3px; min-width: 0; font-size: 13px; }
.facts2 > div > span:first-child { font-size: 11px; color: var(--text-3); }
.facts2 b { font-weight: 600; }
.facts2 small { font-size: 11px; }

.facts2 { background: var(--surface); }
.facts2 .st-original { color: var(--success); } .facts2 .st-counterfeit { color: var(--danger); } .facts2 .st-suspect { color: var(--warning); } .facts2 .st-disabled, .facts2 .st-complaint { color: var(--text-2); }

/* Classic checkboxes in map settings */
.chk-list { display: flex; flex-direction: column; gap: 2px; }
.chk { display: flex; align-items: center; gap: 10px; padding: 5px 0; font-size: 13.5px; cursor: pointer; user-select: none; }
.chk span { flex: 1; }
.chk input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); flex: none; margin-left: auto; }
.chk i { width: 10px; height: 10px; border-radius: 50%; flex: none; }

/* Tag page inside the right panel */
.x-detail .xd-close { position: absolute; top: 10px; right: 10px; z-index: 2; }
.x-detail .xd-page { margin-top: 0; }
.x-detail .xd-page .page-head { display: flex; padding-right: 0; flex-direction: column; align-items: flex-start; margin-bottom: 14px; padding-bottom: 0; border-bottom: 0; }
.x-detail .xd-page .page-head > div:first-child { padding-right: 36px; }
.x-detail .xd-page .page-head h1 { font-size: 16px; }
.x-detail .xd-page .page-head .actions { width: 100%; }
.x-detail .xd-page .page-head .actions .btn { flex: 1; }
.x-detail .xd-page .detail-grid { grid-template-columns: 1fr; gap: 12px; }
.x-detail .xd-page .card { background: none; border: 0; padding: 0; border-radius: 0; }
.x-detail .xd-page .facts2 { background: none; border: 0; padding: 4px 0 12px; border-bottom: 1px solid var(--border); border-radius: 0; }
.x-detail .xd-page .tabs { margin-bottom: 12px; }
.x-detail .xd-page .pp { max-width: none; }
.x-detail .xd-page .timeline li { font-size: 12.5px; grid-template-columns: 92px 14px 1fr; }

.pp-photo { background: #fff; }
.pp-photo img { width: 100%; height: 100%; object-fit: contain; border-radius: 10px; }
.product-card .cover img { width: 100%; height: 100%; object-fit: cover; }

.x-detail .xd-page .top-tabs { margin: 0 0 12px; padding-right: 36px; }
.sheet .top-tabs { margin-bottom: 12px; padding-right: 44px; }

/* Sheet (CRM popups): flat like the left panel — no inner cards, list rows with hairlines */
.sheet .page-head { margin-bottom: 14px; padding-bottom: 0; border-bottom: 0; }
.sheet .card, .sheet .card.flat { background: none; border: 0; padding: 0; border-radius: 0; box-shadow: none; }
.sheet .card-head { padding: 0; border: 0; }
.sheet .section-head, .sheet .card-head, .sheet .card > h2 { margin: 18px 0 6px; }
.sheet .section-head h2, .sheet .card-head h2, .sheet .card > h2 { font: 600 14px/1.3 var(--font-sans); text-transform: none; letter-spacing: 0; }
.sheet .section-head a, .sheet .card-head a { font-size: 12px; text-transform: none; letter-spacing: 0; }
.sheet .stack.gap-6, .sheet .detail-grid, .sheet .dash-grid { gap: 0; }
.sheet .metrics { display: flex; flex-direction: column; background: none; border: 0; border-radius: 0; overflow: visible; }
.sheet .metric { flex-direction: row; justify-content: space-between; align-items: baseline; gap: 12px; min-height: 0; padding: 7px 0; background: none; box-shadow: none; border-bottom: 1px solid var(--border); }
.sheet .metric:last-child { border-bottom: 0; }
.sheet .metric .m-label { font: 400 13.5px/1.3 var(--font-sans); color: var(--text-2); text-transform: none; letter-spacing: 0; }
.sheet .metric .m-value { font: 600 18px/1.1 var(--font-sans); letter-spacing: -.02em; }
.sheet .metric .m-delta { display: none; }
.sheet .kv { grid-template-columns: minmax(96px, max-content) 1fr; gap: 0 16px; align-items: baseline; }
.sheet .kv dt, .sheet .kv dd { padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.sheet .kv dt { color: var(--text-3); text-transform: none; letter-spacing: 0; font-size: 12.5px; }
.sheet .kv dt:last-of-type, .sheet .kv dd:last-of-type { border-bottom: 0; }
/* Tabs inside popups match the left panel tabs (Dashboard | Filter) */
.sheet .tabs, .x-detail .xd-page .tabs { display: flex; gap: 18px; margin: 16px 0 10px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.sheet .tabs button, .x-detail .xd-page .tabs button { border: 0; background: none; font: 500 15px/1.2 var(--font-sans); color: var(--text-3); padding: 0 0 6px; margin-bottom: -1px; border-bottom: 2px solid transparent; text-transform: none; letter-spacing: 0; white-space: nowrap; }
.sheet .tabs button[aria-selected="true"], .x-detail .xd-page .tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--text); }
.sheet .top-tabs, .x-detail .xd-page .top-tabs { margin-top: 0; }
.sheet .facts2 { background: none; border: 0; padding: 4px 0 12px; border-bottom: 1px solid var(--border); border-radius: 0; }
.sheet .product-card .cover { aspect-ratio: 16/10; border-radius: 10px; overflow: hidden; background: #fff; }
.sheet .product-card .cover img { object-fit: contain; display: block; min-width: 0; min-height: 0; }
.sheet .table-wrap, .embed .table-wrap, .x-detail .table-wrap { background: none; border: 0; border-radius: 0; }
/* Feed links inside the bell popover are inline text, not menu rows */
.bell-pop .feed a, .bell-pop .feed a:hover { display: inline; width: auto; padding: 0; background: none; border-radius: 0; font: inherit; color: var(--text); }
.bell-pop .feed a.mono { font-family: var(--font-mono); font-size: 13px; }
.bell-pop .feed a:hover { color: var(--accent-hover); }
.bell-pop .feed li > span:nth-child(2) { min-width: 0; line-height: 1.4; }
.bell-pop .feed svg { width: 14px; height: 14px; }
/* Feed icons use the same solid colours as the dashboard stat dots */
.bell-pop .feed .f-icon, .embed .feed .f-icon { color: #0b1220; border-radius: 8px; }
.bell-pop .feed .f-icon svg, .embed .feed .f-icon svg { width: 15px; height: 15px; stroke-width: 2.2; color: #0b1220; }
.bell-pop .feed .f-icon.scan, .embed .feed .f-icon.scan { background: #4fb3ff; }
.bell-pop .feed .f-icon.activation, .embed .feed .f-icon.activation { background: #39d98a; }
.bell-pop .feed .f-icon.suspicious, .embed .feed .f-icon.suspicious { background: #ffb020; }
.bell-pop .feed .f-icon.counterfeit, .embed .feed .f-icon.counterfeit { background: #ff5a36; }
/* Menu section titles match the layers popover headings (.lg-title) */
.menu .menu-title, .pmenu .menu-title { font: 600 14px/1.3 var(--font-sans); color: var(--text); text-transform: none; letter-spacing: 0; padding: 10px 10px 4px; }
.menu .menu-row .menu-title { padding: 0; }

/* Product list in the popup: flat rows instead of cards */
.sheet .product-grid { gap: 0; }
.sheet .product-card { display: grid; grid-template-columns: 88px 1fr; gap: 14px; align-items: start; padding: 12px 0; border: 0; border-bottom: 1px solid var(--border); border-radius: 0; background: none; overflow: visible; }
.sheet .product-card:hover { background: none; border-color: var(--border); }
.sheet .product-card:hover h3 { color: var(--accent-text); }
.sheet .product-card .cover { aspect-ratio: 1; border-radius: 8px; overflow: hidden; background: #fff; }
.sheet .product-card .cover img { object-fit: contain; display: block; min-width: 0; min-height: 0; }
.sheet .product-card .body { padding: 0; gap: 4px; }
.sheet .product-card .body h3 { font: 500 14px/1.3 var(--font-sans); }
.sheet .product-card .body .caption { font-size: 12.5px; }
.sheet .product-card .stats { border-top: 0; padding-top: 4px; gap: 16px; }
.sheet .product-card .stats b { font-size: 13px; }
.sheet .product-card .stats span { text-transform: none; letter-spacing: 0; font-size: 11px; }
/* Notices and complaint photo tiles: no boxes */
.sheet .notice, .x-detail .notice { border: 0; border-radius: 0; background: none; padding: 8px 0; border-bottom: 1px solid var(--border); }
.sheet .thumbs .thumb { border: 0; }
/* Stacked table rows in popups: flat, no inner box, content aligned left */
@container panel (max-width: 700px) {
  .table tr { padding: 10px 0; }
  .table td { align-items: flex-start; }
  .table td > .badge, .table td > .btn, .table td > .seg, .table td > .select { align-self: flex-start; }
  .table td .input, .table td select { width: 100%; }
}
/* Loading state of the alerts feed: faint row placeholders instead of one grey block */
.feed li.sk { align-items: center; }
.feed li.sk .skeleton { opacity: .45; }
.feed li.sk .f-icon.skeleton { background-image: none; background: var(--bg-muted); }

/* Filter form in the side panel / popups: Reset button is as tall as the inputs */
.embed .filters .btn, .sheet .filters .btn { min-height: 36px; padding: 0 12px; font-size: 12px; }
.series-search .pmenu { max-height: 320px; overflow: auto; }

/* Consumer page: product passport accordion (first section open) */
.pp-passport { border-top: 6px solid #f3f2f8; }
.pp-passport .pp-acc:first-child { border-top: 0; }
.pp-pass-head { display: flex; align-items: center; gap: 8px; padding: 14px 16px 6px; font: 600 11px/1 var(--font-sans); letter-spacing: .08em; text-transform: uppercase; color: #8b8aa3; }
.pp-pass-head svg { width: 14px; height: 14px; }
.pp-acc { border-top: 1px solid #ecebf2; }
.pp-acc summary { display: flex; align-items: center; gap: 10px; padding: 13px 16px; cursor: pointer; list-style: none; font: 600 13.5px/1.3 var(--font-sans); color: #2B295C; user-select: none; }
.pp-acc summary::-webkit-details-marker { display: none; }
.pp-acc summary > svg:first-child { width: 16px; height: 16px; color: #6b6a8a; flex: none; }
.pp-acc summary > span { flex: 1; }
.pp-acc summary > svg:last-child { width: 16px; height: 16px; color: #9a99b0; transition: transform .15s; }
.pp-acc[open] summary > svg:last-child { transform: rotate(180deg); }
.pp-acc[open] summary { background: #faf9fd; }
.pp-acc-body { padding-bottom: 6px; }
.pp-acc-body .pp-attrs { border-top: 0; }
.pp-acc-body .pp-row:last-child { border-bottom: 0; }
.pp-acc-body .pp-section { border-bottom: 0; padding-top: 8px; }
.pp-acc-body .pp-section + .pp-attrs { border-top: 1px solid #ecebf2; }
.pp-caption { padding: 8px 16px 2px; font-size: 11px; color: #8b8aa3; }
.pp-note-row { display: flex; gap: 8px; align-items: flex-start; }
.pp-note-row svg { width: 14px; height: 14px; color: #8b8aa3; flex: none; margin-top: 2px; }
.pp-note-row p { font-size: 12px; color: #8b8aa3; }
.pp-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.pp-chips span { font: 500 11.5px/1 var(--font-sans); padding: 6px 9px; border-radius: 999px; background: #eef2ff; color: #2B295C; }
.pp-steps { list-style: none; margin: 0; padding: 6px 16px 10px; }
.pp-steps li { display: flex; gap: 12px; position: relative; padding-bottom: 14px; }
.pp-steps li::before { content: ''; position: absolute; left: 5px; top: 14px; bottom: -2px; width: 2px; background: #ecebf2; }
.pp-steps li:last-child::before { display: none; }
.pp-steps li i { width: 12px; height: 12px; border-radius: 50%; border: 2px solid #c9c8d8; background: #fff; flex: none; margin-top: 3px; z-index: 1; }
.pp-steps li.done i { background: #5cb85c; border-color: #5cb85c; }
.pp-steps li b { display: block; font: 500 12.5px/1.3 var(--font-sans); color: #2B295C; }
.pp-steps li span { font-size: 11px; color: #8b8aa3; }
.pp-attrs a { color: #3b5bdb; }

/* Link to the standalone consumer page under the phone preview */
.pp-note a { display: inline-flex; align-items: center; gap: 4px; margin-left: 6px; color: var(--accent-text); }
.pp-note a svg { width: 12px; height: 12px; }

/* Consumer page: originality check (QR + unique stained-glass square) */
.pp-verify { padding: 14px 16px 16px; border-bottom: 1px solid #ecebf2; }
.pp-verify-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.pp-verify-grid figure { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.pp-verify-grid svg, .pp-verify-grid .pp-qr { width: 100%; height: auto; aspect-ratio: 1; display: block; }
.pp-verify-grid .pp-qr svg { width: 100%; height: 100%; }
.pp-verify-grid figcaption { font-size: 11px; color: #8b8aa3; text-align: center; }
.pp-verify h3 { display: flex; align-items: center; gap: 6px; margin-top: 14px; font: 600 13.5px/1.3 var(--font-sans); color: #2B295C; }
.pp-verify h3 svg { width: 16px; height: 16px; color: #5cb85c; }
.pp-verify p { margin-top: 6px; font-size: 12.5px; line-height: 1.5; color: #4a4968; }
.pp-btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; margin-top: 12px; min-height: 42px; border-radius: 10px; border: 1.5px solid #d9534f; background: #fff; color: #d9534f; font: 600 13px/1 var(--font-sans); cursor: pointer; }
.pp-btn svg { width: 16px; height: 16px; }
.pp-btn:hover { background: #fdf1f0; }
.pp-reported { display: flex; align-items: center; gap: 8px; margin-top: 12px; padding: 10px 12px; border-radius: 10px; background: #eaf6ea; color: #2f7d32; font-size: 12.5px; }
.pp-reported svg { width: 16px; height: 16px; }
.qr-fallback { font-size: 10px; word-break: break-all; padding: 8px; color: #8b8aa3; }
.kv .vitrage { display: block; border-radius: 4px; }
.kv dt:has(+ dd .vitrage), .kv dd:has(.vitrage) { align-self: center; }
.pp-acc-body .pp-verify { border-bottom: 0; padding-top: 6px; }

/* "Fit all objects" control: same 34px glass button as the layers one, sits under it */
.map-stage .x-fit { top: 125px; right: 16px; padding: 0; border-radius: 8px; width: 34px; height: 34px; box-sizing: border-box; display: flex; align-items: center; justify-content: center; }
.map-stage .x-fit .btn { width: 32px; height: 32px; min-height: 32px; border-radius: 7px; border: 0; }
.map-stage .x-fit .btn svg { width: 17px; height: 17px; }
.stage.sheet-open .map-stage .x-fit { right: 560px; }
@media (max-width: 767px) { .map-stage .x-fit { top: 132px; right: 12px; } .stage.sheet-open .map-stage .x-fit { display: none; } }

/* Consumer page: landing template */
.pp-landing { --pp-accent: #3b82f6; }
.pp-hero img { width: 100%; display: block; max-height: 260px; object-fit: cover; }
.pp-buttons { display: flex; flex-direction: column; gap: 8px; padding: 4px 16px 14px; }
.pp-btn.primary { background: var(--pp-accent, #3b82f6); border-color: var(--pp-accent, #3b82f6); color: #fff; margin-top: 0; text-decoration: none; }
.pp-btn.primary:hover { filter: brightness(1.08); background: var(--pp-accent, #3b82f6); }
.pp-btn.secondary { border-color: #d6d5e2; color: #2B295C; margin-top: 0; text-decoration: none; }
.pp-btn.secondary:hover { background: #f6f5fb; }
.pp-foot span { color: #8b8aa3; font-size: 11px; }

/* Pages & imports screens */
.page-cards { display: flex; flex-direction: column; }
.page-card { padding: 12px 0; border-bottom: 1px solid var(--border); }
.page-card .pc-top { display: flex; align-items: center; gap: 8px; }
.page-card .pc-top svg { width: 16px; height: 16px; color: var(--text-2); }
.page-card .pc-meta { margin-top: 2px; }
.page-card .pc-usage { font-size: 12.5px; color: var(--text-2); margin-top: 4px; }
.page-card .pc-actions { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.imp-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.imp-row .input[type=file] { padding: 6px 10px; }
.imp-list { display: flex; flex-direction: column; }
.imp-item { padding: 10px 0; border-bottom: 1px solid var(--border); }
.imp-errors { margin-top: 6px; font-size: 12px; }
.imp-errors summary { cursor: pointer; color: var(--warning); }
.imp-errors ul { margin: 6px 0 0; padding-left: 16px; color: var(--text-2); }
p.caption svg, .caption a svg { width: 12px; height: 12px; vertical-align: -2px; }

/* Platform admin: user rows */
.user-list { display: flex; flex-direction: column; }
.user-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.user-row.off { opacity: .55; }
.user-row .ur-main { flex: 1; min-width: 0; }
.user-row .ur-flags { display: flex; gap: 4px; }
.user-row .ur-last { white-space: nowrap; }
@container panel (max-width: 700px) { .user-row { flex-wrap: wrap; } .user-row .ur-last { order: 5; } }
.input.readonly { opacity: .6; pointer-events: none; }

/* Empty workspace (no company yet) */
.x-empty { position: absolute; inset: 0; display: grid; place-items: center; background: var(--bg); }
.x-empty-card { width: min(460px, calc(100% - 32px)); padding: 28px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.x-empty-card > svg { width: 28px; height: 28px; color: var(--text-3); }
.x-empty-card h2 { font: 600 18px/1.3 var(--font-sans); }
.x-empty-card p { color: var(--text-2); font-size: 13.5px; line-height: 1.5; }
.x-empty-card .btn { margin-top: 6px; }

.pp-head .pp-head-spacer { width: 32px; }

/* Admin-inspect events and scanner devices */
.timeline .t-dot.inspect, .xd-timeline .t-dot.inspect { background: var(--text-3); box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--text-3); }
.dev-list { display: flex; flex-direction: column; }
.dev-row { display: flex; align-items: center; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.dev-row.off { opacity: .55; }
.dev-row .dev-main { flex: 1; min-width: 0; }

/* ===== Header tabs: Map / Tags ===== */
.header .h-left { display: flex; align-items: center; gap: 18px; }
.h-nav { display: flex; gap: 4px; }
.h-nav a { padding: 7px 12px; border-radius: 8px; font: 500 14px/1 var(--font-sans); color: var(--text-2); text-decoration: none; }
.h-nav a:hover { color: var(--text); background: var(--bg-subtle); }
.h-nav a.on { color: var(--text); background: var(--bg-muted); }

/* ===== Tags mode: full-screen table over the (hidden) map, sheet still opens on the right ===== */
.tags-stage { display: none; }
.stage.tags-mode .map-stage { visibility: hidden; }
.stage.tags-mode .tags-stage { display: block; position: absolute; inset: 0; z-index: 600; overflow: auto; background: var(--bg); padding: 20px 24px 96px; }
.stage.tags-mode.sheet-open .tags-stage { right: 0; }
.tt { max-width: 1600px; margin: 0 auto; }
.tt-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.tt-title { display: flex; align-items: center; gap: 12px; }
.tt-title h1 { font: 600 24px/1.2 var(--font-sans); letter-spacing: -.01em; }
.tt-pill { padding: 4px 10px; border-radius: 999px; background: var(--bg-muted); color: var(--text-2); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.tt-tools { display: flex; align-items: center; gap: 8px; }
.tt-search { width: min(360px, 40vw); }
.tt-search .input { min-height: 40px; border-radius: 10px; background: var(--bg-subtle); border-color: transparent; }
.tt-more { width: 40px; height: 40px; min-height: 40px; border-radius: 50%; font-size: 18px; }
.tt-more-wrap, .tt-chip-wrap { position: relative; }
.tt-menu { top: calc(100% + 6px); left: 0; right: auto; min-width: 200px; max-height: 320px; overflow: auto; }
.tt-menu.right { left: auto; right: 0; }
.tt-menu.up { top: auto; bottom: calc(100% + 8px); }
.tt-menu button.active { color: var(--accent-text); }
.tt-filters { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding-bottom: 14px; }
.tt-chip { display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 0 10px 0 12px; border: 0; border-radius: 999px; background: var(--bg-subtle); color: var(--text-2); font: 400 13px/1 var(--font-sans); }
.tt-chip b { color: var(--text); font-weight: 500; }
.tt-chip svg { width: 13px; height: 13px; color: var(--text-3); }
.tt-chip:hover { background: var(--bg-muted); }
.tt-chip.on { background: var(--accent-soft); color: var(--text); }
.tt-chip.toggle.on.danger { background: rgba(255,90,54,.16); color: #ff8a70; }
.tt-chip.toggle svg { color: currentColor; }
.tt-count { margin-left: auto; color: var(--text-3); font-size: 13px; font-variant-numeric: tabular-nums; }
.tt-table-wrap { overflow-x: auto; }
.tt-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tt-table th { position: sticky; top: -20px; z-index: 1; background: var(--bg); text-align: left; font: 400 12.5px/1 var(--font-sans); color: var(--text-3); padding: 12px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.tt-table th.sortable { cursor: pointer; user-select: none; } .tt-table th.sortable:hover, .tt-table th.on { color: var(--text); }
.tt-table td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; max-width: 260px; }
.tt-table tbody tr { cursor: pointer; }
.tt-table tbody tr:hover td { background: var(--bg-subtle); }
.tt-table tbody tr.sel td { background: var(--accent-soft); }
.tt-table .c-check { width: 36px; } .tt-table input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); }
.tt-table .c-code { font: 500 13px/1.2 var(--font-mono); white-space: nowrap; color: var(--text); }
.tt-table .c-prod b { display: block; font-weight: 500; max-width: 280px; } .tt-table .c-prod span { display: block; color: var(--text-3); font-size: 12.5px; margin-top: 3px; }
.tt-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.tt-table .m-lbl { display: none; }
.tt-table .sub { display: block; color: var(--text-3); font-size: 12px; margin-top: 2px; }
.tt-table .faint { color: var(--text-3); }
.tt-status { display: inline-flex; align-items: center; padding: 4px 10px; border-radius: 999px; font: 500 12.5px/1 var(--font-sans); white-space: nowrap; }
.tt-status.original { background: rgba(57,217,138,.14); color: #39d98a; }
.tt-status.suspect { background: rgba(255,176,32,.16); color: #ffb020; }
.tt-status.counterfeit { background: rgba(255,90,54,.16); color: #ff7a5c; }
.tt-status.disabled { background: var(--bg-muted); color: var(--text-2); }
.tt-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); margin-right: 8px; vertical-align: 1px; }
.tt-dot.on { background: #39d98a; }
.tt-age { display: inline-flex; padding: 4px 10px; border-radius: 999px; background: var(--bg-subtle); color: var(--text-2); font-size: 12.5px; white-space: nowrap; }
.tt-empty { text-align: center; color: var(--text-3); padding: 40px 0 !important; cursor: default; }
.tt-foot { display: flex; align-items: center; justify-content: flex-end; gap: 12px; padding: 14px 0; color: var(--text-3); font-size: 13px; }
.tt-size { display: inline-flex; align-items: center; gap: 8px; } .tt-size .input { width: 72px; }
.tt-range { font-variant-numeric: tabular-nums; }
.tt-bar { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 700; display: flex; align-items: center; gap: 4px; padding: 6px 6px 6px 16px; border-radius: 14px; }
.tt-bar .tt-sel { margin-right: 8px; white-space: nowrap; font-size: 13.5px; } .tt-bar .tt-sel a { color: var(--accent-text); }
.tt-bar .btn.sm { min-height: 34px; padding: 0 12px; font-size: 13px; }
.tt-bar .btn:disabled { opacity: .45; }
:root[data-theme="light"] .tt-status.original { color: #1f8a4c; } :root[data-theme="light"] .tt-status.suspect { color: #b36a00; } :root[data-theme="light"] .tt-status.counterfeit { color: #c9352c; }
@media (max-width: 767px) { .h-nav a { padding: 6px 8px; font-size: 13px; } .stage.tags-mode .tags-stage { padding: 14px 12px 96px; } .tt-head { flex-wrap: wrap; } .tt-search { width: 100%; } .tt-tools { width: 100%; } .tt-bar { left: 12px; right: 12px; transform: none; overflow-x: auto; } }
/* Bulk action bar: solid surface so it reads over table rows */
.tt-bar { background: var(--surface-raised); border: 1px solid var(--border-strong); box-shadow: 0 14px 40px rgba(0,0,0,.55), 0 0 0 1px rgba(0,0,0,.2); backdrop-filter: none; -webkit-backdrop-filter: none; }
:root[data-theme="light"] .tt-bar { box-shadow: 0 14px 40px rgba(0,0,0,.16); }
.tt-bar .btn.ghost:hover { background: var(--bg-muted); }

/* ============================================================
   Phones: dashboard, sticker details and CRM pages are one bottom sheet
   (js/components/bottomsheet.js sets the height; drag or tap the grip)
   ============================================================ */
.bs-grip { display: none; }
@media (max-width: 767px) {
  .bs-grip { display: block; position: sticky; top: 0; z-index: 3; flex: none; height: 22px; margin: 0; cursor: grab; touch-action: none; background: inherit; border-radius: 16px 16px 0 0; }
  .bs-grip::before { content: ""; position: absolute; left: 50%; top: 8px; width: 38px; height: 4px; margin-left: -19px; border-radius: 2px; background: var(--border-strong); }
  .bs-grip:active { cursor: grabbing; }

  /* shared sheet frame */
  .map-stage .x-side, .map-stage .x-detail, .stage .sheet {
    top: auto !important; left: 0 !important; right: 0 !important; bottom: 0 !important; width: auto !important; max-height: none !important;
    border-radius: 16px 16px 0 0 !important; border: 1px solid var(--border) !important; border-bottom: 0 !important;
    background: var(--surface-raised) !important; backdrop-filter: none !important; -webkit-backdrop-filter: none !important;
    box-shadow: 0 -8px 32px rgba(0,0,0,.28) !important; z-index: 1001; /* above Leaflet controls (1000) */
  }
  .map-stage .x-side, .map-stage .x-detail { transition: height .24s cubic-bezier(.2,.8,.2,1); }
  /* dashboard panel: always present on phones (no hide button), hidden while details or a page cover it */
  .map-stage .x-side, .map-stage .x-side.hidden { display: flex; flex-direction: column; overflow: hidden; padding: 0; }
  .map-stage .x-side .lpanel { flex: 1 1 auto; min-height: 0; background: none; border: 0; border-radius: 0; box-shadow: none; backdrop-filter: none; -webkit-backdrop-filter: none; padding: 0 16px 24px; overscroll-behavior: contain; }
  .map-stage .x-side .legend-tabs { position: sticky; top: 0; z-index: 2; background: var(--surface-raised); padding: 2px 16px 10px; margin: 0 -16px 6px; width: calc(100% + 32px); }
  .map-stage .x-hide { display: none !important; }
  .map-stage.detail-open .x-side, .stage.sheet-open .map-stage .x-side { display: none; }

  /* sticker details replace the dashboard in the same place */
  .map-stage .x-detail { padding: 0 16px 24px; overflow: auto; overscroll-behavior: contain; }
  .map-stage .x-detail.hide { display: none; }
  .map-stage .x-detail .bs-grip { margin: 0 -16px; }
  .x-detail .xd-close { top: 18px; right: 12px; }

  /* CRM pages: slide up from the bottom instead of from the right */
  .stage .sheet { transform: translateY(calc(100% + 24px)); transition: transform .22s ease, height .24s cubic-bezier(.2,.8,.2,1); }
  .stage.sheet-open .sheet { transform: none; }
  .stage .sheet .sheet-close { top: 18px; right: 12px; }
  .stage .sheet .sheet-body { overscroll-behavior: contain; }
  .stage .sheet .content { padding-top: 6px; }

  /* map chrome above the sheet */
  .map-stage .leaflet-bottom { bottom: 0; }
  .map-stage .map-legend, .stickers-hint { display: none !important; }

  /* timelines: dot | text, time under the text; long device strings wrap instead of one word per line */
  .timeline li, .x-detail .xd-page .timeline li, .xd-timeline li { grid-template-columns: 12px minmax(0, 1fr); column-gap: 10px; row-gap: 2px; }
  .timeline li .t-dot { grid-column: 1; grid-row: 1; }
  .timeline li .t-body { grid-column: 2; grid-row: 1; min-width: 0; overflow-wrap: anywhere; }
  .timeline li .t-time { grid-column: 2; grid-row: 2; order: 0; }
}
.timeline .t-body { min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 767px) {
  .header { padding: 0 10px; column-gap: 6px; }
  .header .h-left { gap: 8px; min-width: 0; }
  .header .h-left .brand { margin-right: 0; }
  .header .h-right { gap: 0; }
  .h-nav a { padding: 6px 7px; }
}
@media (max-width: 380px) { .header .h-left .brand img, .header .h-left .brand svg { height: 20px; width: auto; } }

/* ---------- Tags table on phones: card rows, scrolling filter chips, menus as bottom lists ---------- */
.tt-mbar { display: none; }
@media (max-width: 767px) {
  .stage.tags-mode .tags-stage { padding: 12px 12px 110px; }
  .tt-head { gap: 10px; margin-bottom: 10px; }
  .tt-title h1 { font-size: 22px; }
  .tt-tools { flex-wrap: nowrap; }
  .tt-search { flex: 1; width: auto; }

  /* filters: one swipeable row */
  .tt-filters { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -12px; padding: 0 12px 10px; }
  .tt-filters::-webkit-scrollbar { display: none; }
  .tt-chip { white-space: nowrap; flex: none; }
  .tt-chip-wrap { flex: none; }
  .tt-filters .tt-count { display: none; }

  /* dropdowns become a list docked at the bottom (they would be clipped by the scrolling chip row) */
  .tt-chip-wrap .tt-menu, .tt-bar .tt-menu.up { position: fixed; top: auto; left: 8px; right: 8px; bottom: 8px; min-width: 0; max-height: 60vh; z-index: 1300; padding: 6px; border-radius: 14px; background: var(--surface-raised); border: 1px solid var(--border-strong); box-shadow: 0 -10px 40px rgba(0,0,0,.45); }
  .tt-chip-wrap .tt-menu button, .tt-bar .tt-menu button { min-height: 44px; font-size: 15px; }

  /* select-all + sort row */
  .tt-mbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 2px 0 6px; border-bottom: 1px solid var(--border); }
  .tt-mall { display: inline-flex; align-items: center; gap: 8px; color: var(--text-2); font-size: 13px; }
  .tt-mall input { width: 18px; height: 18px; accent-color: var(--accent); }
  .tt-mbar .tt-chip.on { background: var(--bg-subtle); }

  /* rows as cards:  [✓] code ............ status
                        product · series
                        • activation · N scans · city · age   (page is shown on the sticker itself) */
  .tt-table-wrap { overflow: visible; }
  .tt-table, .tt-table tbody { display: block; }
  .tt-table thead { display: none; }
  .tt-table tbody tr { position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 0; padding: 12px 4px 12px 40px; border-bottom: 1px solid var(--border); }
  .tt-table tbody tr.sk { display: block; padding: 10px 0; }
  .tt-table td { display: block; padding: 0; border: 0; max-width: none; background: none !important; }
  .tt-table tbody tr.sel { background: var(--accent-soft); }
  .tt-table .c-check { position: absolute; left: 0; top: 0; bottom: 0; width: 40px; display: flex; justify-content: center; padding-top: 13px; }
  .tt-table .c-check input { width: 18px; height: 18px; }
  .tt-table tbody tr[data-id]::before, .tt-table tbody tr[data-id]::after { content: ""; flex: 0 0 100%; height: 0; }
  .tt-table tbody tr[data-id]::before { order: 3; } .tt-table tbody tr[data-id]::after { order: 6; }
  .tt-table .c-code { order: 1; flex: 1 1 0; min-width: 0; font-size: 14px; overflow: hidden; text-overflow: ellipsis; }
  .tt-table .c-status { order: 2; margin-left: 8px; }
  .tt-table .c-status .tt-status { padding: 3px 9px; font-size: 12px; }
  .tt-table .c-prod { order: 4; flex: 1 1 60%; display: flex; gap: 6px; align-items: baseline; min-width: 0; }
  .tt-table .c-prod b { flex: 0 1 auto; min-width: 0; max-width: none; font-size: 13.5px; }
  .tt-table .c-prod span { display: none; } /* series = prefix of the sticker code */
  .tt-table .c-act, .tt-table .c-scans, .tt-table .c-loc { order: 7; font-size: 12.5px; color: var(--text-2); white-space: nowrap; text-align: left; }
  .tt-table .c-scans::before, .tt-table .c-loc::before { content: "·"; margin: 0 6px; color: var(--text-3); }
  .tt-table .c-act .sub { display: inline; margin: 0 0 0 4px; }
  .tt-table .c-age { order: 5; margin-left: 8px; }
  .tt-table .c-age .tt-age { padding: 0; background: none; font-size: 12px; color: var(--text-3); }
  .tt-table .c-loc { max-width: 45%; overflow: hidden; text-overflow: ellipsis; }
  .tt-table .c-page { display: none; }
  .tt-table .m-lbl { display: inline; color: var(--text-3); }

  /* footer + bulk bar */
  .tt-foot { justify-content: space-between; gap: 8px; }
  .tt-foot .tt-range { margin-left: auto; }
  .tt-bar { left: 8px; right: 8px; bottom: 12px; padding: 6px; gap: 2px; overflow-x: auto; scrollbar-width: none; flex-wrap: nowrap; }
  .tt-bar .tt-sel { margin: 0 4px 0 8px; font-size: 13px; }
  .tt-bar { overflow: visible; }
  .tt-bar .tt-sel { flex: 1; min-width: 0; white-space: normal; line-height: 1.3; font-size: 12.5px; }
  .tt-bar .btn.sm { flex: none; width: 40px; min-height: 40px; padding: 0; justify-content: center; }
  .tt-bar .btn.sm .lbl { display: none; }
  .tt-bar .tt-menu.up { bottom: 72px; }
}

/* ---------- Sticker page (CRM) ---------- */
.td-map { height: 320px; }
.kv dt:has(+ dd .vitrage) { align-self: stretch; display: flex; align-items: center; }
@media (max-width: 767px) {
  /* breadcrumbs repeat the title inside a sheet */
  .sheet .page-head .breadcrumb, .x-detail .page-head .breadcrumb { display: none; }
  .sheet .page-head h1, .x-detail .page-head h1 { font-size: 20px; overflow-wrap: anywhere; }
  .sheet .page-head .actions { flex-wrap: wrap; gap: 8px; }
  .sheet .page-head .actions .btn { min-height: 42px; }
  /* reference blocks first, then the map, then the (long) chronological log */
  .td-grid { display: flex; flex-direction: column; gap: 12px; }
  .td-grid > .stack { width: 100%; min-width: 0; align-self: stretch; }
  .td-grid > .stack:last-child { order: -1; }
  .td-map { height: 220px; }
  .td-map .map-legend { display: none; }
  .facts2 { padding: 12px; gap: 12px; }
  .sheet .kv { grid-template-columns: 100px minmax(0, 1fr); column-gap: 0; }
  .sheet .kv dt { padding-right: 12px; }
  .td-grid .card:not(.flat) { padding-left: 0; padding-right: 0; background: none; border: 0; box-shadow: none; }
  .sheet .kv dd { overflow-wrap: anywhere; }
  .sheet .notice { font-size: 13px; line-height: 1.45; }
}

/* ---------- Product modules (platform admin) ---------- */
.mod-head .tt-pill { white-space: nowrap; flex: none; }
.mod-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.mod-group { margin-bottom: 18px; }
.mod-group h3 { font: 500 12px/1.2 var(--font-sans); color: var(--text-3); text-transform: var(--caps); letter-spacing: var(--caps-spacing); margin: 0 0 6px; }
.mod-row { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--border); cursor: pointer; }
.mod-row.ro { cursor: default; }
.mod-ic { width: 32px; height: 32px; flex: none; display: grid; place-items: center; border-radius: 8px; background: var(--bg-subtle); color: var(--text-2); }
.mod-ic svg { width: 16px; height: 16px; }
.mod-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.mod-text b { font-weight: 500; font-size: 14px; }
.mod-text small { color: var(--text-3); font-size: 12.5px; line-height: 1.35; }
input.switch { appearance: none; -webkit-appearance: none; flex: none; width: 38px; height: 22px; border-radius: 999px; background: var(--border-strong); position: relative; cursor: pointer; transition: background .15s; margin: 0; }
input.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.3); transition: transform .15s; }
input.switch:checked { background: var(--accent); }
input.switch:checked::after { transform: translateX(16px); }
input.switch:disabled { cursor: default; opacity: .6; }
input.switch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
