/* Dashboard shell + dense panels. Tokens shared with the site. */

.dash {
  --d-bg: #F4F7FC; --d-panel: #fff; --d-rail: #0C1A2B; --d-rail-2: #16263A;
  --d-ink: #0C1A2B; --d-ink-2: #46586E; --d-ink-3: #7B8CA3;
  --d-rule: #DCE4F0; --d-rule-soft: #EBF0F8; --d-accent: #1554F0; --d-accent-soft: #E9EFFE;
  --s1: #3B6CBF; --s2: #B47825; --s3: #0C6944; --s4: #BC6ECE; --s5: #C74C3D; --s6: #5C6B7A;
  --good: #0F7B3D; --bad: #A62B22; --warn: #A66A00;
  display: grid; grid-template-columns: 200px minmax(0, 1fr);
  border: 1px solid var(--d-rule); border-radius: 18px; overflow: hidden;
  background: var(--d-bg); box-shadow: 0 2px 4px rgba(12,26,43,.04), 0 28px 64px -24px rgba(21,84,240,.25);
  font-family: "Archivo", "Helvetica Neue", Arial, sans-serif; color: var(--d-ink);
  font-size: 13px; line-height: 1.4;
}
@media (max-width: 1000px) { .dash { grid-template-columns: 1fr; } .dash-rail { display: none; } }

