/* ==================== RESET & BASE ==================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg-dark: #0d1117;
    --bg-card: #161b22;
    --bg-sidebar: #0d1117;
    --bg-input: #21262d;
    --border: #30363d;
    --text: #e6edf3;
    --text-dim: #8b949e;
    --green: #3fb950;
    --green-bg: rgba(63,185,80,0.15);
    --red: #f85149;
    --red-bg: rgba(248,81,73,0.15);
    --blue: #58a6ff;
    --yellow: #d29922;
    --accent: #58a6ff;
    --radius: 8px;
    --sidebar-w: 220px;
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
    background: var(--bg-dark);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ==================== LAYOUT ==================== */
.sidebar {
    position: fixed;
    top: 0; left: 0;
    width: var(--sidebar-w);
    height: 100vh;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 100;
}

.sidebar-header {
    padding: 24px 20px 16px;
    border-bottom: 1px solid var(--border);
}

.sidebar-header h2 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
}

.sidebar-header .subtitle {
    font-size: 12px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.nav-links {
    list-style: none;
    flex: 1;
    padding: 12px 0;
}

.nav-links li a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: var(--text-dim);
    font-size: 14px;
    transition: all 0.15s;
}

.nav-links li a:hover {
    color: var(--text);
    background: var(--bg-input);
    text-decoration: none;
}

.nav-links li.active a {
    color: var(--text);
    background: var(--bg-input);
    border-left: 3px solid var(--accent);
}

.nav-links .icon {
    font-size: 12px;
    width: 20px;
    text-align: center;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.user-label {
    font-size: 13px;
    color: var(--text-dim);
}

.logout-btn {
    font-size: 12px;
    color: var(--red);
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: 4px;
}

.logout-btn:hover {
    background: var(--red-bg);
    text-decoration: none;
}

.content {
    margin-left: var(--sidebar-w);
    padding: 24px 32px;
    min-height: 100vh;
}

/* ==================== LOGIN ==================== */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg-dark);
}

.login-container {
    width: 100%;
    max-width: 400px;
    padding: 20px;
}

.login-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 40px 32px;
    text-align: center;
}

.login-box h1 {
    font-size: 24px;
    margin-bottom: 4px;
}

.login-subtitle {
    color: var(--text-dim);
    margin-bottom: 28px;
    font-size: 14px;
}

.form-group {
    margin-bottom: 16px;
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    color: var(--text-dim);
}

.form-group input {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 14px;
    outline: none;
}

.form-group input:focus {
    border-color: var(--accent);
}

/* ==================== BUTTONS ==================== */
.btn {
    display: inline-block;
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-input);
    color: var(--text);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
}

.btn:hover { background: var(--border); text-decoration: none; }

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}
.btn-primary:hover { opacity: 0.85; }

.btn-secondary { background: var(--bg-input); }

.btn-green { background: var(--green); border-color: var(--green); color: #fff; }
.btn-green:hover { opacity: 0.85; }

.btn-red { background: var(--red); border-color: var(--red); color: #fff; }
.btn-red:hover { opacity: 0.85; }

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
}

.btn-full { width: 100%; margin-top: 8px; }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* ==================== ALERTS ==================== */
.alert {
    padding: 10px 14px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 13px;
}

.alert-error {
    background: var(--red-bg);
    border: 1px solid var(--red);
    color: var(--red);
}

/* ==================== CARDS ==================== */
.page-title {
    font-size: 22px;
    font-weight: 600;
    margin-bottom: 20px;
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
}

.card h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-dim);
    margin-bottom: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ==================== KPI ==================== */
.kpi-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 20px;
}

.kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.kpi-label {
    font-size: 12px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.kpi-value {
    font-size: 24px;
    font-weight: 700;
}

/* ==================== CHARTS ==================== */
.chart-row {
    display: flex;
    gap: 16px;
    margin-bottom: 20px;
}

.chart-card-wide { flex: 2; }
.chart-card-narrow { flex: 1; }

canvas { max-height: 280px; }

/* ==================== TABLES ==================== */
.table-wrap { overflow-x: auto; }

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

th {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    color: var(--text-dim);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

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

.empty {
    text-align: center;
    color: var(--text-dim);
    padding: 32px 12px !important;
}

/* ==================== UTILITY ==================== */
.text-green { color: var(--green); }
.text-red { color: var(--red); }

.tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.tag-long { background: var(--green-bg); color: var(--green); }
.tag-short { background: var(--red-bg); color: var(--red); }

.badge {
    display: inline-block;
    background: var(--bg-input);
    border: 1px solid var(--border);
    padding: 1px 8px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 600;
    vertical-align: middle;
}

/* ==================== GRIDS ==================== */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 20px;
}

/* ==================== FILTERS ==================== */
.filter-bar { margin-bottom: 16px; }

.filter-form {
    display: flex;
    align-items: flex-end;
    gap: 14px;
    flex-wrap: wrap;
}

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

.filter-group label {
    font-size: 11px;
    color: var(--text-dim);
    text-transform: uppercase;
}

.filter-group select {
    padding: 6px 10px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 13px;
    outline: none;
}

.sort-link {
    color: var(--text-dim);
}

.sort-link.active {
    color: var(--accent);
}

.sort-link:hover {
    color: var(--text);
    text-decoration: none;
}

/* ==================== PAGINATION ==================== */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.page-info {
    font-size: 13px;
    color: var(--text-dim);
}

/* ==================== BOTS PAGE ==================== */
.regime-card { text-align: center; }

.regime-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-bottom: 16px;
}

.regime-badge {
    padding: 6px 20px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
}

.regime-bullish {
    background: var(--green-bg);
    border-color: var(--green);
    color: var(--green);
}

.regime-bearish {
    background: var(--red-bg);
    border-color: var(--red);
    color: var(--red);
}

.regime-neutral {
    background: rgba(210,153,34,0.15);
    border-color: var(--yellow);
    color: var(--yellow);
}

.regime-time {
    font-size: 12px;
    color: var(--text-dim);
}

.switch-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.service-card {
    text-align: center;
}

.service-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 14px;
    font-size: 16px;
    font-weight: 600;
}

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

.dot-green { background: var(--green); box-shadow: 0 0 6px var(--green); }
.dot-red { background: var(--red); box-shadow: 0 0 6px var(--red); }

.service-actions {
    display: flex;
    gap: 6px;
    justify-content: center;
    margin-bottom: 10px;
}

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

.log-output {
    background: #010409;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 16px;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 12px;
    line-height: 1.6;
    max-height: 500px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-all;
    color: var(--text-dim);
}

.refresh-hint {
    text-align: center;
    color: var(--text-dim);
    font-size: 12px;
    margin-top: 12px;
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
        flex-direction: row;
        flex-wrap: wrap;
    }
    .sidebar-header { padding: 12px 16px; }
    .nav-links {
        display: flex;
        padding: 0;
        width: 100%;
    }
    .nav-links li a { padding: 10px 14px; }
    .sidebar-footer { width: 100%; }
    .content { margin-left: 0; padding: 16px; }
    .kpi-row { grid-template-columns: repeat(2, 1fr); }
    .chart-row { flex-direction: column; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
}
