:root {
  --bg: #070b16;
  --panel: #0f1730;
  --panel-2: #141e3d;
  --line: #22305c;
  --ink: #eef2ff;
  --muted: #97a3c9;
  --accent: #4ade80;
  --accent-ink: #052e16;
  --up: #4ade80;
  --down: #f87171;
  --warn: #fbbf24;
  --radius: 14px;
  --max: 1120px;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: radial-gradient(1200px 600px at 70% -100px, #16224a 0%, var(--bg) 60%);
  color: var(--ink);
  font: 16px/1.6 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  overflow-x: hidden;
}

input, select, textarea, button { font-size: 16px !important; font-family: inherit; }

/* Nothing may force the page wider than the phone: the chart is a full-width
   inline SVG and instrument names and URLs are long and unbreakable. */
img, svg, video, canvas, table { max-width: 100%; }
img, svg, video, canvas { height: auto; }
p, li, td, th, a, h1, h2, h3 { overflow-wrap: anywhere; word-break: break-word; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: clamp(1.7rem, 4.5vw, 2.6rem); line-height: 1.15; margin: 0 0 .6rem; letter-spacing: -.02em; }
h2 { font-size: clamp(1.2rem, 3vw, 1.6rem); margin: 0 0 .6rem; letter-spacing: -.01em; }
h3 { font-size: 1.05rem; margin: 0 0 .35rem; }

main {
  max-width: var(--max);
  margin: 0 auto;
  padding: 1.25rem 1rem 3rem;
}

.narrow { max-width: 460px; margin: 0 auto; }
.muted { color: var(--muted); }
.micro { color: var(--muted); font-size: .85rem; }
.lede { font-size: 1.08rem; color: #cbd5f5; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* --- Nav --------------------------------------------------------------- */

.nav {
  display: flex; align-items: center; gap: 1rem;
  max-width: var(--max); margin: 0 auto;
  padding: .85rem 1rem;
  position: relative;
}
.logo { color: var(--ink); font-weight: 700; font-size: 1.1rem; letter-spacing: -.02em; }
.logo:hover { text-decoration: none; }
.nav-links { margin-left: auto; display: flex; align-items: center; gap: .35rem; flex-wrap: wrap; }
.nav-links a {
  color: var(--muted); padding: .5rem .7rem; border-radius: 10px; font-size: .95rem;
  min-height: 44px; display: inline-flex; align-items: center;
}
.nav-links a:hover { color: var(--ink); background: var(--panel); text-decoration: none; }
.nav-links a.active { color: var(--ink); background: var(--panel); }
.nav-links a.cta, .nav-links a.account {
  background: var(--panel-2); color: var(--ink); border: 1px solid var(--line);
}
.nav-toggle {
  display: none; margin-left: auto; background: var(--panel); color: var(--ink);
  border: 1px solid var(--line); border-radius: 10px; min-width: 44px; min-height: 44px;
}

@media (max-width: 780px) {
  .nav-toggle { display: block; }
  .nav-links {
    display: none; position: absolute; top: 100%; left: 1rem; right: 1rem; z-index: 30;
    flex-direction: column; align-items: stretch;
    background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
    padding: .5rem;
  }
  .nav-links.open { display: flex; }
}

.breadcrumbs { max-width: var(--max); margin: 0 auto; padding: 0 1rem; }
.breadcrumbs ol { display: flex; gap: .5rem; list-style: none; padding: 0; margin: 0; font-size: .85rem; color: var(--muted); flex-wrap: wrap; }
.breadcrumbs li + li::before { content: '›'; margin-right: .5rem; }

/* --- Blocks ------------------------------------------------------------ */

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem;
  margin: 1rem 0;
}

.flash { border-radius: var(--radius); padding: .75rem 1rem; margin-bottom: 1rem; border: 1px solid var(--line); }
.flash.error { background: #3b1220; border-color: #7f2440; }
.flash.success { background: #0d2f1e; border-color: #1f6f45; }
.flash.info { background: var(--panel-2); }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: .6rem 1.1rem;
  border-radius: 999px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--ink);
  font-weight: 600; cursor: pointer;
}
.btn:hover { text-decoration: none; border-color: #35graph; border-color: #3a4d8c; }
.btn.accent { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.ghost { background: transparent; }
.btn.disabled { opacity: .55; cursor: default; }
.btn.small { min-height: 38px; padding: .35rem .8rem; font-size: .9rem; }
form.inline { display: inline; }

.tick-list { list-style: none; padding: 0; margin: .5rem 0; }
.tick-list li { padding-left: 1.6rem; position: relative; margin: .35rem 0; }
.tick-list li::before { content: '✓'; position: absolute; left: 0; color: var(--accent); font-weight: 700; }

.stack { display: flex; flex-direction: column; gap: .8rem; }
.stack label { display: flex; flex-direction: column; gap: .3rem; font-size: .9rem; color: var(--muted); }
.stack input {
  background: var(--bg); color: var(--ink); border: 1px solid var(--line);
  border-radius: 10px; padding: .7rem .8rem; min-height: 44px;
}

/* --- Hero and search --------------------------------------------------- */

.hero { padding: 1.5rem 0 .5rem; }
.search-form { position: relative; display: flex; gap: .5rem; margin: 1rem 0; flex-wrap: wrap; }
.search-form input {
  flex: 1 1 220px; min-width: 0; min-height: 48px;
  background: var(--panel); color: var(--ink);
  border: 1px solid var(--line); border-radius: 12px; padding: .7rem 1rem;
}
.search-form button {
  min-height: 48px; padding: 0 1.4rem; border-radius: 12px; border: 0; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); font-weight: 700;
}

.results { list-style: none; padding: 0; margin: 1rem 0; display: grid; gap: .5rem; }
.search-form .typeahead {
  position: absolute; top: calc(100% + .35rem); left: 0; right: 0; z-index: 30;
  margin: 0; max-height: min(60vh, 22rem); overflow-y: auto;
}
.result a {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: .5rem;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: .85rem 1rem; color: var(--ink); min-height: 44px;
}
.result a:hover { border-color: #3a4d8c; text-decoration: none; }
.result-symbol { font-weight: 700; }
.result-name { color: var(--muted); flex: 1 1 auto; }
.result-meta { display: flex; gap: .35rem; flex-wrap: wrap; }
.tag {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .05em;
  background: var(--panel-2); border: 1px solid var(--line);
  padding: .15rem .5rem; border-radius: 999px; color: var(--muted);
}

.step-grid { list-style: none; padding: 0; display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.step-grid li { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; }
.step-n { display: inline-block; color: var(--accent); font-weight: 700; }

/* --- Stock page -------------------------------------------------------- */

.stock-head { display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-start; justify-content: space-between; }
.stock-name { color: var(--muted); font-weight: 400; font-size: .6em; display: block; }
.stock-meta { display: flex; gap: .35rem; flex-wrap: wrap; margin: .3rem 0 0; }
.stock-price { text-align: right; }
.stock-price .price { font-size: 1.8rem; font-weight: 700; display: block; }
.change.up { color: var(--up); }
.change.down { color: var(--down); }
.stock-price .micro { display: block; }

.actions { display: flex; gap: .5rem; flex-wrap: wrap; margin: 1rem 0; }

.verdict { border-radius: var(--radius); padding: 1rem; border: 1px solid var(--line); background: var(--panel); }
.verdict.good { border-color: #1f6f45; background: #0d2419; }
.verdict.warn { border-color: #8a6a16; background: #241d0d; }
.verdict.bad { border-color: #7f2440; background: #24101a; }
.verdict-grid, .stat-grid, .verdict dl, .fit-quality, .watch-targets {
  display: grid; gap: .5rem; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  margin: .75rem 0 0; padding: 0;
}
.verdict-grid div, .stat-grid div, .fit-quality div {
  background: rgba(255,255,255,.03); border-radius: 10px; padding: .5rem .7rem;
}
dt { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
dd { margin: .1rem 0 0; font-weight: 600; }

.chart-panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; margin: 1rem 0; }
.trend-chart { width: 100%; height: auto; aspect-ratio: 1000 / 460; display: block; }
@media (max-width: 640px) { .trend-chart { aspect-ratio: 1000 / 620; } }

.plot-bg { fill: rgba(255,255,255,.02); }
.grid { stroke: rgba(255,255,255,.07); stroke-width: 1; }
.axis { fill: var(--muted); font-size: 11px; }
.axis.mid { text-anchor: middle; }
.today-label { font-size: 10px; }
.channel-hist { fill: rgba(74,222,128,.06); }
.channel-proj { fill: rgba(74,222,128,.12); }
.price-line { fill: none; stroke: #93c5fd; stroke-width: 1.6; }
.trend-upper { fill: none; stroke: #f87171; stroke-width: 1.8; }
.trend-lower { fill: none; stroke: #4ade80; stroke-width: 1.8; }
.projected { stroke-dasharray: 6 5; }
.today { stroke: rgba(255,255,255,.35); stroke-width: 1; stroke-dasharray: 3 4; }
.last-dot { fill: #93c5fd; }
.marker.buy { fill: var(--accent); }
.marker.sell { fill: var(--down); }
.marker-label { font-size: 12px; font-weight: 700; text-anchor: middle; }
.marker-label.buy { fill: var(--accent); }
.marker-label.sell { fill: var(--down); }

.legend { list-style: none; display: flex; gap: 1rem; flex-wrap: wrap; padding: 0; margin: .6rem 0 0; font-size: .85rem; color: var(--muted); }
.swatch { display: inline-block; width: 14px; height: 3px; vertical-align: middle; margin-right: .35rem; }
.swatch.price { background: #93c5fd; }
.swatch.upper { background: #f87171; }
.swatch.lower { background: #4ade80; }
.swatch.proj { background: repeating-linear-gradient(90deg, #4ade80 0 5px, transparent 5px 9px); }

.trade-grid { display: grid; gap: .6rem; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.trade { border-radius: 12px; padding: .8rem; border: 1px solid var(--line); background: var(--panel-2); }
.trade.buy { border-color: #1f6f45; }
.trade.sell { border-color: #7f2440; }
.trade-price { font-size: 1.5rem; font-weight: 700; margin: .2rem 0 0; }
.trade-date { color: var(--muted); font-size: .85rem; margin: .1rem 0 0; }
.rationale { color: #cbd5f5; margin-top: .9rem; }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; min-width: 420px; font-size: .9rem; }
th, td { text-align: right; padding: .5rem .6rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
thead th { color: var(--muted); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }
tbody th[scope='row'] { text-align: left; font-weight: 600; }
.description { color: #cbd5f5; }

/* --- Watchlist --------------------------------------------------------- */

.watch-grid { list-style: none; padding: 0; display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.watch-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; }
/* The whole card opens the stock: a stretched link covers it, and the controls
   sit above that layer so their own clicks still land on them. */
.clickable { position: relative; cursor: pointer; transition: border-color .12s ease, background .12s ease; }
.clickable:hover { border-color: #3a4d8c; background: #171f38; }
.stretched::after { content: ''; position: absolute; inset: 0; z-index: 0; }
.watch-card .watch-actions { position: relative; z-index: 1; }
.watch-card .watch-actions .btn { cursor: pointer; }
.watch-card.good { border-color: #1f6f45; }
.watch-card.warn { border-color: #8a6a16; }
.watch-card.bad { border-color: #7f2440; }
.watch-head { display: block; color: var(--ink); }
.watch-symbol { font-weight: 700; font-size: 1.1rem; }
.watch-name { display: block; color: var(--muted); font-size: .85rem; }
.watch-price { font-size: 1.4rem; font-weight: 700; margin: .4rem 0 0; }
.watch-zone { color: var(--muted); margin: .1rem 0 .5rem; font-size: .9rem; }
.watch-actions { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: .7rem; }

/* --- Pricing ----------------------------------------------------------- */

.plan-grid { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); margin: 1.25rem 0; }
.plan { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem; display: flex; flex-direction: column; }
.plan.popular { border-color: var(--accent); }
.plan-flag { color: var(--accent-ink); background: var(--accent); display: inline-block; border-radius: 999px; padding: .1rem .6rem; font-size: .75rem; font-weight: 700; margin: 0 0 .5rem; }
.plan-price { font-size: 2rem; font-weight: 800; margin: .2rem 0 0; }
.plan-price span { font-size: .95rem; font-weight: 500; color: var(--muted); }
.plan-annual { color: var(--muted); font-size: .85rem; margin: 0 0 .5rem; }
.plan form { margin-top: auto; }
.interval-toggle { display: flex; gap: .8rem; margin: .6rem 0; font-size: .9rem; color: var(--muted); }
.interval-toggle input { min-height: auto; }
details { border-top: 1px solid var(--line); padding: .6rem 0; }
summary { cursor: pointer; font-weight: 600; min-height: 44px; display: flex; align-items: center; }

/* --- Footer ------------------------------------------------------------ */

footer {
  border-top: 1px solid var(--line);
  margin-top: 2rem; padding: 1.5rem 1rem 3rem;
  color: var(--muted); font-size: .9rem;
}
footer > * { max-width: var(--max); margin-left: auto; margin-right: auto; }
.footer-links { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); margin-bottom: 1rem; }
.footer-links h4 { color: var(--ink); margin: 0 0 .4rem; font-size: .9rem; }
.footer-links a { display: block; color: var(--muted); padding: .25rem 0; }
.disclaimer { font-size: .8rem; opacity: .8; }

/* --- Admin -------------------------------------------------------------- */

.admin-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.kpi-grid { display: grid; gap: .6rem; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin: .6rem 0 1rem; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem .9rem; }
.kpi dt { color: var(--muted); font-size: .85rem; }
.kpi dd { margin: .2rem 0 0; font-size: 1.6rem; font-weight: 800; }
.kpi .micro { margin: .2rem 0 0; }

.panel-grid { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); align-items: start; }
.panel-grid .panel { margin: 0; min-width: 0; }
.panel-grid .panel.wide { grid-column: 1 / -1; }
.panel-grid h2 { margin: 0 0 .6rem; font-size: 1.05rem; }

table.metrics { width: 100%; min-width: 0; }
table.metrics th { text-align: left; font-weight: 500; color: var(--muted); }
table.metrics th .micro { display: block; }
table.metrics td { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }

.admin-controls { display: flex; gap: .5rem; flex-wrap: wrap; margin: 1rem 0 .4rem; }
.admin-controls input { flex: 1 1 14rem; }
.admin-controls input, .admin-controls select {
  min-height: 44px; padding: .55rem .8rem; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--panel-2); color: var(--ink);
}

.panel form.inline { display: inline-flex; align-items: center; gap: .4rem; margin: 0 .4rem .4rem 0; }
.panel form.inline select {
  min-height: 44px; padding: .5rem .7rem; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--panel-2); color: var(--ink);
}

.admin-list { display: flex; flex-direction: column; gap: .5rem; }
.admin-row {
  display: flex; justify-content: space-between; gap: .8rem; flex-wrap: wrap;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .8rem .9rem; color: inherit; cursor: pointer;
}
.admin-row:hover { border-color: var(--accent); text-decoration: none; }
.admin-row-main { display: flex; flex-direction: column; }
.admin-row-meta { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }

.badge { border-radius: 999px; padding: .1rem .6rem; font-size: .78rem; font-weight: 700; border: 1px solid var(--line); }
.badge.ok { background: #0d2419; border-color: #1f6f45; }
.badge.pending { background: #241d0d; border-color: #8a6a16; }
.badge.bad { background: #24101a; border-color: #7f2440; }
.badge.muted { color: var(--muted); }

.panel.danger { border-color: #7f2440; }
.btn.danger { background: #7f2440; border-color: #7f2440; color: #fff; }

/* Panel tables carry their own layout: they must never force the shared
   420px table minimum, which would push values outside the box on a phone. */
.panel-grid table { min-width: 0; }
.panel-grid th, .panel-grid td { white-space: normal; overflow-wrap: anywhere; }
table.metrics th { padding-right: .3rem; }

@media (max-width: 700px) {
  .admin-head { flex-direction: column; align-items: flex-start; }
  .admin-row { flex-direction: column; align-items: flex-start; gap: .5rem; }
  .admin-row-meta { width: 100%; }
  .admin-row-meta .micro { flex-basis: 100%; }
  .kpi dd { font-size: 1.35rem; }
  .panel form.inline { display: flex; flex-wrap: wrap; width: 100%; }
  .panel form.inline select { flex: 1 1 8rem; }
  .panel form.inline button { flex: 1 1 100%; }
}

/* --- Track record ------------------------------------------------------ */

.stats {
  display: grid; gap: .6rem; margin: 1rem 0;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}
.statbox {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .8rem .9rem; text-align: left;
}
.statbox.good { border-color: #2c8a58; box-shadow: inset 0 0 0 1px rgba(44, 138, 88, .35); }
.statbox.good b { color: var(--up); }

tr.hit th, tr.hit td { background: rgba(44, 138, 88, .12); }
tr.hit th:first-child { box-shadow: inset 3px 0 0 var(--up); }
tr.missed th:first-child { box-shadow: inset 3px 0 0 rgba(127, 36, 64, .8); }

.statbox b { display: block; font-size: 1.5rem; font-weight: 800; }
.statbox span { color: var(--muted); font-size: .85rem; overflow-wrap: anywhere; }
td.up { color: var(--up); font-weight: 700; }
td.down { color: var(--down); font-weight: 700; }

/* Entry and target prices are detail: on a phone the call, the move and the
   result are what matter, and dropping them keeps the table inside the box. */
@media (max-width: 700px) {
  table.signals { min-width: 0; }
  table.signals th:nth-child(3), table.signals td:nth-child(3),
  table.signals th:nth-child(4), table.signals td:nth-child(4) { display: none; }
  table.signals th, table.signals td { padding: .5rem .4rem; }
}
