@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

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

:root {
    --bg: #0a0e1a;
    --surface: #111827;
    --surface-2: #1a2236;
    --surface-3: #232d42;
    --border: #2a3550;
    --border-subtle: rgba(42, 53, 80, 0.5);
    --text: #e8edf5;
    --text-muted: #8899b4;
    --text-dim: #5a6a84;
    --accent: #3b82f6;
    --accent-glow: rgba(59, 130, 246, 0.15);
    --green: #22c55e;
    --green-bg: rgba(34, 197, 94, 0.1);
    --green-border: rgba(34, 197, 94, 0.3);
    --red: #ef4444;
    --red-bg: rgba(239, 68, 68, 0.1);
    --red-border: rgba(239, 68, 68, 0.3);
    --orange: #f59e0b;
    --orange-bg: rgba(245, 158, 11, 0.1);
    --orange-border: rgba(245, 158, 11, 0.3);
    --radius: 14px;
    --radius-sm: 10px;
}

body {
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}

.mono {
    font-family: 'JetBrains Mono', monospace;
}

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

/* === Navbar === */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1.5rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text);
}
.nav-brand:hover { text-decoration: none; }

.nav-right {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.9rem;
}

.nav-user {
    color: var(--text-muted);
}

.btn-logout {
    color: var(--red);
    font-size: 0.85rem;
}

/* === Container === */
.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 1.5rem;
}

/* === Flash Messages === */
.flash-messages { margin-bottom: 1rem; }
.flash {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}
.flash-error { background: var(--red-bg); border: 1px solid var(--red-border); color: var(--red); }
.flash-success { background: var(--green-bg); border: 1px solid var(--green-border); color: var(--green); }

/* === Warning Banner === */
.warning-banner {
    background: var(--orange-bg);
    border: 1px solid var(--orange-border);
    color: var(--orange);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 1rem;
    text-align: center;
}

/* === Legacy Domain Banner === */
.legacy-domain-banner {
    background: var(--orange-bg);
    border: 1px solid var(--orange-border);
    color: var(--text);
    padding: 0.9rem 1.25rem;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    line-height: 1.55;
    margin-bottom: 1rem;
    text-align: center;
}
.legacy-domain-banner strong {
    font-weight: 600;
}
.legacy-domain-banner a {
    color: var(--orange);
    text-decoration: underline;
    font-weight: 700;
    word-break: break-all;
}
.legacy-domain-banner a:hover {
    color: #fbbf24;
}
.legacy-domain-banner-guide {
    display: inline-block;
    margin-top: 0.5rem;
    font-size: 0.9rem;
    font-weight: 500;
}

/* === Buttons === */
.btn {
    display: inline-block;
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    text-align: center;
    transition: all 0.2s;
    color: white;
}
.btn:hover { text-decoration: none; opacity: 0.9; }

