:root {
    /* Binance Color Palette */
    --bg-main: #0b0e11;
    --bg-card: #1e2329;
    --bg-secondary: #2b3139;
    --primary: #fcd535;
    --primary-hover: #f0b90b;
    --success: #0ecb81;
    --danger: #f6465d;
    --text-primary: #eaecef;
    --text-muted: #848e9c;
    --text-on-primary: #181a20;
    --border-color: #474d57;
    --border-soft: rgba(71, 77, 87, 0.4);

    /* Layout */
    --content-width: 800px;
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5);
}

/* ==================== Global ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: "PingFang SC", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

.monospace {
    font-family: "IBM Plex Mono", "SF Mono", "Fira Code", monospace;
}

/* ==================== Layout Containers ==================== */

/* settings 页面使用的 container（也是全局默认） */
.container {
    max-width: var(--content-width);
    margin: 0 auto;
    padding: 24px;
}

/* 首页使用的 container — 与 settings 统一宽度 */
.index-container {
    max-width: var(--content-width);
    margin: 0 auto;
    padding: 24px;
}

@media (max-width: 768px) {

    .container,
    .index-container {
        padding: 16px;
    }
}

/* ==================== Typography ==================== */
h1,
h2,
h3 {
    font-weight: 600;
}

/* ==================== Buttons ==================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border: none;
    outline: none;
    font-size: 14px;
    text-decoration: none;
}

.btn-primary {
    background-color: var(--primary);
    color: var(--text-on-primary);
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
}

.btn-secondary {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background-color: #3b424a;
    border-color: var(--text-muted);
}

.btn-danger {
    background-color: rgba(246, 70, 93, 0.1);
    color: var(--danger);
    border: 1px solid var(--danger);
}

.btn-danger:hover {
    background-color: var(--danger);
    color: white;
}

.btn-sm {
    padding: 4px 8px;
    font-size: 12px;
}

/* 币种切换按钮组 */
.btn-group {
    display: inline-flex;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border-color);
}
.btn-coin {
    background: var(--bg-secondary);
    color: var(--text-muted);
    border: none;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}
.btn-coin:hover {
    background: var(--border-color);
    color: var(--text-primary);
}
.btn-coin.active {
    background: var(--primary);
    color: var(--text-on-primary);
}

@media (max-width: 480px) {
    .btn-sm {
        padding: 4px 6px;
        font-size: 11px;
    }
}

/* ==================== Cards ==================== */
.card {
    background-color: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 20px;
    border: 1px solid var(--border-soft);
    box-shadow: var(--shadow-sm);
    transition: border-color 0.2s;
}

.card:hover {
    border-color: var(--border-color);
}

.mb-3 {
    margin-bottom: 16px;
}

.mb-4 {
    margin-bottom: 24px;
}

/* ==================== Header ==================== */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 16px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border-soft);
    gap: 12px;
}

