/* Exchanges console — flat sortable table (default) + calm card grid.
   Colour carries meaning ONLY (green/red = money, one accent per venue type);
   everything else is a grayscale typographic scale on hairline surfaces.
   Scoped to .ex-page so the shared tables.css stays untouched. */

.ex-page { display: flex; flex-direction: column; gap: 0; }
.ex-body { margin-top: 4px; }

/* KPI ribbon — flatten the shared gradient/blur/shadow on this page only. */
.ex-page .kpi-ribbon {
    background: var(--panel);
    box-shadow: none;
    backdrop-filter: none;
}
.ex-kpi { grid-auto-columns: minmax(150px, 1fr); }
.ex-page .kpi-ribbon .kr-value { font-size: 17px; font-weight: 600; }

/* ───────────────────────────────────────── Venue identity: monogram + icons */
.ex-id { display: flex; align-items: center; gap: 10px; min-width: 0; }
.ex-mono {
    flex: 0 0 auto;
    width: 30px; height: 30px;
    border-radius: 7px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 14px; font-weight: 700;
    color: var(--text-secondary);
    background: var(--panel-2);
    border: 1px solid var(--border);
    letter-spacing: 0;
}
.ex-mono.t-crypto         { color: var(--accent); border-color: rgba(99,102,241,0.45); background: rgba(99,102,241,0.08); }
.ex-mono.t-forex          { color: var(--green);  border-color: rgba(34,197,94,0.40);  background: rgba(34,197,94,0.07); }
.ex-mono.t-us_futures     { color: var(--yellow); border-color: rgba(250,204,21,0.40); background: rgba(250,204,21,0.07); }
.ex-mono.t-vn_derivatives { color: var(--red);    border-color: rgba(239,68,68,0.40);  background: rgba(239,68,68,0.07); }

.ex-id-txt { min-width: 0; }
.ex-id-txt .sym { font-weight: 700; color: var(--text-primary); font-size: 13px; }
.ex-id-txt .sym:hover { color: var(--accent); }
.ex-sub {
    font-size: 10px; color: var(--text-muted); margin-top: 1px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ex-testnet {
    color: var(--yellow); font-weight: 700; letter-spacing: 0.05em; font-size: 9px;
}

/* Type tag — small stroke icon + neutral label; colour only on the glyph. */
.type-tag {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: 11px; font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
}
.type-tag.t-crypto .ti         { color: var(--accent); }
.type-tag.t-forex .ti          { color: var(--green); }
.type-tag.t-us_futures .ti     { color: var(--yellow); }
.type-tag.t-vn_derivatives .ti { color: var(--red); }
.ti, .ki {
    width: 15px; height: 15px; flex: 0 0 auto;
    fill: none; stroke: currentColor; stroke-width: 1.4;
    stroke-linecap: round; stroke-linejoin: round;
    vertical-align: middle;
}

/* API-key state — key glyph lit when a credential is present. */
.api-state {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums;
}
.api-state.on  { color: var(--text-secondary); }
.api-state.on .ki { color: var(--green); }
.api-state.off { color: var(--text-muted); }
.api-state.off .ki { color: var(--border); }

/* Status — dot + label */
.ex-page .st {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 11px; color: var(--text-secondary);
}
.ex-page .st .dot {
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--text-muted); flex: 0 0 auto;
}
.ex-page .st .dot.d-on  { background: var(--green); }
.ex-page .st .dot.d-off { background: var(--text-muted); }

/* Pool cell — value + thin live/dry capacity track */
.ex-pool { display: inline-flex; flex-direction: column; gap: 4px; align-items: flex-end; min-width: 96px; }
.ex-pool .pool-v { font-weight: 600; color: var(--text-primary); font-variant-numeric: tabular-nums; }
.ex-page .capacity-bar {
    width: 96px; height: 4px; border-radius: 2px;
    background: var(--bg-tertiary); overflow: hidden;
    display: inline-flex;
}
.ex-page .capacity-bar > span { display: block; height: 100%; }
.ex-page .capacity-bar .seg-live { background: var(--accent); }
.ex-page .capacity-bar .seg-dry  { background: var(--text-muted); }
.iu { font-variant-numeric: tabular-nums; }

/* ───────────────────────────────────────── Table view */
.panel-ex-table {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
}
.panel-ex-table .panel-body {
    max-height: calc(100vh - 300px);
    overflow-y: auto;
    overflow-x: auto;
}
.ex-table { width: 100%; border-collapse: collapse; }
.ex-table thead th {
    position: sticky; top: 0; z-index: 2;
    background: var(--panel-2);
    font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em;
    color: var(--text-muted); font-weight: 700;
    padding: 9px 11px; white-space: nowrap;
    border-bottom: 1px solid var(--border);
    text-align: left;
}
.ex-table thead th.num { text-align: right; }
.ex-table thead th.sortable { cursor: pointer; user-select: none; }
.ex-table thead th.sortable:hover { color: var(--text-secondary); }
.ex-table thead th.is-sorted { color: var(--text-primary); }
.ex-table thead th .sort-arrow { font-size: 8px; margin-left: 3px; }
.ex-table tbody td {
    padding: 8px 11px; font-size: 12px; vertical-align: middle;
    border-bottom: 1px solid var(--border-soft);
}
.ex-table tbody tr:hover td { background: var(--panel-2); }
.ex-table tbody tr.is-dimmed { opacity: 0.45; }
.ex-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.ex-table .pos { color: var(--green); }
.ex-table .neg { color: var(--red); }
.ex-table .flat, .ex-table .t-dim { color: var(--text-muted); }
.ex-table td i { font-style: normal; color: var(--text-muted); font-size: 10px; }
.ex-table .open-live { color: var(--text-primary); font-weight: 600; }
.ex-table .m-live { color: var(--live); }
.ex-table .m-dry  { color: var(--dry); }
.ex-table .row-actions { display: flex; gap: 5px; flex-wrap: nowrap; }
.ex-page .pc-del {
    color: var(--text-muted); border-color: var(--border-soft);
    padding-left: 9px; padding-right: 9px;
}
.ex-page .pc-del:hover {
    color: var(--red); border-color: var(--red);
    background: rgba(239,68,68,0.10);
}

