:root {
  --bg: #eef2f6;
  --surface: #ffffff;
  --line: #d8dee7;
  --text: #152033;
  --muted: #647084;
  --accent: #22577a;
  --accent-2: #287271;
  --green: #147d52;
  --red: #b42318;
  --amber: #b7791f;
  --row: #f7f9fb;
  --shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 14px;
}

.shell { min-height: 100vh; }

.topbar {
  min-height: 72px;
  display: grid;
  grid-template-columns: minmax(190px, 1fr) auto auto;
  grid-template-areas:
    "brand tabs actions";
  align-items: center;
  gap: 14px;
  padding: 10px 22px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand { grid-area: brand; display: flex; align-items: center; gap: 12px; min-width: 0; }
.mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: white;
  font-weight: 800;
  border-radius: 6px;
}
h1 { margin: 0; font-size: 20px; letter-spacing: 0; }
p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }

.tabs {
  grid-area: tabs;
  justify-self: end;
  display: grid;
  grid-template-columns: repeat(5, minmax(86px, 1fr));
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  min-width: 430px;
}

.tab {
  height: 38px;
  border: 0;
  border-right: 1px solid var(--line);
  background: #f8fafc;
  color: var(--text);
  font-weight: 650;
  cursor: pointer;
}
.tab:last-child { border-right: 0; }
.tab.active { background: var(--accent); color: white; }

.marketRates {
  grid-area: rates;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: grid;
  grid-template-columns: repeat(4, minmax(96px, 1fr));
  gap: 10px;
  width: min(560px, 100%);
  z-index: 0;
}

.ratePill {
  min-height: 50px;
  display: grid;
  align-content: center;
  gap: 2px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfdff;
  text-align: center;
  box-shadow: 0 6px 14px rgba(15, 23, 42, 0.08);
}

.ratePill span {
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
}

.ratePill strong {
  font-size: 15px;
  line-height: 1.15;
  white-space: nowrap;
}

.rate-btc {
  background: #fff7ed;
  border-color: #f3d3aa;
  color: #9a4f08;
}

.rate-eth {
  background: #f4f2ff;
  border-color: #cbc5f6;
  color: #42329a;
}

.rate-usdpln {
  background: #edf8f2;
  border-color: #b8dec9;
  color: #0f6843;
}

.rate-eurpln {
  background: #eef6fd;
  border-color: #b8d6ee;
  color: #175d9a;
}

.actions { grid-area: actions; display: flex; align-items: center; justify-self: end; gap: 8px; }
.brand,
.tabs,
.actions {
  position: relative;
  z-index: 1;
}
.iconButton {
  position: relative;
  width: 38px;
  height: 38px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.iconButton:disabled {
  cursor: wait;
  opacity: 0.55;
}

.refreshProgress {
  --progress: 0deg;
  --progress-color: #b42318;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: conic-gradient(var(--progress-color) var(--progress), #e5eaf0 0);
  box-shadow: 0 2px 9px rgba(15, 23, 42, 0.16);
  transition: background 0.25s ease, transform 0.2s ease;
}

.refreshProgress::before {
  content: "";
  grid-area: 1 / 1;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: white;
}

.refreshProgress span {
  grid-area: 1 / 1;
  position: relative;
  color: var(--text);
  font-size: 10px;
  font-weight: 900;
  line-height: 1;
}

.refreshProgress.running {
  transform: scale(1.04);
}

.refreshProgress.failed {
  --progress-color: var(--red);
}

.refreshProgress.hidden {
  display: none;
}

.alertMenu {
  position: relative;
}

.alertButton.hasAlerts {
  border-color: #d99b2b;
  background: #fff4db;
}

.alertBadge {
  position: absolute;
  top: -7px;
  right: -7px;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--red);
  color: white;
  font-size: 11px;
  font-weight: 900;
  line-height: 19px;
  text-align: center;
}

.alertPanel {
  position: absolute;
  top: 46px;
  right: 0;
  z-index: 30;
  width: min(420px, calc(100vw - 28px));
  max-height: 360px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  box-shadow: var(--shadow);
}

.alertPanelHead {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
  font-size: 15px;
  font-weight: 900;
}

.alertList {
  max-height: 306px;
  overflow-y: auto;
  display: grid;
}

