/* Agent terminal (/agent/<id>): an exchange-style layout in the Echo theme.
   Market header + toolbar on the price chart, a matching header on the equity chart,
   tabbed panels, segmented controls, and the landing redesign's buttons (glow, sheen, corner ticks). */

.agentpage { --tick: rgba(143, 240, 212, .75); --glow: rgba(143, 240, 212, .55); }

/* ---------------------------------------------------------------- panels */
.agentpage .ap-charts { gap: 12px; }
.tp, .tp-card { position: relative; border: 1px solid var(--line); background: linear-gradient(180deg, #0f110f, #0c0e0c); }
.tp::before, .tp-card::before, .agentpage .stats::before, .agentpage .ap-why::before {
  content: ""; position: absolute; left: -1px; top: -1px; width: 14px; height: 14px; z-index: 2; pointer-events: none;
  border-left: 1px solid var(--tick); border-top: 1px solid var(--tick);
}
.agentpage .stats, .agentpage .ap-why { position: relative; }
.agentpage .ap-chart { height: 420px; }
.agentpage .ap-legend { font-size: 11px; padding: 8px 14px; gap: 18px; background: rgba(255, 255, 255, .01); }

/* ---------------------------------------------------------------- market header */
.mk { display: flex; align-items: center; gap: 14px; padding: 10px 16px 10px 12px; min-height: 66px; border-bottom: 1px solid var(--line); }
.mk-coin { position: relative; flex: none; }
.mk-coinbtn { display: inline-flex; align-items: center; gap: 10px; padding: 6px 8px; background: none; border: 1px solid transparent; color: var(--text); font: 600 19px var(--mono); letter-spacing: .01em; cursor: pointer; transition: border-color .15s, background .15s; }
.mk-coinbtn:hover { border-color: var(--line2); background: rgba(255, 255, 255, .02); }
.mk-coinbtn b { font-weight: 600; }
.mk-coinbtn.solo, .mk-static { cursor: default; }
.mk-coinbtn.solo:hover, .mk-static:hover { border-color: transparent; background: none; }
.mk-coinbtn.solo .mk-caret { display: none; }
.mk-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px rgba(143, 240, 212, .14), 0 0 14px var(--glow); }
.mk-caret { color: var(--muted); font-size: 12px; transition: transform .2s; }
.mk-coinbtn[aria-expanded="true"] { border-color: var(--line2); }
.mk-coinbtn[aria-expanded="true"] .mk-caret { transform: rotate(180deg); color: var(--accent); }

.mk-menu { position: absolute; top: calc(100% + 6px); left: 0; z-index: 40; min-width: 230px; display: flex; flex-direction: column; padding: 6px; background: #0d0f0d; border: 1px solid var(--line2); box-shadow: 0 22px 50px -14px rgba(0, 0, 0, .85), 0 0 0 1px rgba(143, 240, 212, .05); }
.mk-menu[hidden] { display: none; }
.mk-menu::before { content: ""; position: absolute; left: -1px; top: -1px; width: 12px; height: 12px; border-left: 1px solid var(--tick); border-top: 1px solid var(--tick); }
.mk-menu button { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 9px 10px; background: none; border: none; color: var(--muted); font: 13px var(--mono); text-align: left; cursor: pointer; }
.mk-menu button b { font-weight: 500; }
.mk-menu button span { font-size: 10.5px; letter-spacing: .12em; }
.mk-menu button:hover { background: var(--panel2); color: var(--text); }
.mk-menu button[aria-selected="true"] { background: var(--accent-bg); color: var(--accent); }

.mk-lev { flex: none; padding: 3px 9px; font-size: 12px; letter-spacing: .04em; color: var(--accent); background: var(--accent-bg); border: 1px solid rgba(143, 240, 212, .22); }
.mk-lev.rose { color: var(--rose); background: rgba(232, 163, 160, .08); border-color: rgba(232, 163, 160, .28); }
.mk-lev[hidden] { display: none; }

.mk-stats { flex: 1; min-width: 0; display: flex; gap: 0 22px; overflow-x: auto; scrollbar-width: none; padding: 2px 0; }
.mk-stats::-webkit-scrollbar { display: none; }
.mk-s { flex: none; display: flex; flex-direction: column; gap: 5px; }
.mk-s .k { align-self: flex-start; font-size: 11px; color: var(--muted); white-space: nowrap; padding-bottom: 1px; border-bottom: 1px dashed var(--line2); }
.mk-s .k[title] { cursor: help; }
.mk-s .v { font-size: 14px; color: var(--text); white-space: nowrap; font-variant-numeric: tabular-nums; }
.mk-s .accent { color: var(--accent); } .mk-s .rose { color: var(--rose); } .mk-s .muted { color: var(--muted); }

/* ---------------------------------------------------------------- toolbars + tabs */
.tp-bar, .tp-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; min-height: 46px; padding-right: 12px; border-bottom: 1px solid var(--line); }
.tp-head { justify-content: space-between; }
.tp-utabs { display: flex; align-self: stretch; }
.tp-utabs button { position: relative; padding: 0 16px; min-height: 46px; background: none; border: none; color: var(--muted); font: 13px var(--mono); letter-spacing: .02em; cursor: pointer; transition: color .15s; }
.tp-utabs button:hover { color: var(--text); }
.tp-utabs button.on, .tp-utabs button[aria-pressed="true"] { color: var(--text); }
.tp-utabs button.on[tabindex="-1"] { cursor: default; }
.tp-utabs button::after { content: ""; position: absolute; left: 12px; right: 12px; bottom: -1px; height: 2px; background: var(--accent); box-shadow: 0 0 12px var(--glow); transform: scaleX(0); transition: transform .25s cubic-bezier(.2, .8, .2, 1); }
.tp-utabs button.on::after, .tp-utabs button[aria-pressed="true"]::after { transform: scaleX(1); }
.tp-utabs i { font-style: normal; color: var(--dim); margin-left: 4px; }

.tp-live { margin-left: auto; display: inline-flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.tp-head .tp-live { margin-left: 0; }
.tp-pulse { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 8px var(--accent); animation: tpPulse 1.8s ease-in-out infinite; }
@keyframes tpPulse { 50% { opacity: .3; box-shadow: 0 0 2px var(--accent); } }

/* segmented controls (interval, range, filters) */
.agentpage .ap-tabs { display: inline-flex; flex-wrap: wrap; gap: 0; padding: 2px; background: #0a0c0a; border: 1px solid var(--line2); }
.agentpage .ap-tabs button { position: relative; padding: 5px 11px; min-height: 28px; background: none; border: none; color: var(--muted); font: 11.5px var(--mono); letter-spacing: .06em; cursor: pointer; transition: color .15s, background .15s, box-shadow .15s; }
.agentpage .ap-tabs button:hover { color: var(--text); background: rgba(255, 255, 255, .035); }
.agentpage .ap-tabs button[aria-pressed="true"] { color: var(--accent); background: var(--accent-bg); box-shadow: inset 0 0 0 1px rgba(143, 240, 212, .3), 0 0 18px -6px var(--glow); text-shadow: 0 0 10px rgba(143, 240, 212, .45); }
.agentpage .ap-tabs button:focus-visible, .tp-utabs button:focus-visible, .mk-coinbtn:focus-visible { outline: 1px solid var(--accent); outline-offset: 2px; }

/* ---------------------------------------------------------------- stats strip + pnl breakdown */
.agentpage .stat { background: linear-gradient(180deg, #0f110f, #0c0e0c); padding: 16px 18px; }
.agentpage .stat .k { align-self: flex-start; font-size: 11px; letter-spacing: .1em; padding-bottom: 1px; border-bottom: 1px dashed var(--line2); }
.agentpage .stat .v, .agentpage .ap-why-row .v { font-variant-numeric: tabular-nums; }
.agentpage .ap-why { background: linear-gradient(180deg, #0f110f, #0c0e0c); }

/* ---------------------------------------------------------------- cards + tables */
.agentpage .ap-grid { gap: 12px; }
.agentpage .ap-col { gap: 12px; }
.agentpage .ap-block.tp-card { gap: 0; }
.agentpage .ap-block + .ap-block { margin-top: 0; }
.tp-card .ap-tablewrap { border: none; }
.tp-card .ap-note { margin: 0; padding: 12px 16px 0; }
.tp-card .agentgrid .acard { border: none; background: none; }
.tp-more { align-self: flex-start; margin: 10px 12px 12px; }

.agentpage .ap-table th { padding: 10px 14px; font-size: 11px; letter-spacing: .04em; color: var(--muted); background: rgba(255, 255, 255, .012); }
.agentpage .ap-table td { padding: 9px 14px; border-bottom-color: rgba(38, 42, 39, .7); font-variant-numeric: tabular-nums; }
.agentpage .ap-table tbody tr { transition: background .12s; }
.agentpage .ap-table tbody tr:hover { background: rgba(143, 240, 212, .035); }
#posTable th:nth-child(n+2), #posTable td:nth-child(n+2) { text-align: right; }
#posTable tr[data-coin] { cursor: pointer; }
#posTable tr.on td:first-child { box-shadow: inset 2px 0 0 var(--accent); }

/* ---------------------------------------------------------------- buttons */
.agentpage .btn { position: relative; isolation: isolate; transition: background .18s, color .18s, border-color .18s, box-shadow .18s, transform .1s; }
/* a light sweep across the button on hover (moves the gradient, so nothing spills outside the button) */
.agentpage .btn::after { content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none; background-image: linear-gradient(105deg, transparent 40%, rgba(255, 255, 255, .32) 50%, transparent 60%); background-size: 300% 100%; background-repeat: no-repeat; background-position: 100% 0; transition: background-position .7s cubic-bezier(.2, .8, .2, 1); }
.agentpage .btn:hover::after { background-position: 0 0; }
.agentpage .btn:active:not([disabled]) { transform: translateY(1px); }
.agentpage .btn:focus-visible { outline: 1px solid var(--accent); outline-offset: 3px; }

.agentpage .btn:not(.ghost):not([disabled]) { box-shadow: 0 0 0 1px rgba(143, 240, 212, .25), 0 8px 26px -10px rgba(143, 240, 212, .7), inset 0 1px 0 rgba(255, 255, 255, .35); }
.agentpage .btn:not(.ghost):not([disabled]):hover { background: #b2f6e3; filter: none; box-shadow: 0 0 0 1px rgba(143, 240, 212, .4), 0 10px 32px -8px rgba(143, 240, 212, .85), inset 0 1px 0 rgba(255, 255, 255, .4); }

.agentpage .btn.ghost { background: linear-gradient(180deg, rgba(255, 255, 255, .03), rgba(255, 255, 255, 0)); border-color: var(--line2); }
.agentpage .btn.ghost::after { background-image: linear-gradient(105deg, transparent 40%, rgba(143, 240, 212, .14) 50%, transparent 60%); }
.agentpage .btn.ghost::before { content: ""; position: absolute; inset: -1px; pointer-events: none; opacity: 0; transition: opacity .18s;
  background:
    linear-gradient(var(--accent), var(--accent)) left top / 8px 1px no-repeat,
    linear-gradient(var(--accent), var(--accent)) left top / 1px 8px no-repeat,
    linear-gradient(var(--accent), var(--accent)) right bottom / 8px 1px no-repeat,
    linear-gradient(var(--accent), var(--accent)) right bottom / 1px 8px no-repeat; }
.agentpage .btn.ghost:hover { color: var(--accent); border-color: rgba(143, 240, 212, .5); background: rgba(143, 240, 212, .05); box-shadow: 0 0 0 1px rgba(143, 240, 212, .1), 0 0 24px -8px var(--glow); }
.agentpage .btn.ghost:hover::before { opacity: 1; }

/* close buttons stay rose */
.agentpage .btn.apos-close::before, .agentpage .btn.apos-all::before { background:
    linear-gradient(var(--rose), var(--rose)) left top / 8px 1px no-repeat,
    linear-gradient(var(--rose), var(--rose)) left top / 1px 8px no-repeat,
    linear-gradient(var(--rose), var(--rose)) right bottom / 8px 1px no-repeat,
    linear-gradient(var(--rose), var(--rose)) right bottom / 1px 8px no-repeat; }
.agentpage .btn.apos-close::after, .agentpage .btn.apos-all::after { background-image: linear-gradient(105deg, transparent 40%, rgba(232, 163, 160, .16) 50%, transparent 60%); }
.agentpage .btn.apos-close:hover, .agentpage .btn.apos-all:hover { color: var(--rose); border-color: var(--rose); background: rgba(232, 163, 160, .08); box-shadow: 0 0 24px -8px rgba(232, 163, 160, .55); }

/* control-room pickers get the same hover glow */
.agentpage .afund-src, .agentpage .aldr-pick, .agentpage .aldr-style { transition: color .15s, border-color .15s, background .15s, box-shadow .15s; }
.agentpage .aldr-pick:hover, .agentpage .aldr-style:hover { border-color: rgba(143, 240, 212, .45); box-shadow: 0 0 20px -10px var(--glow); }
.agentpage .afund-src:hover { color: var(--text); background: rgba(255, 255, 255, .03); }

/* ---------------------------------------------------------------- small screens */
@media (max-width: 640px) {
  .mk { flex-wrap: wrap; gap: 8px 10px; padding: 10px 12px; }
  .mk-stats { flex-basis: 100%; gap: 0 20px; }
  .mk-coinbtn { font-size: 17px; }
  .agentpage .ap-chart { height: 320px; }
  .tp-bar .tp-live { display: none; }
  .tp-utabs button { padding: 0 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .tp-pulse { animation: none; }
  .agentpage .btn::after { display: none; }
  .tp-utabs button::after, .mk-caret { transition: none; }
}

/* the market bar spans both charts, like an exchange's top bar */
.ap-charts > .mk { grid-column: 1 / -1; min-width: 0; }
.mk-sep { flex: none; align-self: stretch; width: 1px; margin: 2px 2px; background: var(--line2); }
.mk-stats.more { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 56px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 56px), transparent); }
@media (max-width: 640px) { .tp-bar > .ap-tabs { margin: 6px 0 8px 12px; } }

/* form controls in the control room match the theme */
.agentpage input[type="checkbox"], .agentpage input[type="radio"] { accent-color: var(--accent); }
.agentpage .actl-in input:focus, .agentpage .actl-grid select:focus, .agentpage .actl-coins input:focus, .agentpage .afund-row input:focus { box-shadow: 0 0 0 1px rgba(143, 240, 212, .25), 0 0 18px -8px var(--glow); }

/* ---------------------------------------------------------------- chat with your agent */
.chat { display: flex; flex-direction: column; min-height: 0; }
.chat[hidden], #ctlPane[hidden] { display: none; }
.ch-gate { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; padding: 20px 18px 22px; font-size: 13px; line-height: 1.6; }
.ch-gate p { margin: 0; }
.ch-gate .btn { margin-top: 6px; }
.ch-face { margin: 0 0 4px; font-size: 15px; line-height: 1.1; color: var(--accent); text-shadow: 0 0 14px rgba(143, 240, 212, .45); }
.ch-can { margin: 2px 0 4px; padding-left: 18px; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }
.ch-fine { font-size: 11.5px; }

.ch-bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 14px; border-bottom: 1px solid var(--line); font-size: 11.5px; }
.ch-tools { display: inline-flex; gap: 12px; flex: none; }
.ch-link { background: none; border: none; padding: 4px 0; color: var(--muted); font: 11.5px var(--mono); cursor: pointer; border-bottom: 1px dashed var(--line2); }
.ch-link:hover { color: var(--accent); border-color: var(--accent); }
.ch-link.rose { color: var(--rose); border-color: var(--rose); }
.ch-notes { display: flex; flex-direction: column; gap: 4px; padding: 10px 14px; border-bottom: 1px solid var(--line); background: rgba(143, 240, 212, .025); font-size: 12px; max-height: 180px; overflow-y: auto; }
.ch-notes p { margin: 0; }
.ch-n { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.ch-n button { flex: none; background: none; border: none; color: var(--dim); font-size: 15px; line-height: 1; cursor: pointer; padding: 0 2px; }
.ch-n button:hover { color: var(--rose); }

.ch-log { height: 520px; overflow-y: auto; padding: 16px 14px 8px; display: flex; flex-direction: column; gap: 14px; scroll-behavior: smooth; overscroll-behavior: contain; }
.ch-m { display: flex; flex-direction: column; gap: 6px; max-width: 92%; font-size: 13px; line-height: 1.6; }
.ch-u { align-self: flex-end; align-items: flex-end; }
.ch-u .ch-b { background: var(--accent-bg); border: 1px solid rgba(143, 240, 212, .22); padding: 8px 12px; color: var(--text); }
.ch-a { align-self: flex-start; }
.ch-who { font-size: 11px; letter-spacing: .06em; color: var(--accent); }
.ch-t { font-size: 10.5px; color: var(--dim); letter-spacing: 0; margin-left: 6px; }
.ch-u .ch-t { margin: 0; }
.ch-b p { margin: 0 0 8px; }
.ch-b p:last-child { margin-bottom: 0; }
.ch-b ul, .ch-b ol { margin: 0 0 8px; padding-left: 18px; }
.ch-b li { margin: 2px 0; }
.ch-b .ch-h { color: var(--text); font-weight: 600; margin-top: 4px; }
.ch-b b { color: var(--text); font-weight: 600; }
.ch-b code { font-size: 12px; background: var(--panel2); padding: 0 4px; }
.ch-b a, .ch-src a { color: var(--accent); text-decoration: none; border-bottom: 1px dotted rgba(143, 240, 212, .5); }
.ch-a .ch-b { color: #d9d5c9; }
.ch-src { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 11.5px; }
.ch-src span { color: var(--dim); }
.ch-steps { font-size: 11.5px; color: var(--dim); }
.ch-steps summary { cursor: pointer; list-style: none; }
.ch-steps summary::before { content: "▸ "; }
.ch-steps[open] summary::before { content: "▾ "; }
.ch-steps div { padding-left: 12px; }
.ch-ev { align-self: center; max-width: 90%; text-align: center; font-size: 11.5px; color: var(--muted); }
.ch-ev span { display: inline-block; padding: 4px 10px; border: 1px dashed var(--line2); }
.ch-err { font-size: 12px; }

.ch-act { position: relative; margin-top: 4px; border: 1px solid rgba(143, 240, 212, .35); background: rgba(143, 240, 212, .04); padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 6px; box-shadow: 0 0 24px -14px var(--glow); }
.ch-act::before { content: ""; position: absolute; left: -1px; top: -1px; width: 10px; height: 10px; border-left: 1px solid var(--accent); border-top: 1px solid var(--accent); }
.ch-act.k-close_positions, .ch-act.k-pause { border-color: rgba(232, 163, 160, .4); background: rgba(232, 163, 160, .04); }
.ch-act.k-close_positions::before, .ch-act.k-pause::before { border-color: var(--rose); }
.ch-act.s-done, .ch-act.s-declined { opacity: .7; box-shadow: none; }
.ch-act-h { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 11px; letter-spacing: .12em; }
.ch-act-h b { font-weight: 600; }
.ch-st { font-size: 10.5px; letter-spacing: .08em; color: var(--muted); }
.ch-st.ok { color: var(--accent); } .ch-st.bad { color: var(--rose); } .ch-st.wait { color: #f0d48f; }
.ch-sum { font-size: 12.5px; color: var(--text); }
.ch-why, .ch-note { font-size: 11.5px; color: var(--muted); }
.ch-btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.ch-btns .btn { min-height: 36px; padding: 0 14px; font-size: 12px; }

.ch-empty { margin: auto 0; display: flex; flex-direction: column; align-items: flex-start; gap: 10px; font-size: 13px; color: var(--muted); }
.ch-empty p { margin: 0; }
.ch-sugs { display: flex; flex-wrap: wrap; gap: 6px; }
.ch-sugs button { background: none; border: 1px solid var(--line2); color: var(--text); font: 12px var(--mono); padding: 7px 10px; cursor: pointer; text-align: left; transition: border-color .15s, color .15s, box-shadow .15s; }
.ch-sugs button:hover { border-color: rgba(143, 240, 212, .55); color: var(--accent); box-shadow: 0 0 18px -8px var(--glow); }

.ch-think .ch-step { font-size: 11.5px; color: var(--muted); }
.ch-dots { display: inline-flex; gap: 5px; padding: 6px 0; }
.ch-dots i { width: 6px; height: 6px; background: var(--accent); box-shadow: 0 0 8px var(--accent); animation: chDot 1.1s infinite ease-in-out; }
.ch-dots i:nth-child(2) { animation-delay: .15s; } .ch-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes chDot { 0%, 80%, 100% { opacity: .2; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

.ch-form { display: flex; gap: 8px; align-items: flex-end; padding: 10px 12px 12px; border-top: 1px solid var(--line); }
.ch-form textarea { flex: 1; min-height: 44px; max-height: 160px; resize: vertical; padding: 10px 12px; background: #0a0c0a; border: 1px solid var(--line2); color: var(--text); font: 13px/1.5 var(--mono); }
.ch-form textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 1px rgba(143, 240, 212, .25), 0 0 18px -8px var(--glow); }
.ch-form .btn { min-height: 44px; padding: 0 18px; }
@media (max-width: 640px) { .ch-log { height: 440px; } .ch-m { max-width: 100%; } .ch-form textarea { font-size: 16px; } }
@media (prefers-reduced-motion: reduce) { .ch-dots i { animation: none; opacity: .7; } .ch-log { scroll-behavior: auto; } }
.ch-b i { font-style: italic; color: var(--muted); }
