/* =====================================================================
   Nexpoly — navy + periwinkle, layered depth.
   ===================================================================== */

@property --angle {
  syntax: "<angle>";
  initial-value: 0deg;
  inherits: false;
}

:root {
  --bg: #131820;
  --bg-2: #171d27;
  --surface: #1c2230;
  --surface-hi: #222a3a;
  --surface-2: #262e3f;
  --surface-3: #2e374b;
  --line: rgba(255, 255, 255, 0.065);
  --line-strong: rgba(255, 255, 255, 0.12);
  --highlight: rgba(255, 255, 255, 0.07);
  --text: #e9ecf4;
  --muted: #9aa3b6;
  --faint: #6c7589;
  --accent: #8e97ff;
  --accent-2: #b3a8ff;
  --accent-deep: #6570f0;
  --accent-ink: #10132a;
  --accent-soft: rgba(142, 151, 255, 0.13);
  --accent-glow: rgba(142, 151, 255, 0.45);
  --up: #4cc39a;
  --down: #f27c7c;
  --warn: #e8b65c;
  --up-soft: rgba(76, 195, 154, 0.13);
  --down-soft: rgba(242, 124, 124, 0.13);
  --warn-soft: rgba(232, 182, 92, 0.14);
  --shadow: 0 1px 0 var(--highlight) inset, 0 18px 40px -18px rgba(0, 0, 0, 0.7), 0 4px 12px -4px rgba(0, 0, 0, 0.35);
  --shadow-lift: 0 1px 0 var(--highlight) inset, 0 28px 60px -22px rgba(0, 0, 0, 0.8), 0 8px 18px -6px rgba(0, 0, 0, 0.4);
  --glass: rgba(26, 32, 45, 0.72);
  --r-sm: 10px;
  --r: 14px;
  --r-lg: 22px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --font: "Onest", system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Unbounded", "Onest", system-ui, sans-serif;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #eef0f7;
  --bg-2: #e6e9f3;
  --surface: #ffffff;
  --surface-hi: #ffffff;
  --surface-2: #f2f3f9;
  --surface-3: #e7e9f3;
  --line: rgba(20, 26, 50, 0.08);
  --line-strong: rgba(20, 26, 50, 0.15);
  --highlight: rgba(255, 255, 255, 0.9);
  --text: #171c2b;
  --muted: #5a6378;
  --faint: #8b93a6;
  --accent: #5d65e6;
  --accent-2: #8a7cf5;
  --accent-deep: #4a52d1;
  --accent-ink: #ffffff;
  --accent-soft: rgba(93, 101, 230, 0.1);
  --accent-glow: rgba(93, 101, 230, 0.35);
  --up: #18946a;
  --down: #d24848;
  --warn: #b27a10;
  --up-soft: rgba(24, 148, 106, 0.1);
  --down-soft: rgba(210, 72, 72, 0.09);
  --warn-soft: rgba(178, 122, 16, 0.1);
  --shadow: 0 1px 0 var(--highlight) inset, 0 16px 36px -20px rgba(40, 50, 100, 0.35), 0 3px 10px -4px rgba(40, 50, 100, 0.12);
  --shadow-lift: 0 1px 0 var(--highlight) inset, 0 26px 50px -22px rgba(40, 50, 100, 0.45), 0 8px 16px -8px rgba(40, 50, 100, 0.16);
  --glass: rgba(255, 255, 255, 0.72);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 var(--font);
  font-feature-settings: "tnum" 1, "cv11" 1;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; transition: color 0.2s; }
a:hover { color: var(--accent-2); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }
::selection { background: var(--accent-soft); }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ------------------------------------------------------------ ambient backdrop */

