/* ── Pico CSS variable overrides ────────────────────────────── */
:root {
    --pico-font-size: 93.75%; /* 15px base */
    --pico-border-radius: 0.5rem;
    --pico-primary: #2563eb;
    --pico-primary-background: #2563eb;
    --pico-primary-hover: #1d4ed8;
    --pico-primary-hover-background: #1d4ed8;

    /* Aliases used in domain-specific CSS below */
    --color-bg: var(--pico-background-color);
    --color-surface: var(--pico-card-background-color);
    --color-primary: var(--pico-primary);
    --color-text: var(--pico-color);
    --color-text-muted: var(--pico-muted-color);
    --color-border: var(--pico-muted-border-color);
    --color-error: #dc2626;
    --radius: var(--pico-border-radius);
}

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a {
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* ── Theme toggle ───────────────────────────────────────────── */
.theme-toggle {
    background: none;
    border: none;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    line-height: 1;
    width: auto;
    box-shadow: none;
}

.theme-toggle:hover {
    background: none;
}

/* ── Site Header ────────────────────────────────────────────── */
.site-header {
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--pico-background-color);
}

.site-brand {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--color-primary) !important;
    text-decoration: none !important;
}

.site-footer {
    text-align: center;
    font-size: 0.85rem;
    color: var(--color-text-muted);
    border-top: 1px solid var(--color-border);
    padding-top: 1rem;
    padding-bottom: 1rem;
}

/* ── Layout ─────────────────────────────────────────────────── */
main.container {
    flex: 1;
}

.hero {
    text-align: center;
    padding: 4rem 0;
}

.hero h1 {
    font-size: 2.75rem;
    font-weight: 800;
}

/* ── Page Header ────────────────────────────────────────────── */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.page-header h1 {
    font-size: 1.75rem;
}

.page-header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-left: auto;
}

.page-header-hint {
    margin: 0;
    font-size: 0.875rem;
    color: var(--color-text-muted);
}

/* ── Form pages ─────────────────────────────────────────────── */
/* Pico handles input/label/select/textarea styling */
.form-page {
    display: flex;
    justify-content: center;
    padding: 2rem 0;
}

/* article = Pico card; constrain width for forms */
.form-card {
    width: 100%;
    max-width: 480px;
}

.form-card--manager {
    max-width: 560px;
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

/* .contrast = danger (red) */
button.contrast, [type="submit"].contrast, [role="button"].contrast {
    background-color: #dc2626;
    border-color: #dc2626;
    color: #fff;
}
button.contrast:hover, [type="submit"].contrast:hover, [role="button"].contrast:hover {
    background-color: #b91c1c;
    border-color: #b91c1c;
}

.form-error {
    color: var(--color-error);
    margin-bottom: 1rem;
}

/* Form in flex containers: don't block layout; button becomes direct flex child */
.actions form,
.page-header-right form { display: contents; }

/* ── Flash messages ─────────────────────────────────────────── */
.flash-error {
    background: #fef2f2;
    color: var(--color-error);
    border: 1px solid #fecaca;
    border-radius: var(--radius);
    padding: 0.65rem 1rem;
    margin-bottom: 1rem;
}

.flash-success {
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
    border-radius: var(--radius);
    padding: 0.65rem 1rem;
    margin-bottom: 1rem;
}

.flash-warning {
    background: #fffbeb;
    color: #92400e;
    border: 1px solid #fde68a;
    border-radius: var(--radius);
    padding: 0.65rem 1rem;
    margin-bottom: 1rem;
}

/* ── Misc utilities ─────────────────────────────────────────── */
.text-muted { color: var(--color-text-muted); }
.empty-state { text-align: center; color: var(--color-text-muted); padding: 3rem 0; }
.truncate { font-family: monospace; font-size: 0.85rem; }
.add-link { color: var(--color-text-muted); font-size: 1.25rem; font-weight: 300; line-height: 1; text-decoration: none; }
.add-link:hover { color: var(--color-primary); text-decoration: none; }

/* ── Strategy Tabs ──────────────────────────────────────────── */
.strategy-tabs-nav {
    display: flex;
    border-bottom: 2px solid var(--color-border);
    margin-bottom: 1.5rem;
}

.strategy-tab {
    padding: 0.75rem 1.25rem;
    border: none;
    background: none;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--color-text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    text-decoration: none;
    display: inline-block;
}

.strategy-tab:hover { color: var(--color-text); text-decoration: none; }
.strategy-tab--active { color: var(--color-primary); border-bottom-color: var(--color-primary); }

/* ── Tables — Pico classless styles plain <table> ───────────── */
.table-scroll { overflow-x: auto; }
.actions { display: flex; gap: 0.5rem; }

.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.nowrap {
    white-space: nowrap;
    font-size: 0.85rem;
}

.side-buy  { color: #16a34a; font-weight: 600; }
.side-sell { color: var(--color-error); font-weight: 600; }

.perf-stats-table th:first-child,
.perf-stats-table td:first-child { font-weight: 500; }
.perf-stats-table th:not(:first-child) { text-align: right; }
.perf-stats-table td.num { min-width: 5rem; }

/* Monthly returns: compact cells, horizontal scroll */
.monthly-returns-wrapper {
    overflow-x: auto;
    max-width: 100%;
    -webkit-overflow-scrolling: touch;
}

.monthly-returns-table { table-layout: fixed; width: 100%; }
.monthly-returns-table th,
.monthly-returns-table td { padding: 0.4rem 0.35rem; font-size: 0.8rem; }
.monthly-returns-table .month-best { background: rgba(22, 163, 74, 0.2); font-weight: 600; }
.monthly-returns-table .month-worst { background: rgba(220, 38, 38, 0.2); font-weight: 600; }

/* ── Filter Bar — <article> wrapper provides card ───────────── */
.filter-bar { margin-bottom: 1.5rem; }

.filter-form {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: flex-end;
    margin: 0;
}

.filter-group { display: flex; flex-direction: column; gap: 0.25rem; }

.filter-group label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--color-text-muted);
    margin-bottom: 0;
}

