/* Insight-only layer: keep the existing page shell and bottom-navigation inset. */
.analysis-header,
.analysis-filterbar,
.analysis-scope-note,
.insight-board {
  width: 100%;
  max-width: 1160px;
  min-width: 0;
  margin-right: auto;
  margin-left: auto;
}

.analysis-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-top: 6px;
  margin-bottom: 22px;
}

.analysis-mode-tabs { display: flex; align-items: baseline; gap: 23px; min-width: 0; }
.analysis-mode-tabs button {
  position: relative;
  padding: 5px 0 8px;
  color: #727780;
  font-size: 28px;
  font-weight: 650;
  line-height: 1.35;
  letter-spacing: -.7px;
  white-space: nowrap;
}
.analysis-mode-tabs button.active { color: #22262d; font-weight: 750; }
.analysis-mode-tabs button.active::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 3px;
  border-radius: 3px;
  background: #30353d;
}
.analysis-toolbar-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-width: 44px;
  min-height: 44px;
  padding: 10px 13px;
  border: 1px solid #dce0e5;
  border-radius: 14px;
  background: #fff;
  color: #414954;
  font-size: 14px;
  line-height: 1.4;
}
.analysis-toolbar-button .icon { width: 20px; height: 20px; flex-basis: 20px; }
.analysis-toolbar-button.active { border-color: #b8c3cf; background: #e9eef3; color: #354b60; }

.analysis-filterbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px 18px;
  margin-bottom: 12px;
}
.analysis-range {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  min-width: 0;
}
.analysis-range button {
  min-height: 40px;
  padding: 8px 15px;
  border-radius: 12px;
  color: #555d68;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.5;
  white-space: nowrap;
}
.analysis-range button.active { color: #fff; background: #30353d; }
.analysis-category-filter { display: flex; align-items: center; gap: 9px; width: 100%; min-width: 0; max-width: 1160px; margin: 0 auto 14px; color: #555d68; font-size: 14px; }
.analysis-category-filter select,
select.analysis-category-filter {
  max-width: 100%;
  min-width: 0;
  min-height: 40px;
  padding: 8px 30px 8px 12px;
  border: 1px solid #dce0e5;
  border-radius: 12px;
  background-color: #fff;
  color: #414954;
  font-size: 14px;
  text-overflow: ellipsis;
}
.analysis-scope-note { margin-top: 0; margin-bottom: 22px; color: #5c636e; font-size: 14px; line-height: 1.65; }

.insight-board {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: stretch;
  gap: 24px;
  color: #25282e;
  font-size: 16px;
  line-height: 1.5;
}
.insight-board button { font-family: inherit; }
.analysis-card {
  min-width: 0;
  padding: 28px;
  border: 1px solid #e8eaed;
  border-radius: 28px;
  background: #fff;
  box-shadow: 0 3px 14px #24304703;
}
.discoveries-card,
.retention-card { grid-column: 1 / -1; }
.analysis-card-header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  min-width: 0;
  margin-bottom: 26px;
}
.analysis-card-header h2 { min-width: 0; color: #25282e; font-size: 21px; font-weight: 700; line-height: 1.4; letter-spacing: -.35px; }
.analysis-badge {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  padding: 4px 9px;
  border-radius: 18px;
  background: #f3f4f6;
  color: #626873;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.5;
  white-space: nowrap;
}
.analysis-toggle {
  display: inline-flex;
  flex: 0 1 auto;
  align-items: center;
  gap: 2px;
  max-width: 100%;
  margin-left: auto;
  padding: 3px;
  border-radius: 22px;
  background: #f2f3f5;
}
.analysis-toggle button {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 34px;
  padding: 6px 12px;
  border: 1px solid transparent;
  border-radius: 19px;
  color: #666d77;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.5;
  white-space: nowrap;
}
.analysis-toggle button.active { border-color: #e9ebee; color: #25282e; background: #fff; box-shadow: 0 1px 4px #25282e08; }
.analysis-collapse {
  display: grid;
  flex: 0 0 40px;
  place-items: center;
  width: 40px;
  height: 40px;
  margin: -5px -6px -5px auto;
  border-radius: 12px;
  color: #6b727c;
  font-size: 25px;
  line-height: 1;
}
.discovery-title { display: flex; align-items: center; gap: 10px; }
.insight-spark { width: 27px; height: 27px; flex: 0 0 27px; }
.discovery-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.discovery-row {
  display: grid;
  grid-template-columns: 27px max-content minmax(0, 1fr) 12px;
  align-items: center;
  gap: 10px;
  min-width: 0;
  min-height: 64px;
  padding: 15px 17px;
  border-radius: 17px;
  background: #f5f5f7;
  text-align: left;
}
.discovery-row:last-child:nth-child(odd) { grid-column: 1 / -1; }
.discovery-emoji { font-size: 24px; line-height: 1.3; text-align: center; }
.discovery-label { color: #30353d; font-size: 16px; font-weight: 500; white-space: nowrap; }
.discovery-value { min-width: 0; overflow: hidden; color: #59616d; font-size: 15px; text-align: right; text-overflow: ellipsis; white-space: nowrap; }
.analysis-chevron { color: #8a919b; font-size: 25px; font-weight: 400; line-height: 1; text-align: right; }
.analysis-footnote { margin: 19px 0 0; color: #626a75; font-size: 14px; line-height: 1.7; overflow-wrap: anywhere; }

.analysis-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
  gap: 14px 24px;
  margin-bottom: 27px;
  font-variant-numeric: tabular-nums;
}
.analysis-metrics > div { min-width: 0; }
.analysis-metrics > div:only-child { grid-column: 1 / -1; }
.analysis-metrics p { margin-bottom: 7px; color: #626a75; font-size: 15px; line-height: 1.5; }
.analysis-metrics strong { display: block; color: #20242a; font-size: 32px; font-weight: 750; line-height: 1.25; letter-spacing: -.8px; overflow-wrap: anywhere; }
.analysis-metrics strong small { display: inline-block; margin-left: 3px; color: #30353d; font-size: 16px; font-weight: 550; line-height: 1.5; letter-spacing: 0; }

.analysis-rank-list { display: grid; min-width: 0; gap: 6px; }
.analysis-rank-row {
  display: grid;
  grid-template-columns: 20px 60px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-width: 0;
  min-height: 96px;
  padding: 10px 0;
  border-radius: 13px;
  text-align: left;
}
.ranking-number { color: #69727d; font-size: 19px; font-weight: 650; font-variant-numeric: tabular-nums; text-align: center; }
.ranking-number.rank-1 { color: #c6555d; }
.ranking-number.rank-2 { color: #bd783e; }
.ranking-number.rank-3 { color: #aa8728; }
.analysis-rank-row > img,
.goal-progress-item > img { width: 60px; height: 60px; object-fit: contain; object-position: center; }
.rank-description,
.goal-description { display: block; min-width: 0; }
.rank-description > strong,
.goal-description > strong {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  color: #2c3037;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.rank-description > small,
.goal-description > small { display: block; margin-top: 5px; color: #646c76; font-size: 14px; font-weight: 400; line-height: 1.45; }
.rank-amount { color: #25282e; font-size: 20px; font-weight: 700; line-height: 1.3; letter-spacing: -.5px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.rank-amount > small { margin-left: 3px; color: #66707b; font-size: 14px; font-weight: 400; letter-spacing: 0; }
.analysis-more {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 44px;
  margin-top: 16px;
  padding: 10px 12px;
  border-top: 1px solid #edf0f3;
  border-radius: 0 0 10px 10px;
  color: #596471;
  font-size: 14px;
  line-height: 1.5;
}
.analysis-more > span { font-size: 19px; line-height: 1; }

.goal-progress-list { display: grid; gap: 24px; }
.goal-progress-item {
  display: grid;
  grid-template-columns: 55px minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px 12px;
  width: 100%;
  min-width: 0;
  padding: 2px 0 4px;
  border-radius: 12px;
  text-align: left;
}
.goal-progress-item > img { width: 55px; height: 55px; }
.goal-percentage { align-self: center; color: #333943; font-size: 17px; font-weight: 650; white-space: nowrap; font-variant-numeric: tabular-nums; }
.goal-progress-track { position: relative; grid-column: 1 / -1; display: block; height: 5px; margin: 0 3px; border-radius: 5px; background: #e9edf0; }
.goal-progress-track > i { display: block; height: 100%; border-radius: inherit; background: #809b80; }
.goal-progress-track > b { position: absolute; top: 50%; width: 9px; height: 9px; border: 2px solid #fff; border-radius: 50%; background: #6f8a71; box-shadow: 0 0 0 1px #b3c3b1; transform: translate(-50%, -50%); }

.composition-bar { display: flex; gap: 3px; width: 100%; height: 48px; overflow: hidden; border-radius: 14px; background: #f2f4f6; }
.composition-bar > span { flex-basis: 0; min-width: 3px; height: 100%; }
.composition-legend { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px 20px; margin-top: 23px; }
.composition-legend > button { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; min-width: 0; min-height: 55px; padding: 0 0 0 14px; border-radius: 4px; text-align: left; }
.composition-legend > button::before { content: ""; position: absolute; top: 2px; bottom: 2px; left: 0; width: 4px; border-radius: 4px; background: var(--category-color, #829775); }
.composition-legend > button > span { display: flex; align-items: baseline; flex-wrap: wrap; gap: 0 5px; color: #5a626d; font-size: 14px; line-height: 1.5; overflow-wrap: anywhere; }
.composition-legend small { font-size: 14px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.composition-legend strong { max-width: 100%; color: #30343b; font-size: 19px; font-weight: 700; line-height: 1.4; letter-spacing: -.3px; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }

.holding-list { display: grid; gap: 12px; }
.holding-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; width: 100%; min-height: 81px; padding: 15px 18px; border-radius: 17px; background: #f5f5f7; text-align: left; }
.holding-row > span:first-child { min-width: 0; }
.holding-row strong { display: block; color: #30353d; font-size: 17px; font-weight: 550; line-height: 1.5; }
.holding-row small { display: block; margin-top: 4px; color: #646c77; font-size: 14px; line-height: 1.5; }

.retention-card .analysis-metrics { max-width: 700px; }
.retention-summary { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px 28px; margin-top: -9px; margin-bottom: 27px; color: #626a75; font-size: 14px; line-height: 1.7; }
.retention-summary strong { color: #30353d; font-size: 16px; font-weight: 650; font-variant-numeric: tabular-nums; }
.retention-summary .amount-loss { color: #a34b50; }
.retention-summary .amount-profit { color: #416653; }
.retention-podiums { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: end; gap: 24px; max-width: 720px; margin: 30px auto 24px; }
.retention-podium {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  min-width: 0;
  padding: 12px 12px 20px;
  border-radius: 18px;
  background: linear-gradient(180deg, #fff 33%, #f4f5f7 100%);
  text-align: center;
}
.retention-podium.podium-1 { padding-bottom: 42px; background: linear-gradient(180deg, #fff 30%, #f5f1e8 100%); }
.retention-podium.podium-3 { padding-bottom: 11px; }
.retention-podium > img { width: 110px; height: 108px; margin-bottom: 9px; object-fit: contain; }
.retention-podium.podium-1 > img { width: 126px; height: 124px; }
.podium-medal { display: grid; flex: 0 0 27px; place-items: center; width: 27px; height: 27px; margin-bottom: 9px; border-radius: 50%; background: #e5e9ee; color: #56616e; font-size: 14px; font-weight: 750; line-height: 1; }
.podium-1 .podium-medal { background: #e9d7ad; color: #795e27; }
.podium-3 .podium-medal { background: #e7d6c8; color: #87634a; }
.retention-podium > strong { display: -webkit-box; width: 100%; min-height: 48px; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; color: #333841; font-size: 16px; font-weight: 550; line-height: 1.5; overflow-wrap: anywhere; }
.retention-podium > b { margin-top: 10px; color: #262b32; font-size: 27px; font-weight: 750; line-height: 1.25; letter-spacing: -.6px; font-variant-numeric: tabular-nums; }
.retention-podium > small { margin-top: 5px; color: #646d78; font-size: 14px; line-height: 1.5; }
.retention-card .analysis-rank-list { border-top: 1px solid #edf0f3; padding-top: 10px; }
.retention-card .analysis-rank-list:empty { display: none; }

.analysis-empty { display: grid; justify-items: center; gap: 7px; min-width: 0; padding: 28px 12px 31px; text-align: center; }
.analysis-empty > span { color: #98a0aa; font-size: 26px; line-height: 1; }
.analysis-empty p { color: #4c5662; font-size: 16px; font-weight: 500; line-height: 1.65; }
.analysis-empty small { max-width: 30em; color: #68717c; font-size: 14px; line-height: 1.75; }

.insight-board button,
.analysis-mode-tabs button,
.analysis-toolbar-button,
.analysis-range button { transition: background-color 160ms ease, color 160ms ease, box-shadow 160ms ease; }
.insight-board button:focus-visible,
.analysis-header button:focus-visible,
.analysis-filterbar button:focus-visible,
.analysis-filterbar select:focus-visible { outline: 3px solid #54758f; outline-offset: 3px; }
@media (hover: hover) {
  .discovery-row:hover,
  .holding-row:hover { background: #eceef2; }
  .analysis-rank-row:hover,
  .goal-progress-item:hover { background: #f7f8fa; }
  .analysis-collapse:hover,
  .analysis-more:hover,
  .analysis-toolbar-button:hover,
  .analysis-range button:not(.active):hover { background: #e9ecf0; }
  .composition-legend > button:hover { background: #f5f6f8; }
  .retention-podium:hover { box-shadow: inset 0 0 0 1px #dfe4ea; }
}

@media (max-width: 1100px) and (min-width: 761px) {
  .analysis-card { padding: 22px; }
  .insight-board { gap: 20px; }
  .analysis-card-header { gap: 8px; }
  .analysis-card-header h2 { font-size: 20px; }
  .analysis-rank-row { grid-template-columns: 17px 46px minmax(0, 1fr) auto; gap: 8px; }
  .analysis-rank-row > img { width: 46px; height: 52px; }
  .rank-amount { font-size: 18px; }
  .rank-amount > small { display: block; margin: 3px 0 0; text-align: right; }
  .analysis-metrics { gap: 14px; }
  .analysis-metrics strong { font-size: 28px; }
  .discovery-list { grid-template-columns: minmax(0, 1fr); }
  .composition-legend { column-gap: 12px; }
}

@media (max-width: 760px) {
  .analysis-header { gap: 14px; margin-top: 4px; margin-bottom: 19px; }
  .analysis-mode-tabs { gap: 21px; }
  .analysis-toolbar-button { padding: 10px; }
  .analysis-filterbar { flex-wrap: nowrap; gap: 10px; margin-bottom: 11px; }
  .analysis-range { flex: 1; flex-wrap: nowrap; gap: 3px; overflow-x: auto; scrollbar-width: none; }
  .analysis-range button { flex: 0 0 auto; padding: 8px 11px; }
  .analysis-scope-note { margin-bottom: 19px; }
  .insight-board { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  .analysis-card { padding: 22px 19px; border-radius: 25px; }
  .analysis-card-header { gap: 8px; margin-bottom: 23px; }
  .analysis-card-header h2 { font-size: 20px; }
  .analysis-card-header:has(.analysis-toggle) > .analysis-badge { display: none; }
  .analysis-badge { padding: 4px 8px; }
  .analysis-toggle { gap: 0; }
  .analysis-toggle button { padding-inline: 10px; }
  .discovery-title { gap: 8px; }
  .insight-spark { width: 25px; height: 25px; flex-basis: 25px; }
  .discovery-list { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .discovery-row { grid-template-columns: 24px max-content minmax(0, 1fr) 10px; gap: 8px; min-height: 60px; padding: 13px 12px; border-radius: 16px; }
  .discovery-emoji { font-size: 22px; }
  .discovery-label { font-size: 16px; }
  .discovery-value { font-size: 14px; }
  .analysis-footnote { margin-top: 17px; }
  .analysis-metrics { column-gap: 16px; margin-bottom: 25px; }
  .analysis-metrics p { margin-bottom: 6px; font-size: 14px; }
  .analysis-metrics strong { font-size: clamp(26px, 7.1vw, 30px); letter-spacing: -.8px; }
  .analysis-metrics strong small { margin-left: 2px; font-size: 14px; }
  .analysis-rank-list { gap: 9px; }
  .analysis-rank-row { grid-template-columns: 17px 48px minmax(0, 1fr) auto; gap: 9px; min-height: 92px; padding: 10px 0; }
  .analysis-rank-row > img { width: 48px; height: 55px; }
  .ranking-number { font-size: 18px; }
  .rank-amount { font-size: 19px; }
  .rank-amount > small { display: block; margin: 3px 0 0; text-align: right; }
  .goal-progress-list { gap: 25px; }
  .goal-progress-item { grid-template-columns: 48px minmax(0, 1fr) auto; gap: 11px 10px; }
  .goal-progress-item > img { width: 48px; height: 53px; }
  .goal-percentage { font-size: 16px; }
  .composition-bar { height: 44px; border-radius: 12px; }
  .composition-legend { gap: 20px 13px; margin-top: 21px; }
  .composition-legend > button { padding-left: 12px; }
  .composition-legend strong { font-size: 18px; }
  .holding-row { min-height: 78px; padding: 14px 16px; }
  .retention-summary { gap: 4px 18px; margin-bottom: 24px; }
  .retention-podiums { gap: 8px; margin-top: 16px; margin-bottom: 24px; }
  .retention-podium { padding: 8px 5px 20px; border-radius: 15px; }
  .retention-podium.podium-1 { padding-bottom: 37px; }
  .retention-podium.podium-3 { padding-bottom: 10px; }
  .retention-podium > img { width: 78px; height: 78px; }
  .retention-podium.podium-1 > img { width: 87px; height: 94px; }
  .retention-podium > strong { min-height: 48px; font-size: 16px; }
  .retention-podium > b { font-size: clamp(22px, 6.4vw, 26px); letter-spacing: -.5px; }
  .retention-podium > small { font-size: 14px; }
}

.analysis-mode-tabs button.active::after { display: none; }

@media (max-width: 365px) {
  .analysis-header { gap: 10px; }
  .analysis-mode-tabs { gap: 18px; }
  .analysis-card { padding: 20px 16px; border-radius: 23px; }
  .analysis-card-header { column-gap: 7px; }
  .analysis-card-header h2 { font-size: 19px; }
  .analysis-card-header .analysis-toggle { margin-top: 2px; }
  .analysis-metrics { column-gap: 12px; }
  .analysis-metrics strong { font-size: 26px; }
  .analysis-rank-row { grid-template-columns: 14px 43px minmax(0, 1fr) auto; column-gap: 7px; }
  .analysis-rank-row > img { width: 43px; height: 50px; }
  .rank-amount { font-size: 18px; letter-spacing: -.4px; }
  .discovery-row { grid-template-columns: 23px max-content minmax(0, 1fr) 8px; gap: 6px; padding-inline: 10px; }
  .discovery-label { font-size: 16px; letter-spacing: -.4px; }
  .retention-podiums { gap: 5px; }
  .retention-podium { padding-inline: 3px; }
  .retention-podium > img { width: 68px; height: 70px; }
  .retention-podium.podium-1 > img { width: 76px; height: 87px; }
  .retention-podium > b { font-size: 22px; }
}

@media (prefers-reduced-motion: reduce) {
  .insight-board button,
  .analysis-mode-tabs button,
  .analysis-toolbar-button,
  .analysis-range button { transition: none; }
}