.btn-primary { background: var(--accent); }
.btn-primary:hover { background: #2563eb; }
.btn-success { background: var(--green); color: #000; }
.btn-danger { background: var(--red); }
.btn-warning { background: var(--orange); color: #000; }
.btn-full { width: 100%; }
.btn-large { padding: 18px 32px; font-size: 16px; border-radius: var(--radius); }
.btn-small { padding: 0.35rem 0.7rem; font-size: 0.8rem; }
.btn-ghost {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
}
.btn-ghost:hover { border-color: var(--red); color: var(--red); }

/* === Forms === */
.form-group {
    margin-bottom: 1rem;
}
.form-group label {
    display: block;
    margin-bottom: 0.3rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.6rem 0.8rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.9rem;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-row {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}
.form-row .form-group { flex: 1; min-width: 120px; }
.form-row .form-group-wide { flex: 2; }

.radio-group {
    display: flex;
    gap: 1.5rem;
    padding-top: 0.3rem;
}
.radio-group label {
    color: var(--text);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

/* === Auth === */
.auth-container {
    max-width: 400px;
    margin: 4rem auto;
    text-align: center;
}
.auth-container h1 {
    font-size: 1.8rem;
    margin-bottom: 0.3rem;
}
.auth-subtitle {
    color: var(--text-muted);
    margin-bottom: 2rem;
}
.auth-form {
    background: var(--surface);
    padding: 2rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    text-align: left;
}
.auth-link {
    margin-top: 1rem;
    font-size: 0.85rem;
}

/* === Stats Grid === */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.stat-card {
    background: var(--surface-2);
    padding: 1.2rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    text-align: center;
}
.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
}
.stat-label {
    font-size: 0.7rem;
    color: var(--text-dim);
    margin-top: 0.3rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.stat-mini {
    padding: 0.8rem;
}
.stat-mini .stat-value { font-size: 1.1rem; }

.positive { color: var(--green); }
.negative { color: var(--red); }

/* === Dashboard === */
.dashboard h1 {
    margin-bottom: 1.5rem;
}

.session-control {
    background: var(--surface);
    padding: 1.5rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    margin-bottom: 1.5rem;
    text-align: center;
}
.session-control h2 {
    margin-bottom: 0.75rem;
    font-size: 1.2rem;
}
.session-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 1rem;
}
.recommended-assets {
    color: var(--text-muted);
    margin-bottom: 1rem;
}

/* ================================================================
   SESSION PAGE — Checklist / Timer / Trade flow
   ================================================================ */

.session-page {
    max-width: 600px;
    margin: 0 auto;
}

/* --- Timer --- */
.timer-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--surface);
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    margin-bottom: 1.5rem;
}

.session-timer {
    font-family: 'JetBrains Mono', monospace;
    font-size: 2rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--green);
}
.timer-warning { color: var(--orange) !important; }
.timer-expired { color: var(--red) !important; }

/* --- Session expired notice --- */
.session-expired-notice {
    background: var(--surface);
    padding: 2rem;
    border-radius: var(--radius);
    border: 1px solid var(--orange-border);
    text-align: center;
    margin-bottom: 1.5rem;
}
.session-expired-notice h2 {
    color: var(--orange);
    margin-bottom: 0.5rem;
}
.session-expired-notice p {
    color: var(--text-muted);
    margin-bottom: 1rem;
}

/* --- Checklist header --- */
.checklist h2 {
    margin-bottom: 0.5rem;
}

/* --- Progress bar (segmented) --- */
.checklist-progress {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}
.progress-bar {
    flex: 1;
    height: 8px;
    background: var(--surface-2);
    border-radius: 4px;
    overflow: hidden;
    display: flex;
    gap: 2px;
}
.progress-segment {
    flex: 1;
    height: 100%;
    background: var(--surface-3);
    border-radius: 2px;
    transition: background 0.3s;
}
.progress-segment.filled {
    background: var(--accent);
}
.progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 4px;
    transition: width 0.3s;
}

/* --- Step cards ---
   Every step is its own card with consistent styling.
   Three states: .completed, .active, .locked
*/
.step {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 24px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: var(--surface);
    margin-bottom: 12px;
}

/* Step number circle — 34px round */
.step-circle {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 600;
    flex-shrink: 0;
}

/* Active circle: accent border + glow bg + accent number */
.step-circle.active-circle {
    border: 2px solid var(--accent);
    background: var(--accent-glow);
    color: var(--accent);
}

/* Done circle: solid green, white checkmark */
.step-circle.done {
    background: var(--green);
    color: white;
    font-size: 0.9rem;
}

/* Locked circle: surface-3 bg, dim text, subtle border */
.step-circle.locked-circle {
    background: var(--surface-3);
    color: var(--text-dim);
    border: 1px solid var(--border);
}

/* COMPLETED step: green-tinted */
.step.completed {
    padding: 14px 24px;
    color: var(--text-muted);
    font-size: 0.85rem;
    align-items: center;
    border-color: var(--green-border);
    background: rgba(34, 197, 94, 0.03);
}

/* ACTIVE step: accent border + glow shadow */
.step.active {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15), 0 8px 24px rgba(0, 0, 0, 0.2);
}
.step.active .step-content {
    flex: 1;
    min-width: 0;
}
.step.active .step-content p {
    color: #e2e8f0;
}
.step.active h3 {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 12px;
}

/* LOCKED step: faded, non-interactive */
.step.locked {
    opacity: 0.35;
    pointer-events: none;
    font-size: 0.85rem;
    align-items: center;
    padding: 14px 24px;
}

