/* HumanX Lab — Command Center design system */
:root {
  --bg-0: #040a16;
  --bg-1: #07122a;
  --panel: rgba(12, 24, 48, 0.74);
  --panel-solid: #0b1830;
  --panel-2: rgba(18, 34, 66, 0.62);
  --line: rgba(110, 150, 255, 0.14);
  --line-2: rgba(110, 150, 255, 0.26);
  --text: #e8f0ff;
  --text-2: #a5b7d6;
  --muted: #6c819f;
  --cyan: #22d3ee;
  --blue: #4f8cff;
  --violet: #8b6cff;
  --green: #22e3a0;
  --red: #ff5c7a;
  --amber: #ffb84d;
  --green-bg: rgba(34, 227, 160, 0.13);
  --red-bg: rgba(255, 92, 122, 0.13);
  --amber-bg: rgba(255, 184, 77, 0.14);
  --blue-bg: rgba(79, 140, 255, 0.15);
  --radius: 14px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; font-family: var(--font); color: var(--text); font-size: 13px; line-height: 1.45;
  background:
    radial-gradient(1200px 600px at 12% -10%, rgba(79, 140, 255, 0.16), transparent 60%),
    radial-gradient(900px 520px at 100% 0%, rgba(139, 108, 255, 0.13), transparent 55%),
    radial-gradient(800px 500px at 50% 110%, rgba(34, 211, 238, 0.07), transparent 60%),
    linear-gradient(180deg, var(--bg-1), var(--bg-0));
  background-attachment: fixed; min-height: 100vh;
}
a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; }
.mono, .num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.up { color: var(--green); } .down { color: var(--red); } .warn { color: var(--amber); } .dim { color: var(--muted); }

/* ---------- layout ---------- */
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 18px 12px 14px;
  background: linear-gradient(180deg, rgba(6, 16, 36, 0.92), rgba(4, 10, 22, 0.96)); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 4px; z-index: 30;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; }
