:root {
    --bg: #0b1118;
    --chart: #0e1620;
    --side: #101923;
    --card: #151f2b;
    --card-2: #18232f;
    --border: #243143;
    --grid: #1b2734;
    --text: #e8eef5;
    --muted: #8496a9;
    --faint: #56677a;
    --up: #f0545e;
    --down: #20b486;
    --cyan: #4cc9f0;
    --amber: #f4c95d;
    --purple: #b388ff;
    --shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
    --radius: 14px;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    min-height: 100%;
}

body {
    background:
        radial-gradient(circle at 18% 0%, rgba(76, 201, 240, 0.06), transparent 32%),
        radial-gradient(circle at 90% 10%, rgba(179, 136, 255, 0.05), transparent 28%),
        var(--bg);
    color: var(--text);
    font-family: "Microsoft YaHei UI", "Microsoft YaHei", "Segoe UI", sans-serif;
    font-size: 13px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

button, input {
    font: inherit;
}

a {
    color: var(--cyan);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.mono {
    font-family: Consolas, "SFMono-Regular", monospace;
}

.muted {
    color: var(--muted);
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
    padding: 0 24px;
    background: rgba(11, 17, 24, 0.88);
    border-bottom: 1px solid rgba(36, 49, 67, 0.8);
    backdrop-filter: blur(14px);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 9px;
    background: linear-gradient(145deg, #1b7f9f, #4cc9f0);
    color: #06131b;
    font-family: Consolas, monospace;
    font-size: 19px;
    font-weight: 800;
    box-shadow: 0 0 24px rgba(76, 201, 240, 0.2);
}

.brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.brand-text strong {
    font-size: 14px;
    letter-spacing: 0.18em;
}

.brand-text small {
    margin-top: 3px;
    color: var(--faint);
    font-size: 9px;
    letter-spacing: 0.12em;
}

.top-meta {
    display: flex;
    align-items: center;
    gap: 14px;
    color: var(--muted);
    font-size: 11px;
}

.health-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--amber);
    box-shadow: 0 0 0 4px rgba(244, 201, 93, 0.08);
}

.health-dot.online {
    background: var(--down);
    box-shadow: 0 0 0 4px rgba(32, 180, 134, 0.1);
}

.health-dot.offline {
    background: var(--up);
    box-shadow: 0 0 0 4px rgba(240, 84, 94, 0.1);
}

.layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 356px;
    gap: 18px;
    width: min(1600px, 100%);
    margin: 18px auto 0;
    padding: 0 18px 54px;
}

.chart-card,
.panel-card {
    border: 1px solid var(--border);
    background: linear-gradient(180deg, rgba(21, 31, 43, 0.96), rgba(14, 22, 32, 0.98));
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.chart-card {
    display: flex;
    flex-direction: column;
    min-height: 700px;
    overflow: hidden;
}

.chart-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 18px 20px 0;
}

.chart-title {
    display: flex;
    align-items: center;
    gap: 9px;
}

.symbol {
    font-size: 18px;
    font-weight: 800;
    letter-spacing: 0.02em;
}

.sim-select {
    max-width: 240px;
    height: 30px;
    padding: 0 26px 0 8px;
    border: 1px solid transparent;
    border-radius: 7px;
    background: transparent;
    color: var(--text);
    font-size: 18px;
    font-weight: 800;
    cursor: pointer;
    outline: none;
}

.sim-select:hover,
.sim-select:focus {
    border-color: var(--border);
    background: var(--card);
}

.sim-select option,
.select option {
    background: var(--card);
    color: var(--text);
}

.timeframe-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 5px;
    margin-top: 4px;
}

.tf-btn {
    height: 27px;
    padding: 0 4px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: rgba(11, 17, 24, 0.35);
    color: var(--muted);
    font-family: Consolas, monospace;
    font-size: 9.5px;
    cursor: pointer;
}

.tf-btn:hover {
    border-color: #3a4d63;
    color: var(--text);
}

.tf-btn.active {
    border-color: rgba(76, 201, 240, 0.45);
    background: rgba(76, 201, 240, 0.1);
    color: var(--cyan);
}

.inline-row {
    display: flex;
    gap: 7px;
    margin-bottom: 4px;
}

.text-input {
    min-width: 0;
    flex: 1;
    height: 32px;
    padding: 0 9px;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: rgba(11, 17, 24, 0.35);
    color: var(--text);
    font-size: 11px;
    outline: none;
}

.text-input:focus {
    border-color: rgba(76, 201, 240, 0.5);
}

.period-title {
    margin-top: 13px;
    margin-bottom: 5px;
}

