:root {
    --bg-dark: #0f1923;
    --bg-sidebar: #111d2b;
    --bg-card: #162231;
    --bg-card-hover: #1a2940;
    --bg-input: #1a2940;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --accent-gradient: linear-gradient(135deg, #3b82f6, #06b6d4);
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --border: #1e3a5f;
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #f59e0b;
}

html, body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-primary);
    margin: 0;
    min-height: 100vh;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-dark); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* Layout */
.page {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
}

main {
    flex: 1;
    margin-left: 260px;
    min-height: 100vh;
    background: var(--bg-dark);
}

.top-row {
    display: none;
}

.content {
    padding: 2rem;
}

/* Sidebar Brand */
.sidebar .top-row {
    display: flex;
    align-items: center;
    padding: 1.5rem 1.25rem;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.1), rgba(6, 182, 212, 0.05));
}

.navbar-brand {
    font-size: 1.4rem;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-decoration: none;
    letter-spacing: 0.5px;
}

/* Nav Links */
.nav-scrollable {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 0;
}

.nav-item {
    margin: 2px 0.75rem;
}

.nav-link {
    color: var(--text-secondary) !important;
    border-radius: 8px;
    padding: 0.65rem 1rem !important;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.nav-link:hover {
    color: var(--text-primary) !important;
    background: rgba(59, 130, 246, 0.1);
}

.nav-link.active {
    color: #fff !important;
    background: var(--accent-gradient);
    box-shadow: 0 2px 10px rgba(59, 130, 246, 0.3);
}

/* Nav icons */
.nav-icon {
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text-primary);
    transition: all 0.2s;
}

.card:hover {
    border-color: rgba(59, 130, 246, 0.3);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border);
    padding: 1rem 1.25rem;
    font-weight: 600;
}

.card-body {
    padding: 1.25rem;
}

/* Stat Cards */
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.25rem;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--accent-gradient);
}

.stat-card .stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-card .stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.25rem;
}

/* Clickable elements */
.stat-card.clickable,
.clickable-row {
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}
.stat-card.clickable:hover {
    border-color: var(--accent);
    background: var(--bg-card-hover);
}
.clickable-row:hover td {
    background: var(--bg-card-hover);
}

/* Tables */
.table {
    color: var(--text-primary);
    --bs-table-bg: transparent;
    --bs-table-hover-bg: rgba(59, 130, 246, 0.05);
    --bs-table-striped-bg: rgba(255, 255, 255, 0.02);
    margin-bottom: 0;
}

.table thead th {
    background: rgba(59, 130, 246, 0.08);
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0.75rem 1rem;
    white-space: nowrap;
}

.table tbody td {
    border-bottom: 1px solid rgba(30, 58, 95, 0.5);
    padding: 0.75rem 1rem;
    vertical-align: middle;
    color: var(--text-primary);
}

.table tbody tr:last-child td {
    border-bottom: none;
}

/* Buttons */
.btn-primary {
    background: var(--accent-gradient);
    border: none;
    color: #fff;
    font-weight: 600;
    border-radius: 8px;
    padding: 0.5rem 1.25rem;
    transition: all 0.2s;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #2563eb, #0891b2);
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
}

.btn-outline-primary {
    color: var(--accent);
    border-color: var(--accent);
    border-radius: 8px;
}

.btn-outline-primary:hover {
    background: var(--accent);
    border-color: var(--accent);
}

.btn-outline-danger {
    color: var(--danger);
    border-color: var(--danger);
    border-radius: 8px;
}

.btn-outline-danger:hover {
    background: var(--danger);
    color: #fff;
}

.btn-outline-secondary {
    color: var(--text-secondary);
    border-color: var(--border);
    border-radius: 8px;
}

.btn-outline-secondary:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
    border-color: var(--text-muted);
}

.btn-sm {
    padding: 0.3rem 0.75rem;
    font-size: 0.85rem;
}

/* Forms */
.form-control, .form-select {
    background-color: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-primary);
    border-radius: 8px;
    padding: 0.5rem 0.75rem;
}

