/* HYDRA client cabinet — built on the site's tokens and components (/assets/site.css). */

body.cabinet { min-height: 100vh; }
.cab-head .brand .sub { color: var(--accent); }
.nav-toggle { display: none; }

.cab-body { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 28px; padding-block: 28px 64px; align-items: start; }
.cab-body-public { grid-template-columns: minmax(0, 1fr); }
.cab-view { min-width: 0; display: grid; gap: 18px; align-content: start; }
.cab-title { font-size: clamp(24px, 3vw, 32px); letter-spacing: -0.02em; font-weight: 700; }

/* navigation */
.cab-nav { position: sticky; top: 84px; display: grid; gap: 2px; padding: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; }
.cab-nav a, .cab-logout { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-radius: 8px; color: var(--text-2); text-decoration: none; font-size: 14.5px; line-height: 1.3; }
.cab-nav a:hover, .cab-logout:hover { background: var(--panel-2); color: var(--text); }
.cab-nav a.active { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--text); font-weight: 600; }
.cab-logout { font: inherit; font-size: 14.5px; border: 0; background: transparent; cursor: pointer; text-align: left; margin-top: 6px; border-top: 1px solid var(--line); border-radius: 0 0 8px 8px; }
.badge { margin-left: auto; min-width: 22px; padding: 1px 7px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-family: var(--font-mono); font-size: 12px; font-weight: 600; text-align: center; }

@media (max-width: 1024px) {
  .cab-body { grid-template-columns: minmax(0, 1fr); padding-top: 16px; gap: 16px; }
  .nav-toggle { display: inline-flex; }
  .cab-nav { display: none; position: static; }
  .cab-nav.open { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
  .cab-nav.open .cab-logout { grid-column: 1 / -1; }
}
@media (max-width: 520px) {
  .wrap.cab-body { padding-inline: 14px; }
  .cab-panel-body { padding: 14px; }
  .cab-panel .panel-head { padding: 14px; }
}

/* panels and layout */
.cab-panel .panel-head h3 { font-size: 16px; }
.cab-panel-body { padding: 16px 18px 18px; display: grid; gap: 12px; }
.dash-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: start; }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; }
.stat-card { padding: 16px 18px; display: grid; gap: 6px; }
.big { font-size: clamp(22px, 2.6vw, 30px); font-weight: 700; letter-spacing: -0.01em; }
@media (max-width: 860px) { .dash-grid { grid-template-columns: minmax(0, 1fr); } }

/* dashboard: account and trading buttons */
.dash-toolbar { display: flex; flex-wrap: wrap; gap: 12px; }
#control-notice:empty { display: none; }
.btn-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; padding: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; flex: 1 1 320px; }
.tbtn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 10px 14px; font: inherit; font-size: 15px; font-weight: 600; line-height: 1.15; text-align: center;
  color: var(--text-2); background: transparent; border: 1px solid transparent; border-radius: 9px; cursor: pointer; transition: background-color 0.15s, color 0.15s, border-color 0.15s; }
.tbtn:hover { color: var(--text); background: var(--panel-2); }
.tbtn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tbtn.is-on { background: var(--accent); color: var(--accent-ink); }
.tbtn-go:hover { color: var(--gain); border-color: color-mix(in srgb, var(--gain) 55%, transparent); background: color-mix(in srgb, var(--gain) 10%, transparent); }
.tbtn-halt:hover { color: var(--loss); border-color: color-mix(in srgb, var(--loss) 55%, transparent); background: color-mix(in srgb, var(--loss) 10%, transparent); }
.tbtn-state[disabled] { cursor: default; opacity: 1; }
.tbtn-state.tone-ok { background: var(--gain); color: #03170f; }
.tbtn-state.tone-bad { background: var(--loss); color: #1f0405; }
.tbtn-state .dot { background: currentColor; box-shadow: 0 0 0 4px color-mix(in srgb, currentColor 22%, transparent); }

/* dashboard: status tiles */
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 1180px) and (min-width: 1025px) { .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; } }
.tile { --tone: var(--line-2); position: relative; display: grid; gap: 6px; align-content: start; min-width: 0; padding: 14px 16px 14px 18px; border-radius: 12px; border: 1px solid var(--line);
  background: linear-gradient(135deg, color-mix(in srgb, var(--tone) 12%, var(--panel)), var(--panel) 70%); overflow: hidden; }
