:root {
  --ink: #18231f;
  --forest: #173b2d;
  --forest-2: #234c3c;
  --sage: #a9b8a4;
  --cream: #f1efe7;
  --paper: #faf9f4;
  --line: rgba(24, 35, 31, .14);
  --orange: #d86d3d;
  --muted: #6f7873;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--paper); }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input { font: inherit; }
.wordmark { display: inline-flex; align-items: center; gap: 12px; font-size: 12px; font-weight: 800; letter-spacing: .14em; }
.wordmark span { display: grid; place-items: center; width: 34px; height: 34px; color: var(--cream); background: var(--forest); border-radius: 50%; font-family: Georgia, serif; font-size: 18px; letter-spacing: 0; }
.eyebrow { margin: 0 0 18px; color: var(--orange); font-size: 10px; font-weight: 800; letter-spacing: .2em; }

.login-layout { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(430px, .9fr); }
.login-intro { position: relative; display: flex; flex-direction: column; justify-content: space-between; overflow: hidden; padding: clamp(36px, 5vw, 76px); background: var(--cream); }
.login-intro::before {
  content: ""; position: absolute; width: 640px; height: 640px; right: -220px; bottom: -310px; border: 1px solid rgba(23, 59, 45, .14); border-radius: 50%;
  box-shadow: 0 0 0 70px rgba(23,59,45,.025), 0 0 0 140px rgba(23,59,45,.02), 0 0 0 210px rgba(23,59,45,.015);
}
.intro-copy { position: relative; max-width: 650px; padding: 10vh 0 8vh; }
.intro-copy h1 { margin: 0 0 28px; font: 500 clamp(52px, 6vw, 92px)/1.08 Georgia, "Noto Serif SC", serif; letter-spacing: -.055em; }
.intro-copy .lead { max-width: 510px; margin: 0; color: var(--muted); font-size: 17px; line-height: 1.9; }
.fine-print { position: relative; margin: 0; color: var(--muted); font-size: 11px; letter-spacing: .15em; }
.login-panel { display: grid; place-items: center; min-height: 100%; padding: 46px; background: var(--forest); }
.login-card { width: min(100%, 440px); padding: 48px; background: var(--paper); box-shadow: 0 30px 80px rgba(0, 0, 0, .2); }
.lock-mark { float: right; display: grid; place-items: center; width: 42px; height: 42px; margin-top: -8px; color: var(--cream); background: var(--orange); border-radius: 50%; font-size: 22px; transform: rotate(-45deg); }
.login-card h2 { margin: 0 0 9px; font: 500 32px/1.2 Georgia, "Noto Serif SC", serif; }
.muted { margin: 0 0 32px; color: var(--muted); font-size: 13px; line-height: 1.7; }
.login-card form { display: grid; gap: 20px; }
.login-card label { display: grid; gap: 8px; color: var(--ink); font-size: 12px; font-weight: 700; }
.login-card input {
  width: 100%; height: 52px; padding: 0 16px; color: var(--ink); background: white; border: 1px solid var(--line); border-radius: 2px; outline: none; transition: border-color .2s, box-shadow .2s;
}
.login-card input:focus { border-color: var(--forest-2); box-shadow: 0 0 0 3px rgba(35, 76, 60, .1); }
.login-card button {
  display: flex; justify-content: space-between; align-items: center; height: 54px; margin-top: 5px; padding: 0 20px; color: white; background: var(--forest); border: 0; cursor: pointer; font-weight: 700;
}
.login-card button:hover { background: var(--forest-2); }
.login-card button span { font-size: 20px; font-weight: 400; }
.error { margin: -12px 0 22px; padding: 12px 14px; color: #8a3325; background: #f7e8e2; border-left: 3px solid var(--orange); font-size: 12px; line-height: 1.6; }
.security-note { margin: 28px 0 0; color: var(--muted); font-size: 10px; text-align: center; }
.security-note span { margin-right: 5px; color: #4b8b67; font-size: 8px; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 260px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 34px 28px 28px; color: #eef1e9; background: var(--forest); }
.sidebar .wordmark { padding: 0 8px; }
.sidebar .wordmark span { color: var(--forest); background: var(--cream); }
.sidebar nav { display: grid; gap: 5px; margin-top: 80px; }
.sidebar nav a, .sidebar nav .disabled { display: flex; align-items: center; gap: 15px; min-height: 46px; padding: 0 14px; border-left: 2px solid transparent; font-size: 13px; }
.sidebar nav i { width: 18px; color: var(--sage); font-family: Georgia, serif; font-size: 10px; font-style: normal; }
.sidebar nav .active { color: white; background: rgba(255,255,255,.08); border-left-color: var(--orange); }
.sidebar nav .disabled { color: rgba(238,241,233,.38); }
.nav-label { margin: 32px 14px 9px; color: rgba(238,241,233,.38); font-size: 9px; font-weight: 800; letter-spacing: .18em; }
.sidebar-foot { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; margin-top: auto; padding: 18px 8px 0; border-top: 1px solid rgba(255,255,255,.12); }
.status-dot { width: 8px; height: 8px; background: #75b589; border-radius: 50%; box-shadow: 0 0 0 4px rgba(117,181,137,.12); }
.sidebar-foot strong, .sidebar-foot small { display: block; }
.sidebar-foot strong { max-width: 100px; overflow: hidden; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-foot small { margin-top: 3px; color: var(--sage); font-size: 9px; }
.sidebar-foot button { padding: 5px; color: var(--sage); background: none; border: 0; cursor: pointer; font-size: 10px; }
.workspace { min-width: 0; padding: 50px clamp(28px, 5vw, 76px) 28px; }
.workspace header { display: flex; justify-content: space-between; align-items: end; margin-bottom: 42px; }
.workspace header .eyebrow { margin-bottom: 10px; }
.workspace header h1 { margin: 0; font: 500 clamp(36px, 4vw, 58px)/1.1 Georgia, "Noto Serif SC", serif; letter-spacing: -.04em; }
.date-badge { padding: 9px 13px; border: 1px solid var(--line); color: var(--muted); font-size: 9px; font-weight: 700; letter-spacing: .13em; }
.hero-card { position: relative; display: grid; grid-template-columns: 1fr 270px; min-height: 320px; overflow: hidden; padding: clamp(34px, 5vw, 66px); color: var(--cream); background: var(--forest-2); }
.hero-card::after { content: ""; position: absolute; right: 0; bottom: 0; width: 42%; height: 6px; background: var(--orange); }
.card-index { color: var(--sage); font-size: 9px; font-weight: 800; letter-spacing: .18em; }
.hero-card h2 { max-width: 600px; margin: 60px 0 18px; font: 500 clamp(32px, 4vw, 54px)/1.1 Georgia, "Noto Serif SC", serif; letter-spacing: -.04em; }
.hero-card p { max-width: 610px; margin: 0; color: #cbd4c9; font-size: 14px; line-height: 1.9; }
.orb { align-self: center; justify-self: end; display: grid; place-items: center; width: 210px; height: 210px; border: 1px solid rgba(255,255,255,.18); border-radius: 50%; box-shadow: inset 0 0 0 40px rgba(255,255,255,.025), 0 0 0 40px rgba(255,255,255,.025); }
.orb span { color: var(--orange); font: italic 68px Georgia, serif; }
.section-heading { display: flex; justify-content: space-between; align-items: end; gap: 40px; margin: 62px 0 24px; }
.section-heading span { color: var(--orange); font-size: 9px; font-weight: 800; letter-spacing: .18em; }
.section-heading h2 { margin: 9px 0 0; font: 500 27px Georgia, "Noto Serif SC", serif; }
.section-heading p { max-width: 360px; margin: 0; color: var(--muted); font-size: 12px; line-height: 1.7; text-align: right; }
.module-grid { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.module-grid article, .module-grid > a { position: relative; min-height: 250px; padding: 30px; background: rgba(255,255,255,.38); border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.module-number { color: var(--muted); font: 11px Georgia, serif; }
.module-icon { margin: 42px 0 26px; color: var(--forest-2); font: 36px Georgia, serif; }
.module-grid h3 { margin: 0 0 10px; font: 500 20px Georgia, "Noto Serif SC", serif; }
.module-grid p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.7; }
.coming { position: absolute; right: 22px; top: 25px; padding: 5px 8px; color: var(--muted); background: var(--cream); font-size: 9px; }
.workspace footer { display: flex; justify-content: space-between; margin-top: 44px; color: var(--muted); font-size: 9px; letter-spacing: .12em; }
.workspace footer span:last-child::before { content: "●"; margin-right: 7px; color: #5e9a70; font-size: 7px; }
.not-found { display: grid; place-content: center; min-height: 100vh; text-align: center; }
.not-found h1 { font: 500 46px Georgia, serif; }
.not-found a { color: var(--orange); font-size: 13px; }
.hero-link { display: inline-flex; align-items: center; gap: 28px; margin-top: 30px; padding-bottom: 7px; color: white; border-bottom: 1px solid rgba(255,255,255,.5); font-size: 12px; font-weight: 700; }
.hero-link span { color: var(--orange); font-size: 18px; }
.module-live { transition: background .2s, transform .2s; }
.module-live:hover { z-index: 2; background: white; transform: translateY(-3px); box-shadow: 0 16px 40px rgba(24,35,31,.08); }
.coming.live { color: white; background: var(--forest-2); }

.compact-header { align-items: start !important; }
.compact-header > div:first-child > p:last-child { max-width: 650px; margin: 14px 0 0; color: var(--muted); font-size: 14px; line-height: 1.8; }
.panel { margin-bottom: 24px; padding: clamp(24px, 3vw, 38px); background: rgba(255,255,255,.58); border: 1px solid var(--line); }
.panel-heading { margin-bottom: 24px; }
.panel-heading .eyebrow { margin-bottom: 10px; }
.panel-heading h2, .chart-heading h2, .method-panel h2, .form-card h2 { margin: 0 0 10px; font: 500 27px/1.2 Georgia, "Noto Serif SC", serif; }
.panel-heading p, .chart-heading p { margin-top: 0; }
.split { display: flex; align-items: end; justify-content: space-between; gap: 32px; }
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; padding: 0 17px; color: var(--forest); background: transparent; border: 1px solid rgba(23,59,45,.32); cursor: pointer; font-size: 11px; font-weight: 800; }
.button:hover { background: rgba(23,59,45,.05); }
.button.primary { color: white; background: var(--forest); border-color: var(--forest); }
.button.primary:hover { background: var(--forest-2); }
.button.subtle { min-height: 34px; padding: 0 12px; font-size: 10px; }
.success, .error { padding: 12px 14px; border-left: 3px solid; font-size: 12px; line-height: 1.6; }
.success { color: #225d3c; background: #e5f1e8; border-color: #5b9b70; }
.error { color: #8a3325; background: #f7e8e2; border-color: var(--orange); }
.page-message { margin-bottom: 18px; }
.empty { padding: 26px; color: var(--muted); background: rgba(241,239,231,.7); border: 1px dashed rgba(24,35,31,.2); font-size: 12px; text-align: center; }
.empty.large { margin-bottom: 24px; padding: 56px 24px; }

.group-create-form { display: grid; grid-template-columns: minmax(210px, 1fr) auto; align-items: end; gap: 10px; }
.group-create-form label, .mini-form label, .comparison-form label, .stack-form label { display: grid; gap: 7px; color: var(--ink); font-size: 11px; font-weight: 700; }
.group-create-form input, .mini-form input, .mini-form textarea, .comparison-form input, .comparison-form textarea, .stack-form input {
  width: 100%; min-height: 44px; padding: 10px 12px; color: var(--ink); background: white; border: 1px solid var(--line); border-radius: 0; outline: none;
}
.group-create-form input:focus, .mini-form input:focus, .mini-form textarea:focus, .comparison-form input:focus, .comparison-form textarea:focus, .stack-form input:focus { border-color: var(--forest); box-shadow: 0 0 0 3px rgba(23,59,45,.08); }
.group-grid { display: grid; gap: 10px; }
.group-grid > article { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: 22px; padding: 20px; background: white; border: 1px solid var(--line); }
.group-grid > article.active { border-left: 3px solid var(--orange); }
.group-copy h3 { margin: 0 0 6px; font: 500 18px Georgia, "Noto Serif SC", serif; }
.group-copy p { margin: 0 0 6px; overflow-wrap: anywhere; color: var(--forest-2); font-size: 11px; letter-spacing: .06em; }
.group-copy small { color: var(--muted); font-size: 9px; }
.group-actions { display: flex; align-items: center; gap: 10px; }
.group-actions .selected { color: #2c7350; font-size: 10px; font-weight: 800; }
.group-actions details { position: relative; }
.group-actions summary { cursor: pointer; color: var(--muted); font-size: 10px; }
.group-actions details[open] { min-width: 260px; }
.mini-form { display: grid; gap: 10px; margin-top: 15px; padding: 18px; background: var(--cream); border: 1px solid var(--line); }
.delete-form { padding: 10px 18px 16px; background: var(--cream); }
.delete-form button { padding: 0; color: #a43f32; background: none; border: 0; cursor: pointer; font-size: 10px; }

.selection-feedback { display: flex; align-items: center; gap: 15px; margin: -10px 0 28px; padding: 14px 16px; color: #245b42; background: #e9f1e9; border-left: 3px solid #5b9b70; font-size: 11px; }
.selection-feedback span { color: var(--muted); }
.comparison-form { display: grid; grid-template-columns: minmax(260px, 1.5fr) minmax(150px, .7fr) minmax(150px, .7fr); align-items: end; gap: 16px; }
.comparison-form .codes-field { grid-row: span 2; }
.comparison-form textarea { min-height: 126px; resize: vertical; line-height: 1.6; }
.comparison-form .button { grid-column: 2 / 4; }
.comparison-error { margin-top: 20px; }

.chart-panel { padding-bottom: 28px; }
.chart-heading { display: grid; grid-template-columns: minmax(260px,.8fr) minmax(380px,1.2fr); gap: 30px; margin-bottom: 20px; }
.chart-heading .eyebrow { margin-bottom: 10px; }
.chart-legend { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); align-content: start; gap: 9px 16px; }
.chart-legend span { display: grid; grid-template-columns: 9px 54px minmax(0,1fr); align-items: center; gap: 7px; color: var(--muted); overflow: hidden; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.chart-legend i, .chart-hover-values i, .extreme-fund i { width: 8px; height: 8px; border-radius: 50%; }
.chart-legend b { color: var(--ink); font-size: 10px; }
.chart-scroll { overflow-x: auto; padding: 10px 0; }
#fund-comparison-chart { display: block; min-width: 760px; width: 100%; touch-action: none; }
#fund-comparison-chart text { fill: var(--muted); font: 10px Inter, sans-serif; pointer-events: none; }
.chart-grid-line { stroke: rgba(24,35,31,.1); stroke-width: 1; }
.chart-grid-line.vertical { stroke-dasharray: 3 5; }
.chart-zero-line { stroke: rgba(24,35,31,.28); stroke-width: 1.2; }
.chart-series-line { stroke-width: 2.5; vector-effect: non-scaling-stroke; transition: opacity .15s; }
.chart-series-line.dimmed { opacity: .14; }
.chart-highlight-segment { stroke-width: 6; vector-effect: non-scaling-stroke; }
.chart-highlight-endpoint { stroke: white; stroke-width: 3; vector-effect: non-scaling-stroke; }
.chart-hover-line { stroke: var(--ink); stroke-width: 1; stroke-dasharray: 4 4; }
.chart-hover-point { stroke: white; stroke-width: 2; vector-effect: non-scaling-stroke; }
.chart-hover-values { display: none; grid-template-columns: auto repeat(4,minmax(150px,1fr)); gap: 8px; align-items: center; margin: 4px 0 24px; padding: 12px; background: var(--cream); font-size: 10px; }
.chart-hover-values.visible { display: grid; }
.chart-hover-values span { display: grid; grid-template-columns: 8px 1fr auto; gap: 6px; align-items: center; }
.gain { color: #a34135 !important; }
.loss { color: #287252 !important; }
.extremes { margin-top: 22px; border-top: 1px solid var(--line); }
.extremes-heading { display: flex; justify-content: space-between; align-items: end; gap: 20px; padding: 24px 0 15px; }
.extremes-heading h3 { margin: 0 0 5px; font: 500 20px Georgia, serif; }
.extremes-heading p { margin: 0; }
.extremes-heading > span { color: var(--muted); font-size: 9px; }
.extreme-row { display: grid; grid-template-columns: minmax(170px,1fr) minmax(175px,.8fr) minmax(175px,.8fr); align-items: stretch; border-top: 1px solid var(--line); }
.extreme-fund { display: flex; align-items: center; gap: 10px; padding: 16px 10px 16px 0; }
.extreme-fund strong, .extreme-fund small { display: block; }
.extreme-fund strong { font: 500 13px Georgia, "Noto Serif SC", serif; }
.extreme-fund small { margin-top: 4px; color: var(--muted); font-size: 9px; }
.extreme-row button { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; padding: 14px 16px; color: var(--ink); background: transparent; border: 0; border-left: 1px solid var(--line); cursor: pointer; text-align: left; }
.extreme-row button:hover, .extreme-row button:focus { background: var(--cream); outline: none; }
.extreme-row button span { color: var(--muted); font-size: 9px; }
.extreme-row button strong { font: 500 17px Georgia, serif; }
.extreme-row button small { grid-column: 1/-1; color: var(--muted); font-size: 8px; }

.table-wrap { overflow-x: auto; }
.ranking-panel table { width: 100%; min-width: 780px; border-collapse: collapse; font-size: 11px; }
.ranking-panel th { padding: 12px 14px; color: var(--muted); border-bottom: 1px solid var(--line); font-size: 9px; letter-spacing: .08em; text-align: left; }
.ranking-panel td { padding: 16px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.ranking-panel td strong, .ranking-panel td small { display: block; }
.ranking-panel td small { margin-top: 5px; color: var(--muted); font-size: 9px; }
.ranking-panel .number { text-align: right; }
.pill { padding: 5px 8px; background: var(--cream); color: var(--forest-2); font-size: 9px; }
.warning { color: #704423; background: #faf1e6; border-color: #e2c5a8; }
.warning h2 { margin-top: 0; font: 500 21px Georgia, serif; }
.warning p { display: flex; gap: 16px; margin: 7px 0; font-size: 11px; }
.method-panel p:not(.eyebrow) { max-width: 920px; color: var(--muted); font-size: 12px; line-height: 1.9; }

.settings-grid { display: grid; grid-template-columns: minmax(280px,.8fr) minmax(380px,1.2fr); gap: 24px; }
.settings-summary { padding: 38px; color: white; background: var(--forest-2); }
.settings-summary h2 { margin: 56px 0 10px; font: 500 40px Georgia, serif; }
.settings-summary > p { color: #cad6cf; font-size: 12px; line-height: 1.8; }
.settings-summary dl { margin: 44px 0 0; border-top: 1px solid rgba(255,255,255,.15); }
.settings-summary dl div { display: flex; justify-content: space-between; gap: 18px; padding: 15px 0; border-bottom: 1px solid rgba(255,255,255,.15); font-size: 10px; }
.settings-summary dt { color: var(--sage); }
.settings-summary dd { margin: 0; }
.form-card { padding: 38px; background: white; border: 1px solid var(--line); }
.stack-form { display: grid; gap: 18px; margin-top: 26px; }
.stack-form .button { margin-top: 5px; }

@media (max-width: 900px) {
  .login-layout { grid-template-columns: 1fr; }
  .login-intro { min-height: 46vh; padding: 34px; }
  .intro-copy { padding: 8vh 0 4vh; }
  .fine-print { display: none; }
  .login-panel { padding: 34px 22px; }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: relative; width: 100%; height: auto; min-height: 0; padding: 20px 22px; flex-direction: row; align-items: center; justify-content: space-between; }
  .sidebar nav { display: none; }
  .sidebar-foot { margin: 0; padding: 0; border: 0; }
  .sidebar-foot .status-dot, .sidebar-foot div { display: none; }
  .hero-card { grid-template-columns: 1fr; }
  .orb { position: absolute; right: -55px; top: -55px; opacity: .32; }
  .module-grid { grid-template-columns: 1fr; }
  .chart-heading { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
  .comparison-form { grid-template-columns: 1fr 1fr; }
  .comparison-form .codes-field { grid-column: 1/-1; grid-row: auto; }
  .comparison-form .button { grid-column: 1/-1; }
  .chart-hover-values { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 560px) {
  .login-card { padding: 34px 26px; }
  .intro-copy h1 { font-size: 46px; }
  .workspace { padding: 34px 18px 22px; }
  .workspace header { align-items: start; flex-direction: column; gap: 20px; }
  .hero-card { min-height: 370px; padding: 32px 25px; }
  .hero-card h2 { margin-top: 92px; font-size: 36px; }
  .section-heading { align-items: start; flex-direction: column; gap: 12px; }
  .section-heading p { text-align: left; }
  .workspace footer { gap: 12px; flex-direction: column; }
  .split, .extremes-heading { align-items: start; flex-direction: column; }
  .group-create-form, .group-grid > article, .comparison-form, .extreme-row { grid-template-columns: 1fr; }
  .group-actions { align-items: flex-start; flex-direction: column; }
  .comparison-form .codes-field, .comparison-form .button { grid-column: auto; }
  .extreme-row button { border-left: 0; border-top: 1px solid var(--line); }
  .chart-legend { grid-template-columns: 1fr; }
  .chart-hover-values { grid-template-columns: 1fr; }
}