.form-control:focus, .form-select:focus {
    background-color: var(--bg-input);
    border-color: var(--accent);
    color: var(--text-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.form-control::placeholder {
    color: var(--text-muted);
}

.form-label {
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 0.35rem;
}

.form-select option {
    background: var(--bg-card);
    color: var(--text-primary);
}

.form-check-input {
    background-color: var(--bg-input);
    border-color: var(--border);
}

.form-check-input:checked {
    background-color: var(--accent);
    border-color: var(--accent);
}

/* Badges */
.badge {
    font-weight: 500;
    font-size: 0.75rem;
    padding: 0.35em 0.65em;
    border-radius: 6px;
}

.badge-priority-0 { background: var(--text-muted); }
.badge-priority-1 { background: #3b82f6; }
.badge-priority-2 { background: #f59e0b; }
.badge-priority-3 { background: #f97316; }
.badge-priority-4 { background: #ef4444; }

.badge-status { background: rgba(59, 130, 246, 0.15); color: var(--accent); }

.badge-call { background: rgba(34, 197, 94, 0.15); color: var(--success); }
.badge-put { background: rgba(239, 68, 68, 0.15); color: var(--danger); }

/* Page Header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Modal override */
.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text-primary);
}

.modal-header {
    border-bottom: 1px solid var(--border);
}

.modal-footer {
    border-top: 1px solid var(--border);
}

.modal-backdrop.show {
    opacity: 0.7;
}

.btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
}

/* Profit/Loss colors */
.text-profit { color: var(--success) !important; }
.text-loss { color: var(--danger) !important; }

/* Due date colors */
.text-overdue { color: var(--danger) !important; font-weight: 600; }
.text-due-soon { color: var(--warning) !important; }

/* Completed task */
.task-completed td {
    opacity: 0.5;
    text-decoration: line-through;
}
.task-completed td:first-child,
.task-completed td:last-child {
    text-decoration: none;
}

/* Sortable table headers */
th.sortable {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}
th.sortable:hover {
    color: var(--accent);
}
th.sortable i {
    font-size: 0.7rem;
    margin-left: 3px;
    vertical-align: middle;
}
.sort-icon-inactive {
    opacity: 0.3;
}

/* Nav tabs */
.nav-tabs {
    border-bottom-color: var(--border);
}
.nav-tabs .nav-link {
    color: var(--text-muted);
    border: none;
    border-bottom: 2px solid transparent;
    padding: 0.5rem 1rem;
    background: none;
}
.nav-tabs .nav-link:hover {
    color: var(--text-primary);
    border-bottom-color: var(--text-muted);
}
.nav-tabs .nav-link.active {
    color: var(--accent);
    background: none;
    border-bottom-color: var(--accent);
}

/* Calendar */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    background: var(--border);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}
.calendar-header {
    background: var(--bg-sidebar);
    color: var(--text-muted);
    text-align: center;
    padding: 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}
.calendar-day {
    background: var(--bg-card);
    min-height: 100px;
    padding: 0.35rem;
    position: relative;
}
.calendar-day-other {
    background: var(--bg-dark);
    opacity: 0.5;
}
.calendar-day-today {
    background: var(--bg-card-hover);
}
.calendar-day-today .calendar-day-number {
    background: var(--accent);
    color: #fff;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.calendar-day-number {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 2px;
}
.calendar-item {
    font-size: 0.7rem;
    padding: 1px 4px;
    margin-bottom: 1px;
    border-radius: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
    border-left: 3px solid var(--text-muted);
    background: rgba(148, 163, 184, 0.1);
    color: var(--text-primary);
}
.calendar-item:hover {
    background: rgba(148, 163, 184, 0.2);
}
.calendar-item-priority-1 { border-left-color: var(--accent); }
.calendar-item-priority-2 { border-left-color: var(--warning); }
.calendar-item-priority-3 { border-left-color: #f97316; }
.calendar-item-priority-4 { border-left-color: var(--danger); }
.calendar-item-done {
    opacity: 0.4;
    text-decoration: line-through;
}
.calendar-item-more {
    font-size: 0.65rem;
    color: var(--text-muted);
    padding-left: 4px;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* Blazor error UI */
.blazor-error-boundary {
    background: var(--danger);
    padding: 1rem;
    color: white;
    border-radius: 8px;
}

.blazor-error-boundary::after {
    content: "An error has occurred.";
}

#blazor-error-ui {
    background: var(--danger);
    color: white;
    bottom: 0;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
}

/* Validation */
.valid.modified:not([type=checkbox]) {
    outline: none;
}

.invalid {
    outline: 1px solid var(--danger);
}

.validation-message {
    color: var(--danger);
    font-size: 0.85rem;
}

/* AI Report */
.ai-report {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 1rem;
}

.ai-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    transition: border-color 0.2s;
}

.ai-section:hover {
    border-color: rgba(59, 130, 246, 0.3);
}

.ai-section:first-child {
    grid-column: 1 / -1;
}

.ai-section-header {
    padding: 0.85rem 1.25rem;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
    background: rgba(59, 130, 246, 0.08);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.ai-section-header i {
    color: var(--accent);
    font-size: 1rem;
}

.ai-section-body {
    padding: 1rem 1.25rem;
}

.ai-text {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.65;
    margin-bottom: 0.5rem;
}

.ai-text:last-child {
    margin-bottom: 0;
}

.ai-list {
    list-style: none;
    padding-left: 0;
    margin: 0;
}

ul.ai-list li {
    position: relative;
    padding: 0.4rem 0 0.4rem 1.25rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.55;
    border-bottom: 1px solid rgba(30, 58, 95, 0.3);
}

ul.ai-list li:last-child {
    border-bottom: none;
}

ul.ai-list li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent-gradient);
}

ol.ai-list {
    padding-left: 0;
    counter-reset: ai-counter;
}

ol.ai-list li {
    counter-increment: ai-counter;
    position: relative;
    padding: 0.6rem 0 0.6rem 2.25rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.55;
    border-bottom: 1px solid rgba(30, 58, 95, 0.3);
}

ol.ai-list li:last-child {
    border-bottom: none;
}

ol.ai-list li::before {
    content: counter(ai-counter);
    position: absolute;
    left: 0;
    top: 0.55rem;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--accent-gradient);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-text strong,
.ai-list strong {
    color: var(--text-primary);
}

.ai-text code,
.ai-list code {
    background: rgba(59, 130, 246, 0.1);
    color: var(--accent);
    padding: 0.1em 0.4em;
    border-radius: 4px;
    font-size: 0.85em;
}

.ai-subsection {
    color: var(--text-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0.75rem 0 0.35rem;
}

/* Mobile */
.navbar-toggler {
    display: none;
}

@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
    }

    main {
        margin-left: 0;
    }

    .navbar-toggler {
        display: block;
    }
}

