/* ============ Liquidity Desk — design tokens ============ */
:root {
  --bg: #0c1219;
  --panel: #121b26;
  --panel2: #172331;
  --line: #1f2f42;
  --line2: #2b4059;
  --text: #dde5ef;
  --muted: #8497ad;
  --faint: #5d7089;
  --up: #3fc1a0;
  --down: #e8687e;
  --ai: #9eabff;
  --gold: #f3b84a;
  --blue: #5aa9ff;
  --violet: #c58cff;
  --r: 10px;
  --rs: 6px;
  --font: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 400 14px/1.5 var(--font); font-variant-numeric: tabular-nums; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--ai); outline-offset: 2px; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--line2); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ============ Site header ============ */
.site-header { height: 52px; display: flex; align-items: center; gap: 18px; padding: 0 16px; border-bottom: 1px solid var(--line); background: var(--bg); position: relative; z-index: 20; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 16px; letter-spacing: .01em; }
.brand svg { width: 26px; height: 26px; }
.site-header .grow { flex: 1; }
.nav { display: flex; gap: 4px; }
.nav a { padding: 7px 14px; border-radius: var(--rs); color: var(--muted); font-weight: 500; transition: background .15s, color .15s; }
.nav a:hover { color: var(--text); background: var(--panel); }
.nav a[aria-current="page"] { color: var(--text); background: var(--panel2); box-shadow: inset 0 -2px 0 var(--gold); }
.status-pill { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); display: inline-block; }
.dot.live { background: var(--up); box-shadow: 0 0 0 0 rgba(63,193,160,.6); animation: pulse 2s infinite; }
.dot.bad { background: var(--down); }
@keyframes pulse { 70% { box-shadow: 0 0 0 7px rgba(63,193,160,0); } 100% { box-shadow: 0 0 0 0 rgba(63,193,160,0); } }

