/* MarketDesk — dense dark terminal aesthetic. */
:root {
  --bg: #0a0c10;
  --panel: #10141b;
  --panel-2: #151a23;
  --panel-3: #1b212c;
  --border: #222936;
  --border-2: #2c3444;
  --text: #e7eaf0;
  --muted: #8d96a8;
  --dim: #5c6577;
  --up: #22c977;
  --up-dim: #22c97722;
  --down: #f6465d;
  --down-dim: #f6465d22;
  --accent: #4d8dff;
  --accent-dim: #4d8dff1f;
  --warn: #f0b429;
  --radius: 8px;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow-y: scroll;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input { font: inherit; color: inherit; }
.num, td.num, .mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

.up { color: var(--up); }
.down { color: var(--down); }
.flat, .muted { color: var(--muted); }
.dim { color: var(--dim); }

/* ---------------------------------- chrome ---------------------------------- */

header.top {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 18px;
  padding: 0 18px; height: 52px;
  background: rgba(10, 12, 16, .88);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 650; letter-spacing: -.2px; }
.brand .mark {
  width: 22px; height: 22px; border-radius: 5px; display: grid; place-items: center;
  background: linear-gradient(140deg, var(--up), var(--accent)); color: #05070a;
  font: 700 13px var(--mono);
}
nav.tabs { display: flex; gap: 2px; }
nav.tabs a {
  padding: 6px 13px; border-radius: 6px; color: var(--muted);
  font-weight: 550; font-size: 13.5px; transition: background .12s, color .12s;
}
nav.tabs a:hover { color: var(--text); background: var(--panel-2); }
nav.tabs a.active { color: var(--text); background: var(--panel-3); }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.kbd-hint {
  display: flex; align-items: center; gap: 7px; padding: 5px 10px;
  border: 1px solid var(--border); border-radius: 6px;
  color: var(--dim); font-size: 12.5px; cursor: pointer;
}
.kbd-hint:hover { border-color: var(--border-2); color: var(--muted); }
kbd {
  font: 500 11px var(--mono); padding: 1.5px 5px; border-radius: 4px;
  background: var(--panel-3); border: 1px solid var(--border-2); color: var(--muted);
}
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--up); box-shadow: 0 0 0 3px var(--up-dim); }
.status-dot.stale { background: var(--warn); box-shadow: 0 0 0 3px #f0b42922; }
.status-dot.err { background: var(--down); box-shadow: 0 0 0 3px var(--down-dim); }

main { max-width: 1560px; margin: 0 auto; padding: 18px; }

/* ------------------------------- generic panels ------------------------------- */

.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.panel-head {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--panel-2);
}
.panel-head h2 { margin: 0; font-size: 12px; font-weight: 650; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.panel-head .spacer { margin-left: auto; }
.panel-body { padding: 12px 14px; }
.panel-body.flush { padding: 0; }

.grid { display: grid; gap: 14px; }
.section-title {
  margin: 22px 0 11px; font-size: 12px; font-weight: 650; letter-spacing: .07em;
  text-transform: uppercase; color: var(--dim);
}
.section-title:first-child { margin-top: 0; }

/* --------------------------------- quote tiles --------------------------------- */

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(212px, 1fr)); gap: 10px; }
.tile {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 11px 13px; display: flex; flex-direction: column; gap: 3px;
  position: relative; overflow: hidden; transition: border-color .12s, transform .12s;
}
a.tile:hover { border-color: var(--border-2); transform: translateY(-1px); }
.tile-name { font-size: 12px; color: var(--muted); font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-last { font: 600 20px/1.2 var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -.4px; }
.tile-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tile .spark { position: absolute; right: 10px; bottom: 8px; opacity: .85; pointer-events: none; }

.delta { display: inline-flex; gap: 7px; align-items: baseline; font-family: var(--mono); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.delta-abs { opacity: .78; }
.delta.up { color: var(--up); } .delta.down { color: var(--down); } .delta.flat { color: var(--muted); }

/* ----------------------------------- tables ----------------------------------- */

table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th {
  text-align: right; padding: 8px 12px; font-size: 11px; font-weight: 600;
  letter-spacing: .05em; text-transform: uppercase; color: var(--dim);
  border-bottom: 1px solid var(--border); background: var(--panel-2);
  position: sticky; top: 52px; z-index: 5; white-space: nowrap;
}
table.data th:first-child, table.data td:first-child { text-align: left; }
table.data th.sortable { cursor: pointer; user-select: none; }
table.data th.sortable:hover { color: var(--muted); }
table.data th.sorted { color: var(--accent); }
table.data td {
  padding: 9px 12px; text-align: right; border-bottom: 1px solid var(--border);
  font-family: var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap;
}
table.data td.text { font-family: var(--sans); }
table.data tbody tr { transition: background .1s; }
table.data tbody tr:hover { background: var(--panel-2); }
table.data tbody tr:last-child td { border-bottom: none; }
.sym { font-weight: 650; font-family: var(--mono); letter-spacing: -.1px; }
.sym-name { color: var(--muted); font-family: var(--sans); font-size: 12.5px; margin-left: 9px; font-weight: 400; }
.row-link { cursor: pointer; }

@keyframes flashUp { from { background: var(--up-dim); } to { background: transparent; } }
@keyframes flashDown { from { background: var(--down-dim); } to { background: transparent; } }
.flash-up { animation: flashUp .75s ease-out; }
.flash-down { animation: flashDown .75s ease-out; }

/* ----------------------------------- charts ----------------------------------- */

.chart-host { position: relative; width: 100%; }
.pchart { display: block; overflow: visible; }
.pchart .grid { stroke: var(--border); stroke-width: 1; }
.pchart .baseline { stroke: var(--dim); stroke-width: 1; stroke-dasharray: 3 3; opacity: .7; }
.pchart .axis-y { fill: var(--dim); font: 10.5px var(--mono); }
.pchart .axis-y.base { fill: var(--muted); }
.pchart .axis-x { fill: var(--dim); font: 10.5px var(--mono); }
.pchart .hair-line { stroke: var(--border-2); stroke-width: 1; stroke-dasharray: 2 3; }
.chart-empty { display: grid; place-items: center; height: 200px; color: var(--dim); font-size: 13px; }
.chart-tip {
  position: absolute; pointer-events: none; z-index: 10;
  background: var(--panel-3); border: 1px solid var(--border-2); border-radius: 6px;
  padding: 7px 10px; font-family: var(--mono); font-size: 11.5px; line-height: 1.5;
  box-shadow: 0 8px 24px #00000066; white-space: nowrap;
}
.tip-when { color: var(--dim); font-size: 10.5px; }
.tip-price { font-size: 14px; font-weight: 600; }
.tip-vol, .tip-ohlc { color: var(--muted); font-size: 10.5px; }

.range-tabs { display: flex; gap: 2px; }
.range-tabs button {
  padding: 4px 10px; border-radius: 5px; font: 600 12px var(--mono); color: var(--dim);
}
.range-tabs button:hover { color: var(--text); background: var(--panel-2); }
.range-tabs button.active { color: var(--text); background: var(--panel-3); }

/* bar rows + histogram */
.bar-row { display: grid; grid-template-columns: 132px 1fr 64px; gap: 10px; align-items: center; padding: 4px 0; font-size: 12.5px; }
.bar-row.clickable { cursor: pointer; }
.bar-row.clickable:hover .bar-label { color: var(--text); }
.bar-label { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { position: relative; height: 15px; background: var(--panel-2); border-radius: 3px; }
.bar-mid { position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; background: var(--border-2); }
.bar-fill { position: absolute; top: 2px; bottom: 2px; border-radius: 2px; }
.bar-fill.up { background: var(--up); } .bar-fill.down { background: var(--down); }
.bar-value { text-align: right; font-family: var(--mono); font-size: 12px; font-variant-numeric: tabular-nums; }

.hist { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; height: 132px; align-items: end; }
.hist-col { display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.hist-bar-wrap { flex: 1; width: 100%; display: flex; align-items: flex-end; }
.hist-bar { width: 100%; border-radius: 3px 3px 0 0; min-height: 2px; }
.hist-bar.up { background: var(--up); opacity: .8; } .hist-bar.down { background: var(--down); opacity: .8; }
.hist-n { font: 600 11px var(--mono); color: var(--muted); }
.hist-label { font: 10px var(--mono); color: var(--dim); }

/* --------------------------------- watchlist --------------------------------- */

.wl-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.list-tabs { display: flex; gap: 2px; align-items: center; flex-wrap: wrap; }
.list-tab {
  display: flex; align-items: center; gap: 7px; padding: 6px 12px; border-radius: 6px;
  color: var(--muted); font-weight: 550; font-size: 13px; border: 1px solid transparent;
}
.list-tab:hover { background: var(--panel-2); color: var(--text); }
.list-tab.active { background: var(--panel-3); color: var(--text); border-color: var(--border-2); }
.list-tab .n { font: 600 10.5px var(--mono); color: var(--dim); background: var(--panel); padding: 1px 5px; border-radius: 4px; }
.list-tab .idx { font: 600 10px var(--mono); color: var(--dim); }

.add-box { position: relative; flex: 1; min-width: 300px; }
.add-input {
  width: 100%; padding: 10px 13px 10px 36px; border-radius: 7px;
  background: var(--panel); border: 1px solid var(--border-2); outline: none;
  font-family: var(--mono); font-size: 14px; transition: border-color .12s, box-shadow .12s;
}
.add-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.add-input::placeholder { color: var(--dim); font-family: var(--sans); }
.add-box .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--dim); pointer-events: none; }

.suggest {
  position: absolute; top: calc(100% + 5px); left: 0; right: 0; z-index: 30;
  background: var(--panel-2); border: 1px solid var(--border-2); border-radius: 8px;
  box-shadow: 0 16px 40px #00000088; overflow: hidden; max-height: 340px; overflow-y: auto;
}
.suggest-item {
  display: grid; grid-template-columns: 74px 1fr auto; gap: 10px; align-items: center;
  padding: 8px 12px; cursor: pointer; border-bottom: 1px solid var(--border);
}
.suggest-item:last-child { border-bottom: none; }
.suggest-item.sel { background: var(--accent-dim); }
.suggest-item .s-sym { font: 650 13px var(--mono); }
.suggest-item .s-name { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.suggest-item .s-px { font: 12px var(--mono); font-variant-numeric: tabular-nums; text-align: right; }
.suggest-item .s-tag { font: 9.5px var(--mono); text-transform: uppercase; color: var(--dim); border: 1px solid var(--border-2); border-radius: 3px; padding: 0 4px; margin-left: 6px; }
.suggest-foot { padding: 6px 12px; background: var(--panel); color: var(--dim); font-size: 11.5px; display: flex; gap: 14px; }

.wl-total { display: flex; gap: 22px; flex-wrap: wrap; }
.stat { display: flex; flex-direction: column; gap: 1px; }
.stat .k { font-size: 10.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--dim); }
.stat .v { font: 600 17px var(--mono); font-variant-numeric: tabular-nums; }

.drag-handle { color: var(--border-2); cursor: grab; padding-right: 2px; user-select: none; }
tr.dragging { opacity: .4; }
tr.drop-target td { box-shadow: inset 0 2px 0 var(--accent); }
.icon-btn { color: var(--dim); padding: 2px 5px; border-radius: 4px; line-height: 1; }
.icon-btn:hover { color: var(--text); background: var(--panel-3); }
.icon-btn.danger:hover { color: var(--down); }
.cell-edit {
  width: 78px; background: transparent; border: 1px solid transparent; border-radius: 4px;
  padding: 2px 5px; text-align: right; font-family: var(--mono); font-size: 13px;
}
.cell-edit:hover { border-color: var(--border); }
.cell-edit:focus { border-color: var(--accent); background: var(--panel); outline: none; }

.empty { padding: 46px 20px; text-align: center; color: var(--dim); }
.empty h3 { margin: 0 0 6px; color: var(--muted); font-size: 15px; font-weight: 550; }

/* --------------------------------- symbol page --------------------------------- */

.sym-head { display: flex; align-items: flex-start; gap: 18px; flex-wrap: wrap; margin-bottom: 16px; }
.sym-title h1 { margin: 0; font: 650 26px/1.15 var(--mono); letter-spacing: -.6px; }
.sym-title .co { color: var(--muted); font-size: 14px; margin-top: 2px; }
.sym-title .tags { display: flex; gap: 6px; margin-top: 7px; flex-wrap: wrap; }
.tag { font: 10.5px var(--mono); text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: var(--panel-2); border: 1px solid var(--border); border-radius: 4px; padding: 2px 7px; }
.sym-price { margin-left: auto; text-align: right; }
.sym-price .big { font: 650 34px/1 var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -1px; }
.sym-price .delta { font-size: 15px; margin-top: 6px; }
.sym-price .ext { margin-top: 5px; font: 11.5px var(--mono); color: var(--muted); }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 1px; background: var(--border); }
.stat-cell { background: var(--panel); padding: 10px 13px; display: flex; flex-direction: column; gap: 2px; }
.stat-cell .k { font-size: 10.5px; letter-spacing: .05em; text-transform: uppercase; color: var(--dim); }
.stat-cell .v { font: 550 14.5px var(--mono); font-variant-numeric: tabular-nums; }

.range-bar { padding: 6px 2px 2px; }
.range-track { position: relative; height: 5px; background: linear-gradient(90deg, var(--down), var(--dim) 50%, var(--up)); border-radius: 3px; opacity: .55; }
.range-knob { position: absolute; top: -4px; width: 3px; height: 13px; background: var(--text); border-radius: 2px; box-shadow: 0 0 0 2px var(--panel); }
.range-ends { display: flex; justify-content: space-between; margin-top: 6px; font: 11px var(--mono); color: var(--dim); }

/* ----------------------------------- news ----------------------------------- */

.news-item { display: block; padding: 11px 14px; border-bottom: 1px solid var(--border); transition: background .1s; }
.news-item:last-child { border-bottom: none; }
.news-item:hover { background: var(--panel-2); }
.news-title { font-size: 13.5px; line-height: 1.4; font-weight: 500; }
.news-meta { margin-top: 4px; font-size: 11.5px; color: var(--dim); display: flex; gap: 9px; flex-wrap: wrap; }
.news-meta .pub { color: var(--muted); }

/* -------------------------------- command palette -------------------------------- */

.overlay {
  position: fixed; inset: 0; z-index: 100; background: #04060a99;
  backdrop-filter: blur(3px); display: flex; align-items: flex-start; justify-content: center; padding-top: 12vh;
}
.palette {
  width: min(620px, 92vw); background: var(--panel-2); border: 1px solid var(--border-2);
  border-radius: 12px; box-shadow: 0 28px 70px #000000aa; overflow: hidden;
}
.palette input {
  width: 100%; padding: 15px 18px; background: transparent; border: none;
  border-bottom: 1px solid var(--border); outline: none; font-size: 16px; font-family: var(--mono);
}
.palette input::placeholder { color: var(--dim); font-family: var(--sans); }
.palette .results { max-height: 46vh; overflow-y: auto; }
.palette .suggest-item { border-bottom: 1px solid var(--border); }

/* ----------------------------------- toasts ----------------------------------- */

#toasts { position: fixed; right: 16px; bottom: 16px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--panel-3); border: 1px solid var(--border-2); border-left: 3px solid var(--accent);
  border-radius: 6px; padding: 10px 14px; font-size: 13px; box-shadow: 0 10px 30px #00000077;
  animation: slideIn .2s ease-out; max-width: 330px;
}
.toast.ok { border-left-color: var(--up); }
.toast.err { border-left-color: var(--down); }
.toast.alert { border-left-color: var(--warn); }
.toast.out { opacity: 0; transform: translateX(10px); transition: .3s; }
@keyframes slideIn { from { opacity: 0; transform: translateX(14px); } to { opacity: 1; transform: none; } }

.skeleton { background: linear-gradient(90deg, var(--panel-2) 25%, var(--panel-3) 50%, var(--panel-2) 75%); background-size: 200% 100%; animation: sh 1.3s infinite; border-radius: 4px; }
@keyframes sh { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ---------------------------------- responsive ---------------------------------- */

.cols-2 { grid-template-columns: 1fr 1fr; }
.cols-3 { grid-template-columns: repeat(3, 1fr); }
.cols-main { grid-template-columns: minmax(0, 2.1fr) minmax(0, 1fr); }
@media (max-width: 1100px) {
  .cols-2, .cols-3, .cols-main { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  header.top { gap: 10px; padding: 0 12px; }
  .brand span:not(.mark) { display: none; }
  nav.tabs a { padding: 6px 9px; font-size: 13px; }
  .kbd-hint span { display: none; }
  main { padding: 12px; }
  .hide-sm { display: none !important; }
  .sym-price { margin-left: 0; text-align: left; }
  table.data th { top: 0; }
}
