:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-soft: #f8f9fb;
  --line: #dde2e8;
  --line-strong: #c9d0d8;
  --text: #151922;
  --muted: #697386;
  --muted-2: #8a94a6;
  --yellow: #ffdd2d;
  --yellow-deep: #e6bd00;
  --green: #008f4c;
  --green-soft: #eaf8f1;
  --red: #d92d3a;
  --red-soft: #fff0f1;
  --blue: #1769e0;
  --blue-soft: #edf4ff;
  --black: #111827;
  --shadow: 0 8px 26px rgba(24, 32, 45, .07);
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--bg); }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

button, input, select, textarea { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
.hidden { display: none !important; }
.positive { color: var(--green) !important; }
.negative { color: var(--red) !important; }
.muted { color: var(--muted); }

.topbar {
  position: sticky;
  z-index: 30;
  top: 0;
  display: grid;
  grid-template-columns: 270px minmax(480px, 1fr) 170px;
  align-items: center;
  min-height: 64px;
  padding: 0 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .97);
  backdrop-filter: blur(10px);
}

.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.brandMark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 8px;
  color: #111;
  background: var(--yellow);
  font-weight: 800;
}
.brand > span:last-child { display: grid; gap: 1px; min-width: 0; }
.brand b { font-size: 15px; }
.brand em { overflow: hidden; color: var(--muted); font-size: 11px; font-style: normal; text-overflow: ellipsis; white-space: nowrap; }

.mainNav { display: flex; justify-content: center; align-self: stretch; gap: 28px; }
.navButton {
  position: relative;
  border: 0;
  color: var(--muted);
  background: transparent;
  font-size: 13px;
  font-weight: 600;
}
.navButton::after {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 3px;
  background: transparent;
  content: "";
}
.navButton:hover, .navButton.active { color: var(--text); }
.navButton.active::after { background: var(--text); }
.navCount {
  display: inline-grid;
  min-width: 18px;
  height: 18px;
  margin-left: 4px;
  padding: 0 5px;
  place-items: center;
  border-radius: 9px;
  color: #111;
  background: var(--yellow);
  font-size: 10px;
  font-style: normal;
}
.legacyLink {
  justify-self: end;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--muted);
  background: #fff;
  font-size: 12px;
  font-weight: 600;
}
.legacyLink:hover { border-color: var(--line-strong); color: var(--text); }

.workspace { display: grid; grid-template-columns: 258px minmax(0, 1fr); min-height: calc(100vh - 64px); }
.sidebar {
  position: sticky;
  top: 64px;
  align-self: start;
  min-height: calc(100vh - 64px);
  padding: 26px 18px;
  border-right: 1px solid var(--line);
  background: #eef1f4;
}
.portfolioIdentity { padding: 0 2px 22px; border-bottom: 1px solid var(--line-strong); }
.portfolioIdentity > span, .sideMetric span { color: var(--muted); font-size: 11px; }
.portfolioIdentity h2 { margin: 5px 0 14px; font-size: 18px; line-height: 1.25; }
.portfolioIdentity > b { display: block; font-size: 29px; line-height: 1; }
.portfolioIdentity > em { display: block; margin-top: 8px; color: var(--green); font-size: 10px; font-style: normal; line-height: 1.45; }
.sideMetric { display: grid; gap: 4px; padding: 15px 2px; border-bottom: 1px solid var(--line-strong); }
.sideMetric b { font-size: 15px; }