.tile::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--tone); }
.tile.tone-ok { --tone: var(--gain); }
.tile.tone-warn { --tone: var(--research); }
.tile.tone-bad { --tone: var(--loss); }
.tile.tone-info { --tone: var(--accent); }
.tile-label { font-family: var(--font-mono); font-size: 11.5px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.tile-value { display: flex; align-items: center; gap: 8px; font-size: 17px; font-weight: 700; line-height: 1.25; overflow-wrap: anywhere; }
.tile.tone-ok .tile-value, .tile.tone-bad .tile-value, .tile.tone-warn .tile-value { color: color-mix(in srgb, var(--tone) 80%, var(--text)); }
.tile-value .dot { background: var(--tone); box-shadow: 0 0 0 4px color-mix(in srgb, var(--tone) 22%, transparent); }
.tile-value a { color: inherit; }
.tile-extra { font-size: 13px; color: var(--text-2); line-height: 1.4; overflow-wrap: anywhere; }
@media (max-width: 400px) { .tile { padding: 12px 12px 12px 15px; } .tile-value { font-size: 15.5px; } }

/* dashboard: open positions */
.pos-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: 14px; }
.pos-card { --side: var(--gain); display: grid; gap: 12px; align-content: start; padding: 14px 16px; border: 1px solid var(--line); border-top: 3px solid var(--side); border-radius: 12px; background: var(--panel-2); min-width: 0; }
.pos-card.is-short { --side: var(--loss); }
.pos-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.pos-symbol { font-size: 17px; font-weight: 700; }
.pos-lev { font-size: 12.5px; color: var(--text-2); padding: 1px 7px; border-radius: 4px; background: var(--panel); border: 1px solid var(--line-2); }
.origin { margin-left: auto; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--line-2); color: var(--text-2); white-space: nowrap; }
.origin-bot_and_venue { color: var(--accent-2); border-color: color-mix(in srgb, var(--accent) 55%, transparent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.origin-venue { color: var(--text-2); }
.origin-bot { color: var(--research); border-color: color-mix(in srgb, var(--research) 55%, transparent); }
.pos-pnl { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 10px 12px; border-radius: 9px; background: var(--panel); border: 1px solid var(--line); }
.pos-pnl span { color: var(--muted); font-size: 13px; }
.pos-pnl b { font-size: 20px; }
.pos-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 16px; margin: 0; }
.pos-grid div { display: grid; gap: 2px; min-width: 0; }
.pos-grid dt { font-size: 12px; color: var(--muted); }
.pos-grid dd { margin: 0; font-size: 14.5px; overflow-wrap: anywhere; }
.pos-close { justify-self: start; }

.kv { display: flex; justify-content: space-between; gap: 16px; padding: 7px 0; border-bottom: 1px dashed var(--line); font-size: 14.5px; }
.kv:last-child { border-bottom: 0; }
.kv span { color: var(--muted); }
.kv b { font-weight: 600; text-align: right; }
.kv-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); column-gap: 28px; }