/* --- Step message box ---
   The instruction/hint text inside each active step.
   surface-2 bg, accent left border, rounded.
*/
.step-hint {
    background: var(--surface-2);
    border-radius: 6px;
    border-left: 3px solid var(--accent);
    padding: 12px 16px;
    font-size: 14px;
    color: #e2e8f0;
    margin-bottom: 16px;
    line-height: 1.5;
}

/*
   Link inside a step (e.g. external calendar link).
*/
.step-link {
    margin-bottom: 16px;
}
.step-link a {
    color: var(--accent);
    text-decoration: underline;
    font-size: 14px;
}
.step-link a:hover {
    color: #60a5fa;
}

/* --- Market info calendar link --- */
.market-info-link {
    display: block;
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid white;
    border-radius: 8px;
    padding: 10px 14px;
    color: white;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    margin: 12px 0;
    transition: all 0.2s;
    text-align: center;
}
.market-info-link:hover {
    background: rgba(59, 130, 246, 0.2);
    border-color: #3b82f6;
}

/* --- Confirm buttons (inside steps) ---
   Full-width green, white text.
*/
.step .btn-primary {
    background: #22c55e;
    color: white;
    border-radius: 10px;
    padding: 12px 24px;
    font-weight: 600;
    width: 100%;
    font-size: 15px;
    border: none;
    cursor: pointer;
    font-family: 'DM Sans', sans-serif;
    transition: all 0.2s;
}
.step .btn-primary:hover {
    background: #16a34a;
}

/* --- Market info step — two equal buttons side by side (must be after .step .btn-primary) --- */
.market-info-buttons {
    display: flex;
    flex-direction: row;
    gap: 10px;
}
.market-info-buttons .btn {
    flex: 1;
    padding: 14px 12px !important;
    font-size: 14px !important;
    border-radius: 10px;
    width: auto;
}
.market-info-buttons .btn-success {
    background: #22c55e;
    color: white;
    border: none;
}

/* --- "Sortie de position" button (step 8) --- */
.step .btn-warning.btn-large {
    width: 100%;
    font-size: 16px;
    margin-top: 0.75rem;
    border-radius: 10px;
    padding: 14px 24px;
}

/* --- "Valider la sortie" button (step 9) --- */
.exit-step .btn-primary.btn-large {
    background: var(--accent);
    font-size: 16px;
    border-radius: 10px;
    padding: 14px 24px;
}
.exit-step .btn-primary.btn-large:hover {
    background: #2563eb;
}

/* --- Direction buttons (Achat / Vente) ---
   Grid 2 columns, large cards.
*/
.direction-form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}
.direction-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 20px;
    border-radius: 14px;
    border: 2px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
    cursor: pointer;
    font-family: 'DM Sans', sans-serif;
    transition: all 0.2s;
}
.direction-btn:hover {
    transform: translateY(-2px);
}
.direction-icon {
    font-size: 28px;
    font-weight: 700;
}
.direction-label {
    font-size: 16px;
    font-weight: 700;
}
.direction-buy {
    border-color: #22c55e;
    color: #22c55e;
}
.direction-buy .direction-icon {
    color: #22c55e;
}
.direction-buy:hover, .direction-buy:focus {
    border-color: #22c55e;
    background: rgba(34, 197, 94, 0.1);
    color: #22c55e;
    box-shadow: 0 0 20px var(--green-bg), 0 0 0 3px rgba(34, 197, 94, 0.15);
}
.direction-sell {
    border-color: #ef4444;
    color: #ef4444;
}
.direction-sell .direction-icon {
    color: #ef4444;
}
.direction-sell:hover, .direction-sell:focus {
    border-color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    box-shadow: 0 0 20px var(--red-bg), 0 0 0 3px rgba(239, 68, 68, 0.15);
}

