/* Components added after the first redesign: calendar popover, ROI break-even meters,
   grade distribution and the action board. Same tokens and rules as design.css. */

:root {
  --grade-s: #4cc99b;
  --grade-a: #3a8f73;
  --grade-b: #7d818a;
  --grade-c: #ef9a5b;
  --grade-d: #f0736d;
  --near: #e9b44c;
}
:root[data-theme="light"] {
  --grade-s: #0c8460;
  --grade-a: #5aa88d;
  --grade-b: #9a9ca2;
  --grade-c: #c2621f;
  --grade-d: #cf3f3b;
  --near: #a86d14;
}

/* ---------- date button ---------- */
.date-btn { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-family: var(--font-num); white-space: nowrap; text-align: left; }
.date-btn svg { width: 15px; height: 15px; color: var(--text-3); }
.date-btn em { margin-left: 2px; padding: 1px 7px; color: var(--text-2); background: var(--neutral-soft); border-radius: 6px; font-style: normal; font-size: 12px; }
.date-btn[aria-expanded="true"] { border-color: var(--text-2); }
#liveDate + .date-btn, #dayDate + .date-btn { min-width: 132px; }

/* ---------- searchable select (combo.mjs) ---------- */
.combo-btn { display: inline-flex; align-items: center; gap: 6px; padding-right: 8px; cursor: pointer; font-family: var(--font-ui); text-align: left; }
.combo-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.combo-btn small, .combo-item small { margin-left: 6px; color: var(--text-3); font-size: 11px; font-weight: 400; }
.combo-btn svg { flex-shrink: 0; width: 16px; height: 16px; color: var(--text-3); transition: transform .18s; }
.combo-btn[aria-expanded="true"] { border-color: var(--text-2); }
.combo-btn[aria-expanded="true"] svg { transform: rotate(180deg); }
.combo { position: fixed; z-index: 46; display: flex; flex-direction: column; max-height: min(380px, 70vh); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 12px; box-shadow: var(--shadow-float); overflow: hidden; animation: pop-in .18s var(--out, ease-out); }
.combo-search { display: flex; align-items: center; gap: 8px; flex-shrink: 0; padding: 0 12px; border-bottom: 1px solid var(--line); color: var(--text-3); cursor: text; }
.combo-search svg { flex-shrink: 0; width: 16px; height: 16px; }
.combo-search input { flex: 1; min-width: 0; height: 40px; padding: 0; background: transparent; border: 0; color: var(--text); font-family: var(--font-ui); font-size: 14px; }
.combo-search input:focus { outline: none; }
.combo-search input::placeholder { color: var(--text-3); }
.combo-list { padding: 4px; overflow: auto; overscroll-behavior: contain; }
.combo-item { display: flex; align-items: center; gap: 4px; padding: 8px 10px; border-radius: 8px; color: var(--text); font-size: 13px; cursor: pointer; }
.combo-item .combo-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.combo-item i { display: flex; flex-shrink: 0; width: 16px; margin-left: 4px; color: var(--text-2); }
.combo-item i svg { width: 16px; height: 16px; }
.combo-item.on { background: var(--neutral-soft); }
.combo-item.sel { font-weight: 600; }
.combo-item mark { background: transparent; color: var(--paid); font-weight: 600; }
.combo-empty { padding: 18px 12px; color: var(--text-3); font-size: 13px; text-align: center; }

