/* CP SCS — Design System v2.1 «Soft Dark» (rounded)
   Прототип: CP SCS Redesign v2.dc.html
   Мягкая тёмная тема с холодным сине-фиолетовым подтоном.
   Lavender — единственный брендовый цвет. */

/* ---- Токены ---- */
:root {
  color-scheme: dark;
  /* color */
  --bg: #0E0F14;
  --surface-1: #12131A;
  --surface-list: #14161F;
  --surface-2: #181A24;
  --surface-3: #1E2130;
  --surface-3-hover: #282B3C;
  --surface-nav-active: #2A2E42;
  --line: #20232F;
  --line-2: #262A38;
  --line-3: #33384A;
  --text: #EDEDF4;
  --text-body: #CBCEDC;
  --text-2: #A6AABD;
  --text-3: #8D91A6;
  --text-4: #6F7389;
  --primary: #B4A7FF;
  --primary-hover: #C7BCFF;
  --primary-ink: #16122B;
  --link: #C3B8FF;
  --link-hover: #DDD6FF;
  --success: #72D69E;
  --success-bg: rgba(114,214,158,.12);
  --warning: #EDC06A;
  --warning-bg: rgba(237,192,106,.12);
  --danger: #F59490;
  --danger-bg: rgba(245,148,144,.12);
  --danger-solid: #E0605C;
  --info: #7FD3E8;
  --info-bg: rgba(127,211,232,.11);
  --neutral: #A3A6AD;
  --neutral-bg: rgba(163,166,173,.11);
  /* team tags */
  --team-alpha: #7FB5FF;
  --team-bravo: #C39BF5;
  --team-delta: #F2A07F;
  --team-north: #6FD4B4;
  --team-ops2: #E3C46E;
  /* type */
  --font-sans: "Golos Text", ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --fs-11: 11px; --fs-115: 11.5px; --fs-12: 12px; --fs-125: 12.5px;
  --fs-13: 13px; --fs-135: 13.5px; --fs-15: 15px; --fs-20: 20px;
  --fs-24: 24px; --fs-28: 28px;
  /* spacing */
  --sp-1: 4px; --sp-2: 6px; --sp-3: 8px; --sp-4: 10px; --sp-5: 12px;
  --sp-6: 14px; --sp-7: 16px; --sp-8: 18px; --sp-9: 20px; --sp-10: 24px; --sp-11: 28px;
  /* radius */
  --r-3: 3px; --r-4: 4px; --r-5: 5px; --r-6: 6px; --r-8: 8px;
  --r-10: 10px; --r-12: 12px; --r-14: 14px; --r-16: 16px; --r-18: 18px;
  --r-22: 22px; --r-full: 999px;
  /* sizes */
  --h-row: 40px; --h-header: 32px; --h-control-26: 26px; --h-control-28: 28px;
  --h-control-30: 30px; --h-control-32: 32px; --h-control-34: 34px; --h-control-40: 40px;
  --h-touch: 44px; --h-topbar: 56px;
  /* gutter */
  --gutter: 24px;
  /* z-index */
  --z-menu: 30; --z-drawer: 40; --z-modal: 50; --z-toast: 60;
  /* elevation */
  --shadow-menu: 0 12px 32px rgba(0,0,0,.45);
  --shadow-modal: 0 20px 48px rgba(0,0,0,.5);
  --shadow-drawer: 0 0 40px rgba(0,0,0,.5);
  --overlay: rgba(5,6,8,.72);
  --backdrop: rgba(5,6,8,.64);
  /* motion */
  --hover-ms: 120ms; --switch-ms: 150ms; --drawer-ms: 200ms; --spinner-ms: 800ms; --skeleton-ms: 1.4s; --progress-ms: 1s;
}

@media (max-width: 1023px) { :root { --gutter: 20px; } }
@media (max-width: 767px) { :root { --gutter: 16px; } }

/* ---- Reset / base ---- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); font: var(--fs-13)/1.45 var(--font-sans); }
a { color: var(--link); text-decoration: none; }
a:hover { color: var(--link-hover); }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
[tabindex="-1"]:focus { outline: none; }
h1, h2, h3, p { margin: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: 8px; top: -48px; z-index: 100; padding: 8px 12px; border-radius: var(--r-12); background: var(--primary); color: var(--primary-ink); font-weight: 600; }
.skip-link:focus { top: 8px; }
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--font-mono); font-size: var(--fs-12); }
.sub { font-size: var(--fs-115); color: var(--text-3); }
.muted { color: var(--text-2); }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ta-r { text-align: right; }
.inline { display: inline-flex; align-items: center; gap: var(--sp-3); }
.inline.wrap { flex-wrap: wrap; }

/* ---- Icons (Material Symbols Outlined) ---- */
.ms { font-family: "Material Symbols Outlined"; font-weight: normal; font-style: normal; font-size: 20px; line-height: 1; letter-spacing: normal; text-transform: none; display: inline-block; white-space: nowrap; word-wrap: normal; direction: ltr; -webkit-font-smoothing: antialiased; }
.ms-sm { font-size: 16px; }
.ms-lg { font-size: 22px; }

