/* ═══════════════════════════════════════════════════════════════════════════
   CargoX Relayer — Dashboard-specific Styles
   Requires: shared.css (provides variables, reset, base buttons, modals, forms)
   Activate with: <body class="theme-dashboard">
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Top navbar (dashboard variant — uses .top-nav, not shared nav) ── */
.top-nav { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; padding: 10px 24px; gap: 8px;
  border-bottom: 1px solid var(--border); background: var(--surface); position: sticky; top: 0; z-index: 100; }
.top-nav a { color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 500; transition: color .15s; }
.top-nav a:hover, .top-nav a.active { color: var(--blue); }

/* ── Control bar (below navbar) ── */
.control-bar { background: var(--surface); border-bottom: 1px solid var(--border); padding: 8px 20px;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.control-bar .stats-group { display: flex; gap: 8px; flex-wrap: wrap; flex: 1; }
.stat-pill { display: flex; align-items: center; gap: 5px; background: var(--surface2);
  border: 1px solid var(--border); border-radius: 20px; padding: 3px 10px; font-size: 11px; }
.stat-pill .label { color: var(--muted); }
.stat-pill .value { font-weight: 600; }
.ws-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--red); transition: background .3s; flex-shrink:0; }
.ws-dot.connected { background: var(--green); }
.control-bar .actions-group { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

/* ── Global settings panel ── */
.global-panel { background: var(--surface2); border-bottom: 1px solid var(--border); padding: 8px 20px;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.global-panel .gp-label { font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; margin-right: 4px; }

/* ── Login overlay ── */
#login-overlay { position: fixed; inset: 0; background: var(--bg);
  display: flex; align-items: center; justify-content: center; z-index: 999;
  background: radial-gradient(ellipse at 50% 0%, #1e3a5f 0%, var(--bg) 70%); }
#login-overlay.hidden { display: none; }
/* Pre-paint guard: an inline <head> script tags <html> with .is-authed
   when localStorage has a valid (non-expired) JWT, which makes this rule
   match BEFORE the body parses. Eliminates the "login flash" we used to
   see on every dashboard navigation while waiting for JS to toggle .hidden. */
html.is-authed #login-overlay { display: none; }
.login-wrap { display: flex; gap: 40px; align-items: center; max-width: 900px; padding: 24px; }
.login-box { background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  padding: 36px; width: 380px; display: flex; flex-direction: column; gap: 14px; flex-shrink: 0; }
.login-box h2 { font-size: 20px; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.login-box h2 img { width: 36px; height: 36px; border-radius: 10px; }
.login-tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.login-tab { flex: 1; padding: 8px 0; text-align: center; font-size: 13px; font-weight: 600;
  color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; transition: all .2s; }
.login-tab.active { color: var(--blue); border-bottom-color: var(--blue); }
.login-tab:hover { color: var(--text); }
.login-form { display: flex; flex-direction: column; gap: 12px; }
.login-form.hidden { display: none; }
.login-preview { flex: 1; min-width: 0; }
.login-preview img { width: 100%; border-radius: 12px; border: 1px solid var(--border);
  box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.login-preview p { color: var(--muted); font-size: 13px; margin-top: 12px; text-align: center; }
.login-back { color: var(--muted); font-size: 13px; text-decoration: none; text-align: center; display: block; margin-top: 4px; }
.login-back:hover { color: var(--blue); }
/* Scroll hint — mobile only */
.role-scroll-hint { display: none; }

@media (max-width: 768px) {
  #login-overlay { align-items: flex-start; overflow-y: auto; -webkit-overflow-scrolling: touch; }
  .login-wrap { flex-direction: column; align-items: stretch; padding: 16px; padding-top: 24px; padding-bottom: 40px; }
  .login-preview { order: 2; margin-top: 16px; }
  .login-preview img { display: none; }
  .login-box { width: 100%; max-width: 100%; padding: 20px; }
  .role-scroll-hint { display: block; text-align: center; font-size: 12px; color: var(--accent);
    text-decoration: none; margin-top: 6px; animation: scrollBounce 2s infinite; }
  @keyframes scrollBounce { 0%,100% { transform: translateY(0); } 50% { transform: translateY(4px); } }
}

/* ── Dashboard body font-size override ── */
body.theme-dashboard { font-size: 14px; }

/* ── Dashboard form extras ── */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }

/* ── Toggle switch ── */
.toggle-wrap { display: flex; align-items: center; gap: 8px; }
.toggle { position: relative; width: 36px; height: 20px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; inset: 0; background: var(--surface2); border: 1px solid var(--border);
  border-radius: 10px; cursor: pointer; transition: .2s; }
.toggle input:checked + .toggle-slider { background: var(--green); border-color: var(--green); }
.toggle-slider:before { content: ''; position: absolute; width: 14px; height: 14px; left: 2px; top: 2px;
  background: #fff; border-radius: 50%; transition: .2s; }
.toggle input:checked + .toggle-slider:before { transform: translateX(16px); }

/* (Chart section CSS removed 2026-05-19 — Document Activity chart deleted) */

/* ── Grid ── */
main { padding: 14px 20px; }
#relayer-grid { display: flex; flex-direction: column; gap: 0; }

/* ── View toggle (Card ↔ Table, admin only) ── */
.view-toggle { display: inline-flex; background: var(--surface2); border: 1px solid var(--border); border-radius: 6px; padding: 2px; gap: 1px; }
.vt-btn { background: transparent; border: 0; color: var(--muted); font-size: 11px; font-weight: 600; padding: 4px 10px; border-radius: 4px; cursor: pointer; }
.vt-btn:hover:not(.active) { color: var(--text); }
.vt-btn.active { background: var(--accent); color: #fff; }

/* ── Issues only filter ── */
.issues-only { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); cursor: pointer; padding: 4px 8px; }
.issues-only input { cursor: pointer; }
.issues-only:hover { color: var(--text); }

/* ── Compact dashboard table (admin) ── */
#dashboard-table-wrap { padding: 0 8px; margin-top: 8px; }
.dashboard-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.dashboard-table thead th {
  padding: 8px 10px; font-size: 10px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--border);
  cursor: pointer; user-select: none; white-space: nowrap; background: var(--bg);
  position: sticky; top: 0; z-index: 5;
}
.dashboard-table thead th:hover { color: var(--accent); }
.dashboard-table thead th .sort-arrow { font-size: 9px; margin-left: 3px; }
.dashboard-table tbody tr { border-bottom: 1px solid rgba(255,255,255,.04); transition: background .1s; }
.dashboard-table tbody tr:hover { background: rgba(255,255,255,.02); }
.dashboard-table td { padding: 7px 10px; white-space: nowrap; vertical-align: middle; }
.dashboard-table .dt-status { width: 18px; text-align: center; }
.dt-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; vertical-align: middle; }
.dt-dot.RUNNING { background: var(--green); box-shadow: 0 0 4px var(--green); }
.dt-dot.PAUSED { background: var(--yellow); }
.dt-dot.ERROR { background: var(--red); box-shadow: 0 0 4px var(--red); }
.dt-dot.INITIALIZING { background: var(--purple); }
.dt-name { font-weight: 600; color: var(--text); }
.dt-addr { font-family: monospace; font-size: 10px; color: var(--muted); margin-left: 6px; }
/* Clickable name + address in the table view. Strip default button chrome so
   they read as inline text, layer interactivity on hover. Mirrors the
   card-view affordance: name → openEditModal, addr → copyRelayerAddress. */
.dt-name-btn {
  font-weight: 600; color: var(--text); cursor: pointer;
  background: none; border: 0; padding: 0; margin: 0;
  font-family: inherit; font-size: inherit; text-align: left;
}
.dt-name-btn:hover { color: var(--green); text-decoration: underline; }
.dt-addr-btn {
  font-family: monospace; font-size: 10px; color: var(--muted);
  margin-left: 6px; cursor: pointer;
  background: none; border: 0; padding: 0;
  text-align: left;
}
.dt-addr-btn:hover { color: var(--accent); text-decoration: underline; }
.dt-addr-btn.copied { color: var(--green); text-decoration: none; }
.dt-user { color: var(--muted); font-size: 11px; max-width: 200px; overflow: hidden; text-overflow: ellipsis; }
.dt-num { font-variant-numeric: tabular-nums; }
.dt-num.good { color: var(--green); }
.dt-num.warn { color: var(--yellow); }
.dt-num.bad { color: var(--red); font-weight: 600; }
/* Stacked two-line win-rate cell: bold percentage on top, muted ratio below.
   Mirrors the card's WIN RATE chip so values match across views.
   .dt-winrate-pct inherits .dt-num heat class (good/warn/bad) from the <td>. */
.dt-winrate { display: inline-flex; flex-direction: column; align-items: flex-end; line-height: 1.15; }
.dt-winrate-pct { font-size: 13px; font-weight: 600; }
.dt-winrate-roi { font-size: 10px; color: var(--muted); font-variant-numeric: tabular-nums; }
.dt-rpc { display: inline-block; padding: 2px 8px; border-radius: 3px; font-size: 9px; font-weight: 700; }
.dt-rpc.ws { background: rgba(78,161,255,.15); color: var(--accent); }
.dt-rpc.http { background: rgba(125,133,144,.15); color: var(--muted); }
.dt-actions { display: inline-flex; gap: 4px; }
.dt-actions button { padding: 3px 8px; font-size: 10px; }
.dt-severity-icon { display: inline-block; margin-right: 5px; }

/* Auto-recovery badge — Fix F1.
   Shown when a relayer was auto-rescued (restart / wake-nonce) within 24 h.
   Yellow tint signals "automation touched this", tooltip carries the type
   and today-count. Pulse animation in the first 60s draws the eye when a
   fresh event lands. */
.dt-recovery {
  display: inline-block; margin-left: 8px;
  background: rgba(245,158,11,.12); color: var(--yellow);
  font-size: 10px; font-weight: 600;
  padding: 1px 6px; border-radius: 8px;
  border: 1px solid rgba(245,158,11,.30);
  vertical-align: middle;
}
@keyframes dtRecoveryPulse {
  0%   { background: rgba(245,158,11,.45); }
  100% { background: rgba(245,158,11,.12); }
}
.dt-recovery.fresh { animation: dtRecoveryPulse 1.2s ease-out; }

/* Severity row backgrounds — critical (red) and warning (yellow) */
.dashboard-table tbody tr.row-critical { background: rgba(248,81,73,.10); }
.dashboard-table tbody tr.row-critical:hover { background: rgba(248,81,73,.16); }
.dashboard-table tbody tr.row-warn { background: rgba(245,158,11,.07); }
.dashboard-table tbody tr.row-warn:hover { background: rgba(245,158,11,.12); }

@media (max-width: 768px) {
  #dashboard-table-wrap { padding: 0; overflow-x: auto; }
  .dashboard-table thead th { position: static; padding: 6px 6px; font-size: 9px; }
  .dashboard-table td { padding: 5px 6px; font-size: 11px; }
  .dt-user { max-width: 120px; }
}

/* ── Owner groups ── */
.owner-group { margin-bottom: 16px; }
.owner-header { display: flex; align-items: center; gap: 12px; padding: 8px 12px;
  background: var(--surface2); border: 1px solid var(--border); border-radius: 8px;
  margin-bottom: 8px; flex-wrap: wrap; }
.owner-email { font-size: 13px; font-weight: 600; color: var(--text); }
.owner-count { font-size: 11px; color: var(--muted); }
.owner-stats { font-size: 11px; color: var(--green); margin-left: auto; }
.owner-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 12px; }

/* ── User filter ── */
.user-filter { padding: 3px 8px; font-size: 11px; height: 26px; max-width: 200px;
  background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); font-family: var(--font); cursor: pointer; }

/* ── Card ── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; }
.card.disabled { opacity: .55; }
.card.state-RUNNING  { border-left: 3px solid var(--green); }
.card.state-PAUSED   { border-left: 3px solid var(--yellow); }
.card.state-ERROR    { border-left: 3px solid var(--red); }
.card.state-INITIALIZING { border-left: 3px solid var(--purple); }

.card-header { display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px 5px; gap: 6px; }
.card-title { display: flex; align-items: center; gap: 6px; min-width: 0; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.state-RUNNING  .status-dot { background: var(--green); box-shadow: 0 0 5px var(--green); }
.state-PAUSED   .status-dot { background: var(--yellow); }
.state-ERROR    .status-dot { background: var(--red); box-shadow: 0 0 5px var(--red); }
.state-INITIALIZING .status-dot { background: var(--purple); }
.card-name { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: inherit; text-decoration: none;
  background: none; border: 0; padding: 0; margin: 0; font-family: inherit; text-align: left; cursor: pointer; max-width: 100%; }
.card-name:hover { text-decoration: underline; color: var(--green); }
.card-name.copied { color: var(--green); text-decoration: none; }
.state-badge { font-size: 9px; font-weight: 600; padding: 2px 6px; border-radius: 10px;
  text-transform: uppercase; letter-spacing: .5px; flex-shrink: 0; }
.state-RUNNING  .state-badge { background: #1a3d24; color: var(--green); }
.state-PAUSED   .state-badge { background: #3d2e00; color: var(--yellow); }
.state-ERROR    .state-badge { background: #3d1a1a; color: var(--red); }
.state-INITIALIZING .state-badge { background: #2a1a4a; color: var(--purple); }

.card-body { padding: 0 12px 6px; }

/* Rank strip — leaderboard position chips between header and body.
   Clickable on the whole strip, drills through to /relayer detail page. */
.rank-strip-slot { padding: 0 12px; }
.rank-strip { display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  margin: 2px 0 6px; padding: 4px 8px;
  background: linear-gradient(90deg, rgba(78,161,255,.06), rgba(78,161,255,.02) 60%, transparent);
  border: 1px solid rgba(78,161,255,.18); border-radius: 8px;
  text-decoration: none; color: var(--muted); font-size: 11px;
  transition: background .15s ease, border-color .15s ease; }
.rank-strip:hover { background: linear-gradient(90deg, rgba(78,161,255,.12), rgba(78,161,255,.04) 60%, transparent);
  border-color: rgba(78,161,255,.35); color: var(--text); }
.rank-strip:empty { display: none; }
.rs-trophy { font-size: 12px; line-height: 1; flex-shrink: 0; }
.rs-chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 6px; border-radius: 6px;
  background: rgba(255,255,255,.03); border: 1px solid rgba(255,255,255,.06); }
