:root {
  --bg:        #0a0e13;
  --bg-2:      #0e141c;
  --panel:     #111a24;
  --panel-2:   #0d151d;
  --line:      #1e2b38;
  --line-2:    #263849;
  --text:      #e6edf3;
  --muted:     #8ca0b3;
  --muted-2:   #5f7386;
  --accent:    #2ee6a6;
  --accent-2:  #35c4ff;
  --pos:       #2ee6a6;
  --neg:       #ff5d6c;
  --warn:      #ffcc4d;
  --purple:    #a389ff;
  --radius:    14px;
  --radius-sm: 9px;
  --shadow:    0 1px 0 rgba(255,255,255,.02) inset, 0 10px 30px rgba(0,0,0,.35);
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Roboto Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(53,196,255,.06), transparent 60%),
    radial-gradient(900px 500px at -10% 0%, rgba(46,230,166,.05), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

.app { max-width: 1440px; margin: 0 auto; padding: 0 18px 40px; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 18px;
  padding: 14px 4px; margin-bottom: 6px;
  background: linear-gradient(180deg, var(--bg) 60%, rgba(10,14,19,.7));
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.brand-mark { width: 34px; height: 34px; }
.brand-text { display: flex; flex-direction: column; line-height: 1; }
.brand-name { font-weight: 800; letter-spacing: 2px; font-size: 15px; }
.brand-sub { font-size: 10px; letter-spacing: 4px; color: var(--accent); font-weight: 600; }

.search { flex: 1; display: flex; align-items: center; gap: 8px; position: relative; max-width: 640px; }
.search-ico { position: absolute; left: 12px; width: 18px; height: 18px; color: var(--muted-2); pointer-events: none; }
#search-input {
  flex: 1; height: 42px; padding: 0 12px 0 38px;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 10px; color: var(--text); font-size: 14px; font-family: var(--mono);
  outline: none; transition: border-color .15s, box-shadow .15s;
}
#search-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(46,230,166,.12); }
#search-input::placeholder { color: var(--muted-2); font-family: var(--sans); }

.btn { cursor: pointer; border: 1px solid var(--line-2); background: var(--panel); color: var(--text); border-radius: 9px; height: 42px; padding: 0 16px; font-weight: 600; font-size: 13px; transition: .15s; }
.btn:hover { border-color: var(--line-2); background: var(--bg-2); }
.btn-primary { background: linear-gradient(180deg, #2ee6a6, #24c993); color: #04140d; border: none; box-shadow: 0 6px 16px rgba(46,230,166,.25); }
.btn-primary:hover { filter: brightness(1.06); }
.btn-ghost { height: 32px; padding: 0 12px; font-size: 12px; background: transparent; }

.topbar-right { display: flex; align-items: center; gap: 14px; flex-shrink: 0; }
.clock { font-family: var(--mono); font-size: 13px; color: var(--muted); }
.market-status { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); }
.market-status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted-2); }
.market-status.open .dot { background: var(--pos); box-shadow: 0 0 8px var(--pos); }
.market-status.closed .dot { background: var(--neg); }

/* ---------- Quick bar ---------- */
.quickbar { display: flex; gap: 7px; flex-wrap: wrap; padding: 8px 2px 14px; }
.quickbar button {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--muted);
  border-radius: 999px; padding: 5px 12px; font-size: 12px; font-family: var(--mono);
  cursor: pointer; transition: .15s;
}
.quickbar button:hover { color: var(--text); border-color: var(--line-2); }
.quickbar button.active { color: var(--accent); border-color: var(--accent); background: rgba(46,230,166,.08); }

/* ---------- Banner ---------- */
.banner { padding: 12px 16px; border-radius: 10px; margin-bottom: 14px; font-size: 13px; border: 1px solid var(--line-2); background: var(--panel-2); }
.banner.err { border-color: rgba(255,93,108,.4); background: rgba(255,93,108,.08); color: #ffb3ba; }
.banner.load { color: var(--muted); }

/* ---------- Grid ---------- */
.grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 14px; }
.span-4 { grid-column: span 4; }
.span-6 { grid-column: span 6; }
.span-8 { grid-column: span 8; }
.span-12 { grid-column: span 12; }

.card {
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  min-width: 0;
}
.card-h { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 10px; }
.card-h h2 { margin: 0; font-size: 13px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase; color: var(--muted); }
.hint { font-size: 11px; color: var(--muted-2); font-family: var(--mono); }
.badge { font-size: 10px; font-weight: 700; letter-spacing: .5px; color: var(--purple); border: 1px solid rgba(163,137,255,.4); border-radius: 6px; padding: 2px 6px; text-transform: uppercase; }