/* ---- Buttons ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: var(--h-control-32); padding: 0 16px; border-radius: var(--r-full); border: 1px solid var(--line-3); background: var(--surface-3); color: var(--text); font: 500 var(--fs-125)/1 var(--font-sans); cursor: pointer; white-space: nowrap; transition: background var(--hover-ms), border-color var(--hover-ms); }
.btn:hover { background: var(--surface-3-hover); border-color: var(--line-3); }
.btn:disabled { opacity: .35; cursor: not-allowed; }
.btn[aria-busy="true"] { opacity: .8; cursor: progress; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); font-weight: 600; }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: var(--primary-ink); }
.btn-danger-outline { background: transparent; border-color: rgba(245,148,144,.45); color: var(--danger); }
.btn-danger-outline:hover { background: var(--danger-bg); border-color: var(--danger); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); }
.btn-sm { height: var(--h-control-28); padding: 0 12px; font-size: var(--fs-12); }
.btn-lg { height: var(--h-control-40); font-size: var(--fs-13); }
.btn-icon { width: var(--h-control-32); padding: 0; }
.btn-icon.btn-sm { width: var(--h-control-28); }
.btn-icon.btn-lg { width: var(--h-control-40); }
.spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin var(--spinner-ms) linear infinite; flex-shrink: 0; }
.spinner.sm { width: 12px; height: 12px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Fields ---- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.label { font-size: var(--fs-11); font-weight: 600; color: var(--text-3); letter-spacing: .06em; text-transform: uppercase; }
.input { height: var(--h-control-32); width: 100%; padding: 0 12px; border-radius: var(--r-12); border: 1px solid var(--line-3); background: var(--surface-2); color: var(--text); font: var(--fs-13) var(--font-sans); transition: border-color var(--hover-ms); }
.input::placeholder { color: var(--text-4); }
.input:hover { border-color: #4A4D55; }
.input:focus-visible { outline: 2px solid var(--primary); outline-offset: 0; border-color: var(--primary); }
.input.is-error { border-color: #F07470; }
.input:disabled { opacity: .75; }
select.input { padding-right: 28px; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238D91A6' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; }
.pw-wrap { position: relative; }
.pw-wrap .input { padding-right: 44px; }
.pw-toggle { position: absolute; right: 4px; top: 4px; width: 24px; height: 24px; border: 0; border-radius: var(--r-8); background: none; color: var(--text-3); display: flex; align-items: center; justify-content: center; cursor: pointer; }
.pw-toggle:hover { background: var(--surface-3); color: var(--text); }
.chk { display: inline-flex; align-items: center; gap: 8px; height: var(--h-control-32); padding: 0 12px; border: 1px solid var(--line-3); border-radius: var(--r-12); font-size: var(--fs-125); color: var(--text-2); cursor: pointer; white-space: nowrap; }
.chk input { accent-color: var(--primary); width: 15px; height: 15px; margin: 0; }
.field-label { font-size: var(--fs-11); font-weight: 600; color: var(--text-3); letter-spacing: .06em; text-transform: uppercase; }
.field-error { font-size: var(--fs-115); color: var(--danger); }
textarea.input { height: auto; min-height: 96px; padding: 8px 12px; resize: vertical; font-family: var(--font-mono); font-size: var(--fs-125); line-height: 1.5; }
.segmented { display: inline-flex; gap: 0; border: 1px solid var(--line-3); border-radius: var(--r-full); overflow: hidden; align-self: flex-start; }
.seg-btn { appearance: none; border: 0; background: var(--surface-2); color: var(--text-2); font: 600 var(--fs-125) var(--font-sans); padding: 0 14px; height: 30px; cursor: pointer; }
.seg-btn + .seg-btn { border-left: 1px solid var(--line-3); }
.seg-btn:hover { background: var(--surface-3); color: var(--text); }
.seg-btn.seg-active { background: var(--primary); color: var(--primary-ink); }
.bulk-report { display: flex; flex-direction: column; gap: 4px; max-height: 240px; overflow-y: auto; border: 1px solid var(--line-3); border-radius: var(--r-12); padding: 8px 12px; background: var(--surface-2); }
.bulk-report-row { font-size: var(--fs-125); color: var(--text-2); }
.otp-code { font-family: var(--font-mono); font-size: 1.05em; font-weight: 700; letter-spacing: .08em; padding: 1px 7px; border-radius: var(--r-8); border: 1px solid var(--line-3); background: var(--surface-2); color: var(--text); cursor: copy; user-select: all; transition: border-color var(--hover-ms), background var(--hover-ms); }
.otp-code:hover { border-color: var(--primary); background: var(--primary); color: var(--primary-ink); }
.otp-code:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.otp-code.copied { border-color: var(--success); background: var(--success); color: var(--bg); }

/* ---- Badges ---- */
.badge { display: inline-flex; align-items: center; gap: 5px; height: 20px; padding: 0 8px; border-radius: var(--r-3); font-size: var(--fs-115); font-weight: 500; white-space: nowrap; border: 1px solid transparent; }
.badge::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.t-success { color: var(--success); background: var(--success-bg); border-color: rgba(114,214,158,.24); }
.t-warning { color: var(--warning); background: var(--warning-bg); border-color: rgba(237,192,106,.24); }
.t-danger { color: var(--danger); background: var(--danger-bg); border-color: rgba(245,148,144,.26); }
.t-info { color: var(--info); background: var(--info-bg); border-color: rgba(127,211,232,.24); }
.t-neutral { color: var(--neutral); background: var(--neutral-bg); border-color: var(--line-3); }
.chip { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: var(--r-8); background: var(--surface-3); border: 1px solid var(--line-3); font: 500 var(--fs-115) var(--font-mono); color: var(--text-2); }
.count { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: var(--r-full); background: var(--primary); color: var(--primary-ink); font-size: 11px; font-weight: 600; }
/* Team tag badges */
.badge.t-team-alpha { color: var(--team-alpha); background: rgba(127,181,255,.12); border-color: rgba(127,181,255,.35); }
.badge.t-team-bravo { color: var(--team-bravo); background: rgba(195,155,245,.12); border-color: rgba(195,155,245,.35); }
.badge.t-team-delta { color: var(--team-delta); background: rgba(242,160,127,.12); border-color: rgba(242,160,127,.35); }
.badge.t-team-north { color: var(--team-north); background: rgba(111,212,180,.12); border-color: rgba(111,212,180,.35); }
.badge.t-team-ops2 { color: var(--team-ops2); background: rgba(227,196,110,.12); border-color: rgba(227,196,110,.35); }
.team-tag-badge { font-size: 10px; }
.team-tag-none { opacity: .6; }

