:root {
  --bg: #f5f7f8;
  --surface: #ffffff;
  --surface-2: #f8fafb;
  --panel: #ffffff;
  --panel-2: #f8fafb;
  --border: #e7ecef;
  --border-strong: #dbe3e7;
  --text: #1e2429;
  --muted: #748089;
  --muted-2: #9aa4aa;
  --green: #0f918c;
  --green-2: #0aa79f;
  --green-soft: rgba(15, 145, 140, .10);
  --green-wash: #e8f7f5;
  --red: #df4b57;
  --red-soft: rgba(223, 75, 87, .10);
  --blue: #5b91f5;
  --gold: #f0b64a;
  --purple: #8b5cf6;
  --shadow: 0 18px 48px rgba(18, 37, 46, .08);
  --shadow-soft: 0 6px 18px rgba(18, 37, 46, .06);
  --radius: 18px;
  --radius-lg: 24px;
  --sidebar: 264px;
  --topbar: 76px;
}
html[data-theme='dark'] {
  --bg: #0e1518;
  --surface: #121c20;
  --surface-2: #172329;
  --panel: #121c20;
  --panel-2: #172329;
  --border: rgba(255,255,255,.08);
  --border-strong: rgba(255,255,255,.13);
  --text: #ecf3f2;
  --muted: #94a7ac;
  --muted-2: #73868b;
  --green: #16b8ad;
  --green-2: #27d3c6;
  --green-soft: rgba(39, 211, 198, .13);
  --green-wash: rgba(39, 211, 198, .10);
  --red: #ff6675;
  --red-soft: rgba(255,102,117,.13);
  --shadow: 0 18px 46px rgba(0,0,0,.25);
  --shadow-soft: 0 8px 22px rgba(0,0,0,.18);
}
* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); color: var(--text); }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(24px, 2.2vw, 34px); letter-spacing: -.04em; margin: 0; font-weight: 850; }
h2 { font-size: clamp(22px, 2vw, 28px); letter-spacing: -.035em; margin: 0; font-weight: 820; }
h3 { margin: 0; font-size: 21px; letter-spacing: -.035em; }
small, .muted { color: var(--muted); }
.ambient { position: fixed; width: 420px; height: 420px; border-radius: 999px; filter: blur(90px); opacity: .22; pointer-events: none; z-index: -1; }
.ambient.one { top: -170px; left: 22%; background: #7ae8df; }
.ambient.two { bottom: -210px; right: -160px; background: #d7f2ee; }
html[data-theme='dark'] .ambient.one { background: #0f918c; opacity: .16; }
html[data-theme='dark'] .ambient.two { background: #2563eb; opacity: .11; }

/* Sidebar */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar);
  padding: 32px 24px 22px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 30;
  box-shadow: 8px 0 22px rgba(24, 39, 44, .03);
}
.brand { display: flex; align-items: center; gap: 14px; min-height: 48px; margin-bottom: 72px; }
.brand strong { display: block; font-size: 22px; letter-spacing: -.03em; color: var(--green); line-height: 1; }
.brand small { display: block; font-size: 12px; margin-top: 4px; color: var(--muted); }
.brand-mark { width: 44px; height: 44px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; align-items: end; padding: 9px 7px; }
.brand-mark i { display: block; border-radius: 6px 6px 2px 2px; background: linear-gradient(180deg, #53dbd2, var(--green)); transform: skewY(-28deg); }
.brand-mark i:nth-child(1) { height: 16px; }
.brand-mark i:nth-child(2) { height: 28px; }
.brand-mark i:nth-child(3) { height: 38px; }
.nav-label {
  margin: 0 0 18px 8px;
  color: var(--muted);
  text-transform: uppercase;
  font-size: 14px;
  letter-spacing: .06em;
}
.support-label { margin-top: 58px; }
.sidebar nav { display: grid; gap: 8px; }
.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 40px;
  padding: 8px 10px;
  color: #5e6870;
  border-radius: 12px;
  font-weight: 650;
  transition: background .18s ease, color .18s ease, transform .18s ease;
}
html[data-theme='dark'] .sidebar nav a { color: #a0adb2; }
.sidebar nav a span { width: 24px; text-align: center; color: #6e7a82; font-size: 20px; line-height: 1; }
.sidebar nav a:hover { background: var(--surface-2); transform: translateX(2px); }
.sidebar nav a.active { color: var(--green); background: transparent; }
.sidebar nav a.active span { color: var(--green); }
.sidebar-footer { margin-top: auto; }
.theme-toggle {
  border: 0;
  min-height: 46px;
  width: 100%;
  border-radius: 999px;
  color: #fff;
  background: #172126;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: var(--shadow-soft);
}
.theme-toggle span { width: 18px; height: 18px; display: grid; place-items: center; border: 1px solid rgba(255,255,255,.7); border-radius: 4px; }

/* Shell / top bar */
.shell {
  margin-left: var(--sidebar);
  min-height: 100vh;
  padding: 0 28px 34px;
  max-width: 1680px;
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--topbar);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  margin: 0 -28px 26px;
  padding: 14px 28px;
  background: rgba(245, 247, 248, .86);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(18px);
}
html[data-theme='dark'] .topbar { background: rgba(14, 21, 24, .86); }
.searchbar {
  position: relative;
  width: min(360px, 40vw);
}
.searchbar input {
  min-height: 46px;
  border-radius: 3px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-soft);
  padding: 0 46px 0 18px;
}
.searchbar span {
  position: absolute;
  top: 50%;
  right: 14px;
  transform: translateY(-50%);
  font-size: 29px;
  line-height: 1;
  color: var(--text);
}
.top-actions { display: flex; align-items: center; gap: 16px; min-width: 0; }
.icon-button {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  position: relative;
  color: var(--text);
  background: transparent;
  border: 1px solid transparent;
  transition: background .18s ease, border-color .18s ease;
}
.icon-button:hover { background: var(--surface); border-color: var(--border); }
.icon-button b {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 10px;
  height: 10px;
  padding: 0;
  border-radius: 10px;
  color: transparent;
  background: var(--red);
  overflow: hidden;
}
.profile-card { display: flex; align-items: center; gap: 12px; min-width: 0; }
.profile-card span { display: grid; text-align: right; min-width: 0; }
.profile-card strong { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 180px; }
.profile-card small { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.profile-card em {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #d9f6f2, #f3eecb);
  border: 2px solid var(--surface);
  color: var(--green);
  font-style: normal;
  font-weight: 900;
  box-shadow: var(--shadow-soft);
}
.page-title { display: flex; justify-content: space-between; align-items: center; gap: 18px; margin: 0 0 18px; }
.eyebrow { color: var(--green); font-size: 12px; font-weight: 850; letter-spacing: .12em; text-transform: uppercase; }

/* Cards and controls */
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  padding: 22px;
}
.btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 12px;
  min-height: 44px;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  font-weight: 750;
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-soft); }
.btn.primary { background: var(--green); color: white; border-color: var(--green); }
.btn.ghost { background: var(--surface-2); }
.btn.compact { min-height: 40px; padding: 0 14px; border-radius: 10px; }
.link-btn { border: 0; background: transparent; color: var(--green); cursor: pointer; padding: 0; font-weight: 700; }
.link-btn.danger, .danger { color: var(--red); }
.flash { margin: 0 0 16px; padding: 13px 15px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface); }
.flash.success { background: var(--green-wash); color: var(--green); }
.flash.error { background: var(--red-soft); color: var(--red); }
.gain { color: var(--green) !important; }
.loss { color: var(--red) !important; }