.status-line { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.dot-on { background: var(--gain); box-shadow: 0 0 0 4px color-mix(in srgb, var(--gain) 22%, transparent); }
.dot-off { background: var(--muted); }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }
.sub-line { font-size: 14px; color: var(--text-2); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
a.chip { text-decoration: none; }

.segmented { display: inline-grid; grid-auto-flow: column; background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 10px; padding: 3px; gap: 3px; }
.seg { font: inherit; font-size: 14px; font-weight: 600; padding: 9px 14px; border-radius: 8px; border: 0; background: transparent; color: var(--text-2); cursor: pointer; }
.seg.on { background: var(--accent); color: var(--accent-ink); }

/* rich text from the bot's catalog */
.rich { white-space: pre-line; overflow-wrap: anywhere; line-height: 1.6; }
.rich code, .address { font-family: var(--font-mono); font-size: 0.92em; background: var(--panel-2); border: 1px solid var(--line); border-radius: 5px; padding: 1px 6px; overflow-wrap: anywhere; }
.address-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.address-row .address { padding: 8px 10px; }

.notice { border-radius: 10px; padding: 12px 14px; border: 1px solid var(--line-2); background: var(--panel-2); }
.notice-success { border-color: color-mix(in srgb, var(--gain) 55%, transparent); background: color-mix(in srgb, var(--gain) 9%, var(--panel)); }
.notice-warning { border-color: color-mix(in srgb, var(--research) 60%, transparent); background: color-mix(in srgb, var(--research) 9%, var(--panel)); }
.notice-error { border-color: color-mix(in srgb, var(--loss) 60%, transparent); background: color-mix(in srgb, var(--loss) 9%, var(--panel)); }
.notice-info { border-color: color-mix(in srgb, var(--accent) 45%, transparent); background: color-mix(in srgb, var(--accent) 7%, var(--panel)); }
.guide { max-width: 100%; border-radius: 10px; border: 1px solid var(--line); }
.loading { color: var(--muted); font-size: 14px; }
.tag { font-size: 11.5px; font-family: var(--font-mono); padding: 1px 7px; border-radius: 4px; border: 1px solid var(--line-2); color: var(--muted); margin-left: 6px; }
.tag-ok { color: var(--gain); border-color: color-mix(in srgb, var(--gain) 50%, transparent); }

/* tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
.cab-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.cab-table th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12.5px; padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--panel-2); white-space: nowrap; }
.cab-table td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.cab-table tr:last-child td { border-bottom: 0; }
.cab-table tr.clickable { cursor: pointer; }
.cab-table tr.clickable:hover td { background: var(--panel-2); }
.cab-table small { color: inherit; opacity: 0.8; }
.cab-table td.mono { white-space: nowrap; }
@media (max-width: 640px) {
  .table-wrap:has(> .stack) { overflow: visible; border: 0; }
  .cab-table.stack thead { display: none; }
  .cab-table.stack, .cab-table.stack tbody, .cab-table.stack tr, .cab-table.stack td { display: block; width: 100%; }
  .cab-table.stack tr { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; margin-bottom: 10px; background: var(--panel); }
  .cab-table.stack td { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 5px 0; border: 0; text-align: right; white-space: normal; }
  .cab-table.stack td::before { content: attr(data-label); color: var(--muted); font-size: 12.5px; text-align: left; }
  .cab-table.stack td[data-label=""]::before { content: none; }
  .cab-table.stack td[data-label=""] { justify-content: flex-end; }
  .cab-table.stack tr.clickable:hover td { background: transparent; }
}

/* charts */
.equity-svg { width: 100%; height: 220px; display: block; }
.trade-svg { width: 100%; height: 300px; display: block; }
.eq-line-gain { fill: none; stroke: var(--gain); stroke-width: 2; }
.eq-line-loss { fill: none; stroke: var(--loss); stroke-width: 2; }
.eq-area-gain { fill: color-mix(in srgb, var(--gain) 12%, transparent); }
.eq-area-loss { fill: color-mix(in srgb, var(--loss) 12%, transparent); }

/* notification feed */
.feed { display: grid; gap: 10px; }
.feed-item { border: 1px solid var(--line); border-left: 4px solid var(--line-2); border-radius: 10px; padding: 12px 14px; background: var(--panel); display: grid; gap: 8px; }
.feed-item.unread { box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 45%, transparent); }
.feed-item.sev-success { border-left-color: var(--gain); }
.feed-item.sev-warning { border-left-color: var(--research); }
.feed-item.sev-critical { border-left-color: var(--loss); }
.feed-item.sev-info { border-left-color: var(--accent); }
.feed-meta { font-family: var(--font-mono); font-size: 12px; color: var(--muted); }
.feed-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* content */
.content-grid { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 16px; align-items: start; }
.content-list { display: grid; gap: 4px; }
.content-list a { padding: 8px 12px; border-radius: 8px; color: var(--text-2); text-decoration: none; font-size: 14px; border: 1px solid transparent; }
.content-list a:hover { border-color: var(--line-2); }
.content-list a.active { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--text); font-weight: 600; }
.content-body { padding: 18px 20px; display: grid; gap: 14px; color: var(--text); }
@media (max-width: 800px) { .content-grid { grid-template-columns: minmax(0, 1fr); } }

