/* ============================================================================
   Reset & base
   ============================================================================ */
*, *::before, *::after { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: #1f2937;
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    min-height: 100vh;
}

h1, h2, h3 { margin-top: 0; }

a { color: #6366f1; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ============================================================================
   Layout
   ============================================================================ */
.container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

/* ============================================================================
   Auth card (login, 2fa)
   ============================================================================ */
.auth-card {
    background: white;
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.auth-card-wide {
    max-width: 600px;
}

.auth-card h1 {
    margin-bottom: 8px;
    font-size: 24px;
    color: #1f2937;
}

.auth-card p {
    color: #6b7280;
    margin-bottom: 24px;
}

.hint {
    margin-top: 24px;
    font-size: 13px;
    color: #9ca3af;
    text-align: center;
}

/* ============================================================================
   Forms
   ============================================================================ */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
    font-weight: 500;
    color: #374151;
}

.form-group input {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid #e5e7eb;
    border-radius: 8px;
    font-size: 15px;
    transition: border-color 0.15s, box-shadow 0.15s;
    font-family: inherit;
}

.form-group input:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.form-group input[name="token"] {
    text-align: center;
    font-size: 28px;
    letter-spacing: 12px;
    font-family: "SF Mono", Monaco, Consolas, monospace;
    font-weight: 600;
}

/* ============================================================================
   Buttons
   ============================================================================ */
.btn {
    display: inline-block;
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.15s, transform 0.05s;
    width: 100%;
    font-family: inherit;
}

.btn:active { transform: scale(0.98); }

.btn-primary {
    background: #6366f1;
    color: white;
}

.btn-primary:hover { background: #4f46e5; }

.btn-secondary {
    background: #f3f4f6;
    color: #374151;
    width: auto;
}

.btn-secondary:hover { background: #e5e7eb; }

.btn-link {
    background: none;
    border: none;
    color: #6b7280;
    font-size: 14px;
    cursor: pointer;
    text-decoration: underline;
    width: auto;
    padding: 8px;
    font-family: inherit;
}

.btn-link:hover { color: #374151; }

.cancel-form {
    text-align: center;
    margin-top: 16px;
}

/* ============================================================================
   Alerts
   ============================================================================ */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 14px;
}

.alert-error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.alert-success {
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
}

/* ============================================================================
   2FA setup
   ============================================================================ */
.setup-steps .step {
    padding: 20px 0;
    border-top: 1px solid #f3f4f6;
}

.setup-steps .step:first-child {
    border-top: none;
    padding-top: 0;
}

.setup-steps h3 {
    font-size: 16px;
    margin-bottom: 12px;
    color: #4f46e5;
}

.qr-wrapper {
    display: flex;
    justify-content: center;
    padding: 20px;
    background: #f9fafb;
    border-radius: 12px;
    margin-bottom: 12px;
}

.qr-code {
    max-width: 220px;
    width: 100%;
    height: auto;
    image-rendering: pixelated;
}

.manual-secret {
    margin-top: 12px;
}

.manual-secret summary {
    cursor: pointer;
    font-size: 14px;
    color: #6b7280;
    padding: 4px 0;
}

.secret-code {
    display: block;
    background: #f3f4f6;
    padding: 12px;
    border-radius: 6px;
    font-family: "SF Mono", Monaco, Consolas, monospace;
    font-size: 13px;
    word-break: break-all;
    margin: 8px 0;
    color: #1f2937;
}

/* ============================================================================
   Dashboard
   ============================================================================ */
.dashboard {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
}

.dashboard-header {
    background: white;
    border-radius: 16px;
    padding: 24px 32px;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.dashboard-header h1 {
    margin: 0 0 4px 0;
    font-size: 22px;
}

.user-info {
    margin: 0;
    font-size: 14px;
    color: #6b7280;
}

.dashboard-content {
    background: white;
    border-radius: 16px;
    padding: 40px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.placeholder-card h2 {
    color: #6366f1;
    margin-bottom: 12px;
}

.placeholder-card ul {
    margin-top: 16px;
    padding-left: 24px;
    color: #4b5563;
}

.placeholder-card li {
    padding: 4px 0;
}

/* ============================================================================
   Mobile
   ============================================================================ */
@media (max-width: 480px) {
    .auth-card {
        padding: 24px;
    }
    
    .dashboard-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }
    
    .dashboard-content {
        padding: 24px;
    }
}

/* ============================================================================
   Dashboard v2 — full layout with chart, toolbar, stats
   ============================================================================ */

.dashboard {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 16px;
}

/* ============================================================================
   Header
   ============================================================================ */
.dashboard-header {
    background: white;
    border-radius: 12px;
    padding: 16px 24px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.header-left h1 {
    margin: 0 0 4px 0;
    font-size: 20px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.user-name {
    font-weight: 600;
    color: #4f46e5;
}

.btn-small {
    padding: 8px 14px;
    font-size: 13px;
    width: auto;
}

/* Health indicator */
.health-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: #f9fafb;
    border-radius: 20px;
    font-size: 13px;
    color: #6b7280;
}

.health-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #9ca3af;
    transition: background 0.2s;
}

.health-indicator.healthy .health-dot {
    background: #10b981;
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.6);
}

.health-indicator.healthy .health-text {
    color: #065f46;
}

.health-indicator.degraded .health-dot {
    background: #ef4444;
}

.health-indicator.degraded .health-text {
    color: #991b1b;
}

/* ============================================================================
   Toolbar
   ============================================================================ */
.toolbar {
    background: white;
    border-radius: 12px;
    padding: 14px 20px;
    margin-bottom: 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
    align-items: flex-end;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.toolbar-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.toolbar-group-right {
    margin-left: auto;
}

.toolbar-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #9ca3af;
    font-weight: 600;
}

.btn-group {
    display: flex;
    gap: 4px;
    background: #f3f4f6;
    padding: 4px;
    border-radius: 8px;
}

.btn-toggle {
    background: transparent;
    border: none;
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    color: #6b7280;
    transition: all 0.15s;
    font-family: inherit;
}

.btn-toggle:hover:not(:disabled) {
    color: #1f2937;
    background: rgba(255, 255, 255, 0.5);
}

.btn-toggle.active {
    background: white;
    color: #4f46e5;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.btn-toggle:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ============================================================================
   Stats panel
   ============================================================================ */
.stats-panel {
    background: white;
    border-radius: 12px;
    padding: 16px 20px;
    margin-bottom: 16px;
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 16px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

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

.stat label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #9ca3af;
    font-weight: 600;
}

.stat-value {
    font-size: 16px;
    font-weight: 600;
    color: #1f2937;
    font-variant-numeric: tabular-nums;
}

.stat-price {
    font-size: 18px;
    color: #4f46e5;
}

.stat-value.up {
    color: #10b981;
}

.stat-value.down {
    color: #ef4444;
}

/* ============================================================================
   Chart
   ============================================================================ */
.chart-card {
    background: white;
    border-radius: 12px;
    padding: 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.chart-container {
    width: 100%;
    height: 500px;
}

.chart-rsi {
    height: 150px;
    border-top: 1px solid #f3f4f6;
    margin-top: 8px;
    padding-top: 8px;
}

/* ============================================================================
   Mobile
   ============================================================================ */
@media (max-width: 900px) {
    .dashboard-header {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }
    
    .toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 14px;
    }
    
    .toolbar-group-right {
        margin-left: 0;
    }
    
    .stats-panel {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .chart-container {
        height: 400px;
    }
}