.backdrop { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.backdrop::before {
  content: ""; position: absolute; inset: 0;
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(ellipse 80% 55% at 50% 0%, #000 0%, transparent 75%);
  opacity: 0.55;
}
.blob { position: absolute; border-radius: 50%; filter: blur(90px); opacity: 0.55; will-change: transform; }
.blob.a { width: 620px; height: 620px; left: -160px; top: -260px; background: radial-gradient(circle, rgba(142, 151, 255, 0.55), transparent 65%); animation: drift-a 26s ease-in-out infinite alternate; }
.blob.b { width: 520px; height: 520px; right: -140px; top: 80px; background: radial-gradient(circle, rgba(179, 168, 255, 0.35), transparent 65%); animation: drift-b 32s ease-in-out infinite alternate; }
.blob.c { width: 700px; height: 500px; left: 30%; bottom: -320px; background: radial-gradient(circle, rgba(101, 112, 240, 0.28), transparent 65%); animation: drift-a 38s ease-in-out infinite alternate-reverse; }
:root[data-theme="light"] .blob { opacity: 0.35; }
@keyframes drift-a { to { transform: translate(90px, 60px) scale(1.08); } }
@keyframes drift-b { to { transform: translate(-80px, 70px) scale(0.94); } }

/* ------------------------------------------------------------ top navigation */

.topnav {
  position: sticky; top: 12px; z-index: 40;
  max-width: 1400px; margin: 12px auto 0; padding: 0 20px;
}
.topnav-inner {
  display: flex; align-items: center; gap: 20px;
  padding: 8px 8px 8px 14px;
  background: var(--glass);
  backdrop-filter: blur(18px) saturate(1.4);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-family: var(--display); font-weight: 600; font-size: 16px; letter-spacing: -0.02em; white-space: nowrap; }
.brand:hover { color: var(--text); }
.brand-mark {
  width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(145deg, var(--accent-2), var(--accent) 45%, var(--accent-deep));
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.45) inset, 0 -2px 0 rgba(0, 0, 0, 0.18) inset, 0 6px 16px -4px var(--accent-glow);
  color: var(--accent-ink);
  transition: transform 0.4s var(--spring);
}
.brand:hover .brand-mark { transform: rotate(-8deg) scale(1.06); }
.brand-mark svg { width: 18px; height: 18px; stroke: #10132a; stroke-width: 2.6; fill: none; stroke-linecap: round; stroke-linejoin: round; }

.nav { position: relative; display: flex; gap: 2px; flex: 1; min-width: 0; overflow: hidden; }
/* When labels don't fit (long Russian labels, narrow windows) app.js steps down:
   username, then the brand name, then inactive items collapse to icons. */
.topnav-inner.fit-1 .who span:not(.avatar) { display: none; }
.topnav-inner.fit-2 .brand > span:last-child { display: none; }
.topnav-inner.fit-3 .nav a:not([aria-current="page"]) span { display: none; }
.topnav-inner.fit-3 .nav a:not([aria-current="page"]) { padding: 9px 11px; }
.nav a {
  position: relative; z-index: 1;
  display: flex; align-items: center; gap: 8px;
  padding: 8px 11px; border-radius: 11px; font-size: 14.5px;
  color: var(--muted); font-weight: 500; white-space: nowrap;
  transition: color 0.25s;
}
.nav a svg.i { width: 17px; height: 17px; opacity: 0.8; }
.nav a .short { display: none; }
.nav a:hover { color: var(--text); }
.nav a[aria-current="page"] { color: var(--text); }
.nav a[aria-current="page"] svg.i { color: var(--accent); opacity: 1; }
.nav-ind {
  position: absolute; z-index: 0; top: 0; left: 0; height: 100%;
  border-radius: 11px;
  background: linear-gradient(180deg, var(--surface-3), var(--surface-2));
  box-shadow: 0 1px 0 var(--highlight) inset, 0 4px 12px -6px rgba(0, 0, 0, 0.5);
  transition: transform 0.45s var(--ease), width 0.45s var(--ease);
  pointer-events: none;
}
.nav-ind::after { content: ""; position: absolute; left: 22%; right: 22%; bottom: -1px; height: 2px; border-radius: 2px; background: var(--accent); box-shadow: 0 0 10px var(--accent); }

.tools { display: flex; align-items: center; gap: 6px; flex: none; }
.tools form { margin: 0; display: contents; }
.who { display: flex; align-items: center; gap: 8px; padding-right: 6px; color: var(--muted); font-weight: 500; white-space: nowrap; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  background: linear-gradient(145deg, var(--surface-3), var(--surface-2));
  border: 1px solid var(--line-strong); color: var(--accent); font-weight: 700; font-size: 13px; text-transform: uppercase;
}
.icon-btn {
  width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center;
  background: transparent; border: 1px solid transparent; color: var(--muted); cursor: pointer;
  font: 600 12px var(--font);
  transition: background 0.2s, color 0.2s, border-color 0.2s, transform 0.2s var(--spring);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); border-color: var(--line); }
.icon-btn:active { transform: scale(0.92); }

/* ------------------------------------------------------------ page */

main { max-width: 1200px; margin: 0 auto; padding: 30px 20px 90px; }
main.narrow { max-width: 880px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 16px; margin: 8px 0 22px; }
h1 { font-family: var(--display); font-weight: 600; font-size: 28px; letter-spacing: -0.03em; line-height: 1.15; margin: 0; }
.page-head p { margin: 6px 0 0; color: var(--muted); max-width: 60ch; }
h2 { font-size: 17px; font-weight: 700; margin: 0; letter-spacing: -0.01em; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.up { color: var(--up); }
.down { color: var(--down); }
code, .mono { font-family: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace; font-size: 0.92em; }

/* entrance: one orchestrated sequence on page load */
/* short and capped: the whole page is in place within ~0.5 s however many blocks it has */
/* backwards, not both: a fill that outlives the animation keeps each element a separate layer,
   and a popover inside one would slide under the next card. */
.reveal { animation: rise 0.42s var(--ease) backwards; animation-delay: calc(min(var(--d, 0), 4) * 35ms); }
.no-reveal .reveal { animation: none; }
@keyframes rise { from { opacity: 0; transform: translateY(14px) scale(0.985); filter: blur(4px); } to { opacity: 1; transform: none; filter: none; } }

/* ------------------------------------------------------------ cards */

.card {
  position: relative;
  background: linear-gradient(180deg, var(--surface-hi), var(--surface));
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
}
.card::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: linear-gradient(180deg, var(--highlight), transparent 30%);
  opacity: 0.6;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px 0; }
.card-head .meta { color: var(--muted); font-size: 13.5px; }
.card-body { padding: 18px 22px 22px; }
.count-badge {
  display: inline-grid; place-items: center; min-width: 24px; height: 24px; padding: 0 7px; margin-left: 8px;
  border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 12.5px; font-weight: 700; vertical-align: 2px;
}

/* ------------------------------------------------------------ hero status */

.hero {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 28px;
  padding: 26px 28px; overflow: hidden; isolation: isolate;
}
.hero::after {
  /* light sweep behind content */
  content: ""; position: absolute; z-index: -1; inset: -40% -10% auto auto; width: 60%; height: 180%;
  background: radial-gradient(closest-side, var(--accent-soft), transparent);
  pointer-events: none;
}
.hero.is-running { border-color: transparent; }
.hero.is-running .ring {
  position: absolute; inset: -1px; border-radius: inherit; padding: 1.5px; pointer-events: none;
  background: conic-gradient(from var(--angle), transparent 0 55%, var(--up) 70%, var(--accent) 85%, transparent 100%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  animation: spin 5s linear infinite;
}
@keyframes spin { to { --angle: 360deg; } }

.orb {
  position: relative; width: 64px; height: 64px; border-radius: 50%; flex: none;
  background: radial-gradient(circle at 32% 28%, #ffffff55, transparent 38%), radial-gradient(circle at 50% 60%, var(--faint), #3a4256 75%);
  box-shadow: 0 10px 24px -8px rgba(0, 0, 0, 0.6), inset 0 -6px 12px rgba(0, 0, 0, 0.35);
}
.is-running .orb {
  background: radial-gradient(circle at 32% 28%, #ffffff88, transparent 38%), radial-gradient(circle at 50% 60%, #6fe0b8, var(--up) 45%, #1f7a5c 85%);
  box-shadow: 0 0 0 0 rgba(76, 195, 154, 0.5), 0 12px 30px -8px rgba(76, 195, 154, 0.7), inset 0 -6px 12px rgba(0, 0, 0, 0.25);
  animation: orb-pulse 2.4s ease-out infinite;
}
.is-setup .orb { background: radial-gradient(circle at 32% 28%, #ffffff88, transparent 38%), radial-gradient(circle at 50% 60%, #f3d08d, var(--warn) 50%, #8a5d0d 90%); }
@keyframes orb-pulse {
  0% { box-shadow: 0 0 0 0 rgba(76, 195, 154, 0.45), 0 12px 30px -8px rgba(76, 195, 154, 0.7), inset 0 -6px 12px rgba(0, 0, 0, 0.25); }
  70% { box-shadow: 0 0 0 18px rgba(76, 195, 154, 0), 0 12px 30px -8px rgba(76, 195, 154, 0.7), inset 0 -6px 12px rgba(0, 0, 0, 0.25); }
  100% { box-shadow: 0 0 0 0 rgba(76, 195, 154, 0), 0 12px 30px -8px rgba(76, 195, 154, 0.7), inset 0 -6px 12px rgba(0, 0, 0, 0.25); }
}
.orb svg { position: absolute; inset: 0; margin: auto; width: 26px; height: 26px; stroke: rgba(255, 255, 255, 0.92); stroke-width: 2.4; fill: none; stroke-linecap: round; stroke-linejoin: round; }

.hero-word { font-family: var(--display); font-weight: 600; font-size: 30px; letter-spacing: -0.035em; line-height: 1.1; }
.hero-text { color: var(--muted); margin: 6px 0 0; max-width: 62ch; }
.hero-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }

/* greeting with the last day in one sentence */
.greet { margin: 6px 0 20px; }
.greet h1 { font-size: 26px; }
.greet p { margin: 6px 0 0; color: var(--muted); max-width: 70ch; }
.greet p b { font-weight: 650; color: var(--text); }
.greet p b.up { color: var(--up); }
.greet p b.down { color: var(--down); }

/* first-run checklist inside the hero */
.onboard { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 4px; max-width: 60ch; }
.onboard li { position: relative; display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 12px; padding: 8px 0; }
/* the thread between the steps */
.onboard li:not(:last-child)::before { content: ""; position: absolute; left: 14px; top: 38px; bottom: -6px; width: 2px; border-radius: 2px; background: var(--line-strong); }
.onboard li.done:not(:last-child)::before { background: linear-gradient(var(--up), var(--line-strong)); }
.onboard b { display: block; font-weight: 600; }
.onboard .hint { display: block; margin-top: 2px; }
.onboard li:not(.done):not(.next) { opacity: 0.6; }
.ob-dot {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  font-weight: 700; font-size: 13px; color: var(--muted); background: var(--surface-2); border: 1.5px solid var(--line-strong);
}
.ob-dot svg.i { width: 15px; height: 15px; stroke-width: 3; }
.done .ob-dot { color: #0d2a20; background: var(--up); border-color: var(--up); animation: check-pop 0.5s var(--spring) backwards; animation-delay: calc(0.3s + var(--i, 0) * 0.15s); }
.next .ob-dot { color: var(--accent); border-color: var(--accent); box-shadow: 0 0 0 0 var(--accent-glow); animation: ob-call 2.4s ease-out 1s infinite; }
@keyframes check-pop { from { transform: scale(0.3); opacity: 0; } }
@keyframes ob-call { 0% { box-shadow: 0 0 0 0 var(--accent-glow); } 70%, 100% { box-shadow: 0 0 0 10px transparent; } }
.ob-link { display: inline-block; margin-top: 6px; font-weight: 600; font-size: 14px; }

.chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 6px 5px 11px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--text); font-size: 13px; white-space: nowrap;
}
.chip.plain { padding-right: 11px; color: var(--muted); }
.chip.plain.warn-text { color: var(--down); white-space: normal; border-radius: 12px; max-width: 100%; overflow-wrap: anywhere; }
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--up); box-shadow: 0 0 8px var(--up); }
.chip .dot.off { background: var(--down); box-shadow: 0 0 8px var(--down); }
.chip .dot.idle { background: var(--faint); box-shadow: none; }
.chip button {
  width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; border: 0; cursor: pointer;
  background: var(--surface-3); color: var(--muted); transition: background 0.2s, color 0.2s, transform 0.2s var(--spring);
}
.chip button:hover { color: var(--text); background: var(--accent-soft); }
.chip button:active { transform: scale(0.88); }
.chip button svg.i { width: 13px; height: 13px; }
.chip button.done { color: var(--up); }

/* ------------------------------------------------------------ buttons */

.btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  padding: 12px 20px; border-radius: 13px; border: 1px solid transparent; cursor: pointer;
  font: 600 15px/1 var(--font); white-space: nowrap; color: var(--accent-ink);
  background: linear-gradient(180deg, var(--accent-2), var(--accent) 55%, var(--accent-deep));
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.4) inset, 0 -2px 0 rgba(0, 0, 0, 0.14) inset, 0 8px 22px -8px var(--accent-glow);
  transition: transform 0.25s var(--spring), box-shadow 0.25s, filter 0.2s, background 0.2s;
}
.btn:hover { color: var(--accent-ink); transform: translateY(-1px); box-shadow: 0 1px 0 rgba(255, 255, 255, 0.45) inset, 0 -2px 0 rgba(0, 0, 0, 0.14) inset, 0 14px 30px -10px var(--accent-glow); filter: brightness(1.05); }
.btn:active { transform: translateY(0) scale(0.97); }
.btn svg.i { width: 17px; height: 17px; stroke-width: 2.2; }
.btn.lg { padding: 15px 24px; font-size: 16px; border-radius: 15px; }
.btn.sm { padding: 8px 13px; font-size: 13.5px; border-radius: 10px; gap: 6px; }
.btn.sm svg.i { width: 15px; height: 15px; }
.btn.ghost {
  color: var(--text); background: linear-gradient(180deg, var(--surface-3), var(--surface-2));
  border-color: var(--line-strong); box-shadow: 0 1px 0 var(--highlight) inset, 0 6px 14px -8px rgba(0, 0, 0, 0.5);
}
.btn.ghost:hover { color: var(--text); border-color: var(--accent); box-shadow: 0 1px 0 var(--highlight) inset, 0 10px 22px -10px var(--accent-glow); }
.btn.danger { color: var(--down); background: var(--down-soft); border-color: color-mix(in srgb, var(--down) 30%, transparent); box-shadow: none; }
.btn.danger:hover { color: #fff; background: var(--down); box-shadow: 0 10px 24px -10px var(--down); }
.btn[disabled], .btn.is-loading { pointer-events: none; }
.btn[disabled]:not(.is-loading) { opacity: 0.45; }
.btn.is-loading { color: transparent !important; }
.btn.is-loading::after {
  content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid currentColor; border-color: var(--accent-ink) transparent var(--accent-ink) transparent;
  animation: spin-plain 0.7s linear infinite;
}
.btn.ghost.is-loading::after, .btn.danger.is-loading::after { border-color: var(--text) transparent var(--text) transparent; }
@keyframes spin-plain { to { transform: rotate(360deg); } }
.linkbtn { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; }

/* ------------------------------------------------------------ stats */

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-top: 18px; }
.stat { padding: 18px 20px 18px; overflow: hidden; transition: transform 0.35s var(--ease), box-shadow 0.35s; }
.stat:hover { transform: translateY(-3px); box-shadow: var(--shadow-lift); }
.stat-top { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-weight: 500; font-size: 14px; }
.stat-icon {
  width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--accent);
}
.stat-icon svg.i { width: 17px; height: 17px; }
.stat-value { font-family: var(--display); font-weight: 500; font-size: 27px; letter-spacing: -0.03em; line-height: 1.15; margin-top: 14px; white-space: nowrap; }
.stat-hint { color: var(--faint); font-size: 13px; margin-top: 4px; }
.stat.accent {
  background: linear-gradient(150deg, color-mix(in srgb, var(--accent) 26%, var(--surface-hi)), var(--surface) 70%);
  border-color: color-mix(in srgb, var(--accent) 30%, transparent);
}
.stat.accent .stat-value { background: linear-gradient(90deg, var(--text), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.stat.accent .stat-icon { background: var(--accent); color: var(--accent-ink); border: 0; box-shadow: 0 6px 14px -6px var(--accent-glow); }
.stat .stat-value.up { color: var(--up); }
.stat .stat-value.down { color: var(--down); }
.stat .spark { position: absolute; right: -10px; bottom: -14px; width: 120px; opacity: 0.18; color: var(--accent); }

/* ------------------------------------------------------------ dashboard grid */

.dash { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 18px; margin-top: 18px; align-items: start; }
.side { display: grid; gap: 18px; min-width: 0; }

/* ------------------------------------------------------------ position cards */

.pos-list { display: grid; gap: 12px; }
.pos {
  position: relative; padding: 16px 18px; border-radius: var(--r);
  background: linear-gradient(180deg, var(--surface-2), color-mix(in srgb, var(--surface-2) 60%, var(--surface)));
  border: 1px solid var(--line);
  transition: transform 0.35s var(--ease), border-color 0.25s, box-shadow 0.35s;
}
.pos:hover { transform: translateY(-2px); border-color: var(--line-strong); box-shadow: 0 16px 30px -18px rgba(0, 0, 0, 0.6); }
.pos-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.pos-title { font-weight: 600; color: var(--text); line-height: 1.35; display: inline-flex; gap: 6px; align-items: flex-start; }
.pos-title:hover { color: var(--accent); }
.pos-title svg.i { width: 14px; height: 14px; margin-top: 3px; opacity: 0; transform: translate(-4px, 4px); transition: opacity 0.2s, transform 0.25s var(--ease); }
.pos-title:hover svg.i { opacity: 1; transform: none; }
.outcome {
  display: inline-block; margin-top: 6px; padding: 2px 9px; border-radius: 7px;
  background: var(--accent-soft); color: var(--accent); font-size: 12.5px; font-weight: 600;
}
.pos-pnl { text-align: right; white-space: nowrap; }
.pos-pnl .big { font-family: var(--display); font-weight: 500; font-size: 19px; letter-spacing: -0.02em; }
.pos-pnl .pct { display: inline-block; margin-top: 4px; padding: 1px 8px; border-radius: 999px; font-size: 12.5px; font-weight: 600; background: var(--surface-3); color: var(--muted); }
.pos-pnl.up .pct { background: var(--up-soft); color: var(--up); }
.pos-pnl.down .pct { background: var(--down-soft); color: var(--down); }

.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-top: 14px; }
.metric { padding: 8px 10px; border-radius: 10px; background: color-mix(in srgb, var(--bg) 35%, transparent); border: 1px solid var(--line); min-width: 0; }
.metric .k { display: block; color: var(--faint); font-size: 12px; }
.metric .v { display: block; font-weight: 600; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.pos-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.pos-foot .left { display: flex; gap: 8px; flex-wrap: wrap; }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600; background: var(--surface-3); color: var(--muted); white-space: nowrap; }
.pill.up { background: var(--up-soft); color: var(--up); }
.pill.down { background: var(--down-soft); color: var(--down); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.accent { background: var(--accent-soft); color: var(--accent); }
.pill svg.i { width: 13px; height: 13px; }
.fx-copy .table { margin-top: 10px; }
.pill .spinner { width: 11px; height: 11px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin-plain 0.8s linear infinite; }

/* expandable TP/SL editor */
details.edit > summary { list-style: none; cursor: pointer; }
details.edit > summary::-webkit-details-marker { display: none; }
details.edit[open] > summary { color: var(--accent); }
.edit-panel { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; margin-top: 12px; padding: 12px; border-radius: 12px; background: color-mix(in srgb, var(--bg) 40%, transparent); border: 1px dashed var(--line-strong); animation: rise 0.35s var(--ease) both; }
.edit-panel label { display: grid; gap: 4px; font-size: 12.5px; color: var(--muted); }
.edit-panel .input-wrap { width: 120px; }

/* ------------------------------------------------------------ chart */

.chart-total { font-family: var(--display); font-weight: 500; font-size: 24px; letter-spacing: -0.03em; }
.chart { width: 100%; height: auto; display: block; margin-top: 8px; overflow: visible; }
.chart .zero { stroke: var(--line-strong); stroke-dasharray: 3 5; }
.chart .line { fill: none; stroke: url(#chart-stroke); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.chart .area { fill: url(#chart-fill); }
.chart .end { fill: var(--accent); }
.chart .end-halo { fill: var(--accent); opacity: 0.3; transform-box: fill-box; transform-origin: center; animation: halo 2.2s ease-out infinite; }
@keyframes halo { from { transform: scale(1); opacity: 0.45; } to { transform: scale(3.2); opacity: 0; } }
.chart.draw .line { stroke-dasharray: var(--len); stroke-dashoffset: var(--len); animation: draw 1.6s var(--ease) 0.3s forwards; }
.chart.draw .area { opacity: 0; animation: fade 1s ease 1.1s forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes fade { to { opacity: 1; } }
.chart-stats { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

/* ------------------------------------------------------------ position chart (the market's life) */

.life { position: relative; margin-top: 14px; padding-bottom: 20px; color: var(--accent); }
.life.up { color: var(--up); }
.life.down { color: var(--down); }
.life.is-empty { display: none; }
.life .spark { display: block; width: 100%; height: 92px; overflow: visible; }
.spark-line { fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; }
.spark-area { fill: currentColor; opacity: 0.1; }
.spark-entry { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 4 4; opacity: 0.6; vector-effect: non-scaling-stroke; }
.life-future { fill: var(--text); opacity: 0.045; }
.life-mid { stroke: var(--line-strong); stroke-width: 1; stroke-dasharray: 2 5; vector-effect: non-scaling-stroke; }
.life-level { stroke-width: 1; stroke-dasharray: 2 3; vector-effect: non-scaling-stroke; opacity: 0.75; }
.life-level.sl { stroke: var(--down); }
.life-level.tp { stroke: var(--up); }
.life-now { stroke: var(--text); stroke-opacity: 0.3; stroke-width: 1; vector-effect: non-scaling-stroke; }
.spark-dot {
  position: absolute; left: 100%; top: 50%; width: 8px; height: 8px; margin: -4px 0 0 -4px; border-radius: 50%;
  background: currentColor; box-shadow: 0 0 10px currentColor; transition: top 0.4s var(--ease), left 0.4s var(--ease);
}
.is-live .spark-dot::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%; background: currentColor;
  animation: halo-dot 1.8s ease-out infinite;
}
@keyframes halo-dot { from { transform: scale(1); opacity: 0.6; } to { transform: scale(3.4); opacity: 0; } }
.life-y { position: absolute; left: 4px; font-size: 10.5px; color: var(--faint); font-variant-numeric: tabular-nums; pointer-events: none; }
.life-y.hi { top: 2px; }
.life-y.lo { top: 74px; }
.life-left { position: absolute; top: 8px; display: grid; font-size: 11.5px; line-height: 1.25; color: var(--muted); pointer-events: none; }
.life-left b { color: var(--text); font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.life-axis { position: absolute; left: 0; right: 0; bottom: 0; height: 16px; font-size: 11.5px; color: var(--faint); font-variant-numeric: tabular-nums; }
.life-axis span { position: absolute; bottom: 0; white-space: nowrap; }
.life-axis .t0 { left: 0; }
.life-axis .t1 { right: 0; }
.life-axis .tn { transform: translateX(-50%); color: var(--text); }
.life-levels { display: flex; justify-content: space-between; gap: 10px; margin-top: 6px; font-size: 12px; color: var(--faint); }
.life-levels b { font-weight: 600; }
.life-levels .sl b { color: var(--down); }
.life-levels .tp b { color: var(--up); }

/* ------------------------------------------------------------ copy speed */

.speed-big { display: flex; align-items: baseline; gap: 6px; font-family: var(--display); }
.speed-big b { font-weight: 500; font-size: 34px; letter-spacing: -0.04em; line-height: 1; }
.speed-big > span:last-child { color: var(--muted); font-size: 15px; }
.speed-icon { align-self: center; display: grid; place-items: center; width: 30px; height: 30px; margin-right: 4px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); }
.speed-icon svg.i { width: 17px; height: 17px; fill: currentColor; stroke: none; }
.speed-sub { margin: 6px 0 0; color: var(--faint); font-size: 12.5px; }
.speed-bar { display: flex; gap: 3px; height: 10px; margin-top: 14px; }
.speed-bar .seg { flex-basis: 0; border-radius: 999px; transform-origin: left; animation: grow 0.9s var(--ease) both; transition: flex-grow 0.6s var(--ease); }
/* A live refresh re-renders the bar: no entrance again, the parts glide from their old lengths (app.js). */
.speed-bar.still .seg { animation: none; }
.speed-bar .seg:nth-child(2) { animation-delay: 0.12s; }
.speed-bar .seg:nth-child(3) { animation-delay: 0.24s; }
@keyframes grow { from { transform: scaleX(0); } }
.seg.detect, .seg-dot.detect { background: color-mix(in srgb, var(--muted) 55%, transparent); }
.seg.decide, .seg-dot.decide { background: linear-gradient(90deg, var(--accent-deep), var(--accent)); }
.seg.ahead, .seg-dot.ahead { background: var(--up); }
.speed-legend b.up { color: var(--up); }
.seg.order, .seg-dot.order { background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.speed-legend { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.speed-legend li { display: flex; align-items: center; gap: 8px; }
.speed-legend b { margin-left: auto; color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.seg-dot { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.speed-foot { margin: 12px 0 0; padding-top: 10px; border-top: 1px solid var(--line); color: var(--faint); font-size: 12px; }
.tl-lat { display: inline-flex; align-items: center; gap: 3px; margin-left: 6px; padding: 0 7px; border-radius: 6px; background: var(--accent-soft); color: var(--accent); font-size: 11.5px; font-weight: 700; vertical-align: 1px; white-space: nowrap; }
.tl-lat svg.i { width: 11px; height: 11px; fill: currentColor; stroke: none; }

/* ------------------------------------------------------------ activity timeline */

.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 13px; top: 6px; bottom: 6px; width: 1px; background: linear-gradient(var(--line-strong), transparent); }
.timeline li { position: relative; display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 10px; padding: 9px 0; }
.tl-dot {
  position: relative; z-index: 1; width: 27px; height: 27px; border-radius: 9px; display: grid; place-items: center;
  background: var(--surface-2); border: 1px solid var(--line-strong); color: var(--faint);
}
.tl-dot svg.i { width: 14px; height: 14px; stroke-width: 2.2; }
.tl-dot.ok { color: var(--up); background: var(--up-soft); border-color: color-mix(in srgb, var(--up) 30%, transparent); }
.tl-dot.warn { color: var(--warn); background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.tl-dot.error { color: var(--down); background: var(--down-soft); border-color: color-mix(in srgb, var(--down) 30%, transparent); }
.tl-dot.info { color: var(--accent); background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
.tl-body { min-width: 0; padding-top: 3px; font-size: 14px; line-height: 1.45; }
.tl-where { display: block; color: var(--faint); font-size: 12.5px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-time { display: block; color: var(--faint); font-size: 12px; margin-top: 3px; }
.tl-count { display: inline-block; margin-left: 6px; padding: 0 6px; border-radius: 6px; background: var(--surface-3); color: var(--muted); font-size: 11.5px; font-weight: 700; vertical-align: 1px; }
.scroll-y { max-height: 560px; overflow-y: auto; margin-right: -8px; padding-right: 8px; scrollbar-width: thin; scrollbar-color: var(--surface-3) transparent; }

/* ------------------------------------------------------------ empty states */

.empty { display: grid; justify-items: center; text-align: center; gap: 10px; padding: 34px 20px; color: var(--muted); }
.empty-art {
  width: 64px; height: 64px; border-radius: 20px; display: grid; place-items: center; color: var(--accent);
  background: linear-gradient(145deg, var(--surface-3), var(--surface-2)); border: 1px solid var(--line-strong);
  box-shadow: 0 12px 26px -14px var(--accent-glow); animation: float 4s ease-in-out infinite;
}
.empty-art svg.i { width: 28px; height: 28px; }
@keyframes float { 50% { transform: translateY(-6px); } }
.empty p { margin: 0; max-width: 40ch; }
.empty .btn { margin-top: 6px; }

/* ------------------------------------------------------------ tables */

.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-weight: 500; font-size: 12.5px; color: var(--faint); padding: 0 12px 10px; border-bottom: 1px solid var(--line); }
.table td { padding: 14px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr { transition: background 0.2s; }
.table tbody tr:hover { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
.table th.num, .table td.num { text-align: right; white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
.table .market { max-width: 420px; }
.table .market a { color: var(--text); font-weight: 600; }
.table .market a:hover { color: var(--accent); }
.table .market .outcome { margin-top: 4px; }

/* ------------------------------------------------------------ forms */

.form-grid { display: grid; gap: 18px; }
.panel { padding: 22px 24px 8px; }
.panel-head { display: flex; gap: 14px; align-items: flex-start; padding-bottom: 14px; }
.panel-icon {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex: none; color: var(--accent);
  background: linear-gradient(145deg, var(--surface-3), var(--surface-2)); border: 1px solid var(--line-strong);
  box-shadow: 0 8px 18px -12px var(--accent-glow);
}
.panel-head p { margin: 4px 0 0; color: var(--muted); font-size: 14px; max-width: 70ch; }

.field-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 380px); gap: 12px 40px; padding: 18px 0; border-top: 1px solid var(--line); }
.field-row > * { min-width: 0; }
.label { font-weight: 600; display: block; }
.hint { color: var(--muted); font-size: 13.5px; margin-top: 4px; line-height: 1.5; }
.error-text { display: flex; align-items: center; gap: 6px; color: var(--down); font-size: 13.5px; margin-top: 8px; animation: shake 0.4s var(--ease); }
@keyframes shake { 20%, 60% { transform: translateX(-4px); } 40%, 80% { transform: translateX(4px); } }

input[type="text"], input[type="password"], input[type="number"], select {
  width: 100%; padding: 12px 14px;
  background: color-mix(in srgb, var(--bg) 55%, var(--surface));
  color: var(--text); border: 1px solid var(--line-strong); border-radius: 12px; font: inherit;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.18);
  transition: border-color 0.2s, box-shadow 0.25s, background 0.2s;
}
input::placeholder { color: var(--faint); }
input:hover, select:hover { border-color: color-mix(in srgb, var(--accent) 35%, var(--line-strong)); }
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.12), 0 0 0 4px var(--accent-soft); }
input.invalid { border-color: var(--down); box-shadow: 0 0 0 4px var(--down-soft); }
select { appearance: none; cursor: pointer; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 20px) 52%, calc(100% - 15px) 52%; background-size: 5px 5px; background-repeat: no-repeat; }

.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap input { padding-right: 64px; }
.input-wrap .suffix { position: absolute; right: 12px; color: var(--faint); font-size: 13.5px; font-weight: 600; pointer-events: none; transition: color 0.2s; }
.input-wrap:focus-within .suffix { color: var(--accent); }
.input-wrap .reveal-btn { position: absolute; right: 6px; }
.input-wrap.has-btn input { padding-right: 48px; }

/* option cards (radio) */
.options { display: grid; gap: 10px; }
.option { position: relative; display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 12px; padding: 14px 16px; border-radius: 14px; cursor: pointer;
  background: color-mix(in srgb, var(--bg) 35%, var(--surface)); border: 1px solid var(--line-strong);
  transition: border-color 0.25s, background 0.25s, transform 0.25s var(--spring), box-shadow 0.25s; }
.option:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line-strong)); transform: translateY(-1px); }
.option:has(input:checked) { border-color: var(--accent); background: linear-gradient(150deg, var(--accent-soft), transparent 70%); box-shadow: 0 10px 24px -16px var(--accent-glow); }
.option input { appearance: none; margin: 2px 0 0; width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--line-strong); display: grid; place-content: center; cursor: pointer; background: var(--surface); transition: border-color 0.2s; }
.option input::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 8px var(--accent-glow); transform: scale(0); transition: transform 0.3s var(--spring); }
.option input:checked { border-color: var(--accent); }
.option input:checked::before { transform: scale(1); }
.option .title { font-weight: 600; }
.option .hint { margin-top: 2px; }

/* segmented control */
.segmented { position: relative; display: grid; grid-template-columns: 1fr 1fr; padding: 4px; border-radius: 13px; background: color-mix(in srgb, var(--bg) 55%, var(--surface)); border: 1px solid var(--line-strong); box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.18); }
.segmented label { position: relative; z-index: 1; display: grid; place-items: center; padding: 9px 10px; border-radius: 10px; cursor: pointer; font-weight: 600; font-size: 14px; color: var(--muted); transition: color 0.25s; text-align: center; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label:has(input:checked) { color: var(--accent-ink); }
.segmented label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.segmented .thumb { position: absolute; z-index: 0; top: 4px; bottom: 4px; left: 4px; width: calc(50% - 4px); border-radius: 10px;
  background: linear-gradient(180deg, var(--accent-2), var(--accent)); box-shadow: 0 6px 16px -6px var(--accent-glow), 0 1px 0 rgba(255, 255, 255, 0.4) inset;
  transition: transform 0.45s var(--spring); }
.segmented:has(label:nth-of-type(2) input:checked) .thumb { transform: translateX(100%); }
.preview { display: flex; gap: 8px; align-items: center; margin-top: 12px; padding: 10px 12px; border-radius: 11px; background: var(--accent-soft); color: var(--text); font-size: 13.5px; }
.preview svg.i { color: var(--accent); width: 16px; height: 16px; }

.check { display: flex; align-items: center; gap: 10px; padding: 16px 0; color: var(--muted); cursor: pointer; border-top: 1px solid var(--line); }
.check input { appearance: none; width: 20px; height: 20px; border-radius: 6px; border: 2px solid var(--line-strong); display: grid; place-content: center; cursor: pointer; transition: background 0.2s, border-color 0.2s; margin: 0; }
.check input::before { content: ""; width: 10px; height: 6px; border: solid var(--accent-ink); border-width: 0 0 2.5px 2.5px; transform: rotate(-45deg) scale(0); margin-top: -2px; transition: transform 0.25s var(--spring); }
.check input:checked { background: var(--accent); border-color: var(--accent); }
.check input:checked::before { transform: rotate(-45deg) scale(1); }

.actions { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin-top: 20px; }

/* unsaved-changes bar */
.dirty-bar {
  position: fixed; left: 50%; bottom: 22px; z-index: 50;
  display: flex; align-items: center; gap: 14px; padding: 10px 10px 10px 18px; border-radius: 16px;
  background: var(--glass); backdrop-filter: blur(18px) saturate(1.4); -webkit-backdrop-filter: blur(18px) saturate(1.4);
  border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--line-strong)); box-shadow: var(--shadow-lift), 0 0 40px -10px var(--accent-glow);
  transform: translate(-50%, 140%); opacity: 0; visibility: hidden; pointer-events: none;
  transition: transform 0.5s var(--spring), opacity 0.3s, visibility 0s 0.3s;
}
/* Hidden it must not catch taps meant for the page beneath it. */
.dirty-bar.show { transform: translate(-50%, 0); opacity: 1; visibility: visible; pointer-events: auto; transition: transform 0.5s var(--spring), opacity 0.3s; }
.dirty-bar .msg { display: flex; align-items: center; gap: 9px; font-weight: 600; white-space: nowrap; }
.dirty-bar .msg::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--warn); box-shadow: 0 0 10px var(--warn); }