/* forms */
.form { display: grid; gap: 14px; }
.form label { display: grid; gap: 6px; font-size: 14px; color: var(--text-2); }
.form input, .form select { font: inherit; font-size: 15px; color: var(--text); background: var(--ground-2); border: 1px solid var(--line-2); border-radius: 8px; padding: 11px 12px; width: 100%; }
.form input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.form-inline { grid-template-columns: minmax(0, 220px) auto; align-items: end; }
.form-inline .form-error { grid-column: 1 / -1; }
.form-error { color: var(--loss); font-size: 14px; white-space: pre-line; }
.btn[disabled] { opacity: 0.6; cursor: progress; }

/* auth */
.auth-wrap { display: grid; place-items: center; padding-block: 24px 48px; }
.auth-card { width: min(460px, 100%); padding: 28px; display: grid; gap: 16px; }
.auth-card h1 { font-size: 26px; letter-spacing: -0.02em; }
.auth-links { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px; font-size: 14px; }

/* two-factor */
.totp-grid { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 20px; align-items: start; }
.totp-grid .qr { background: #fff; border-radius: 10px; padding: 8px; }
.totp-grid .qr svg { display: block; width: 100%; height: auto; }
@media (max-width: 600px) { .totp-grid { grid-template-columns: minmax(0, 1fr); } .totp-grid .qr { max-width: 220px; } }

/* modal and toasts */
#modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 16px; }
#modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(3, 6, 12, 0.66); }
.modal { position: relative; width: min(480px, 100%); padding: 22px; display: grid; gap: 14px; box-shadow: var(--shadow); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 70; display: grid; gap: 10px; width: min(380px, calc(100vw - 32px)); }
.toast { padding: 12px 14px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line-2); box-shadow: var(--shadow); white-space: pre-line; font-size: 14px; }
.toast-success { border-color: color-mix(in srgb, var(--gain) 60%, transparent); }
.toast-warning { border-color: color-mix(in srgb, var(--research) 60%, transparent); }
.toast-error { border-color: color-mix(in srgb, var(--loss) 60%, transparent); }

/* dashboard: connect Telegram */
.tg-card { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px 20px; padding: 16px 18px;
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 14%, var(--panel)), var(--panel) 75%); }
.tg-card-text { display: grid; gap: 4px; flex: 1 1 320px; min-width: 0; }
.tg-card-text h3 { font-size: 17px; }
.tg-card-text p { color: var(--text-2); font-size: 14.5px; line-height: 1.5; }
@media (max-width: 520px) { .tg-card .btn { width: 100%; } }
.tg-link-grid { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 18px; align-items: start; }
.tg-link-grid .qr { background: #fff; border-radius: 10px; padding: 8px; }
.tg-link-grid .qr svg { display: block; width: 100%; height: auto; }
.tg-link-steps { display: grid; gap: 12px; justify-items: start; }
@media (max-width: 520px) { .tg-link-grid { grid-template-columns: minmax(0, 1fr); } .tg-link-grid .qr { max-width: 200px; } .tg-link-steps .btn { width: 100%; } }