/* ---- Switch ---- */
.switch { position: relative; width: 28px; height: 16px; border-radius: var(--r-full); border: 1px solid var(--line-3); background: #2C2E33; padding: 0; cursor: pointer; flex-shrink: 0; transition: background var(--switch-ms), border-color var(--switch-ms); }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 10px; height: 10px; border-radius: 50%; background: var(--text-3); transition: transform var(--switch-ms), background var(--switch-ms); }
.switch.on { background: var(--primary); border-color: var(--primary); }
.switch.on::after { transform: translateX(12px); background: var(--primary-ink); }
.switch:hover:not(:disabled) { border-color: #4A4D55; }
.switch:disabled { opacity: .45; cursor: not-allowed; }
.switch.busy { opacity: .55; cursor: progress; }

/* Clean opt-in table: reuse Soft Dark tokens, never alter legacy row layout. */
.clean-table-wrap { overflow-x: auto; border: 1px solid var(--line-2); border-radius: var(--r-14); background: var(--surface-1); }
.clean-account-table { width: 100%; min-width: 1100px; border-collapse: collapse; text-align: left; }
.clean-account-table th, .clean-account-table td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.clean-account-table th { color: var(--text-3); font-weight: 500; }
.clean-account-table td .toolbar-actions { flex-wrap: wrap; }
.clean-account-table .sub { overflow-wrap: anywhere; }

/* ---- Surfaces ---- */
.card { background: var(--surface-1); border: 1px solid var(--line-2); border-radius: var(--r-14); min-width: 0; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); padding: 12px 16px; border-bottom: 1px solid var(--line); }
.card-h h2 { font-size: var(--fs-135); font-weight: 600; }
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: var(--r-10); border: 1px solid; font-size: var(--fs-125); }
.alert > .ms { margin-top: 1px; }
.alert-body { flex-grow: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.alert-body strong { font-weight: 600; }
.alert-info { border-color: rgba(127,211,232,.35); background: var(--info-bg); color: #CDEAF3; }
.alert-success { border-color: rgba(114,214,158,.35); background: var(--success-bg); color: #CFF0DF; }
.alert-warning { border-color: rgba(237,192,106,.35); background: var(--warning-bg); color: #F5DEB5; }
.alert-danger { border-color: rgba(245,148,144,.35); background: var(--danger-bg); color: #F2D3D2; }
.alert-neutral { border-color: rgba(163,166,173,.25); background: var(--neutral-bg); color: #B0B7C3; }
.skel { display: inline-block; background: var(--surface-3); border-radius: 4px; animation: pulse var(--skeleton-ms) ease-in-out infinite; max-width: 100%; }
.skel.pill { border-radius: var(--r-full); }
@keyframes pulse { 50% { opacity: .45; } }
.empty { padding: 48px 24px; display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; }
.empty-title { font-size: var(--fs-15); font-weight: 600; }
.empty .muted { font-size: var(--fs-125); max-width: 420px; }
.empty .btn { margin-top: 8px; }

/* ---- Brand ---- */
.brand { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 0 8px; }
.brand-mark { width: 28px; height: 28px; border-radius: 8px; background: var(--primary); color: var(--primary-ink); display: flex; align-items: center; justify-content: center; font: 700 11px var(--font-mono); flex-shrink: 0; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-name { font-weight: 600; font-size: var(--fs-13); }
.brand-sub { font-size: 11px; color: var(--text-3); }

/* ---- Shell: top-bar (all screen sizes) ---- */
.shell { display: flex; min-height: 100vh; }
.topbar { height: var(--h-topbar); display: flex; align-items: center; gap: var(--sp-4); padding: 0 var(--gutter); border-bottom: 1px solid var(--line); position: sticky; top: 0; background: rgba(14,15,20,.96); backdrop-filter: blur(8px); z-index: 20; }
.topbar-nav { display: flex; align-items: center; gap: 2px; background: #151720; border-radius: var(--r-full); padding: 2px; flex-wrap: wrap; }
.topbar-nav .nav-item { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 14px; border-radius: var(--r-full); color: var(--text-2); font: 500 var(--fs-125) var(--font-sans); text-decoration: none; transition: color var(--hover-ms), background var(--hover-ms); }
.topbar-nav .nav-item:hover { color: var(--text); }
.topbar-nav .nav-item.active { color: var(--text); background: var(--surface-nav-active); }
.topbar-nav .nav-item .ms { font-size: 18px; }
.nav-divider { width: 1px; height: 20px; background: var(--line-3); margin: 0 6px; }
.main-col { flex-grow: 1; min-width: 0; display: flex; flex-direction: column; }
.main { flex-grow: 1; padding: 20px var(--gutter) 32px; min-width: 0; }
.page { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.page-title { font-size: var(--fs-20); font-weight: 600; }
.page-title-lg { font-size: var(--fs-24); font-weight: 600; }

/* user menu — full button in top-right corner */
.user-menu, .card-menu { position: relative; }
.user-menu { margin-left: auto; }
.user-btn { height: 44px; gap: 10px; padding: 0 8px 0 6px; }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--surface-3); border: 1px solid var(--line-3); display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 600; color: var(--text); }
.user-meta { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.25; }
.user-name { font-size: var(--fs-125); color: var(--text); }
.user-role { font-size: 11px; color: var(--text-3); }
.menu { position: absolute; right: 0; top: calc(100% + 6px); width: 220px; background: var(--surface-2); border: 1px solid var(--line-3); border-radius: var(--r-14); padding: 6px; z-index: var(--z-menu); box-shadow: var(--shadow-menu); }
.menu-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 36px; padding: 0 10px; border-radius: var(--r-8); color: var(--text); text-decoration: none; font: var(--fs-125) var(--font-sans); background: none; border: 0; cursor: pointer; text-align: left; }
.menu-item:hover:not(:disabled) { background: var(--surface-3); color: var(--text); }
.menu-item:disabled { color: var(--text-3); cursor: not-allowed; }

/* demo panel */
.demo { margin-top: auto; border: 1px dashed rgba(237,192,106,.45); background: rgba(237,192,106,.04); border-radius: var(--r-12); padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.demo .label { font-size: 11px; }
.demo .input { height: 30px; font-size: var(--fs-12); }
.demo-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.demo-head .btn { padding: 0 6px; font-size: 11px; height: 24px; }
.demo-title { white-space: nowrap; font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--warning); }
.demo-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.demo-actions .btn { white-space: normal; height: auto; min-height: var(--h-control-28); padding: 6px 10px; text-align: left; line-height: 1.2; }
.seg { display: flex; padding: 2px; border-radius: var(--r-8); background: var(--bg); border: 1px solid var(--line); }
.seg button { flex: 1; height: 26px; border: 0; border-radius: 6px; background: none; color: var(--text-2); font: 500 var(--fs-12) var(--font-sans); cursor: pointer; }
.seg button.on { background: var(--surface-3); color: var(--text); }
.demo-creds { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.demo-creds li { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.demo-creds li .btn { margin-left: auto; }

/* ---- Login ---- */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 32px 16px; }
.login-wrap { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 20px; }
.login-card { padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.login-title { font-size: var(--fs-20); font-weight: 600; }

/* ---- Accounts list ---- */
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.tile { padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; }
.tile-label { font-size: var(--fs-125); color: var(--text-3); }
.tile-value { font-size: var(--fs-24); font-weight: 600; }
.tone-warning { color: var(--warning); }
.filters { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.search-select { position: relative; min-width: 0; width: 100%; }
.search-select > .input { padding-right: 28px; text-overflow: ellipsis; background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%); background-position: calc(100% - 16px) 14px, calc(100% - 12px) 14px; background-size: 4px 4px; background-repeat: no-repeat; }
.search-select > .input[aria-expanded="true"] { border-color: var(--text-3); }
.search-select > [role="status"] { position: absolute; top: calc(100% + 2px); font-size: var(--fs-11); z-index: 1; }
.filters > .search-select, .filters-extra > .search-select { width: 180px; flex: 0 1 180px; }
.live-accounts-page > .filters { align-items: center; min-height: var(--h-control-32); }
.live-accounts-page > .filters > .search-select > .input, .live-accounts-page > .filters .btn, .live-accounts-page > .filters .search > .input { height: var(--h-control-32); }
.live-team-control > .search-select { flex: 1 1 0; width: 0; }
.live-card > .search-select { width: 100%; }
.live-team-select > .input, .live-card-select > .input { height: var(--h-control-28); padding-left: 8px; font-size: var(--fs-12); background-position: calc(100% - 16px) 12px, calc(100% - 12px) 12px; }
.tag-search-options { position: fixed; z-index: calc(var(--z-modal, 100) + 10); max-height: 260px; overflow-y: auto; overscroll-behavior: contain; padding: 4px; border: 1px solid var(--line-3); border-radius: var(--r-12); background: var(--surface-2); box-shadow: var(--shadow-modal); }
.tag-search-options[hidden] { display: none; }
.tag-search-option { padding: 8px 10px; cursor: pointer; border-radius: 6px; overflow-wrap: anywhere; }
.tag-search-option.active, .tag-search-option:hover { background: var(--surface-3); }
.tag-search-option[aria-selected="true"] { font-weight: 600; }
.tag-search-option[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }
@media (max-width: 767px) {
  .filters > .search-select { flex: 1 1 140px; width: auto; }
  .filters-extra > .search-select { width: 100%; flex: none; }
  .live-accounts-page > .filters > .search-select > .input, .live-accounts-page > .filters .btn, .live-accounts-page > .filters .search > .input { height: var(--h-touch); }
}
.search { position: relative; flex: 1 1 240px; max-width: 360px; }
.search-compact { flex: 0 1 280px; max-width: 280px; }
.search .input { padding-left: 34px; }
.search-ic { position: absolute; left: 11px; top: 10px; color: var(--text-3); }
.filters-extra { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.filters-extra[hidden] { display: none; }
.filters-extra .field { width: auto; }
.filters-extra select.input { width: auto; min-width: 160px; }
.toolbar-actions { display: flex; gap: 8px; margin-left: auto; }
.results { display: flex; align-items: center; gap: 12px; min-height: 28px; font-size: var(--fs-125); color: var(--text-2); }
.is-stale .bal time, .is-stale .bal .amount { opacity: .7; }

/* table */
.table { overflow: hidden; }
.tr { display: grid; align-items: center; column-gap: 16px; padding: 0 16px; }
.tr.admin { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) minmax(200px, 1.1fr) minmax(0, 1fr) 96px 104px; }
.tr.op { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1.1fr) minmax(200px, 1.1fr) minmax(0, 1.1fr) 104px; }
.th { min-height: var(--h-header); font-size: var(--fs-11); font-weight: 600; color: var(--text-3); letter-spacing: .06em; text-transform: uppercase; border-bottom: 1px solid var(--line); }
.td-row { min-height: 62px; padding-top: 10px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.td-row:last-child { border-bottom: 0; }
.td-row:hover { background: var(--surface-1); }
.cell-acc { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cell-stack { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; min-width: 0; }
.acc-link { color: var(--text); font-weight: 600; text-decoration: none; }
.acc-link:hover { color: var(--link-hover); text-decoration: underline; }
.row-actions { display: flex; justify-content: flex-end; gap: 4px; }
.parse-ctl { display: flex; align-items: center; gap: 8px; flex-wrap: nowrap; }
.bal { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.amount { font-weight: 600; }
.amount .cur { color: var(--text-3); font-weight: 500; }
.amount-big { font-size: var(--fs-28); letter-spacing: -.01em; font-family: var(--font-mono); }
.amount-big .cur { font-size: 18px; }
.bal-none { color: var(--text-2); }
.stale { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-115); color: var(--warning); }
.bal time.sub, .bal .sub { font-size: var(--fs-115); }

/* mobile cards */
.m-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.m-card { background: var(--surface-1); border: 1px solid var(--line-2); border-radius: var(--r-14); padding: 14px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.m-card-top { display: flex; justify-content: space-between; gap: 12px; }
.m-card-top .bal { align-items: flex-end; }
.m-name { font-size: var(--fs-15); }
.m-badges { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.m-actions { display: flex; gap: 8px; }
.m-actions .btn { height: var(--h-touch); }
.m-actions .btn-icon { width: var(--h-touch); }
.m-open { flex-grow: 1; }

/* ---- Live account list (compact rows) ---- */
/* The document owns vertical scrolling; this frame only scrolls horizontally.
   Never shrink the flex child into a second vertical viewport. */
.live-accounts-page > .live-account-list { flex: 0 0 auto; height: auto; max-height: none; overflow-y: hidden; }
.live-account-list { border: 1px solid var(--line-2); border-radius: var(--r-14); overflow-x: auto; background: var(--surface-list); }
/* Identical explicit tracks in every row; no auto/min-content action column.
   Narrow viewports scroll the list instead of rearranging individual accounts. */
.live-account-row { display: grid; grid-template-columns: minmax(150px, 1.4fr) 88px minmax(108px, .8fr) minmax(150px, 1.1fr) minmax(140px, 1fr) 72px 72px 340px; gap: 10px; align-items: center; padding: 4px 12px; min-width: 1314px; border-bottom: 1px solid var(--line); }
.live-account-row > * { min-width: 0; }
.live-identity .acc-link, .live-card > .sub, .live-team > .sub, .live-auto > .sub { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.live-card-select, .live-team-select { min-width: 0; max-width: 100%; }
.live-account-row:last-child { border-bottom: 0; }
.live-account-row:hover { background: var(--surface-1); }
.live-identity { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.live-title-line { display: flex; align-items: center; gap: 6px; min-width: 0; }
.live-title-line .acc-link { flex: 1 1 auto; min-width: 0; }
.live-renewal-badge { flex: 0 0 auto; max-width: 78px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 4px 6px; border: 1px solid var(--line); border-radius: var(--r-8); background: var(--surface-1); color: var(--text-3); font-family: var(--font-mono); font-size: 11px; line-height: 1.25; font-variant-numeric: tabular-nums; }
.live-login { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.live-card-select, .live-team-select { width: 100%; min-height: 28px; padding: 3px 6px; font-size: var(--fs-12); border-radius: var(--r-8); }
.live-auto { display: flex; flex-direction: column; align-items: center; gap: 1px; }
.live-auto-hint { max-width: 96px; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.live-balance { text-align: left; justify-self: start; font-weight: 600; white-space: nowrap; font-family: var(--font-mono); }
.live-balance-box { display: flex; align-items: center; justify-content: center; justify-self: stretch; padding: 4px 10px; background: var(--surface-2); border: 1px solid var(--line-2); border-radius: var(--r-8); font-weight: 600; white-space: nowrap; font-family: var(--font-mono); min-width: 0; }
.live-balance-box .cell-stack { min-width: 0; max-width: 100%; }
.live-balance-box .num { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.live-balance-box .cell-stack { gap: 0; }
.live-balance-box .num { font-size: var(--fs-125); }
.live-status-line { display: flex; flex-wrap: nowrap; gap: 4px; align-items: center; }
.live-status-line .badge { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.live-team { gap: 2px; }
.live-team-control { display: flex; align-items: stretch; gap: 2px; width: 100%; border-radius: var(--r-8); }
.live-team-control .live-team-select { flex: 1; min-width: 0; }
.team-drag-handle { flex: 0 0 14px; width: 14px; min-height: 28px; padding: 0; border: 1px solid var(--line-2); border-radius: 4px; background: var(--surface-2); color: var(--text-3); font-size: 14px; cursor: grab; touch-action: none; user-select: none; }
.team-drag-handle:hover:not(:disabled) { color: var(--text); border-color: var(--text-3); }
.team-drag-handle:disabled { opacity: .45; cursor: not-allowed; }
.team-brush-active, .team-brush-active * { cursor: grabbing !important; user-select: none; }
.team-brush-active .team-drag-handle { color: var(--primary); }
.live-team-control.team-drop-hover, .live-team-control.team-brush-selected { outline: 2px solid var(--primary); outline-offset: 2px; background: var(--surface-2); }
.team-brush-status { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 40; max-width: calc(100vw - 32px); padding: 8px 12px; border: 1px solid var(--primary); border-radius: var(--r-8); background: var(--surface-2); color: var(--text); font-size: var(--fs-12); pointer-events: none; }
.live-row-message { grid-column: 1 / -1; }
.live-account-row .badge { font-size: 11px; padding: 2px 6px; }
.live-account-row .cell-stack { gap: 2px; }
.live-account-row .sub { font-size: 11px; }
.live-account-row .toolbar-actions { gap: 4px; margin-left: 0; flex-wrap: nowrap; }
.live-account-row .toolbar-actions > * { flex-shrink: 0; }
/* Override mobile toolbar stretching: rows remain a horizontally scrollable grid. */
.live-account-row .toolbar-actions .btn { flex: 0 0 auto; height: var(--h-control-28); }
.live-account-row .toolbar-actions .btn-icon { width: var(--h-control-28); }
.live-clean-details { overflow-wrap: anywhere; }
.btn.clean-state-busy { color: var(--primary); border-color: var(--primary); }
.btn.clean-state-warning { color: var(--warning); border-color: var(--warning); }
.btn.clean-state-success { color: var(--success); border-color: var(--success); }
.btn.clean-state-danger { color: var(--danger); border-color: var(--danger); }
.live-clean-details .btn { align-self: flex-start; }
.live-login-action { position: relative; display: inline-flex; border-radius: var(--r-8); }
.live-login-action:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.live-login-action::after { content: attr(data-tooltip); position: absolute; z-index: 30; top: 100%; right: 0; width: 280px; padding: 8px 10px; border: 1px solid var(--line-2); border-radius: var(--r-8); background: var(--surface-2); color: var(--text); font-size: var(--fs-12); line-height: 1.4; white-space: normal; pointer-events: none; visibility: hidden; }
.live-login-action:hover::after, .live-login-action:focus-within::after { visibility: visible; }

/* ---- Account page ---- */
.acc-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.acc-title { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.acc-title-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.acc-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: thin; }
.tab { display: inline-flex; align-items: center; min-height: 40px; padding: 0 12px; border-bottom: 2px solid transparent; margin-bottom: -1px; color: var(--text-2); font: 500 var(--fs-125) var(--font-sans); text-decoration: none; white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--primary); }
.overview { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.overview .col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.sk-card { padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.fin-top { padding: 18px 18px 4px; display: flex; flex-direction: column; gap: 6px; }
.fin-top .k, .kv dt { color: var(--text-3); font-size: var(--fs-115); }
.kv { display: grid; grid-template-columns: minmax(140px, 200px) minmax(0, 1fr); gap: 12px 16px; font-size: var(--fs-125); align-items: center; padding: 16px 18px; margin: 0; }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.pos { font-weight: 600; color: var(--success); }
.ctrl { display: flex; gap: 16px; align-items: flex-start; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.ctrl:last-child { border-bottom: 0; }
.ctrl-col { flex-direction: column; align-items: stretch; gap: 12px; }
.ctrl-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.ctrl-text { display: flex; flex-direction: column; gap: 4px; max-width: 480px; min-width: 0; }
.ctrl-text .sub { font-size: var(--fs-125); }
.ctrl-title { font-weight: 600; }
.ctrl-alert { padding: 12px 18px; border-bottom: 1px solid var(--line); }
.status-line { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-125); color: var(--text-2); }
.status-line.info { color: var(--info); }
.status-line.warn { color: var(--warning); }
.stepper-box { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; padding: 12px; border-radius: var(--r-12); background: var(--bg); border: 1px solid var(--line); }
.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px 16px; }
.step { display: flex; align-items: center; gap: 6px; font-size: var(--fs-115); color: var(--text-3); white-space: nowrap; }
.step .dot { width: 20px; height: 20px; border-radius: 50%; border: 1.5px solid var(--line-3); display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 600; }
.step.done { color: var(--text-2); }
.step.done .dot { background: var(--success); border-color: var(--success); color: var(--bg); }
.step.current { color: var(--text); }
.step.current .dot { border-color: var(--primary); color: var(--primary); box-shadow: 0 0 0 3px rgba(180,167,255,.14); }
.step.fail { color: var(--danger); }
.step.fail .dot { border-color: var(--danger); color: var(--danger); background: var(--danger-bg); }
.stepper-box .sub { font-size: var(--fs-125); }

/* activity */
.activity { list-style: none; margin: 0; padding: 0; }
.ev { display: grid; grid-template-columns: 130px 150px minmax(0, 1fr) 110px; gap: 16px; padding: 12px 18px; border-bottom: 1px solid var(--line); align-items: start; font-size: var(--fs-125); }
.ev:last-child { border-bottom: 0; }
.ev-time { color: var(--text-2); }
.ev-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ev-main .sub { font-size: var(--fs-115); }
.ev-action { font-weight: 500; }
.sk-list .ev { align-items: center; }

/* ---- Modal & toasts ---- */
.overlay { position: fixed; inset: 0; background: var(--overlay); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: var(--z-modal); overflow-y: auto; }
.modal { width: 460px; max-width: 100%; max-height: calc(100vh - 32px); overflow-y: auto; background: var(--surface-2); border: 1px solid var(--line-3); border-radius: var(--r-18); box-shadow: var(--shadow-modal); }
.modal-body { padding: 20px 20px 0; display: flex; flex-direction: column; gap: 10px; }
.modal-title { font-size: 17px; font-weight: 600; }
.modal-desc { color: var(--text-body); font-size: var(--fs-13); }
.modal-note { padding: 10px 12px; border-radius: var(--r-12); border: 1px solid var(--line-3); background: var(--surface-3); color: var(--text-2); font-size: var(--fs-115); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 20px; }
.toasts { position: fixed; right: 24px; bottom: 24px; z-index: var(--z-toast); display: flex; flex-direction: column; gap: 8px; align-items: flex-end; pointer-events: none; }
.toast { pointer-events: auto; display: flex; gap: 10px; align-items: center; width: 360px; max-width: calc(100vw - 32px); padding: 10px 10px 10px 14px; border-radius: var(--r-14); background: var(--surface-3); border: 1px solid var(--line-3); box-shadow: var(--shadow-menu); font-size: var(--fs-125); }
.toast .badge { flex-shrink: 0; }
.toast-text { flex-grow: 1; min-width: 0; }

/* ---- Operators list ---- */
.op-list { border: 1px solid var(--line-2); border-radius: var(--r-14); background: var(--surface-1); overflow-x: auto; }
.op-row { display: grid; grid-template-columns: minmax(160px, 1.4fr) 130px 90px minmax(150px, 1fr) minmax(200px, auto); gap: 12px; align-items: center; padding: 8px 14px; min-width: 760px; border-bottom: 1px solid var(--line); }
.op-row:last-child { border-bottom: 0; }
.op-row:hover { background: var(--surface-2); }
.op-id { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.op-name { font-weight: 600; }

/* ---- Responsive ---- */
@media (max-width: 1279px) {
  .overview { grid-template-columns: minmax(0, 1fr); }
  .tr.admin { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) minmax(190px, 1fr) minmax(0, 1fr) 88px 104px; column-gap: 12px; }
}
@media (max-width: 1023px) {
  :root { --gutter: 20px; }
  .topbar { padding: 0 12px; gap: 4px; flex-wrap: wrap; height: auto; min-height: var(--h-topbar); padding-top: 8px; padding-bottom: 8px; }
  .topbar-nav { order: 2; width: 100%; justify-content: center; }
  .topbar-title { order: 1; }
  .user-menu { order: 1; margin-left: auto; }
}
@media (max-width: 767px) {
  :root { --gutter: 16px; }
  .main { padding-top: 16px; }
  .tiles { gap: 8px; }
  .tile { padding: 10px 12px; }
  .tile-label { font-size: var(--fs-115); }
  .tile-value { font-size: var(--fs-20); }
  .search { max-width: none; flex-basis: 100%; }
  .filters > .btn { height: var(--h-touch); }
  .filters-extra { flex-basis: 100%; flex-direction: column; align-items: stretch; }
  .filters-extra select.input { width: 100%; height: var(--h-touch); }
  .chk { height: var(--h-touch); }
  .toolbar-actions { margin-left: 0; flex-basis: 100%; }
  .toolbar-actions .btn { flex: 1; height: var(--h-touch); }
  .m-list { grid-template-columns: minmax(0, 1fr); }
  .user-meta { display: none; }
  .acc-actions { width: 100%; }
  .acc-actions > .btn { flex-grow: 1; height: var(--h-touch); }
  .page-title-lg { font-size: var(--fs-20); }
  .kv { grid-template-columns: minmax(0, 1fr); gap: 2px 0; }
  .kv dd { margin-bottom: 10px; }
  .ctrl, .ctrl-row { flex-wrap: wrap; }
  .ctrl-row > .btn { height: var(--h-touch); }
  .ev { grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; }
  .ev-time { grid-column: 1; }
  .ev-result { grid-column: 2; grid-row: 1; }
  .ev-actor, .ev-main { grid-column: 1 / -1; }
  .overlay { align-items: flex-end; padding: 12px; }
  .modal-actions { flex-direction: column-reverse; }
  .modal-actions .btn { height: var(--h-touch); width: 100%; }
  .toasts { right: 16px; left: 16px; bottom: 16px; align-items: stretch; }
  .toast { width: auto; max-width: none; }
  .amount-big { font-size: 26px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  .spinner { animation: none; border-right-color: currentColor; opacity: .6; }
  .skel { animation: none; }
}