/* --- Monitor boxes (step 8) --- */
.monitor-box {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 12px 16px;
    margin-bottom: 10px;
}
.monitor-box p {
    font-size: 14px;
    margin-bottom: 0.3rem;
    color: #e2e8f0;
    line-height: 1.5;
}
.monitor-title {
    font-weight: 700;
    font-size: 0.8rem;
    margin-bottom: 0.4rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.monitor-sl .monitor-title { color: var(--red); }
.monitor-sl { border-left: 3px solid var(--red); }
.monitor-rebond .monitor-title { color: var(--orange); }
.monitor-rebond { border-left: 3px solid var(--orange); }
.monitor-tp .monitor-title { color: var(--green); }
.monitor-tp { border-left: 3px solid var(--green); }

/* --- MM rules (step 5) --- */
.mm-rules {
    background: var(--surface-2);
    padding: 12px 16px;
    border-radius: 6px;
    border-left: 3px solid var(--accent);
    margin-bottom: 16px;
    font-size: 14px;
    color: #e2e8f0;
    line-height: 1.5;
}
.mm-rules p { margin-bottom: 0.5rem; }

.mm-admin-rules {
    background: var(--bg);
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 14px;
    white-space: pre-line;
    color: #e2e8f0;
    border-left: 3px solid var(--orange);
    line-height: 1.5;
}

/* --- TP1 rules (step 6) --- */
.tp1-rules {
    background: var(--surface-2);
    padding: 12px 16px;
    border-radius: 6px;
    border-left: 3px solid var(--accent);
    margin-bottom: 16px;
    font-size: 14px;
    color: #e2e8f0;
    line-height: 1.5;
}
.tp1-rules p { margin-bottom: 0.5rem; }

/* --- Exit reasons (step 9) --- */
.exit-reasons {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}
.exit-option input { display: none; }
.exit-chip {
    display: inline-block;
    padding: 0.6rem 1.2rem;
    background: var(--surface-2);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.2s;
}
.exit-option input:checked + .exit-tp {
    border-color: var(--green);
    background: var(--green-bg);
    color: var(--green);
}
.exit-option input:checked + .exit-sl {
    border-color: var(--red);
    background: var(--red-bg);
    color: var(--red);
}
.exit-option input:checked + .exit-autre {
    border-color: var(--accent);
    background: var(--accent-glow);
    color: var(--accent);
}

.exit-form .form-group { margin-bottom: 1rem; }

/* --- Cancel trade --- */
.cancel-trade {
    margin-top: 0.5rem;
    text-align: center;
}

/* --- Pulse indicator (open trade direction) --- */
.pulse-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 1rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 1rem;
}
.pulse-buy {
    background: var(--green-bg);
    color: var(--green);
    border: 1px solid var(--green-border);
}
.pulse-sell {
    background: var(--red-bg);
    color: var(--red);
    border: 1px solid var(--red-border);
}
.pulse-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    animation: pulse 1.5s ease-in-out infinite;
}
.pulse-buy .pulse-dot { background: var(--green); }
.pulse-sell .pulse-dot { background: var(--red); }

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(1.3); }
}

/* === New Trade === */
.new-trade-section {
    background: var(--surface);
    padding: 24px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    margin-bottom: 1.5rem;
}
.new-trade-section h2 { margin-bottom: 1rem; }

.asset-selection {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 1rem;
}
.asset-option input { display: none; }
.asset-chip {
    display: inline-block;
    padding: 0.5rem 1rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}
.asset-option input:checked + .asset-chip {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}
.custom-asset input {
    padding: 0.5rem 0.8rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.9rem;
    width: 150px;
}