/* ---- rail ---- */
.dash-rail { background: var(--d-rail); color: #fff; padding: 1.1rem .9rem; display: flex; flex-direction: column; gap: .2rem; }
.dash-rail .brand { display: flex; align-items: center; gap: .55rem; margin: 0 .3rem 1.1rem; }
.dash-rail .brand img { height: 22px; width: auto; }
.dash-rail .brand b { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; font-weight: 700; }
.dash-rail a {
  color: rgba(255,255,255,.62); text-decoration: none; padding: .48rem .65rem; border-radius: 8px;
  font-size: 12.5px; font-weight: 500; display: flex; align-items: center; gap: .55rem;
}
.dash-rail a svg { width: 15px; height: 15px; opacity: .8; }
.dash-rail a[data-on] { background: var(--d-rail-2); color: #fff; }
.dash-rail .practice { margin-top: auto; padding: .7rem .65rem 0; font-size: 11px; color: rgba(255,255,255,.5); line-height: 1.45; }
.dash-rail .practice b { color: #fff; display: block; font-size: 12px; }

/* ---- top bar ---- */
.dash-main { min-width: 0; display: flex; flex-direction: column; }
.dash-top {
  display: flex; align-items: center; gap: .6rem; flex-wrap: wrap;
  padding: .8rem 1.1rem; background: var(--d-panel); border-bottom: 1px solid var(--d-rule);
}
.dash-top h2 { margin: 0; font-size: 15px; font-weight: 700; letter-spacing: -.01em; }
.dash-top .chips { display: flex; gap: .4rem; flex-wrap: wrap; margin-left: .5rem; }
.chip {
  display: inline-flex; align-items: center; gap: .35rem; font-size: 11.5px; font-weight: 500;
  padding: .3rem .6rem; border-radius: 999px; border: 1px solid var(--d-rule); background: var(--d-bg); color: var(--d-ink-2);
}
.chip svg { width: 10px; height: 10px; opacity: .6; }
.chip.on { background: var(--d-accent-soft); border-color: #BBD0FC; color: #0B3FC4; font-weight: 600; }
.dash-top .right { margin-left: auto; display: flex; gap: .5rem; align-items: center; font-size: 11.5px; color: var(--d-ink-3); }
.dash-top .btn-x {
  font-size: 11.5px; font-weight: 600; color: #fff; background: var(--d-accent);
  border-radius: 999px; padding: .38rem .8rem;
}

/* ---- body grid ---- */
.dash-body { padding: 1rem 1.1rem 1.2rem; display: grid; gap: .8rem; grid-template-columns: repeat(12, minmax(0, 1fr)); }
.kpis { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: .6rem; }
@media (max-width: 1000px) { .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 560px)  { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.kpi { background: var(--d-panel); border: 1px solid var(--d-rule); border-radius: 10px; padding: .65rem .8rem .55rem; display: grid; gap: .1rem; min-width: 0; }
.kpi span { font-size: 10.5px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--d-ink-3); }
.kpi b { font-size: 19px; font-weight: 700; letter-spacing: -.025em; font-variant-numeric: tabular-nums; line-height: 1.15; }
.kpi i { font-style: normal; font-size: 11px; font-weight: 600; }
.kpi i.up { color: var(--good); } .kpi i.down { color: var(--bad); }
.kpi svg { width: 100%; height: 22px; margin-top: .25rem; display: block; }

.panel { background: var(--d-panel); border: 1px solid var(--d-rule); border-radius: 12px; padding: .8rem .95rem .7rem; min-width: 0; display: flex; flex-direction: column; gap: .5rem; }
.panel.w12 { grid-column: span 12; } .panel.w8 { grid-column: span 8; } .panel.w7 { grid-column: span 7; }
.panel.w6 { grid-column: span 6; } .panel.w5 { grid-column: span 5; } .panel.w4 { grid-column: span 4; }
@media (max-width: 1000px) { .panel.w8, .panel.w7, .panel.w6, .panel.w5, .panel.w4 { grid-column: span 12; } }
.panel-h { display: flex; align-items: baseline; justify-content: space-between; gap: .8rem; }
.panel-h h3 { margin: 0; font-size: 13px; font-weight: 700; letter-spacing: -.005em; }
.panel-h small { font-size: 11px; color: var(--d-ink-3); white-space: nowrap; }
.panel-f { font-size: 11.5px; color: var(--d-ink-2); margin: 0; }
.panel-f b { color: var(--d-ink); font-weight: 600; }
.panel svg { display: block; width: 100%; height: auto; overflow: visible; }
.legend { display: flex; flex-wrap: wrap; gap: .25rem .8rem; font-size: 11px; color: var(--d-ink-2); }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: .35rem; vertical-align: -1px; }

/* svg text */
.ax { font-size: 10px; fill: var(--d-ink-3); font-weight: 500; }
.ax-b { font-size: 10px; fill: var(--d-ink); font-weight: 700; font-variant-numeric: tabular-nums; }
.grid { stroke: rgba(12,26,43,.07); stroke-width: 1; }

/* table */
.tbl { width: 100%; border-collapse: collapse; font-size: 11.5px; font-variant-numeric: tabular-nums; }
.tbl th, .tbl td { text-align: right; padding: .38rem .45rem; border-bottom: 1px solid var(--d-rule-soft); white-space: nowrap; }
.tbl th:first-child, .tbl td:first-child, .tbl th:nth-child(2), .tbl td:nth-child(2) { text-align: left; }
.tbl thead th { color: var(--d-ink-3); font-weight: 600; font-size: 10.5px; letter-spacing: .05em; text-transform: uppercase; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.pill { display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; padding: .12rem .45rem; border-radius: 999px; }
.pill.warn { background: #FBF1DC; color: var(--warn); } .pill.bad { background: #FBE4E1; color: var(--bad); } .pill.ok { background: #E1F3E8; color: var(--good); }

/* chat loop sits in a panel with no padding */
.panel.chat { padding: 0; overflow: hidden; }
.panel.chat .demo { border: 0; border-radius: 12px; box-shadow: none; flex: 1; min-height: 0; height: auto; }
.panel.chat .demo-stage { min-height: 0; }

/* first row: fixed height so neither panel stretches the other */
.panel.trend, .panel.chat { height: 27rem; }
.panel.trend > svg { flex: 1; min-height: 0; height: 100%; }
@media (max-width: 1000px) { .panel.trend { height: auto; } .panel.trend > svg { height: auto; } }

/* ---- trend rows + watch list ---- */
.trl, .twl { display: flex; flex-direction: column; }
.trow { display: grid; grid-template-columns: 104px minmax(0, 1fr) auto auto; align-items: center; gap: .7rem; padding: .48rem 0; border-bottom: 1px solid var(--d-rule-soft); }
.trow:last-child { border-bottom: 0; }
.trow > span { font-size: 11.5px; font-weight: 600; color: var(--d-ink-2); }
.trow svg { width: 100%; height: 24px; }
.trow b { font-size: 13.5px; font-variant-numeric: tabular-nums; text-align: right; }
.trow i { font-style: normal; font-size: 11px; font-weight: 600; white-space: nowrap; text-align: right; min-width: 78px; font-variant-numeric: tabular-nums; }
.trow i.up { color: var(--good); } .trow i.down { color: var(--bad); }
.tw { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .1rem .6rem; padding: .5rem 0; border-bottom: 1px solid var(--d-rule-soft); }
.tw:last-child { border-bottom: 0; }
.tw b { font-size: 12px; letter-spacing: -.005em; }
.tw i { font-style: normal; font-size: 11.5px; font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tw i.up { color: var(--good); } .tw i.down { color: var(--bad); }
.tw p { margin: 0; grid-column: 1 / -1; font-size: 11px; color: var(--d-ink-2); }

/* ---- interactive controls ---- */
.dash-rail a { cursor: pointer; }
select.chip.sel {
  font-family: inherit; cursor: pointer; appearance: none; -webkit-appearance: none;
  padding-right: 1.5rem; max-width: 12rem;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2346586E' stroke-width='3'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .5rem center; background-size: 10px;
}
select.chip.sel:hover { border-color: #BBD0FC; color: #0B3FC4; }
.dash-top .btn-x { cursor: pointer; }

/* ---- chat panel ---- */
.panel.chat { display: flex; flex-direction: column; gap: 0; }
.ch-head { padding: .7rem .95rem; border-bottom: 1px solid var(--d-rule); font-weight: 700; font-size: 13px; flex: none; }
.ch-msgs { flex: 1; min-height: 0; overflow-y: auto; padding: .8rem .9rem; display: flex; flex-direction: column; gap: .55rem; }
.ch-q { align-self: flex-end; background: var(--d-accent); color: #fff; border-radius: 12px 12px 3px 12px; padding: .45rem .7rem; font-size: 12.5px; max-width: 85%; }
.ch-a { align-self: flex-start; background: var(--d-bg); border: 1px solid var(--d-rule-soft); border-radius: 12px 12px 12px 3px; padding: .5rem .7rem; font-size: 12.5px; line-height: 1.45; max-width: 94%; }
.ch-a b { font-weight: 700; }
.ch-sug { display: flex; flex-wrap: wrap; gap: .4rem; }
.ch-sug span { cursor: pointer; border: 1px solid #BBD0FC; background: var(--d-accent-soft); color: #0B3FC4; border-radius: 999px; padding: .3rem .65rem; font-size: 11.5px; font-weight: 600; }
.ch-sug span:hover { background: #DCE7FD; }
.ch-foot { flex: none; display: flex; gap: .5rem; align-items: center; padding: .6rem .9rem; border-top: 1px solid var(--d-rule); }
.ch-foot input { flex: 1; min-width: 0; border: 1px solid var(--d-rule); border-radius: 999px; padding: .45rem .85rem; font-family: inherit; font-size: 12.5px; outline: none; background: var(--d-bg); color: var(--d-ink); }
.ch-foot input:focus { border-color: #BBD0FC; background: #fff; }
.ch-send { width: 30px; height: 30px; border-radius: 50%; background: var(--d-accent); color: #fff; display: grid; place-items: center; cursor: pointer; flex: none; }
.ch-send svg { width: 14px; height: 14px; }
.cb { display: grid; grid-template-columns: 88px minmax(0,1fr) auto; gap: .45rem; align-items: center; margin-top: .4rem; font-size: 11px; color: var(--d-ink-2); }
.cb .cbar { height: 8px; background: var(--d-rule-soft); border-radius: 4px; overflow: hidden; }
.cb .cbar i { display: block; height: 100%; border-radius: 4px; }
.cb b { font-variant-numeric: tabular-nums; color: var(--d-ink); }
.ch-think { display: inline-flex; gap: 4px; align-items: center; padding: .6rem .8rem; }
.ch-think i { width: 5px; height: 5px; border-radius: 50%; background: var(--d-ink-3); animation: chb 1s infinite ease-in-out; }
.ch-think i:nth-child(2) { animation-delay: .15s; } .ch-think i:nth-child(3) { animation-delay: .3s; }
@keyframes chb { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-3px); opacity: 1; } }

/* panels keep their content top-aligned when a filter shrinks the chart */
.dash-body { align-items: start; }
.tbl-wrap { overflow-x: auto; margin-inline: -.2rem; padding-inline: .2rem; }

/* fixed shell: switching views never changes the page height */
.dash { height: clamp(40rem, 84vh, 58rem); }
.dash-main { min-height: 0; }
.dash-body { overflow-y: auto; min-height: 0; align-content: start; }
@media (max-width: 1000px) {
  .dash { height: auto; }
  .dash-body { overflow-y: visible; }
}
