:root {
    --fx-bg: #f4f6fb;
    --fx-panel: #ffffff;
    --fx-border: #d8deea;
    --fx-text: #162033;
    --fx-muted: #5b6780;
    --fx-brand: #0f6ad9;
    --fx-brand-soft: #e9f2ff;
    --fx-danger: #cf3f3f;
    --fx-success: #198754;
    --fx-warning: #b7791f;
}

html, body {
    font-family: "Microsoft YaHei", "Segoe UI", sans-serif;
    background: linear-gradient(180deg, #eef3fb 0%, #f9fbff 55%, #f4f6fb 100%);
    color: var(--fx-text);
}

body {
    margin: 0;
}

a, .btn-link {
    color: var(--fx-brand);
}

.shell {
    display: flex;
    min-height: 100vh;
    gap: 0;
    padding: 0;
    background:
        radial-gradient(circle at top left, rgba(47, 140, 255, .14), transparent 26%),
        radial-gradient(circle at bottom right, rgba(89, 208, 255, .12), transparent 28%),
        linear-gradient(180deg, #edf3fc 0%, #f7faff 100%);
}

.shell-sidebar {
    width: 280px;
    background: #10223f;
    color: #fff;
    padding: 24px 18px;
    border-radius: 0;
    box-shadow: inset -1px 0 0 rgba(255,255,255,.06);
    min-height: 100vh;
    flex: 0 0 280px;
}

.shell-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 100vh;
    background: #fff;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    overflow: hidden;
}

.shell-topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 24px;
    background: rgba(255,255,255,.8);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--fx-border);
    position: sticky;
    top: 0;
    z-index: 20;
}

.shell-content {
    padding: 24px;
    background: linear-gradient(180deg, #f8fbff 0%, #ffffff 32%);
    flex: 1;
}

.topbar-title {
    font-size: 1.2rem;
    font-weight: 700;
}

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

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 24px;
}

.brand-mark {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, #2f8cff, #59d0ff);
    color: white;
    font-weight: 800;
    letter-spacing: .06em;
}

.brand-mark.large {
    width: 60px;
    height: 60px;
    font-size: 1.2rem;
}

.brand-title {
    font-size: 1rem;
    font-weight: 700;
}