.walletSection { padding-top: 22px; }
.sideHeading { display: flex; align-items: center; justify-content: space-between; }
.sideHeading h3 { margin: 0; font-size: 13px; }
.iconButton {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  color: var(--text);
  background: #fff;
  font-size: 19px;
  line-height: 1;
}
.iconButton:hover { border-color: var(--text); }
.walletList { display: grid; gap: 6px; margin-top: 12px; }
.walletItem {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  align-items: center;
  min-height: 48px;
  padding: 6px 7px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
}
.walletItem:hover, .walletItem.active { border-color: var(--line-strong); background: #fff; }
.walletItem.active { box-shadow: inset 3px 0 0 var(--yellow-deep); }
.walletAvatar { display: grid; width: 26px; height: 26px; place-items: center; border-radius: 50%; color: #fff; background: var(--black); font-size: 10px; font-weight: 700; }
.walletCopy { min-width: 0; }
.walletCopy b, .walletCopy span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.walletCopy b { font-size: 12px; }
.walletCopy span { margin-top: 2px; color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 9px; }
.walletTools { display: flex; gap: 1px; opacity: 0; }
.walletItem:hover .walletTools, .walletItem.active .walletTools { opacity: 1; }
.walletTools button { width: 24px; height: 24px; padding: 0; border: 0; color: var(--muted); background: transparent; font-size: 14px; }
.walletTools button:hover { color: var(--text); }

.addWalletForm { display: grid; gap: 9px; margin-top: 12px; padding: 12px; border: 1px solid var(--line-strong); border-radius: 7px; background: #fff; }
.addWalletForm label, .modalForm label { display: grid; gap: 5px; color: var(--muted); font-size: 10px; font-weight: 600; }
.addWalletForm input, .modalForm input, .modalForm select, .modalForm textarea {
  width: 100%;
  min-height: 36px;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  outline: 0;
  color: var(--text);
  background: #fff;
}
.addWalletForm input:focus, .modalForm input:focus, .modalForm select:focus, .modalForm textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 2px rgba(23, 105, 224, .1); }
.addWalletForm > div { display: flex; align-items: center; gap: 8px; }
.smallPrimary { min-height: 32px; padding: 0 12px; border: 0; border-radius: 6px; color: #111; background: var(--yellow); font-size: 11px; font-weight: 700; }
.textButton { padding: 4px 0; border: 0; color: var(--blue); background: transparent; font-size: 12px; font-weight: 600; }
.textButton:hover { color: #0d4ea9; }
.sideFoot { margin-top: 28px; padding: 12px; border-left: 3px solid var(--green); color: var(--muted); background: rgba(255, 255, 255, .6); }
.sideFoot span { color: var(--text); font-size: 11px; font-weight: 700; }
.sideFoot p { margin: 4px 0 0; font-size: 10px; line-height: 1.5; }
.sideFoot small { display: block; margin-top: 8px; color: var(--muted); font-size: 9px; line-height: 1.4; }
.accessTools { display: flex; gap: 6px; margin-top: 10px; }
.accessTools button, .accessTools label { flex: 1; min-width: 0; padding: 7px 4px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--text); font: inherit; font-size: 9px; font-weight: 700; text-align: center; cursor: pointer; }

.content { min-width: 0; padding: 26px 28px 60px; }
.workHeader { display: flex; align-items: flex-end; justify-content: space-between; gap: 28px; margin-bottom: 18px; }
.eyebrow { color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; }
.workHeader h1 { margin: 6px 0 4px; font-size: 28px; line-height: 1.15; }
.workHeader p, .sectionToolbar p { margin: 0; color: var(--muted); font-size: 12px; }
.headerActions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.primaryButton, .secondaryButton {
  min-height: 40px;
  padding: 0 16px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.primaryButton { border: 1px solid var(--yellow-deep); color: #111; background: var(--yellow); }
.primaryButton:hover { background: #ffe45a; }
.secondaryButton { border: 1px solid var(--line-strong); color: var(--text); background: #fff; }
.secondaryButton:hover { border-color: var(--text); }
.primaryButton:disabled, .secondaryButton:disabled { cursor: wait; opacity: .55; }

.qualityBanner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 62px;
  margin-bottom: 16px;
  padding: 12px 16px;
  border: 1px solid #efcc19;
  border-left-width: 5px;
  border-radius: 7px;
  background: #fffbea;
}
.qualityBanner.good { border-color: #6acb94; background: var(--green-soft); }
.qualityBanner.risk { border-color: #f08a92; background: var(--red-soft); }
.qualityBanner b { font-size: 12px; }
.qualityBanner p { margin: 4px 0 0; color: #5f6673; font-size: 11px; line-height: 1.45; }

.view { display: none; }
.view.activeView { display: block; }
.kpiStrip {
  display: grid;
  grid-template-columns: 1.2fr repeat(4, minmax(145px, 1fr));
  margin-bottom: 16px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}
.kpi { min-width: 0; min-height: 112px; padding: 18px; border-right: 1px solid var(--line); }
.kpi:last-child { border-right: 0; }
.kpi span { display: block; color: var(--muted); font-size: 10px; font-weight: 600; }
.kpi b { display: block; margin-top: 11px; overflow: hidden; font-size: 23px; line-height: 1; text-overflow: ellipsis; white-space: nowrap; }
.kpi em { display: block; margin-top: 9px; color: var(--muted-2); font-size: 9px; font-style: normal; }
.primaryKpi { color: #fff; background: var(--black); }
.primaryKpi span, .primaryKpi em { color: #aab2c0; }
.importantKpi { box-shadow: inset 0 4px 0 var(--yellow); background: #fffdf1; }
.returnMethods {
  display:grid;
  grid-template-columns:repeat(4,minmax(0,1fr));
  margin-bottom:16px;
  overflow:hidden;
  border:1px solid var(--line);
  border-radius:8px;
  background:#fff;
}
.returnMethods > div { min-width:0; padding:13px 16px; border-right:1px solid var(--line); }
.returnMethods > div:last-child { border-right:0; }
.returnMethods span,.returnMethods em { display:block; color:var(--muted); font-size:9px; font-style:normal; }
.returnMethods b { display:block; margin:6px 0 5px; overflow:hidden; font-size:16px; text-overflow:ellipsis; white-space:nowrap; }

.panel {
  margin-bottom: 16px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 3px 12px rgba(24, 32, 45, .035);
}
.panelHead, .sectionToolbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.panelHead h2, .sectionToolbar h2 { margin: 0; font-size: 16px; }
.panelHead p { margin: 4px 0 0; color: var(--muted); font-size: 10px; }
.panelHead > span { color: var(--muted); font-size: 11px; }
.sectionToolbar { margin-bottom: 14px; }

.segmented { display: inline-flex; padding: 3px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface-soft); }
.segmented button { min-height: 30px; padding: 0 11px; border: 0; border-radius: 5px; color: var(--muted); background: transparent; font-size: 10px; font-weight: 600; }
.segmented button:hover { color: var(--text); }
.segmented button.active { color: var(--text); background: #fff; box-shadow: 0 1px 4px rgba(17, 24, 39, .1); }

.capitalChart { min-height: 305px; margin-top: 18px; overflow: hidden; }
.capitalChart svg { display: block; width: 100%; height: 305px; overflow: visible; }
.chartGrid { stroke: #e8ebef; stroke-width: 1; }
.chartAxisLabel { fill: var(--muted-2); font-size: 10px; }
.chartValuePath { fill: none; stroke: var(--green); stroke-linecap: round; stroke-linejoin: round; stroke-width: 3; }
.chartInvestedPath { fill: none; stroke: #52606f; stroke-dasharray: 7 6; stroke-linecap: round; stroke-width: 2; }
.chartArea { fill: rgba(0, 143, 76, .08); }
.chartDot { fill: #fff; stroke: var(--green); stroke-width: 3; }
.chartFlowDot { fill: var(--yellow-deep); stroke: #111; stroke-width: 1.5; }
.chartEmpty { display: grid; min-height: 275px; place-items: center; color: var(--muted); text-align: center; }
.chartEmpty b { display: block; color: var(--text); font-size: 15px; }
.chartEmpty p { max-width: 440px; margin: 8px auto 0; font-size: 11px; line-height: 1.55; }
.chartLegend { display: flex; flex-wrap: wrap; gap: 18px; padding-top: 8px; border-top: 1px solid var(--line); color: var(--muted); font-size: 10px; }
.chartLegend span { display: flex; align-items: center; gap: 6px; }
.chartLegend i { display: inline-block; width: 24px; height: 3px; }
.valueLine { background: var(--green); }
.investedLine { border-top: 2px dashed #52606f; }
.flowMark { width: 7px !important; height: 7px !important; border-radius: 50%; background: var(--yellow-deep); }
.flowSourceNote { margin: 0 0 14px; padding: 10px 12px; border-left: 3px solid var(--yellow-deep); background: #fffbea; color: var(--muted); font-size: 10px; line-height: 1.5; }
.flowSourceNote b { color: var(--text); }

.twoColumns { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr); gap: 16px; }
.insightColumns { grid-template-columns:minmax(0,1fr) minmax(0,1fr); }
.attributionList,.allocationList { display:grid; margin-top:12px; }
.attributionRow { display:flex; align-items:center; justify-content:space-between; gap:14px; min-height:48px; border-top:1px solid var(--line); }
.attributionRow:first-child,.allocationRow:first-child { border-top:0; }
.attributionRow b,.attributionRow span,.allocationRow b,.allocationRow span { display:block; }
.attributionRow b,.allocationRow b { font-size:11px; }
.attributionRow span,.allocationRow span { margin-top:3px; color:var(--muted); font-size:9px; }
.attributionRow strong { flex:0 0 auto; font-size:12px; }
.allocationRow { display:grid; grid-template-columns:minmax(120px,.8fr) minmax(100px,1fr); align-items:center; gap:14px; min-height:48px; border-top:1px solid var(--line); }
.allocationRow > i { display:block; height:7px; overflow:hidden; border-radius:5px; background:#edf0f3; }
.allocationRow > i > em { display:block; height:100%; border-radius:5px; background:var(--green); }
.deltaPlanPanel { margin-bottom: 14px; }
.deltaPlan { display: grid; gap: 12px; }
.deltaSummary { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.deltaSummary > div { display: grid; gap: 5px; padding: 12px 14px; border-right: 1px solid var(--line); }
.deltaSummary > div:last-child { border-right: 0; }
.deltaSummary span { color: var(--muted); font-size: 10px; }
.deltaSummary b { font-size: 17px; }
.deltaTrack { height: 8px; overflow: hidden; border-radius: 4px; background: #e8ebef; }
.deltaTrack i { display: block; height: 100%; background: var(--yellow); }
.allocationChips { display: flex; flex-wrap: wrap; gap: 7px; }
.allocationChips span { padding: 7px 9px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--muted); font-size: 10px; }
.allocationChips b { margin-right: 5px; color: var(--text); }
.allocationInputs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.panelNote { margin:10px 0 0; color:var(--muted); font-size:9px; line-height:1.5; }
.walletBreakdown { margin-top: 14px; }
.walletBreakdownRow {
  display: grid;
  grid-template-columns: minmax(130px, 1fr) minmax(120px, 1.1fr) 90px;
  align-items: center;
  gap: 14px;
  min-height: 52px;
  border-top: 1px solid var(--line);
}
.walletBreakdownRow:first-child { border-top: 0; }
.walletName b, .walletName span { display: block; }
.walletName b { font-size: 11px; }
.walletName span { margin-top: 3px; color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 9px; }
.walletBar { height: 7px; overflow: hidden; border-radius: 4px; background: #edf0f3; }
.walletBar i { display: block; height: 100%; border-radius: 4px; background: var(--blue); }
.walletValue { text-align: right; }
.walletValue b, .walletValue span { display: block; }
.walletValue b { font-size: 12px; }
.walletValue span { margin-top: 3px; color: var(--muted); font-size: 9px; }

.attentionList { display: grid; margin-top: 14px; }
.attentionItem { display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; align-items: center; gap: 10px; min-height: 52px; border-top: 1px solid var(--line); }
.attentionItem:first-child { border-top: 0; }
.attentionIcon { display: grid; width: 28px; height: 28px; place-items: center; border-radius: 50%; color: var(--text); background: #f0f2f5; font-size: 10px; font-weight: 800; }
.attentionIcon.warn { background: #fff5c7; }
.attentionIcon.risk { color: var(--red); background: var(--red-soft); }
.attentionCopy b, .attentionCopy span { display: block; }
.attentionCopy b { font-size: 11px; }
.attentionCopy span { margin-top: 3px; color: var(--muted); font-size: 9px; line-height: 1.4; }
.attentionItem button { border: 0; color: var(--blue); background: transparent; font-size: 10px; font-weight: 600; }

.monthStrip { display: grid; grid-template-columns: repeat(6, 1fr); margin-top: 14px; border-top: 1px solid var(--line); }
.monthMetric { padding: 16px 12px 4px 0; }
.monthMetric span, .monthMetric b { display: block; }
.monthMetric span { color: var(--muted); font-size: 9px; }
.monthMetric b { margin-top: 7px; font-size: 15px; }

.tablePanel { padding: 0; overflow: hidden; }
.responsiveTable { width: 100%; overflow-x: auto; }
.dataGrid { min-width: 980px; }
.dataHead, .dataRow { display: grid; align-items: center; gap: 14px; padding: 0 18px; }
.dataHead { min-height: 42px; border-bottom: 1px solid var(--line); color: var(--muted); background: var(--surface-soft); font-size: 9px; font-weight: 700; text-transform: uppercase; }
.dataRow { min-height: 76px; border-bottom: 1px solid var(--line); }
.dataRow:last-child { border-bottom: 0; }
.dataRow:hover { background: #fbfcfd; }
.positionGrid { grid-template-columns: minmax(120px, .8fr) minmax(200px, 1.4fr) minmax(110px, .8fr) minmax(150px, 1fr) minmax(170px, 1.15fr) 72px; }
.stableToolbar { margin-bottom: 14px; }
.stableControls { display: flex; align-items: end; gap: 12px; margin-bottom: 14px; }
.stableControls label { display: grid; gap: 5px; color: var(--muted); font-size: 9px; font-weight: 700; }
.stableControls select { min-height: 36px; min-width: 170px; padding: 0 30px 0 10px; border: 1px solid var(--line-strong); border-radius: 6px; color: var(--text); background: #fff; }
.stableSummary { display: grid; grid-template-columns: repeat(4, 1fr); margin-bottom: 14px; overflow: hidden; border: 1px solid var(--line); border-radius: 7px; background: #fff; }
.stableSummary > div { min-height: 74px; padding: 14px 16px; border-right: 1px solid var(--line); }
.stableSummary > div:last-child { border-right: 0; }
.stableSummary span, .stableSummary b { display: block; }
.stableSummary span { color: var(--muted); font-size: 9px; }
.stableSummary b { margin-top: 8px; font-size: 18px; }
.stablePanel .panelHead { margin: 0; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.sourceBadge { padding: 5px 8px; border-radius: 5px; color: #745d00; background: #fff6c4; font-size: 9px; font-weight: 700; }
.stableDataGrid { min-width: 1180px; }
.stableGrid { grid-template-columns: minmax(165px, 1.1fr) minmax(105px, .7fr) 105px 95px minmax(155px, 1fr) 110px minmax(180px, 1.15fr) 80px; }
.stableProtocol { display: flex; align-items: center; gap: 9px; min-width: 0; }
.stableProtocol b, .stableProtocol span, .stableApy b, .stableApy span { display: block; }
.stableProtocol b { font-size: 11px; }
.stableProtocol span, .stableApy span { margin-top: 3px; color: var(--muted); font-size: 9px; }
.strategyMark { display: grid !important; flex: 0 0 auto; width: 31px; height: 31px; margin: 0 !important; place-items: center; border-radius: 50%; color: #3d2c00 !important; background: #fff1a6; font-size: 9px !important; font-weight: 800; }
.strategyMark.lending { color: #244c84 !important; background: #eaf2ff; }
.stableType { display: inline-flex; min-height: 23px; padding: 0 8px; align-items: center; border-radius: 4px; color: #725c00; background: #fff6c8; font-size: 9px; font-weight: 700; }
.stableType.lending { color: #24558d; background: #edf5ff; }
.stableApy b { color: var(--green); font-size: 15px; }
.stableRisk { display: inline-flex !important; width: fit-content; min-height: 22px; margin: 0 !important; padding: 0 7px; align-items: center; border-radius: 4px; color: var(--green) !important; background: var(--green-soft); font-size: 9px !important; font-weight: 700; }
.stableRisk.medium { color: #856100 !important; background: #fff5c5; }
.stableRisk.high { color: var(--red) !important; background: var(--red-soft); }
.openStrategy { color: var(--blue); font-size: 10px; font-weight: 700; white-space: nowrap; }
.stableLoading { padding: 54px 20px; color: var(--muted); text-align: center; font-size: 12px; }
.stablePanel > .panelNote { margin: 0; padding: 12px 18px; border-top: 1px solid var(--line); background: #fffdf1; }
.cellWallet b, .cellWallet span, .positionTitle b, .positionTitle span, .metricCell b, .metricCell span { display: block; }
.cellWallet b, .positionTitle b, .metricCell b { font-size: 11px; }
.cellWallet span, .positionTitle span, .metricCell span { margin-top: 3px; color: var(--muted); font-size: 9px; line-height: 1.4; }
.positionTitle { display: flex; align-items: center; gap: 9px; min-width: 0; }
.protocolMark { display: grid; flex: 0 0 auto; width: 30px; height: 30px; place-items: center; border-radius: 50%; color: var(--text); background: #f1f3f6; font-size: 9px; font-weight: 800; }
.protocolMark.lp { color: #b11c68; background: #fff0f7; }
.protocolMark.lending { color: #5b42c7; background: #f2efff; }
.statusPill { display: inline-flex; align-items: center; min-height: 23px; padding: 0 8px; border-radius: 12px; color: var(--muted); background: #eef1f4; font-size: 9px; font-weight: 700; }
.statusPill.in { color: var(--green); background: var(--green-soft); }
.statusPill.warn { color: #8a6200; background: #fff4c2; }
.statusPill.out { color: var(--red); background: var(--red-soft); }
.tableEmpty { padding: 50px 20px; color: var(--muted); text-align: center; font-size: 12px; }

.pendingPanel { border-color: #efcc19; }
.pendingPanel .panelHead > span { display: grid; min-width: 26px; height: 26px; padding: 0 7px; place-items: center; border-radius: 13px; color: #111; background: var(--yellow); font-weight: 800; }
.flowList, .flowLedger { margin-top: 12px; }
.flowRow { display: grid; grid-template-columns: 105px minmax(130px, .8fr) minmax(230px, 1.5fr) 120px auto; align-items: center; gap: 14px; min-height: 70px; border-top: 1px solid var(--line); }
.flowRow:first-child { border-top: 0; }
.flowDate b, .flowDate span, .flowWallet b, .flowWallet span, .flowMeta b, .flowMeta span { display: block; }
.flowDate b, .flowWallet b, .flowMeta b { font-size: 10px; }
.flowDate span, .flowWallet span, .flowMeta span { margin-top: 3px; color: var(--muted); font-size: 9px; }
.flowAmount { font-size: 13px; font-weight: 800; text-align: right; }
.flowActions { display: flex; justify-content: flex-end; gap: 5px; }
.flowActions button { min-height: 30px; padding: 0 9px; border: 1px solid var(--line); border-radius: 6px; color: var(--text); background: #fff; font-size: 9px; font-weight: 600; }
.flowActions button:hover { border-color: var(--text); }
.flowActions .confirm { border-color: #63c590; color: var(--green); background: var(--green-soft); }
.flowBadge { display: inline-flex; min-height: 22px; padding: 0 8px; align-items: center; border-radius: 11px; color: var(--muted); background: #eef1f4; font-size: 9px; font-weight: 700; }
.flowBadge.external { color: var(--green); background: var(--green-soft); }
.flowBadge.internal { color: var(--blue); background: var(--blue-soft); }
.flowBadge.ignored { color: var(--muted); background: #f0f1f3; }

.monthGrid { grid-template-columns: minmax(120px, 1fr) repeat(6, minmax(110px, .8fr)) 105px; }
.monthStatus { display: inline-flex; min-height: 23px; padding: 0 8px; align-items: center; border-radius: 12px; color: var(--blue); background: var(--blue-soft); font-size: 9px; font-weight: 700; }
.monthStatus.frozen { color: var(--green); background: var(--green-soft); }
.monthStatus.estimate { color: #895f00; background: #fff5c7; }
.telegramPanel pre { margin: 14px 0 0; padding: 16px; overflow: auto; border: 1px solid var(--line); border-radius: 7px; color: #dce5ef; background: #19202a; font-family: Inter, sans-serif; font-size: 12px; line-height: 1.65; white-space: pre-wrap; }

.emptyState { display: grid; min-height: calc(100vh - 160px); place-items: center; align-content: center; text-align: center; }
.emptyMark { display: grid; width: 58px; height: 58px; place-items: center; border-radius: 8px; color: #111; background: var(--yellow); font-size: 24px; font-weight: 800; }
.emptyState h1 { margin: 18px 0 6px; font-size: 25px; }
.emptyState p { margin: 0 0 18px; color: var(--muted); }

.syncProgress {
  position: fixed;
  z-index: 100;
  top: 76px;
  right: 22px;
  width: min(420px, calc(100vw - 32px));
  padding: 14px 16px;
  border: 1px solid #e3bf00;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 16px 42px rgba(17, 24, 39, .2);
}
.syncProgressTop { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.syncProgressTop b { font-size: 12px; }
.syncProgressTop span { color: var(--muted); font-size: 10px; }
.syncTrack { height: 6px; margin-top: 10px; overflow: hidden; border-radius: 3px; background: #eceff2; }
.syncTrack i { display: block; width: 0; height: 100%; border-radius: 3px; background: var(--yellow-deep); transition: width .35s ease; }
.syncProgress p { margin: 8px 0 0; color: var(--muted); font-size: 10px; }

.modal { position: fixed; z-index: 120; inset: 0; display: grid; padding: 20px; place-items: center; background: rgba(15, 23, 42, .45); }
.modalCard { position: relative; width: min(520px, 100%); max-height: calc(100vh - 40px); overflow: auto; padding: 24px; border-radius: 8px; background: #fff; box-shadow: 0 22px 70px rgba(15, 23, 42, .28); }
.modalClose { position: absolute; top: 10px; right: 10px; display: grid; width: 30px; height: 30px; padding: 0; place-items: center; border: 0; border-radius: 50%; color: var(--muted); background: #f0f2f5; font-size: 19px; }
.modalClose:hover { color: var(--text); }
.modalCard h2 { margin: 0 38px 5px 0; font-size: 19px; }
.modalCard > div > p { margin: 0 0 18px; color: var(--muted); font-size: 11px; line-height: 1.5; }
.modalForm { display: grid; gap: 13px; }
.modalForm textarea { min-height: 76px; resize: vertical; }
.modalActions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.modalNote { padding: 10px 12px; border-left: 3px solid var(--yellow-deep); color: var(--muted); background: #fffbea; font-size: 10px; line-height: 1.5; }

.toast { position: fixed; z-index: 140; right: 24px; bottom: 24px; max-width: 380px; padding: 12px 15px; border-radius: 7px; color: #fff; background: var(--black); box-shadow: 0 10px 30px rgba(15, 23, 42, .25); font-size: 11px; }

@media (max-width: 1180px) {
  .topbar { grid-template-columns: 220px minmax(430px, 1fr) 140px; }
  .mainNav { gap: 15px; }
  .workspace { grid-template-columns: 220px minmax(0, 1fr); }
  .content { padding: 22px 20px 50px; }
  .kpiStrip { grid-template-columns: repeat(3, 1fr); }
  .kpi { border-bottom: 1px solid var(--line); }
  .kpi:nth-child(3) { border-right: 0; }
  .kpi:nth-child(n+4) { border-bottom: 0; }
  .twoColumns { grid-template-columns: 1fr; }
  .returnMethods { grid-template-columns:repeat(2,1fr); }
  .returnMethods > div:nth-child(2) { border-right:0; }
  .returnMethods > div:nth-child(-n+2) { border-bottom:1px solid var(--line); }
  .flowRow { grid-template-columns: 90px minmax(120px, .7fr) minmax(180px, 1fr) 100px; }
  .flowActions { grid-column: 1 / -1; justify-content: flex-start; padding-bottom: 10px; }
}

@media (max-width: 860px) {
  .topbar { position: relative; grid-template-columns: 1fr auto; padding: 10px 14px; }
  .mainNav { grid-column: 1 / -1; order: 3; justify-content: flex-start; gap: 0; margin: 8px -14px -10px; overflow-x: auto; border-top: 1px solid var(--line); }
  .navButton { flex: 0 0 auto; min-height: 46px; padding: 0 14px; }
  .legacyLink { display: none; }
  .workspace { display: block; }
  .sidebar { position: relative; top: 0; min-height: 0; padding: 14px; border-right: 0; border-bottom: 1px solid var(--line); }
  .portfolioIdentity { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 2px 12px; padding-bottom: 12px; }
  .portfolioIdentity > span, .portfolioIdentity h2 { grid-column: 1; }
  .portfolioIdentity h2 { margin: 2px 0 0; font-size: 15px; }
  .portfolioIdentity > b { grid-column: 2; grid-row: 1 / span 2; font-size: 22px; }
  .portfolioIdentity > em { grid-column: 1 / -1; }
  .sideMetric { display: none; }
  .sideFoot { display: block; margin: 10px 0 0; padding: 0; border: 0; background: transparent; }
  .sideFoot > span, .sideFoot > p, .sideFoot > small { display: none; }
  .sideFoot .accessTools { max-width: 300px; margin-top: 0; }
  .walletSection { padding-top: 12px; }
  .walletList { display: flex; overflow-x: auto; }
  .walletItem { flex: 0 0 190px; background: rgba(255,255,255,.55); }
  .walletTools { opacity: 1; }
  .content { padding: 18px 14px 42px; }
  .workHeader { align-items: flex-start; flex-direction: column; gap: 14px; }
  .headerActions { justify-content: flex-start; width: 100%; }
  .headerActions .primaryButton { flex: 1; }
  .kpiStrip { grid-template-columns: repeat(2, 1fr); }
  .kpi:nth-child(2n) { border-right: 0; }
  .kpi:nth-child(3) { border-right: 1px solid var(--line); }
  .kpi:nth-child(n+4) { border-bottom: 1px solid var(--line); }
  .kpi:last-child { grid-column: 1 / -1; border-bottom: 0; }
  .panelHead { align-items: flex-start; flex-direction: column; }
  .chartPanel .panelHead { align-items: stretch; }
  .segmented { max-width: 100%; overflow-x: auto; }
  .capitalChart, .capitalChart svg { min-height: 245px; height: 245px; }
  .monthStrip { grid-template-columns: repeat(3, 1fr); }
  .deltaSummary { grid-template-columns: repeat(2, 1fr); }
  .deltaSummary > div:nth-child(2) { border-right: 0; }
  .deltaSummary > div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .allocationInputs { grid-template-columns: repeat(2, 1fr); }
  .sectionToolbar { align-items: flex-start; flex-direction: column; }
  .stableControls { align-items: stretch; flex-direction: column; }
  .stableControls select { width: 100%; }
  .stableSummary { grid-template-columns: repeat(2, 1fr); }
  .stableSummary > div:nth-child(2) { border-right: 0; }
  .stableSummary > div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
}

@media (max-width: 540px) {
  body { font-size: 13px; }
  .brand em { max-width: 150px; }
  .workHeader h1 { font-size: 23px; }
  .headerActions { display: grid; grid-template-columns: 1fr 1fr; }
  .headerActions .primaryButton { grid-column: 1 / -1; }
  .primaryButton, .secondaryButton { padding: 0 11px; }
  .qualityBanner { align-items: flex-start; }
  .kpiStrip { grid-template-columns: 1fr 1fr; }
  .kpi { min-height: 102px; padding: 15px; }
  .kpi b { font-size: 19px; }
  .returnMethods { grid-template-columns:1fr 1fr; }
  .returnMethods > div { padding:11px 12px; }
  .panel { padding: 15px; }
  .tablePanel { padding: 0; }
  .walletBreakdownRow { grid-template-columns: minmax(105px, 1fr) 80px; }
  .walletBar { display: none; }
  .monthStrip { grid-template-columns: repeat(2, 1fr); }
  .flowRow { grid-template-columns: 86px minmax(0, 1fr) 90px; padding: 10px 0; }
  .flowWallet { display: none; }
  .flowMeta { min-width: 0; }
  .flowActions { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; }
  .flowActions button { min-height: 36px; }
  .syncProgress { top: 12px; right: 12px; }
  .toast { right: 12px; bottom: 12px; left: 12px; max-width: none; }
}
