:root {
  --bg: #0f1420;
  --panel: #171d2c;
  --panel-2: #1e2637;
  --line: #2b3450;
  --text: #e7ecf5;
  --muted: #9aa7bd;
  --accent: #5b9dff;
  --good: #35c28c;
  --bad: #f2647a;
  --warn: #f0b429;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 "Segoe UI", system-ui, -apple-system, sans-serif;
}
h1, h2, h3 { margin: 0 0 .4rem; font-weight: 650; }
h2 { font-size: 1.05rem; }
h3 { font-size: .95rem; margin-top: 1.6rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
a { color: var(--accent); }
.muted { color: var(--muted); font-weight: 400; }

header {
  display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; justify-content: space-between;
  padding: 1rem 1.5rem; border-bottom: 1px solid var(--line); background: var(--panel);
}
.brand { display: flex; gap: .8rem; align-items: center; }
.brand h1 { font-size: 1.15rem; }
.brand p { margin: 0; color: var(--muted); font-size: .82rem; }
.logo {
  display: grid; place-items: center; width: 38px; height: 38px; border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), #7b6bff); font-weight: 800; color: #fff;
}
.header-right { display: flex; gap: .8rem; align-items: center; }
#ticker-form { display: flex; gap: .5rem; }
#ticker {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  padding: .55rem .7rem; border-radius: 8px; font-size: .95rem; text-transform: uppercase; width: 150px;
}
#go {
  background: var(--accent); color: #08122a; border: 0; font-weight: 700; padding: .55rem 1.1rem;
  border-radius: 8px; cursor: pointer;
}
#go:disabled, #login-go:disabled { opacity: .5; cursor: default; }
.user-chip { display: flex; align-items: center; gap: .5rem; color: var(--muted); font-size: .82rem; }
.linkbtn { background: none; border: 0; color: var(--accent); cursor: pointer; font: inherit; padding: 0; text-decoration: underline; }

/* login */
.login { max-width: 380px; margin: 3rem auto; }
.login form { display: flex; flex-direction: column; gap: .7rem; margin-top: .8rem; }
.login label { display: flex; flex-direction: column; gap: .3rem; color: var(--muted); font-size: .82rem; }
.login input {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  padding: .55rem .7rem; border-radius: 8px; font-size: .95rem;
}
#login-go {
  background: var(--accent); color: #08122a; border: 0; font-weight: 700; padding: .6rem 1rem;
  border-radius: 8px; cursor: pointer; margin-top: .3rem;
}
.login-error { color: var(--bad); font-size: .82rem; margin: .2rem 0 0; }

.status { margin: 1rem 1.5rem 0; padding: .7rem 1rem; border-radius: 8px; background: var(--panel-2); border: 1px solid var(--line); }
.status.error { border-color: var(--bad); color: #ffd7dd; }

main { padding: 1.5rem; max-width: 1240px; margin: 0 auto; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 1.1rem 1.2rem; margin-bottom: 1.2rem; }
.columns { display: grid; grid-template-columns: 340px 1fr; gap: 1.2rem; align-items: start; }
@media (max-width: 900px) { .columns { grid-template-columns: 1fr; } }
.hint, .disclaimer { color: var(--muted); font-size: .8rem; }
.disclaimer { margin-top: 1.5rem; text-align: center; }

/* summary */
#summary { display: flex; flex-wrap: wrap; gap: 1.4rem 2.4rem; align-items: baseline; }
#summary .co-name { font-size: 1.2rem; font-weight: 700; }
#summary .metric { display: flex; flex-direction: column; }
#summary .metric span:first-child { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; }
#summary .metric span:last-child { font-size: 1rem; font-weight: 650; }

/* assumptions form */
#assumptions-form .group { border: 0; padding: 0; margin: 0 0 1rem; }
#assumptions-form legend { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); margin-bottom: .4rem; }
.field { display: grid; grid-template-columns: 1fr 96px; gap: .4rem; align-items: center; margin-bottom: .35rem; }
.field label { color: var(--muted); font-size: .82rem; }
.field input[type="number"], .field select {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  border-radius: 6px; padding: .35rem .45rem; font-size: .85rem; width: 100%;
}
.field.wide { grid-template-columns: 1fr; }
.field.wide select { width: 100%; }
.field .inwrap { display: flex; gap: .3rem; align-items: center; }
.field input:focus, .field select:focus { outline: 1px solid var(--accent); }
.field .suffix { color: var(--muted); font-size: .78rem; }
.checkbox { display: flex; gap: .5rem; align-items: center; margin: .3rem 0; color: var(--muted); font-size: .82rem; }

/* valuation card */
#valuation-card { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1rem; }
.stat { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: .8rem .9rem; }
.stat .k { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; }
.stat .v { font-size: 1.35rem; font-weight: 750; margin-top: .2rem; }
.stat .v.big { font-size: 1.7rem; }
.pos { color: var(--good); }
.neg { color: var(--bad); }

#bridge { margin-top: 1rem; color: var(--muted); font-size: .85rem; }
#bridge b { color: var(--text); }

.warn-list { margin: 1rem 0 0; padding: .7rem .9rem; border: 1px solid var(--warn); border-radius: 8px; background: rgba(240,180,41,.08); color: #ffe6ab; font-size: .82rem; }
.warn-list li { margin: .2rem 0; }

/* tables */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .82rem; }
th, td { border: 1px solid var(--line); padding: .4rem .55rem; text-align: right; white-space: nowrap; }
th:first-child, td:first-child { text-align: left; position: sticky; left: 0; background: var(--panel); }
thead th { background: var(--panel-2); color: var(--muted); font-weight: 600; }
tbody tr:hover td { background: rgba(91,157,255,.06); }

#sensitivity td.cell { color: #0c1322; font-weight: 650; }
#sensitivity .corner { background: var(--panel-2); }

#ratios .latest { background: rgba(91,157,255,.10); font-weight: 650; }
#ratios thead th.latest { color: var(--text); }

/* DCF-by-horizon cards */
#horizons { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; }
.hcard { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: .8rem .9rem; }
.hcard.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.hcard .k { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; }
.hcard .v { font-size: 1.5rem; font-weight: 750; margin: .15rem 0; }
.hcard .sub { font-size: .76rem; }

/* charts */
#history-charts { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: .5rem; }
@media (max-width: 700px) { #history-charts { grid-template-columns: 1fr; } }
.chart { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: .7rem; }
.chart h4 { margin: 0 0 .4rem; font-size: .78rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.chart svg { width: 100%; height: 140px; display: block; }
.bar { fill: var(--accent); }
.bar.neg { fill: var(--bad); }
.axis { stroke: var(--line); stroke-width: 1; }
.blabel { fill: var(--muted); font-size: 9px; }