/* key/value list */
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 10px 20px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }

.status-card { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 18px; align-items: start; padding: 22px 24px; }
.shield { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; color: var(--faint); background: var(--surface-2); border: 1px solid var(--line-strong); }
.shield.ok { color: var(--up); background: var(--up-soft); border-color: color-mix(in srgb, var(--up) 35%, transparent); box-shadow: 0 10px 26px -12px var(--up); }
.shield svg.i { width: 24px; height: 24px; }

/* ------------------------------------------------------------ toasts */

.toasts { position: fixed; top: 84px; right: 20px; z-index: 60; display: grid; gap: 10px; width: min(380px, calc(100vw - 32px)); }
.toast {
  position: relative; overflow: hidden; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: start;
  padding: 14px 12px 14px 14px; border-radius: 14px;
  background: var(--glass); backdrop-filter: blur(18px) saturate(1.4); -webkit-backdrop-filter: blur(18px) saturate(1.4);
  border: 1px solid var(--line-strong); box-shadow: var(--shadow-lift);
  animation: toast-in 0.55s var(--spring) both;
}
.toast.leaving { animation: toast-out 0.35s var(--ease) forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateX(40px) scale(0.96); } }
@keyframes toast-out { to { opacity: 0; transform: translateX(40px) scale(0.96); } }
.toast .t-icon { width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center; background: var(--up-soft); color: var(--up); }
.toast.error .t-icon { background: var(--down-soft); color: var(--down); }
.toast .t-icon svg.i { width: 16px; height: 16px; stroke-width: 2.4; }
.toast p { margin: 3px 0 0; }
.toast .close { width: 28px; height: 28px; }
.toast .bar { position: absolute; left: 0; bottom: 0; height: 2px; width: 100%; background: var(--up); transform-origin: left; animation: countdown var(--life, 5s) linear forwards; }
.toast.error .bar { background: var(--down); }
@keyframes countdown { to { transform: scaleX(0); } }

