/* AK TERMINAL — dense dark design system */
:root {
  --bg: #0b0d10;
  --bg2: #10141a;
  --bg3: #151a21;
  --panel: #0e1217;
  --border: #1e2630;
  --border2: #2a3542;
  --text: #d7dde6;
  --muted: #7b8796;
  --dim: #566170;
  --amber: #ffb000;
  --amber2: #ffc94d;
  --cyan: #3ec7e8;
  --green: #22c55e;
  --red: #f04352;
  --blue: #5b8def;
  --mono: "JetBrains Mono", "Fira Code", "SF Mono", Consolas, "Liberation Mono", monospace;
  --sans: "Segoe UI", system-ui, -apple-system, sans-serif;
  --up: #22c55e;
  --down: #f04352;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body, #app { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  overflow: hidden;
}

#app { display: flex; flex-direction: column; height: 100%; }

/* Top bar */
#topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px;
  height: 40px;
  background: linear-gradient(180deg, #141a22, #0f1319);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.brand {
  font-family: var(--mono);
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--amber);
  white-space: nowrap;
  user-select: none;
}
.brand span { color: var(--muted); font-weight: 500; margin-left: 2px; }

#command-wrap { position: relative; flex: 1; display: flex; align-items: center; gap: 8px; max-width: 920px; }
.prompt { color: var(--amber); font-family: var(--mono); font-weight: 700; }
#command {
  flex: 1;
  background: #0a0c0f;
  border: 1px solid var(--border2);
  color: var(--amber2);
  font-family: var(--mono);
  font-size: 13px;
  padding: 7px 10px;
  outline: none;
  caret-color: var(--amber);
}
#command:focus { border-color: var(--amber); box-shadow: 0 0 0 1px rgba(255, 176, 0, 0.25); }
#command::placeholder { color: var(--dim); }

#suggest {
  position: absolute;
  top: calc(100% + 2px);
  left: 22px;
  right: 0;
  background: #0c1015;
  border: 1px solid var(--border2);
  max-height: 280px;
  overflow: auto;
  z-index: 50;
  box-shadow: 0 12px 32px rgba(0,0,0,0.55);
}
#suggest .item {
  display: grid;
  grid-template-columns: 72px 1fr auto;
  gap: 10px;
  padding: 6px 10px;
  cursor: pointer;
  border-bottom: 1px solid #151b22;
  font-family: var(--mono);
  font-size: 12px;
}
#suggest .item.active, #suggest .item:hover { background: #17202b; }
#suggest .code { color: var(--amber); font-weight: 600; }
#suggest .name { color: var(--text); }
#suggest .desc { color: var(--muted); font-family: var(--sans); font-size: 11px; grid-column: 2 / -1; margin-top: -2px; }
#suggest .meta { color: var(--dim); }

.status { display: flex; align-items: center; gap: 10px; margin-left: auto; font-family: var(--mono); font-size: 11px; }
#clock { color: var(--muted); }
.pill {
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border2);
  color: var(--muted);
  background: var(--bg3);
}
.pill.ok { color: var(--green); border-color: rgba(34,197,94,0.35); }
.pill.err { color: var(--red); border-color: rgba(240,67,82,0.4); }

/* Sub bar */
#subbar {
  display: flex;
  align-items: stretch;
  height: 30px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  overflow: hidden;
}
.watchbar {
  display: flex;
  align-items: center;
  gap: 0;
  overflow-x: auto;
  flex: 1;
  font-family: var(--mono);
  font-size: 11px;
  scrollbar-width: none;
}
.watchbar::-webkit-scrollbar { display: none; }
.watchbar .tick {
  display: flex;
  gap: 6px;
  padding: 0 12px;
  height: 100%;
  align-items: center;
  border-right: 1px solid var(--border);
  cursor: pointer;
  white-space: nowrap;
  color: var(--text);
}
.watchbar .tick:hover { background: #17202b; }
.watchbar .tick .sym { color: var(--cyan); font-weight: 600; }
.watchbar .tick .px { color: var(--text); }
.watchbar .tick .ch.up { color: var(--up); }
.watchbar .tick .ch.down { color: var(--down); }
.watchbar .tick.err .sym { color: var(--red); }

.sub-actions { display: flex; align-items: center; gap: 4px; padding: 0 8px; border-left: 1px solid var(--border); }
.sub-actions button {
  background: transparent;
  border: 1px solid var(--border2);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  padding: 3px 8px;
  cursor: pointer;
}
.sub-actions button:hover, .sub-actions button.active {
  color: var(--amber);
  border-color: var(--amber);
  background: rgba(255,176,0,0.06);
}

/* Workspace */
#workspace {
  flex: 1;
  min-height: 0;
  display: grid;
  gap: 1px;
  background: var(--border);
  padding: 1px;
}
.layout-1X1 { grid-template-columns: 1fr; grid-template-rows: 1fr; }
.layout-2X1 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr; }
.layout-3X1 { grid-template-columns: 1fr 1fr 1fr; grid-template-rows: 1fr; }
.layout-2X2 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
.layout-TICKER { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }

.link-badge {
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 700;
  color: #0b0d10;
  background: var(--cyan);
  border-radius: 2px;
  padding: 1px 4px;
  cursor: pointer;
  user-select: none;
  letter-spacing: 0.04em;
}
.link-badge:hover { filter: brightness(1.15); }

.chart-stack {
  position: relative;
  width: 100%;
  height: calc(100% - 56px);
  min-height: 220px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.chart-stack canvas:first-child { flex: 3; min-height: 140px; display: block; width: 100%; }
.chart-stack canvas:last-child { flex: 1; min-height: 56px; display: block; width: 100%; }

table.data.corr td { text-align: right; font-variant-numeric: tabular-nums; }
table.data.mon td:nth-child(2) { max-width: 140px; overflow: hidden; text-overflow: ellipsis; }

.panel-head .fn { color: var(--amber); font-weight: 700; }

.panel {
  background: var(--panel);
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  outline: none;
  position: relative;
}
.panel:focus { box-shadow: inset 0 0 0 1px rgba(255,176,0,0.35); }
.panel-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 8px;
  height: 28px;
  background: #121820;
  border-bottom: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 11px;
  flex-shrink: 0;
  user-select: none;
}
.panel-head .fn { color: var(--amber); font-weight: 700; }
.panel-head .ent { color: var(--cyan); cursor: pointer; }
.panel-head .ent:hover { text-decoration: underline; }
.panel-head .title { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.panel-head .spacer { flex: 1; }
.panel-head .src {
  color: var(--dim);
  font-size: 10px;
  border: 1px solid var(--border2);
  padding: 1px 6px;
  border-radius: 2px;
}
.panel-head .btn {
  background: none;
  border: none;
  color: var(--dim);
  cursor: pointer;
  font-family: var(--mono);
  font-size: 12px;
  padding: 0 4px;
}
.panel-head .btn:hover { color: var(--red); }
.panel-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 10px 12px;
  font-size: 12px;
}
.panel-body.loading { color: var(--muted); font-family: var(--mono); }
.panel-body.error { color: var(--red); font-family: var(--mono); }

/* Content typography inside panels */
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 4px 12px; font-family: var(--mono); font-size: 12px; }
.kv .k { color: var(--muted); }
.kv .v { color: var(--text); text-align: right; }
.kv .v.up { color: var(--up); }
.kv .v.down { color: var(--down); }
.kv .v.accent { color: var(--amber); }

.hero-price {
  font-family: var(--mono);
  font-size: 28px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 4px;
}
.hero-price .chg.up { color: var(--up); font-size: 16px; }
.hero-price .chg.down { color: var(--down); font-size: 16px; }
.hero-meta { color: var(--muted); font-family: var(--mono); font-size: 11px; margin-bottom: 12px; }

h3.section {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--amber);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 14px 0 6px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 3px;
}
.profile-text { color: var(--text); line-height: 1.45; font-size: 12px; }

