:root {
  color-scheme: light;
  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface-alt: #eef3f7;
  --ink: #142033;
  --muted: #64748b;
  --line: #d7e0ea;
  --blue: #1f5eff;
  --blue-dark: #183a73;
  --green: #16764f;
  --green-bg: #e5f5ed;
  --amber: #9a5a00;
  --amber-bg: #fff2cf;
  --red: #b42318;
  --red-bg: #fde8e5;
  --shadow: 0 14px 35px rgba(20, 32, 51, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

button,
input {
  font: inherit;
}

.app-header {
  min-height: 116px;
  padding: 24px clamp(18px, 4vw, 48px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  background: #101826;
  color: white;
}

.brand-lockup {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-logo {
  flex: 0 0 auto;
  width: 52px;
  height: 52px;
  border-radius: 14px;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.22);
}

.eyebrow {
  margin: 0 0 6px;
  color: #9fb2cc;
  font-size: 13px;
  letter-spacing: 0;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(26px, 4vw, 42px);
  letter-spacing: 0;
  line-height: 1.08;
}

.header-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.header-meta span {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  color: #d8e3f0;
  font-size: 13px;
}

.layout {
  width: min(1220px, calc(100% - 32px));
  margin: 22px auto 42px;
}

.sticky-toolbar {
  position: sticky;
  top: 0;
  z-index: 40;
  padding: 12px clamp(16px, 4vw, 48px);
  background: rgba(245, 247, 250, 0.96);
  border-bottom: 1px solid rgba(215, 224, 234, 0.85);
  box-shadow: 0 10px 24px rgba(20, 32, 51, 0.08);
  backdrop-filter: blur(12px);
}

.sticky-toolbar .toolbar {
  width: min(1220px, 100%);
  margin: 0 auto;
}

.summary-band {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metric {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.metric-label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  display: block;
  font-size: 28px;
  line-height: 1;
}

.allocation-panel {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  margin-bottom: 16px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.allocation-panel strong {
  display: block;
  margin-bottom: 6px;
  font-size: 18px;
}

.allocation-panel p {
  color: #334155;
  line-height: 1.5;
}

.system-status-panel {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid #c7d7f4;
  border-radius: 8px;
  background: #f8fbff;
  box-shadow: var(--shadow);
}

.system-status-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.system-status-head strong {
  display: block;
  margin-bottom: 4px;
  font-size: 18px;
}

.system-status-head p,
.system-status-foot {
  color: #334155;
  line-height: 1.45;
}

.system-status-actions {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.system-status-pill,
.system-status-refresh {
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.system-status-refresh {
  border: 0;
  background: #e8efff;
  color: var(--blue-dark);
  cursor: pointer;
}

.system-status-refresh:hover {
  background: var(--blue-dark);
  color: #ffffff;
}

.system-status-pill.ok {
  background: var(--green-bg);
  color: var(--green);
}

.system-status-pill.warn,
.system-status-pill.loading {
  background: var(--amber-bg);
  color: var(--amber);
}

.system-status-pill.error {
  background: var(--red-bg);
  color: var(--red);
}

.system-status-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.system-status-card {
  min-width: 0;
  padding: 10px;
  border: 1px solid #d8e2ff;
  border-radius: 8px;
  background: var(--surface);
}

.system-status-card span,
.system-status-card small,
.system-status-card em,
.system-status-foot {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.system-status-card strong {
  display: block;
  margin: 4px 0;
  color: var(--ink);
  font-size: 18px;
  line-height: 1.15;
}

.system-status-card em {
  margin-top: 4px;
  font-style: normal;
  line-height: 1.35;
}

.system-status-card.ok {
  border-color: #bfe8d4;
  background: #f1fbf6;
}

.system-status-card.warn,
.system-status-card.loading {
  border-color: #eadca7;
  background: #fffaf0;
}

.system-status-card.error {
  border-color: #f0c1bc;
  background: #fff5f3;
}

.system-status-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
}

.capital-control {
  display: grid;
  gap: 6px;
  min-width: 210px;
  color: var(--muted);
  font-size: 12px;
}

.capital-control input {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fbfcfe;
  font-size: 16px;
  font-weight: 800;
}

.index-module {
  display: grid;
  gap: 14px;
  margin-bottom: 18px;
  padding: 16px;
  border: 1px solid #b8cdfd;
  border-radius: 8px;
  background: #f8faff;
  box-shadow: var(--shadow);
}

.index-module-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
}

.index-module-head h2 {
  margin-bottom: 6px;
  font-size: 22px;
}

.index-module-head p,
.index-plan,
.index-note {
  color: #334155;
  line-height: 1.5;
}

.index-total {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  background: #e8efff;
  color: var(--blue-dark);
  font-weight: 800;
  white-space: nowrap;
}

.index-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.index-summary-grid div,
.index-fund-card {
  min-width: 0;
  padding: 12px;
  border: 1px solid #d8e2ff;
  border-radius: 8px;
  background: var(--surface);
}

.index-summary-grid span,
.index-summary-grid small,
.index-fund-metrics span,
.index-fund-metrics small,
.index-fund-foot {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.index-summary-grid strong {
  display: block;
  margin: 5px 0;
  color: var(--blue-dark);
  font-size: clamp(18px, 2vw, 24px);
  line-height: 1.1;
}

.index-fund-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.index-fund-card {
  display: grid;
  gap: 12px;
}

.index-fund-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 150px;
  gap: 12px;
  align-items: center;
}

.index-chip {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: #e8efff;
  color: var(--blue-dark);
  font-size: 12px;
  font-weight: 800;
}

.index-sparkline {
  width: 100%;
  height: 48px;
}

.index-fund-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.index-fund-metrics div {
  min-width: 0;
  padding: 10px;
  border-radius: 8px;
  background: #f3f6ff;
}

.index-fund-metrics strong {
  display: block;
  margin: 4px 0;
  color: var(--blue-dark);
  font-size: clamp(14px, 1.4vw, 18px);
  line-height: 1.15;
  white-space: nowrap;
}

.index-fund-foot {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  line-height: 1.35;
}

.index-plan {
  padding: 12px;
  border-left: 4px solid var(--blue);
  border-radius: 6px;
  background: #eef4ff;
}

.history-module {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid #b8cdfd;
  border-radius: 8px;
  background: #f8faff;
  box-shadow: var(--shadow);
}

.holdings-module {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid #b8cdfd;
  border-radius: 8px;
  background: #f8faff;
  box-shadow: var(--shadow);
}

.history-head,
.history-section-head,
.holdings-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
}

.history-head h2,
.history-section-head h3,
.holdings-head h2 {
  margin-bottom: 6px;
  font-size: 22px;
}

.history-head p,
.history-rule,
.holdings-head p,
.holdings-note {
  color: #334155;
  line-height: 1.5;
}

.history-verdict,
.result-pill,
.local-save-pill,
.holdings-sync-pill,
.live-price-pill {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.history-verdict.good,
.result-pill.pass {
  background: var(--green-bg);
  color: var(--green);
}

.history-verdict.pending,
.history-verdict.watch {
  background: var(--amber-bg);
  color: var(--amber);
}

.local-save-pill {
  background: #e8efff;
  color: var(--blue-dark);
}

.holdings-sync-pill {
  background: #e8efff;
  color: var(--blue-dark);
}

.holdings-sync-pill.synced {
  background: var(--green-bg);
  color: var(--green);
}

.holdings-sync-pill.saving,
.holdings-sync-pill.loading {
  background: #e8efff;
  color: var(--blue-dark);
}

.holdings-sync-pill.error {
  background: var(--red-bg);
  color: var(--red);
}

.live-price-pill {
  background: var(--surface-alt);
  color: var(--muted);
}

.live-price-pill.ok {
  background: var(--green-bg);
  color: var(--green);
}

.live-price-pill.loading {
  background: #e8efff;
  color: var(--blue-dark);
}

.live-price-pill.error {
  background: var(--red-bg);
  color: var(--red);
}

.holdings-actions {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.holdings-auth-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 420px);
  gap: 18px;
  align-items: center;
  padding: 18px;
  border: 1px solid #d8e2ff;
  border-radius: 8px;
  background: var(--surface);
}

.holdings-auth-copy h2 {
  margin: 6px 0;
  font-size: 22px;
}

.holdings-auth-copy p {
  color: #334155;
  line-height: 1.5;
}

.holdings-auth-error {
  display: inline-flex;
  margin-top: 10px;
  color: var(--red);
}

.holdings-unlock-form {
  display: grid;
  gap: 8px;
}

.holdings-unlock-form label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.holdings-unlock-row {
  display: flex;
  gap: 8px;
}

.holdings-unlock-row input {
  min-width: 0;
  flex: 1 1 auto;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 800;
}

.holdings-refresh,
.holdings-live-refresh,
.holdings-lock,
.holdings-unlock-row button {
  min-height: 30px;
  padding: 0 10px;
  border: 0;
  border-radius: 999px;
  background: var(--blue);
  color: #ffffff;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.holdings-live-refresh,
.holdings-lock {
  background: #e8efff;
  color: var(--blue-dark);
}

.holdings-refresh:hover,
.holdings-live-refresh:hover,
.holdings-lock:hover,
.holdings-unlock-row button:hover {
  background: var(--blue-dark);
  color: #ffffff;
}

.holdings-unlock-row button {
  min-height: 40px;
  padding: 0 16px;
}

.holdings-unlock-row button:disabled,
.holdings-unlock-row input:disabled {
  cursor: wait;
  opacity: 0.7;
}

.history-verdict.bad,
.result-pill.fail {
  background: var(--red-bg);
  color: var(--red);
}

.history-score-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.history-score-card {
  min-width: 0;
  padding: 12px;
  border: 1px solid #d8e2ff;
  border-radius: 8px;
  background: var(--surface);
}

.history-score-card.primary {
  border-color: #b8cdfd;
  background: #eef4ff;
}

.history-score-card span,
.history-score-card small,
.history-section-head > span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.history-score-card strong {
  display: block;
  margin: 5px 0;
  color: var(--blue-dark);
  font-size: clamp(18px, 2vw, 24px);
  line-height: 1.1;
}

.holdings-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(136px, 1fr));
  gap: 10px;
}

.holdings-summary-grid div {
  min-width: 0;
  padding: 12px;
  border: 1px solid #d8e2ff;
  border-radius: 8px;
  background: var(--surface);
}

.holdings-summary-grid span,
.holdings-summary-grid small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.holdings-summary-grid strong {
  display: block;
  margin: 5px 0;
  color: var(--blue-dark);
  font-size: clamp(18px, 2vw, 24px);
  line-height: 1.1;
}

.alert-settings-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid #d8e2ff;
  border-radius: 8px;
  background: var(--surface);
}

.alert-settings-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
}

.alert-settings-head h3 {
  margin: 4px 0;
  font-size: 18px;
}

.alert-settings-head p,
.alert-settings-note {
  color: #334155;
  line-height: 1.45;
}

.alert-settings-counts {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.alert-settings-counts span {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: #e8efff;
  color: var(--blue-dark);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.alert-settings-list {
  display: grid;
  gap: 8px;
}

.alert-settings-row {
  display: grid;
  grid-template-columns: minmax(170px, 1fr) minmax(260px, auto);
  gap: 10px;
  align-items: center;
  padding: 9px 10px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #fbfcfe;
}

.alert-settings-row strong,
.alert-settings-row span {
  display: block;
}

.alert-settings-row > div:first-child span {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.alert-toggle-group {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.alert-toggle {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 7px;
  row-gap: 1px;
  align-items: center;
  min-width: 124px;
  padding: 7px 9px;
  border: 1px solid #d8e2ff;
  border-radius: 8px;
  background: #f8fbff;
  color: var(--blue-dark);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.alert-toggle input {
  grid-row: span 2;
  width: 16px;
  height: 16px;
  accent-color: var(--blue);
}

.alert-toggle small {
  color: var(--muted);
  font-weight: 700;
}

.alert-toggle.is-off {
  border-color: #f4cccc;
  background: var(--red-bg);
  color: var(--red);
}

.alert-toggle.is-disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.alert-settings-note {
  padding: 10px;
  border-left: 4px solid var(--blue);
  border-radius: 6px;
  background: #eef4ff;
}

.transactions-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid #d8e2ff;
  border-radius: 8px;
  background: var(--surface);
}

.transactions-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
}

.transactions-head h3 {
  margin: 4px 0;
  font-size: 18px;
}

.transactions-head p,
.transaction-note {
  color: #334155;
  line-height: 1.45;
}

.transactions-actions {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.transactions-count {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: #e8efff;
  color: var(--blue-dark);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.transaction-calibrate,
.transaction-reset-base {
  min-height: 28px;
  padding: 0 10px;
  border: 0;
  border-radius: 999px;
  background: var(--blue);
  color: #ffffff;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}

.transaction-reset-base {
  background: #e8efff;
  color: var(--blue-dark);
}

.transaction-calibrate:hover,
.transaction-reset-base:hover {
  background: var(--blue-dark);
  color: #ffffff;
}

.transaction-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(136px, 1fr));
  gap: 10px;
}

.transaction-summary-grid div {
  min-width: 0;
  padding: 10px;
  border: 1px solid #d8e2ff;
  border-radius: 8px;
  background: var(--surface-alt);
}

.transaction-summary-grid span,
.transaction-summary-grid small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.transaction-summary-grid strong {
  display: block;
  margin: 4px 0;
  color: var(--blue-dark);
  font-size: clamp(16px, 1.7vw, 21px);
  line-height: 1.1;
}

.transactions-form {
  display: grid;
  grid-template-columns: 116px 116px 86px 98px 104px 90px minmax(160px, 1fr) auto auto;
  gap: 8px;
  align-items: end;
}

.transaction-form-title {
  display: inline-flex;
  width: fit-content;
  min-height: 28px;
  align-items: center;
  padding: 0 10px;
  border-radius: 999px;
  background: #e8efff;
  color: var(--blue-dark);
  font-size: 12px;
  font-weight: 800;
}

.transactions-form label {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.transactions-form label span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.transactions-form input,
.transactions-form select {
  width: 100%;
  min-width: 0;
  height: 34px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfcfe;
  color: var(--ink);
  font: inherit;
  font-weight: 700;
}

.transactions-form button {
  min-height: 34px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: var(--blue);
  color: #ffffff;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}

.transactions-form button:hover {
  background: var(--blue-dark);
}

.transactions-form .transaction-edit-cancel {
  background: #e8efff;
  color: var(--blue-dark);
}

.transactions-form .transaction-edit-cancel:hover {
  background: var(--red-bg);
  color: var(--red);
}

.transaction-filters {
  display: grid;
  grid-template-columns: minmax(110px, 1fr) 108px 126px 126px auto auto;
  gap: 8px;
  align-items: end;
  padding: 10px;
  border: 1px solid #d8e2ff;
  border-radius: 8px;
  background: #f8fbff;
}

.transaction-filters label {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.transaction-filters label span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.transaction-filter-control {
  width: 100%;
  min-width: 0;
  height: 34px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  color: var(--ink);
  font: inherit;
  font-weight: 700;
}

.transaction-filter-reset {
  min-height: 34px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: #e8efff;
  color: var(--blue-dark);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}

.transaction-filter-reset:hover {
  background: var(--blue-dark);
  color: #ffffff;
}

.transaction-filter-reset:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.transaction-filter-reset:disabled:hover {
  background: #e8efff;
  color: var(--blue-dark);
}

.transaction-filter-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 10px;
  border-radius: 999px;
  background: #eef4ff;
  color: var(--blue-dark);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.transaction-error {
  color: var(--red);
  font-size: 12px;
}

.transaction-notice {
  color: var(--green);
  font-size: 12px;
}

.transactions-table-wrap {
  overflow-x: auto;
  border: 1px solid #d8e2ff;
  border-radius: 8px;
  background: var(--surface);
}

.transactions-table {
  width: 100%;
  min-width: 860px;
  border-collapse: collapse;
}

.transactions-table th,
.transactions-table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

.transactions-table tr:last-child td {
  border-bottom: 0;
}

.transactions-table tr.is-editing td {
  background: #eef4ff;
}

.transactions-table th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.trade-side {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
}

.trade-side.buy {
  background: var(--green-bg);
  color: var(--green);
}

.trade-side.sell {
  background: var(--red-bg);
  color: var(--red);
}

.transaction-row-note {
  display: inline-block;
  max-width: 220px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
  white-space: nowrap;
}

.trade-edit,
.trade-delete {
  margin-left: 8px;
  border: 0;
  border-radius: 999px;
  background: #e8efff;
  color: var(--blue-dark);
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
}

.trade-edit {
  background: var(--green-bg);
  color: var(--green);
}

.trade-edit:hover {
  background: #ccebdd;
}

.trade-delete:hover {
  background: var(--red-bg);
  color: var(--red);
}

.transaction-note {
  padding: 10px;
  border-left: 4px solid var(--blue);
  border-radius: 6px;
  background: #eef4ff;
}

.holdings-table-tools {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.holdings-table-tools > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.holdings-view-switch {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  border-radius: 8px;
  background: #e8efff;
}

.holding-view-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 0 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--blue-dark);
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}

.holding-view-toggle strong {
  min-width: 22px;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.75);
  font-size: 11px;
}

.holding-view-toggle.is-active {
  background: var(--surface);
  box-shadow: 0 1px 5px rgba(15, 23, 42, 0.08);
}

.history-section {
  display: grid;
  gap: 10px;
}

.history-section-head > span {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: #e8efff;
  color: var(--blue-dark);
  font-weight: 800;
  white-space: nowrap;
}

.history-table-wrap {
  overflow-x: auto;
  border: 1px solid #d8e2ff;
  border-radius: 8px;
  background: var(--surface);
}

.holdings-table-wrap {
  overflow-x: auto;
  border: 1px solid #d8e2ff;
  border-radius: 8px;
  background: var(--surface);
}

.history-table,
.holdings-table {
  width: 100%;
  min-width: 660px;
  border-collapse: collapse;
}

.holdings-table {
  min-width: 1180px;
}

.history-table th,
.history-table td,
.holdings-table th,
.holdings-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

.holdings-table th:nth-child(9),
.holdings-table td:nth-child(9) {
  width: 150px;
  max-width: 150px;
}

.holdings-table th:nth-child(10),
.holdings-table td:nth-child(10) {
  width: 132px;
  max-width: 132px;
  padding-right: 12px;
  white-space: normal;
}

.history-table th,
.holdings-table th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.holding-sort-button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 24px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.holding-sort-button i {
  color: #94a3b8;
  font-style: normal;
  font-weight: 900;
}

.holding-sort-button.is-active {
  color: var(--blue-dark);
}

.holding-sort-button:hover {
  color: var(--blue);
}

.history-table tr:last-child td,
.holdings-table tr:last-child td {
  border-bottom: 0;
}

.holdings-table td > span,
.holdings-table td > strong + span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.holdings-empty-row {
  padding: 18px;
  border-radius: 8px;
  background: var(--surface-alt);
  color: var(--muted);
  text-align: center;
  white-space: normal;
}

.holding-input {
  width: 92px;
  height: 34px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfcfe;
  color: var(--ink);
  font-weight: 700;
}

.holding-price {
  display: grid;
  gap: 2px;
}

.holding-price strong {
  color: var(--ink);
}

.holding-price span {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.holding-price.live span {
  color: var(--green);
  font-weight: 800;
}

.holding-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  width: 100%;
  max-width: 100%;
  padding: 6px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.25;
  overflow-wrap: anywhere;
  text-align: center;
  white-space: normal;
}

.holding-buy-plan {
  display: grid;
  gap: 2px;
  min-width: 0;
  width: 100%;
  padding: 8px;
  border-radius: 8px;
  background: var(--surface-alt);
}

.holding-buy-plan span,
.holding-buy-plan small {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.holding-buy-plan strong {
  color: var(--blue-dark);
  font-size: 14px;
  overflow-wrap: anywhere;
}

.holding-buy-plan.ok {
  background: var(--green-bg);
}

.holding-buy-plan.watch {
  background: var(--amber-bg);
}

.holding-buy-plan.risk {
  background: var(--red-bg);
}

.holding-action.ok {
  background: var(--green-bg);
  color: var(--green);
}

.holding-action.watch,
.holding-action.muted {
  background: var(--amber-bg);
  color: var(--amber);
}

.holding-action.risk {
  background: var(--red-bg);
  color: var(--red);
}

.holdings-note {
  padding: 12px;
  border-left: 4px solid var(--blue);
  border-radius: 6px;
  background: #eef4ff;
}

.positive {
  color: var(--green);
  font-weight: 800;
}

.negative {
  color: var(--red);
  font-weight: 800;
}

.history-empty {
  display: grid;
  gap: 6px;
  padding: 18px;
  border: 1px dashed #b8cdfd;
  border-radius: 8px;
  background: var(--surface);
}

.history-empty span {
  color: var(--muted);
  line-height: 1.45;
}

.history-rule {
  display: grid;
  gap: 5px;
  padding: 12px;
  border-left: 4px solid var(--blue);
  border-radius: 6px;
  background: #eef4ff;
}

.equity-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid #d8e2ff;
  border-radius: 8px;
  background: var(--surface);
}

.equity-chart-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.equity-chart-head strong {
  display: block;
  margin: 4px 0;
  font-size: 18px;
}

.equity-chart-head small,
.equity-legend,
.equity-note,
.equity-stats span,
.equity-empty {
  color: var(--muted);
  font-size: 12px;
}

.equity-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.equity-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.strategy-dot,
.benchmark-dot,
.account-dot,
.cost-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--blue);
}

.benchmark-dot,
.cost-dot {
  background: var(--muted);
}

.account-dot {
  background: var(--green);
}

.equity-chart {
  width: 100%;
  height: auto;
  min-height: 180px;
  border-radius: 8px;
  background: linear-gradient(180deg, #fbfcff 0%, #f4f7fb 100%);
}

.chart-axis,
.chart-guide {
  stroke: #d7e0ea;
  stroke-width: 1;
}

.chart-guide {
  stroke-dasharray: 5 6;
}

.strategy-line,
.benchmark-line,
.account-line,
.cost-line {
  fill: none;
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.strategy-line {
  stroke: var(--blue);
}

.benchmark-line {
  stroke: #7b8797;
}

.account-line {
  stroke: var(--green);
}

.cost-line {
  stroke: #7b8797;
  stroke-dasharray: 8 8;
}

.real-account-point circle {
  fill: var(--green);
  stroke: #ffffff;
  stroke-width: 1.5;
}

.chart-value-label,
.chart-date-label {
  fill: #334155;
  font-size: 10px;
  font-weight: 800;
  text-anchor: middle;
  paint-order: stroke;
  stroke: #ffffff;
  stroke-width: 3px;
  stroke-linejoin: round;
}

.chart-date-label {
  fill: var(--muted);
  font-size: 9px;
  font-weight: 700;
}

.equity-empty {
  padding: 8px 10px;
  border-radius: 6px;
  background: #f7f9fc;
}

.equity-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.equity-stats div {
  min-width: 0;
  padding: 9px 10px;
  border-radius: 8px;
  background: var(--surface-alt);
}

.equity-stats strong {
  display: block;
  margin-top: 4px;
  color: var(--blue-dark);
  font-size: 15px;
}

.equity-note {
  line-height: 1.45;
}

.contribution-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid #d8e2ff;
  border-radius: 8px;
  background: var(--surface);
}

.contribution-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.contribution-summary div {
  min-width: 0;
  padding: 9px 10px;
  border-radius: 8px;
  background: var(--surface-alt);
}

.contribution-summary span,
.contribution-row span,
.contribution-empty {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.contribution-summary strong {
  display: block;
  margin-top: 4px;
  color: var(--blue-dark);
  font-size: 15px;
  overflow-wrap: anywhere;
}

.contribution-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.contribution-grid > div {
  min-width: 0;
  display: grid;
  gap: 8px;
}

.contribution-title {
  color: var(--ink);
  font-weight: 800;
}

.contribution-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.contribution-row > div {
  min-width: 0;
}

.contribution-row > div:last-child {
  text-align: right;
}

.contribution-row strong {
  display: block;
  margin-bottom: 3px;
}

.contribution-empty {
  padding: 10px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
}

.search-box {
  flex: 1 1 420px;
  min-width: 220px;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 42px;
  padding: 0 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.search-box span {
  color: var(--muted);
  font-size: 18px;
}

.search-box input {
  width: 100%;
  border: 0;
  outline: none;
  color: var(--ink);
  background: transparent;
}

.segmented {
  flex: 0 0 auto;
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  background: #e5ebf2;
  border-radius: 8px;
}

.segment {
  height: 34px;
  padding: 0 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #3e5068;
  cursor: pointer;
  white-space: nowrap;
}

.segment.is-active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 2px 8px rgba(20, 32, 51, 0.08);
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 420px);
  gap: 18px;
  align-items: start;
}

.section-title {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 10px;
}

.section-title h2 {
  font-size: 18px;
}

.section-title span {
  color: var(--muted);
  font-size: 13px;
}

.stock-list {
  display: grid;
  gap: 12px;
}

.stock-card,
.detail-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.stock-card {
  width: 100%;
  padding: 16px;
  display: grid;
  grid-template-columns:
    minmax(150px, 1fr) 96px minmax(62px, 0.4fr) minmax(76px, 0.45fr)
    minmax(130px, 0.75fr) minmax(142px, 0.8fr);
  gap: 10px;
  align-items: center;
  border-color: var(--line);
  text-align: left;
  cursor: pointer;
}

.stock-card:hover,
.stock-card.is-selected {
  border-color: #8db4ff;
}

.stock-main {
  min-width: 0;
}

.ticker-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.ticker {
  font-size: 20px;
  font-weight: 800;
}

.company {
  color: var(--muted);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tag {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.tag.buy,
.tag.hold {
  background: var(--green-bg);
  color: var(--green);
}

.tag.watch {
  background: var(--amber-bg);
  color: var(--amber);
}

.tag.reduce,
.tag.risk {
  background: var(--red-bg);
  color: var(--red);
}

.priority-pill,
.insight-chip,
.freshness-badge {
  display: inline-flex;
  align-items: center;
  min-height: 21px;
  padding: 0 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.2;
  white-space: nowrap;
}

.priority-pill.high,
.priority-pill.medium,
.priority-pill.watch,
.insight-chip.ready,
.insight-chip.near,
.insight-chip.agree {
  background: var(--green-bg);
  color: var(--green);
}

.priority-pill.low,
.insight-chip.watch,
.insight-chip.far,
.insight-chip.muted,
.insight-chip.unknown {
  background: var(--amber-bg);
  color: var(--amber);
}

.priority-pill.danger,
.insight-chip.conflict,
.freshness-badge.stale {
  background: var(--red-bg);
  color: var(--red);
}

.stock-insight-row,
.freshness-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 7px;
}

.stock-insight-row .insight-chip {
  max-width: 100%;
  white-space: normal;
}

.buy-holding-compare {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin-top: 8px;
  padding: 8px;
  border: 1px solid #d8e2ff;
  border-radius: 8px;
  background: #f8faff;
}

.buy-holding-compare > div {
  min-width: 0;
}

.buy-holding-compare span,
.buy-holding-compare small {
  display: block;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.25;
}

.buy-holding-compare strong {
  display: block;
  margin: 2px 0;
  color: var(--blue-dark);
  font-size: 12px;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.buy-holding-compare.ok {
  border-color: #bde8d8;
  background: var(--green-bg);
}

.buy-holding-compare.watch {
  border-color: #f8df9c;
  background: var(--amber-bg);
}

.buy-holding-compare.risk {
  border-color: #f5c2c0;
  background: var(--red-bg);
}

.buy-holding-compare.locked {
  grid-template-columns: 96px minmax(0, 1fr);
  background: var(--surface-alt);
}

.buy-top-summary {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid #b8cdfd;
  border-radius: 8px;
  background: #f8faff;
  box-shadow: var(--shadow);
}

.buy-summary-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.buy-summary-head strong {
  display: block;
  font-size: 18px;
}

.buy-summary-source {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: #e8efff;
  color: var(--blue-dark);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.buy-top-summary.locked .buy-summary-source {
  background: var(--amber-bg);
  color: var(--amber);
}

.buy-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.buy-summary-grid div {
  min-width: 0;
  padding: 11px;
  border: 1px solid #d8e2ff;
  border-radius: 8px;
  background: var(--surface);
}

.buy-summary-grid span,
.buy-summary-grid small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}

.buy-summary-grid strong {
  display: block;
  margin: 5px 0;
  color: var(--blue-dark);
  font-size: clamp(17px, 1.8vw, 23px);
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.buy-summary-grid .buy-priority-cell {
  border-color: #bde8d8;
  background: var(--green-bg);
}

.buy-summary-grid .buy-priority-cell strong {
  color: var(--green);
}

.buy-summary-grid .buy-priority-cell.empty {
  border-color: #f8df9c;
  background: var(--amber-bg);
}

.buy-summary-grid .buy-priority-cell.empty strong {
  color: var(--amber);
}

.sparkline {
  width: 100%;
  height: 54px;
}

.card-metric {
  display: grid;
  gap: 5px;
}

.card-metric span,
.detail-label {
  color: var(--muted);
  font-size: 12px;
}

.card-metric strong {
  font-size: 16px;
}

.card-metric small {
  color: var(--muted);
  font-size: 12px;
}

.allocation-metric strong {
  font-size: 16px;
}

.runaway-metric {
  padding: 10px;
  border: 1px solid #c7d7ff;
  border-radius: 8px;
  background: #f3f6ff;
}

.runaway-metric strong {
  color: var(--blue-dark);
  font-size: 15px;
}

.list-summary-card {
  padding: 16px;
  border: 1px solid #c7d7ff;
  border-radius: 8px;
  background: #f8faff;
  box-shadow: var(--shadow);
}

.list-summary-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.list-summary-head strong {
  display: block;
  font-size: 18px;
}

.list-summary-head > span {
  display: inline-flex;
  align-items: center;
  height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  background: #e8efff;
  color: var(--blue-dark);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.list-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.list-summary-grid div {
  min-width: 0;
  padding: 12px;
  border: 1px solid #d8e2ff;
  border-radius: 8px;
  background: var(--surface);
}

.list-summary-grid span,
.list-summary-grid small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.list-summary-grid strong {
  display: block;
  margin: 5px 0;
  color: var(--blue-dark);
  font-size: clamp(14px, 1.25vw, 18px);
  line-height: 1.15;
  white-space: nowrap;
}

.list-summary-grid small {
  line-height: 1.25;
}

.detail-panel {
  position: sticky;
  top: 84px;
  min-height: 360px;
  padding: 18px;
}

.empty-state {
  min-height: 310px;
  display: grid;
  place-content: center;
  text-align: center;
  color: var(--muted);
  gap: 8px;
}

.empty-state strong {
  color: var(--ink);
  font-size: 18px;
}

.detail-content {
  display: grid;
  gap: 16px;
}

.detail-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.detail-head h2 {
  font-size: 24px;
  line-height: 1.1;
}

.detail-price {
  text-align: right;
}

.detail-price .detail-label {
  display: block;
}

.detail-price.live .detail-label {
  color: var(--green);
  font-weight: 800;
}

.detail-price.stale .detail-label {
  color: var(--muted);
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.detail-box {
  padding: 12px;
  background: var(--surface-alt);
  border-radius: 8px;
}

.accent-box {
  border: 1px solid #c7d7ff;
  background: #f3f6ff;
}

.detail-value {
  display: block;
  margin-top: 5px;
  font-weight: 800;
}

.detail-box .detail-label:last-child {
  display: block;
  margin-top: 5px;
}

.decision-grid,
.freshness-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.decision-box,
.freshness-card {
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.decision-box strong,
.freshness-card strong {
  display: block;
  margin: 4px 0;
  color: var(--ink);
  line-height: 1.2;
}

.decision-box small,
.freshness-card span,
.freshness-card small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.32;
}

.decision-box.high,
.decision-box.medium,
.decision-box.ready,
.decision-box.near,
.decision-box.agree,
.freshness-card.ok {
  border-color: #bfe8d4;
  background: #f1fbf6;
}

.decision-box.watch,
.decision-box.low,
.decision-box.far,
.decision-box.muted {
  border-color: #eadca7;
  background: #fffaf0;
}

.decision-box.danger,
.decision-box.conflict,
.freshness-card.stale {
  border-color: #f0c1bc;
  background: #fff5f3;
}

.trigger-list,
.risk-list {
  display: grid;
  gap: 8px;
}

.trigger,
.risk-item {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.trigger strong,
.risk-item strong {
  display: block;
  margin-bottom: 4px;
}

.weekly-note {
  padding: 12px;
  background: #f7f9fc;
  border-left: 4px solid var(--blue);
  border-radius: 6px;
  color: #334155;
  line-height: 1.55;
}

.bank-rating-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.bank-rating-card {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  color: inherit;
  text-decoration: none;
}

.bank-rating-card.buy {
  border-color: #bfe8d4;
  background: #f1fbf6;
}

.bank-rating-card.hold {
  border-color: #eadca7;
  background: #fffaf0;
}

.bank-rating-card.sell {
  border-color: #f0c1bc;
  background: #fff5f3;
}

.bank-rating-card.unknown {
  border-style: dashed;
}

.bank-rating-card span,
.bank-rating-card small,
.bank-rating-card em,
.rating-note {
  color: var(--muted);
  font-size: 11px;
}

.bank-rating-card strong {
  color: var(--ink);
  font-size: 13px;
  line-height: 1.15;
}

.bank-rating-card small,
.bank-rating-card em {
  overflow-wrap: anywhere;
  font-style: normal;
  line-height: 1.25;
}

.rating-note {
  margin-top: 8px;
  line-height: 1.35;
}

.source-link {
  color: var(--blue);
  text-decoration: none;
  font-weight: 700;
}

.source-link:hover {
  text-decoration: underline;
}

@media (max-width: 920px) {
  .app-header,
  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .brand-lockup {
    align-items: flex-start;
  }

  .brand-logo {
    width: 44px;
    height: 44px;
    border-radius: 12px;
  }

  .sticky-toolbar {
    padding: 10px;
  }

  .search-box {
    flex: 0 0 auto;
    width: 100%;
    min-width: 0;
    height: 38px;
  }

  .header-meta {
    justify-content: flex-start;
  }

  .summary-band {
    display: flex;
    gap: 8px;
    margin: 0 -10px 12px;
    padding: 0 10px 2px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
  }

  .summary-band::-webkit-scrollbar {
    display: none;
  }

  .summary-band .metric {
    flex: 0 0 112px;
    min-height: 70px;
    padding: 10px 12px;
    scroll-snap-align: start;
  }

  .summary-band .metric-label {
    margin-bottom: 6px;
    font-size: 12px;
    white-space: nowrap;
  }

  .summary-band .metric strong {
    font-size: 24px;
  }

  .allocation-panel {
    align-items: stretch;
    flex-direction: column;
  }

  .system-status-head {
    display: grid;
  }

  .system-status-actions {
    justify-content: flex-start;
  }

  .system-status-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .index-module-head,
  .index-fund-top {
    grid-template-columns: 1fr;
  }

  .index-module-head {
    display: grid;
  }

  .index-total {
    justify-self: start;
  }

  .index-summary-grid,
  .index-fund-grid,
  .history-score-grid,
  .transaction-summary-grid,
  .holdings-summary-grid {
    grid-template-columns: 1fr;
  }

  .index-fund-metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .content-grid {
    grid-template-columns: 1fr;
  }

  .detail-panel {
    position: static;
  }

  .stock-card {
    grid-template-columns: 1fr;
  }

  .list-summary-grid {
    grid-template-columns: 1fr;
  }

  .bank-rating-grid {
    grid-template-columns: 1fr;
  }

  .decision-grid,
  .freshness-grid {
    grid-template-columns: 1fr;
  }

  .sparkline {
    height: 64px;
  }

  .history-head,
  .history-section-head,
  .alert-settings-head,
  .transactions-head,
  .holdings-head {
    display: grid;
  }

  .holdings-auth-card {
    grid-template-columns: 1fr;
  }

  .holdings-unlock-row {
    display: grid;
  }

  .holdings-actions {
    justify-content: flex-start;
  }

  .holdings-table-tools {
    align-items: flex-start;
    flex-direction: column;
  }

  .history-table {
    min-width: 560px;
  }

  .transactions-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .transactions-actions {
    justify-content: flex-start;
  }

  .alert-settings-counts,
  .alert-toggle-group {
    justify-content: flex-start;
  }

  .alert-settings-row {
    grid-template-columns: 1fr;
  }

  .transaction-filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .transaction-filter-reset,
  .transaction-filter-count {
    width: 100%;
  }

  .transactions-form .wide {
    grid-column: 1 / -1;
  }

  .equity-chart-head {
    display: grid;
  }

  .equity-legend {
    justify-content: flex-start;
  }

  .equity-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .contribution-summary,
  .contribution-grid {
    grid-template-columns: 1fr;
  }

  .contribution-row {
    align-items: flex-start;
  }
}

@media (max-width: 560px) {
  .layout {
    width: min(100% - 20px, 1220px);
    margin-top: 14px;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }

  .segmented {
    width: 100%;
  }

  .segment {
    flex: 1;
    min-width: 50px;
    padding: 0 8px;
  }

  .index-fund-metrics {
    grid-template-columns: 1fr;
  }

  .index-fund-foot {
    flex-direction: column;
    gap: 4px;
  }

  .transactions-form {
    grid-template-columns: 1fr;
  }

  .alert-toggle {
    flex: 1 1 140px;
  }

  .transaction-filters {
    grid-template-columns: 1fr;
  }
}

/* Compact display mode: smaller type and tighter cards for denser research views. */
body {
  font-size: 13px;
}

.app-header {
  min-height: 96px;
  padding-top: 18px;
  padding-bottom: 18px;
}

.brand-logo {
  width: 44px;
  height: 44px;
  border-radius: 12px;
}

h1 {
  font-size: clamp(22px, 3vw, 32px);
}

.eyebrow,
.header-meta span,
.holdings-refresh,
.holdings-live-refresh,
.live-price-pill,
.holdings-sync-pill,
.holdings-table-tools > span,
.holding-view-toggle,
.metric-label,
.section-title span,
.company,
.card-metric span,
.card-metric small,
.detail-label,
.priority-pill,
.insight-chip,
.freshness-badge,
.decision-box small,
.freshness-card span,
.freshness-card small,
.contribution-summary span,
.contribution-row span,
.contribution-empty,
.holdings-summary-grid span,
.holdings-summary-grid small,
.holdings-table th,
.holdings-table td > span,
.holding-price span,
.holding-buy-plan span,
.holding-buy-plan small,
.alert-settings-counts span,
.alert-toggle,
.alert-toggle small,
.transactions-count,
.transaction-calibrate,
.transaction-reset-base,
.transaction-form-title,
.transaction-filters label span,
.transaction-filter-reset,
.transaction-filter-count,
.transactions-form label span,
.transactions-form button,
.transactions-table th,
.trade-side,
.trade-edit,
.trade-delete,
.transaction-summary-grid span,
.transaction-summary-grid small,
.index-summary-grid span,
.index-summary-grid small,
.index-fund-metrics span,
.index-fund-metrics small,
.index-fund-foot,
.list-summary-grid span,
.list-summary-grid small,
.capital-control,
.tag,
.index-chip {
  font-size: 11px;
}

.header-meta span {
  min-height: 30px;
  padding: 0 10px;
}

.layout {
  margin-top: 18px;
}

.sticky-toolbar {
  padding-top: 9px;
  padding-bottom: 9px;
}

.metric,
.allocation-panel,
.index-module,
.holdings-module,
.transactions-card,
.list-summary-card,
.buy-top-summary,
.stock-card {
  padding: 12px;
}

.summary-band,
.stock-list,
.index-module,
.detail-content {
  gap: 10px;
}

.metric-label {
  margin-bottom: 6px;
}

.metric strong {
  font-size: 22px;
}

.allocation-panel strong,
.section-title h2,
.list-summary-head strong,
.empty-state strong {
  font-size: 15px;
}

.allocation-panel p,
.index-module-head p,
.index-plan,
.index-note,
.holdings-head p,
.holdings-note,
.transactions-head p,
.transaction-note,
.weekly-note {
  line-height: 1.42;
}

.capital-control input,
.search-box {
  height: 36px;
}

.capital-control input {
  font-size: 13px;
}

.search-box {
  gap: 8px;
}

.search-box span {
  font-size: 15px;
}

.segment {
  height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

.index-module-head h2 {
  font-size: 18px;
}

.history-head h2,
.history-section-head h3,
.holdings-head h2,
.transactions-head h3,
.equity-chart-head strong {
  font-size: 18px;
}

.index-total {
  min-height: 30px;
  padding: 0 10px;
}

.index-summary-grid strong,
.history-score-card strong,
.holdings-summary-grid strong {
  font-size: clamp(15px, 1.55vw, 20px);
}

.index-fund-metrics strong {
  font-size: clamp(12px, 1.1vw, 15px);
}

.ticker {
  font-size: 17px;
}

.tag,
.index-chip {
  height: 21px;
  padding: 0 7px;
}

.stock-card {
  grid-template-columns:
    minmax(135px, 1fr) 86px minmax(56px, 0.35fr) minmax(68px, 0.4fr)
    minmax(118px, 0.7fr) minmax(130px, 0.75fr);
}

.sparkline {
  height: 46px;
}

.card-metric strong,
.allocation-metric strong,
.runaway-metric strong,
.detail-value {
  font-size: 13px;
}

.runaway-metric,
.detail-box,
.trigger,
.risk-item,
.weekly-note,
.history-score-card,
.history-rule,
.equity-card,
.contribution-card,
.holdings-summary-grid div,
.holdings-note,
.transactions-card,
.transaction-summary-grid div,
.transaction-note,
.index-fund-metrics div,
.index-summary-grid div,
.buy-summary-grid div,
.list-summary-grid div {
  padding: 9px 10px;
}

.detail-panel {
  top: 76px;
  padding: 14px;
}

.detail-head h2 {
  font-size: 19px;
}

.detail-grid,
.trigger-list,
.risk-list {
  gap: 8px;
}

@media (max-width: 920px) {
  .stock-list {
    overflow: hidden;
  }

  .stock-card {
    width: 100%;
    min-width: 0;
    grid-template-columns: minmax(0, 1fr);
    gap: 9px;
    overflow: hidden;
  }

  .stock-card > * {
    min-width: 0;
  }

  .card-metric,
  .runaway-metric {
    width: 100%;
  }

  .stock-card {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch;
  }

  .stock-main {
    grid-column: 1 / -1;
  }

  .buy-holding-compare,
  .buy-holding-compare.locked {
    grid-template-columns: 1fr;
  }

  .buy-summary-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .buy-summary-grid {
    grid-template-columns: 1fr;
  }

  .transactions-actions {
    justify-content: flex-start;
  }

  .transactions-form {
    grid-template-columns: 1fr;
  }

  .stock-card .sparkline,
  .stock-card .allocation-metric,
  .stock-card .runaway-metric {
    display: none;
  }

  .stock-card .card-metric {
    min-height: 54px;
    padding: 9px;
    border-radius: 8px;
    background: var(--surface-alt);
  }

  .stock-insight-row {
    gap: 4px;
  }

  .priority-pill,
  .insight-chip,
  .freshness-badge {
    max-width: 100%;
    white-space: normal;
  }

  .card-metric strong,
  .card-metric small {
    overflow-wrap: anywhere;
  }

  .summary-band .metric {
    flex-basis: 96px;
    min-height: 60px;
    padding: 8px 10px;
  }

  .summary-band .metric-label {
    font-size: 10px;
  }

  .summary-band .metric strong {
    font-size: 18px;
  }

  .system-status-grid {
    grid-template-columns: 1fr;
  }

  .system-status-card strong {
    font-size: 16px;
  }

  .sparkline {
    height: 54px;
  }
}

@media (max-width: 560px) {
  .segment {
    padding: 0 6px;
    font-size: 11px;
  }
}