/* ---------- calendar popover ---------- */
.dp { position: fixed; z-index: 45; display: flex; padding: 10px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 14px; box-shadow: var(--shadow-float); animation: pop-in .2s var(--out, ease-out); }
.dp.hidden { display: none; }
.dp-presets { display: flex; flex-direction: column; gap: 2px; min-width: 92px; padding: 4px 8px 4px 2px; margin-right: 8px; border-right: 1px solid var(--line); }
.dp-preset { padding: 7px 10px; background: transparent; color: var(--text-2); border: 0; border-radius: 8px; font-size: 13px; text-align: left; white-space: nowrap; transition: background .15s, color .15s; }
.dp-preset:hover { background: var(--neutral-soft); color: var(--text); }
.dp-preset.on { background: var(--neutral-soft); color: var(--text); font-weight: 600; }
.dp-body { position: relative; }
.dp-nav { position: absolute; top: 0; left: 0; right: 0; display: flex; justify-content: space-between; pointer-events: none; }
.dp-nav .icon-btn { width: 30px; height: 30px; pointer-events: auto; }
.dp-months { display: flex; gap: 18px; }
.dp-month { width: 238px; }
.dp-title { height: 30px; line-height: 30px; text-align: center; font-size: 14px; font-weight: 600; font-family: var(--font-num); }
.dp-week, .dp-grid { display: grid; grid-template-columns: repeat(7, 34px); }
.dp-week { margin-top: 6px; color: var(--text-3); font-size: 12px; text-align: center; line-height: 28px; }
.dp-grid { row-gap: 2px; }
.dp-day { position: relative; height: 34px; padding: 0; background: transparent; color: var(--text); border: 0; border-radius: 9px; font-family: var(--font-num); font-size: 13px; font-variant-numeric: tabular-nums; transition: background .12s, color .12s; }
.dp-day:hover:not(:disabled) { background: var(--neutral-soft); }
.dp-day:disabled { color: var(--text-3); opacity: .45; cursor: default; }
.dp-day.today::after { content: ""; position: absolute; left: 50%; bottom: 5px; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: var(--good); }
.dp-day.sel, .dp-day.start, .dp-day.end { background: var(--invert); color: var(--on-invert); font-weight: 600; }
.dp-day.in:not(.start):not(.end) { background: var(--neutral-soft); border-radius: 0; }
.dp-day.in.start:not(.end) { border-radius: 9px 0 0 9px; }
.dp-day.in.end:not(.start) { border-radius: 0 9px 9px 0; }
.dp-hint { margin-top: 8px; color: var(--text-3); font-size: 12px; text-align: center; }
.dp-single .dp-presets { min-width: 72px; }

/* ---------- ROI break-even meter: a full bar is 1.0000 (break-even) ---------- */
.roi-cell { position: relative; white-space: nowrap; }
/* in tables the meter sits in the cell padding, so rows keep one height with or without it */
.roi-cell .roi-meter { position: absolute; right: var(--cell-x); bottom: calc(var(--row-y) * .38); margin: 0; }
td:last-child.roi-cell .roi-meter { right: var(--pad); }
.roi-meter { display: block; height: 3px; margin: 5px 0 0 auto; width: 64px; max-width: 100%; border-radius: 3px; background: var(--neutral-soft); overflow: hidden; }
.roi-meter i { display: block; height: 100%; width: var(--w); border-radius: inherit; background: var(--text-3); opacity: .7; transition: width .5s var(--out, ease-out); }
.roi-hi { color: var(--good); }
/* partial games: muted figures, dashed meter, one badge on the name instead of a tag per cell */
.roi-partial-cell { color: var(--text-2); }
.roi-partial-cell .roi-meter { background: repeating-linear-gradient(90deg, var(--neutral-soft) 0 4px, transparent 4px 7px); }
.roi-partial-cell .roi-meter i { background: var(--text-3); opacity: .55; }
.game-sub { display: flex; align-items: center; gap: 6px; color: var(--text-3); }
.partial-badge { padding: 0 6px; border-radius: 5px; background: var(--warn-soft); color: var(--warn); font-style: normal; font-size: 11px; line-height: 18px; }
.status-cell, .status-cell.warn { white-space: nowrap; max-width: none; }
.roi-lo { color: var(--grade-c); }
.roi-meter.hi i { background: var(--good); opacity: 1; }
.roi-meter.lo i { background: var(--grade-c); opacity: 1; }
.rows-in .roi-meter i { animation: meter-in .9s var(--out, ease-out) both; animation-delay: calc(var(--row-delay, 0ms) + 160ms); transform-origin: left center; }