/* === Tables === */
.trades-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}
.trades-table th,
.trades-table td {
    padding: 0.6rem 0.8rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
.trades-table th {
    color: var(--text-dim);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.badge-rec {
    background: var(--accent);
    color: white;
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    font-size: 0.7rem;
    font-weight: 600;
}
.badge-online {
    background: var(--green);
    color: #000;
    padding: 0.1rem 0.5rem;
    border-radius: 3px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* === Trade notes (expandable row) === */
.has-notes {
    cursor: pointer;
}
.has-notes:hover {
    background: var(--surface-2);
}
.notes-icon {
    font-size: 0.75rem;
    opacity: 0.7;
}
.trade-notes-row td {
    padding: 0 !important;
    border-bottom: 1px solid var(--border);
}
.trade-notes-row.hidden {
    display: none;
}
.trade-notes {
    background: var(--surface-2);
    padding: 10px 14px;
    margin: 0 8px 8px;
    border-radius: 6px;
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.5;
    border-left: 3px solid var(--accent);
    white-space: pre-line;
}

/* === Card === */
.card {
    background: var(--surface);
    padding: 24px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    margin-bottom: 1rem;
}
.card h2 { margin-bottom: 1rem; font-size: 1.1rem; }

/* === Today's / Session trades === */
.today-trades {
    background: var(--surface);
    padding: 24px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}
.today-trades h2 { margin-bottom: 1rem; }

.session-trades {
    background: var(--surface);
    padding: 24px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    margin-top: 1.5rem;
}
.session-trades h3 { margin-bottom: 1rem; }

/* === Account === */
.account-page h1 { margin-bottom: 1.5rem; }
.account-page h2 { margin-bottom: 1rem; font-size: 1.1rem; }
.account-page .card { max-width: 500px; }
.text-muted { color: var(--text-muted); }

/* === Admin === */
.admin-page h1 { margin-bottom: 1.5rem; }
.admin-page h2 { margin-top: 1.5rem; margin-bottom: 0.75rem; }

.config-form {
    background: var(--surface);
    padding: 24px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}
.config-form h2 {
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}
.config-form h2:first-of-type {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}

.trader-email { color: var(--text-muted); margin-bottom: 1.5rem; }
.stat-extra { margin-bottom: 1.5rem; color: var(--text-muted); }

.invite-link {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    word-break: break-all;
}

/* ================================================================
   CALENDAR PAGE
   ================================================================ */

.calendar-page h1 {
    font-size: 1.4rem;
}

.calendar-header {
    margin-bottom: 1rem;
}

.calendar-nav {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}
.calendar-nav h1 { flex: 1; text-align: center; }

.calendar-monthly-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.calendar-actions {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}
.calendar-actions .btn {
    background: #1a2236;
    border: 1px solid #2a3550;
    color: #8899b4;
    border-radius: 6px;
    padding: 8px 14px;
    font-weight: 600;
    font-size: 12px;
}
.calendar-actions .btn:hover {
    background: #232d42;
    color: #e8edf5;
    border-color: #3b82f6;
}

.calendar-capture {
    background: var(--bg);
    border-radius: var(--radius);
}
.calendar-footer-brand {
    display: none;
    text-align: center;
    padding: 0.75rem;
    color: var(--text-dim);
    font-size: 0.85rem;
    margin-top: 0.5rem;
}

/* Calendar card container */
.calendar-card {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Each week row: flex with 7-col days grid + summary box */
.calendar-week-row {
    display: flex;
    gap: 8px;
    margin-bottom: 0;
}

/* 7-column grid for day cells */
.calendar-days {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    min-width: 0;
}

/* Day header row */
.calendar-header-row {
    margin-bottom: 0;
}
.calendar-header-row .day-header {
    min-height: auto;
    background: transparent;
    border: none;
    padding: 6px 4px;
}

.day-header, .week-summary-header {
    text-align: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
}
.week-summary-header {
    width: 155px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Day cells */
.calendar-cell {
    min-height: 62px;
    background: var(--surface-2);
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    padding: 6px;
    font-size: 0.75rem;
}
.calendar-cell.empty {
    background: transparent;
    border-color: transparent;
}
.calendar-cell.has-data {
    border-color: var(--border);
}

.day-number {
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 2px;
}
.day-trades {
    font-size: 0.65rem;
    color: var(--text-dim);
}
.day-pnl {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 600;
    font-size: 0.7rem;
}
.day-winrate {
    font-size: 0.6rem;
    color: var(--text-dim);
}

/* Weekly summary box (right of each row) */
.week-summary {
    width: 155px;
    flex-shrink: 0;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
}
.week-trades {
    font-size: 0.7rem;
    color: var(--text-muted);
}
.week-pnl {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    font-size: 0.8rem;
}
.week-winrate {
    font-size: 0.65rem;
    color: var(--text-dim);
}
.week-empty {
    color: var(--text-dim);
}

.trader-selector {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    font-weight: 600;
}
.trader-selector select {
    padding: 0.5rem 0.8rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.9rem;
}

/* === Chat Widget === */
.chat-widget {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 200;
}
.chat-toggle {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--accent);
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.chat-panel {
    position: fixed;
    bottom: 5rem;
    right: 1.5rem;
    width: 700px;
    max-height: 80vh;
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.chat-panel.hidden { display: none; }

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: 1rem;
}
.chat-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.3rem;
    cursor: pointer;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem;
    min-height: 300px;
}
.chat-msg {
    margin-bottom: 1rem;
    font-size: 15px;
    line-height: 1.6;
}
.chat-msg.user {
    text-align: right;
}
.chat-msg .bubble {
    display: inline-block;
    padding: 0.75rem 1.1rem;
    border-radius: var(--radius-sm);
    max-width: 80%;
    text-align: left;
}
.chat-msg.user .bubble {
    background: var(--accent);
}
.chat-msg.assistant .bubble {
    background: var(--surface-2);
}

.chat-form {
    display: flex;
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border);
    gap: 0.5rem;
}
.chat-form input {
    flex: 1;
    padding: 0.7rem 1rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: 'DM Sans', sans-serif;
    font-size: 15px;
}
.chat-form button {
    padding: 0.7rem 1rem;
    background: var(--accent);
    border: none;
    border-radius: var(--radius-sm);
    color: white;
    cursor: pointer;
    font-size: 1.1rem;
}

/* === Toast notifications === */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--green);
    color: #000;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.9rem;
    z-index: 500;
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
}
.toast.toast-error {
    background: var(--red);
    color: white;
}
.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* === Pagination === */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-top: 1.5rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* === Empty State === */
.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 2rem;
}

