: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 */
    --max-width: 1200px;
    --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 Browser Overrides */
* {
    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;
    /* Ensure global text wrapping */
    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);
}

.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 24px;
}

@media (max-width: 768px) {
    .container {
        padding: 16px;
    }
}

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

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

/* 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;
}

/* Cards & Panels */
.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 Component */
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;
    /* Prevent title wrapping */
}

@media (max-width: 480px) {
    .logo {
        font-size: 14px;
        /* Smaller font on very small screens */
    }

    .btn-sm {
        padding: 4px 6px;
        font-size: 11px;
    }
}

/* Stats Display */
.stats-banner {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

.stat-item {
    padding: 12px;
    text-align: center;
    border-right: 1px solid var(--border-soft);
}

.stat-item:last-child {
    border-right: none;
}

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

.stat-value {
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -0.2px;
}

.summary-bar {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    background-color: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 16px;
    border: 1px solid var(--border-soft);
}

.summary-item {
    text-align: center;
    border-right: 1px solid var(--border-soft);
}

.summary-item:last-child {
    border-right: none;
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

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

    .stats-banner,
    .summary-bar {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 576px) {

    .stats-banner,
    .summary-bar {
        grid-template-columns: repeat(2, 1fr);
        /* 2x2 layout */
        gap: 0;
    }

    .stat-item,
    .summary-item {
        border-right: 1px solid var(--border-soft);
        border-bottom: 1px solid var(--border-soft);
        padding: 12px 0;
    }

    /* Target every 2nd item to remove right border in 2x2 grid */
    .stat-item:nth-child(2n),
    .summary-item:nth-child(2n) {
        border-right: none;
    }

    /* Target last two items to remove bottom border in 2x2 grid */
    .stat-item:nth-child(n+3),
    .summary-item:nth-child(n+3) {
        border-bottom: none;
    }

    .stat-value {
        font-size: 16px;
        /* Slightly smaller for mobile grid */
    }
}

/* Price Panel */
.price-display {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    height: 100%;
}

.price-card {
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 12px 8px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: var(--radius-md);
    min-width: 0;
    /* Allow shrinking */
}

.price-current {
    font-size: 24px;
    font-weight: 700;
    margin: 4px 0;
    transition: color 0.3s;
    word-break: break-all;
}

@media (max-width: 480px) {
    .price-current {
        font-size: 18px;
    }

    .price-meta {
        font-size: 10px;
    }
}

.price-meta {
    font-size: 12px;
    color: var(--text-muted);
}

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

.log-console {
    background-color: #000;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    height: 200px;
    overflow-y: auto;
    overflow-x: hidden;
    /* Prevent horizontal stretching */
    padding: 12px;
    font-family: inherit;
    font-size: 12px;
    border: 1px solid var(--border-color);
    border-bottom: none;
}

.status-bar {
    background-color: var(--bg-secondary);
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.log-entry {
    margin-bottom: 4px;
    padding-bottom: 2px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    white-space: pre-wrap;
    /* Enable text wrapping for logs */
    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 Styles */
.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);
}

@media (max-width: 768px) {
    /* Hide specific columns on mobile to save space */
    /* Table Columns: 1.时间 2.币种 3.方向 4.胜率 5.入场 6.结算 7.结果 8.盈亏 */
    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;
        /* Balanced padding */
        font-size: 12px;
        text-align: left;
        /* Better readability */
    }

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

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

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

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

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

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

    /* Profit */
}

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

/* Status 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);
}

/* Forms & Settings */
.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;
    }
}

/* 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);
}

/* 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;
}