/* ---------- live detail: larger type, richer cards ---------- */
@media (min-width: 761px) {
  .live-table { font-size: 14px; }
  .live-table thead th { font-size: 12.5px; }
}
.mobile-game-card { display: flex; flex-direction: column; gap: 12px; padding: 14px 16px; }
.mobile-game-card header { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.mobile-game-card h4 { margin: 0; font-size: 15px; }
.mobile-game-card .card-cost { flex-shrink: 0; font-family: var(--font-num); font-size: 20px; font-weight: 500; font-variant-numeric: tabular-nums; }
.mobile-game-card .card-cost small { margin-right: 2px; color: var(--text-3); font-size: 12px; font-weight: 400; }
.mobile-game-card .meter { margin-top: -4px; }
.mobile-compact-metrics { grid-template-columns: repeat(2, minmax(0,1fr)); }
.mobile-compact-metrics > div:last-child { text-align: left; }
.mobile-compact-metrics dd { font-size: 20px; }
.mobile-compact-metrics .roi-meter { margin-left: 0; width: 100%; }
.mobile-game-card .card-meta { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 0; padding-top: 10px; border-top: 1px solid var(--line); color: var(--text-3); font-size: 12px; }
.mobile-game-card .card-meta b { color: var(--text-2); font-family: var(--font-num); font-weight: 500; font-variant-numeric: tabular-nums; }
.mobile-game-card.good { border-color: rgba(76,201,155,.35); }
:root[data-theme="light"] .mobile-game-card.good { border-color: rgba(12,132,96,.3); }

/* ---------- compact revenue split: one line ---------- */
.split { display: grid; grid-template-columns: auto minmax(60px,1fr) auto; align-items: center; gap: 14px; padding: 11px var(--pad); }
.split .split-track { height: 6px; }
.split-side { display: inline-flex; align-items: baseline; gap: 7px; color: var(--text-2); font-size: 13px; white-space: nowrap; }
.split-side .dot { align-self: center; }
.split-side b { color: var(--text); font-family: var(--font-num); font-weight: 500; font-variant-numeric: tabular-nums; }
.split-side em { color: var(--text-3); font-family: var(--font-num); font-style: normal; font-size: 12px; }

/* ---------- rating page ---------- */
.rating-top { display: grid; grid-template-columns: minmax(300px, 380px) minmax(0,1fr); gap: var(--gap); }
.grade-card { display: flex; flex-direction: column; }
.grade-total { display: flex; align-items: baseline; gap: 6px; margin: 2px 0 14px; }
.grade-total b { font-family: var(--font-num); font-size: 34px; font-weight: 500; line-height: 1; }
.grade-total span { color: var(--text-3); font-size: 13px; }
.grade-bar { display: flex; gap: 3px; height: 10px; border-radius: 6px; overflow: hidden; }
.grade-bar i { display: block; min-width: 3px; transform-origin: left center; animation: meter-in .9s var(--out, ease-out) both; }
.grade-list { display: flex; flex-direction: column; gap: 2px; margin: 14px -8px 0; }
.grade-row { display: grid; grid-template-columns: 30px minmax(0,1fr) auto auto; align-items: center; gap: 10px; width: 100%; padding: 8px; background: transparent; color: var(--text); border: 0; border-radius: 9px; text-align: left; font-size: 13px; transition: background .15s, opacity .15s; }
.grade-row:hover { background: var(--neutral-soft); }
.grade-row.on { background: var(--neutral-soft); }
.grade-list.filtered .grade-row:not(.on) { opacity: .45; }
.grade-row .grade { margin: 0; }
.grade-row .what { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grade-row .what small { margin-left: 6px; color: var(--text-3); font-family: var(--font-num); font-size: 12px; }
.grade-row .n { font-family: var(--font-num); font-variant-numeric: tabular-nums; }
.grade-row .share { min-width: 46px; color: var(--text-3); font-family: var(--font-num); font-size: 12px; text-align: right; }
.grade-row:disabled { opacity: .35; cursor: default; }
.grade-foot { margin-top: auto; padding-top: 14px; color: var(--text-3); font-size: 12px; line-height: 1.7; }
.grade.S, .grade-bar .S { background: var(--grade-s); color: var(--surface); }
.grade.A { background: rgba(76,201,155,.16); color: var(--grade-s); }
.grade-bar .A { background: var(--grade-a); }
.grade.B, .grade-bar .B { background: var(--neutral-soft); color: var(--text-2); }
.grade-bar .B { background: var(--grade-b); }
.grade.C { background: rgba(239,154,91,.16); color: var(--grade-c); }
.grade-bar .C { background: var(--grade-c); }
.grade.D { background: var(--bad-soft); color: var(--grade-d); }
.grade-bar .D { background: var(--grade-d); }
:root[data-theme="light"] .grade.A { background: rgba(12,132,96,.1); }
:root[data-theme="light"] .grade.C { background: rgba(194,98,31,.1); }
.quad-card .chart { height: calc(var(--chart-h) + 90px); }

.actions { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.action-col h3 .count { margin-left: 0; }
.action-col .filter-note { margin-left: auto; color: var(--text-3); font-size: 12px; font-weight: 400; }
.action-item { grid-template-columns: auto minmax(0,1fr) auto; grid-template-rows: auto auto; align-items: center; gap: 3px 10px; padding: 10px 8px; }
.action-item .grade { grid-row: 1 / 3; margin: 0; }
.action-item .name { grid-column: 2; color: var(--text); }
.action-item .verdict { grid-column: 3; justify-self: end; padding: 2px 8px; border-radius: 6px; background: var(--neutral-soft); color: var(--text-2); font-size: 12px; }
.action-col.good .verdict { background: var(--good-soft); color: var(--good); }
.action-col.bad .verdict { background: var(--bad-soft); color: var(--bad); }
.action-col.warn .verdict { background: var(--warn-soft); color: var(--warn); }
.action-item .meta { grid-column: 2; display: flex; gap: 10px; flex-wrap: wrap; }
.action-item .spark { grid-column: 3; grid-row: 2; justify-self: end; width: 64px; height: 18px; }
.action-item .reason { grid-column: 2 / 4; color: var(--text-2); font-size: 12px; line-height: 1.5; }
.action-item { grid-template-rows: auto auto auto; }
.modal-reason { flex-basis: 100%; color: var(--text-2); }
.action-more-btn { margin-top: 6px; padding: 6px 8px; background: none; border: 0; color: var(--text-2); font-size: 12px; text-decoration: underline; text-underline-offset: 3px; }
.action-more-btn:hover { color: var(--text); }

/* ---------- medium widths ---------- */
@media (max-width: 1100px) {
  .rating-top { grid-template-columns: minmax(0,1fr); }
  .grade-card .grade-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px,1fr)); }
  .actions { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
}

/* ---------- phones ---------- */
@media (max-width: 760px) {
  /* At the top, so the on-screen keyboard does not cover the results; height follows the visible area. */
  .combo { left: 8px; right: 8px; top: calc(env(safe-area-inset-top) + 8px); bottom: auto; width: auto; border-radius: 14px; }
  .combo-search input { height: 48px; font-size: 16px; }
  .combo-item { padding: 11px 12px; font-size: 15px; }
  .dp { left: 0; right: 0; bottom: 0; top: auto; flex-direction: column; padding: 14px 14px calc(14px + env(safe-area-inset-bottom)); border-radius: 18px 18px 0 0; animation: sheet-up .26s var(--out, ease-out); }
  @keyframes sheet-up { from { transform: translateY(40px); opacity: .4; } }
  .dp-presets { flex-direction: row; flex-wrap: wrap; gap: 6px; margin: 0 0 10px; padding: 0 0 10px; border-right: 0; border-bottom: 1px solid var(--line); }
  .dp-preset { padding: 6px 11px; background: var(--neutral-soft); }
  .dp-months { justify-content: center; }
  .dp-month { width: 100%; }
  .dp-week, .dp-grid { grid-template-columns: repeat(7, minmax(0,1fr)); }
  .dp-day { height: 40px; font-size: 15px; }
  .date-btn { flex: 1; justify-content: flex-start; }
  .date-range-btn { flex: 1 1 100%; }
  .split { grid-template-columns: 1fr 1fr; gap: 8px 12px; }
  .split .split-track { grid-column: 1 / -1; grid-row: 1; }
  .split-side.organic { justify-content: flex-end; }
  .split-side { font-size: 12px; }
  .grade-total b { font-size: 28px; }
}

/* the day table carries 14 columns; tighter cells keep it on one screen at 1440px */
@media (min-width: 761px) { #dayTable { --cell-x: 9px; } }

/* ---------- network activity: a thin line along the top while a request is slow ---------- */
.netbar { position: fixed; top: 0; left: 0; right: 0; z-index: 80; height: 2px; pointer-events: none; opacity: 0; transition: opacity .25s; overflow: hidden; }
.netbar.on { opacity: 1; }
.netbar::before { content: ""; position: absolute; top: 0; bottom: 0; left: -40%; width: 40%; background: linear-gradient(90deg, transparent, var(--paid), transparent); animation: netbar 1.1s ease-in-out infinite; }
@keyframes netbar { to { left: 100%; } }
:root[data-motion="off"] .netbar::before { left: 0; width: 100%; animation: none !important; opacity: .6; }

/* ---- alerts, badges, grade changes ---- */
.data-alerts { display: grid; gap: 8px; margin-bottom: 14px; }
.data-alerts:empty, body[data-tab="live"] .data-alerts, body[data-tab="day"] .data-alerts { display: none; }
.data-alerts .notice { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; }
.data-alerts .notice .btn { margin-left: auto; }
.data-alerts .link-btn { color: inherit; text-decoration: underline; }
.mini-badge { display: inline-block; margin-left: 6px; padding: 0 5px; border-radius: 5px; background: var(--neutral-soft); color: var(--text-2); font-style: normal; font-size: 11px; font-weight: 500; line-height: 17px; vertical-align: 1px; white-space: nowrap; }
.mini-badge.new { background: var(--good-soft); color: var(--good); }
.mini-badge.up { background: var(--good-soft); color: var(--good); }
.mini-badge.down, .mini-badge.warn { background: var(--bad-soft); color: var(--bad); }
.mini-badge.pin { background: var(--warn-soft); color: var(--warn); }
.action-item .reason.note { color: var(--text-3); }
.change-card { margin-bottom: 14px; }
.change-list { display: flex; flex-wrap: wrap; gap: 8px; }
.change-chip { display: inline-flex; align-items: center; gap: 5px; height: 30px; padding: 0 10px 0 7px; background: var(--neutral-soft); border: 0; border-radius: 8px; color: var(--text); font-size: 13px; transition: background .15s, transform .15s; }
.change-chip:hover { background: var(--surface-3); }
.change-chip .grade { margin: 0; }
.change-chip b { color: var(--text-3); font-weight: 400; }
.change-chip.up b { color: var(--good); }
.change-chip.down b { color: var(--bad); }

/* ---- notes in the game drawer ---- */
.modal-notes { display: grid; gap: 8px; margin-top: 18px; }
.modal-notes h4 { font-size: 13px; font-weight: 600; color: var(--text-2); }
.modal-notes .note-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 16px; }
.modal-notes textarea.field { height: auto; min-height: 60px; padding: 8px 10px; resize: vertical; font-family: var(--font-ui); line-height: 1.5; }
.chk { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); font-size: 13px; cursor: pointer; }
.chk input { width: 15px; height: 15px; accent-color: var(--good); }