.brand img { width: 38px; height: 38px; object-fit: contain; }
.brand h1 { margin: 0; font-size: 15px; letter-spacing: 0.12em; font-weight: 800; }
.brand span { display: block; font-size: 10px; color: var(--muted); margin-top: 2px; }
.nav-group { margin-top: 10px; }
.nav-group > .label { padding: 6px 10px; font-size: 9.5px; letter-spacing: 0.16em; font-weight: 700; color: var(--muted); text-transform: uppercase; }
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: 9px; color: var(--text-2);
  font-size: 12.5px; font-weight: 500; background: none; border: 1px solid transparent; cursor: pointer; text-align: left;
}
.nav-item i, .nav-item svg { width: 16px; height: 16px; flex: none; opacity: 0.85; }
.nav-item:hover { background: rgba(79, 140, 255, 0.09); color: var(--text); text-decoration: none; }
.nav-item.active { background: linear-gradient(90deg, rgba(79, 140, 255, 0.22), rgba(79, 140, 255, 0.06)); border-color: var(--line-2); color: #fff; }
.nav-item .badge { margin-left: auto; background: var(--red); color: #fff; border-radius: 10px; font-size: 10px; padding: 1px 6px; font-weight: 700; }
.side-foot { margin-top: auto; padding: 12px 8px 0; font-size: 10.5px; color: var(--muted); border-top: 1px solid var(--line); }
.side-foot b { color: var(--text-2); }

.main { padding: 14px 18px 40px; min-width: 0; }
.topbar { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.menu-btn { display: none; }
.seg { display: inline-flex; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 3px; gap: 2px; }
.seg button { background: none; border: 0; color: var(--text-2); padding: 7px 14px; border-radius: 9px; font-size: 12.5px; font-weight: 600; cursor: pointer; display: inline-flex; gap: 7px; align-items: center; }
.seg button:hover { color: var(--text); }
.seg button.active { background: linear-gradient(180deg, rgba(79, 140, 255, 0.35), rgba(79, 140, 255, 0.18)); color: #fff; box-shadow: inset 0 0 0 1px var(--line-2); }
.search { flex: 1; min-width: 220px; max-width: 560px; margin-left: auto; position: relative; }
.search input {
  width: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; color: var(--text); padding: 10px 14px 10px 38px; font-size: 13px; outline: none;
}
.search input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(79, 140, 255, 0.18); }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--muted); }
.search kbd { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font-family: var(--mono); font-size: 10px; color: var(--muted); border: 1px solid var(--line-2); border-radius: 5px; padding: 1px 5px; }
.icon-btn { position: relative; width: 38px; height: 38px; border-radius: 11px; background: var(--panel); border: 1px solid var(--line); color: var(--text-2); display: grid; place-items: center; cursor: pointer; }
.icon-btn:hover { color: #fff; border-color: var(--line-2); }
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn .dot { position: absolute; top: -4px; right: -4px; min-width: 17px; height: 17px; border-radius: 9px; background: var(--red); color: #fff; font-size: 10px; font-weight: 700; display: grid; place-items: center; padding: 0 4px; }
.live { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 12px; background: var(--green-bg); border: 1px solid rgba(34, 227, 160, 0.35); font-size: 12px; font-weight: 700; color: var(--green); }
.live small { display: block; font-weight: 500; color: var(--text-2); font-size: 10px; }
.live .pulse-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 0 rgba(34, 227, 160, 0.7); animation: ping 1.8s infinite; }
.live.off { background: var(--red-bg); border-color: rgba(255, 92, 122, 0.4); color: var(--red); } .live.off .pulse-dot { background: var(--red); animation: none; }
@keyframes ping { 70% { box-shadow: 0 0 0 7px rgba(34, 227, 160, 0); } 100% { box-shadow: 0 0 0 0 rgba(34, 227, 160, 0); } }
.health { display: flex; flex-direction: column; align-items: flex-end; font-size: 10px; color: var(--muted); }
.health b { font-size: 13px; color: var(--green); }

.ribbon { display: none; margin: 0 0 12px; padding: 9px 14px; border-radius: 12px; border: 1px solid rgba(255, 184, 77, 0.4); background: var(--amber-bg); font-size: 12.5px; }

/* ---------- grid ---------- */
.grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 14px; align-items: start; }
.col { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.row { display: grid; gap: 14px; }
.r-4 { grid-template-columns: 1.15fr 1fr 1.25fr 1fr; }
.r-chart { grid-template-columns: minmax(0, 1.75fr) minmax(0, 1fr); }
.r-bottom { grid-template-columns: 1.1fr 1.2fr 1fr 1fr; }
.cards-row { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; }

.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; backdrop-filter: blur(8px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.03); min-width: 0; position: relative;
}
.card h3 { margin: 0 0 10px; font-size: 11.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text); font-weight: 700; display: flex; align-items: center; gap: 8px; }
.card h3 .sub { margin-left: auto; font-size: 10px; letter-spacing: 0; text-transform: none; color: var(--muted); font-weight: 500; }
.card h3 svg { width: 14px; height: 14px; color: var(--cyan); }
.card .foot { margin-top: 8px; font-size: 10px; color: var(--muted); }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px; border-radius: 8px; font-size: 11px; font-weight: 600; border: 1px solid var(--line); background: var(--panel-2); color: var(--text-2); white-space: nowrap; }
.chip.g { color: var(--green); background: var(--green-bg); border-color: rgba(34, 227, 160, 0.3); }
.chip.r { color: var(--red); background: var(--red-bg); border-color: rgba(255, 92, 122, 0.3); }
.chip.a { color: var(--amber); background: var(--amber-bg); border-color: rgba(255, 184, 77, 0.3); }
.chip.b { color: var(--blue); background: var(--blue-bg); border-color: rgba(79, 140, 255, 0.35); }
.empty { padding: 18px 8px; text-align: center; color: var(--muted); font-size: 12px; }
.skeleton { position: relative; overflow: hidden; background: rgba(120, 150, 220, 0.08); border-radius: 8px; min-height: 14px; }
.skeleton::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(160, 190, 255, 0.12), transparent); animation: shimmer 1.4s infinite; }
@keyframes shimmer { 100% { transform: translateX(100%); } }

