/* =====================================================================
   Casa Portfolio — design system
   Majorelle blue accent, zellige star motif, dark-first.
   ===================================================================== */

:root {
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --r-xl: 22px;
  --r-lg: 18px;
  --r: 14px;
  --r-sm: 10px;
  --sidebar: 252px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --zellige-dark: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='46' height='46'%3E%3Cg fill='none' stroke='%23fff' stroke-width='1'%3E%3Crect x='15' y='15' width='16' height='16'/%3E%3Crect x='15' y='15' width='16' height='16' transform='rotate(45 23 23)'/%3E%3C/g%3E%3C/svg%3E");
  --zellige-light: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='46' height='46'%3E%3Cg fill='none' stroke='%235b4cf0' stroke-width='1'%3E%3Crect x='15' y='15' width='16' height='16'/%3E%3Crect x='15' y='15' width='16' height='16' transform='rotate(45 23 23)'/%3E%3C/g%3E%3C/svg%3E");
}

/* ---------- dark (default) ---------- */
:root, :root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #07090e;
  --side: #0a0d14;
  --card: #0f131c;
  --card-2: #151a25;
  --card-3: #1c2230;
  --hover: rgba(255, 255, 255, .04);
  --border: rgba(255, 255, 255, .07);
  --border-2: rgba(255, 255, 255, .11);
  --border-3: rgba(255, 255, 255, .18);
  --text: #eef1f7;
  --text-2: #a4acbe;
  --muted: #6d758a;
  --accent: #7c6cff;
  --accent-2: #3b82f6;
  --accent-soft: rgba(124, 108, 255, .15);
  --accent-shadow: rgba(124, 108, 255, .55);
  --up: #34d399;
  --up-bg: rgba(52, 211, 153, .12);
  --up-flash: rgba(52, 211, 153, .35);
  --down: #fb7185;
  --down-bg: rgba(251, 113, 133, .12);
  --down-flash: rgba(251, 113, 133, .35);
  --warn: #fbbf24;
  --warn-bg: rgba(251, 191, 36, .12);
  --grid: rgba(255, 255, 255, .05);
  --shadow: 0 1px 0 rgba(255, 255, 255, .03) inset, 0 12px 32px -12px rgba(0, 0, 0, .6);
  --shadow-lg: 0 30px 80px -20px rgba(0, 0, 0, .75);
  --glow: radial-gradient(900px 520px at 12% -10%, rgba(124, 108, 255, .16), transparent 62%),
          radial-gradient(760px 460px at 96% -4%, rgba(59, 130, 246, .10), transparent 60%);
  --zellige: var(--zellige-dark);
  --pattern-o: .07;
  --tabbar: rgba(10, 13, 20, .94);
}

/* ---------- light ---------- */
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f5f9;
  --side: #ffffff;
  --card: #ffffff;
  --card-2: #f6f7fb;
  --card-3: #eceef4;
  --hover: rgba(15, 23, 42, .035);
  --border: rgba(15, 23, 42, .07);
  --border-2: rgba(15, 23, 42, .11);
  --border-3: rgba(15, 23, 42, .2);
  --text: #0f172a;
  --text-2: #475569;
  --muted: #8a94a8;
  --accent: #5b4cf0;
  --accent-2: #2563eb;
  --accent-soft: rgba(91, 76, 240, .10);
  --accent-shadow: rgba(91, 76, 240, .45);
  --up: #047857;
  --up-bg: rgba(5, 150, 105, .10);
  --up-flash: rgba(5, 150, 105, .25);
  --down: #e11d48;
  --down-bg: rgba(225, 29, 72, .08);
  --down-flash: rgba(225, 29, 72, .22);
  --warn: #b45309;
  --warn-bg: rgba(245, 158, 11, .14);
  --grid: rgba(15, 23, 42, .06);
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 10px 30px -14px rgba(15, 23, 42, .12);
  --shadow-lg: 0 30px 80px -24px rgba(15, 23, 42, .35);
  --glow: radial-gradient(900px 520px at 12% -10%, rgba(91, 76, 240, .10), transparent 62%),
          radial-gradient(760px 460px at 96% -4%, rgba(37, 99, 235, .07), transparent 60%);
  --zellige: var(--zellige-light);
  --pattern-o: .09;
  --tabbar: rgba(255, 255, 255, .95);
}

/* ---------- 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: 14px/1.5 var(--font);
  font-feature-settings: "cv11", "ss01", "ss03";
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
body::before { content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none; background: var(--glow); }
button, input, select, textarea { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, p { margin: 0; }
img { display: block; }
kbd {
  font: 600 10.5px/1 var(--font); padding: 4px 6px; border-radius: 6px;
  border: 1px solid var(--border-2); background: var(--card-2); color: var(--muted);
}
.ic { width: 18px; height: 18px; flex: none; display: block; }
[data-icon] { display: contents; }
.hidden { display: none !important; }
.grow { flex: 1; }
.num { font-variant-numeric: tabular-nums; }
.up { color: var(--up); }
.down { color: var(--down); }
.flat { color: var(--text-2); }
.muted { color: var(--muted); }
.sub { color: var(--text-2); }
.small { font-size: 12px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::selection { background: var(--accent-soft); }

/* ---------- app shell ---------- */
.app { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh; transition: grid-template-columns .22s var(--ease); }
.sidebar {
  position: sticky; top: 0; height: 100vh; height: 100dvh; display: flex; flex-direction: column; gap: 22px;
  padding: 22px 14px 18px; background: var(--side); border-right: 1px solid var(--border);
  overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--border-2) transparent;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 2px 8px; color: var(--text); text-decoration: none !important; }