.filter-group select,
.filter-group input[type="date"] { margin-bottom: 0; }

.filter-actions { display: flex; gap: 0.5rem; align-items: flex-end; }

/* ── Trades layout ──────────────────────────────────────────── */
.trades-layout {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 1.5rem;
    align-items: start;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 1rem;
}

.results-header h2 { font-size: 1.25rem; }
.results-count { font-size: 0.85rem; color: var(--color-text-muted); }

/* ── Stats — PnL totals ─────────────────────────────────────── */
.stats-totals-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stats-total-card {
    flex: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--pico-box-shadow);
}

.pnl-positive-bg { background: #f0fdf4; border: 1px solid #bbf7d0; }
.pnl-negative-bg { background: #fef2f2; border: 1px solid #fecaca; }

.stats-total-label {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--color-text-muted);
}

.stats-total-value {
    font-size: 1.5rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.pnl-positive { color: #16a34a; }
.pnl-negative { color: var(--color-error); }

.stats-section { margin-bottom: 1.5rem; }
.stats-section h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--color-text-muted);
}

/* ── Stats — DD notes panel ─────────────────────────────────── */
.notes-columns { display: flex; gap: 1rem; }
.notes-columns .dd-notes { flex: 1; }

.dd-notes {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    line-height: 1.8;
}

.dd-note-heading {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-muted);
    margin-bottom: 0.5rem;
    padding-bottom: 0.35rem;
    border-bottom: 2px solid var(--color-border);
}

.dd-note-row { display: flex; gap: 0.5rem; }
.dd-note-label { font-weight: 600; color: var(--color-text-muted); min-width: 110px; }
.dd-note-value { color: var(--color-text); font-weight: 500; }
.dd-note-divider { border-top: 1px solid var(--color-border); margin: 0.35rem 0; }

/* ── Day Card — Pico handles <details> base styles ──────────── */
.day-card { margin-bottom: 0.5rem; }
.day-card[open] { margin-bottom: 1rem; }

.day-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.day-header::after { display: none; } /* hide Pico's chevron */

.day-header h3 { font-size: 0.95rem; font-weight: 600; margin: 0; }

.day-header-pills {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.day-pill {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    background: var(--pico-card-sectioning-background-color);
    border: 1px solid var(--color-border);
    font-variant-numeric: tabular-nums;
}

.day-pill-total { font-weight: 700; }

/* ── EOD Summary ────────────────────────────────────────────── */
.eod-summary {
    border-top: 2px solid var(--color-border);
    padding: 0.75rem 1rem;
    background: var(--pico-card-sectioning-background-color);
}

.eod-summary h4 {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--color-text-muted);
    margin-bottom: 0.5rem;
}

.eod-table { background: transparent; width: auto; min-width: 500px; }
.eod-table th, .eod-table td { padding: 0.4rem 1rem; }
.eod-table th:first-child, .eod-table td:first-child { padding-left: 0; }
.eod-warning { font-size: 0.8rem; color: #92400e; margin-top: 0.35rem; }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 900px) {
    .trades-layout { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
    .hero h1 { font-size: 2rem; }
    .stats-totals-row { flex-wrap: wrap; }
    .notes-columns { flex-direction: column; }
}
