* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background: #0f172a;
    color: #e2e8f0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 3rem;
    background: #1e293b;
    border-bottom: 1px solid rgba(148, 163, 184, 0.2);
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.35);
}

header .brand h1 {
    font-size: 1.8rem;
    margin-bottom: 0.25rem;
}

header .brand p {
    color: #94a3b8;
    font-size: 0.95rem;
}

.status-chip {
    padding: 0.5rem 1rem;
    border-radius: 999px;
    background: #ef4444;
    color: #0f172a;
    font-weight: 600;
    transition: background 0.2s ease-in-out;
}

.status-chip.online {
    background: #22c55e;
}

.status-chip.online.polling {
    background: #fbbf24;
    color: #0f172a;
}

main {
    flex: 1;
    padding: 2rem 3rem 3.5rem 3rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.controls {
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid rgba(148, 163, 184, 0.15);
    border-radius: 16px;
    padding: 1.5rem;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1.5rem;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.45);
}

.controls label {
    display: block;
    margin-bottom: 0.5rem;
    color: #cbd5f5;
}

.controls input[type="number"] {
    width: 100%;
    padding: 0.75rem;
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.3);
    background: #0f172a;
    color: #e2e8f0;
    font-size: 1rem;
}

.control-buttons {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.control-buttons button {
    flex: 1;
    padding: 0.9rem 1.2rem;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: transform 0.15s ease, filter 0.15s ease;
}

.control-buttons button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.control-buttons .primary {
    background: linear-gradient(135deg, #1e40af, #3b82f6);
    color: #f8fafc;
}

.control-buttons .primary:hover:not(:disabled) {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

.control-buttons .danger {
    background: linear-gradient(135deg, #b91c1c, #ef4444);
    color: #f8fafc;
}

.control-buttons .danger:hover:not(:disabled) {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

.control-message {
    grid-column: 1 / -1;
    color: #fbbf24;
    font-size: 0.95rem;
}

.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
}

.card {
    background: rgba(30, 41, 59, 0.9);
    border: 1px solid rgba(148, 163, 184, 0.15);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.35);
}

.card h2 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    color: #a5b4fc;
}

.card .value {
    font-size: 2.2rem;
    font-weight: 700;
}

.card .sub {
    margin-top: 0.4rem;
    color: #cbd5f5;
    font-size: 0.95rem;
}

.sub.positive {
    color: #4ade80;
}

.sub.negative {
    color: #f87171;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.panel {
    background: rgba(30, 41, 59, 0.9);
    border: 1px solid rgba(148, 163, 184, 0.15);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.35);
}

.chart-panel {
    min-height: 480px;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.chart-header h3 {
    margin: 0;
}

.chart-controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.chart-controls-hint {
    margin-bottom: 1rem;
    padding: 0.5rem 0.75rem;
    background: rgba(59, 130, 246, 0.1);
    border-radius: 8px;
    font-size: 0.85rem;
    color: #94a3b8;
}

.chart-controls-hint span {
    display: inline-block;
}

button.secondary {
    background: rgba(148, 163, 184, 0.15);
    border: 1px solid rgba(148, 163, 184, 0.3);
    color: #cbd5f5;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.15s ease;
}

button.secondary:hover {
    background: rgba(148, 163, 184, 0.25);
    border-color: rgba(148, 163, 184, 0.5);
    transform: translateY(-1px);
}

button.secondary.small {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
}

button.secondary.icon-btn {
    padding: 0.4rem 0.6rem;
    min-width: 32px;
    font-size: 0.95rem;
}

.chart-wrapper {
    position: relative;
    width: 100%;
    height: 380px;
    margin-top: 0.75rem;
}

.chart-wrapper canvas {
    width: 100% !important;
    height: 100% !important;
}

.panel h3 {
    margin-bottom: 1rem;
    color: #a5b4fc;
}

#signal-list {
    list-style: none;
    margin-top: 0.5rem;
    display: grid;
    gap: 0.4rem;
}

#signal-list li {
    padding: 0.5rem 0.75rem;
    border-radius: 10px;
    background: rgba(59, 130, 246, 0.12);
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.indicators-table,
.trades-table {
    width: 100%;
    border-collapse: collapse;
}

.indicators-table th,
.indicators-table td,
.trades-table th,
.trades-table td {
    padding: 0.5rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid rgba(148, 163, 184, 0.15);
}

.indicators-table th {
    color: #cbd5f5;
    font-weight: 500;
    width: 50%;
}

.trades-table thead {
    background: rgba(15, 23, 42, 0.6);
}

.trades-table tbody tr:hover {
    background: rgba(148, 163, 184, 0.08);
}

.trades-table .empty {
    text-align: center;
    color: #94a3b8;
    padding: 1.2rem 0;
}

footer {
    padding: 1.2rem 3rem;
    text-align: center;
    background: #1e293b;
    color: #94a3b8;
    font-size: 0.9rem;
    border-top: 1px solid rgba(148, 163, 184, 0.2);
}

@media (max-width: 768px) {
    header,
    main,
    footer {
        padding-left: 1.25rem;
        padding-right: 1.25rem;
    }

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

    .control-buttons {
        flex-direction: column;
    }

    .control-buttons button {
        width: 100%;
    }
}