.timeframe {
    display: inline-flex;
    align-items: center;
    height: 21px;
    padding: 0 8px;
    border: 1px solid rgba(76, 201, 240, 0.35);
    border-radius: 10px;
    background: rgba(76, 201, 240, 0.08);
    color: var(--cyan);
    font-size: 9px;
    font-weight: 700;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    height: 21px;
    padding: 0 9px;
    border-radius: 10px;
    background: rgba(132, 150, 169, 0.1);
    color: var(--muted);
    font-size: 9px;
    font-weight: 700;
}

.status-badge.running {
    background: rgba(32, 180, 134, 0.1);
    color: var(--down);
}

.status-badge.paused {
    background: rgba(244, 201, 93, 0.1);
    color: var(--amber);
}

.status-badge.stopped {
    background: rgba(240, 84, 94, 0.1);
    color: var(--up);
}

.price-block {
    display: flex;
    align-items: baseline;
    gap: 10px;
    text-align: right;
}

.last-price {
    font-family: Consolas, monospace;
    font-size: 28px;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.last-change {
    font-family: Consolas, monospace;
    font-size: 12px;
    font-weight: 700;
}

.up-text {
    color: var(--up);
}

.down-text {
    color: var(--down);
}

.chart-wrap {
    position: relative;
    flex: 1;
    min-height: 520px;
    margin: 8px 8px 0;
}

#chart {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    min-height: 520px;
}

.empty {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    color: var(--faint);
    font-size: 13px;
    pointer-events: none;
}

.ohlc {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 16px;
    min-height: 30px;
    margin: 0 20px;
    padding: 10px 0 13px;
    border-top: 1px solid rgba(36, 49, 67, 0.65);
    color: var(--muted);
    font-family: Consolas, monospace;
    font-size: 10.5px;
}

.ohlc .label {
    color: var(--faint);
    font-family: "Microsoft YaHei UI", sans-serif;
    font-size: 9.5px;
    margin-right: 3px;
}

.side {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 0;
}

.panel-card {
    padding: 15px 16px;
}

.card-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
    color: var(--text);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.hint {
    color: var(--faint);
    font-size: 9px;
    font-weight: 400;
    letter-spacing: 0;
}

.pill-row {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.pill {
    display: inline-flex;
    align-items: center;
    height: 23px;
    padding: 0 9px;
    border-radius: 12px;
    background: rgba(132, 150, 169, 0.12);
    color: var(--muted);
    font-size: 10px;
    font-weight: 700;
}

.pill.running {
    background: rgba(32, 180, 134, 0.1);
    color: var(--down);
}

.pill.paused {
    background: rgba(244, 201, 93, 0.1);
    color: var(--amber);
}

.pill.stopped {
    background: rgba(240, 84, 94, 0.1);
    color: var(--up);
}

.pill.up {
    background: rgba(240, 84, 94, 0.1);
    color: var(--up);
}

.pill.down {
    background: rgba(32, 180, 134, 0.1);
    color: var(--down);
}

.stat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 12px;
}

.stat-grid div {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 7px;
    background: rgba(11, 17, 24, 0.36);
}

.stat-grid span {
    color: var(--muted);
    font-size: 9.5px;
}

.stat-grid b {
    overflow: hidden;
    color: var(--text);
    font-family: Consolas, monospace;
    font-size: 11px;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.mini-note {
    margin-top: 10px;
    color: var(--faint);
    font-size: 9px;
    line-height: 1.5;
}

.button-grid {
    display: grid;
    gap: 7px;
}

.button-grid.four {
    grid-template-columns: repeat(4, 1fr);
    margin-bottom: 7px;
}

.btn {
    height: 34px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--card-2);
    color: var(--text);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.08s ease;
}

.btn:hover {
    border-color: #3a4d63;
    background: #1d2b3a;
}

.btn:active {
    transform: translateY(1px);
}

.btn:disabled {
    cursor: not-allowed;
    opacity: 0.4;
}

.btn.wide {
    width: 100%;
    margin-top: 7px;
}

.btn.ghost {
    color: var(--muted);
    background: transparent;
}

.btn.flat {
    margin-top: 7px;
    color: var(--muted);
    background: #1b2836;
}

.btn.cyan {
    border-color: rgba(76, 201, 240, 0.36);
    background: rgba(76, 201, 240, 0.08);
    color: var(--cyan);
}

.btn.danger {
    color: var(--up);
}

.trend-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.trend {
    height: 48px;
    border: 1px solid transparent;
    border-radius: 9px;
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: filter 0.15s ease, transform 0.08s ease;
}

