/* SAHM terminal. Dense, dark, monospace. */
:root {
  --bg: #000;
  --panel: #07090b;
  --panel-2: #0d1114;
  --line: #22292e;
  --line-2: #2f3a41;
  --amber: #ff9f1a;
  --amber-dim: #a86a10;
  --text: #e8eaec;
  --dim: #8b969e;
  --faint: #55616a;
  --up: #1fd67a;
  --down: #ff4d4d;
  --cyan: #3fb6ff;
  --mono: "Cascadia Mono", "Cascadia Code", Consolas, "SF Mono", Menlo, "DejaVu Sans Mono", monospace;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; background: var(--bg); color: var(--text); }
body { font: 12px/1.35 var(--mono); overflow: hidden; -webkit-font-smoothing: antialiased; }
a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; color: inherit; cursor: pointer; }
::selection { background: var(--amber); color: #000; }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: #050607; }
::-webkit-scrollbar-thumb { background: #27323a; border-radius: 0; }
::-webkit-scrollbar-thumb:hover { background: #3a4852; }

#term { display: grid; grid-template-rows: auto auto auto 1fr auto; height: 100vh; height: 100dvh; }

/* Top bar */
#top { display: flex; align-items: center; gap: 14px; padding: 0 10px; height: 34px; background: #000; border-bottom: 1px solid var(--line-2); }
.logo { display: flex; align-items: center; gap: 8px; color: var(--text); padding: 0 4px; font-size: 14px; }
.logo img { display: block; border-radius: 5px; }
.logo b { font-weight: 800; letter-spacing: 0.1em; }
.logo small { font-weight: 400; letter-spacing: 0.02em; color: var(--amber); font-size: 13px; }
#cmdwrap { position: relative; flex: 1; max-width: 520px; display: flex; align-items: center; background: #14100a; border: 1px solid var(--amber-dim); }
#cmdwrap:focus-within { border-color: var(--amber); box-shadow: 0 0 0 1px var(--amber) inset; }
#cmdwrap .prompt { color: var(--amber); padding: 0 8px; font-weight: 700; }
#cmd { flex: 1; background: transparent; border: 0; outline: 0; color: var(--amber); font: 600 13px var(--mono); padding: 6px 0; text-transform: uppercase; letter-spacing: 0.04em; }
#cmd::placeholder { color: #6b4a14; text-transform: none; font-weight: 400; }
#sugg { position: absolute; top: 100%; left: -1px; right: -1px; z-index: 50; background: #0a0c0e; border: 1px solid var(--amber-dim); max-height: 320px; overflow-y: auto; display: none; }
#sugg div { padding: 5px 10px; display: flex; gap: 10px; cursor: pointer; white-space: nowrap; }
#sugg div.on, #sugg div:hover { background: #22190a; }
#sugg .t { color: var(--amber); font-weight: 700; min-width: 64px; }
#sugg .n { color: var(--dim); overflow: hidden; text-overflow: ellipsis; }
#sugg .k { margin-left: auto; color: var(--faint); font-size: 10px; text-transform: uppercase; }
.top-right { margin-left: auto; display: flex; gap: 16px; align-items: center; color: var(--dim); font-size: 11px; }
.top-right b { color: var(--text); font-weight: 600; }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--up); margin-right: 6px; box-shadow: 0 0 6px var(--up); }

/* Tape */
#tape { height: 22px; overflow: hidden; background: #040506; border-bottom: 1px solid var(--line); position: relative; white-space: nowrap; }
#tape .track { display: inline-flex; animation: scroll 240s linear infinite; }
#tape:hover .track { animation-play-state: paused; }
#tape a { display: inline-flex; gap: 6px; padding: 3px 14px; border-right: 1px solid #14191d; color: var(--text); }
#tape a:hover { background: #14191d; text-decoration: none; }
#tape .tk { color: var(--amber); font-weight: 700; }
@keyframes scroll { from { transform: translateX(0); } to { transform: translateX(-50%); } }

/* Function keys */
#fkeys { display: flex; gap: 0; background: #0a0d10; border-bottom: 1px solid var(--line-2); overflow-x: auto; }
#fkeys button { background: transparent; border: 0; border-right: 1px solid var(--line); padding: 5px 14px; display: flex; gap: 7px; align-items: baseline; white-space: nowrap; color: var(--dim); }
#fkeys button span.f { color: var(--faint); font-size: 10px; }
#fkeys button b { color: var(--amber); font-weight: 700; letter-spacing: 0.04em; }
#fkeys button:hover { background: #151a1e; color: var(--text); }
#fkeys button.on { background: var(--amber); color: #000; }
#fkeys button.on b, #fkeys button.on span.f { color: #000; }

#screen { overflow: auto; padding: 8px; min-height: 0; }
#foot { display: flex; flex-wrap: wrap; gap: 2px 18px; padding: 4px 10px; border-top: 1px solid var(--line-2); background: #05070a; color: var(--faint); font-size: 10.5px; }
#foot b { color: var(--dim); font-weight: 600; }
#foot .sp { margin-left: auto; }

/* Panels */
.grid { display: grid; gap: 8px; }
.g-mkt { grid-template-columns: minmax(0, 1.7fr) minmax(300px, 1fr); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-eq { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
@media (max-width: 1100px) { .g-mkt, .g-eq, .g-3 { grid-template-columns: 1fr; } }
.panel { background: var(--panel); border: 1px solid var(--line); min-width: 0; }
.ph { display: flex; align-items: center; gap: 10px; padding: 4px 8px; background: #11161a; border-bottom: 1px solid var(--line); color: var(--amber); font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; }
.ph .r { margin-left: auto; color: var(--dim); font-weight: 400; text-transform: none; letter-spacing: 0; display: flex; gap: 6px; align-items: center; }
.pb { padding: 8px; }
.pb.flush { padding: 0; }
.note { color: var(--faint); font-size: 10.5px; padding: 5px 8px; line-height: 1.45; }
.note b { color: var(--dim); }

/* Colors */
.up { color: var(--up); } .down { color: var(--down); } .dim { color: var(--dim); } .amber { color: var(--amber); } .na { color: var(--faint); }

/* Tables */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 3px 8px; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; border-bottom: 1px solid #12171a; }
th { color: var(--amber); font-weight: 600; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.04em; background: #0c1013; position: sticky; top: 0; z-index: 2; cursor: default; user-select: none; }
th.s { cursor: pointer; } th.s:hover { color: #fff; }
th.l, td.l { text-align: left; }
tbody tr:hover td { background: #121a20; }
tr.click { cursor: pointer; }
td .tk { color: var(--amber); font-weight: 700; }
td.nm { color: var(--dim); max-width: 230px; overflow: hidden; text-overflow: ellipsis; }
.scroll { overflow: auto; }

/* Quote rows */
.kv { display: grid; grid-template-columns: 1fr auto; }
.kv > div { padding: 3px 8px; border-bottom: 1px solid #12171a; }
.kv > div:nth-child(odd) { color: var(--dim); }
.kv > div:nth-child(even) { text-align: right; font-variant-numeric: tabular-nums; }

/* Hero */
.hero { display: flex; align-items: flex-end; gap: 18px; padding: 8px 10px; flex-wrap: wrap; border: 1px solid var(--line); background: linear-gradient(180deg, #0d1215, #07090b); margin-bottom: 8px; }
.hero .tk { color: var(--amber); font-size: 20px; font-weight: 800; letter-spacing: 0.04em; }
.hero .nm { color: var(--dim); font-size: 12px; }
.hero .px { font-size: 30px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.hero .chg { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.hero .meta { margin-left: auto; text-align: right; color: var(--dim); font-size: 11px; }
.tag { display: inline-block; border: 1px solid var(--line-2); color: var(--dim); padding: 0 6px; font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em; }
.tag.amber { border-color: var(--amber-dim); color: var(--amber); }
.star { background: transparent; border: 1px solid var(--line-2); padding: 2px 8px; color: var(--dim); }
.star.on { color: var(--amber); border-color: var(--amber); }

/* Toolbar buttons */
.tb { display: flex; gap: 2px; flex-wrap: wrap; }
.tb button { background: #0f1418; border: 1px solid var(--line); padding: 2px 9px; color: var(--dim); font-size: 11px; }
.tb button:hover { color: #fff; border-color: var(--line-2); }
.tb button.on { background: var(--amber); border-color: var(--amber); color: #000; font-weight: 700; }
.tb .sep { width: 10px; }

/* Charts */
.chartbox { position: relative; }
.chart { width: 100%; }
.legend { position: absolute; left: 8px; top: 6px; z-index: 5; pointer-events: none; font-size: 11px; display: flex; gap: 12px; flex-wrap: wrap; background: rgba(0,0,0,0.55); padding: 2px 6px; }
.legend b { color: var(--dim); font-weight: 400; margin-right: 3px; }
.range { position: relative; height: 6px; background: #1a2227; margin: 6px 0 2px; }
.range i { position: absolute; top: -3px; width: 2px; height: 12px; background: var(--amber); }
.bar { display: inline-block; height: 8px; vertical-align: middle; }
.mini-range { position: relative; width: 70px; height: 4px; background: #1b2429; display: inline-block; vertical-align: middle; }
.mini-range i { position: absolute; top: -3px; width: 2px; height: 10px; background: var(--amber); }

/* Forms */
.form { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
label.f { display: grid; gap: 3px; color: var(--dim); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.04em; }
input.in, select.in, input[type="number"], input[type="text"].in {
  background: #0a0d10; border: 1px solid var(--line-2); color: var(--text); font: 12px var(--mono); padding: 5px 7px; outline: 0; width: 100%;
}
input.in:focus, select.in:focus, input[type="number"]:focus { border-color: var(--amber); }
.btn { background: var(--amber); color: #000; border: 0; padding: 6px 14px; font-weight: 800; letter-spacing: 0.05em; text-transform: uppercase; }
.btn:hover { filter: brightness(1.1); }
.btn.ghost { background: transparent; color: var(--amber); border: 1px solid var(--amber-dim); font-weight: 600; }
.banner { border: 1px solid var(--amber-dim); background: #1a1306; color: var(--amber); padding: 6px 10px; margin: 6px 0; font-size: 11.5px; }
.banner.err { border-color: #7a2323; background: #1d0a0a; color: var(--down); }
.empty { padding: 28px 12px; text-align: center; color: var(--dim); }

/* Heatmap */
#map { position: relative; width: 100%; background: #000; }
#map .cell { position: absolute; border: 1px solid #000; overflow: hidden; padding: 3px 5px; color: #fff; cursor: pointer; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; }
#map .cell:hover { outline: 2px solid var(--amber); z-index: 3; }
#map .cell b { font-size: 12px; text-shadow: 0 1px 2px #000; }
#map .cell span { font-size: 11px; text-shadow: 0 1px 2px #000; }

/* Help */
.kbd { display: inline-block; border: 1px solid var(--line-2); background: #11161a; padding: 0 6px; color: var(--amber); }
.help li { margin: 4px 0; }
.help ul { padding-left: 16px; margin: 6px 0; }
.loading { padding: 40px; text-align: center; color: var(--amber); letter-spacing: 0.2em; }
.loading::after { content: ""; animation: dots 1.2s steps(4) infinite; }
@keyframes dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }

.lang, .sw { display: flex; border: 1px solid var(--line-2); }
.lang button, .sw button { background: transparent; border: 0; padding: 2px 9px; color: var(--dim); font-weight: 700; font-size: 11px; letter-spacing: 0.06em; }
.lang button:hover, .sw button:hover { color: #fff; }
.lang button.on, .sw button.on { background: var(--amber); color: #000; }

/* AI assistant placeholder */
.ai .spark { color: var(--amber); font-size: 14px; }
.ai-lead { margin: 0 0 12px; line-height: 1.6; color: var(--text); font-size: 13px; }
.ai-list { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.ai-item { border: 1px solid var(--line); background: var(--panel-2); padding: 8px 10px; border-left: 2px solid var(--amber-dim); }
.ai-h { color: var(--amber); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 700; margin-bottom: 3px; }
.ai-t { color: var(--dim); line-height: 1.5; }
.ai-box { display: flex; gap: 8px; }
.ai-box input:disabled, .ai-box button:disabled { opacity: 0.5; cursor: not-allowed; }
.ai-box button:disabled { filter: grayscale(0.6); }

/* Phones and small tablets */
@media (max-width: 800px) {
  #top { flex-wrap: wrap; height: auto; padding: 6px 8px; gap: 8px; }
  .logo small { display: none; }
  #cmdwrap { order: 3; flex-basis: 100%; max-width: none; }
  .top-right { margin-left: auto; font-size: 10px; gap: 8px; }
  .top-right > span:nth-child(2) { display: none; }
  #fkeys button { padding: 6px 10px; }
  #fkeys button span:last-child:not(.f) { display: none; }
  #screen { padding: 6px; }
  .hero { gap: 10px; padding: 8px; }
  .hero .px { font-size: 24px; }
  .hero .meta { margin-left: 0; text-align: left; width: 100%; }
  .ph { flex-wrap: wrap; }
  .ph .r { margin-left: 0; width: 100%; flex-wrap: wrap; }
  .legend { font-size: 10px; gap: 8px; }
  th, td { padding: 3px 6px; }
  td.nm { max-width: 120px; }
  .kv > div { padding: 3px 6px; }
  #foot { flex-wrap: wrap; white-space: normal; gap: 2px 12px; font-size: 10px; }
  #foot .xs { display: none; }
  #foot .sp { margin-left: 0; }
  .tb button { padding: 4px 9px; }
}

/* market news and TradingView tab */
.g-news { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; align-content: start; }
.news { list-style: none; margin: 0; padding: 0; }
.news li { padding: 6px 10px; border-bottom: 1px solid var(--line); line-height: 1.35; }
.news li:last-child { border-bottom: 0; }
.news a { color: var(--text); text-decoration: none; }
.news a:hover { color: var(--amber); }
.news .src { display: block; color: var(--dim); font-size: 10.5px; margin-top: 2px; }
.tv-credit { font-size: 10.5px; padding-top: 4px; }
.tv-credit a { color: var(--dim); }
@media (max-width: 800px) { .g-news { grid-template-columns: 1fr; } }
/* ten function keys: keep the label only for the active key when space is tight */
@media (max-width: 1750px) {
  #fkeys button { padding: 5px 11px; }
  #fkeys button:not(.on) > span:last-child { display: none; }
}

/* TradingView tab: a fixed, tall box so the widget cannot collapse to a few lines */
.tv-wrap { height: max(600px, 78vh); min-height: 420px; }
.tv-wrap .tradingview-widget-container, .tv-wrap .tradingview-widget-container__widget { height: 100% !important; width: 100% !important; }
@media (max-width: 800px) { .tv-wrap { height: 460px; } }

/* LIVE feed: TradingView widgets */
#tape.live { height: 48px; white-space: normal; }
#tape.live .tradingview-widget-container { height: 100%; }
.tv-box { width: 100%; }
.tv-box .tradingview-widget-container, .tv-box .tradingview-widget-container__widget { height: 100% !important; width: 100% !important; }
.sw { margin-right: 8px; }

/* All tab and company logos */
.allsec { border-top: 1px solid var(--line); padding-bottom: 6px; }
.allsec:first-child { border-top: 0; }
.subh { color: var(--amber); font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; font-size: 11px; padding: 10px 10px 4px; }
.allscroll { max-height: 440px; overflow: auto; }
.clogo { width: 44px; height: 44px; object-fit: contain; background: #fff; border-radius: 8px; padding: 4px; align-self: center; }
#map .cell .mlogo { max-width: 60%; max-height: 38%; object-fit: contain; background: #fff; border-radius: 5px; padding: 2px 4px; margin-bottom: 3px; }

/* heat map sector groups */
#map .shead { position: absolute; display: flex; justify-content: space-between; align-items: center; padding: 0 6px; background: #05070a; color: #cfd6db; font-size: 11px; border: 1px solid #000; overflow: hidden; white-space: nowrap; z-index: 2; }
#map .shead b { letter-spacing: 0.04em; font-weight: 700; }
#map .shead .up { color: var(--up); } #map .shead .dn { color: var(--down); }