/* ---------- pulse bar ---------- */
.pulse { display: flex; align-items: center; gap: 10px; padding: 10px 14px; flex-wrap: wrap; }
.pulse .title { display: flex; align-items: center; gap: 8px; font-weight: 800; letter-spacing: 0.08em; font-size: 12.5px; padding-right: 6px; }
.pulse .title svg { color: var(--cyan); width: 18px; height: 18px; }
.pulse .metric { font-size: 11.5px; color: var(--text-2); display: inline-flex; gap: 6px; align-items: baseline; }
.pulse .metric b { color: var(--text); font-weight: 700; }
.pulse .conf { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: 10.5px; color: var(--muted); }
.pulse .conf b { display: block; color: var(--text); font-size: 12.5px; }
.ring { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-size: 10.5px; font-weight: 800; background: conic-gradient(var(--cyan) var(--p, 50%), rgba(120, 150, 220, 0.2) 0); position: relative; }
.ring::before { content: ""; position: absolute; inset: 4px; background: var(--panel-solid); border-radius: 50%; }
.ring span { position: relative; }

/* ---------- asset cards ---------- */
.asset { padding: 12px; cursor: pointer; transition: transform 0.15s, border-color 0.15s; }
.asset:hover { transform: translateY(-2px); border-color: var(--line-2); }
.asset.sel { border-color: var(--blue); box-shadow: 0 0 0 1px var(--blue), 0 10px 30px rgba(79, 140, 255, 0.18); }
.asset .top { display: flex; align-items: center; gap: 8px; }
.asset .coin { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 11px; color: #fff; flex: none; background-size: cover; }
.asset .tkr { font-weight: 700; font-size: 13px; }
.asset .chg { margin-left: auto; font-weight: 700; font-size: 12px; }
.asset .price { font-size: 20px; font-weight: 700; margin: 8px 0 2px; letter-spacing: -0.01em; }
.asset svg.spark { width: 100%; height: 40px; display: block; margin: 2px 0; }
.asset .meta { display: flex; justify-content: space-between; font-size: 10px; color: var(--muted); }
.asset .tags { margin-top: 7px; display: flex; gap: 5px; flex-wrap: wrap; }

/* ---------- tables ---------- */
table.t { width: 100%; border-collapse: collapse; font-size: 12px; }
table.t th { text-align: left; font-size: 9.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); font-weight: 600; padding: 5px 6px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.t td { padding: 7px 6px; border-bottom: 1px solid rgba(110, 150, 255, 0.07); vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; }
table.t tr.click { cursor: pointer; } table.t tr.click:hover td { background: rgba(79, 140, 255, 0.07); }
.bar { height: 6px; border-radius: 4px; background: rgba(120, 150, 220, 0.16); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 4px; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 5px 10px; font-size: 12px; }
.kv .k { color: var(--text-2); } .kv .v { font-weight: 700; text-align: right; }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.stat { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.stat .k { font-size: 9.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.stat .v { font-size: 14px; font-weight: 700; margin-top: 2px; }

/* ---------- charts ---------- */
.chart-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.chart-head .sym { font-weight: 800; font-size: 14px; letter-spacing: 0.04em; }
.tf { display: inline-flex; gap: 2px; background: var(--panel-2); border-radius: 9px; padding: 2px; border: 1px solid var(--line); }
.tf button { background: none; border: 0; color: var(--text-2); padding: 4px 9px; border-radius: 7px; font-size: 11px; cursor: pointer; font-weight: 600; }
.tf button.active { background: var(--blue-bg); color: #fff; box-shadow: inset 0 0 0 1px rgba(79, 140, 255, 0.45); }
.tog { display: inline-flex; gap: 6px; margin-left: auto; font-size: 11px; color: var(--text-2); }
.tog label { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; padding: 3px 7px; border-radius: 7px; border: 1px solid var(--line); background: var(--panel-2); }
.tog input { accent-color: var(--blue); }
#priceChart { height: 330px; } #cvdChart { height: 92px; margin-top: 4px; } #oiChart { height: 70px; margin-top: 4px; }
.legend-line { display: flex; gap: 12px; font-size: 10.5px; color: var(--text-2); margin-bottom: 4px; flex-wrap: wrap; }
.legend-line i { display: inline-block; width: 9px; height: 3px; border-radius: 2px; margin-right: 4px; vertical-align: middle; }
canvas.heat { width: 100%; height: 190px; border-radius: 9px; background: rgba(4, 10, 22, 0.6); display: block; }

/* ---------- corr / gauge ---------- */
.corr { display: grid; gap: 2px; font-size: 10px; }
.corr .c { padding: 5px 0; text-align: center; border-radius: 4px; font-family: var(--mono); font-size: 10px; }
.corr .h { color: var(--text-2); font-weight: 700; font-size: 9.5px; display: flex; align-items: center; justify-content: center; }
.gauge { position: relative; width: 100%; max-width: 170px; margin: 0 auto; }
.gauge .val { position: absolute; left: 0; right: 0; bottom: 4px; text-align: center; font-size: 22px; font-weight: 800; }
.gauge .lab { display: block; font-size: 10px; font-weight: 600; color: var(--text-2); }

/* ---------- right rail lists ---------- */
.feed { display: flex; flex-direction: column; gap: 2px; max-height: 280px; overflow-y: auto; margin: 0 -4px; padding: 0 4px; }
.feed-item { display: flex; gap: 9px; padding: 8px 4px; border-bottom: 1px solid rgba(110, 150, 255, 0.07); align-items: flex-start; }
.feed-item:last-child { border-bottom: 0; }
.feed-item .ico { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; flex: none; background: var(--blue-bg); color: var(--blue); }
.feed-item .ico svg { width: 14px; height: 14px; }
.feed-item .ico.r { background: var(--red-bg); color: var(--red); } .feed-item .ico.a { background: var(--amber-bg); color: var(--amber); } .feed-item .ico.g { background: var(--green-bg); color: var(--green); }
.feed-item .body { min-width: 0; flex: 1; }
.feed-item .t { font-size: 12px; font-weight: 600; color: var(--text); line-height: 1.35; }
.feed-item .d { font-size: 10.5px; color: var(--muted); margin-top: 1px; }
.feed-item .when { font-size: 10px; color: var(--muted); flex: none; white-space: nowrap; font-family: var(--mono); }
.new-pill { background: var(--red); color: #fff; border-radius: 9px; font-size: 10px; padding: 1px 7px; font-weight: 700; }

/* ---------- agent drawer ---------- */
.fab { position: fixed; right: 20px; bottom: 20px; z-index: 60; display: flex; align-items: center; gap: 9px; padding: 12px 16px; border-radius: 16px; border: 1px solid rgba(139, 108, 255, 0.55); cursor: pointer; color: #fff; font-weight: 700; font-size: 13px;
  background: linear-gradient(135deg, rgba(79, 140, 255, 0.95), rgba(139, 108, 255, 0.95)); box-shadow: 0 14px 40px rgba(79, 140, 255, 0.4); }
.fab svg { width: 18px; height: 18px; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(440px, 100vw); z-index: 70; display: flex; flex-direction: column; transform: translateX(105%); transition: transform 0.25s ease;
  background: linear-gradient(180deg, rgba(8, 18, 40, 0.98), rgba(4, 10, 22, 0.99)); border-left: 1px solid var(--line-2); box-shadow: -20px 0 60px rgba(0, 0, 0, 0.5); }
.drawer.open { transform: none; }
.drawer header { padding: 14px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.drawer header h2 { margin: 0; font-size: 14px; letter-spacing: 0.04em; }
.drawer header .mode { margin-left: auto; }
.chat { flex: 1; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 92%; padding: 10px 12px; border-radius: 12px; font-size: 12.5px; line-height: 1.5; white-space: pre-wrap; word-wrap: break-word; }
.msg.user { align-self: flex-end; background: linear-gradient(135deg, rgba(79, 140, 255, 0.4), rgba(139, 108, 255, 0.35)); border: 1px solid var(--line-2); }
.msg.bot { align-self: flex-start; background: var(--panel-2); border: 1px solid var(--line); }
.msg .src { display: block; margin-top: 6px; font-size: 10px; color: var(--muted); }
.suggest { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 16px 8px; }
.suggest button { background: var(--panel-2); border: 1px solid var(--line-2); color: var(--text-2); border-radius: 999px; padding: 5px 11px; font-size: 11px; cursor: pointer; }
.suggest button:hover { color: #fff; border-color: var(--blue); }
.composer { display: flex; gap: 8px; padding: 12px 16px 16px; border-top: 1px solid var(--line); }
.composer input { flex: 1; background: var(--panel); border: 1px solid var(--line-2); border-radius: 11px; color: var(--text); padding: 11px 13px; font-size: 13px; outline: none; }
.composer input:focus { border-color: var(--blue); }
.composer button { border: 0; border-radius: 11px; padding: 0 16px; font-weight: 700; color: #fff; cursor: pointer; background: linear-gradient(135deg, var(--blue), var(--violet)); }
.typing span { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--text-2); margin-right: 3px; animation: blink 1.2s infinite; } .typing span:nth-child(2) { animation-delay: 0.2s; } .typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }

/* ---------- palette / dropdown / toasts ---------- */
.overlay { position: fixed; inset: 0; background: rgba(2, 6, 16, 0.6); backdrop-filter: blur(3px); z-index: 80; display: none; align-items: flex-start; justify-content: center; padding-top: 12vh; }
.overlay.open { display: flex; }
.palette { width: min(620px, 92vw); background: var(--panel-solid); border: 1px solid var(--line-2); border-radius: 16px; box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6); overflow: hidden; }
.palette input { width: 100%; background: none; border: 0; border-bottom: 1px solid var(--line); color: var(--text); padding: 16px 18px; font-size: 15px; outline: none; }
.palette .list { max-height: 360px; overflow-y: auto; }
.palette .opt { display: flex; align-items: center; gap: 10px; padding: 10px 18px; cursor: pointer; font-size: 13px; color: var(--text-2); }
.palette .opt.sel, .palette .opt:hover { background: rgba(79, 140, 255, 0.14); color: #fff; }
.palette .opt small { margin-left: auto; color: var(--muted); }
.dropdown { position: absolute; top: 46px; right: 0; width: 360px; z-index: 50; display: none; }
.dropdown.open { display: block; }
.toasts { position: fixed; top: 16px; right: 16px; z-index: 90; display: flex; flex-direction: column; gap: 10px; width: 330px; pointer-events: none; }
.toast { pointer-events: auto; background: var(--panel-solid); border: 1px solid var(--line-2); border-left: 4px solid var(--blue); border-radius: 12px; padding: 10px 12px; box-shadow: 0 14px 40px rgba(0, 0, 0, 0.5); animation: slide 0.25s ease; }
.toast.high { border-left-color: var(--red); } .toast.med { border-left-color: var(--amber); }
.toast b { display: block; font-size: 12.5px; } .toast span { font-size: 11px; color: var(--text-2); }
@keyframes slide { from { opacity: 0; transform: translateX(20px); } }

/* ---------- responsive ---------- */
@media (max-width: 1500px) { .grid { grid-template-columns: minmax(0, 1fr) 310px; } .r-4 { grid-template-columns: 1fr 1fr; } .r-bottom { grid-template-columns: 1fr 1fr; } .cards-row { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 1180px) { .grid { grid-template-columns: 1fr; } .r-chart { grid-template-columns: 1fr; } }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 250px; transform: translateX(-105%); transition: transform 0.25s; }
  .sidebar.open { transform: none; }
  .menu-btn { display: grid; }
  .r-4, .r-bottom { grid-template-columns: 1fr; }
  .cards-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .main { padding: 10px 10px 90px; }
  .health { display: none; }
}
@media (max-width: 860px) {
  body { overflow-x: hidden; }
  .topbar { gap: 8px; }
  .seg { order: 3; width: 100%; overflow-x: auto; scrollbar-width: none; }
  .seg button { padding: 7px 11px; flex: none; }
  .search { min-width: 0; flex: 1 1 130px; margin-left: 0; }
  .search kbd { display: none; }
  .live small { display: none; }
  .drawer { width: 100vw; }
  .toasts { width: calc(100vw - 24px); right: 12px; }
}
.card table.t { min-width: 0; }
.scroll-x { overflow-x: auto; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } html { scroll-behavior: auto; } }
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