.alertItem {
  display: grid;
  gap: 4px;
  padding: 11px 14px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: white;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.alertItem:hover {
  background: #fff4db;
}

.alertItem strong {
  font-size: 14px;
}

.alertItem strong span {
  color: var(--muted);
  font-size: 12px;
}

.alertItem em {
  color: var(--muted);
  font-style: normal;
  font-size: 13px;
  line-height: 1.35;
}

.alertEmpty {
  padding: 14px;
  color: var(--muted);
  font-size: 13px;
}

main { padding: 18px 22px 24px; }
.view { display: none; }
.view.active { display: block; }

.kpiGrid {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.kpiGrid.dividendKpis {
  grid-template-columns: repeat(auto-fit, minmax(240px, 300px));
  justify-content: center;
}

.kpiGrid.progressKpis {
  grid-template-columns: repeat(3, minmax(180px, 1fr));
}

.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px 14px;
  min-height: 76px;
  box-shadow: var(--shadow);
  text-align: center;
  display: grid;
  align-content: center;
}
.kpi span { display: block; color: var(--muted); font-size: 15px; margin-bottom: 8px; font-weight: 800; }
.kpi strong { display: block; font-size: 24px; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi.resultKpi.positive {
  background: #e1f4e8;
  border-color: #9bd3b3;
}
.kpi.resultKpi.negative {
  background: #fde7e4;
  border-color: #efaaa2;
}
.kpi.resultKpi span { color: var(--text); }
.kpi.resultKpi strong { font-size: 26px; }
.positive { color: var(--green); }
.negative { color: var(--red); }
.warning { color: var(--amber); }

.workbench {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.filters, .panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: var(--shadow);
}

.filters {
  padding: 14px;
  display: grid;
  gap: 12px;
  position: sticky;
  top: 90px;
  text-align: center;
}

.filters label,
.filters .check {
  justify-items: center;
}

.filters .check {
  grid-template-columns: 18px auto;
  justify-content: center;
}

.filters input,
.filters select {
  text-align: center;
}

label { display: grid; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 650; }
input, select {
  width: 100%;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  background: white;
  color: var(--text);
  font: inherit;
}
.check { grid-template-columns: 18px 1fr; align-items: center; color: var(--text); }
.check input { width: 16px; height: 16px; padding: 0; }

.primaryButton {
  height: 36px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: white;
  font-weight: 800;
  cursor: pointer;
}

.secondaryButton {
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--text);
  font-weight: 800;
  cursor: pointer;
}

.actionButton {
  height: 38px;
  border: 1px solid;
  border-radius: 6px;
  font-weight: 900;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.actionButton:hover {
  transform: translateY(-1px);
}

.actionPosition {
  background: #eaf7ef;
  border-color: #a8d8b8;
  color: #166534;
}

.actionPosition:hover {
  background: #dcf2e4;
  border-color: #79bd92;
}

.actionWatchlist {
  background: #fff7e6;
  border-color: #f0cc8d;
  color: #92400e;
}

.actionWatchlist:hover {
  background: #ffefcf;
  border-color: #dda94f;
}

.actionDividend {
  background: #f3efff;
  border-color: #cbbef5;
  color: #5b21b6;
}

.actionDividend:hover {
  background: #ebe4ff;
  border-color: #aa94ed;
}

.formActions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.formActions .primaryButton,
.formActions .secondaryButton {
  height: auto;
  min-height: 36px;
  padding: 8px;
  line-height: 1.2;
  white-space: normal;
}

.addForm {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
}

.addForm.collapsed {
  display: none;
}

.sidebarStack {
  display: grid;
  gap: 10px;
}

.sidebarGroup {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  justify-items: stretch;
  text-align: center;
}

.sidebarGroup > strong {
  font-size: 13px;
  font-weight: 900;
}

.mediaSidebarGroup {
  gap: 12px;
  padding: 14px;
  background: #fbfdff;
}

.mediaSidebarGroup > strong {
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
  color: var(--accent);
  font-size: 14px;
}

.sidebarActionButton {
  height: 40px;
}

.mediaNav {
  gap: 10px;
}

.mediaNav .subTab {
  position: relative;
  height: 40px;
  border-color: #cbd5e1;
  background: #ffffff;
  color: var(--text);
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.04);
}

.mediaNav .subTab::before {
  content: "";
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 4px;
  border-radius: 0 3px 3px 0;
  background: #b8c5d4;
}

.mediaNav .subTab.active {
  background: #eef6fb;
  border-color: #9fc1d7;
  color: var(--accent);
}

.mediaNav .subTab.active::before {
  background: var(--accent);
}

.sidebarEmpty {
  padding: 12px;
  border: 1px dashed var(--line);
  border-radius: 6px;
  background: #ffffff;
  font-size: 13px;
}

.panel { overflow: hidden; }
.panelHead {
  height: 50px;
  display: grid;
  grid-template-columns: 1fr;
  place-items: center;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
}
h2 { margin: 0; font-size: 21px; letter-spacing: 0; text-align: center; }
.muted { color: var(--muted); font-size: 12px; }

.subTabs {
  display: flex;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
}

.sidebarTabs {
  display: grid;
  grid-template-columns: 1fr;
  padding: 0;
  border: 0;
  background: transparent;
}

.subTab {
  height: 34px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--text);
  font-weight: 800;
  cursor: pointer;
}