/* ------------------------------------------------------------ modal */

dialog.modal {
  width: min(420px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--line-strong); border-radius: 20px;
  background: linear-gradient(180deg, var(--surface-hi), var(--surface)); color: var(--text); box-shadow: var(--shadow-lift);
}
dialog.modal[open] { animation: pop 0.4s var(--spring); }
dialog.modal::backdrop { background: rgba(8, 10, 18, 0.55); backdrop-filter: blur(4px); animation: fade-in 0.3s ease; }
@keyframes pop { from { opacity: 0; transform: translateY(12px) scale(0.95); } }
@keyframes fade-in { from { opacity: 0; } }
.modal-body { padding: 24px 24px 8px; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 14px; }
.modal-icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--down-soft); color: var(--down); }
.modal-body p { margin: 8px 0 0; color: var(--text); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; padding: 18px 24px 22px; }

/* ------------------------------------------------------------ live-update feedback */

.flash-up { animation: flash-up 1.4s var(--ease); }
.flash-down { animation: flash-down 1.4s var(--ease); }
@keyframes flash-up { 0% { color: var(--up); text-shadow: 0 0 14px var(--up); } }
@keyframes flash-down { 0% { color: var(--down); text-shadow: 0 0 14px var(--down); } }
.is-new { animation: slide-in 0.6s var(--spring) backwards; }
@keyframes slide-in { from { opacity: 0; transform: translateY(-10px) scale(0.97); } }