/* === Screen summary (multi-screen checklist) === */
.screen-title {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-dim);
    margin-bottom: 0.75rem;
}

.screen-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 1rem;
}

.summary-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.3rem 0.7rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text-muted);
}

.summary-done {
    background: var(--green-bg);
    border-color: var(--green-border);
    color: var(--green);
}
.summary-done::before {
    content: "\2713";
    font-size: 0.7rem;
}

.summary-buy {
    background: var(--green-bg);
    border-color: var(--green-border);
    color: var(--green);
}

.summary-sell {
    background: var(--red-bg);
    border-color: var(--red-border);
    color: var(--red);
}

/* === Knowledge Base === */
.knowledge-edit-row td {
    padding: 1rem 0.8rem !important;
    background: var(--surface-2);
}
.knowledge-edit-row.hidden {
    display: none;
}
.knowledge-thumb {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid var(--border);
}
.image-upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius-sm);
    padding: 1rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s;
}
.image-upload-zone:hover {
    border-color: var(--accent);
}
.upload-placeholder {
    color: var(--text-dim);
    font-size: 0.85rem;
}
.upload-placeholder.hidden, .upload-preview.hidden {
    display: none;
}
.upload-preview {
    position: relative;
    display: inline-block;
}
.upload-preview img {
    max-width: 200px;
    max-height: 150px;
    border-radius: 6px;
    border: 1px solid var(--border);
}
.upload-remove {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--red);
    color: white;
    border: none;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}
.edit-current-image {
    position: relative;
    display: inline-block;
    margin-bottom: 0.75rem;
}
.edit-current-image.hidden {
    display: none;
}
.edit-current-image img {
    max-width: 200px;
    max-height: 150px;
    border-radius: 6px;
    border: 1px solid var(--border);
}

/* === Chat markdown === */
.chat-msg.assistant .bubble h2,
.chat-msg.assistant .bubble h3 {
    margin: 12px 0 4px;
    line-height: 1.3;
}
.chat-msg.assistant .bubble h2 { font-size: 16px; }
.chat-msg.assistant .bubble h3 { font-size: 14px; }
.chat-msg.assistant .bubble h2:first-child,
.chat-msg.assistant .bubble h3:first-child { margin-top: 0; }
.chat-msg.assistant .bubble p {
    margin: 0 0 8px;
}
.chat-msg.assistant .bubble p:last-child { margin-bottom: 0; }
.chat-msg.assistant .bubble ul,
.chat-msg.assistant .bubble ol {
    padding-left: 16px;
    margin: 0 0 8px;
}
.chat-msg.assistant .bubble li {
    margin-bottom: 4px;
}
.chat-msg.assistant .bubble li:last-child { margin-bottom: 0; }
.chat-msg.assistant .bubble strong {
    color: white;
}
.chat-msg.assistant .bubble hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 10px 0;
}
.chat-msg.assistant .bubble code {
    background: var(--surface-3);
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 0.85em;
}