/* ---------- Instrument header ---------- */
.card-head { padding: 18px 20px; }
.inst { display: flex; align-items: center; gap: 28px; flex-wrap: wrap; }
.inst-id h1 { margin: 0; font-size: 30px; font-weight: 800; letter-spacing: 1px; font-family: var(--mono); }
.inst-name { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.inst-price { display: flex; align-items: baseline; gap: 14px; }
.inst-price .last { font-size: 30px; font-weight: 800; font-family: var(--mono); }
.inst-price .change { font-size: 15px; font-weight: 700; font-family: var(--mono); }
.inst-meta { margin-left: auto; display: flex; gap: 22px; flex-wrap: wrap; }
.inst-meta .m { display: flex; flex-direction: column; }
.inst-meta .m .k { font-size: 10px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted-2); }
.inst-meta .m .v { font-size: 14px; font-family: var(--mono); font-weight: 600; }

.pos { color: var(--pos); }
.neg { color: var(--neg); }
.muted { color: var(--muted); }

/* ---------- Chart ---------- */
.seg { display: inline-flex; background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.seg button { background: transparent; border: none; color: var(--muted); padding: 6px 12px; font-size: 12px; font-family: var(--mono); cursor: pointer; transition: .12s; }
.seg button:hover { color: var(--text); }
.seg button.active { background: rgba(46,230,166,.12); color: var(--accent); }

.chart-wrap { position: relative; }
.chart { width: 100%; height: 340px; }
.chart svg { width: 100%; height: 100%; display: block; }
.chart-tip {
  position: absolute; pointer-events: none; z-index: 5;
  background: rgba(6,10,14,.95); border: 1px solid var(--line-2);
  border-radius: 8px; padding: 8px 10px; font-family: var(--mono); font-size: 11px;
  transform: translate(-50%, -110%); white-space: nowrap; color: var(--text);
  box-shadow: 0 8px 20px rgba(0,0,0,.5);
}
.chart-legend { display: flex; gap: 16px; margin-top: 10px; font-size: 11px; color: var(--muted); }
.lg { display: inline-flex; align-items: center; gap: 6px; }
.lg::before { content: ""; width: 14px; height: 3px; border-radius: 2px; }
.lg-price::before { background: var(--accent-2); }
.lg-fc::before { background: var(--accent); border-top: 2px dashed var(--accent); height: 0; border-bottom: 0; }
.lg-band::before { background: rgba(46,230,166,.25); height: 10px; }

/* ---------- Gauge ---------- */
.gauge { width: 100%; height: 190px; display: flex; align-items: center; justify-content: center; }
.gauge-read { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-top: 6px; }
.gauge-read > div { display: flex; flex-direction: column; align-items: center; text-align: center; background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px; padding: 8px; }
.gauge-read .k { font-size: 10px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted-2); }
.gauge-read .v { font-size: 16px; font-weight: 700; font-family: var(--mono); margin-top: 2px; }

