/* Deep Backtest (app/deep-backtest.js). Builds on the optimizer's dialog styles (app/strategy-optimizer.css). */

.db-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 14px; }
.db-field { display: flex; flex-direction: column; gap: 5px; }
.db-range {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-width: 290px;
    height: 38px;
    padding: 0 12px;
    color: var(--text);
    font: 500 14px/1 Inter, -apple-system, "Segoe UI", sans-serif;
    font-variant-numeric: tabular-nums;
    text-align: left;
    cursor: pointer;
}
.db-range span { flex: 1; white-space: nowrap; }
.db-range em { margin: 0 8px; color: var(--text-muted); font-style: normal; }
.db-range svg { flex: none; width: 16px; height: 16px; color: var(--text-muted); }
.db-range svg:first-child { color: var(--accent); }
.db-range:hover, .db-range.is-open { border-color: var(--accent); }
.db-range.is-open svg:last-child { transform: rotate(180deg); }

/* ---- the calendar (on the page, over the dialog) */
.db-pop {
    position: fixed;
    z-index: 85;
    width: 300px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 12px 32px rgba(0, 0, 0, .35);
    font: 400 13px/1.2 Inter, -apple-system, "Segoe UI", sans-serif;
}
.db-pop[hidden] { display: none; }
.db-pop button:not(.al-btn) { font: inherit; color: inherit; }
.db-pop-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 10px; }
.db-pop-tab {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 3px;
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: none;
    cursor: pointer;
}
.db-pop-tab small { color: var(--text-muted); font-size: 11px; }
.db-pop-tab strong { font-weight: 600; font-variant-numeric: tabular-nums; }
.db-pop-tab.is-active { border-color: var(--accent); background: var(--accent-soft); }
.db-pop-nav { display: flex; align-items: center; gap: 4px; margin-bottom: 6px; }
.db-pop-title { flex: 1; height: 30px; border: 0; border-radius: 6px; background: none; font-weight: 600 !important; cursor: pointer; }
.db-pop-title:hover, .db-pop-arrow:hover { background: var(--surface-2); }
.db-pop-arrow { display: grid; place-items: center; width: 30px; height: 30px; border: 0; border-radius: 6px; background: none; cursor: pointer; }
.db-pop-arrow svg { width: 16px; height: 16px; }
.db-pop-grid { display: grid; grid-template-columns: repeat(7, 1fr); row-gap: 2px; }
.db-pop-grid.is-months { grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 4px 0; }
.db-pop-dow { padding: 6px 0; color: var(--text-muted); font-size: 11px; text-align: center; }
.db-pop-day {
    height: 34px;
    border: 0;
    border-radius: 8px;
    background: none;
    font-variant-numeric: tabular-nums;
    cursor: pointer;
}
.db-pop-day:hover:not(:disabled) { background: var(--surface-2); }
.db-pop-day.is-today { box-shadow: inset 0 0 0 1px var(--border); }
.db-pop-day.is-in { border-radius: 0; background: var(--accent-soft); }
.db-pop-day.is-start, .db-pop-day.is-end { background: var(--accent) !important; color: #fff !important; font-weight: 600; }
.db-pop-day.is-start:not(.is-end) { border-radius: 8px 0 0 8px; }
.db-pop-day.is-end:not(.is-start) { border-radius: 0 8px 8px 0; }
.db-pop-day:disabled, .db-pop-month:disabled { color: var(--text-muted); opacity: .35; cursor: default; }
.db-pop-month { height: 40px; border: 1px solid var(--border); border-radius: 8px; background: none; cursor: pointer; }
.db-pop-month:hover:not(:disabled) { background: var(--surface-2); }
.db-pop-month.is-current { border-color: var(--accent); }
.db-pop-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; }
.db-pop-note { color: var(--text-muted); font-size: 12px; }
.db-pop-done { height: 32px; padding: 0 16px; }
.db-cost { width: 120px; height: 38px; }
.db-presets { display: flex; gap: 4px; padding-bottom: 3px; }
.db-preset {
    height: 32px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: none;
    color: var(--text-muted);
    font: 500 12px/1 Inter, -apple-system, "Segoe UI", sans-serif;
    cursor: pointer;
}
.db-preset:hover { background: var(--surface-2); color: var(--text); }

.db-chart { display: flex; flex-direction: column; gap: 4px; }
.db-svg { width: 100%; height: 180px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.db-svg path { fill: none; stroke-width: 1.6; stroke-linejoin: round; }
.db-svg .db-line.is-up { stroke: var(--up); }
.db-svg .db-line.is-down { stroke: var(--down); }
.db-svg .db-line-gross { stroke: var(--text-muted); stroke-dasharray: 4 4; stroke-width: 1.2; opacity: .7; }
.db-svg .db-base { stroke: var(--border); stroke-width: 1; }
.db-axis { display: flex; justify-content: space-between; gap: 8px; color: var(--text-muted); font-size: 12px; font-variant-numeric: tabular-nums; }

.db-months th, .db-months td { padding: 6px 4px; font-size: 12px; }
.db-months th:first-child, .db-months td:first-child { padding-left: 10px; }
.db-cell.is-up { color: var(--up); background: color-mix(in srgb, var(--up) 12%, transparent); }
.db-cell.is-down { color: var(--down); background: color-mix(in srgb, var(--down) 12%, transparent); }

@media (max-width: 640px) {
    .db-field { flex: 1 1 40%; min-width: 0; }
    .db-cost { width: 100%; font-size: 16px; }
    .db-field:has(.db-range) { flex-basis: 100%; }
    .db-range { width: 100%; min-width: 0; font-size: 15px; }
    .db-pop.is-sheet { left: 8px; right: 8px; bottom: 8px; width: auto; }
    .db-presets { flex: 1 0 100%; }
    .db-preset { flex: 1; }
    .db-axis span:nth-child(2) { display: none; }
    .st-deep span { display: none; }
}