/* ------------------------------------------------------------ simulation */

.sim-badge {
  display: inline-flex; align-items: center; gap: 6px; vertical-align: 6px; margin-left: 8px;
  padding: 4px 11px; border-radius: 999px; font: 600 13px var(--font); letter-spacing: 0;
  color: var(--warn); background: var(--warn-soft); border: 1px dashed color-mix(in srgb, var(--warn) 55%, transparent);
}
.sim-badge svg.i { width: 15px; height: 15px; }
.sim-tag {
  display: inline-block; padding: 1px 7px; border-radius: 6px; font-size: 11.5px; font-weight: 700;
  color: var(--warn); background: var(--warn-soft); border: 1px dashed color-mix(in srgb, var(--warn) 50%, transparent);
  vertical-align: 1px;
}
.sim-panel.is-on { border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
.sim-panel.is-on .panel-icon { color: var(--warn); }
@media (max-width: 760px) { .sim-panel form[data-confirm] { position: static !important; margin: 0 0 18px; } }

/* ------------------------------------------------------------ users */

.user-tools { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; }
.search-box, .sort-box {
  position: relative; display: flex; align-items: center; gap: 10px; padding: 0 14px; height: 46px;
  border-radius: 13px; background: color-mix(in srgb, var(--bg) 55%, var(--surface));
  border: 1px solid var(--line-strong); box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.18);
  transition: border-color 0.2s, box-shadow 0.25s; cursor: text;
}
.search-box:focus-within, .sort-box:focus-within { border-color: var(--accent); box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.12), 0 0 0 4px var(--accent-soft); }
.search-box svg.i, .sort-box svg.i { color: var(--faint); flex: none; transition: color 0.2s; }
.search-box:focus-within svg.i, .sort-box:focus-within svg.i { color: var(--accent); }
.search-box input, .sort-box select {
  flex: 1; min-width: 0; height: 100%; padding: 0; border: 0; background: none; box-shadow: none; color: var(--text);
  font: inherit; -webkit-appearance: none; appearance: none;
}
.search-box input:focus, .sort-box select:focus { box-shadow: none; outline: none; }
.search-box input::-webkit-search-cancel-button { display: none; }
.search-clear { display: grid; color: var(--faint); }
.search-clear:hover { color: var(--text); }
.sort-box { cursor: pointer; min-width: 210px; }
.sort-box select { cursor: pointer; padding-right: 22px; background-position: calc(100% - 6px) 52%, calc(100% - 1px) 52%; }

