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

:root {
    --bg-primary: #f8f9fc;
    --bg-card: #ffffff;
    --bg-table-header: #f1f3f9;
    --bg-table-hover: #f6f8fc;
    --bg-badge: #3861FB;
    --text-primary: #1a1d29;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --border: #e5e7eb;
    --border-light: #f0f1f3;
    --accent: #3861FB;
    --accent-light: #eef1ff;
    --positive: #10b981;
    --positive-bg: #ecfdf5;
    --negative: #ef4444;
    --negative-bg: #fef2f2;
    --buy: #3861FB;
    --buy-bg: #eef1ff;
    --sell: #e84393;
    --sell-bg: #fdf0f7;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.08);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* Navbar */
.navbar {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 0 32px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

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

.brand-text {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.3px;
}

.nav-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border-radius: 20px;
    background: var(--bg-table-header);
    font-size: 13px;
    color: var(--text-secondary);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: background 0.3s;
}

.status-dot.connected {
    background: var(--positive);
    box-shadow: 0 0 6px rgba(16, 185, 129, 0.5);
}

.status-dot.disconnected {
    background: var(--negative);
    box-shadow: 0 0 6px rgba(239, 68, 68, 0.5);
}

/* Container */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 28px 32px;
}

/* Account Cards */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}

.account-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 22px 26px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s, transform 0.2s;
}

.account-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.error-card {
    border-color: var(--negative);
    background: var(--negative-bg);
}

.card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.card-badge {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: var(--accent);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    flex-shrink: 0;
}

.card-account {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.card-server {
    font-size: 12px;
    color: var(--text-muted);
    margin-left: auto;
    background: var(--bg-table-header);
    padding: 3px 10px;
    border-radius: 12px;
}

.card-status.error {
    font-size: 12px;
    color: var(--negative);
    font-weight: 600;
    margin-left: auto;
}

.card-name {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 16px;
    padding-left: 38px;
}

.card-error {
    font-size: 13px;
    color: var(--negative);
    padding: 8px 0;
}

.card-metrics {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    padding-top: 16px;
    border-top: 1px solid var(--border-light);
}

.metric {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.metric-label {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.metric-value {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-primary);
}

.metric-value.positive {
    color: var(--positive);
}

.metric-value.negative {
    color: var(--negative);
}

/* Tables Section */
.tables-section {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.table-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.table-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px;
    border-bottom: 1px solid var(--border-light);
}

.table-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.account-badge {
    width: 26px;
    height: 26px;
    border-radius: 7px;
    background: var(--accent);
    color: white;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
}

.position-count {
    font-size: 13px;
    color: var(--text-muted);
    background: var(--bg-table-header);
    padding: 4px 12px;
    border-radius: 12px;
    font-weight: 500;
}

/* Data Table */
.table-wrapper {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table thead {
    background: var(--bg-table-header);
}

.data-table th {
    padding: 11px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    border-bottom: 1px solid var(--border-light);
}

.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-light);
    white-space: nowrap;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.data-table tbody tr {
    transition: background 0.15s;
}

.data-table tbody tr:hover {
    background: var(--bg-table-hover);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.empty-row td {
    text-align: center;
    padding: 40px 16px;
    color: var(--text-muted);
    font-size: 14px;
}

.ticket {
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 12px;
}

.symbol {
    font-weight: 600;
}

.type-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 5px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.3px;
}

.type-buy {
    background: var(--buy-bg);
    color: var(--buy);
}

.type-sell {
    background: var(--sell-bg);
    color: var(--sell);
}

.btn-close-pos {
    background: var(--negative);
    color: white;
    border: none;
    padding: 5px 14px;
    border-radius: 5px;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s, opacity 0.2s;
    letter-spacing: 0.3px;
}

.btn-close-pos:hover {
    background: #dc2626;
}

.btn-close-pos:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-close-pos.closed {
    background: var(--positive);
}

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

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

.profit-cell {
    font-weight: 600;
}

/* Table Footer */
.table-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    padding: 14px 24px;
    border-top: 1px solid var(--border);
    background: var(--bg-table-header);
}

.total-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.total-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.total-value.positive {
    color: var(--positive);
}

.total-value.negative {
    color: var(--negative);
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

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


/* Responsive */
@media (max-width: 768px) {
    .navbar { padding: 0 16px; }
    .container { padding: 16px; }
    .cards-grid { grid-template-columns: 1fr; }
    .table-header { flex-direction: column; align-items: flex-start; gap: 8px; }
    .card-metrics { grid-template-columns: 1fr; }
}