/* ───────────────────────────────────────── Card view (secondary) */
.ex-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 10px;
}
.ex-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 9px;
    padding: 12px 13px;
    display: flex; flex-direction: column; gap: 10px;
    transition: border-color 0.12s ease, background 0.12s ease;
}
.ex-card:hover { border-color: #3a3c54; background: var(--panel-2); }
.ex-card.is-inactive { opacity: 0.5; }
.ex-card.is-inactive:hover { opacity: 0.85; }
.ex-card .ec-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.ex-card .ec-badges { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; flex: 0 0 auto; }

.ex-card .ec-pool {
    display: flex; flex-direction: column; gap: 6px;
    background: var(--panel-2);
    border: 1px solid var(--border-soft);
    border-radius: 6px;
    padding: 8px 10px;
}
.ex-card .ec-pool .ex-pool { align-items: stretch; min-width: 0; }
.ex-card .ec-pool .ex-pool .pool-v { font-size: 15px; }
.ex-card .ec-pool .capacity-bar { width: 100%; }
.ex-card .ec-pool-meta {
    display: flex; flex-wrap: wrap; gap: 3px 12px;
    font-size: 10px; color: var(--text-muted); font-variant-numeric: tabular-nums;
}
.ex-card .ec-pool-meta .m-live { color: var(--live); }
.ex-card .ec-pool-meta .m-dry  { color: var(--dry); }

.ex-card .ec-stats {
    display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px;
}
.ex-card .ec-stats .m { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.ex-card .ec-stats .k {
    font-size: 9px; color: var(--text-muted); letter-spacing: 0.05em;
    text-transform: uppercase; font-weight: 600;
}
.ex-card .ec-stats .v {
    font-size: 13px; color: var(--text-primary); font-weight: 600;
    font-variant-numeric: tabular-nums;
}
.ex-card .ec-stats .v i { font-style: normal; font-weight: 400; font-size: 10px; color: var(--text-muted); }
.ex-card .ec-stats .v.pos { color: var(--green); }
.ex-card .ec-stats .v.neg { color: var(--red); }
.ex-card .ec-stats .v.flat { color: var(--text-muted); }
.ex-card .ec-actions {
    display: flex; gap: 6px; flex-wrap: wrap;
    padding-top: 9px; margin-top: auto;
    border-top: 1px solid var(--border-soft);
}
.ex-card .ec-actions .pc-del { margin-left: auto; }

.inactive-tag {
    font-size: 9px; color: var(--text-muted); background: var(--bg-tertiary);
    padding: 1px 5px; border-radius: 3px; font-weight: 700;
    letter-spacing: 0.06em; text-transform: uppercase;
}

/* ───────────────────────────────────────── Live toggle (filter bar) */
.chip.live-toggle { display: inline-flex; align-items: center; gap: 6px; }
.chip.live-toggle .live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-muted); }
.chip.live-toggle.is-on .live-dot { background: var(--green); animation: exLivePulse 1.6s ease-in-out infinite; }
@keyframes exLivePulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }

/* ───────────────────────────────────────── KV editor (API endpoints) */
/* Inherits the legacy ``.kv-editor`` markup so existing app.css rules
   still apply; this file just polishes the row layout. */
.kv-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 6px;
}
.kv-row {
    display: grid;
    grid-template-columns: 220px 1fr auto;
    gap: 6px;
    align-items: center;
}
.kv-row input {
    background: var(--panel-2);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 5px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-family: monospace;
}
.kv-row input.kv-key { font-weight: 600; }
.kv-row .kv-remove {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
}
.kv-row .kv-remove:hover { color: var(--red); border-color: var(--red); }
.kv-empty {
    padding: 12px;
    color: var(--text-muted);
    font-style: italic;
    font-size: 12px;
    text-align: center;
    border: 1px dashed var(--border-soft);
    border-radius: 5px;
}
.kv-editor-toolbar {
    display: flex; align-items: center; gap: 6px;
    padding: 4px 0 6px;
    border-bottom: 1px solid var(--border-soft);
    flex-wrap: wrap;
}
.kv-spacer { flex: 1 1 auto; }
.kv-raw-wrap textarea {
    width: 100%;
    background: var(--panel-2);
    border: 1px solid var(--border);
    color: var(--text-primary);
    border-radius: 4px;
    padding: 8px 10px;
    font-family: monospace;
    font-size: 12px;
    min-height: 240px;
}
