:root {
  /* Dark palette -- the long-standing default, and what an explicit
     data-theme="dark" (see momentum_investing_app.py's current_theme
     context var, set server-side per account) resolves to as well, since
     neither selector below matches when data-theme="dark" is present. */
  --bg: #0f1420;
  --panel: #161d2e;
  --panel-alt: #1c2438;
  --border: #2a3350;
  --text: #e6e9f2;
  --text-dim: #9aa4c0;
  --accent: #4f8cff;
  --accent-dim: #2e4f8f;
  /* A separate, deliberately pale/muted companion to --accent-dim -- see the
     light-theme comment below for why these two can't share one value. */
  --accent-soft: #2e4f8f;
  --green: #33c481;
  --red: #e5566b;
  --amber: #e0a93a;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Light theme. Two selectors intentionally carry the same declarations (no
   CSS mixin/@extend to share them without a preprocessor, and it's short
   enough to not be worth one): the media query covers "System" (no explicit
   data-theme attribute at all) when the OS itself is set to light; the
   attribute selector covers an explicit per-account choice of "light", which
   must win regardless of the OS setting. green/red/amber are deepened from
   the dark palette's values -- they're used as both solid button/badge fills
   (white text on top, any shade works) and as plain text directly on
   --bg/--panel (needs real contrast against a near-white background, which
   the dark palette's brighter versions don't have).

   --accent-dim vs --accent-soft, found necessary by a real "this looks
   garish in light mode" report: --accent-dim is used for two visually
   opposite jobs -- (a) a BOLD active-tab/button fill with WHITE text on top
   (.tab-btn.active, .theme-opt.active, .fno-place, .site-banner-info), which
   wants a rich, saturated blue in any theme, and (b) a SUBTLE selection
   highlight behind the page's own dark text (.card-item.selected, the
   "Shared" badge), which in the dark theme happens to work with the exact
   same value (a dim navy blends quietly into a dark page) but in a light
   theme needs the opposite direction -- a pale tint, not a deepened solid --
   to read as "gently highlighted" rather than "a loud blue block" against a
   near-white page. --accent-soft is job (b)'s own variable, identical to
   --accent-dim in the dark palette (zero visual change there) and a pale
   blue wash here instead of a deepened one. */
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    --bg: #f5f7fb;
    --panel: #ffffff;
    --panel-alt: #eef1f8;
    --border: #d8deec;
    --text: #1a2033;
    --text-dim: #5b6584;
    --accent: #2f6fe0;
    --accent-dim: #1f4fb0;
    --accent-soft: #dde8fc;
    --green: #1f9d63;
    --red: #c6334f;
    --amber: #a66d0a;
  }
}
:root[data-theme="light"] {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --panel-alt: #eef1f8;
  --border: #d8deec;
  --text: #1a2033;
  --text-dim: #5b6584;
  --accent: #2f6fe0;
  --accent-dim: #1f4fb0;
  --accent-soft: #dde8fc;
  --green: #1f9d63;
  --red: #c6334f;
  --amber: #a66d0a;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

.app-shell { display: flex; flex-direction: column; min-height: 100vh; }

.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 12px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: var(--banner-h, 0px);
  z-index: 10;
}