/* ---- rules dialog ---- */
.rules-card fieldset { margin: 0 0 14px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; }
.rules-card legend { padding: 0 6px; color: var(--text-2); font-size: 13px; font-weight: 600; }
.rules-card label { display: grid; gap: 4px; color: var(--text-2); font-size: 12px; }
.rules-card input[type="number"] { height: 34px; padding: 0 10px; background: var(--surface-2); color: var(--text); border: 1px solid var(--line-strong); border-radius: 8px; font-family: var(--font-num); font-size: 14px; }
.rules-card input[type="number"]:focus { outline: none; border-color: var(--text-2); }
.rules-card .grid2, .rules-card .grid3, .rules-card .grid4 { display: grid; gap: 10px 12px; }
.rules-card .grid2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.rules-card .grid3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.rules-card .grid4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.rules-card .hint { margin: 8px 0 0; color: var(--text-3); font-size: 12px; line-height: 1.55; }
.rules-foot { display: flex; align-items: center; justify-content: space-between; }

/* ---- pull to refresh ---- */
.ptr { position: fixed; top: calc(env(safe-area-inset-top) + 6px); left: 50%; z-index: 60; padding: 6px 14px; background: var(--surface-3); color: var(--text-2); border-radius: 999px; font-size: 12px; opacity: 0; transform: translate(-50%, -40px); pointer-events: none; transition: opacity .12s; }
.ptr.show { opacity: 1; }
@media (max-width: 760px) {
  .rules-card .grid4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rules-card .grid3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .change-chip { height: 32px; }
}