/* ============ Primitives ============ */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 34px; padding: 0 14px; border-radius: var(--rs); border: 1px solid var(--line2); background: var(--panel2); cursor: pointer; font-weight: 500; transition: background .15s, border-color .15s, transform .05s; white-space: nowrap; }
.btn:hover { background: #1d2c3e; border-color: #38506d; }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .55; cursor: progress; }
.btn.primary { background: var(--gold); border-color: var(--gold); color: #1b1300; font-weight: 600; }
.btn.primary:hover { background: #ffc85f; }
.btn.ghost { background: transparent; }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn svg { width: 16px; height: 16px; }
.seg { display: inline-flex; background: var(--bg); border: 1px solid var(--line); border-radius: var(--rs); padding: 2px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 5px 11px; border-radius: 4px; color: var(--muted); cursor: pointer; font-weight: 500; }
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"], .seg button.on { background: var(--panel2); color: var(--text); box-shadow: inset 0 -2px 0 var(--gold); }
.select, .input { height: 34px; background: var(--bg); border: 1px solid var(--line2); border-radius: var(--rs); padding: 0 10px; color: var(--text); }
.select { cursor: pointer; }
.input::placeholder { color: var(--faint); }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; border-radius: 99px; font-size: 11.5px; font-weight: 500; border: 1px solid var(--line2); color: var(--muted); background: transparent; line-height: 18px; }
.chip.up { color: var(--up); border-color: rgba(63,193,160,.4); background: rgba(63,193,160,.08); }
.chip.down { color: var(--down); border-color: rgba(232,104,126,.4); background: rgba(232,104,126,.08); }
.chip.gold { color: var(--gold); border-color: rgba(243,184,74,.4); background: rgba(243,184,74,.08); }
.chip.ai { color: var(--ai); border-color: rgba(158,171,255,.4); background: rgba(158,171,255,.08); }
.chip.warn { color: #ffb38a; border-color: rgba(255,179,138,.4); background: rgba(255,179,138,.08); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); }
.card > h2, .card-h { margin: 0; padding: 11px 14px; font-size: 13px; font-weight: 600; color: var(--muted); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.muted { color: var(--muted); }
.up { color: var(--up); } .down { color: var(--down); } .gold { color: var(--gold); }
.banner { display: flex; gap: 10px; align-items: flex-start; padding: 10px 14px; border-radius: var(--rs); border: 1px solid var(--line2); background: var(--panel); font-size: 13px; }
.banner.warn { border-color: rgba(243,184,74,.45); background: rgba(243,184,74,.07); }
.banner.bad { border-color: rgba(232,104,126,.5); background: rgba(232,104,126,.08); }
.empty { padding: 28px 18px; text-align: center; color: var(--muted); }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--panel2); border: 1px solid var(--line2); padding: 9px 16px; border-radius: var(--rs); z-index: 99; font-size: 13px; }

/* ============ Terminal (main page) ============ */
.terminal { display: grid; grid-template-columns: minmax(0, 1fr) 348px; gap: 10px; padding: 10px; height: calc(100vh - 52px); min-height: 560px; }
.chart-card { display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden; }
.toolbar { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.toolbar .grow { flex: 1; }
.toolbar .sym { font-weight: 600; min-width: 104px; }
.stage { position: relative; flex: 1; min-height: 0; background: var(--bg); }
#chart, #tvBox { position: absolute; inset: 0; }
#tvBox { display: none; }
.tv-mode #chart, .tv-mode #overlay, .tv-mode .ohlc, .tv-mode .legend { display: none; }
.tv-mode #tvBox { display: block; }
#overlay { position: absolute; left: 0; top: 0; pointer-events: none; z-index: 3; }
.ohlc { position: absolute; left: 12px; top: 8px; z-index: 5; font-size: 12px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 12px; pointer-events: none; text-shadow: 0 1px 2px #000; }
.ohlc b { color: var(--text); font-weight: 600; }
.badges { position: absolute; left: 12px; top: 32px; z-index: 6; display: flex; gap: 6px; flex-wrap: wrap; max-width: calc(100% - 90px); pointer-events: none; }
.tv-mode .badges { display: none; }
.tv-note { position: absolute; left: 50%; top: 10px; transform: translateX(-50%); z-index: 6; display: none; }
.tv-mode .tv-note { display: inline-flex; }
.chart-card:fullscreen { border-radius: 0; border: 0; background: var(--bg); }

/* ============ AI console (bottom-left of chart) ============ */
.console { position: absolute; left: 12px; bottom: 34px; z-index: 8; width: min(430px, calc(100% - 24px)); max-height: min(60%, 460px); display: flex; flex-direction: column; background: rgba(14,22,32,.95); border: 1px solid var(--line2); border-radius: 12px; backdrop-filter: blur(10px); overflow: hidden; }
.tv-mode .console { bottom: 58px; }
.console.tall { max-height: 84%; width: min(560px, calc(100% - 24px)); }
.c-head { display: flex; align-items: center; gap: 9px; padding: 9px 12px; border-bottom: 1px solid var(--line); cursor: default; }
.c-head .title { font-weight: 600; font-size: 13px; flex: 1; display: flex; align-items: center; gap: 8px; }
.c-head .title svg { width: 16px; height: 16px; color: var(--ai); }
.icon-btn { width: 26px; height: 26px; display: grid; place-items: center; border: 0; background: transparent; color: var(--muted); border-radius: 5px; cursor: pointer; }
.icon-btn:hover { background: var(--panel2); color: var(--text); }
.icon-btn svg { width: 15px; height: 15px; }
.c-body { flex: 1; min-height: 60px; overflow-y: auto; padding: 10px 12px; display: flex; flex-direction: column; gap: 9px; scroll-behavior: smooth; }
.console.min .c-body, .console.min .c-foot { display: none; }
.c-foot { border-top: 1px solid var(--line); padding: 8px 10px 10px; display: grid; gap: 8px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips button { border: 1px solid var(--line2); background: transparent; color: var(--muted); border-radius: 99px; padding: 2px 10px; font-size: 12px; cursor: pointer; }
.chips button:hover { color: var(--text); border-color: var(--ai); }
.prompt { display: flex; gap: 8px; }
.prompt .input { flex: 1; min-width: 0; }
.msg { font-size: 13px; line-height: 1.5; }
.msg.you { align-self: flex-end; background: var(--panel2); border: 1px solid var(--line2); padding: 6px 11px; border-radius: 10px 10px 2px 10px; max-width: 88%; }
.msg.ai { color: var(--text); white-space: pre-wrap; }
.msg.sys { color: var(--muted); font-size: 12.5px; }
.think { display: inline-flex; gap: 4px; align-items: center; color: var(--muted); font-size: 12.5px; }
.think i { width: 5px; height: 5px; border-radius: 50%; background: var(--ai); animation: blink 1.1s infinite; }
.think i:nth-child(2) { animation-delay: .18s; } .think i:nth-child(3) { animation-delay: .36s; }
@keyframes blink { 0%, 80%, 100% { opacity: .2; } 40% { opacity: 1; } }
.step { border-left: 3px solid var(--line2); padding: 1px 0 1px 10px; opacity: 0; transform: translateY(4px); transition: opacity .35s, transform .35s; }
.step.in { opacity: 1; transform: none; }
.step.ltf { border-color: var(--blue); } .step.htf { border-color: var(--violet); } .step.synthesis { border-color: var(--gold); }
.step h4 { margin: 0 0 3px; font-size: 12.5px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.step p { margin: 0 0 3px; font-size: 12.5px; color: #c3cfde; }
.phase { font-size: 11.5px; color: var(--faint); font-weight: 500; }
.trade-box { border: 1px solid var(--line2); border-radius: 10px; background: var(--bg); padding: 10px 12px; opacity: 0; transition: opacity .4s; }
.trade-box.in { opacity: 1; }
.trade-box h3 { margin: 0 0 6px; font-size: 14px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.trade-box .lv { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 8px 0; }
.trade-box .lv div { background: var(--panel); border-radius: 6px; padding: 5px 8px; }
.trade-box .lv small { display: block; color: var(--muted); font-size: 11px; }
.trade-box .lv b { font-size: 13px; }
.trade-box ol { margin: 8px 0 0; padding-left: 18px; display: grid; gap: 6px; font-size: 12.5px; color: #c3cfde; }
.trade-box ol b { color: var(--text); }
.trade-box .why { margin: 10px 0 2px; font-size: 12px; color: var(--muted); font-weight: 600; }

/* ============ Sidebar ============ */
.side { display: flex; flex-direction: column; gap: 10px; min-height: 0; overflow-y: auto; padding-right: 2px; }
.plan { padding: 14px; }
.plan .top { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.dir { font-weight: 700; font-size: 15px; padding: 4px 12px; border-radius: 6px; }
.dir.long { background: rgba(63,193,160,.14); color: var(--up); } .dir.short { background: rgba(232,104,126,.14); color: var(--down); } .dir.none { background: var(--panel2); color: var(--muted); }
.plan .headline { font-size: 13px; color: var(--muted); margin: 0 0 10px; }
.lvls { display: grid; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.lvls > div { display: grid; grid-template-columns: 78px 1fr auto; gap: 8px; padding: 7px 10px; background: var(--panel); align-items: center; }
.lvls .k { color: var(--muted); font-size: 12px; }
.lvls .v { font-weight: 600; }
.lvls .r { font-size: 11.5px; color: var(--muted); }
.lvls .entry .v { color: var(--gold); } .lvls .sl .v { color: var(--down); } .lvls .tp .v { color: var(--up); }
.meter { height: 6px; background: var(--bg); border-radius: 4px; overflow: hidden; margin: 6px 0 2px; }
.meter i { display: block; height: 100%; background: linear-gradient(90deg, var(--blue), var(--up)); border-radius: 4px; transition: width .6s; }
.plan .row { display: flex; justify-content: space-between; align-items: center; font-size: 12.5px; margin-top: 10px; }
.checks { margin: 10px 0 0; padding: 0; list-style: none; display: grid; gap: 3px; font-size: 12px; }
.checks li { display: flex; gap: 8px; color: var(--faint); } .checks li.ok { color: #b9c7d8; }
.checks li::before { content: "○"; } .checks li.ok::before { content: "●"; color: var(--up); }
details.fold summary { cursor: pointer; color: var(--muted); font-size: 12.5px; margin-top: 10px; }
.mtf { padding: 4px 6px 8px; }
.mtf .r { display: grid; grid-template-columns: 34px 1fr 76px 50px; white-space: nowrap; gap: 8px; align-items: center; padding: 6px 8px; border-radius: 6px; font-size: 12.5px; }
.mtf .r:nth-child(odd) { background: rgba(255,255,255,.02); }
.mtf .tf { font-weight: 600; }
.mom { height: 5px; background: var(--bg); border-radius: 3px; position: relative; }
.mom i { position: absolute; top: 0; bottom: 0; border-radius: 3px; }
.layers { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 12px 12px; }
.layers label { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border: 1px solid var(--line2); border-radius: 99px; font-size: 12px; cursor: pointer; color: var(--muted); user-select: none; }
.layers input { position: absolute; opacity: 0; pointer-events: none; }
.layers label:has(input:checked) { color: var(--text); border-color: var(--ai); background: rgba(158,171,255,.09); }
.layers label:has(input:focus-visible) { outline: 2px solid var(--ai); }
.feed { list-style: none; margin: 0; padding: 4px 8px 8px; max-height: 260px; overflow-y: auto; display: grid; gap: 1px; }
.feed li { display: grid; grid-template-columns: 44px 38px 1fr; gap: 8px; padding: 6px 6px; font-size: 12.5px; border-radius: 6px; align-items: start; }
.feed li:nth-child(odd) { background: rgba(255,255,255,.02); }
.feed li.fresh { animation: fresh 2.4s ease-out; }
@keyframes fresh { from { background: rgba(158,171,255,.22); } }
.feed time { color: var(--faint); font-size: 11.5px; }

/* ============ Shared page layout ============ */
.page { max-width: 1240px; margin: 0 auto; padding: 22px 18px 60px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head h1 { margin: 0; font-size: 24px; font-weight: 600; letter-spacing: -.01em; }
.page-head p { margin: 4px 0 0; color: var(--muted); max-width: 640px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }

/* ============ Forex Data ============ */
.next-up { display: flex; align-items: center; gap: 14px; padding: 12px 16px; margin-bottom: 12px; flex-wrap: wrap; }
.next-up .cd { font-size: 26px; font-weight: 600; color: var(--gold); min-width: 118px; }
.cal-wrap { overflow-x: auto; }
table.cal { width: 100%; border-collapse: collapse; min-width: 820px; }
.cal th { position: sticky; top: 0; background: var(--panel); text-align: left; font-weight: 500; font-size: 12px; color: var(--muted); padding: 9px 12px; border-bottom: 1px solid var(--line); z-index: 2; }
.cal td { padding: 9px 12px; border-bottom: 1px solid rgba(31,47,66,.6); vertical-align: middle; }
.cal td.num, .cal th.num { text-align: right; }
.cal tr.day td { background: var(--panel2); font-weight: 600; font-size: 12.5px; color: var(--text); padding: 7px 12px; }
.cal tr.past { color: var(--muted); }
.cal tr.next td { box-shadow: inset 0 1px 0 var(--gold), inset 0 -1px 0 var(--gold); background: rgba(243,184,74,.05); }
.cal tr:hover td:not(.day) { background: rgba(255,255,255,.025); }
.imp { display: inline-flex; gap: 2px; align-items: flex-end; height: 14px; }
.imp i { width: 4px; background: var(--line2); border-radius: 1px; } .imp i:nth-child(1) { height: 6px; } .imp i:nth-child(2) { height: 10px; } .imp i:nth-child(3) { height: 14px; }
.imp.high i { background: var(--down); } .imp.medium i:nth-child(-n+2) { background: var(--gold); } .imp.low i:nth-child(1) { background: #7f93ab; }
.ccy { font-weight: 600; padding: 1px 7px; border-radius: 4px; background: var(--panel2); border: 1px solid var(--line2); font-size: 12px; }
.act { font-weight: 600; min-width: 74px; }
.act.pending { color: var(--faint); font-weight: 400; }
.act.bullish { color: var(--up); } .act.bearish { color: var(--down); }
.flash { animation: flashRow 3.2s ease-out; }
@keyframes flashRow { 0% { background: rgba(243,184,74,.35); } 100% { background: transparent; } }
.note { font-size: 12px; color: var(--faint); margin-top: 10px; }

/* ============ News ============ */
.news-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 12px; }
.news-item { padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; transition: border-color .15s; }
.news-item:hover { border-color: var(--line2); }
.news-item h3 { margin: 0; font-size: 15px; font-weight: 600; line-height: 1.4; }
.news-item h3 a:hover { color: var(--ai); text-decoration: underline; text-underline-offset: 3px; }
.news-item p { margin: 0; color: var(--muted); font-size: 13px; }
.news-item .meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 12px; color: var(--faint); margin-top: auto; }
.news-item.high { border-left: 3px solid var(--down); }
.news-item.medium { border-left: 3px solid var(--gold); }
.news-item.low { border-left: 3px solid #7f93ab; }
.news-item h3 { display: flex; align-items: center; gap: 7px; }
.impact-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; flex: none; }
.impact-dot.red { background: var(--down); box-shadow: 0 0 6px rgba(232,104,126,.6); }
.impact-dot.yellow { background: var(--gold); box-shadow: 0 0 6px rgba(243,184,74,.55); }
.impact-dot.white { background: #c7d2de; }
.news-thumb { margin: -14px -16px 0; height: 140px; overflow: hidden; border-radius: var(--r) var(--r) 0 0; background: var(--bg); }
.news-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ============ History ============ */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
.stat { padding: 12px 14px; } .stat small { color: var(--muted); display: block; } .stat b { font-size: 22px; font-weight: 600; }
table.hist { width: 100%; border-collapse: collapse; min-width: 860px; }
.hist th { text-align: left; font-weight: 500; font-size: 12px; color: var(--muted); padding: 9px 12px; border-bottom: 1px solid var(--line); }
.hist td { padding: 10px 12px; border-bottom: 1px solid rgba(31,47,66,.6); vertical-align: top; }
.hist tr.row { cursor: pointer; } .hist tr.row:hover td { background: rgba(255,255,255,.025); }
.hist tr.detail td { background: var(--bg); padding: 14px 18px 18px; }
.hist ol { margin: 6px 0 0; padding-left: 18px; display: grid; gap: 6px; color: #c3cfde; font-size: 13px; }

/* ============ Responsive ============ */
@media (max-width: 1100px) {
  .terminal { grid-template-columns: 1fr; height: auto; }
  .chart-card { height: 74vh; min-height: 520px; }
  .side { overflow: visible; }
}
@media (max-width: 640px) {
  .site-header { padding: 0 10px; gap: 8px; }
  .brand span { display: none; }
  .nav a { padding: 7px 9px; }
  .toolbar .sym { min-width: 96px; }
  #fsTxt { display: none; }
  .chart-card { height: 84vh; }
  .ohlc { font-size: 11px; gap: 2px 8px; }
  .console { width: calc(100% - 16px); left: 8px; }
  .trade-box .lv { grid-template-columns: repeat(2, 1fr); }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