/* === Chat images === */
.chat-image {
    display: block;
    max-width: 100%;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.1);
    margin-top: 10px;
}
.chat-image-link {
    display: block;
}
.chat-image-link:hover {
    text-decoration: none;
    opacity: 0.9;
}
.chat-image-caption {
    display: block;
    font-size: 0.7rem;
    color: var(--text-dim);
    margin-top: 4px;
}

/* === Conversations === */
.conversations-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.conversation-card {
    cursor: pointer;
    transition: border-color 0.2s;
}
.conversation-card:hover {
    border-color: var(--accent);
}
.conversation-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
}
.conversation-preview {
    flex: 1;
    font-size: 0.9rem;
    color: var(--text);
    min-width: 0;
}
.conversation-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.25rem;
    flex-shrink: 0;
}
.conversation-date {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
}
.conversation-count {
    font-size: 0.75rem;
    color: var(--text-dim);
}
.conversation-thread {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.conversation-thread.hidden {
    display: none;
}
.conv-msg {
    display: flex;
    flex-direction: column;
}
.conv-msg-user {
    align-items: flex-end;
}
.conv-msg-assistant {
    align-items: flex-start;
}
.conv-bubble {
    max-width: 80%;
    padding: 0.6rem 0.9rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    line-height: 1.5;
    white-space: pre-line;
}
.conv-bubble-user {
    background: var(--accent);
    color: white;
}
.conv-bubble-assistant {
    background: var(--surface-2);
    color: var(--text);
}
.conv-time {
    font-size: 0.7rem;
    color: var(--text-dim);
    margin-top: 0.2rem;
    font-family: 'JetBrains Mono', monospace;
}

/* === Responsive === */
@media (max-width: 700px) {
    .navbar { flex-direction: column; gap: 0.5rem; }
    .nav-right { flex-wrap: wrap; justify-content: center; gap: 0.5rem; }
    .container { padding: 1rem; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .form-row { flex-direction: column; }
    .chat-panel { width: calc(100vw - 2rem); max-width: 450px; right: -0.5rem; }
    .session-actions { flex-direction: column; }
    .trades-table { font-size: 0.8rem; }
    .trades-table th, .trades-table td { padding: 0.4rem; }
    .direction-form { grid-template-columns: 1fr; }
    .step { padding: 16px; }
    .step.completed, .step.locked { padding: 12px 16px; }
    .week-summary, .week-summary-header { display: none; }
    .calendar-week-row { gap: 0; }
    .calendar-days { gap: 3px; }
    .calendar-monthly-stats { grid-template-columns: repeat(2, 1fr); }
    .calendar-cell { min-height: 50px; padding: 4px; }
    .calendar-card { padding: 8px; }
}

/* === Market info buttons (ID selector for max specificity, after everything) === */
#market-info-buttons {
    display: flex !important;
    flex-direction: row !important;
    gap: 10px !important;
}
#market-info-buttons > button {
    flex: 1 1 50% !important;
    min-width: 0 !important;
    max-width: none !important;
    width: auto !important;
    padding: 14px 12px !important;
    font-size: 14px !important;
    border-radius: 10px !important;
    box-sizing: border-box !important;
}

/* === Migration Guide Page === */
.guide-migration {
    max-width: 720px;
    margin: 2rem auto;
    padding: 0 1rem;
    line-height: 1.7;
}
.guide-migration h1 {
    font-size: 1.75rem;
    margin-bottom: 1.5rem;
}
.guide-migration h2 {
    font-size: 1.3rem;
    margin-top: 2.5rem;
    margin-bottom: 1rem;
    color: var(--orange);
}
.guide-migration h3 {
    font-size: 1.05rem;
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
    color: var(--text);
}
.guide-migration ol {
    padding-left: 1.5rem;
    margin-bottom: 1rem;
}
.guide-migration ol li {
    margin-bottom: 0.5rem;
}
.guide-migration .guide-intro {
    background: var(--surface);
    border-left: 3px solid var(--orange);
    padding: 1rem 1.25rem;
    border-radius: var(--radius-sm);
    margin-bottom: 2rem;
}
.guide-migration .guide-note {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-style: italic;
    margin-top: -0.5rem;
    margin-bottom: 1rem;
}