.trend:hover {
    filter: brightness(1.12);
}

.trend:active {
    transform: translateY(1px);
}

.trend.up {
    background: linear-gradient(145deg, #f0545e, #c7353f);
    box-shadow: 0 8px 20px rgba(240, 84, 94, 0.16);
}

.trend.down {
    background: linear-gradient(145deg, #20b486, #148866);
    box-shadow: 0 8px 20px rgba(32, 180, 134, 0.14);
}

.slider-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 14px 0 3px;
    color: var(--muted);
    font-size: 10px;
}

.slider-label b {
    color: var(--cyan);
    font-family: Consolas, monospace;
    font-size: 10px;
}

.slider {
    display: block;
    width: 100%;
    height: 18px;
    margin: 0;
    background: transparent;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
}

.slider::-webkit-slider-runnable-track {
    height: 4px;
    border-radius: 4px;
    background: #263442;
}

.slider::-webkit-slider-thumb {
    width: 14px;
    height: 14px;
    margin-top: -5px;
    border: 3px solid var(--card);
    border-radius: 50%;
    background: var(--cyan);
    box-shadow: 0 0 0 3px rgba(76, 201, 240, 0.14);
    appearance: none;
    -webkit-appearance: none;
}

.slider::-moz-range-track {
    height: 4px;
    border-radius: 4px;
    background: #263442;
}

.slider::-moz-range-thumb {
    width: 12px;
    height: 12px;
    border: 3px solid var(--card);
    border-radius: 50%;
    background: var(--cyan);
}

.feed {
    display: flex;
    flex-direction: column;
    gap: 5px;
    max-height: 150px;
    overflow: auto;
}

.feed-empty {
    color: var(--faint);
    font-size: 10px;
}

.feed-row {
    display: grid;
    grid-template-columns: 38px 1fr auto;
    align-items: center;
    gap: 8px;
    padding: 5px 7px;
    border-radius: 6px;
    background: rgba(11, 17, 24, 0.36);
    font-family: Consolas, monospace;
    font-size: 9.5px;
}

.feed-side {
    font-weight: 700;
}

.feed-side.buy {
    color: var(--up);
}

.feed-side.sell {
    color: var(--down);
}

.feed-price {
    color: var(--text);
}

.feed-qty {
    color: var(--muted);
    text-align: right;
}

.commands {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 130px;
    overflow: auto;
}

.cmd-row {
    display: grid;
    grid-template-columns: 34px 1fr auto;
    align-items: center;
    gap: 8px;
    padding: 4px 6px;
    border-radius: 5px;
    background: rgba(11, 17, 24, 0.3);
    font-family: Consolas, monospace;
    font-size: 9px;
    color: var(--muted);
}

.cmd-type {
    color: var(--text);
}

.cmd-status {
    font-size: 8.5px;
    font-weight: 700;
}

.cmd-status.PROCESSED {
    color: var(--down);
}

.cmd-status.PENDING {
    color: var(--amber);
}

.cmd-status.FAILED {
    color: var(--up);
}

.footer {
    display: flex;
    flex-wrap: wrap;
    gap: 18px;
    width: min(1600px, 100%);
    margin: 0 auto;
    padding: 0 20px 24px;
    color: var(--faint);
    font-size: 9.5px;
}

.footer a {
    color: var(--muted);
}

.footer-right {
    margin-left: auto;
}

.toast {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 50;
    max-width: 360px;
    padding: 10px 14px;
    border: 1px solid rgba(76, 201, 240, 0.3);
    border-radius: 9px;
    background: rgba(21, 31, 43, 0.97);
    color: var(--text);
    box-shadow: var(--shadow);
    font-size: 11px;
    opacity: 0;
    transform: translateY(8px);
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast.error {
    border-color: rgba(240, 84, 94, 0.4);
    color: #ffb8bc;
}

@media (max-width: 1080px) {
    .layout {
        grid-template-columns: minmax(0, 1fr);
    }

    .side {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .chart-card {
        min-height: 620px;
    }
}

@media (max-width: 720px) {
    .topbar {
        padding: 0 14px;
    }

    .top-meta {
        gap: 8px;
        font-size: 9.5px;
    }

    .layout {
        padding: 0 10px 40px;
        margin-top: 10px;
    }

    .side {
        display: flex;
    }

    .chart-head {
        padding: 14px 14px 0;
    }

    .last-price {
        font-size: 22px;
    }

    .ohlc {
        margin: 0 14px;
    }

    .footer {
        padding: 0 14px 20px;
    }

    .footer-right {
        margin-left: 0;
    }
}