.filter-row { margin: 12px 0 8px; }
.filter-row::-webkit-scrollbar { display: none; }
.filter-bar {
  position: relative; display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 4px; border-radius: 14px;
  background: color-mix(in srgb, var(--bg) 55%, var(--surface)); border: 1px solid var(--line-strong);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.18);
}
.fchip {
  position: relative; z-index: 1; display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 11px 7px 10px; border-radius: 10px; white-space: nowrap;
  font-size: 13.5px; font-weight: 600; color: var(--muted); transition: color 0.25s;
}
.fchip svg.i { width: 15px; height: 15px; opacity: 0.85; }
.fchip:hover { color: var(--text); }
.fchip[aria-current="true"] { color: var(--accent-ink); }
.fcount {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; display: inline-grid; place-items: center;
  font-size: 11.5px; font-weight: 700; background: var(--surface-3); color: var(--muted); transition: background 0.25s, color 0.25s;
}
.fchip[aria-current="true"] .fcount { background: rgba(16, 19, 42, 0.18); color: var(--accent-ink); }
:root[data-theme="light"] .fchip[aria-current="true"] .fcount { background: rgba(255, 255, 255, 0.25); }
.filter-ind {
  position: absolute; z-index: 0; top: 0; left: 0; width: 0; height: 0; border-radius: 10px;
  background: linear-gradient(180deg, var(--accent-2), var(--accent)); box-shadow: 0 6px 16px -6px var(--accent-glow), 0 1px 0 rgba(255, 255, 255, 0.4) inset;
  transition: transform 0.45s var(--spring), width 0.45s var(--spring), height 0.3s var(--ease); pointer-events: none;
}
/* Without JS the active chip still stands out. */
.no-js .fchip[aria-current="true"], .filter-bar:not(.ready) .fchip[aria-current="true"] { background: linear-gradient(180deg, var(--accent-2), var(--accent)); }
.users-table tbody tr { cursor: pointer; }
.users-table td { padding-top: 11px; padding-bottom: 11px; }
.users-table td.mono, .users-table td.num { white-space: nowrap; }
.users-table .pill svg.i { width: 12px; height: 12px; }
.user-cell { display: inline-flex; align-items: center; gap: 10px; color: var(--text); max-width: 100%; min-width: 0; }
.user-cell > span { min-width: 0; }
.user-cell strong { overflow-wrap: anywhere; }  /* a wallet without a name shows its full address */
.user-cell:hover strong { color: var(--accent); }
.avatar.is-online { position: relative; }
.avatar.is-online::after {
  content: ""; position: absolute; right: -1px; bottom: -1px; width: 10px; height: 10px; border-radius: 50%;
  background: var(--up); border: 2px solid var(--surface); box-shadow: 0 0 8px var(--up);
}
.online-dot { display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 50%; background: var(--up); box-shadow: 0 0 8px var(--up); animation: blink 2s ease-in-out infinite; }
@keyframes blink { 50% { opacity: 0.45; } }
.pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 16px; font-size: 13.5px; }
.btn.is-disabled { opacity: 0.4; pointer-events: none; }
.feed-user { font-weight: 700; color: var(--text); margin-right: 4px; }
.feed-user:hover { color: var(--accent); }

.back-link { display: inline-block; margin: 6px 0 14px; color: var(--muted); font-weight: 500; }
.back-link:hover { color: var(--text); }
.profile { display: flex; align-items: center; gap: 20px; padding: 22px 24px; }
.profile h1 { font-size: 26px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.profile-meta { display: flex; flex-wrap: wrap; gap: 6px 22px; margin-top: 8px; color: var(--muted); font-size: 14px; }
.avatar.xl { width: 64px; height: 64px; font-size: 26px; border-radius: 20px; flex: none; }
.avatar.xl.is-online::after { width: 14px; height: 14px; }
.danger-zone { border-color: color-mix(in srgb, var(--down) 28%, var(--line)); }
.danger-zone .panel-icon { color: var(--down); }
dialog.modal h2 { margin: 2px 0 0; }

@media (max-width: 760px) {
  .user-tools { grid-template-columns: minmax(0, 1fr); }
  .sort-box { min-width: 0; }
  .filter-row { overflow-x: auto; scrollbar-width: none; margin-right: -16px; padding-right: 16px; }
  .filter-bar { flex-wrap: nowrap; }
  .profile { padding: 18px; }
}

/* ------------------------------------------------------------ login */

.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 410px; padding: 34px 32px 26px; }
.login .brand { font-size: 20px; }
.login .brand-mark { width: 40px; height: 40px; border-radius: 13px; }
/* the mark's trend line draws itself once the card is in */
.login .brand-mark path { stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw 0.9s var(--ease) 0.35s forwards; }
.login-lead { color: var(--muted); margin: 18px 0 8px; }
.login label { display: block; font-weight: 600; font-size: 14px; margin: 18px 0 7px; }
.login .btn { width: 100%; margin-top: 26px; }
.login .tools { justify-content: center; margin-top: 22px; }
.login .flash p { margin: 14px 0 0; padding: 11px 14px; border-radius: 12px; background: var(--down-soft); color: var(--down); animation: shake 0.4s var(--ease); }

/* ------------------------------------------------------------ responsive */

@media (max-width: 1080px) {
  .dash { grid-template-columns: minmax(0, 1fr); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .topnav { top: 8px; margin-top: 8px; padding: 0 12px; }
  /* backdrop-filter would turn the header into the containing block of the fixed tab bar */
  .topnav-inner { gap: 10px; padding: 6px 6px 6px 10px; backdrop-filter: none; -webkit-backdrop-filter: none; background: color-mix(in srgb, var(--surface) 94%, transparent); }
  .who span:not(.avatar) { display: none; }
  .nav {
    position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 45;
    justify-content: space-around; padding: 6px;
    background: var(--glass); backdrop-filter: blur(18px) saturate(1.4); -webkit-backdrop-filter: blur(18px) saturate(1.4);
    border: 1px solid var(--line-strong); border-radius: 18px; box-shadow: var(--shadow-lift);
  }
  .nav a { flex-direction: column; gap: 2px; padding: 7px 4px; font-size: 10.5px; flex: 1; min-width: 0; }
  .nav a span { display: block; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  .nav a span.full { display: none; }
  .nav a span.short { display: block; }
  .nav a svg.i { width: 20px; height: 20px; }
  .nav-ind::after { display: none; }
  .tools { margin-left: auto; }
  main { padding: 20px 16px 120px; }
  h1 { font-size: 24px; }
  .hero { grid-template-columns: minmax(0, 1fr); gap: 16px; padding: 20px; }
  .hero .orb { position: absolute; top: 18px; right: 18px; width: 44px; height: 44px; }
  .hero .orb svg { width: 20px; height: 20px; }
  .hero-text { padding-right: 52px; }
  .hero-word { font-size: 24px; }
  .greet h1 { font-size: 22px; }
  .hero-cta .btn { width: 100%; }
  .stats { gap: 12px; }
  .stat { padding: 14px 15px; }
  .stat-value { font-size: 21px; margin-top: 10px; }
  .stat-hint { display: none; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .field-row { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .panel { padding: 18px 16px 4px; }
  .card-head { padding: 16px 16px 0; }
  .card-body { padding: 14px 16px 18px; }
  .toasts { top: auto; bottom: 96px; right: 16px; }
  .dirty-bar { bottom: 92px; width: calc(100vw - 24px); justify-content: space-between; flex-wrap: wrap; gap: 8px 10px; }
  .dirty-bar .msg { font-size: 13px; white-space: normal; flex: 1 1 100%; }
  .dirty-bar .btn { flex: 1 1 0; justify-content: center; }

  .table.stack thead { display: none; }
  .table.stack tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 6px 12px; padding: 14px 4px; border-bottom: 1px solid var(--line); }
  .table.stack td { border: 0; padding: 0; text-align: left !important; }
  .table.stack td.market { grid-column: 1 / -1; max-width: none; margin-bottom: 4px; }
  .table.stack td[data-label]::before { content: attr(data-label); display: block; color: var(--faint); font-size: 12px; }
  .table.stack td.wide { grid-column: 1 / -1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  .chart.draw .line { stroke-dashoffset: 0; }
  .chart.draw .area { opacity: 1; }
  .login .brand-mark path { stroke-dashoffset: 0; }
}

/* ------------------------------------------------------------ provider budget (admin) */

.prov-status { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 14px 0 4px; border-top: 1px solid var(--line); }
.prov-meter { position: relative; height: 10px; margin: 14px 0 10px; border-radius: 999px; background: var(--surface-3); box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.4); }
.prov-meter .fill { position: absolute; inset: 0 auto 0 0; border-radius: inherit; background: linear-gradient(90deg, var(--accent-deep), var(--accent)); transition: width 0.8s var(--ease); }
.prov-meter .fill.over { background: linear-gradient(90deg, var(--warn), var(--down)); }
.prov-meter .mark { position: absolute; top: -4px; bottom: -4px; width: 2px; margin-left: -1px; border-radius: 2px; }
.prov-meter .mark.pace { background: var(--text); opacity: 0.8; }
.prov-meter .mark.cap { background: var(--down); }
.prov-facts { display: grid; gap: 4px; color: var(--muted); font-size: 13px; padding-bottom: 6px; }
.prov-pair { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 8px; }

/* ------------------------------------------------------------ wallet finder */

.fx-tabs { margin: -6px 0 18px; }
.notice {
  display: flex; align-items: flex-start; gap: 10px; margin-top: 14px; padding: 12px 14px; border-radius: 13px;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); font-size: 14px; line-height: 1.5;
}
.notice svg.i { width: 17px; height: 17px; flex: none; margin-top: 2px; }
.notice.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 35%, transparent); color: var(--text); }
.notice.warn svg.i { color: var(--warn); }
.notice.down { background: var(--down-soft); border-color: color-mix(in srgb, var(--down) 35%, transparent); color: var(--text); }
.notice.down svg.i { color: var(--down); }
.notice.accent { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 35%, transparent); color: var(--text); font-weight: 600; }
.notice.accent svg.i { color: var(--accent); }
a.notice:hover { border-color: var(--accent); }