.brand-subtitle {
    font-size: .82rem;
    color: rgba(255,255,255,.65);
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nav-menu .nav-link {
    color: rgba(255,255,255,.85);
    border-radius: 12px;
    padding: 12px 14px;
    font-weight: 600;
}

.nav-menu .nav-link.active,
.nav-menu .nav-link:hover {
    color: white;
    background: rgba(255,255,255,.12);
}

.card, .panel {
    background: var(--fx-panel);
    border: 1px solid var(--fx-border);
    border-radius: 18px;
    box-shadow: 0 16px 50px rgba(17, 41, 78, .05);
}

.panel {
    padding: 20px;
}

.panel.hero-panel {
    background:
        radial-gradient(circle at top right, rgba(47, 140, 255, .12), transparent 32%),
        linear-gradient(180deg, rgba(255,255,255,.98), rgba(247,250,255,.96));
}

.panel-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.panel-title-row h5,
.panel-title-row h6 {
    margin: 0;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
}

.stat-card {
    padding: 16px 18px;
    border-radius: 18px;
    background: linear-gradient(180deg, #fff, #f7faff);
    border: 1px solid var(--fx-border);
}

.stat-card.compact {
    padding: 13px 15px;
}

.stat-label {
    color: var(--fx-muted);
    font-size: .85rem;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 1.6rem;
    font-weight: 800;
}

.status-chip {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: .8rem;
    font-weight: 700;
}

.status-ok {
    background: #e6f7ef;
    color: var(--fx-success);
}

.status-warn {
    background: #fff4e0;
    color: var(--fx-warning);
}

.status-bad {
    background: #ffe8e8;
    color: var(--fx-danger);
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: 999px;
    padding: 5px 10px;
    background: #edf4ff;
    color: #174d91;
    font-size: .82rem;
    font-weight: 700;
}

.chip-muted {
    background: #eef1f6;
    color: var(--fx-muted);
}

.chip-danger {
    background: #ffe8e8;
    color: var(--fx-danger);
}

.chip-success {
    background: #e6f7ef;
    color: var(--fx-success);
}

.resource-bar {
    width: 110px;
    height: 8px;
    border-radius: 999px;
    background: #e7edf7;
    overflow: hidden;
    margin-top: 5px;
}

.resource-bar > span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #2f8cff, #59d0ff);
}

.resource-bar.warn > span {
    background: linear-gradient(90deg, #f59e0b, #facc15);
}

.resource-bar.danger > span {
    background: linear-gradient(90deg, #ef4444, #fb7185);
}

.table-wrap {
    overflow: auto;
}

.mt4-table {
    min-width: 2000px;
    border-collapse: separate;
    border-spacing: 0;
}

.mt4-table .pin-col {
    position: sticky;
    z-index: 4;
    background: #fff;
    background-clip: padding-box;
}

.mt4-table thead .pin-col {
    z-index: 7;
    background: #f8fbff;
}

.mt4-table tbody tr:hover .pin-col {
    background: #f6faff;
}

.mt4-table .pin-select {
    left: 0;
    width: 46px;
    min-width: 46px;
}

.mt4-table .pin-server {
    left: 46px;
    width: 120px;
    min-width: 120px;
}

.mt4-table .pin-account {
    left: 166px;
    width: 110px;
    min-width: 110px;
}

.mt4-table .pin-principal {
    left: 276px;
    width: 105px;
    min-width: 105px;
    box-shadow: 8px 0 14px rgba(15, 36, 64, .08);
}

.table-toolbar {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    margin-bottom: 12px;
}

.pager-size,
.pager {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.pager-size select {
    width: 90px;
}

.pager {
    justify-content: flex-end;
    margin-top: 12px;
}

.pager-current {
    color: var(--fx-muted);
    padding: 0 6px;
}

.clear-log-footer {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
    margin-top: 14px;
}

.clear-log-password {
    width: 170px;
}

.clear-log-message {
    color: var(--fx-muted);
    font-size: .86rem;
}

table td, table th {
    vertical-align: middle;
    white-space: nowrap;
}

.page-header {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: end;
    margin-bottom: 18px;
}

.page-header h1 {
    margin: 0;
    font-size: 1.6rem;
}

.page-subtitle {
    color: var(--fx-muted);
    margin-top: 4px;
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.filter-panel {
    padding: 18px;
    border-radius: 18px;
    border: 1px solid var(--fx-border);
    background: rgba(255,255,255,.82);
    box-shadow: 0 12px 42px rgba(17, 41, 78, .04);
}

.section-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 18px;
}

.command-card {
    border: 1px solid var(--fx-border);
    border-radius: 18px;
    padding: 18px;
    background: linear-gradient(180deg, #fff, #f8fbff);
}

.command-card h5 {
    margin: 0 0 8px 0;
}

.record-tabs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.record-tabs .btn.active {
    color: #fff;
    background: var(--fx-brand);
    border-color: var(--fx-brand);
}

.account-card {
    position: relative;
    overflow: hidden;
}

.account-card::after {
    content: "";
    position: absolute;
    width: 180px;
    height: 180px;
    right: -70px;
    top: -90px;
    border-radius: 50%;
    background: rgba(47, 140, 255, .08);
}

.table thead th {
    background: rgba(248, 251, 255, .95);
    position: sticky;
    top: 0;
    z-index: 2;
}

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(circle at top left, rgba(15,106,217,.16), transparent 30%),
        radial-gradient(circle at bottom right, rgba(89,208,255,.14), transparent 28%),
        linear-gradient(180deg, #eff5ff 0%, #f8fbff 100%);
}

.login-card {
    width: 100%;
    max-width: 520px;
    background: rgba(255,255,255,.94);
    border: 1px solid rgba(255,255,255,.85);
    border-radius: 24px;
    padding: 28px;
    box-shadow: 0 30px 80px rgba(14, 45, 87, .14);
}

.login-header {
    display: flex;
    gap: 16px;
    align-items: center;
    margin-bottom: 18px;
}

.login-header h1 {
    font-size: 1.4rem;
    margin: 0 0 6px 0;
}

.login-header p,
.login-tip {
    color: var(--fx-muted);
}

.empty-layout {
    min-height: 100vh;
}

.action-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.inline-form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

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

.details-panel {
    margin-top: 10px;
    padding: 14px;
    background: #f8fbff;
    border: 1px solid var(--fx-border);
    border-radius: 14px;
}

#components-reconnect-modal {
    position: fixed;
    inset: 14px 24px auto 24px;
    z-index: 1000;
    display: none;
    justify-content: center;
    pointer-events: none;
}

#components-reconnect-modal.components-reconnect-show,
#components-reconnect-modal.components-reconnect-failed,
#components-reconnect-modal.components-reconnect-rejected {
    display: flex;
}

.reconnect-card {
    display: none;
    padding: 10px 18px;
    border-radius: 14px;
    background: #fff7e6;
    border: 1px solid #f0c36a;
    color: #7a4b00;
    box-shadow: 0 12px 38px rgba(42, 52, 74, .18);
    pointer-events: auto;
}

#components-reconnect-modal.components-reconnect-show .reconnect-show,
#components-reconnect-modal.components-reconnect-failed .reconnect-failed,
#components-reconnect-modal.components-reconnect-rejected .reconnect-rejected {
    display: block;
}

.reconnect-card button {
    border: 0;
    background: transparent;
    color: var(--fx-brand);
    font-weight: 700;
    padding: 0 2px;
}

@media (max-width: 1024px) {
    .shell {
        flex-direction: column;
        padding: 0;
    }

    .shell-sidebar {
        width: auto;
        min-height: auto;
        flex-basis: auto;
    }

    .shell-content {
        padding: 16px;
    }
}