.brand img { border-radius: 10px; box-shadow: 0 8px 20px -8px var(--accent-shadow); }
.brand-name { font-size: 16.5px; font-weight: 700; letter-spacing: -.02em; }
.brand-name b {
  font-weight: 800; margin-left: 3px;
  background: linear-gradient(120deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.nav { display: grid; gap: 3px; }
.nav-label { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: 0 12px 6px; }
.nav-btn {
  position: relative; display: flex; align-items: center; gap: 12px; height: 42px; padding: 0 12px;
  border: 0; border-radius: 12px; background: none; color: var(--text-2); font-weight: 550; font-size: 14px;
  cursor: pointer; text-align: left; width: 100%; text-decoration: none !important;
  transition: background .15s, color .15s;
}
.nav-btn:hover { background: var(--hover); color: var(--text); }
.nav-btn[aria-current="page"] { background: var(--accent-soft); color: var(--text); }
.nav-btn[aria-current="page"]::before {
  content: ""; position: absolute; left: -14px; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0;
  background: linear-gradient(var(--accent), var(--accent-2));
}
.nav-btn[aria-current="page"] .ic { color: var(--accent); }
.nav-btn .badge {
  margin-left: auto; min-width: 22px; height: 20px; padding: 0 6px; border-radius: 99px; display: grid; place-items: center;
  font-size: 11px; font-weight: 700; background: var(--card-3); color: var(--text-2);
}
.nav-btn .badge.hot { background: var(--accent); color: #fff; }
.side-foot { margin-top: auto; display: grid; gap: 12px; }
.side-actions { display: grid; gap: 2px; }
.side-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.side-toggle { color: var(--muted); flex: none; }
.market-mini {
  display: none; justify-items: center; gap: 6px; padding: 10px 2px; border-radius: 14px;
  background: var(--card); border: 1px solid var(--border); font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums;
}

.market-card {
  position: relative; overflow: hidden; padding: 14px 14px 12px; border-radius: 16px;
  background: linear-gradient(160deg, var(--card-2), var(--card)); border: 1px solid var(--border);
}
.market-card::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; background-image: var(--zellige);
  opacity: var(--pattern-o); -webkit-mask-image: linear-gradient(200deg, #000, transparent 70%); mask-image: linear-gradient(200deg, #000, transparent 70%);
}
.mk-head { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; color: var(--text-2); }
.mk-idx { display: flex; align-items: baseline; gap: 8px; margin-top: 10px; }
.mk-idx span:first-child { font-size: 11px; font-weight: 700; letter-spacing: .06em; color: var(--muted); }
.mk-idx > span:last-child { white-space: nowrap; }
.mk-idx b { font-size: 18px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.mk-foot { margin-top: 6px; font-size: 11.5px; color: var(--muted); }
.pulse { position: relative; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.pulse.on { background: var(--up); }
.pulse.on::after { content: ""; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid var(--up); animation: ping 1.8s var(--ease) infinite; }
@keyframes ping { from { transform: scale(.5); opacity: .9; } to { transform: scale(1.6); opacity: 0; } }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 16px;
  padding: 20px 36px 16px; background: linear-gradient(var(--bg) 72%, transparent);
}
.page-title { min-width: 0; flex: 1 1 auto; }
.page-title h1 { font-size: 24px; font-weight: 750; letter-spacing: -.03em; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.page-title h1 .t-short { display: none; }
.acct-name { width: 150px; }
.page-title p { font-size: 13px; color: var(--text-2); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.search-btn {
  display: flex; align-items: center; gap: 10px; height: 40px; min-width: 260px; padding: 0 8px 0 12px;
  border-radius: 12px; border: 1px solid var(--border-2); background: var(--card); color: var(--muted);
  cursor: pointer; transition: border-color .15s, background .15s;
}
.search-btn:hover { border-color: var(--border-3); color: var(--text-2); }
.search-btn .lbl { flex: 1; text-align: left; font-size: 13.5px; }
.sync { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.sync .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--up); }
.sync.warn { color: var(--warn); }
.sync.warn .dot { background: var(--warn); }
.sync.busy .dot { background: var(--accent); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .25; } }
.content { width: 100%; max-width: 1480px; padding: 4px 36px 56px; }
.banner {
  margin: 0 36px 12px; padding: 12px 16px; border-radius: 14px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
  background: var(--warn-bg); border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent); font-size: 13.5px;
}
.banner b { color: var(--warn); }
.banner .btn { margin-left: auto; }
.banner-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.banner-actions .btn { margin-left: 0; }
/* Site manager reading someone else's portfolio */
.banner.info { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.banner.info > b:first-child { color: var(--accent); }
.viewas .topbar { box-shadow: inset 0 -2px 0 var(--accent); }

/* ---------- admin ---------- */
.ad-user { display: flex; align-items: center; gap: 10px; min-width: 220px; }
.ad-id { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; min-width: 0; }
.ad-id > b { font-weight: 650; }
.ad-id > .small { flex-basis: 100%; }
.ad-actions { display: inline-flex; gap: 6px; align-items: center; justify-content: flex-end; }
.ad-actions .btn.sm .ic { width: 15px; height: 15px; }
.ad-tbl tr.ad-blocked td { opacity: .62; }
.ad-tbl tr.ad-blocked td:last-child { opacity: 1; }
.empty > .ic { width: 28px; height: 28px; color: var(--muted); margin-bottom: 8px; }
@media (max-width: 860px) {
  /* Phones: one card per account, actions within reach (no sideways scrolling). */
  .ad-tbl thead, .ad-log thead { display: none; }
  .ad-tbl, .ad-tbl tbody, .ad-log, .ad-log tbody { display: block; }
  .ad-tbl tr { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px 14px; padding: 14px 0; border-bottom: 1px solid var(--grid); }
  .tbl.ad-tbl tr > td { display: block; padding: 0; border: 0; text-align: left; white-space: normal; font-size: 12.5px; }
  .tbl.ad-tbl tr > td[data-label]::before { content: attr(data-label); display: block; font-size: 11px; color: var(--muted); }
  .tbl.ad-tbl tr > td:first-child, .tbl.ad-tbl tr > td:last-child { grid-column: 1 / -1; }
  .tbl.ad-tbl td:last-child .ad-actions { justify-content: flex-start; margin-top: 4px; }
  .ad-user { min-width: 0; }
  .ad-log tr { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; padding: 10px 0; border-bottom: 1px solid var(--grid); }
  .tbl.ad-log tr > td { padding: 0; border: 0; white-space: normal; text-align: left; }
  .tbl.ad-log tr > td:nth-child(3), .tbl.ad-log tr > td:nth-child(4) { grid-column: 1 / -1; font-size: 12.5px; }
}

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px;
  border-radius: 12px; border: 1px solid var(--border-2); background: var(--card); color: var(--text);
  font-weight: 600; font-size: 13.5px; cursor: pointer; white-space: nowrap; text-decoration: none !important;
  transition: transform .12s var(--ease), background .15s, border-color .15s, box-shadow .2s, filter .15s;
}
.btn:hover { background: var(--card-2); border-color: var(--border-3); }
.btn:active { transform: translateY(1px) scale(.99); }
.btn:disabled { opacity: .5; pointer-events: none; }
.btn.primary {
  border: 0; color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 8px 22px -10px var(--accent-shadow), inset 0 1px 0 rgba(255, 255, 255, .18);
}
.btn.primary:hover { filter: brightness(1.08); box-shadow: 0 10px 26px -10px var(--accent-shadow), inset 0 1px 0 rgba(255, 255, 255, .2); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--hover); }
.btn.danger { color: var(--down); }
.btn.sm { height: 32px; padding: 0 11px; font-size: 12.5px; border-radius: 10px; gap: 6px; }
.btn.sm .ic { width: 16px; height: 16px; }
.icon-btn {
  width: 40px; height: 40px; display: grid; place-items: center; flex: none; border-radius: 12px;
  border: 1px solid var(--border-2); background: var(--card); color: var(--text-2); cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.icon-btn:hover { color: var(--text); border-color: var(--border-3); background: var(--card-2); }
.icon-btn.ghost { border-color: transparent; background: transparent; }
.icon-btn.sm { width: 32px; height: 32px; border-radius: 10px; }
.icon-btn.sm .ic { width: 16px; height: 16px; }
.icon-btn.busy .ic { animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- position split between accounts ---------- */
.acct-parts { display: block; margin-top: 4px; padding: 0; border: 0; background: none; color: var(--muted); font: inherit;
  font-size: 11.5px; font-variant-numeric: tabular-nums; cursor: pointer; text-align: left; white-space: nowrap; }
.acct-parts:hover { color: var(--accent); text-decoration: underline; }
/* A stock held in several accounts: one table row per account (part-row), grouped by a bar on the left. */
.tbl tr.part-row td:first-child { box-shadow: inset 3px 0 0 var(--accent-soft); }
.tbl tr.part-row:not(.part-last) td { border-bottom-color: transparent; }
.tbl tr.part-row:not(.part-first) .stock .logo { visibility: hidden; }
.acct-fixed { display: inline-block; font-size: 12.5px; font-weight: 600; padding: 5px 0; }
.split-rows { display: grid; gap: 12px; margin-bottom: 14px; }
.split-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 0; padding: 12px 14px 14px; border: 1px solid var(--border-2); border-radius: var(--r); }
.split-row legend { padding: 0 6px; font-size: 13px; font-weight: 700; }
.summary-note.warn { color: var(--warn); }

/* ---------- assistant chat ---------- */
.chat-card { display: flex; flex-direction: column; height: calc(100dvh - 150px); min-height: 460px; max-width: 980px; width: 100%; margin: 0 auto; padding-bottom: 14px; }
.chat-card .card-h { margin-bottom: 8px; }
.chat-log { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; padding: 8px 4px 16px; overscroll-behavior: contain; }
.chat-empty { margin: auto; max-width: 560px; text-align: center; display: grid; justify-items: center; gap: 10px; padding: 20px 8px; }
.chat-empty > .ic { width: 34px; height: 34px; color: var(--accent); filter: drop-shadow(0 6px 16px var(--accent-shadow)); }
.chat-empty h3 { font-size: 19px; font-weight: 700; letter-spacing: -.02em; }
.chat-empty p { color: var(--text-2); font-size: 13.5px; }
.chat-sugg { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 8px; }
.chat-sugg .chip { height: auto; min-height: 34px; padding: 7px 14px; text-align: left; line-height: 1.35; white-space: normal; }
.chat-sugg .chip:disabled { opacity: .5; cursor: default; }
.msg { display: flex; gap: 10px; align-items: flex-start; }
.msg.user { justify-content: flex-end; }
.msg .bubble { max-width: min(760px, 88%); font-size: 14px; line-height: 1.6; overflow-wrap: anywhere; }
.msg.user .bubble { background: var(--accent); color: #fff; padding: 10px 14px; border-radius: 18px 18px 6px 18px; }
.msg.ai .bubble { padding-top: 3px; color: var(--text); }
.ai-mark { flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; }
.ai-mark .ic { width: 16px; height: 16px; }
.md p, .md ul, .md ol, .md h4, .md .md-table { margin: 0 0 10px; }
.md > :last-child { margin-bottom: 0; }
.md h4 { font-size: 14.5px; font-weight: 700; margin-top: 14px; }
.md ul, .md ol { padding-left: 20px; display: grid; gap: 4px; }
.md code { font-size: 12.5px; padding: 1px 5px; border-radius: 6px; background: var(--card-3); }
.md a { color: var(--accent); }
.md-table { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; }
.md-table table { border-collapse: collapse; width: 100%; font-size: 13px; font-variant-numeric: tabular-nums; }
.md-table th, .md-table td { padding: 7px 10px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
.md-table th { font-size: 11.5px; color: var(--muted); font-weight: 700; background: var(--card-2); }
.md-table tr:last-child td { border-bottom: 0; }
.msg-note { margin-top: 8px; font-size: 12.5px; color: var(--warn); }
.typing { display: inline-flex; align-items: center; gap: 6px; height: 22px; color: var(--muted); font-size: 12.5px; }
.typing .ic { width: 14px; height: 14px; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; } .typing i:nth-child(3) { animation-delay: .4s; }
.chat-form { display: flex; gap: 10px; align-items: flex-end; padding: 10px; border: 1px solid var(--border-2); border-radius: 18px; background: var(--card-2); }
.chat-form:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.chat-form textarea { flex: 1; height: auto; min-height: 40px; max-height: 180px; resize: none; border: 0; background: transparent; padding: 9px 6px; line-height: 1.45; font: inherit; font-size: 14px; }
.chat-form textarea:focus { box-shadow: none; }
.chat-send { width: 40px; padding: 0; flex: none; }
.chat-send:disabled { opacity: .45; cursor: default; }
.chat-foot { margin-top: 8px; font-size: 11.5px; color: var(--muted); text-align: center; }
.chat-off { margin: 4px 0 0; }
#chatKeyBtn code { font-size: 11.5px; color: var(--text-2); }
.key-panel { display: grid; gap: 12px; margin: 4px 0 12px; padding: 16px; border-radius: var(--r); border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); background: var(--accent-soft); }
.kp-head { display: flex; gap: 12px; align-items: flex-start; }
.kp-head > .ic { flex: none; width: 20px; height: 20px; color: var(--accent); margin-top: 2px; }
.kp-head div { display: grid; gap: 3px; font-size: 13px; color: var(--text-2); line-height: 1.5; }
.kp-head b { color: var(--text); font-size: 14px; }
.kp-current { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 13px; }
.kp-current code { font-size: 12.5px; padding: 2px 7px; border-radius: 7px; background: var(--card); }
.kp-form { display: flex; gap: 8px; flex-wrap: wrap; }
.kp-form .input { min-width: 200px; }
.kp-form .input { flex: 1; background: var(--card); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
.kp-help { font-size: 12px; color: var(--muted); }
.kp-error { display: flex; gap: 8px; align-items: flex-start; padding: 10px 12px; border-radius: 10px; font-size: 13px; line-height: 1.45;
  color: var(--text); background: var(--down-bg); border: 1px solid color-mix(in srgb, var(--down) 35%, transparent); }
.kp-error .ic { flex: none; width: 16px; height: 16px; color: var(--down); margin-top: 2px; }
.kp-help a { color: var(--accent); }

/* ---------- signed-in account ---------- */
.user-wrap { position: relative; flex: none; }
.avatar-btn {
  display: grid; place-items: center; width: 40px; height: 40px; padding: 0; border-radius: 50%;
  border: 1px solid var(--border-2); background: var(--card); cursor: pointer; transition: border-color .15s, box-shadow .15s;
}
.avatar-btn:hover, .avatar-btn[aria-expanded="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.avatar-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.avatar {
  position: relative; display: grid; place-items: center; flex: none; width: 32px; height: 32px; border-radius: 50%; overflow: hidden;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff;
  font-size: 12.5px; font-weight: 750; letter-spacing: .02em;
}
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.avatar.local { background: var(--card-3); color: var(--text-2); }
.avatar.local .ic { width: 18px; height: 18px; }
.avatar.lg { width: 44px; height: 44px; font-size: 16px; }
.avatar.lg.local .ic { width: 22px; height: 22px; }
.avatar.sm { width: 32px; height: 32px; font-size: 12px; flex: none; }
.user-menu {
  position: absolute; top: calc(100% + 10px); right: 0; z-index: 60; width: 290px; padding: 8px;
  background: var(--card); border: 1px solid var(--border-2); border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
  animation: menuIn .16s var(--ease);
}
@keyframes menuIn { from { opacity: 0; transform: translateY(-6px); } }
.um-head { display: flex; align-items: center; gap: 12px; padding: 10px 10px 12px; }
.um-id { display: grid; gap: 2px; min-width: 0; }
.um-id b, .um-id span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.um-id b { font-size: 14px; font-weight: 700; }
.um-id span { font-size: 12.5px; color: var(--text-2); }
.um-id .um-idp { font-size: 11.5px; color: var(--muted); white-space: normal; }
.user-menu .nav-btn { border-top: 1px solid var(--border); border-radius: 0 0 10px 10px; margin-top: 2px; }
.user-menu .nav-btn:hover { color: var(--down); background: var(--down-bg); }

.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 12px; background: var(--card-2); border: 1px solid var(--border); }
.seg button {
  height: 28px; padding: 0 11px; border: 0; border-radius: 9px; background: none; color: var(--text-2);
  font-weight: 600; font-size: 12.5px; cursor: pointer; white-space: nowrap; transition: background .15s, color .15s;
}
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--card); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .25), 0 0 0 1px var(--border); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  height: 32px; padding: 0 12px; border-radius: 99px; border: 1px solid var(--border-2); background: var(--card);
  color: var(--text-2); font-weight: 600; font-size: 12.5px; cursor: pointer; transition: all .15s;
}
.chip:hover { color: var(--text); border-color: var(--border-3); }
.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 45%, transparent); color: var(--text); }