.fx-filters { display: flex; flex-wrap: wrap; gap: 10px 22px; margin-bottom: 14px; }
.fx-group { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.fx-label { color: var(--faint); font-size: 12.5px; margin-right: 4px; white-space: nowrap; }
.pick-link, .pick span {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; cursor: pointer; white-space: nowrap; flex: none;
  font: 600 13px var(--font); color: var(--muted); background: var(--surface-2); border: 1px solid var(--line);
  transition: color 0.2s, background 0.2s, border-color 0.2s, transform 0.2s var(--ease);
}
.pick-link svg.i { width: 14px; height: 14px; }
.pick-link:hover, .pick span:hover { color: var(--text); border-color: var(--line-strong); transform: translateY(-1px); }
.pick-link[aria-current="true"], .pick input:checked + span {
  color: var(--accent-ink); border-color: transparent;
  background: linear-gradient(180deg, var(--accent-2), var(--accent)); box-shadow: 0 6px 16px -8px var(--accent-glow);
}
.pick-link.toggle[aria-current="true"] { color: var(--accent); background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 40%, transparent); box-shadow: none; }
.pick { position: relative; }
.pick input { position: absolute; opacity: 0; pointer-events: none; }
.pick input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
button.pick-link { line-height: inherit; }

.fx-tools { margin-bottom: 14px; }
.fx-tools.three { grid-template-columns: minmax(0, 1fr) auto auto; }
.fx-summary { font-size: 13px; margin: 4px 0 10px; }
.fx-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 6px; }
.fx-table .user-cell strong { font-weight: 600; }
.fx-table td.market .pill { margin-right: 4px; vertical-align: 1px; }
.fx-table td.market .outcome { margin: 0 4px 4px 0; }
.fx-ava { width: 32px; height: 32px; font-size: 14px; border-radius: 10px; }
.pill.lg { padding: 6px 13px; font-size: 13.5px; }
.pill.lg svg.i { width: 15px; height: 15px; }

.score {
  display: inline-flex; align-items: center; gap: 3px; min-width: 38px; justify-content: center; padding: 3px 9px; border-radius: 9px;
  font: 700 13px var(--font); font-variant-numeric: tabular-nums; color: var(--muted); background: var(--surface-3);
}
.score svg.i { width: 12px; height: 12px; stroke-width: 3; }
.score.mid { color: var(--warn); background: var(--warn-soft); }
.score.pass { color: var(--up); background: var(--up-soft); box-shadow: 0 0 0 1px color-mix(in srgb, var(--up) 30%, transparent) inset; }