.subTab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.hidden { display: none; }

.tableWrap {
  max-height: none;
  overflow-x: auto;
  overflow-y: visible;
}
table {
  width: 100%;
  border-collapse: collapse;
  min-width: 920px;
}
th, td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: center;
  white-space: nowrap;
  font-size: 16px;
}
th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f6f8fb;
  color: var(--muted);
  font-size: 15px;
  font-weight: 850;
}
tbody tr:nth-child(even) { background: var(--row); }
tbody tr:hover { background: #edf6f4; }
tbody tr.row-positive,
tbody tr.row-positive:nth-child(even),
tbody tr.row-positive:hover { background: #e7f5ec; }
tbody tr.row-negative,
tbody tr.row-negative:nth-child(even),
tbody tr.row-negative:hover { background: #fdecea; }
tbody tr.row-neutral { background: #f7f9fb; }
tbody tr.row-watch-alert,
tbody tr.row-watch-alert:nth-child(even),
tbody tr.row-watch-alert:hover {
  background: #fff1c2;
}

.watchlistGroupRow,
.watchlistGroupRow:nth-child(even),
.watchlistGroupRow:hover {
  background: #e8eef5;
}

.watchlistGroupRow td {
  padding: 0;
  border-bottom: 1px solid #cbd5e1;
}

.watchlistGroupToggle {
  width: 100%;
  min-height: 46px;
  display: grid;
  grid-template-columns: 24px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.watchlistGroupToggle strong {
  font-size: 15px;
  font-weight: 900;
}

.watchlistGroupToggle em {
  min-width: 30px;
  padding: 3px 9px;
  border-radius: 999px;
  background: white;
  color: var(--accent);
  font-size: 12px;
  font-style: normal;
  font-weight: 900;
  text-align: center;
}

.watchlistGroupChevron {
  color: var(--accent);
  font-size: 19px;
  font-weight: 900;
  text-align: center;
}

.watchlistGroupActions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.watchlistGroupActions.hidden {
  display: none;
}

.watchlistGroupActions .secondaryButton {
  height: auto;
  min-height: 36px;
  padding: 7px 8px;
  line-height: 1.15;
  white-space: normal;
}

#autoGroupWatchlist {
  grid-column: 1 / -1;
}

.expandBtn {
  width: 24px;
  height: 24px;
  margin-right: 8px;
  border: 1px solid #b8c5d4;
  border-radius: 4px;
  background: #ffffff;
  color: var(--accent);
  font-weight: 800;
  cursor: pointer;
}

.rowActions {
  display: flex;
  justify-content: center;
  gap: 6px;
}

.smallButton {
  height: 30px;
  padding: 0 11px;
  border: 1px solid #b8c5d4;
  border-radius: 4px;
  background: #ffffff;
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.dangerButton {
  color: var(--red);
  border-color: #efb4ad;
}

.closeButton {
  color: #147d52;
  border-color: #9fd2b8;
}

.detail-row,
.detail-row:hover {
  background: #ffffff;
}

.detail-row td {
  padding: 0;
  border-bottom: 1px solid var(--line);
}

.detailBox {
  padding: 14px 18px 18px;
  background: #ffffff;
  border-top: 1px solid #cfd8e3;
}

.detailTitle {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-align: left;
}

.innerTable {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}

.innerTable th,
.innerTable td {
  font-size: 15px;
  padding: 8px 10px;
}

.metricCell {
  font-weight: 800;
}

.regularPrice,
.currentPriceValue {
  color: var(--text);
  font-size: 18px;
  line-height: 1.15;
  font-weight: 950;
}

.regularPriceStack {
  display: inline-grid;
  justify-items: center;
  gap: 2px;
}

.regularPriceStack em {
  font-size: 12px;
  font-style: normal;
  font-weight: 850;
}

.extendedPriceLine {
  display: inline-grid;
  grid-template-columns: 92px 76px 116px;
  align-items: center;
  gap: 6px;
  padding: 3px 7px;
  border-radius: 999px;
  background: #f8fafc;
  font-size: 12px;
  line-height: 1.1;
  font-weight: 800;
}

.extendedPriceLine span {
  font-weight: 850;
}

.extendedPriceLine strong {
  font-size: 12px;
  text-align: right;
}

.extendedPriceLine em {
  font-style: normal;
  font-size: 12px;
  text-align: right;
}

.extendedPriceLine .positive {
  color: var(--green);
}

.extendedPriceLine .negative {
  color: var(--red);
}

.preMarketLine span { color: #d97706; }

.preMarketLine {
  background: #fff7ed;
  border: 1px solid #fed7aa;
}

.preMarketStack {
  min-width: 104px;
  display: inline-grid;
  justify-items: center;
  gap: 4px;
  padding: 8px 12px;
  border: 1px solid #fed7aa;
  border-radius: 10px;
  background: #fff7ed;
  line-height: 1.05;
}

.preMarketStack strong {
  color: var(--text);
  font-size: 18px;
  font-weight: 950;
}

.preMarketStack em {
  font-size: 13px;
  font-style: normal;
  font-weight: 900;
}

.mutedPreMarketStack {
  color: var(--muted);
  opacity: 0.7;
}

.mutedPreMarketStack strong {
  color: var(--muted);
}

.compactMarketLine {
  grid-template-columns: 76px 116px;
}

.mutedMarketLine {
  grid-template-columns: auto auto;
  color: var(--muted);
  opacity: 0.72;
}

.tickerColumn {
  width: 86px;
  min-width: 86px;
  max-width: 92px;
  padding-left: 8px;
  padding-right: 8px;
}

.companyColumn {
  min-width: 430px;
  text-align: left;
}

.preMarketColumn {
  width: 168px;
  min-width: 168px;
  text-align: center;
}

.earningsColumn {
  width: 132px;
  min-width: 132px;
  text-align: center;
}

.earningsCell {
  display: inline-block;
  width: 100%;
  color: var(--muted);
  font-size: 16px;
  font-weight: 900;
  line-height: 1.15;
  text-align: center;
  white-space: nowrap;
}

.earningsCell.earningsSoon {
  color: #b45309;
}

.earningsCell.earningsLater {
  color: var(--text);
}

.earningsCell.earningsToday {
  color: #dc2626;
}

.companyCell {
  display: grid;
  grid-template-columns: 16px 64px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-width: 396px;
  text-align: left;
}

.companyLogo {
  width: 60px;
  height: 60px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  overflow: hidden;
  background: #eef2f6;
  border: 1px solid #d8dee7;
}

.marketStateDot {
  width: 13px;
  height: 13px;
  border: 2px solid white;
  border-radius: 999px;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.25);
}

.marketStateSlot {
  width: 16px;
  display: grid;
  place-items: center;
}

.market-regular { background: #16a34a; }
.market-pre { background: #f59e0b; }
.market-post { background: #2563eb; }
.market-closed { background: #94a3b8; }

.companyLogoImage {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.companyLogoFallback {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 20px;
  font-weight: 900;
}

.companyText {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.companyNameRow {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.companyIdentity {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.companyTickerRow {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.companyText strong,
.companyText em {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.companyText strong {
  min-width: 0;
  color: var(--text);
  font-size: 16px;
  font-weight: 900;
}

.companyText em {
  color: var(--muted);
  font-size: 14px;
  font-style: normal;
  font-weight: 600;
}

.companyExtendedPrices {
  display: inline-grid;
  align-items: start;
  gap: 4px;
  min-width: 0;
  align-self: center;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  background: #e8eef5;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

.tickerPill {
  min-width: 62px;
  height: 28px;
  padding: 0 10px;
  background: #eef2f6;
  color: var(--text);
  font-size: 14px;
  font-weight: 900;
}

.softPill {
  background: #eef2f6;
  color: var(--muted);
}

.empty {
  padding: 28px;
  text-align: center;
  color: var(--muted);
}

.chartBox {
  padding: 16px 18px 10px;
  background: white;
  border-bottom: 1px solid var(--line);
}

.historyCharts {
  display: grid;
  gap: 20px;
  padding: 18px 20px 10px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfe;
}

.historyCharts.hidden {
  display: none;
}

.historyChartBlock {
  min-width: 0;
  overflow-x: auto;
}

.historyChartBlock + .historyChartBlock {
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.historyChartHead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 10px 2px 72px;
  font-size: 14px;
}

.historyChartSvg {
  display: block;
  width: 100%;
  min-width: 680px;
  height: auto;
}

.historyGridLine {
  stroke: #e3e9f1;
  stroke-width: 1;
}

.historyZeroLine {
  stroke: #8391a3;
  stroke-width: 1.5;
}

.historyBar {
  transition: opacity 0.15s ease;
}

.historyBar:hover {
  opacity: 0.78;
}

.historyBarPositive {
  fill: var(--green);
}

.historyBarNegative {
  fill: var(--red);
}

.historyAxisLabel,
.historyMonthLabel,
.historyAxisTitle,
.historyValueLabel {
  fill: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.historyValueLabel {
  fill: var(--text);
  font-weight: 850;
}

.historyAxisTitle {
  font-size: 13px;
}

.kidsProgress {
  display: grid;
  gap: 16px;
  padding: 18px 20px 20px;
  background: #fbfcfe;
}

.kidsProgress.hidden {
  display: none;
}

.kidsProgressIntro,
.kidsProgressChartHead {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.kidsProgressIntro h3 {
  margin: 0;
  font-size: 20px;
}

.kidsProgressIntro p {
  margin-top: 5px;
  font-size: 13px;
}

.kidsQuarterBadge {
  flex: 0 0 auto;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
  font-weight: 750;
}

.kidsChildTabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.kidsChildButton {
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface);
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
}

.kidsChildButton.active {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

.kidsProgressChartBlock {
  min-width: 0;
  padding: 14px 14px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  overflow-x: auto;
}

.kidsProgressChartHead {
  align-items: center;
  padding-bottom: 6px;
}

.kidsProgressChartHead strong {
  font-size: 14px;
}

.kidsProgressChartHead p {
  margin-top: 3px;
  font-size: 12px;
}

.kidsProgressLegend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  color: var(--muted);
  font-size: 12px;
}

.kidsLegendItem {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.kidsLegendLine {
  width: 18px;
  height: 3px;
  background: var(--green);
}

.kidsLegendLine.invested {
  height: 2px;
  background: var(--amber);
}

.kidsLegendBar {
  width: 13px;
  height: 13px;
  border-radius: 2px;
}

.kidsLegendBar.principal {
  background: #b8d5e5;
}

.kidsLegendBar.earned {
  background: #079455;
}

.kidsLegendBar.loss {
  background: var(--red);
}

.kidsProgressSvg {
  display: block;
  width: 100%;
  min-width: 680px;
  height: auto;
}

.kidsProgressGrid {
  stroke: #dbe4ed;
  stroke-width: 1;
}

.kidsProgressArea {
  fill: var(--green);
  opacity: 0.11;
}

.kidsProgressValueLine {
  fill: none;
  stroke: var(--green);
  stroke-width: 4;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.kidsProgressInvestedLine {
  fill: none;
  stroke: var(--amber);
  stroke-width: 2.5;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.kidsProgressAxisLabel {
  fill: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.kidsProgressPoint {
  fill: var(--green);
  stroke: var(--surface);
  stroke-width: 3;
}

.kidsProgressCurrentGuide {
  stroke: var(--muted);
  stroke-width: 1;
  stroke-dasharray: 5 5;
}

.kidsContributionBar {
  transition: opacity 0.15s ease;
}

.kidsContributionBar:hover {
  opacity: 0.78;
}

.kidsContributionPrincipal {
  fill: #b8d5e5;
}

.kidsContributionEarned {
  fill: #079455;
}

.kidsContributionLoss {
  fill: var(--red);
}

.kidsContributionProfitLabel,
.kidsContributionComparison {
  font-size: 12px;
  font-weight: 850;
}

.kidsContributionProfitLabel.positive {
  fill: var(--green);
}

.kidsContributionProfitLabel.negative {
  fill: var(--red);
}

.kidsContributionComparison {
  fill: var(--text);
}

.kidsProgressMessage {
  padding: 10px 12px;
  border-left: 4px solid var(--green);
  background: #e9f6ef;
  color: var(--text);
  font-size: 13px;
}

.kidsProgressFootnote {
  color: var(--muted);
  font-size: 11px;
}

.kidsProgressState {
  padding: 42px 20px;
  text-align: center;
  color: var(--muted);
}

@media (max-width: 700px) {
  .kidsProgressIntro,
  .kidsProgressChartHead {
    flex-direction: column;
  }

  .kidsProgress {
    padding: 14px 12px 16px;
  }
}

.mediaChartSvg {
  width: 100%;
  min-height: 260px;
  display: block;
}

.gridLine {
  stroke: #e3e9f1;
  stroke-width: 1;
}

.axisLine {
  stroke: #aab7c7;
  stroke-width: 1.2;
}

.axisLabel {
  fill: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.seriesLine {
  fill: none;
  stroke-width: 3;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.seriesPoint {
  stroke: white;
  stroke-width: 2;
}

.multiChartGrid {
  display: grid;
  gap: 14px;
}

.singleChart {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfdff;
  overflow: hidden;
}

.singleChartHead {
  min-height: 54px;
  display: grid;
  grid-template-columns: 1fr;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: #f6f8fb;
  text-align: center;
}

.singleChartHead span {
  display: block;
  font-size: 22px;
  font-weight: 900;
}

.barRect {
  opacity: 0.88;
}

.barRect:hover {
  opacity: 1;
}

.averageLine {
  stroke: #111827;
  stroke-width: 2;
  stroke-dasharray: 7 5;
}

.averageLabel {
  fill: #111827;
  font-size: 12px;
  font-weight: 900;
}

.monthLabel {
  fill: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.chartSummaryWrap {
  max-height: 260px;
}

/* Keep portfolio controls visible while only the positions list scrolls. */
@media (min-width: 981px) {
  .shell:has(#portfolioView.active) {
    height: 100dvh;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  .shell:has(#portfolioView.active) > .topbar { flex-shrink: 0; }
  .shell:has(#portfolioView.active) > main {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }
  #portfolioView.active {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }
  #portfolioKpis { flex-shrink: 0; }
  #portfolioView > .workbench {
    flex: 1;
    min-height: 0;
    grid-template-rows: minmax(0, 1fr);
    align-items: stretch;
  }
  #portfolioView .filters {
    position: static;
    min-height: 0;
    overflow-y: auto;
    align-content: start;
  }
  #portfolioView .panel {
    min-height: 0;
    display: flex;
    flex-direction: column;
  }
  #portfolioView .panelHead { flex-shrink: 0; }
  #portfolioHistoryCharts {
    flex-shrink: 0;
    max-height: 40%;
    overflow-y: auto;
  }
  #kidsProgressView { min-height: 0; overflow-y: auto; }
  #portfolioTableWrap {
    min-height: 0;
    overflow: auto;
    scrollbar-gutter: stable;
  }
}

@media (max-width: 980px) {
  .topbar {
    height: auto;
    grid-template-columns: 1fr;
    grid-template-areas:
      "brand"
      "rates"
      "tabs"
      "actions";
    padding: 12px;
  }
  .marketRates {
    position: static;
    transform: none;
    justify-self: stretch;
  }
  .tabs { justify-self: stretch; min-width: 0; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .marketRates { min-width: 0; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .actions { justify-self: center; }
  main { padding: 12px; }
  .kpiGrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .workbench { grid-template-columns: 1fr; }
  .filters { position: static; }
}
