:root {
  --bg: #0f1115;
  --panel: #151922;
  --panel-2: #1b2130;
  --text: #e6e8ee;
  --muted: #9aa3b2;
  --line: #2a3140;
  --line-hover: #3b4558;
  --grid: #1e2430;
  --accent: #2962ff;
  --ce: #26a69a;
  --pe: #ef5350;
  --mono: ui-monospace, Menlo, monospace;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 -apple-system, "Segoe UI", Roboto, sans-serif; padding: 12px 16px 24px; }
button { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 4px 10px; cursor: pointer; font: inherit; font-size: 13px; }
button:hover:not(:disabled) { border-color: var(--line-hover); }
button:disabled { opacity: .4; cursor: default; }
button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); }
input[type="date"] { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 3px 8px; font: inherit; color-scheme: dark; }

.top { display: flex; flex-direction: column; gap: 10px; margin-bottom: 10px; }
.daybar { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.db-nav { display: flex; gap: 6px; align-items: center; }
.db-title { font-size: 18px; margin: 0; }
.db-sub { color: var(--muted); font: 12px var(--mono); }
.controls { display: flex; gap: 8px 20px; flex-wrap: wrap; align-items: center; }
.seg, .emas { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.seg-label { color: var(--muted); font-size: 12px; margin-right: 4px; }
.ema-chip i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; background: var(--c); margin-right: 6px; vertical-align: middle; }
.ema-chip[aria-pressed="true"] { background: var(--panel-2); border-color: var(--c); box-shadow: inset 0 0 0 1px var(--c); }
.ema-chip[aria-pressed="false"] { opacity: .5; }
.ema-all { color: var(--muted); }

.timeline { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin-bottom: 8px; position: sticky; top: 0; z-index: 5; }
.tl-strip { display: flex; height: 22px; border-radius: 4px; overflow: hidden; gap: 1px; background: var(--line); cursor: pointer; }
.tl-seg { background: var(--panel-2); color: var(--muted); font: 11px/22px var(--mono); text-align: center; overflow: hidden; white-space: nowrap; min-width: 2px; }
.tl-seg:nth-child(even) { background: #202737; }
.tl-seg:hover { color: var(--text); background: #2a3348; }
.tl-seg.on { background: var(--accent); color: #fff; }
.tl-row { display: flex; gap: 6px; align-items: center; margin-top: 8px; flex-wrap: wrap; }
.tl-range { flex: 1 1 260px; accent-color: var(--accent); min-width: 160px; }
.tl-time { font: 600 14px var(--mono); min-width: 230px; }

.headline { font: 600 14px var(--mono); margin: 4px 0 10px; }
.headline.error { color: var(--pe); }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 1100px) { .grid { grid-template-columns: 1fr; } }
.pane { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; min-width: 0; }
.pane-head { display: flex; gap: 10px; align-items: baseline; padding: 8px 12px 0; flex-wrap: wrap; }
.pane-title { margin: 0; font-size: 16px; }
#pane-ce .pane-title { color: var(--ce); }
#pane-pe .pane-title { color: var(--pe); }
.pane-sub { color: var(--muted); font: 12px var(--mono); }
.pane-actions { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; }
.switch { background: #3a2f0b; border-color: #ffd54f; color: #ffd54f; font-weight: 600; }
.reset { color: var(--muted); }
.pane.switched { border-color: #ffd54f; }
.switch:hover:not(:disabled) { background: #4a3c0e; border-color: #ffe082; }
.readout { padding: 4px 12px 6px; font: 12px var(--mono); color: var(--muted); min-height: 62px; }
.readout b { color: var(--text); font-weight: 600; }
.ro-ohlc { display: flex; gap: 12px; flex-wrap: wrap; }
.ro-line { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 2px; }
.ro-tag { min-width: 52px; }
.hv-tag { color: #ffd54f; font-weight: 600; }
.ro-signal { margin-top: 3px; color: #40c4ff; font-weight: 600; }
.ro-nifty { margin: 1px 0 2px; color: var(--text); }
.strike-tag { color: var(--text); background: var(--panel-2); border: 1px solid var(--line); border-radius: 4px; padding: 0 6px; }
.legend { color: var(--muted); font-size: 12px; }
.chip { border-left: 3px solid var(--c); padding-left: 5px; }
.chip b { color: var(--c); }
.chart-box { position: relative; height: max(520px, 68vh); }
.chart { position: absolute; inset: 0; }
.nav-link { color: #82b1ff; font-size: 13px; text-decoration: none; margin-left: auto; }
.nav-link:hover { text-decoration: underline; }

/* multi-timeframe page */
.mtf-side { margin-bottom: 14px; }
.mtf-title { display: flex; gap: 10px; align-items: baseline; margin: 0 0 6px; flex-wrap: wrap; }
.mtf-title h2 { margin: 0; font-size: 16px; }
#side-CE h2 { color: var(--ce); }
#side-PE h2 { color: var(--pe); }
.mtf-row { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
@media (max-width: 1400px) { .mtf-row { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 800px) { .mtf-row { grid-template-columns: minmax(0, 1fr); } }
.mini { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; min-width: 0; }
.mini-head { padding: 5px 8px 3px; font: 11px/1.4 var(--mono); color: var(--muted); min-height: 34px; }
.mini-head b { color: var(--text); font-weight: 600; }
.mini-label { font: 600 13px -apple-system, "Segoe UI", Roboto, sans-serif; margin-right: 6px; }
.mini-box { position: relative; height: max(440px, 52vh); }
.mini-chart { position: absolute; inset: 0; }
.header-toggle { font-size: 12px; padding: 2px 10px; }
.pnav { margin-left: auto; display: flex; gap: 4px; align-items: center; }
.pnav button { padding: 1px 8px; font-size: 12px; }
.pnav-list { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 6px; font: 12px var(--mono); padding: 2px 4px; max-width: 320px; }
.pnav-count { color: var(--muted); font: 12px var(--mono); min-width: 52px; }
.mini.focus { border-color: #ffd54f; box-shadow: 0 0 0 1px #ffd54f; }
.day-mini { display: none; color: var(--text); font: 600 13px var(--mono); }
body.header-hidden #mtf-header { display: none; }
body.header-hidden .day-mini { display: inline; }
/* Wide screens: CE row + PE row fill the window height exactly, charts stretch to fit. */
@media (min-width: 1401px) {
  body.mtf { height: 100vh; display: flex; flex-direction: column; overflow: hidden; padding: 8px 12px; }
  body.mtf .top { margin-bottom: 6px; gap: 6px; }
  body.mtf .headline { margin: 0; }
  body.mtf .mtf-side { flex: 1 1 0; min-height: 0; display: flex; flex-direction: column; margin-bottom: 6px; }
  body.mtf .mtf-side:last-child { margin-bottom: 0; }
  body.mtf .mtf-title { margin-bottom: 4px; }
  body.mtf .mtf-row { flex: 1; min-height: 0; }
  body.mtf .mini { display: flex; flex-direction: column; min-height: 0; }
  body.mtf .mini-box { flex: 1; height: auto; min-height: 0; }
}
.missing { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); background: var(--panel); font-size: 14px; padding: 16px; text-align: center; }

/* MyTV 5 Min page */
.five-bar { display: flex; gap: 8px 16px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; }
.five-bar .pnav { margin-left: auto; }
.gap-chip { font: 600 13px var(--mono); padding: 2px 8px; border-radius: 6px; border: 1px solid currentColor; color: var(--muted); }
.gap-chip[data-kind="up"] { color: #26a69a; }
.gap-chip[data-kind="down"] { color: #ef5350; }
.spick { display: flex; gap: 4px; align-items: center; }
.spick-list { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 6px; font: 12px var(--mono); padding: 2px 4px; }
.spick.custom .spick-list { border-color: #ffd54f; color: #ffd54f; }
.spick-reset { padding: 1px 8px; font-size: 12px; color: var(--muted); }
#pick-CE .seg-label { color: var(--ce); font-weight: 600; }
#pick-PE .seg-label { color: var(--pe); font-weight: 600; }
.five-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 1000px) { .five-grid { grid-template-columns: minmax(0, 1fr); } }
.five-side { min-width: 0; display: flex; flex-direction: column; }
.five-side.custom .mini { border-color: #ffd54f; }
.five-side .mini-box { height: max(520px, 70vh); }
@media (min-width: 1001px) {
  body.five { height: 100vh; display: flex; flex-direction: column; overflow: hidden; padding: 8px 12px; }
  body.five .top { margin-bottom: 6px; gap: 6px; }
  body.five .headline { margin: 0; }
  body.five .five-grid { flex: 1; min-height: 0; }
  body.five .five-side, body.five .five-chart, body.five .five-body { min-height: 0; }
  body.five .five-body { flex: 1; }
  body.five .five-chart { display: flex; flex-direction: column; }
  body.five .five-levels { max-height: none; }
  body.five .five-side .mini-box { flex: 1; height: auto; min-height: 0; }
}

.five-body { display: flex; gap: 6px; min-width: 0; }
.five-chart { flex: 1; min-width: 0; }
.five-levels { width: 250px; flex: none; overflow-y: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; max-height: max(560px, 74vh); }
body.levels-list-off .five-levels { display: none; }
@media (max-width: 1000px) { .five-body { flex-direction: column; } .five-levels { width: auto; max-height: 300px; } }
.hvl-title { position: sticky; top: 0; background: var(--panel); padding: 5px 8px; font: 600 11px var(--mono); color: var(--muted); border-bottom: 1px solid var(--line); }
.hvl-table { width: 100%; border-collapse: collapse; font: 11px var(--mono); }
.hvl-table td { padding: 2px 6px; border-bottom: 1px solid var(--grid); white-space: nowrap; }
.hvl-tf { font-weight: 600; }
.hvl-when { color: var(--muted); }
.hvl-price { text-align: right; font-weight: 600; }
.hvl-red .hvl-price { color: var(--pe); }
.hvl-green .hvl-price { color: var(--ce); }
.hvl-vol { text-align: right; color: var(--text); }
.hvl-empty { padding: 8px; color: var(--muted); font-size: 12px; }

.replay { display: flex; gap: 4px; align-items: center; }
.replay button { padding: 2px 10px; font-size: 12px; }
.replay-switch[aria-checked="true"] { background: #3a2f0b; border-color: #ffd54f; color: #ffd54f; font-weight: 600; }
.replay-next:not(:disabled) { border-color: var(--accent); }
.replay-label { color: #ffd54f; font: 600 12px var(--mono); margin-left: 4px; }
.hvl-table tr.hvl-hot td { background: #5c4a0c; box-shadow: inset 0 1px #ffd54f, inset 0 -1px #ffd54f; }
.hvl-table tr.hvl-hot td:first-child { box-shadow: inset 0 1px #ffd54f, inset 0 -1px #ffd54f, inset 2px 0 #ffd54f; }
.hvl-table tr.hvl-hot .hvl-when { color: #ffd54f; }
.hvl-table tbody tr { cursor: pointer; }
.hvl-table tbody tr:hover td { background: var(--panel-2); }