/* ========== Minimal Layout ========== */
.minimal-page {
    min-height: 100vh;
    background: var(--bg-dark);
}

/* ========== Login Page ========== */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 380px;
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-header h1 {
    font-size: 2rem;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 8px;
}

.login-header p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.login-field input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 1rem;
    outline: none;
    box-sizing: border-box;
    margin-bottom: 16px;
}

.login-field input:focus {
    border-color: var(--accent);
}

.login-btn {
    width: 100%;
    padding: 12px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
}

.login-btn:hover {
    background: var(--accent-hover);
}

.login-error {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.85rem;
    text-align: center;
    margin-bottom: 16px;
}

/* ========== Mobile Trade Page ========== */
.mobile-denied {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    color: var(--text-muted);
}

.mobile-trade-page {
    padding: 16px;
    max-width: 600px;
    margin: 0 auto;
    padding-bottom: 40px;
}

.mobile-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 12px;
}

.mobile-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
}

.mobile-date {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.mobile-range-bar {
    display: flex;
    gap: 6px;
    margin-bottom: 16px;
}

.mobile-range-bar a {
    flex: 1;
    padding: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
}

.mobile-range-bar a.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.mobile-hero {
    text-align: center;
    padding: 20px;
    border-radius: 14px;
    margin-bottom: 16px;
}

.mobile-hero.profit {
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.mobile-hero.loss {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.mobile-hero-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.mobile-hero-value {
    font-size: 2rem;
    font-weight: 700;
}

.mobile-hero.profit .mobile-hero-value { color: var(--success); }
.mobile-hero.loss .mobile-hero-value { color: var(--danger); }

.mobile-stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 16px;
}

.mobile-stats-grid.cols-2 {
    grid-template-columns: 1fr 1fr;
}

.mobile-stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px;
    text-align: center;
}

.mobile-stat-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 4px;
}

.mobile-stat-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.mobile-stat-sub {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.mobile-section {
    margin-bottom: 20px;
}

.mobile-section-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}

.mobile-chart-container {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px;
    height: 200px;
}

.mobile-trade-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 14px;
    margin-bottom: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.mobile-trade-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.mobile-trade-ticker {
    font-weight: 700;
    font-size: 0.95rem;
}

.mobile-trade-type {
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
}

.badge-call {
    background: rgba(59, 130, 246, 0.2);
    color: #3b82f6;
}

.badge-put {
    background: rgba(168, 85, 247, 0.2);
    color: #a855f7;
}

.mobile-trade-contracts {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.mobile-trade-right {
    text-align: right;
}

.mobile-trade-pl {
    font-weight: 700;
    font-size: 0.95rem;
}

.mobile-trade-date {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.text-profit { color: var(--success) !important; }
.text-loss { color: var(--danger) !important; }

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.spin { animation: spin 1s linear infinite; }