.cat-chip { display: inline-block; padding: 1px 8px; border-radius: 7px; font-size: 12px; font-weight: 600; color: var(--muted); background: var(--surface-3); }
.cat-sports { color: #7fd1a8; background: rgba(127, 209, 168, 0.12); }
.cat-crypto { color: #f0b86e; background: rgba(240, 184, 110, 0.13); }
.cat-politics { color: #9fb2ff; background: rgba(159, 178, 255, 0.13); }
.cat-geopolitics { color: #c6a4ff; background: rgba(198, 164, 255, 0.13); }
.cat-finance { color: #6fd0e0; background: rgba(111, 208, 224, 0.12); }
.cat-weather { color: #8fc8ff; background: rgba(143, 200, 255, 0.12); }
.cat-tech { color: #ff9fc6; background: rgba(255, 159, 198, 0.12); }
.cat-culture { color: #ffb38f; background: rgba(255, 179, 143, 0.12); }
:root[data-theme="light"] .cat-chip { filter: saturate(1.4) brightness(0.75); }

.fx-add { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; }
.fx-add input { font-family: ui-monospace, "SF Mono", Menlo, monospace; }

.fx-hero { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: start; }
.fx-hero .profile-meta a { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); }
.fx-hero .profile-meta a:hover { color: var(--accent); }
.fx-hero .profile-meta svg.i { width: 13px; height: 13px; }
.fx-hero .profile-meta .mono { overflow-wrap: anywhere; }
.fx-hero-actions { display: grid; gap: 8px; justify-items: stretch; }
.fx-hero-actions form { width: 100%; }
.fx-hero-actions .btn, .fx-hero-actions .pill { width: 100%; justify-content: center; }
.icon-btn.sm { width: 26px; height: 26px; border-radius: 8px; }
.icon-btn.sm svg.i { width: 14px; height: 14px; }
.fx-metrics { grid-template-columns: repeat(6, minmax(0, 1fr)); margin-top: 0; }

.fx-verdict { margin: 0 0 8px; font-weight: 600; }
.fx-reasons { margin: 0 0 12px; padding-left: 18px; color: var(--muted); line-height: 1.55; }
.fx-reasons.small { font-size: 13px; margin: 6px 0 0; }
.fx-checks { margin: 8px 0 6px; font-size: 13.5px; }
.fx-checks td { padding: 9px 8px; }
.fx-mark { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.fx-mark .fx-group { margin-top: 10px; }

.fx-bars { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.fx-bars li { display: grid; grid-template-columns: minmax(0, 7.5em) minmax(0, 1fr) 3em; align-items: center; gap: 10px; font-size: 13.5px; }
.fx-bars b { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 600; }
.fx-bar { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.fx-bar i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent-deep), var(--accent-2)); transform-origin: left; animation: grow 0.9s var(--ease) both; }
.fx-bars.small { gap: 7px; margin-top: 10px; }
.fx-bars.small li { font-size: 12.5px; }
.fx-bars.small .fx-bar { height: 6px; }
.fx-score-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.fx-score-list > li + li { padding-top: 14px; border-top: 1px solid var(--line); }
.fx-score-head { display: flex; align-items: center; gap: 8px; }
.fx-score-head a { font-weight: 600; color: var(--text); margin-right: auto; }

.fx-field { padding: 16px 0; border-top: 1px solid var(--line); }
.fx-field > .label { margin-bottom: 10px; }
.fx-field .check { padding: 10px 0; border-top: 0; }
.fx-own { width: 130px; }
.fx-own input { padding-right: 28px; text-align: right; }
.fx-select { height: 44px; max-width: 320px; }
.fx-more { padding: 14px 0 6px; border-top: 1px solid var(--line); }
.fx-more summary { cursor: pointer; color: var(--muted); font-weight: 600; }
.fx-more summary:hover { color: var(--text); }
.fx-more .check { padding: 10px 0; border-top: 0; }

.fx-scan-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.fx-scan-list a { display: grid; gap: 3px; padding: 11px 12px; border-radius: 12px; color: var(--text); font-size: 13.5px; border: 1px solid transparent; transition: background 0.2s, border-color 0.2s; }
.fx-scan-list a:hover { background: var(--surface-2); border-color: var(--line); }
.fx-scan-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.fx-scan-head { align-items: flex-start; }
.fx-scan-head h2 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.fx-steps { list-style: none; margin: 0 0 18px; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.fx-steps li { display: flex; gap: 10px; align-items: flex-start; padding: 12px; border-radius: 13px; border: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 30%, transparent); font-size: 13.5px; }
.fx-steps li.active { border-color: var(--accent); background: var(--accent-soft); }
.fx-steps li.failed { border-color: color-mix(in srgb, var(--down) 45%, transparent); background: var(--down-soft); }
.fx-step-dot { width: 26px; height: 26px; flex: none; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 12.5px; border: 1.5px solid var(--line-strong); color: var(--muted); }
.fx-steps li.done .fx-step-dot { background: var(--up); border-color: var(--up); color: #0d2a20; }
.fx-steps li.active .fx-step-dot { border-color: var(--accent); color: var(--accent); }
.fx-step-dot svg.i { width: 14px; height: 14px; stroke-width: 3; }
.spinner { display: inline-block; width: 12px; height: 12px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin-plain 0.8s linear infinite; }
.fx-progress-line { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; margin-bottom: 8px; }
.fx-progress-line > span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fx-progress { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.4); }
.fx-progress i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent-deep), var(--accent), var(--accent-2)); transition: width 0.8s var(--ease); }
.fx-progress.is-live i { background-size: 200% 100%; animation: fx-shimmer 1.6s linear infinite; }
@keyframes fx-shimmer { from { background-position: 200% 0; } to { background-position: 0 0; } }
.fx-scan-stats { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; margin-top: 18px; }
.fx-scan-stats > div { padding: 10px 12px; border-radius: 12px; background: color-mix(in srgb, var(--bg) 35%, transparent); border: 1px solid var(--line); min-width: 0; }
.fx-scan-stats span { display: block; color: var(--faint); font-size: 12px; }
.fx-scan-stats b { display: block; font-family: var(--display); font-weight: 500; font-size: 18px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fx-scan-stats .accent { border-color: color-mix(in srgb, var(--up) 35%, transparent); background: var(--up-soft); }
.fx-scan-stats .accent b { color: var(--up); }
.fx-result { max-width: 360px; font-size: 13px; line-height: 1.45; }
.fx-log { max-height: 320px; overflow-y: auto; padding: 12px 14px; border-radius: 12px; background: color-mix(in srgb, var(--bg) 55%, transparent); border: 1px solid var(--line);
  font: 12.5px/1.65 ui-monospace, "SF Mono", Menlo, monospace; }
.fx-log time { margin-right: 6px; }
.fx-log .lvl-success { color: var(--up); }
.fx-log .lvl-muted { color: var(--faint); }
.fx-log .lvl-warn { color: var(--warn); }
.fx-log .lvl-error { color: var(--down); }

.fx-crit-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: 18px; margin-top: 18px; }
.fx-crit.is-mine { border-color: color-mix(in srgb, var(--accent) 45%, transparent); box-shadow: var(--shadow), 0 0 40px -18px var(--accent-glow); }
.fx-crit .panel-head h2 { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.fx-kv { gap: 7px 16px; font-size: 13.5px; }
.fx-kv dd { text-align: right; }

@media (max-width: 1080px) {
  .fx-metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .fx-scan-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .fx-hero { grid-template-columns: auto minmax(0, 1fr); }
  .fx-hero-actions { grid-column: 1 / -1; grid-template-columns: minmax(0, 1fr); }
  .fx-hero-main { min-width: 0; }
  .fx-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fx-steps { grid-template-columns: minmax(0, 1fr); }
  .fx-scan-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fx-tools.three { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .fx-tools.three .search-box { grid-column: 1 / -1; }
  .fx-filters { gap: 10px; }
  .fx-group { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; max-width: 100%; }
  .fx-add { grid-template-columns: minmax(0, 1fr); }
}

/* finder: watchlist, teams, tables, criteria editor */
.fx-star { margin-left: 6px; color: var(--warn); font-size: 14px; vertical-align: 1px; }
.btn.ghost.is-starred { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, transparent); background: var(--warn-soft); }
.fx-follow { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr)); gap: 18px; padding: 18px 22px; margin-top: 18px; }
.fx-follow .label { margin-bottom: 8px; }
.fx-inline { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
/* Fixed-height fields: no vertical padding, or the 12 px of the general field style pushes the
   text below the middle (a select shows it cut at the bottom). */
.fx-inline > input, .fx-inline > select { flex: 1 1 160px; min-width: 0; height: 40px; padding-block: 0; }
.fx-select { padding-block: 0; }
.fx-updated { margin-top: 6px; font-size: 13px; }
.fx-inline.grow > input:first-of-type { flex: 2 1 260px; }
.fx-stack { display: grid; gap: 10px; }
.fx-stack .label { display: grid; gap: 6px; font-size: 13px; }
.fx-group.wrap { flex-wrap: wrap; }
.fx-pop { position: relative; }
.fx-pop > summary { list-style: none; cursor: pointer; }
.fx-pop > summary::-webkit-details-marker { display: none; }
.fx-pop[open] > summary { color: var(--text); border-color: var(--accent); }
.fx-pop-body {
  position: absolute; z-index: 30; top: calc(100% + 8px); left: 0; width: min(340px, 86vw); padding: 14px; border-radius: 14px;
  display: grid; gap: 10px; text-align: left; white-space: normal;
  background: linear-gradient(180deg, var(--surface-hi), var(--surface)); border: 1px solid var(--line-strong); box-shadow: var(--shadow-lift);
}
.fx-pop.right > .fx-pop-body { left: auto; right: 0; }
/* Set by app.js when the preferred side would run off the screen. */
.fx-pop.flip > .fx-pop-body { left: auto; right: 0; }
.fx-pop.right.flip > .fx-pop-body { left: 0; right: auto; }
.fx-team .card-head { flex-wrap: wrap; }
.fx-team-body { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 28px; }
.fx-sub { font-size: 13px; font-weight: 600; color: var(--faint); text-transform: uppercase; letter-spacing: 0.06em; margin: 0 0 10px; }
.fx-members { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.fx-members li { display: flex; align-items: center; gap: 10px; }
.fx-members li form { margin-left: auto; }
.fx-table-tools { display: flex; gap: 10px; align-items: flex-start; flex-wrap: wrap; padding-bottom: 20px; }
.fx-table-tools > form { flex: 1 1 520px; }
.fx-kind { display: inline-block; padding: 3px 10px; border-radius: 8px; font-size: 12.5px; font-weight: 700; color: var(--accent); background: var(--accent-soft); }
.fx-note { max-width: 320px; white-space: pre-line; font-size: 13.5px; }
.fx-who { white-space: normal; font-size: 12px; margin-top: 4px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.fx-crit-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); gap: 12px 18px; padding: 4px 0 16px; }
.fx-crit-field { display: grid; gap: 6px; font-size: 13.5px; color: var(--muted); }
.fx-crit-field.is-bad input, input.invalid { border-color: var(--down) !important; box-shadow: 0 0 0 3px var(--down-soft); }
.fx-crit-field .input-wrap input { width: 100%; }
@media (max-width: 760px) {
  .fx-team-body { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  .fx-follow { padding: 16px; }
  .fx-pop-body { position: fixed; left: 12px !important; right: 12px; top: auto; bottom: 96px; width: auto; }
}

/* ------------------------------------------------------------ subscriptions, invites */

.row-actions { display: inline-flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.row-actions form { margin: 0; }
.invite-fresh { margin-bottom: 18px; }
.invite-link { display: flex; gap: 10px; padding-bottom: 20px; }
.invite-link input { flex: 1; min-width: 0; font-size: 13.5px; }
.sub-banner { margin: 0 0 18px; }
.sub-banner a { color: inherit; text-decoration: underline; }
.sub-state { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 4px 0 18px; }
.sub-state .big { font-size: 20px; font-weight: 650; }
.sub-actions { display: grid; gap: 10px; padding: 16px 0 20px; border-top: 1px solid var(--line); }
.sub-actions .inline { display: flex; gap: 8px; }
.sub-actions .inline input { flex: 1; min-width: 0; }
@media (max-width: 560px) {
  .invite-link { flex-direction: column; }
  .row-actions { justify-content: flex-start; }
}

/* In-place navigation (filters, tabs): the old content dims while the new one loads. */
main { transition: opacity 0.15s; }
main.is-swapping { opacity: 0.55; pointer-events: none; }

/* two-step sign-in setup */
.tfa-qr { width: 200px; max-width: 100%; margin: 4px auto 10px; line-height: 0; }
.tfa-qr svg { width: 100%; height: auto; border-radius: 10px; }
dialog.tfa-modal { width: min(440px, calc(100vw - 32px)); }
.tfa-modal-body { padding: 24px 24px 4px; display: grid; gap: 10px; }
.tfa-modal-body h2 { margin: 0; }
.tfa-modal-body .hint { margin: 0; }
.tfa-modal-body .label { margin-top: 6px; }
.tfa-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 4px; border-radius: 12px; background: var(--surface-2); }
.tfa-tabs > input { position: absolute; opacity: 0; pointer-events: none; }
.tfa-tabs > label { display: flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 10px;
  border-radius: 9px; color: var(--muted); font-weight: 600; cursor: pointer; transition: background 0.2s, color 0.2s; }
.tfa-tabs > label svg { width: 16px; height: 16px; }
.tfa-tabs > input:checked + label { background: var(--surface-hi); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2); }
.tfa-tabs > input:focus-visible + label { outline: 2px solid var(--accent); outline-offset: 1px; }
.tfa-pane { display: none; grid-column: 1 / -1; padding: 12px 8px 8px; text-align: center; }
.tfa-pane .hint { margin: 0 0 8px; }
#tfa-way-qr:checked ~ .tfa-pane-qr, #tfa-way-key:checked ~ .tfa-pane-key { display: block; }
.tfa-pane-key .tfa-secret { margin: 2px 0 10px; word-break: normal; overflow-wrap: normal; }
.tfa-pane-key .btn { max-width: 100%; white-space: normal; }
.tfa-tabs > label { white-space: nowrap; }
@media (max-width: 480px) {
  .tfa-modal-body { padding: 20px 18px 4px; }
  .tfa-modal .modal-actions { padding: 16px 18px 18px; }
  .tfa-tabs > label { padding: 8px 6px; font-size: 14px; }
  .tfa-pane { padding: 10px 4px 6px; }
}
#tfa-code { font-size: 20px; letter-spacing: 0.2em; text-align: center; }
.tfa-steps { margin: 0 0 14px; padding-left: 20px; display: grid; gap: 8px; color: var(--muted); line-height: 1.5; }
.tfa-secret { display: inline-block; margin: 6px 0; padding: 6px 10px; border-radius: 8px; background: var(--surface-2);
  color: var(--text); font-size: 15px; letter-spacing: 0.06em; user-select: all; word-break: break-all; }