.input {
  height: 40px; width: 100%; min-width: 0; padding: 0 12px; border-radius: 12px; border: 1px solid var(--border-2);
  background: var(--card-2); color: var(--text); outline: none; transition: border-color .15s, box-shadow .15s, background .15s;
}
.input::placeholder { color: var(--muted); }
.input:hover { border-color: var(--border-3); }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); background: var(--card); }
select.input, select.chip-select {
  appearance: none; -webkit-appearance: none; padding-right: 32px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a94a8' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 16px;
}
.input.sm { height: 32px; font-size: 12.5px; border-radius: 10px; padding: 0 10px; }
select.input.sm { padding-right: 28px; }
.chip-select {
  height: 28px; padding: 0 28px 0 10px; border-radius: 99px; border: 1px solid var(--border-2); background-color: var(--card-2);
  color: var(--text-2); font-size: 12px; font-weight: 600; outline: none;
}
.search-field { position: relative; min-width: 200px; }
.search-field .ic { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 16px; height: 16px; }
.search-field .input { padding-left: 36px; }

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 13px; color: var(--text-2); user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .sw { position: relative; width: 36px; height: 20px; border-radius: 99px; background: var(--card-3); border: 1px solid var(--border-2); transition: background .2s; flex: none; }
.switch .sw::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--text-2); transition: transform .2s var(--ease), background .2s; }
.switch input:checked + .sw { background: var(--accent); border-color: transparent; }
.switch input:checked + .sw::after { transform: translateX(16px); background: #fff; }
.switch input:focus-visible + .sw { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- cards & layout ---------- */
.view { display: grid; gap: 18px; animation: rise .35s var(--ease); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
.card {
  position: relative; min-width: 0; padding: 20px; border-radius: var(--r-xl);
  background: var(--card); border: 1px solid var(--border); box-shadow: var(--shadow);
}
.card.flush { padding: 0; overflow: hidden; }
.card-h { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.card.flush > .card-h { padding: 18px 20px 0; }
.card-h h2 { display: flex; align-items: center; gap: 9px; font-size: 15px; font-weight: 650; letter-spacing: -.01em; }
.card-h h2 .ic { color: var(--accent); width: 17px; height: 17px; }
.card-h .sub { font-size: 12.5px; }
.note { margin-top: 12px; font-size: 12px; color: var(--muted); }
.empty { padding: 36px 16px; text-align: center; color: var(--muted); font-size: 13.5px; }
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.grid-12 { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 18px; }
.span-12 { grid-column: span 12; } .span-8 { grid-column: span 8; } .span-7 { grid-column: span 7; }
.span-6 { grid-column: span 6; } .span-5 { grid-column: span 5; } .span-4 { grid-column: span 4; }
/* Hidden with !important on wide screens so component display rules (grid, flex) can't bring them back. */
@media (min-width: 861px) { .mobile-only { display: none !important; } }

/* ---------- hero ---------- */
/* The hero spans two rows so allocation and movers stack beside it; its chart absorbs the extra height. */
.dash .hero { grid-row: span 2; display: flex; flex-direction: column; }
.dash .hero .chart-box { flex: 1 1 280px; min-height: 280px; }
.hero { padding: 26px 26px 18px; overflow: hidden; background: radial-gradient(640px 300px at 100% 0%, var(--accent-soft), transparent 70%), var(--card); }
.hero::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; background-image: var(--zellige); opacity: var(--pattern-o);
  -webkit-mask-image: radial-gradient(520px 300px at 100% 0%, #000, transparent 72%); mask-image: radial-gradient(520px 300px at 100% 0%, #000, transparent 72%);
}
.hero > * { position: relative; z-index: 1; }
.hero-top { display: flex; gap: 24px; align-items: flex-start; flex-wrap: wrap; }
.hero-main { flex: 1 1 320px; min-width: 0; }
.eyebrow { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 13px; font-weight: 600; color: var(--text-2); }
.hero-value { display: flex; align-items: baseline; gap: 8px; margin-top: 10px; }
.hero-value .hv { font-size: 48px; font-weight: 750; letter-spacing: -.045em; line-height: 1; }
.hero-value .cur { font-size: 18px; font-weight: 650; color: var(--text-2); }
.hero-deltas { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.delta-chip {
  display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 12px; border-radius: 99px;
  font-size: 13px; font-weight: 650; font-variant-numeric: tabular-nums; background: var(--card-2); color: var(--text-2);
}
.delta-chip.up { background: var(--up-bg); color: var(--up); }
.delta-chip.down { background: var(--down-bg); color: var(--down); }
.delta-chip em { font-style: normal; font-weight: 500; opacity: .75; }
.hero-stats { display: grid; grid-template-columns: repeat(2, minmax(140px, 1fr)); gap: 10px; flex: 0 1 360px; }
.hs { padding: 12px 14px; border-radius: 14px; background: color-mix(in srgb, var(--card-2) 80%, transparent); border: 1px solid var(--border); }
.hs-l { display: flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 600; color: var(--text-2); }
.hs-l .ic { width: 15px; height: 15px; color: var(--muted); }
.hs-v { margin-top: 6px; font-size: 17px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.hs-s { font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.chart-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 22px 0 10px; }
.chart-ctrl { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.legend { display: flex; gap: 14px; font-size: 12px; font-weight: 600; color: var(--text-2); flex-wrap: wrap; }
.legend i { display: inline-block; width: 16px; height: 3px; border-radius: 3px; margin-right: 7px; vertical-align: middle; }
.chart-box { position: relative; height: 280px; }
.chart-empty {
  position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 20px;
  color: var(--muted); font-size: 13px; background: color-mix(in srgb, var(--card) 70%, transparent); border-radius: 12px;
}

/* ---------- allocation ---------- */
.strip { display: flex; gap: 3px; height: 16px; border-radius: 99px; overflow: hidden; margin: 6px 0 18px; }
.strip span { min-width: 4px; height: 100%; transition: filter .15s; }
.strip span:hover { filter: brightness(1.2); }
.legend-list { display: grid; gap: 4px; }
.lg-row { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto 54px; gap: 12px; align-items: center; padding: 7px 8px; border-radius: 10px; font-size: 13px; }
.lg-row:hover { background: var(--hover); }
.lg-row .dot { width: 10px; height: 10px; border-radius: 3px; }
.lg-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lg-val { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12.5px; }
.lg-pct { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- treemap ---------- */
.treemap { position: relative; height: 380px; border-radius: 14px; overflow: hidden; background: var(--card-2); }
.treemap.tall { height: 520px; }
.tile {
  position: absolute; border-radius: 7px; padding: 7px 9px; overflow: hidden; cursor: pointer;
  display: flex; flex-direction: column; gap: 1px; transition: filter .15s, box-shadow .15s;
}
.tile:hover { filter: brightness(1.14) saturate(1.05); z-index: 2; box-shadow: 0 0 0 2px rgba(255, 255, 255, .55); }
.tile.held { box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .85); }
.tile .tt { font-weight: 750; letter-spacing: -.01em; line-height: 1.1; white-space: nowrap; }
.tile .tp { font-weight: 600; font-variant-numeric: tabular-nums; opacity: .95; white-space: nowrap; }
.tile .tn { margin-top: auto; font-size: 11px; opacity: .8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tm-group {
  position: absolute; height: 18px; line-height: 18px; padding: 0 4px; font-size: 10.5px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none;
}
.heat-legend { display: flex; align-items: center; gap: 8px; font-size: 11.5px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.heat-legend i { width: 110px; height: 8px; border-radius: 99px; }

/* ---------- bar lists ---------- */
.bars { display: grid; gap: 2px; }
.bar-row {
  display: grid; grid-template-columns: minmax(84px, 138px) minmax(0, 1fr) 76px; align-items: center; gap: 12px;
  padding: 7px 8px; border-radius: 10px; font-size: 13px;
}
.bar-row[data-act] { cursor: pointer; }
.bar-row:hover { background: var(--hover); }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-value { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.track { position: relative; height: 8px; border-radius: 99px; background: var(--card-3); }
.fill { position: absolute; top: 0; bottom: 0; left: 0; border-radius: 99px; background: var(--accent); min-width: 3px; }
.fill.over { background: #f59e0b; }
.limit { position: absolute; top: -5px; bottom: -5px; width: 2px; border-radius: 2px; background: var(--text-2); opacity: .55; }
.limit-tag { position: absolute; top: -21px; transform: translateX(-50%); font-size: 10.5px; font-weight: 700; color: var(--text-2); white-space: nowrap; }
.dv .track { background: transparent; }
.dv .track::before { content: ""; position: absolute; left: 0; right: 0; top: 3px; height: 2px; border-radius: 2px; background: var(--card-3); }
.axis { position: absolute; left: 50%; top: -5px; bottom: -5px; width: 1px; background: var(--border-3); }
.fill.pos { left: 50%; background: var(--up); border-radius: 0 99px 99px 0; }
.fill.neg { left: auto; right: 50%; background: var(--down); border-radius: 99px 0 0 99px; }
.over-tag { color: #f59e0b; font-size: 11px; margin-left: 4px; }

/* ---------- lists ---------- */
.stock { display: flex; align-items: center; gap: 12px; min-width: 0; }
.logo {
  width: 36px; height: 36px; border-radius: 50%; flex: none; object-fit: cover; background: var(--card-3);
  display: grid; place-items: center; font-size: 10.5px; font-weight: 750; color: var(--text-2); letter-spacing: -.02em;
}
.logo.sm { width: 30px; height: 30px; font-size: 9.5px; }
.logo.lg { width: 52px; height: 52px; font-size: 14px; }
.stock-name { display: grid; min-width: 0; line-height: 1.3; }
.stock-name b { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stock-name span { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rows { display: grid; gap: 2px; }
.item {
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 14px; align-items: center;
  padding: 9px 10px; border-radius: 14px; cursor: pointer; transition: background .12s;
}
.item:hover { background: var(--hover); }
.item .right { text-align: right; font-variant-numeric: tabular-nums; }
.item .right b { display: block; font-weight: 650; }
.item .right span { font-size: 12px; }
.chg {
  display: inline-flex; align-items: center; justify-content: flex-end; min-width: 72px; height: 26px; padding: 0 9px;
  border-radius: 8px; font-size: 12.5px; font-weight: 650; font-variant-numeric: tabular-nums; background: var(--card-2); color: var(--text-2);
}
.chg.up { background: var(--up-bg); color: var(--up); }
.chg.down { background: var(--down-bg); color: var(--down); }
.flash-up { animation: flashUp 1.8s ease-out; }
.flash-down { animation: flashDown 1.8s ease-out; }
@keyframes flashUp { 0%, 20% { background: var(--up-flash); } }
@keyframes flashDown { 0%, 20% { background: var(--down-flash); } }
.price { border-radius: 6px; padding: 1px 4px; margin: -1px -4px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
.tbl th {
  position: sticky; top: 0; z-index: 1; padding: 12px 14px; background: var(--card); border-bottom: 1px solid var(--border);
  font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); text-align: left; white-space: nowrap; user-select: none;
}
.tbl th.sort { cursor: pointer; }
.tbl th.sort:hover { color: var(--text); }
.tbl th .arrow { color: var(--accent); margin-left: 4px; }
.tbl td { padding: 11px 10px; border-bottom: 1px solid var(--grid); white-space: nowrap; font-variant-numeric: tabular-nums; }
.tbl th { padding-inline: 10px; }
.tbl tbody tr { transition: background .12s; }
.tbl tbody tr:hover { background: var(--hover); }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr[data-act] { cursor: pointer; }
.tbl .stock { min-width: 210px; }
.tbl .r { text-align: right; }
.tbl .c { text-align: center; }
.tbl tfoot td { border-top: 1px solid var(--border-2); border-bottom: 0; font-weight: 700; }
.tbl td:first-child, .tbl th:first-child { padding-left: 20px; }
.tbl td:last-child, .tbl th:last-child { padding-right: 20px; }
.row-actions { display: inline-flex; gap: 4px; opacity: 0; transition: opacity .15s; }
.tbl tr:hover .row-actions, .row-actions:focus-within { opacity: 1; }
.cell-stack { display: grid; justify-items: end; line-height: 1.25; }
.cell-stack small { font-size: 12px; }
.w-bar { display: inline-grid; grid-template-columns: 44px auto; gap: 8px; align-items: center; }
.w-bar .track { height: 6px; }
.acct-select { height: 30px; font-size: 12.5px; border-radius: 9px; width: 166px; padding: 0 24px 0 9px; background-position: right 6px center; }
.row-actions .icon-btn.sm { width: 30px; height: 30px; }

/* ---------- stat strip ---------- */
.stat-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.stat {
  padding: 16px 18px; border-radius: var(--r-lg); background: var(--card); border: 1px solid var(--border); box-shadow: var(--shadow);
}
.stat .k { display: flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.stat .k .ic { width: 15px; height: 15px; color: var(--accent); }
.stat .v { margin-top: 6px; font-size: 21px; font-weight: 750; letter-spacing: -.025em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stat .v small { font-size: 13px; font-weight: 600; color: var(--text-2); margin-left: 3px; }
.stat .s { margin-top: 2px; font-size: 12px; font-weight: 600; }

/* ---------- position cards (mobile) ---------- */
.pcards { display: grid; gap: 10px; }
.pcard {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px 12px; padding: 14px 16px; border-radius: 18px;
  background: var(--card); border: 1px solid var(--border); cursor: pointer;
}
.pcard .right { text-align: right; font-variant-numeric: tabular-nums; }
.pcard .right b { display: block; font-size: 15px; font-weight: 700; }
.pcard .right span { font-size: 12.5px; font-weight: 600; }
.pcard .foot { grid-column: 1 / -1; display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.pcard .foot b { color: var(--text-2); font-weight: 600; }

/* ---------- transactions timeline ---------- */
.month { margin: 22px 6px 8px; font-size: 11.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); display: flex; justify-content: space-between; }
.month:first-child { margin-top: 4px; }
.tx { display: grid; grid-template-columns: 42px minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 12px 14px; border-radius: 16px; cursor: pointer; transition: background .12s; }
.tx:hover { background: var(--hover); }
.tx + .tx { border-top: 1px solid var(--grid); }
.ti { width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; background: var(--card-3); color: var(--text-2); }
.ti .ic { width: 19px; height: 19px; }
.ti.buy { background: var(--accent-soft); color: var(--accent); }
.ti.sell { background: var(--warn-bg); color: var(--warn); }
.ti.div { background: var(--up-bg); color: var(--up); }
.ti.cash { background: color-mix(in srgb, var(--accent-2) 14%, transparent); color: var(--accent-2); }
.tx-main { min-width: 0; }
.tx-main b { display: block; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-main span { display: block; font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-amt { text-align: right; font-variant-numeric: tabular-nums; }
.tx-amt b { display: block; font-weight: 700; }
.tx-amt span { font-size: 12px; color: var(--muted); }
.tag { display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 6px; font-size: 11px; font-weight: 700; background: var(--card-3); color: var(--text-2); }
.tag.up { background: var(--up-bg); color: var(--up); }
.tag.down { background: var(--down-bg); color: var(--down); }
.tag.warn { background: var(--warn-bg); color: var(--warn); }
.tag.accent { background: var(--accent-soft); color: var(--accent); }

/* ---------- market ---------- */
.idx-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.idx-card { overflow: hidden; }
.idx-card::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; background-image: var(--zellige); opacity: var(--pattern-o);
  -webkit-mask-image: linear-gradient(250deg, #000, transparent 55%); mask-image: linear-gradient(250deg, #000, transparent 55%);
}
.idx-card .k { font-size: 12.5px; font-weight: 700; letter-spacing: .06em; color: var(--muted); }
.idx-card .v { font-size: 30px; font-weight: 750; letter-spacing: -.035em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.perf-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.perf { display: grid; gap: 1px; padding: 7px 11px; border-radius: 11px; background: var(--card-2); min-width: 72px; }
.perf span { font-size: 11px; font-weight: 600; color: var(--muted); }
.perf b { font-size: 13px; font-variant-numeric: tabular-nums; }
.star-btn { border: 0; background: none; cursor: pointer; color: var(--muted); padding: 4px; border-radius: 8px; display: grid; place-items: center; }
.star-btn:hover { color: var(--text); background: var(--hover); }
.star-btn.on { color: #f5b014; }
.star-btn.on .ic { fill: currentColor; }

/* ---------- watchlist ---------- */
.wl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.wl-card { display: grid; gap: 14px; cursor: pointer; transition: transform .2s var(--ease), border-color .2s; }
.wl-card:hover { transform: translateY(-2px); border-color: var(--border-3); }
.wl-top { display: flex; align-items: center; gap: 10px; }
.wl-price { display: flex; align-items: baseline; gap: 10px; }
.wl-price b { font-size: 24px; font-weight: 750; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.wl-meta { display: flex; gap: 14px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; flex-wrap: wrap; }
.wl-meta b { color: var(--text-2); }
.wl-target { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; }
.wl-foot { display: flex; gap: 8px; }
.wl-foot .btn { flex: 1; }
.range { display: grid; gap: 5px; }
.range-track { position: relative; height: 6px; border-radius: 99px; background: linear-gradient(90deg, var(--down-bg), var(--card-3), var(--up-bg)); }
.range-mark { position: absolute; top: 50%; width: 12px; height: 12px; border-radius: 50%; background: var(--text); border: 3px solid var(--card); transform: translate(-50%, -50%); box-shadow: 0 0 0 1px var(--border-3); }
.range-labels { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- dividends ---------- */
.big-stat { display: grid; gap: 4px; }
.big-stat .v { font-size: 40px; font-weight: 750; letter-spacing: -.04em; line-height: 1.05; font-variant-numeric: tabular-nums; }

/* ---------- settings ---------- */
.set-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: start; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.field { display: grid; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.field small { font-size: 12px; font-weight: 500; color: var(--muted); min-height: 0; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
code { font-size: 12px; padding: 2px 6px; border-radius: 6px; background: var(--card-3); }

/* ---------- dialogs ---------- */
dialog {
  padding: 0; border: 1px solid var(--border-2); border-radius: 24px; background: var(--card); color: var(--text);
  box-shadow: var(--shadow-lg); width: min(580px, calc(100vw - 24px)); max-height: calc(100dvh - 32px);
}
dialog::backdrop { background: rgba(3, 5, 10, .6); backdrop-filter: blur(3px); }
dialog[open] { animation: pop .24s var(--ease); }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.985); } }
dialog.narrow { width: min(440px, calc(100vw - 24px)); }
.dlg-h { display: flex; align-items: flex-start; gap: 12px; padding: 22px 22px 0; }
.dlg-h > div { flex: 1; min-width: 0; }
.dlg-h h2 { font-size: 18px; font-weight: 700; letter-spacing: -.02em; }
.dlg-h .sub { font-size: 13px; margin-top: 3px; }
.dlg-b { padding: 18px 22px; display: grid; gap: 16px; }
.dlg-f { display: flex; align-items: center; gap: 8px; padding: 0 22px 22px; }
.confirm-text { color: var(--text-2); line-height: 1.55; }
.type-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.type-grid button {
  display: grid; justify-items: center; gap: 7px; padding: 12px 4px 10px; border-radius: 14px; cursor: pointer;
  border: 1px solid var(--border-2); background: var(--card-2); color: var(--text-2); font-size: 12.5px; font-weight: 650;
  transition: border-color .15s, background .15s, color .15s;
}
.type-grid button:hover { border-color: var(--border-3); color: var(--text); }
.type-grid button[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--text); box-shadow: 0 0 0 3px var(--accent-soft); }
.type-grid .ti { width: 34px; height: 34px; border-radius: 11px; }
.summary {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 14px 16px; border-radius: 16px;
  background: linear-gradient(135deg, var(--accent-soft), transparent), var(--card-2); border: 1px solid var(--border);
}
.summary { flex-wrap: wrap; }
.summary span { font-size: 13px; font-weight: 600; color: var(--text-2); }
.summary .summary-note { flex-basis: 100%; font-size: 12.5px; font-weight: 600; }
.summary .summary-note:empty { display: none; }
.summary b { font-size: 22px; font-weight: 750; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.form-msg { font-size: 12.5px; font-weight: 600; color: var(--down); }
.form-msg.warn { color: var(--warn); }
.form-msg:empty { display: none; }
.hint { font-size: 12px; color: var(--muted); }

/* drawer */
dialog.drawer {
  margin: 0 0 0 auto; height: 100dvh; max-height: 100dvh; width: min(800px, 100vw);
  border-radius: 24px 0 0 24px; border-right: 0; overflow-y: auto; overscroll-behavior: contain;
}
dialog.drawer[open] { animation: slideIn .32s var(--ease); }
@keyframes slideIn { from { transform: translateX(48px); opacity: .3; } }
.dt-head {
  position: sticky; top: 0; z-index: 3; display: flex; align-items: center; gap: 14px; padding: 20px 24px 16px;
  background: color-mix(in srgb, var(--card) 94%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border);
}
.dt-head h2 { font-size: 20px; font-weight: 750; letter-spacing: -.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dt-head h2 + div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dt-price { text-align: right; }
.dt-price b { display: block; font-size: 28px; font-weight: 750; letter-spacing: -.035em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.dt-body { padding: 18px 24px 32px; display: grid; gap: 18px; }
.tv-box { height: 400px; border-radius: 18px; overflow: hidden; border: 1px solid var(--border); background: var(--card-2); }
.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px 18px; }
.kv .k { font-size: 12px; color: var(--muted); font-weight: 600; }
.kv .v { font-weight: 650; font-variant-numeric: tabular-nums; margin-top: 2px; }
.links { display: flex; gap: 18px; flex-wrap: wrap; font-size: 13px; font-weight: 600; }
.links a { display: inline-flex; align-items: center; gap: 6px; }
.links .ic { width: 15px; height: 15px; }

/* palette */
dialog.palette { margin-top: 11vh; width: min(640px, calc(100vw - 24px)); }
.pal-search { position: relative; border-bottom: 1px solid var(--border); }
.pal-search .ic { position: absolute; left: 20px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 20px; height: 20px; }
.pal-search input { width: 100%; height: 62px; border: 0; outline: none; background: transparent; padding: 0 20px 0 54px; font-size: 16px; }
.pal-list { max-height: min(56vh, 460px); overflow-y: auto; padding: 8px; }
.pal-sec { padding: 10px 12px 6px; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.pal-item { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 9px 12px; border-radius: 12px; cursor: pointer; }
.pal-item[aria-selected="true"] { background: var(--accent-soft); }
.pal-item .pi { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--card-3); color: var(--text-2); }
.pal-foot { display: flex; gap: 14px; padding: 10px 16px; border-top: 1px solid var(--border); font-size: 11.5px; color: var(--muted); align-items: center; }

/* more sheet */
.more-list { display: grid; gap: 4px; padding: 8px 12px 18px; }

/* tooltip & toasts */
.tip {
  position: fixed; left: 0; top: 0; z-index: 200; pointer-events: none; opacity: 0; max-width: 280px; padding: 10px 12px; border-radius: 12px;
  background: var(--card-3); border: 1px solid var(--border-2); box-shadow: var(--shadow-lg); font-size: 12.5px; line-height: 1.5;
  white-space: pre-line; color: var(--text-2); transition: opacity .12s; font-variant-numeric: tabular-nums;
}
.tip.show { opacity: 1; }
.tip::first-line { color: var(--text); font-weight: 700; }
#toasts { position: fixed; right: 20px; bottom: 20px; z-index: 300; display: grid; gap: 10px; max-width: min(400px, calc(100vw - 32px)); }
.toast {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px 16px; border-radius: 14px; font-size: 13.5px; font-weight: 550;
  background: var(--card-3); color: var(--text); border: 1px solid var(--border-2); box-shadow: var(--shadow-lg); animation: toastIn .25s var(--ease);
}
.toast.alert { border-color: color-mix(in srgb, var(--warn) 50%, transparent); }
.toast.error { border-color: color-mix(in srgb, var(--down) 50%, transparent); }
.toast.out { animation: toastOut .2s ease-in forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px) scale(.98); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(6px); } }

/* skeleton */
.skel { border-radius: 14px; background: linear-gradient(90deg, var(--card-2) 0%, var(--card-3) 50%, var(--card-2) 100%); background-size: 200% 100%; animation: shimmer 1.3s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- mobile tab bar ---------- */
.tabbar { display: none; }

/* ---------- responsive ---------- */
@media (max-width: 1320px) {
  .dash .hero { grid-column: span 12; grid-row: auto; }
  .dash .alloc, .dash .movers { grid-column: span 6; }
}
/* Collapsed sidebar ("rail", icons only): the user's choice, automatic between 861 and 1180 px.
   The .rail class is set on <html> before first paint (see index.html) and by the toggle button. */
@media (min-width: 861px) {
  :root.rail { --sidebar: 78px; }
  .rail .brand-name, .rail .nav-btn .lbl, .rail .nav-label, .rail .market-card, .rail .nav-btn .badge { display: none; }
  .rail .nav-btn { justify-content: center; padding: 0; }
  .rail .nav-btn[aria-current="page"]::before { left: -12px; }
  .rail .sidebar { padding-inline: 12px; }
  .rail .side-head { flex-direction: column; gap: 14px; }
  .rail .brand { justify-content: center; padding: 0; }
  .rail .market-mini { display: grid; }
}
@media (max-width: 1180px) and (min-width: 861px) {
  .search-btn { min-width: 0; }
  .search-btn .lbl, .search-btn kbd { display: none; }
}
@media (max-width: 1100px) {
  .span-4 { grid-column: span 6; }
  .stat-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .set-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; }
  .desktop-only { display: none !important; }
  .topbar { padding: calc(10px + env(safe-area-inset-top)) 16px 10px; gap: 12px; background: var(--bg); border-bottom: 1px solid var(--border); }
  .topbar .brand img { width: 30px; height: 30px; }
  .page-title h1 { font-size: 18px; }
  .page-title p { font-size: 12px; }
  .top-actions { gap: 6px; }
  .search-btn { min-width: 0; width: 40px; padding: 0; justify-content: center; }
  .search-btn .lbl, .search-btn kbd, .sync .txt, .top-actions .btn.primary .lbl { display: none; }
  .top-actions .btn.primary { width: 40px; padding: 0; }
  .avatar-btn { width: 38px; height: 38px; }
  .chat-card { height: auto; min-height: calc(100dvh - 200px - env(safe-area-inset-bottom)); padding: 14px 12px 10px; }
  .chat-log { overflow: visible; }
  .chat-form { position: sticky; bottom: calc(78px + env(safe-area-inset-bottom)); z-index: 5; box-shadow: 0 -12px 24px -12px var(--bg); }
  .chat-foot { font-size: 10.5px; }
  .msg .bubble { max-width: 100%; }
  .msg.ai .ai-mark { display: none; }
  .user-menu { position: fixed; top: calc(62px + env(safe-area-inset-top)); left: 16px; right: 16px; width: auto; }
  .toolbar .btn { flex: 1 1 auto; }
  .toolbar .grow { display: none; }
  .toolbar .search-field { flex: 1 1 100% !important; min-width: 0; }
  .page-title h1 .t-full { display: none; }
  .page-title h1 .t-short { display: inline; }
  .acct-name { width: 110px; }
  .content { padding: 14px 16px calc(92px + env(safe-area-inset-bottom)); }
  .banner { margin: 10px 16px 0; }
  .grid-12 { gap: 14px; }
  .span-8, .span-7, .span-6, .span-5, .span-4, .dash .alloc, .dash .movers { grid-column: span 12; }
  .view { gap: 14px; }
  .card { padding: 16px; border-radius: 20px; }
  .card.flush > .card-h { padding: 16px 16px 0; }
  .hero { padding: 20px 18px 14px; }
  .hero-value .hv { font-size: 38px; }
  .hero-stats { flex-basis: 100%; }
  .chart-bar { margin-top: 18px; }
  .chart-ctrl { margin-left: 0; width: 100%; justify-content: space-between; }
  .chart-box { height: 220px; }
  .treemap { height: 340px; }
  .treemap.tall { height: 460px; }
  .idx-row { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .stat-strip { gap: 10px; }
  .stat { padding: 14px; }
  .stat .v { font-size: 18px; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .type-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
  .type-grid button { font-size: 11px; padding: 10px 2px 8px; }
  .bar-row { grid-template-columns: 96px minmax(0, 1fr) 66px; gap: 10px; }
  .wl-grid { grid-template-columns: minmax(0, 1fr); }

  dialog.sheet { margin: auto auto 0; width: 100vw; max-width: 100vw; border-radius: 26px 26px 0 0; border-bottom: 0; max-height: 92dvh; }
  dialog.sheet[open] { animation: sheetUp .3s var(--ease); }
  @keyframes sheetUp { from { transform: translateY(40px); opacity: .4; } }
  dialog.sheet .dlg-f { padding-bottom: calc(18px + env(safe-area-inset-bottom)); }
  dialog.drawer { width: 100vw; max-width: 100vw; border-radius: 0; border: 0; }
  .dt-head { padding: calc(14px + env(safe-area-inset-top)) 16px 12px; gap: 10px; }
  .dt-head .logo.lg { width: 40px; height: 40px; }
  .dt-head h2 { font-size: 17px; }
  .dt-price b { font-size: 21px; }
  .dt-body { padding: 16px 16px calc(28px + env(safe-area-inset-bottom)); }
  .tv-box { height: 320px; }
  dialog.palette { margin-top: 8px; }

  .tabbar {
    display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); background: var(--tabbar); border-top: 1px solid var(--border);
  }
  .tabbar button {
    display: grid; justify-items: center; gap: 3px; padding: 6px 0 4px; border: 0; background: none; cursor: pointer;
    color: var(--muted); font-size: 10.5px; font-weight: 650; border-radius: 12px;
  }
  .tabbar button .ic { width: 22px; height: 22px; }
  .tabbar button[aria-current="page"] { color: var(--accent); }
  .tabbar button[aria-current="page"] .ic { filter: drop-shadow(0 4px 10px var(--accent-shadow)); }
  #toasts { left: 16px; right: 16px; bottom: calc(84px + env(safe-area-inset-bottom)); max-width: none; }
}
@media (max-width: 420px) {
  .hero-value .hv { font-size: 34px; }
  .hero-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hs-v { font-size: 15px; }
  .seg button { padding: 0 7px; font-size: 12px; }
}
@media (hover: none) {
  .row-actions { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