/* ---- rules dialog and tables on narrow screens ---- */
.rules-card { overflow-x: hidden; }
.rules-card fieldset { min-width: 0; }
.rules-card label { min-width: 0; grid-template-rows: 1fr auto; align-items: end; }
.rules-card input[type="number"] { width: 100%; min-width: 0; box-sizing: border-box; }

/* ---- add game ---- */
.add-game-card input[type="text"], .add-game-card input[type="password"], .add-game-card textarea {
  width: 100%; min-width: 0; box-sizing: border-box; padding: 0 10px; background: var(--surface-2); color: var(--text);
  border: 1px solid var(--line-strong); border-radius: 8px; font-size: 14px; transition: border-color .15s;
}
.add-game-card input[type="text"], .add-game-card input[type="password"] { height: 36px; }
.add-game-card input[name="wxid"], .add-game-card input[name="secret"], .add-game-card textarea { font-family: var(--font-num); letter-spacing: .02em; }
.add-game-card textarea { padding: 8px 10px; line-height: 1.5; resize: vertical; }
.add-game-card input:focus, .add-game-card textarea:focus { outline: none; border-color: var(--text-2); }
.add-game-card input[aria-invalid="true"] { border-color: var(--bad); }
.add-game-card ::placeholder { color: var(--text-3); }
.add-game-card fieldset > label + .hint { margin-bottom: 12px; }
.add-game-card .seg { display: flex; }
.add-game-card .seg button { flex: 1; }
.form-error { margin: 0 0 14px; padding: 9px 12px; color: var(--bad); background: var(--bad-soft); border-radius: 9px; font-size: 13px; line-height: 1.55; }