.rs-chip.primary { background: rgba(78,161,255,.10); border-color: rgba(78,161,255,.28); }
.rs-chip.top10 { background: rgba(34,197,94,.10); border-color: rgba(34,197,94,.30); }
.rs-chip.top10 .rs-rank { color: var(--green); }
.rs-chip.empty { opacity: .55; }
.rs-label { font-size: 9px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); }
.rs-rank { font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.rs-docs { font-size: 10px; color: var(--muted); font-variant-numeric: tabular-nums; }
.rs-arrow { font-size: 10px; font-weight: 700; padding: 0 2px; flex-shrink: 0; }
.rs-arrow.up   { color: var(--green); }
.rs-arrow.down { color: var(--red); }
.rs-arrow.flat { color: var(--muted); }
.rs-cta { margin-left: auto; font-size: 10px; color: var(--accent, #4ea1ff); white-space: nowrap;
  text-transform: uppercase; letter-spacing: .3px; font-weight: 600; }

/* Balances: MATIC + CXO big */
.card-balances { display: flex; gap: 20px; margin-bottom: 7px; padding-bottom: 7px;
  border-bottom: 1px solid var(--border); }
.bal-block { display: flex; flex-direction: column; gap: 0; }
.bal-val { font-size: 18px; font-weight: 700; line-height: 1.1; }
.bal-currency { font-size: 9px; color: var(--muted); text-transform: uppercase; letter-spacing: .8px; }
.bal-link { text-decoration: none; color: inherit; display: flex; flex-direction: column; gap: 0;
  border-radius: 4px; padding: 2px 4px; margin: -2px -4px; transition: background .15s; }
.bal-link:hover { background: var(--surface2); }
.bal-link:hover .bal-val { color: var(--blue); }

/* Doc counters: 4-cell row */
.doc-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin-bottom: 7px; }
.doc-cell { background: var(--surface2); border-radius: 5px; padding: 4px 6px; text-align: center; white-space: nowrap; overflow: hidden; }
.doc-num { display: block; font-size: 15px; font-weight: 700; line-height: 1.1; }
.doc-lbl { display: block; font-size: 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }

/* Operational info 2-col grid */
.op-grid { display: grid; grid-template-columns: 5em 1fr; gap: 2px 8px; font-size: 11px; margin-bottom: 5px; }
.og-label { color: var(--muted); white-space: nowrap; align-self: center; }
.og-val { font-family: 'SF Mono','Consolas',monospace; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; align-self: center; }
.og-val a { color: var(--blue); text-decoration: none; }
.og-val a:hover { text-decoration: underline; }

/* Collapsible details (addresses, nonce) */
.details-toggle { font-size: 10px; color: var(--muted); cursor: pointer; padding: 2px 0 3px;
  user-select: none; }
.details-toggle:hover { color: var(--text); }
.details-panel { display: none; padding-top: 4px; }
.details-panel.open { display: block; }

/* Error block */
.error-msg { font-size: 11px; color: var(--red); background: #200d0d; border: 1px solid #5a242466;
  border-radius: 6px; padding: 6px 8px; margin-bottom: 5px; }
.err-summary { display: inline; font-weight: 500; line-height: 1.4; word-break: break-word; }
.err-expand { display: inline-block; margin-top: 3px; font-size: 10px; color: #f8514988;
  cursor: pointer; user-select: none; }
.err-expand:hover { color: var(--red); }
.err-dismiss {
  float: right;
  margin-left: 6px;
  padding: 0 4px;
  color: #f8514988;
  font-size: 11px;
  cursor: pointer;
  user-select: none;
  border-radius: 3px;
  line-height: 1.4;
}
.err-dismiss:hover { color: var(--red); background: rgba(248,81,73,.1); }
.err-debug { display: none; margin-top: 5px; padding-top: 5px; border-top: 1px solid #5a242433;
  font-family: 'SF Mono','Consolas',monospace; font-size: 10px; color: #f8514999;
  word-break: break-all; line-height: 1.5; max-height: 100px; overflow-y: auto; }
.err-debug.open { display: block; }

/* Log panel */
.log-toggle { font-size: 10px; color: var(--muted); cursor: pointer; padding: 2px 0;
  user-select: none; }
.log-toggle:hover { color: var(--text); }
.log-panel { display: none; background: var(--bg); border-radius: 5px; padding: 5px; margin-top: 3px;
  max-height: 120px; overflow-y: auto; font-family: 'SF Mono','Consolas',monospace; font-size: 10px; line-height: 1.5; }
.log-panel.open { display: block; }
.log-line { display: flex; gap: 5px; }
.log-ts   { color: var(--muted); flex-shrink: 0; }
.log-lvl  { flex-shrink: 0; width: 30px; }
.log-msg  { color: var(--text); word-break: break-word; }
.log-line.INFO  .log-lvl { color: var(--blue); }
.log-line.WARN  .log-lvl { color: var(--yellow); }
.log-line.ERROR .log-lvl { color: var(--red); }

/* History panel (inline + modal) */
.hist-toggle { font-size: 10px; color: var(--muted); cursor: pointer; padding: 2px 0;
  user-select: none; }
.hist-toggle:hover { color: var(--text); }
.hist-panel { display: none; background: var(--bg); border-radius: 5px; margin-top: 3px;
  overflow: hidden; border: 1px solid var(--border); }
.hist-panel.open { display: block; }
.hist-table { width: 100%; border-collapse: collapse; font-size: 10px; }
.hist-table th { padding: 3px 5px; text-align: left; color: var(--muted);
  border-bottom: 1px solid var(--border); font-weight: 500; white-space: nowrap; }
.hist-table td { padding: 2px 5px; border-bottom: 1px solid #21262d;
  font-family: 'SF Mono','Consolas',monospace; white-space: nowrap; overflow: hidden;
  max-width: 90px; text-overflow: ellipsis; }
.hist-table tr:last-child td { border-bottom: none; }
.hist-table tr:hover td { background: #1c2128; }
.hist-table td.tx-link a { color: var(--blue); text-decoration: none; }
.hist-table td.tx-link a:hover { text-decoration: underline; }
.hist-empty { padding: 6px 8px; font-size: 10px; color: var(--muted); }
/* type colors */
.ht-relayed      { color: var(--blue); }
.ht-confirmed    { color: var(--green); }
.ht-race         { color: #e6a020; }
.ht-skipped      { color: var(--muted); }
.ht-estimate_high { color: var(--yellow); }
.ht-gas_high     { color: var(--red); }
/* history filter buttons in modal */
.hfilt-btns { display: flex; gap: 3px; }
.hfilt-btn { background: var(--surface2); border: 1px solid var(--border); color: var(--muted);
  border-radius: 5px; padding: 3px 10px; font-size: 11px; cursor: pointer; }
.hfilt-btn.active { background: var(--blue); color: #0d1117; border-color: var(--blue); font-weight: 600; }

/* Diagnostic dropdown -- position:fixed bypasses overflow:hidden on .card */
.diag-wrap { position: relative; }
.diag-menu { display: none; position: fixed;
  background: var(--surface2); border: 1px solid var(--border); border-radius: 6px;
  padding: 4px; min-width: 172px; z-index: 1000; box-shadow: 0 4px 20px rgba(0,0,0,.6); }
.diag-menu.open { display: block; }
.diag-menu button { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  padding: 6px 10px; background: transparent; border: none; color: var(--text); font-size: 12px;
  border-radius: 4px; font-family: var(--font); cursor: pointer; white-space: nowrap; }
.diag-menu button:hover { background: var(--bg); }
.diag-menu hr { border: none; border-top: 1px solid var(--border); margin: 2px 0; }

/* Boost control */
.boost-ctrl { display: flex; align-items: center; gap: 3px; margin-left: auto; }
.boost-label { font-size: 10px; color: var(--muted); margin-right: 1px; }
.boost-btn { background: var(--surface2); border: 1px solid var(--border); color: var(--text);
  border-radius: 4px; padding: 1px 7px; font-size: 13px; line-height: 1.3; cursor: pointer; }
.boost-btn:hover { background: var(--bg); }
.boost-val { font-size: 12px; font-weight: 700; min-width: 14px; text-align: center;
  padding: 0 2px; border-radius: 3px; }
.boost-val.lv0, .boost-val.lv1 { color: var(--green); }
.boost-val.lv2, .boost-val.lv3 { color: var(--yellow); }
.boost-val.lv4, .boost-val.lv5 { color: var(--red); }

/* Modal promo panel (right column, below on mobile) */
.modal-promo { width: 220px; flex-shrink: 0; padding: 24px 20px; border-left: 1px solid var(--border);
  display: flex; flex-direction: column; align-items: center; text-align: center;
  background: linear-gradient(180deg, var(--surface2) 0%, var(--surface) 100%); }
.modal-columns { display: flex; gap: 0; }
@media (max-width: 768px) {
  .modal-columns { flex-direction: column; }
  .modal-promo { width: 100%; border-left: none; border-top: 1px solid var(--border);
    padding: 20px 16px; }
  .modal-promo img { width: 80px; }
  #relayer-modal .modal { width: 100vw !important; }
}

/* Reward address dropdown */
.reward-item { padding: 8px 12px; cursor: pointer; font-size: 12px; border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center; gap: 8px; transition: background .1s; }
.reward-item:hover { background: var(--surface2); }
.reward-item:last-child { border-bottom: none; }
.reward-addr { font-family: 'SF Mono','Consolas',monospace; font-size: 11px; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.reward-bal { font-size: 11px; color: var(--green); white-space: nowrap; flex-shrink: 0; }

/* Card actions */
.card-actions { display: flex; gap: 4px; padding: 6px 10px; border-top: 1px solid var(--border);
  background: var(--bg); flex-wrap: wrap; align-items: center; }

.empty { text-align: center; color: var(--muted); padding: 60px 0; }

/* ── Dashboard modal overrides ── */
.modal { width: 560px; max-width: 96vw; }
.modal-footer { padding: 10px 16px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 8px; }
.modal-error { color: var(--red); font-size: 12px; min-height: 16px; }
.modal-logs-body { flex: 1; overflow-y: auto; padding: 12px 16px; background: var(--bg);
  font-family: 'SF Mono','Consolas',monospace; font-size: 11px; line-height: 1.6; max-height: 70vh; }

/* History modal — wider for table + wrap filter buttons */
#hist-modal .modal { width: 900px; }
#hist-modal .modal-header { flex-wrap: wrap; gap: 8px; }
#hist-modal .hfilt-btns { flex-wrap: wrap; }

/* ── Scrollbars ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── PWA / Mobile responsive ── */
body { padding-top: env(safe-area-inset-top); padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }

/* Hamburger button -- hidden on desktop */
.hamburger { display: none; background: var(--surface2); border: 1px solid var(--border);
  color: var(--text); border-radius: 6px; padding: 6px 10px; font-size: 16px; cursor: pointer;
  min-height: 36px; line-height: 1; }

/* Mobile controls panel -- hidden on desktop, toggled on mobile */
.mobile-controls { display: none; }

@media (max-width: 768px) {
  /* ── Navbar + controls ── */
  .top-nav { padding: 8px 12px; }
  .top-nav .nav-brand { font-size: 14px; }
  .top-nav .nav-brand img { width: 28px; height: 28px; }
  .nav-links { gap: 10px; }
  .nav-links a { font-size: 13px; }
  .nav-user-row { font-size: 11px; }
  .control-bar { padding: 6px 12px; gap: 6px; }
  .stats-group { gap: 4px; overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; padding-bottom: 2px; }
  .stat-pill { font-size: 10px; padding: 2px 8px; flex-shrink: 0; white-space: nowrap; }
  .actions-group { display: none; } /* hidden -- moved to hamburger panel */
  .global-panel { display: none; } /* hidden on mobile -- use hamburger */
  .hamburger { display: block; }

  /* Mobile controls -- slide-down panel */
  .mobile-controls { background: var(--surface); border-bottom: 1px solid var(--border);
    padding: 10px 12px; flex-wrap: wrap; gap: 8px; align-items: center; }
  .mobile-controls.open { display: flex; }
  .mobile-controls button { min-height: 40px; padding: 8px 14px; font-size: 13px; }
  .mobile-controls .boost-ctrl { margin-left: 0; }
  .mobile-controls .boost-btn { min-height: 36px; min-width: 36px; font-size: 16px; padding: 4px 10px; }
  .mobile-controls .boost-label { font-size: 11px; }
  .mobile-controls .boost-val { font-size: 14px; }

  /* (Chart mobile overrides removed 2026-05-19) */

  /* ── Card grid ── */
  #main-content { padding: 8px; }
  .owner-grid { grid-template-columns: 1fr; gap: 8px; }
  .owner-header { gap: 8px; padding: 6px 10px; }
  .user-filter { max-width: 160px; }

  /* ── Card ── */
  .card-body { padding: 0 10px 6px; }
  .card-header { padding: 6px 10px 4px; }
  .card-name { font-size: 14px; }
  .rank-strip-slot { padding: 0 10px; }
  .rank-strip { font-size: 10px; gap: 4px; padding: 3px 6px; }
  .rs-chip { padding: 2px 4px; gap: 3px; }
  .rs-cta { font-size: 9px; }
  .bal-val { font-size: 16px; }
  .bal-currency { font-size: 9px; }
  .doc-num { font-size: 16px; }
  .doc-lbl { font-size: 9px; }
  .op-grid { font-size: 12px; }

  /* Card actions -- wrap + bigger touch targets */
  .card-actions { flex-wrap: wrap; padding: 6px 8px; gap: 6px; }
  .card-actions button { min-height: 38px; padding: 8px 10px; font-size: 12px; }
  .card-actions .boost-btn { min-height: 34px; min-width: 34px; font-size: 15px; }
  .card-actions .boost-val { font-size: 13px; }

  /* ── Modals -> bottom sheet ── */
  .modal-overlay { padding-top: 0; align-items: flex-end; }
  .modal { width: 100vw; max-width: 100vw; border-radius: 12px 12px 0 0;
    max-height: 90vh; display: flex; flex-direction: column; }
  .modal-body { overflow-y: auto; flex: 1; }
  .modal-logs-body { max-height: 65vh; font-size: 11px; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }

  /* History table scroll */
  .hist-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* ── Touch targets ── */
  button { min-height: 36px; }
  .btn-sm { min-height: 34px; padding: 6px 10px; }

  /* ── Diagnostics menu ── */
  .diag-menu { min-width: 200px; }
  .diag-menu button { min-height: 40px; font-size: 13px; }
}

/* ── PWA install banner ── */
.install-banner { display: none; position: fixed; bottom: 0; left: 0; right: 0; z-index: 600;
  background: linear-gradient(135deg, #1a3d24 0%, #162b44 100%);
  border-top: 1px solid var(--green); padding: 14px 16px;
  align-items: center; gap: 12px; animation: slideUp .3s ease-out; }
.install-banner.show { display: flex; }
.install-banner img { width: 48px; height: 48px; border-radius: 12px; flex-shrink: 0; }
.install-banner-text { flex: 1; }
.install-banner-text strong { font-size: 14px; display: block; }
.install-banner-text span { font-size: 12px; color: var(--muted); }
.install-banner .btn-install { background: var(--green); color: #0d1117; font-weight: 700;
  padding: 10px 20px; border-radius: 8px; font-size: 14px; min-height: 44px; border: none; cursor: pointer; }
.install-banner .btn-dismiss { background: transparent; color: var(--muted);
  padding: 8px; font-size: 18px; border: none; cursor: pointer; min-height: 44px; }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

/* ── Extra small (< 380px) ── */
@media (max-width: 380px) {
  .top-nav .nav-brand span { display: none; }
  .card-balances { gap: 12px; }
  .bal-val { font-size: 14px; }
}