/* ---------- Seasonality ---------- */
.seasonality { display: grid; grid-template-columns: repeat(12, 1fr); gap: 6px; height: 200px; align-items: end; }
.sbar { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.sbar .bar-track { position: relative; width: 100%; height: 100%; display: flex; flex-direction: column; justify-content: center; }
.sbar .fill { width: 70%; margin: 0 auto; border-radius: 4px; transition: height .4s ease; }
.sbar.up .fill { background: linear-gradient(180deg, var(--pos), #1f9e73); }
.sbar.down .fill { background: linear-gradient(0deg, var(--neg), #c23c49); }
.sbar .mlabel { font-size: 10px; color: var(--muted-2); margin-top: 6px; font-family: var(--mono); }
.sbar.current .mlabel { color: var(--accent); font-weight: 700; }
.sbar .val { font-size: 9px; color: var(--muted); font-family: var(--mono); margin-bottom: 3px; }
.season-foot { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 16px; }
.season-foot .sf { display: flex; flex-direction: column; background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; }
.season-foot .k { font-size: 10px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted-2); }
.season-foot .v { font-size: 15px; font-weight: 700; font-family: var(--mono); margin-top: 3px; }

/* ---------- Technical stats ---------- */
.stats { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0; }
.stats li { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: 13px; }
.stats li:last-child { border-bottom: none; }
.stats .k { color: var(--muted); }
.stats .v { font-family: var(--mono); font-weight: 600; }
.verdict { margin-top: 12px; padding: 10px 12px; border-radius: 9px; font-size: 13px; font-weight: 700; text-align: center; border: 1px solid var(--line-2); }
.verdict.bull { color: var(--pos); border-color: rgba(46,230,166,.4); background: rgba(46,230,166,.07); }
.verdict.bear { color: var(--neg); border-color: rgba(255,93,108,.4); background: rgba(255,93,108,.07); }
.verdict.neutral { color: var(--warn); border-color: rgba(255,204,77,.35); background: rgba(255,204,77,.06); }

/* ---------- AI ---------- */
.ai { display: flex; flex-direction: column; gap: 10px; }
.ai .row { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; font-size: 13px; }
.ai .ico { flex-shrink: 0; width: 22px; height: 22px; border-radius: 6px; display: flex; align-items: center; justify-content: center; font-size: 12px; }
.ai .ico.up { background: rgba(46,230,166,.14); color: var(--pos); }
.ai .ico.down { background: rgba(255,93,108,.14); color: var(--neg); }
.ai .ico.info { background: rgba(53,196,255,.14); color: var(--accent-2); }
.ai .ico.warn { background: rgba(255,204,77,.14); color: var(--warn); }
.ai .txt { color: var(--text); }
.ai .txt b { color: #fff; }

/* ---------- Table ---------- */
.table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.table th { text-align: left; color: var(--muted-2); font-weight: 600; font-size: 10px; text-transform: uppercase; letter-spacing: .5px; padding: 8px 8px; border-bottom: 1px solid var(--line); }
.table td { padding: 9px 8px; border-bottom: 1px dashed var(--line); font-family: var(--mono); }
.table td.num, .table th.num { text-align: right; }
.table tbody tr:hover { background: rgba(255,255,255,.02); }
.tag { font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 5px; }
.tag.buy { color: var(--pos); background: rgba(46,230,166,.12); }
.tag.sell { color: var(--neg); background: rgba(255,93,108,.12); }
.insider-foot { margin-top: 12px; font-size: 12px; color: var(--muted); font-family: var(--mono); display: flex; gap: 18px; }

/* ---------- Watchlist ---------- */
.watchlist { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.wl-item { position: relative; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 12px; cursor: pointer; transition: .15s; }
.wl-item:hover { border-color: var(--line-2); transform: translateY(-1px); }
.wl-item .sym { font-family: var(--mono); font-weight: 700; font-size: 14px; }
.wl-item .px { font-family: var(--mono); font-size: 16px; font-weight: 700; margin-top: 6px; }
.wl-item .ch { font-family: var(--mono); font-size: 12px; margin-top: 2px; }
.wl-item .rm { position: absolute; top: 8px; right: 8px; width: 18px; height: 18px; border-radius: 5px; border: none; background: transparent; color: var(--muted-2); cursor: pointer; font-size: 14px; line-height: 1; }
.wl-item .rm:hover { color: var(--neg); background: rgba(255,93,108,.1); }
.wl-empty { color: var(--muted-2); font-size: 13px; padding: 6px 2px; }

/* ---------- Skeleton / loading ---------- */
.skeleton { position: relative; overflow: hidden; background: var(--panel-2); border-radius: 8px; }
.skeleton::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255,255,255,.04), transparent); animation: sweep 1.3s infinite; }
@keyframes sweep { 100% { transform: translateX(100%); } }
.is-loading { opacity: .55; pointer-events: none; }

/* ---------- Footer ---------- */
.foot { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 26px; padding-top: 16px; border-top: 1px solid var(--line); color: var(--muted-2); font-size: 12px; }
.foot .sep { opacity: .5; }
.foot .disclaimer { color: var(--muted-2); }

/* ---------- Responsive ---------- */
@media (max-width: 1080px) {
  .span-8 { grid-column: span 12; }
  .span-6 { grid-column: span 12; }
  .span-4 { grid-column: span 6; }
}
@media (max-width: 780px) {
  .topbar { flex-wrap: wrap; }
  .search { order: 3; max-width: none; width: 100%; }
  .span-4 { grid-column: span 12; }
  .inst-meta { margin-left: 0; width: 100%; }
  .season-foot { grid-template-columns: repeat(2, 1fr); }
  .inst { gap: 16px; }
  .clock { display: none; }
}