/* ---- manage games ---- */
/* Forms opened from the manage panel or the game detail stay above them. */
#addGame, #delGame, #adsToken { z-index: 55; }
.modal-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.manage-card { width: min(720px, 100%); }
.manage-bar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.manage-tools { display: flex; align-items: center; gap: 8px; flex: 1 1 260px; justify-content: flex-end; min-width: 0; }
.manage-tools .field { flex: 1 1 auto; width: 200px; max-width: 260px; height: 30px; font-family: var(--font-ui); }
.manage-list { display: grid; gap: 8px; }
.manage-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 6px 14px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); transition: border-color .15s, background .15s; }
.manage-row:hover { border-color: var(--line-strong); }
.manage-row .mr-name { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 14px; font-weight: 600; }
.manage-row .mr-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.manage-row .mr-meta { grid-column: 1; display: flex; flex-wrap: wrap; gap: 2px 14px; color: var(--text-3); font-size: 12px; }
.manage-row .mr-meta code { color: var(--text-2); font-family: var(--font-num); letter-spacing: .02em; }
.manage-row .mr-meta .warn { color: var(--warn); }
.manage-row .mr-actions { grid-column: 2; grid-row: 1 / span 2; display: flex; gap: 6px; }
.manage-row .mr-actions svg { width: 14px; height: 14px; }
.btn.danger-ghost { color: var(--bad); }
.btn.danger-ghost:hover:not(:disabled) { background: var(--bad-soft); border-color: var(--bad); }
.manage-note { margin: 0 0 12px; padding: 9px 12px; color: var(--text-2); background: var(--neutral-soft); border-radius: 9px; font-size: 12px; line-height: 1.6; }
.manage-log { display: grid; gap: 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.manage-log > div { display: grid; grid-template-columns: 96px 52px minmax(0, 1fr); gap: 10px; align-items: baseline; padding: 9px 14px; font-size: 13px; border-top: 1px solid var(--line); }
.manage-log > div:first-child { border-top: 0; }
.manage-log time { color: var(--text-3); font-family: var(--font-num); font-size: 12px; }
.manage-log .act { font-size: 12px; font-weight: 600; }
.manage-log .act.delete { color: var(--bad); }
.manage-log .act.restore, .manage-log .act.add { color: var(--good); }
.manage-log .what { min-width: 0; overflow-wrap: anywhere; color: var(--text-2); }
.manage-log .what b { color: var(--text); font-weight: 500; }
.manage-bar .seg button { min-width: 0; }
.add-game-card input[readonly] { color: var(--text-2); background: var(--neutral-soft); cursor: default; }
.add-game-card .hint.rename { color: var(--warn); }

/* ---- delete confirmation ---- */
.btn.danger { background: var(--bad); color: #fff; border-color: transparent; font-weight: 600; }
.btn.danger:hover:not(:disabled) { background: var(--bad); opacity: .88; }
.btn.danger:disabled { opacity: .35; }
.danger-head { display: flex; align-items: center; gap: 12px; min-width: 0; }
.danger-icon { display: grid; place-items: center; flex-shrink: 0; width: 38px; height: 38px; color: var(--bad); background: var(--bad-soft); border-radius: 11px; }
.danger-icon svg { width: 20px; height: 20px; }
.danger-list { margin: 0 0 16px; padding: 12px 14px 12px 30px; color: var(--text-2); background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; font-size: 13px; line-height: 1.75; }
.danger-list b { color: var(--text); font-weight: 600; }
.confirm-label { display: grid; gap: 6px; margin-bottom: 12px; color: var(--text-2); font-size: 13px; }
.confirm-name { padding: 1px 6px; color: var(--text); background: var(--bad-soft); border-radius: 5px; font-weight: 600; overflow-wrap: anywhere; -webkit-user-select: all; user-select: all; }
.confirm-label input { width: 100%; min-width: 0; height: 38px; box-sizing: border-box; padding: 0 11px; background: var(--surface-2); color: var(--text); border: 1px solid var(--line-strong); border-radius: 9px; font-size: 14px; transition: border-color .15s; }
.confirm-label input:focus { outline: none; border-color: var(--text-2); }
.confirm-label input.match { border-color: var(--bad); }
.confirm-card .rules-foot { margin-top: 4px; }
/* ---- ad account token ---- */
.key-icon { color: var(--text); background: var(--neutral-soft); }
.token-steps { margin-bottom: 14px; list-style: decimal; }
.token-steps li { display: list-item; padding-left: 2px; }
.token-steps li::marker { color: var(--text-3); font-family: var(--font-num); }
.token-card select { width: 100%; min-width: 0; height: 38px; box-sizing: border-box; padding: 0 10px; background: var(--surface-2); color: var(--text); border: 1px solid var(--line-strong); border-radius: 9px; font-size: 14px; font-family: var(--font-num); }
.token-card select:focus { outline: none; border-color: var(--text-2); }
.token-card input { font-family: var(--font-num); letter-spacing: .02em; }
.token-card input[aria-invalid="true"] { border-color: var(--bad); }
.inline-link { display: inline; padding: 0; height: auto; color: var(--warn); font: inherit; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.token-note { margin: -2px 0 14px; color: var(--text-3); font-size: 12px; line-height: 1.6; }
.manage-row .mr-meta .pending-ids { color: var(--warn); font-family: var(--font-num); }
.btn.small.attention { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
@media (min-width: 761px) {
  .modal.center { justify-content: center; align-items: center; padding: 16px; }
  .confirm-card { width: min(460px, 100%); height: auto; max-height: calc(100vh - 32px); border: 1px solid var(--line-strong); border-radius: 16px; animation-name: pop; }
}
@media (max-width: 760px) {
  .manage-tools { flex-basis: 100%; }
  .manage-tools .field { max-width: none; width: auto; }
  .manage-row { grid-template-columns: minmax(0, 1fr); }
  .manage-row .mr-actions { grid-column: 1; grid-row: auto; }
  .manage-log > div { grid-template-columns: 82px minmax(0, 1fr); }
  .manage-log .what { grid-column: 1 / -1; }
}

/* ---- behaviour (ESTrack) ---- */
.b-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: var(--gap); align-items: start; }
.b-grid.wide-left { grid-template-columns: minmax(0, 1.8fr) minmax(0, 1fr); }
.b-table td, .b-table th { white-space: nowrap; }
.b-table .ev-id { display: block; color: var(--text-3); font-family: var(--font-num); font-size: 11px; letter-spacing: .02em; }
.b-table .ev-name { font-weight: 500; }
.b-heat { border-radius: 6px; padding: 2px 6px; }
#bRetention th:not(:first-child), #bRetention td:not(:first-child) { padding-left: 4px; padding-right: 4px; }
#bRetention th:last-child, #bRetention td:last-child { padding-right: var(--pad); }
.b-tag { display: inline-block; padding: 1px 7px; border-radius: 999px; font-size: 11px; line-height: 18px; background: var(--neutral-soft); color: var(--text-2); }
.b-tag.ok { background: var(--good-soft); color: var(--good); }
.b-tag.warn { background: var(--warn-soft); color: var(--warn); }
.b-tag.off { background: var(--bad-soft); color: var(--bad); }
.b-tag.sys { background: transparent; border: 1px solid var(--line-strong); color: var(--text-3); }

.b-check { padding-top: 14px; padding-bottom: 14px; }
.b-check-head { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 14px; font-size: 13px; color: var(--text-2); }
.b-check-head b { color: var(--text); font-weight: 600; }
.b-check-head .link-btn { margin-left: auto; }
.b-steps { display: grid; gap: 6px; margin: 12px 0 0; padding: 0; list-style: none; counter-reset: s; font-size: 13px; line-height: 1.6; color: var(--text-2); }
.b-steps li { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 8px; counter-increment: s; }
.b-steps li::before { content: counter(s); display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--neutral-soft); color: var(--text-2); font-size: 11px; font-family: var(--font-num); }
.b-steps code, .b-check code { padding: 0 4px; border-radius: 4px; background: var(--neutral-soft); color: var(--text); font-family: var(--font-num); font-size: 12px; }
.b-live { display: grid; gap: 0; margin-top: 12px; max-height: 260px; overflow: auto; border: 1px solid var(--line); border-radius: 10px; }
.b-live > div { display: grid; grid-template-columns: 64px 54px minmax(0, 180px) minmax(0, 1fr); gap: 10px; align-items: baseline; padding: 6px 12px; border-top: 1px solid var(--line); font-size: 12px; }
.b-live > div:first-child { border-top: 0; }
.b-live time, .b-live .p { color: var(--text-3); font-family: var(--font-num); }
.b-live .e { font-family: var(--font-num); color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.b-live .p { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.b-funnel { display: grid; gap: 4px; }
.b-step { display: grid; grid-template-columns: minmax(0, 220px) minmax(0, 1fr) 76px 64px; align-items: center; gap: 12px; padding: 7px 0; font-size: 13px; }
.b-step .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.b-step .lbl small { display: block; color: var(--text-3); font-family: var(--font-num); font-size: 11px; }
.b-step .bar { position: relative; height: 22px; border-radius: 6px; background: var(--neutral-soft); overflow: hidden; }
.b-step .bar i { position: absolute; inset: 0 auto 0 0; width: var(--w); border-radius: 6px; background: linear-gradient(90deg, var(--paid), var(--organic)); opacity: .85; transform-origin: left; animation: b-grow .7s cubic-bezier(.2, .8, .2, 1) both; animation-delay: var(--d, 0s); }
:root[data-motion="off"] .b-step .bar i { animation: none; }
@keyframes b-grow { from { transform: scaleX(0); } }
.b-step .n { text-align: right; font-family: var(--font-num); font-variant-numeric: tabular-nums; }
.b-step .r { text-align: right; font-family: var(--font-num); font-size: 12px; color: var(--text-2); }
.b-step .r.drop { color: var(--bad); }
.b-funnel-editor { display: grid; gap: 8px; margin-bottom: 14px; padding: 12px; border: 1px dashed var(--line-strong); border-radius: 12px; }
.b-fe-row { display: grid; grid-template-columns: 22px minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, 1fr) auto; gap: 8px; align-items: center; font-size: 12px; }
.b-fe-row .field { width: 100%; min-width: 0; height: 30px; }
.b-fe-foot { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; align-items: center; }
.b-fe-foot .hint { margin: 0 auto 0 0; }
.b-bd-tools .field { width: auto; max-width: 220px; height: 30px; }
.b-presets { display: flex; gap: 6px; flex-wrap: wrap; }
.b-share { position: relative; display: inline-block; width: 90px; height: 6px; margin-right: 8px; vertical-align: middle; border-radius: 3px; background: var(--neutral-soft); overflow: hidden; }
.b-share i { position: absolute; inset: 0 auto 0 0; width: var(--w); background: var(--organic); border-radius: 3px; }

.ev-card { width: min(780px, 100%); }
.ev-body { display: grid; gap: 10px; }
.ev-drop { display: grid; place-items: center; gap: 6px; padding: 18px; border: 1.5px dashed var(--line-strong); border-radius: 12px; color: var(--text-2); font-size: 13px; text-align: center; transition: border-color .15s, background .15s; }
.ev-drop.over { border-color: var(--good); background: var(--good-soft); }
.ev-drop code { font-family: var(--font-num); }
.ev-body textarea { width: 100%; min-height: 150px; box-sizing: border-box; padding: 10px 12px; background: var(--surface-2); color: var(--text); border: 1px solid var(--line-strong); border-radius: 10px; font: 12px/1.6 var(--font-num); resize: vertical; }
.ev-plan { display: grid; gap: 8px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; font-size: 13px; }
.ev-plan h4 { margin: 0; font-size: 13px; font-weight: 600; }
.ev-plan ul { margin: 0; padding-left: 18px; color: var(--text-2); max-height: 140px; overflow: auto; font-size: 12px; line-height: 1.7; }
.ev-plan .del h4 { color: var(--bad); }
.ev-row { display: grid; grid-template-columns: 20px minmax(0, 200px) minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 6px 4px; border-top: 1px solid var(--line); font-size: 13px; }
.ev-row:first-child { border-top: 0; }
.ev-row code { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--font-num); font-size: 12px; color: var(--text-2); }
.ev-row input[type="text"] { width: 100%; min-width: 0; height: 30px; box-sizing: border-box; padding: 0 9px; background: var(--surface-2); color: var(--text); border: 1px solid var(--line); border-radius: 8px; font-size: 13px; }
.ev-row input[type="text"]:focus { outline: none; border-color: var(--text-2); }
.ev-list { border: 1px solid var(--line); border-radius: 12px; padding: 4px 10px; max-height: 52vh; overflow: auto; }
.ev-foot { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: flex-end; }
.ev-foot .hint { margin: 0 auto 0 0; }

@media (max-width: 900px) {
  .b-grid, .b-grid.wide-left { grid-template-columns: minmax(0, 1fr); }
  .b-step { grid-template-columns: minmax(0, 1fr) 64px 54px; }
  .b-step .bar { grid-column: 1 / -1; grid-row: 2; height: 16px; }
  .b-fe-row { grid-template-columns: 22px minmax(0, 1fr) auto; }
  .b-fe-row .field.where { grid-column: 2 / 3; }
  .b-live > div { grid-template-columns: 56px minmax(0, 1fr); }
  .b-live .p { grid-column: 1 / -1; }
  .ev-row { grid-template-columns: 20px minmax(0, 1fr) auto; }
  .ev-row input[type="text"] { grid-column: 2 / -1; }
}