.logo {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

@media (max-width: 480px) {
    .logo {
        font-size: 14px;
    }
}

/* ==================== Shared Labels ==================== */
.stat-label {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ==================== Index: Top Section Layout ==================== */
.top-grid {
    display: block;
}

@media (max-width: 768px) {
    .top-grid {
        grid-template-columns: 1fr;
    }
}

/* ==================== Index: Price Cards ==================== */
.price-pair {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.price-box {
    text-align: center;
    padding: 16px 12px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: var(--radius-md);
}

.price-box .price-value {
    font-size: 28px;
    font-weight: 700;
    margin: 6px 0 4px;
    transition: color 0.3s;
    word-break: break-all;
}

.price-box .price-sub {
    font-size: 11px;
    color: var(--text-muted);
}

.price-box .martin-tag {
    display: inline-block;
    margin-top: 8px;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    background: rgba(252, 213, 53, 0.08);
    color: var(--primary);
    font-family: "IBM Plex Mono", monospace;
}

@media (max-width: 480px) {
    .price-box .price-value {
        font-size: 17px;
    }
}

/* ==================== Index: Stats Panels ==================== */
.stats-panel {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0;
}

.stats-panel .sp-item {
    text-align: center;
    padding: 14px 8px;
    border-right: 1px solid var(--border-soft);
}

.stats-panel .sp-item:last-child {
    border-right: none;
}

.stats-panel .sp-label {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.stats-panel .sp-value {
    font-size: 15px;
    font-weight: 600;
    font-family: "IBM Plex Mono", monospace;
}

@media (max-width: 480px) {
    .stats-panel .sp-value {
        font-size: 13px;
    }

    .stats-panel .sp-item {
        padding: 10px 4px;
    }
}

/* ==================== Log Console ==================== */
.log-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.log-console {
    height: 200px;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px;
    font-family: inherit;
    font-size: 12px;
    border-bottom: none;
}

.status-bar {
    padding: 8px 12px;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}

.log-entry {
    margin-bottom: 4px;
    padding-bottom: 2px;
    white-space: pre-wrap;
    word-break: break-all;
}

.log-type-info {
    color: var(--text-muted);
}

.log-type-success {
    color: var(--success);
}

.log-type-danger {
    color: var(--danger);
}

.log-type-warning {
    color: var(--primary);
}

.log-type-system {
    color: #3b82f6;
}

/* ==================== Table ==================== */
.table-container {
    overflow-x: auto;
    margin-top: 12px;
}

table {
    width: 100%;
    border-collapse: collapse;
    white-space: nowrap;
}

th {
    text-align: left;
    padding: 12px 16px;
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
    border-bottom: 1px solid var(--border-soft);
}

td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-soft);
}

tr:hover td {
    background-color: rgba(255, 255, 255, 0.02);
}

@media (max-width: 768px) {

    /* 移动端隐藏入场价和结算价列 */
    th:nth-child(5),
    td:nth-child(5),
    th:nth-child(6),
    td:nth-child(6) {
        display: none;
    }

    table {
        table-layout: fixed;
        width: 100%;
    }

    th,
    td {
        padding: 12px 4px;
        font-size: 12px;
        text-align: left;
    }

    th:nth-child(1),
    td:nth-child(1) {
        width: 65px;
    }

    th:nth-child(2),
    td:nth-child(2) {
        width: 40px;
    }

    th:nth-child(3),
    td:nth-child(3) {
        width: 30px;
    }

    th:nth-child(4),
    td:nth-child(4) {
        width: 38px;
    }

    th:nth-child(7),
    td:nth-child(7) {
        width: 55px;
    }

    th:nth-child(8),
    td:nth-child(8) {
        width: 55px;
    }
}

/* ==================== Badges ==================== */
.badge {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.badge-yes {
    color: var(--success);
    background: rgba(14, 203, 129, 0.1);
}

.badge-no {
    color: var(--danger);
    background: rgba(246, 70, 93, 0.1);
}

.badge-pending {
    color: var(--text-muted);
    background: rgba(132, 142, 156, 0.1);
}

/* ==================== Settings Page ==================== */
.settings-section {
    max-width: 800px;
    margin: 0 auto;
}

.form-group {
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-size: 13px;
    color: var(--text-muted);
}

input[type="text"],
input[type="number"],
input[type="password"],
input[type="date"],
select {
    width: 100%;
    background-color: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.2s;
}

input:focus {
    border-color: var(--primary);
}

.grid-2,
.grid-3 {
    display: grid;
    gap: 20px;
}

.grid-2 {
    grid-template-columns: 1fr 1fr;
}

.grid-3 {
    grid-template-columns: 1fr 1fr 1fr;
}

@media (max-width: 768px) {

    .grid-2,
    .grid-3 {
        grid-template-columns: 1fr;
    }
}

/* Toggle Switch */
.switch-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 22px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--bg-secondary);
    transition: .4s;
    border-radius: 34px;
    border: 1px solid var(--border-color);
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 2px;
    bottom: 2px;
    background-color: var(--text-muted);
    transition: .4s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: var(--success);
    border-color: var(--success);
}

input:checked+.slider:before {
    transform: translateX(22px);
    background-color: white;
}

/* Hibt Status Box */
.hibt-status-card {
    background: rgba(0, 0, 0, 0.2);
    padding: 16px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.status-online {
    background-color: var(--success);
    box-shadow: 0 0 8px var(--success);
}

.status-offline {
    background-color: var(--danger);
    box-shadow: 0 0 8px var(--danger);
}

/* Settings Section Title */
.settings-section-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.settings-section-title::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--border-soft);
}

/* ==================== Animation ==================== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.card {
    animation: fadeIn 0.4s ease-out backwards;
}

.card:nth-child(2) {
    animation-delay: 0.1s;
}

.card:nth-child(3) {
    animation-delay: 0.2s;
}

.card:nth-child(4) {
    animation-delay: 0.3s;
}