table.data {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: 11px;
}
table.data th {
  text-align: left;
  color: var(--muted);
  font-weight: 500;
  padding: 4px 6px;
  border-bottom: 1px solid var(--border2);
  position: sticky;
  top: -10px;
  background: var(--panel);
}
table.data td {
  padding: 4px 6px;
  border-bottom: 1px solid #151b22;
  color: var(--text);
  white-space: nowrap;
}
table.data td.num, table.data th.num { text-align: right; }
table.data tr:hover td { background: #141b24; }
table.data td.up { color: var(--up); }
table.data td.down { color: var(--down); }

/* stat strip — one-line key metrics under a panel toolbar */
.stat-strip {
  font-size: 11px;
  color: var(--amber);
  background: #0d1117;
  border: 1px solid var(--border2);
  border-radius: 3px;
  padding: 5px 8px;
  margin: 6px 0;
  letter-spacing: 0.02em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.panel-body p.summary {
  color: var(--text);
  font-size: 11.5px;
  line-height: 1.5;
  margin: 8px 0;
  display: -webkit-box;
  -webkit-line-clamp: 6;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.panel-body a.link {
  color: var(--cyan);
  text-decoration: none;
  font-family: var(--mono);
  font-size: 10px;
}
.panel-body a.link:hover { text-decoration: underline; }

.map-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 220px;
  flex: 1;
}
.map-wrap canvas { cursor: crosshair; }

.map-split { display: flex; flex: 1; min-height: 0; gap: 0; }
.map-split .map-wrap { min-width: 0; }
.map-side {
  width: 208px;
  min-width: 208px;
  border-left: 1px solid var(--border2);
  margin-left: 8px;
  padding-left: 8px;
  overflow-y: auto;
  font-family: var(--mono);
  font-size: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.map-side .stat-strip { display: flex; gap: 10px; color: var(--muted); }
.map-side .stat-strip .up { color: var(--up); }
.map-side .stat-strip .down { color: var(--down); }
.map-side .map-readout { color: var(--muted); font-size: 10px; }
.map-side table.data { font-size: 10px; }
.map-side table.data th, .map-side table.data td { padding: 2px 4px; }
.map-side table.data tr.hover-row { background: #151b22; }
.map-side table.data tbody tr { cursor: pointer; }

.needs-key {
  border: 1px solid var(--amber);
  padding: 12px 14px;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.7;
  color: var(--text);
  max-width: 560px;
}
.needs-key h4 { color: var(--amber); margin: 0 0 6px; font-size: 12px; }
.needs-key code { color: var(--cyan); }
.needs-key .muted { color: var(--muted); }

.tracker-side {
  width: 260px;
  min-width: 260px;
  border-left: 1px solid var(--border2);
  margin-left: 8px;
  padding-left: 8px;
  overflow-y: auto;
  font-family: var(--mono);
  font-size: 10px;
}
.tracker-side table.data { font-size: 10px; }
.tracker-side table.data th, .tracker-side table.data td { padding: 2px 4px; white-space: nowrap; }
.tracker-side table.data tbody tr { cursor: pointer; }
.tracker-side table.data tr.hover-row { background: #151b22; }

.chart-wrap { position: relative; width: 100%; height: 100%; min-height: 160px; }

/* GLOBE — embedded God's Eye View (Cesium) */
.panel-body.globe-mode { display: flex; flex-direction: column; gap: 8px; overflow: hidden; }
.globe-stage {
  position: relative;
  flex: 1;
  min-height: 320px;
  border: 1px solid var(--border2);
  background: #000;
  overflow: hidden;
}
.globe-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}
.globe-boot {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--muted);
  background: #000;
  pointer-events: none;
  z-index: 1;
}
.globe-foot {
  display: flex;
  gap: 14px;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.08em;
  color: var(--muted);
  text-transform: uppercase;
}
.globe-foot a { color: var(--cyan); text-decoration: none; }
.globe-foot a:hover { text-decoration: underline; }
.globe-state { margin-left: auto; color: var(--green); }
.globe-state.err { color: var(--red); }

.chart-wrap canvas { width: 100%; height: 100%; display: block; }
.chart-toolbar {
  display: flex;
  gap: 4px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.chart-toolbar button {
  background: transparent;
  border: 1px solid var(--border2);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  padding: 2px 7px;
  cursor: pointer;
}
.chart-toolbar button.active, .chart-toolbar button:hover {
  color: var(--cyan);
  border-color: var(--cyan);
}

.news-item {
  padding: 8px 0;
  border-bottom: 1px solid #151b22;
}
.news-item .t { color: var(--text); font-size: 12px; line-height: 1.35; cursor: pointer; }
.news-item .t:hover { color: var(--amber); }
.news-item .m { color: var(--dim); font-family: var(--mono); font-size: 10px; margin-top: 3px; display: flex; gap: 8px; flex-wrap: wrap; }
.news-item a { color: inherit; text-decoration: none; }

.ask-answer {
  white-space: pre-wrap;
  line-height: 1.5;
  color: var(--text);
  font-size: 12.5px;
  margin-bottom: 12px;
}
.ask-sources { list-style: none; }
.ask-sources li {
  font-size: 11px;
  color: var(--muted);
  padding: 4px 0;
  border-top: 1px solid #151b22;
  font-family: var(--mono);
}
.ask-sources li .idx { color: var(--amber); margin-right: 6px; }
.ask-sources a { color: var(--cyan); text-decoration: none; }
.ask-sources a:hover { text-decoration: underline; }

.help-grid { font-family: var(--mono); font-size: 11px; }
.help-grid .row { display: grid; grid-template-columns: 100px 1fr; gap: 8px; padding: 3px 0; border-bottom: 1px solid #151b22; }
.help-grid .c { color: var(--amber); }
.help-grid .n { color: var(--text); }
.help-grid .d { color: var(--muted); grid-column: 2; font-family: var(--sans); font-size: 11px; }

.mono { font-family: var(--mono); }
.pos { color: var(--up); }
.neg { color: var(--down); }
.muted { color: var(--muted); }

/* Status bar */
#statusbar {
  height: 24px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 10px;
  background: #0a0c0f;
  border-top: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
  flex-shrink: 0;
}
#statusbar .sep { color: var(--border2); }
#statusbar .spacer { flex: 1; }
#statusbar .hint { color: var(--dim); }
#status-msg.ok { color: var(--green); }
#status-msg.err { color: var(--red); }

.bar-row { display: flex; align-items: center; gap: 8px; margin: 3px 0; font-family: var(--mono); font-size: 11px; }
.bar-row .lbl { width: 110px; color: var(--muted); }
.bar-row .track { flex: 1; height: 8px; background: #151b22; position: relative; }
.bar-row .fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--cyan); opacity: 0.75; }
.bar-row .val { width: 56px; text-align: right; color: var(--text); }

@media (max-width: 900px) {
  .layout-2X1, .layout-2X2 { grid-template-columns: 1fr; grid-template-rows: repeat(auto-fit, minmax(240px, 1fr)); }
  .brand span { display: none; }
}