/* F&O order desk (static/fno.js, admin only) */
.fno { max-width: 1180px; }
.fno-title h2 { margin: 0 0 2px; font-size: 22px; }
.fno-ver { font-size: 12px; font-weight: 400; color: var(--text-dim); margin-left: 6px; }
.fno-sub { color: var(--text-dim); font-size: 12.5px; margin-bottom: 14px; }
.fno-box { margin-bottom: 14px; }
.fno-box h3 { margin: 0 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-dim); }
.fno-conn { margin-top: 10px; font-size: 13.5px; color: var(--text-dim); }
.fno-conn.ok { color: var(--green); font-weight: 600; }
.fno-hint { font-size: 12px; color: var(--text-dim); margin-top: 6px; }
.fno-hint.stale, .fno-avail.stale { color: var(--amber); }
.fno-avail { font-size: 22px; font-weight: 700; color: var(--accent); }
.fno-avail.grey { color: var(--text-dim); }
.fno-limline { font-size: 13px; margin-top: 4px; }
.fno-tabs { display: flex; gap: 4px; margin: 6px 0 0; border-bottom: 1px solid var(--border); }
.fno-tabs .tab-btn { border-radius: 6px 6px 0 0; }
.fno-panel { display: none; padding: 12px 0 4px; }
.fno-panel.active { display: block; }
.fno-panel textarea { width: 100%; font-family: Consolas, "Courier New", monospace; font-size: 14px; }
.fno-example { margin-top: 8px; padding: 6px 10px; background: var(--panel-alt); border-radius: 6px; font-size: 12px; color: var(--text-dim); }
.fno-tkinfo { display: flex; gap: 24px; margin-top: 8px; font-size: 12.5px; color: var(--text-dim); flex-wrap: wrap; }
.fno-controls { align-items: center; margin-top: 12px; }
.fno-practice { padding: 7px 10px; background: var(--panel-alt); border-radius: 6px; }
.fno-place { background: var(--accent-dim); border-color: var(--accent-dim); color: #fff; font-weight: 700; }
.fno-place.live { background: var(--red); border-color: var(--red); }
.fno-place:disabled { background: var(--panel-alt); border-color: var(--border); color: var(--text-dim); }
.fno-preview { margin: 10px 0; padding: 10px 12px; background: var(--panel-alt); border: 1px solid var(--border); border-radius: 6px; font-family: Consolas, "Courier New", monospace; font-size: 12.5px; white-space: pre-wrap; }
.fno-status { margin: 10px 0; font-size: 13.5px; min-height: 20px; }
.fno-footer { margin-top: 4px; }
.fno-mode-badge { padding: 4px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 700; letter-spacing: 0.06em; }
.fno-mode-badge.practice { background: rgba(51, 196, 129, 0.15); color: var(--green); border: 1px solid var(--green); }
.fno-mode-badge.live { background: var(--red); color: #fff; border: 1px solid var(--red); }
.fno-dialog-body { max-width: 640px; max-height: 60vh; overflow: auto; white-space: pre-wrap; font-family: Consolas, "Courier New", monospace; font-size: 12.5px; }

/* Admin announcement banner (static/announcement.js): sticky above the top bar. */
.site-banner {
  position: sticky;
  top: 0;
  z-index: 11;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 9px 16px;
  font-size: 13.5px;
  line-height: 1.35;
  border-bottom: 1px solid var(--border);
}
.site-banner-info { background: var(--accent-dim); color: #f2f6ff; }
.site-banner-warning { background: var(--amber); color: #1b1404; font-weight: 600; }
.site-banner-text { flex: 1; }
.site-banner-meta { font-size: 12px; opacity: 0.8; white-space: nowrap; font-weight: 400; }
.site-banner-close {
  background: transparent;
  border: 0;
  color: inherit;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}
@media (max-width: 640px) {
  .site-banner { flex-wrap: wrap; gap: 4px 10px; }
  .site-banner-meta { order: 3; flex-basis: 100%; }
}

.brand { font-weight: 700; font-size: 16px; letter-spacing: 0.02em; }

.tabs { display: flex; gap: 4px; flex: 1; }

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  padding: 8px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}
.tab-btn:hover { background: var(--panel-alt); color: var(--text); }
.tab-btn.active { background: var(--accent-dim); color: #fff; }

.data-badge { font-size: 11px; color: var(--text-dim); white-space: nowrap; }

.content { flex: 1; padding: 20px; max-width: 1500px; width: 100%; margin: 0 auto; }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.panel-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: end;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 16px;
}
.panel-toolbar label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

input, select, textarea, button {
  font-family: inherit;
  font-size: 13px;
}

input, select, textarea {
  background: var(--panel-alt);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 7px 9px;
  min-width: 120px;
}
textarea { min-width: 260px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 1px solid var(--accent); border-color: var(--accent); }

.btn {
  background: var(--panel-alt);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  white-space: nowrap;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #3f78e8; }
.btn.danger { color: var(--red); border-color: var(--red); background: transparent; }
.btn.danger:hover { background: rgba(229, 86, 107, 0.15); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.stat-tile {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
}
.stat-tile .label { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.03em; }
.stat-tile .value { font-size: 20px; font-weight: 700; margin-top: 4px; }
.stat-tile .value.pos { color: var(--green); }
.stat-tile .value.neg { color: var(--red); }

.table-wrap {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: auto;
  max-height: 65vh;
}

table { border-collapse: collapse; width: 100%; font-size: 12.5px; }
th, td { padding: 7px 10px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--border); }
th:first-child, td:first-child, th.left, td.left { text-align: left; }
th { position: sticky; top: 0; background: var(--panel-alt); color: var(--text-dim); font-weight: 600; text-transform: uppercase; font-size: 10.5px; letter-spacing: 0.03em; z-index: 1; }
th.sortable-th { cursor: pointer; user-select: none; }
th.sortable-th:hover { color: var(--text); }
tr.filter-row th { position: sticky; top: 26px; padding: 4px 6px; z-index: 1; }
.col-filter-input {
  width: 100%;
  min-width: 60px;
  padding: 4px 6px;
  font-size: 11px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: normal;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
}
.col-filter-input:focus { outline: 1px solid var(--accent); border-color: var(--accent); }
.table-filter-count { font-size: 11px; color: var(--text-dim); margin: -8px 0 8px; }
tbody tr:hover { background: var(--panel-alt); }
td.pos { color: var(--green); }
td.neg { color: var(--red); }

.split { display: grid; grid-template-columns: 320px 1fr; gap: 16px; align-items: start; }
.split-list, .split-form {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
}
.split-list h3, .split-form h3 { margin: 0 0 12px; font-size: 13px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.03em; }
.split-form label { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.03em; }
.split-form input, .split-form select, .split-form textarea { width: 100%; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px 16px; align-items: start; }
.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.form-grid input, .form-grid select { width: 100%; }
.form-actions { display: flex; gap: 10px; margin-top: 10px; flex-wrap: wrap; }

fieldset.market-filter { border: 1px solid var(--border); border-radius: 8px; margin: 14px 0; padding: 12px; }
fieldset.market-filter legend { padding: 0 6px; font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.03em; }

.sim-fieldset { border: 1px solid var(--border); border-radius: 8px; margin: 0 0 14px; padding: 14px; }
.sim-fieldset legend { padding: 0 6px; font-size: 12px; font-weight: 700; color: var(--text); text-transform: uppercase; letter-spacing: 0.03em; }
.sim-field-row { display: flex; flex-wrap: wrap; gap: 18px; align-items: start; margin-bottom: 12px; }
.sim-field-row:last-child { margin-bottom: 0; }

/* "+AND" grouped exit-clause rows (Technicals Desk Strategy Builder / Backtest
   overrides) -- a continuation row in an AND-group, indented with a small
   "AND" badge so it reads visually as "this clause AND the one above it",
   distinct from an ordinary OR'd clause row. */
.clause-row.clause-and-row { margin-left: 28px; padding-left: 10px; border-left: 2px solid var(--accent); }
.clause-and-label { font-size: 11px; font-weight: 700; color: var(--accent); margin-right: 6px; letter-spacing: 0.03em; }
/* "1.", "2.", ... before each main (non-AND-continuation) clause row, purely
   for visual differentiation in a multi-clause box -- not sent anywhere,
   recomputed from DOM order on every render/add/remove. */
.clause-number { font-size: 11px; color: var(--text-dim); margin-right: 6px; min-width: 16px; text-align: right; }
/* "x" between a compare-to column and its multiplier/adjust term, e.g.
   "vol_sma_20  x  [3]" or "close  -  [3]  x  atr_14". */
.clause-x-label { font-size: 13px; color: var(--text-dim); }
.sim-field { min-width: 200px; }
.sim-field > .field-label { display: block; font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.03em; margin-bottom: 6px; }
.checkbox-group { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.checkbox-item { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text); cursor: pointer; }
.checkbox-item input[type="checkbox"] { min-width: auto; width: 15px; height: 15px; cursor: pointer; }
.sim-field input[type="text"], .sim-field input[type="number"] { width: 220px; }
.sltp-rows { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.sltp-row { display: flex; align-items: center; gap: 8px; }
.sltp-row input { width: 110px; }
.combo-count-badge { font-size: 13px; font-weight: 700; padding: 8px 14px; border-radius: 8px; background: var(--panel-alt); border: 1px solid var(--border); }
.combo-count-badge.over-limit { color: var(--red); border-color: var(--red); }
.sim-log {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  max-height: 280px;
  overflow-y: auto;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-dim);
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
}

.collapsible-section { margin-bottom: 12px; }
.collapsible-toggle {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
}
.collapsible-toggle:hover { border-color: var(--accent); color: var(--text); }
.collapsible-toggle .toggle-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 4px;
  background: var(--accent-dim);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}
.collapsible-body {
  background: var(--panel);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 8px 8px;
  padding: 14px;
  margin-top: -1px;
}

.card-list { display: flex; flex-direction: column; gap: 8px; max-height: 70vh; overflow: auto; }
.card-item {
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  cursor: pointer;
}
.card-item:hover { border-color: var(--accent); }
.card-item.selected { border-color: var(--accent); background: var(--accent-soft); }
.card-item .card-title { font-weight: 700; font-size: 13px; }
.card-item .card-sub { font-size: 11px; color: var(--text-dim); margin-top: 2px; }
.card-item .card-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: 4px;
  padding: 1px 6px;
  margin-left: 6px;
  vertical-align: middle;
}
.card-item .card-share-btn {
  float: right;
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text-dim);
  cursor: pointer;
}
.card-item .card-share-btn:hover { border-color: var(--accent); color: var(--text); }

.progress { padding: 30px; text-align: center; color: var(--text-dim); font-size: 14px; }
.hidden { display: none !important; }

.chart-wrap {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 16px;
}
#btChart { width: 100%; height: 280px; display: block; }

.subtabs { display: flex; gap: 4px; margin-bottom: 8px; }
.subtab-btn {
  background: var(--panel-alt);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
}
.subtab-btn.active { background: var(--accent-dim); color: #fff; border-color: var(--accent); }

.warnings-list { background: var(--panel); border: 1px solid var(--amber); border-radius: 8px; padding: 12px 24px; color: var(--amber); font-size: 12.5px; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 6px; }

/* Help page */
.help-layout { display: grid; grid-template-columns: 260px 1fr; gap: 24px; align-items: start; }
.help-toc {
  position: sticky;
  top: 76px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  max-height: calc(100vh - 100px);
  overflow: auto;
  font-size: 12.5px;
}
.help-toc ul { list-style: none; margin: 0; padding-left: 14px; }
.help-toc > ul { padding-left: 0; }
.help-toc li { margin: 6px 0; }
.help-toc a { color: var(--text-dim); text-decoration: none; }
.help-toc a:hover { color: var(--accent); }

.help-content {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 28px 36px;
  max-width: 900px;
  line-height: 1.6;
  font-size: 14px;
}
.help-content h1 { font-size: 24px; margin: 0 0 8px; border-bottom: 1px solid var(--border); padding-bottom: 12px; }
.help-content h2 { font-size: 18px; color: var(--accent); margin: 32px 0 12px; }
.help-content h3 { font-size: 15px; margin: 22px 0 8px; }
.help-content p { margin: 10px 0; color: var(--text); }
.help-content ul, .help-content ol { margin: 10px 0; padding-left: 24px; }
.help-content li { margin: 4px 0; }
.help-content hr { border: none; border-top: 1px solid var(--border); margin: 28px 0; }
.help-content strong { color: #fff; }
.help-content code {
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 12.5px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}
.help-content pre {
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  overflow-x: auto;
}
.help-content pre code { background: none; border: none; padding: 0; }
.help-content table { border-collapse: collapse; width: 100%; margin: 14px 0; font-size: 13px; }
.help-content th, .help-content td { text-align: left; padding: 8px 12px; border: 1px solid var(--border); white-space: normal; }
.help-content th { background: var(--panel-alt); color: var(--text-dim); text-transform: none; font-size: 12px; }
.help-content a { color: var(--accent); }

/* ---- header account menu (templates/_user_menu.html) ---- */
.user-menu { position: relative; }
.user-btn { display: inline-flex; align-items: center; gap: 6px; background: var(--panel-alt); border: 1px solid var(--border); color: var(--text); border-radius: 999px; padding: 4px 10px 4px 4px; cursor: pointer; font: inherit; }
.user-btn:hover, .user-btn[aria-expanded="true"] { border-color: var(--accent); }
.user-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.user-avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: #fff; font-weight: 700; font-size: 13px; display: inline-flex; align-items: center; justify-content: center; }
.user-caret { font-size: 11px; color: var(--text-dim); }
/* hover/focus tooltip with the signed-in user; hidden while the menu is open (it shows the name itself) */
.user-btn::after { content: attr(data-user); display: none; position: absolute; right: 0; top: calc(100% + 8px); background: var(--panel); border: 1px solid var(--border); border-radius: 6px; padding: 6px 10px; font-size: 12px; font-weight: 600; white-space: nowrap; color: var(--text); box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4); pointer-events: none; z-index: 40; }
.user-btn:hover:not([aria-expanded="true"])::after, .user-btn:focus-visible:not([aria-expanded="true"])::after { display: block; }
.user-panel { position: absolute; right: 0; top: calc(100% + 8px); min-width: 230px; max-width: 320px; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5); padding: 6px; z-index: 40; }
.user-panel[hidden] { display: none; }
.user-panel-head { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.user-panel-label { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.06em; }
.user-panel-name { font-size: 13px; font-weight: 600; overflow-wrap: anywhere; }
.user-item { display: block; width: 100%; text-align: left; background: transparent; border: 0; color: var(--text); font: inherit; font-size: 13px; padding: 8px 10px; border-radius: 6px; cursor: pointer; text-decoration: none; }
.user-item:hover, .user-item:focus-visible { background: var(--panel-alt); outline: none; }
.theme-row { padding: 2px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.theme-row .user-panel-label { display: block; margin-bottom: 6px; }
.theme-switch { display: flex; gap: 4px; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 3px; }
.theme-opt { flex: 1; border: 0; background: transparent; color: var(--text-dim); font: inherit; font-size: 12px; font-weight: 600; padding: 5px 0; border-radius: 4px; cursor: pointer; }
.theme-opt:hover { color: var(--text); }
.theme-opt:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.theme-opt.active { background: var(--accent-dim); color: #fff; }

dialog.pw-dialog { background: var(--panel); color: var(--text); border: 1px solid var(--border); border-radius: 10px; padding: 22px; width: min(400px, 92vw); }
dialog.pw-dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
.pw-dialog h3 { margin: 0 0 14px; }
.pw-dialog label { display: block; font-size: 12.5px; color: var(--text-dim); margin-bottom: 12px; }
.pw-dialog input, .pw-dialog select { display: block; width: 100%; margin-top: 5px; padding: 9px 10px; font: inherit; font-size: 14px; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 6px; }
.pw-dialog input:focus-visible, .pw-dialog select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.pw-hint { opacity: 0.7; }
.pw-note { font-size: 12px; color: var(--text-dim); margin: 0 0 16px; }
.pw-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.pw-checkbox { display: flex !important; align-items: center; gap: 8px; }
.pw-checkbox input { width: auto !important; margin: 0 !important; }
.pw-msg { font-size: 13px; margin: 0 0 12px; padding: 9px 11px; border-radius: 6px; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 240px; overflow-y: auto; }
.pw-msg[hidden] { display: none; }
.pw-msg.error { background: rgba(229, 86, 107, 0.14); border: 1px solid var(--red); }
.pw-msg.ok { background: rgba(51, 196, 129, 0.14); border: 1px solid var(--green); }
.pw-msg.warn { background: rgba(224, 169, 58, 0.14); border: 1px solid var(--amber); color: var(--amber); }

.selection-info { font-size: 12px; color: var(--text-dim); align-self: center; }
.run-total { font-size: 13px; font-weight: 600; align-self: center; }
.pager { display: inline-flex; gap: 6px; align-items: center; }
.pager .btn { padding: 3px 10px; }
.pager-label { font-size: 12px; color: var(--text-dim); padding: 0 4px; }
.pager-row { display: flex; justify-content: flex-end; margin: 8px 0; }