/* Dashboard redesign */
.dashboard-grid { display: grid; grid-template-columns: minmax(420px, 0.88fr) minmax(0, 1.38fr); gap: 26px; align-items: start; }
.left-column, .right-column { display: grid; gap: 26px; min-width: 0; }
.overview-card { display: grid; grid-template-columns: 1fr 1fr; padding: 0; overflow: hidden; min-height: 330px; }
.overview-panel { padding: 24px 22px 22px; display: flex; flex-direction: column; justify-content: space-between; min-width: 0; }
.overview-panel + .overview-panel { border-left: 1px solid var(--border); }
.metric-head small { display: block; margin-bottom: 7px; }
.metric-head strong { font-size: clamp(24px, 2.7vw, 30px); letter-spacing: -.055em; white-space: nowrap; }
.metric-head.split { display: flex; justify-content: space-between; gap: 12px; }
.metric-head.split b { padding-top: 3px; font-size: 13px; }
.donut-wrap { display: grid; place-items: center; min-height: 150px; }
.donut {
  --p: 0;
  width: 118px;
  height: 118px;
  border-radius: 50%;
  background: conic-gradient(var(--green) calc(var(--p) * 1%), #d7dde0 0);
  display: grid;
  place-items: center;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.02);
}
html[data-theme='dark'] .donut { background: conic-gradient(var(--green) calc(var(--p) * 1%), rgba(255,255,255,.14) 0); }
.donut.secondary { background: conic-gradient(var(--green-2) calc(var(--p) * 1%), #d7dde0 0); }
html[data-theme='dark'] .donut.secondary { background: conic-gradient(var(--green-2) calc(var(--p) * 1%), rgba(255,255,255,.14) 0); }
.donut span { width: 74px; height: 74px; background: var(--panel); border-radius: 50%; box-shadow: inset 0 0 0 1px var(--border); }
.mini-metrics { display: grid; gap: 16px; }
.mini-metrics.two-up { grid-template-columns: 1fr 1fr; }
.mini-metrics strong { display: block; margin-top: 6px; font-size: 17px; letter-spacing: -.02em; }
.section-heading { display: flex; justify-content: space-between; align-items: end; margin-bottom: 18px; gap: 12px; }
.section-heading a, .section-title a, .section-title span { color: var(--muted); font-size: 13px; }
.market-strip { min-width: 0; }
.market-cards {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(160px, 1fr);
  gap: 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
}
.ticker-card { min-height: 132px; padding: 22px 18px; border-right: 1px solid var(--border); scroll-snap-align: start; display: grid; gap: 7px; }
.ticker-card:last-child { border-right: 0; }
.ticker-card strong { display: block; font-size: 20px; letter-spacing: -.03em; }
.ticker-card svg { width: 74px; height: 30px; justify-self: end; margin-top: -4px; }
.ticker-card path { fill: none; stroke: var(--green); stroke-width: 2; stroke-linecap: round; }
.ticker-card small.loss + svg path, .ticker-card .loss ~ svg path { stroke: var(--red); }
.ticker-actions { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.ticker-actions span { color: var(--muted); font-size: 12px; max-width: 80px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ticker-actions a, .empty-ticker a { border: 1px solid var(--border); color: var(--green); background: var(--surface-2); padding: 5px 12px; border-radius: 6px; font-size: 13px; }
.empty-ticker { grid-auto-flow: row; width: 100%; }
.watch-chart-card { padding: 28px; min-height: 552px; }
.chart-topline { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 26px; }
.chart-topline h3 { font-size: clamp(22px, 2.2vw, 25px); }
.chart-topline h3 span { color: var(--green); margin-left: 12px; }
.broker-chip { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 14px; border-radius: 12px; background: var(--surface-2); color: var(--text); font-weight: 750; }
.range-tabs { display: flex; flex-wrap: wrap; gap: 18px; margin-bottom: 18px; }
.range-tabs button { border: 0; background: var(--surface-2); color: #6f7980; min-height: 34px; padding: 0 12px; border-radius: 8px; cursor: pointer; }
.range-tabs button.active { background: var(--green); color: white; }
.chart-shell { height: 380px; position: relative; }
.assets-card { padding: 0; overflow: hidden; }
.assets-card .section-title { padding: 22px 22px 10px; }
.asset-filter-row { display: flex; align-items: center; justify-content: space-between; padding: 0 22px 14px; border-bottom: 1px solid var(--border); }
.asset-filter-row span { font-size: 17px; font-weight: 750; }
.asset-filter-row div { display: flex; gap: 18px; color: var(--muted); }
.clean-list { gap: 0; }
.clean-list .asset-row { border-radius: 0; border-left: 0; border-right: 0; border-bottom: 1px solid var(--border); background: transparent; }
.clean-list .asset-row:last-child { border-bottom: 0; }

/* Shared grids, assets, tables */
.grid.two { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 20px; margin-top: 20px; }
.compact-dashboard-grid { margin-top: 0; align-items: stretch; }
.stat-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 18px; margin-bottom: 18px; }
.stat-strip strong, .mini-stack strong { display: block; font-size: 24px; letter-spacing: -.03em; margin-top: 6px; }
.mini-stack { display: grid; gap: 12px; }
.mini-stack > div { padding: 14px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface-2); }
.soft-stack { align-content: start; }
.forex-margin-card { margin-bottom: 18px; background: linear-gradient(135deg, var(--surface), var(--green-soft)); }
.margin-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.margin-grid > div { padding: 15px; border: 1px solid var(--border); border-radius: 16px; background: rgba(255,255,255,.68); }
html[data-theme='dark'] .margin-grid > div { background: rgba(255,255,255,.04); }
.margin-grid strong { display: block; font-size: clamp(20px, 2vw, 28px); letter-spacing: -.035em; margin-top: 7px; }
.small-note { font-size: 13px; line-height: 1.55; margin: 14px 0 0; }
.section-title { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; }
.asset-list { display: grid; gap: 10px; }
.asset-list.compact { margin-top: 16px; }
.asset-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px; border: 1px solid var(--border); background: var(--surface-2); border-radius: 16px; }
.asset-row > div:first-child { display: grid; grid-template-columns: auto minmax(0,1fr); column-gap: 10px; align-items: center; min-width: 0; }
.asset-row strong, .asset-row small { display: block; }
.asset-row strong small { display: inline; font-weight: 600; font-size: 14px; }
.asset-row small { grid-column: 2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 360px; }
.asset-row .right { text-align: right; min-width: 126px; }
.asset-badge { grid-row: 1 / span 2; width: 38px; height: 38px; display: grid; place-items: center; border-radius: 11px; background: var(--green-wash); color: var(--green); font-weight: 900; text-transform: uppercase; }
.asset-badge.crypto { color: #c18608; background: rgba(240, 182, 74, .16); }
.asset-badge.forex { color: var(--blue); background: rgba(91,145,245,.14); }
.asset-badge.commodity { color: #e27725; background: rgba(226,119,37,.14); }
.asset-badge.index, .asset-badge.fund, .asset-badge.etf { color: var(--purple); background: rgba(139,92,246,.14); }
.timeline { display: grid; gap: 10px; }
.timeline article { display: grid; grid-template-columns: 48px minmax(0,1fr) auto; align-items: center; gap: 11px; padding: 12px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--border); }
.timeline article span { color: var(--green); font-size: 11px; font-weight: 900; }
.slim-timeline article { padding: 10px; }
.table-card { overflow: hidden; }
.responsive-table { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 14px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
td small { display: block; }
.empty { color: var(--muted); text-align: center; padding: 24px; }
.tag { display: inline-flex; align-items: center; justify-content: center; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: 12px; text-transform: capitalize; padding: 6px 10px; }
.tag.good { background: var(--green-wash); color: var(--green); }
.notification-card { margin-top: 22px; }
.feed { display: grid; gap: 10px; }
.feed article { padding: 12px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--border); }
.feed p { margin: 4px 0; color: var(--muted); }

/* Forms */
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 14px; align-items: end; }
.form-grid.wide { grid-template-columns: repeat(4, minmax(0,1fr)); }
.form-grid .full { grid-column: 1 / -1; }
label { display: grid; gap: 7px; color: var(--muted); font-weight: 700; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  min-height: 44px;
  padding: 10px 12px;
  outline: none;
}
textarea { resize: vertical; }
label small { font-weight: 600; color: var(--muted); font-size: 12px; line-height: 1.35; }
input:focus, select:focus, textarea:focus { border-color: var(--green); box-shadow: 0 0 0 4px var(--green-soft); }
.forex-preview { display: none; padding: 13px 14px; border: 1px solid rgba(91,145,245,.25); background: rgba(91,145,245,.10); color: var(--text); border-radius: 14px; font-size: 13px; line-height: 1.45; }
.forex-preview.is-visible { display: block; }
.code-sample { margin-top: 14px; padding: 14px; border-radius: 14px; background: var(--surface-2); overflow-x: auto; color: var(--muted); border: 1px solid var(--border); }
.checklist { margin: 0; padding-left: 20px; color: var(--muted); }
.checklist li { margin: 8px 0; }

/* Auth */
.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 10% 10%, var(--green-wash), transparent 35%), var(--bg); }
.auth-card { width: min(1060px, 100%); display: grid; grid-template-columns: 1.05fr .95fr; gap: 22px; align-items: stretch; }
.auth-hero { border-radius: 34px; padding: clamp(28px, 5vw, 48px); background: linear-gradient(135deg, #ffffff, #e8f7f5); border: 1px solid var(--border); box-shadow: var(--shadow); display: flex; flex-direction: column; justify-content: flex-end; min-height: 560px; }
html[data-theme='dark'] .auth-hero { background: linear-gradient(135deg, #142126, #0f171a); }
.auth-hero h1 { font-size: clamp(38px, 6vw, 68px); line-height: 1; margin: 20px 0 14px; }
.auth-hero p:not(.eyebrow) { color: var(--muted); font-size: 17px; max-width: 560px; }
.brand-mark.large { width: 64px; height: 64px; border-radius: 22px; }
.auth-form { display: flex; flex-direction: column; justify-content: center; gap: 16px; padding: clamp(22px, 4vw, 36px); }
.auth-form h2 { font-size: 30px; margin-bottom: 0; }
.mobile-nav { display: none; }

@media (max-width: 1280px) {
  :root { --sidebar: 236px; }
  .dashboard-grid { grid-template-columns: minmax(360px, .9fr) minmax(0, 1.1fr); gap: 20px; }
  .overview-card { grid-template-columns: 1fr; }
  .overview-panel + .overview-panel { border-left: 0; border-top: 1px solid var(--border); }
  .watch-chart-card { min-height: 500px; }
  .chart-shell { height: 330px; }
  .form-grid.wide { grid-template-columns: repeat(3, minmax(0,1fr)); }
}
@media (max-width: 1040px) {
  :root { --sidebar: 0; }
  .sidebar { display: none; }
  .shell { margin-left: 0; padding: 0 18px 94px; }
  .topbar { margin: 0 -18px 20px; padding: 12px 18px; }
  .searchbar { width: min(420px, 48vw); }
  .profile-card span { display: none; }
  .dashboard-grid, .grid.two, .auth-card { grid-template-columns: 1fr; }
  .margin-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .overview-card { grid-template-columns: 1fr 1fr; }
  .overview-panel + .overview-panel { border-top: 0; border-left: 1px solid var(--border); }
  .mobile-nav {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: 12px;
    z-index: 40;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
    padding: 8px;
    background: rgba(255,255,255,.9);
    border: 1px solid var(--border);
    border-radius: 24px;
    backdrop-filter: blur(20px);
    box-shadow: var(--shadow);
  }
  html[data-theme='dark'] .mobile-nav { background: rgba(18,28,32,.9); }
  .mobile-nav a { min-height: 52px; display: grid; place-items: center; gap: 0; color: var(--muted); border-radius: 18px; }
  .mobile-nav a.active { background: var(--green-wash); color: var(--green); }
  .mobile-nav span { color: inherit; }
  .mobile-nav small { font-size: 11px; }
}
@media (max-width: 760px) {
  body { font-size: 14px; }
  .topbar { height: auto; display: grid; grid-template-columns: 1fr auto; gap: 12px; }
  .searchbar { width: 100%; }
  .top-actions { gap: 6px; }
  .icon-button { width: 36px; height: 36px; }
  .profile-card em { width: 36px; height: 36px; font-size: 13px; }
  .page-title { align-items: flex-start; }
  .page-title .btn { display: none; }
  .overview-card { grid-template-columns: 1fr; }
  .overview-panel + .overview-panel { border-left: 0; border-top: 1px solid var(--border); }
  .market-cards { grid-auto-columns: minmax(148px, 66vw); }
  .watch-chart-card { padding: 20px; min-height: auto; }
  .chart-topline { align-items: stretch; flex-direction: column; margin-bottom: 18px; }
  .range-tabs { gap: 8px; }
  .range-tabs button { flex: 1 0 auto; }
  .chart-shell { height: 280px; }
  .form-grid, .form-grid.wide { grid-template-columns: 1fr 1fr; }
  .auth-shell { padding: 14px; }
  .auth-card { gap: 14px; }
  .auth-hero { min-height: 330px; border-radius: 24px; }
}
@media (max-width: 560px) {
  .shell { padding: 0 12px 92px; }
  .topbar { margin-left: -12px; margin-right: -12px; padding: 10px 12px; }
  .searchbar { grid-column: 1 / -1; order: 2; }
  .top-actions { justify-content: flex-end; }
  .card { padding: 16px; border-radius: 16px; }
  .overview-card, .assets-card { border-radius: 16px; }
  .overview-panel { padding: 18px 16px; }
  .metric-head strong { font-size: 23px; }
  .donut { width: 106px; height: 106px; }
  .donut span { width: 66px; height: 66px; }
  .mini-metrics.two-up { gap: 10px; }
  .asset-row { align-items: flex-start; }
  .asset-row small { max-width: 185px; }
  .asset-row .right { min-width: 96px; }
  .clean-list .asset-row { padding-left: 16px; padding-right: 16px; }
  .form-grid, .form-grid.wide, .margin-grid { grid-template-columns: 1fr; }
  .section-title { align-items: flex-start; flex-direction: column; gap: 4px; }
  table, thead, tbody, th, td, tr { display: block; }
  thead { display: none; }
  tr { padding: 12px 0; border-bottom: 1px solid var(--border); }
  td { display: grid; grid-template-columns: 112px minmax(0,1fr); gap: 8px; border: 0; padding: 8px 2px; }
  td::before { content: attr(data-label); color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
  td.empty { display: block; }
}

/* UI patch: trade modal, clickable assets, live price controls, asset details */
button.icon-button { border: 0; cursor: pointer; }
.ticker-actions button { border: 1px solid var(--border); color: var(--green); background: var(--surface-2); padding: 5px 12px; border-radius: 6px; font-size: 13px; cursor: pointer; }
.action-row { display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.action-row form { margin: 0; }
.compact-actions { justify-content: flex-end; }
.portfolio-actions { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.portfolio-actions h3 { margin: 0 0 4px; }
.portfolio-actions p { margin: 0; }
.clickable-row, .asset-link { color: inherit; text-decoration: none; }
.clickable-row { transition: transform .15s ease, background .15s ease, box-shadow .15s ease; }
.clickable-row:hover { transform: translateY(-1px); background: var(--green-wash); }
.asset-link strong { color: var(--text); }
.asset-link:hover strong { color: var(--green); }
.back-link { display: inline-flex; color: var(--green); font-weight: 800; margin-bottom: 14px; }
.asset-detail-hero { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.asset-title-line { display: flex; align-items: center; gap: 14px; }
.asset-title-line h2 { font-size: clamp(30px, 4vw, 48px); margin: 0; letter-spacing: -.05em; }
.asset-title-line p { margin: 4px 0 0; color: var(--muted); }
.asset-detail-grid { margin-bottom: 18px; }
.calc-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.calc-list > div { padding: 14px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface-2); }
.calc-list strong { display: block; font-size: 20px; margin-top: 5px; }
.modal-backdrop { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; background: rgba(9, 18, 20, .42); backdrop-filter: blur(10px); }
.modal-backdrop[hidden] { display: none !important; }
.modal-card { width: min(980px, 100%); max-height: min(92vh, 860px); overflow: auto; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); border-radius: 28px; padding: clamp(18px, 3vw, 28px); }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; margin-bottom: 18px; }
.modal-head h2 { margin: 0; font-size: 30px; }
.modal-head small { color: var(--muted); }
.modal-close { width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font-size: 24px; cursor: pointer; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }
body.modal-open { overflow: hidden; }
.mobile-add { min-height: 52px; display: grid; place-items: center; gap: 0; color: white; background: var(--green); border: 0; border-radius: 18px; cursor: pointer; font: inherit; font-weight: 850; }
.mobile-add span { color: inherit; font-size: 20px; }
.mobile-add small { font-size: 11px; color: inherit; }
.fallback-chart { width: 100%; height: 100%; color: var(--green); display: block; }
.fallback-chart .grid-lines line { stroke: var(--border); stroke-dasharray: 4 6; }
.fallback-chart .chart-label { fill: var(--muted); font-size: 16px; font-weight: 800; }
.fallback-chart .chart-label.gain { fill: var(--green); }
.fallback-chart .chart-label.loss { fill: var(--red); }

@media (max-width: 760px) {
  .portfolio-actions, .asset-detail-hero { align-items: stretch; flex-direction: column; }
  .action-row { justify-content: stretch; }
  .action-row .btn, .action-row form, .action-row form .btn { width: 100%; }
  .modal-backdrop { padding: 10px; align-items: end; }
  .modal-card { max-height: 94vh; border-radius: 24px 24px 0 0; }
  .modal-actions { flex-direction: column-reverse; }
  .modal-actions .btn { width: 100%; }
  .calc-list { grid-template-columns: 1fr; }
}

/* Ledger edit/delete actions */
.table-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.table-actions form { margin: 0; }

/* Live market data status */
.live-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  background: var(--card);
}
.live-status::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: currentColor;
  opacity: .55;
}
.live-status.active {
  color: var(--green);
}
@media (max-width: 760px) {
  .live-status { display: none; }
}
