/* =============================================================================
   Dashboard — UI redesign (matches the terminal's Portfolio / History pages)
   ============================================================================= */

.db2 { max-width: 1100px; padding: 32px 28px 56px; display: flex; flex-direction: column; gap: 20px; }
.db2 .mono { font-family: 'IBM Plex Mono', ui-monospace, monospace; font-variant-numeric: tabular-nums; }
.db2 .dashboard-greeting { margin: 0; }
.db2 .dashboard-greeting-text h1 { font-size: 1.5rem; font-weight: 600; letter-spacing: -0.3px; margin: 0 0 6px; }
.db2 .dashboard-greeting-text p { font-size: 0.8125rem; margin: 0; }

.db2-card { background: var(--bg-secondary); border: 1px solid var(--bg-tertiary); border-radius: 16px; padding: 20px; min-width: 0; }
.db2-section { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.db2-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.db2-title { margin: 0; font-size: 0.9375rem; font-weight: 600; color: var(--text-primary); }
.db2-sub { margin: 4px 0 0; font-size: 0.75rem; color: var(--text-secondary); }
.db2-link { font-size: 0.75rem; font-weight: 500; color: var(--accent); text-decoration: none; white-space: nowrap; }
.db2-link:hover { color: #FCD535; }
.db2-count { font-size: 0.75rem; color: var(--text-secondary); }
.db2-label { font-size: 0.75rem; color: var(--text-secondary); }
.db2-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; display: inline-block; flex-shrink: 0; box-sizing: border-box; }
.db2-empty { padding: 28px 16px; text-align: center; font-size: 0.8125rem; color: var(--text-tertiary); background: var(--bg-secondary); border: 1px solid var(--bg-tertiary); border-radius: 14px; }
.db2-empty a { color: var(--accent); }
.db2-disclaimer { margin: 0; font-size: 0.6875rem; color: var(--text-secondary); line-height: 1.5; }
.db2-disclaimer a { color: var(--accent); }

/* Briefing */
.db2-briefing { padding: 22px 24px; display: flex; flex-direction: column; gap: 18px; }
.db2-briefing-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.db2-briefing-week { margin: 4px 0 0; font-size: 1.0625rem; font-weight: 600; color: var(--text-primary); }
.db2-live { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: rgba(14, 203, 129, 0.12); color: var(--green); font-size: 0.75rem; font-weight: 600; }
.db2-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.db2-stat { padding: 16px; border-radius: 12px; background: var(--bg-tertiary); }
.db2-stat-val { font-size: 1.625rem; font-weight: 600; letter-spacing: -0.5px; margin-top: 6px; color: var(--text-primary); }
.db2-stat-sub { display: flex; gap: 10px; margin-top: 6px; font-size: 0.75rem; color: var(--text-secondary); }
.db2-stat-sub span { display: inline-flex; align-items: center; gap: 5px; }

/* Two columns */
.db2-two { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 20px; align-items: start; }

/* Actions list */
.db2-list { display: flex; flex-direction: column; gap: 6px; }
.db2-row {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 14px 16px; border-radius: 12px; background: var(--bg-secondary); border: 1px solid var(--bg-tertiary);
    text-decoration: none; color: var(--text-primary); transition: border-color 0.15s, background 0.15s;
}
a.db2-row:hover { border-color: #3A424C; background: #191D22; }
.db2-row-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.db2-row-text { min-width: 0; }
.db2-coin {
    width: 36px; height: 36px; flex-shrink: 0; border-radius: 50%; background: var(--border-color); color: var(--text-primary);
    display: flex; align-items: center; justify-content: center; font-size: 0.875rem; font-weight: 700;
    overflow: hidden;   /* coin logo fills the circle */
}
.db2-watch .db2-coin { width: 28px; height: 28px; font-size: 0.75rem; }
.db2-sym { font-size: 0.9375rem; font-weight: 600; color: var(--text-primary); }
.db2-alloc { margin-left: 8px; font-size: 0.75rem; color: var(--text-secondary); }
.db2-chips { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.db2-chip { padding: 2px 8px; border-radius: 999px; background: var(--bg-tertiary); color: var(--text-secondary); font-size: 0.6875rem; }
.db2-row-right { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex-shrink: 0; }
.db2-pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px 3px 8px; border-radius: 999px; font-size: 0.75rem; font-weight: 600; white-space: nowrap; }
.db2-pill--buy { background: rgba(14, 203, 129, 0.12); color: var(--green); }
.db2-pill--sell { background: rgba(246, 70, 93, 0.12); color: var(--red); }
.db2-pill--hold { background: rgba(240, 185, 11, 0.10); color: var(--accent); }
.db2-pill--hold .db2-dot { background: transparent; border: 1.5px solid currentColor; }
.db2-conf { display: inline-flex; align-items: center; gap: 4px; font-size: 0.6875rem; color: var(--text-secondary); white-space: nowrap; }
/* Risk level (from the signal's position size) — same words and dot colours
   as the terminal's holdings list and the Market overview */
.db2-sym-line { display: flex; align-items: center; flex-wrap: wrap; gap: 2px 10px; }
.db2-risk { display: inline-flex; align-items: center; gap: 5px; font-size: 0.75rem; color: var(--text-secondary); white-space: nowrap; }
.db2-risk--meta { font-size: inherit; }
.db2-risk-val { color: var(--text-primary); font-weight: 500; }
.risk-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; display: inline-block; }
.risk-dot--low { background: var(--green); }
.risk-dot--moderate { background: var(--accent); }
.risk-dot--high { background: var(--red); }
.db2-conf-bar { width: 44px; height: 3px; border-radius: 2px; background: var(--border-color); overflow: hidden; display: block; }
.db2-conf-bar > span { display: block; height: 100%; }
.db2-conf--buy .db2-conf-bar > span { background: var(--green); }
.db2-conf--sell .db2-conf-bar > span { background: var(--red); }

/* Signal performance */
.db2-quality { display: flex; flex-direction: column; gap: 16px; }
.db2-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.db2-tile { padding: 12px; border-radius: 10px; background: var(--bg-tertiary); }
.db2-tile .db2-label { font-size: 0.6875rem; }
.db2-tile-val { font-size: 1.0625rem; font-weight: 600; margin-top: 4px; }
.db2-chart { margin-top: 16px; }
.db2-chart-top { display: flex; justify-content: space-between; font-size: 0.75rem; color: var(--text-secondary); margin-bottom: 10px; }
.db2-bars { position: relative; height: 130px; display: flex; align-items: flex-end; gap: 6px; border-bottom: 1px solid var(--border-color); padding-top: 16px; }
.db2-midline { position: absolute; left: 0; right: 0; bottom: calc((100% - 16px) / 2); border-top: 1px dashed var(--border-color); pointer-events: none; }
.db2-bar-wrap { position: relative; flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; }
.db2-bar { display: block; width: 100%; border-radius: 4px 4px 0 0; max-height: 100%; }
/* Track Record benchmark colours: red <45% · yellow 45–55% · green 55%+ */
.db2-bar.is-poor { background: #E24B4A; }
.db2-bar.is-fair { background: #F0B90B; }
.db2-bar.is-good { background: #0ECB81; }
.db2-bar-val { font-size: 0.6875rem; color: var(--text-secondary); margin-bottom: 4px; }
.db2-chart-dates { display: flex; justify-content: space-between; font-size: 0.6875rem; color: var(--text-tertiary); margin-top: 6px; }

/* Watchlist */
.db2-watch-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.db2-watch {
    display: flex; flex-direction: column; gap: 10px; padding: 16px; border-radius: 12px;
    background: var(--bg-secondary); border: 1px solid var(--bg-tertiary); text-decoration: none; color: var(--text-primary);
    transition: border-color 0.15s, background 0.15s;
}
.db2-watch:hover { border-color: #3A424C; background: #191D22; }
.db2-watch-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.db2-watch .db2-sym { font-size: 0.875rem; }
.db2-watch .db2-row-left { gap: 10px; }
.db2-watch-meta { font-size: 0.75rem; color: var(--text-secondary); }
.db2-watch-meta .mono { color: var(--text-primary); }
.db2-watch .db2-chips { margin-top: 0; }   /* the card's own gap spaces the chips */
.db2-nowrap { white-space: nowrap; }
.db2-lock { display: inline-block; vertical-align: -1px; margin-left: 4px; color: var(--accent); }   /* Free: Starter and Pro detail */
.db2-risk .db2-lock { margin-left: 0; }   /* .db2-risk already spaces its items */
/* This week's actions: risk level + confidence on the logo line (desktop),
   on their own line under the logo (phones) */
.db2-action .db2-watch-top { flex-wrap: wrap; row-gap: 10px; }
.db2-action-meta { flex: 1; min-width: 0; margin-left: 4px; }
.db2-action .db2-watch-top > .sig-pill,
.db2-action .db2-watch-top > :last-child { margin-left: auto; }
@media (max-width: 640px) {
    .db2-action-meta { order: 3; flex-basis: 100%; margin-left: 0; }
}
.db2-nudge {
    display: flex; align-items: center; gap: 14px; padding: 12px 14px 12px 16px; border-radius: 12px;
    background: var(--bg-secondary); border: 1px solid var(--bg-tertiary);
}
.db2-nudge-icon { width: 32px; height: 32px; flex-shrink: 0; border-radius: 8px; display: flex; align-items: center; justify-content: center; background: rgba(91, 143, 255, 0.12); color: #5B8FFF; }
.db2-nudge--warn { background: rgba(240, 185, 11, 0.06); border-color: rgba(240, 185, 11, 0.25); }
.db2-nudge--warn .db2-nudge-icon { background: rgba(240, 185, 11, 0.12); color: var(--accent); }
.db2-nudge--danger { background: rgba(246, 70, 93, 0.06); border-color: rgba(246, 70, 93, 0.25); }
.db2-nudge--danger .db2-nudge-icon { background: rgba(246, 70, 93, 0.12); color: var(--red); }
.db2-nudge--ok .db2-nudge-icon { background: rgba(14, 203, 129, 0.12); color: var(--green); }
.db2-nudge-body { flex: 1; min-width: 0; }
.db2-nudge-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 0.8125rem; font-weight: 600; color: var(--text-primary); }
.db2-nudge-pill { padding: 1px 8px; border-radius: 999px; background: var(--bg-tertiary); color: var(--text-secondary); font-size: 0.6875rem; font-weight: 500; }
.db2-nudge-sub { font-size: 0.75rem; color: var(--text-secondary); margin-top: 2px; }
.db2-nudge-action {
    flex-shrink: 0; display: inline-flex; align-items: center; padding: 8px 14px; border-radius: 8px;
    border: 1px solid var(--border-color); color: var(--text-primary); font-size: 0.75rem; font-weight: 500; text-decoration: none;
}
.db2-nudge--warn .db2-nudge-action, .db2-nudge--danger .db2-nudge-action { background: var(--accent); border-color: var(--accent); color: var(--bg-primary); font-weight: 600; }
.db2-nudge-action:hover { border-color: #3A424C; }
button.db2-nudge-action { background: transparent; font-family: inherit; cursor: pointer; }
button.db2-nudge-action:disabled { opacity: 0.6; cursor: default; }

/* Side by side (desktop): Signal performance card matches the height of the
   actions list; the extra room goes to the weekly bars */
@media (min-width: 901px) {
    .db2-two { align-items: stretch; }
    .db2-two > .db2-section { display: flex; flex-direction: column; }
    .db2-two .db2-quality { flex: 1; }
    #dbSignalQuality, #dbWeeklyChart, #dbSignalQuality .db2-chart { flex: 1; display: flex; flex-direction: column; }
    #dbSignalQuality .db2-bars { flex: 1; height: auto; min-height: 130px; }
}
@media (max-width: 900px) {
    .db2-two { grid-template-columns: minmax(0, 1fr); }
}
/* Tablet: Signal performance card spans the full width, so the weekly bars get more height */
@media (min-width: 641px) and (max-width: 900px) {
    #dbSignalQuality .db2-bars { height: 250px; }
}
@media (max-width: 640px) {
    .db2 { padding: 20px 16px 96px; gap: 18px; }
    .db2-briefing { padding: 18px; }
    .db2-stats { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
    .db2-stats .db2-stat:last-child { grid-column: 1 / -1; }
    .db2-stat-val { font-size: 1.375rem; }
    /* Text beside the icon, button full width on its own line below */
    .db2-nudge { flex-wrap: wrap; }
    .db2-nudge-body { flex-basis: calc(100% - 46px); }
    .db2-nudge-action { width: 100%; justify-content: center; }
}
.db2-alloc { white-space: nowrap; }
@media (max-width: 640px) {
    .db2-row { padding: 12px 14px; }
    .db2-row-text > div:first-child { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; }
    .db2-alloc { margin-left: 0; }
}

/* ── What our signals did for your coins ─────────────────────────────────────────── */
.db2-whatif { padding: 22px 24px; display: flex; flex-direction: column; gap: 18px; }
.db2-whatif[hidden] { display: none; }
.db2-wf-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.db2-wf-title { font-size: 1.0625rem; }
.db2-whatif .pos { color: var(--green); }
.db2-whatif .neg { color: var(--red); }
.db2-seg { display: inline-flex; gap: 2px; padding: 3px; border-radius: 8px; background: var(--bg-tertiary); }
.db2-seg button {
    padding: 5px 12px; border: 0; border-radius: 6px; background: transparent; color: var(--text-secondary);
    font-family: inherit; font-size: 0.75rem; font-weight: 600; cursor: pointer;
}
.db2-seg button:hover { color: var(--text-primary); }
.db2-seg button.active { background: var(--border-color); color: var(--text-primary); }

.db2-wf-body { display: grid; grid-template-columns: minmax(0, 280px) minmax(0, 1fr); gap: 28px; align-items: start; }
.db2-wf-nums { display: flex; flex-direction: column; gap: 16px; }
.db2-wf-key { display: flex; align-items: center; gap: 8px; font-size: 0.8125rem; color: var(--text-primary); }
.db2-wf-swatch { width: 16px; height: 3px; border-radius: 2px; background: var(--accent); display: inline-block; }
.db2-wf-swatch--hold { height: 0; border-radius: 0; background: none; border-top: 2px dashed var(--text-secondary); }
.db2-wf-big { margin-top: 4px; font-size: 1.875rem; font-weight: 600; letter-spacing: -0.5px; }
.db2-wf-usd { font-size: 0.75rem; color: var(--text-secondary); }
/* Rounded box rather than a pill, so it still looks right when it wraps to two lines */
.db2-wf-verdict { align-self: flex-start; padding: 6px 12px; border-radius: 10px; font-size: 0.8125rem; font-weight: 600; line-height: 1.45; }
.db2-wf-verdict.pos { background: rgba(14, 203, 129, 0.12); }
.db2-wf-verdict.neg { background: rgba(246, 70, 93, 0.12); }
.db2-wf-added { font-size: 0.75rem; line-height: 1.5; color: var(--text-secondary); }

.db2-wf-chart { display: grid; grid-template-columns: 48px minmax(0, 1fr); gap: 8px; }
.db2-wf-y { position: relative; height: 200px; }
.db2-wf-y span { position: absolute; right: 0; transform: translateY(-50%); font-size: 0.6875rem; color: var(--text-tertiary); }
.db2-wf-plot { position: relative; min-width: 0; }
.db2-wf-plot svg { display: block; width: 100%; height: 200px; overflow: visible; }
.db2-wf-zero { stroke: var(--border-color); stroke-width: 1; stroke-dasharray: 4 4; }
.db2-wf-hold { fill: none; stroke: var(--text-secondary); stroke-width: 2; stroke-dasharray: 6 5; }
.db2-wf-sig { fill: none; stroke: var(--accent); stroke-width: 2.5; }
.db2-wf-x { position: relative; height: 22px; }
.db2-wf-x span { position: absolute; top: 6px; font-size: 0.6875rem; color: var(--text-tertiary); white-space: nowrap; }

.db2-wf-table { border-top: 1px solid var(--border-color); }
.db2-wf-row {
    display: grid; grid-template-columns: minmax(150px, 1.4fr) repeat(3, minmax(90px, 1fr)) minmax(110px, 1fr);
    gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--bg-tertiary); font-size: 0.8125rem;
}
.db2-wf-row > span:not(.db2-wf-coin) { text-align: right; font-weight: 600; }
.db2-wf-th { font-size: 0.75rem; color: var(--text-secondary); }
.db2-wf-th > span { font-weight: 500 !important; }
.db2-wf-th > span:first-child { text-align: left !important; }
.db2-wf-coin { display: flex; align-items: center; gap: 10px; min-width: 0; }
.db2-wf-coin .db2-coin { width: 20px; height: 20px; font-size: 0.6875rem; overflow: hidden; }
.db2-wf-coin .db2-sym { font-size: 0.875rem; }
.db2-wf-name { font-size: 0.75rem; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.db2-wf-out { font-size: 0.75rem; color: var(--text-secondary); }
.db2-wf-out a, .db2-wf-out .link-btn { color: var(--accent); font-weight: 600; text-decoration: none; }
.db2-wf-empty { padding: 18px 0; font-size: 0.8125rem; color: var(--text-secondary); }
.db2-wf-how { display: flex; flex-direction: column; gap: 6px; padding: 12px 14px; border-radius: 10px; background: var(--bg-primary); font-size: 0.75rem; line-height: 1.55; color: var(--text-secondary); }
.db2-wf-how b { color: var(--text-primary); font-weight: 600; }
.db2-wf-fine { color: var(--text-tertiary); }
.db2-wf-how--phone, .db2-wf-fine--phone { display: none; }
.db2-wf-how--phone summary { list-style: none; cursor: pointer; min-height: 44px; display: flex; align-items: center; justify-content: space-between; color: var(--text-primary); font-weight: 600; }
.db2-wf-how--phone summary::-webkit-details-marker { display: none; }
.db2-wf-how--phone summary::after { content: '›'; font-size: 1rem; color: var(--text-secondary); transition: transform 0.2s; }
.db2-wf-how--phone[open] summary::after { transform: rotate(90deg); }
.db2-wf-how--phone summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
@media (prefers-reduced-motion: reduce) { .db2-wf-how--phone summary::after { transition: none; } }

@media (max-width: 760px) {
    .db2-whatif { padding: 18px; }
    .db2-wf-body { grid-template-columns: minmax(0, 1fr); gap: 18px; }
    .db2-wf-nums { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
    .db2-wf-verdict, .db2-wf-added { grid-column: 1 / -1; }
    .db2-wf-big { font-size: 1.5rem; }
    .db2-wf-chart { grid-template-columns: 44px minmax(0, 1fr); gap: 6px; }
    /* Rows become a compact list: coin + this week's signal, then the three numbers */
    .db2-wf-th { display: none; }
    .db2-wf-row { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px 10px; padding: 12px 0; }
    .db2-wf-coin { grid-column: 1 / 3; }
    .db2-wf-now { grid-column: 3; grid-row: 1; }
    .db2-wf-row > span[data-k] { text-align: left; font-size: 0.75rem; }
    .db2-wf-row > span[data-k="Holding"] { text-align: center; }
    .db2-wf-row > span[data-k="Difference"] { text-align: right; }
    .db2-wf-now { justify-self: end; text-align: right; }
    .db2-wf-how--wide { display: none; }
    .db2-wf-how--phone { display: block; padding: 0 14px; }
    .db2-wf-how--phone[open] { padding-bottom: 12px; }
    .db2-wf-fine--phone { display: block; margin-top: -10px; padding: 0 2px; font-size: 0.6875rem; line-height: 1.55; }
    .db2-wf-row > span[data-k]::before { content: attr(data-k); display: block; font-family: Inter, sans-serif; font-weight: 400; font-size: 0.6875rem; color: var(--text-secondary); }
}

/* Apple HIG: every button and link can be tapped in a 44 × 44px area */
button.db2-nudge-action, .db2-nudge-action { min-height: 44px; min-width: 44px; }
.db2-link { min-height: 44px; display: inline-flex; align-items: center; gap: 4px; }   /* gap: flex drops the space before the arrow */
/* Period tabs: 44px tall, all the same width */
.db2-seg { display: inline-grid; grid-auto-flow: column; grid-auto-columns: 1fr; }
.db2-seg button { min-height: 44px; min-width: 44px; }

/* What-if placeholder (drawn with the page) and the fade when numbers arrive */
.db2-wf-sk-title { flex: 1; min-width: 0; }
.db2-wf-sk-sub2 { display: none; margin-top: 6px; }
.db2-wf-sk-seg { width: 140px; height: 50px; border-radius: 8px; flex: none; }
.db2-wf-sk-nums { width: 100%; height: 308px; border-radius: 10px; }
.db2-wf-sk-chart { width: 100%; height: 222px; border-radius: 10px; }
.db2-wf-sk-head { height: 28px; margin-bottom: 8px; border-radius: 6px; }
.db2-wf-sk-row { height: 34px; margin-bottom: 8px; border-radius: 6px; }
.db2-wf-sk-how { height: 104px; border-radius: 10px; }
@media (max-width: 760px) {
    .db2-wf-sk-title { flex-basis: 100%; }
    .db2-wf-sk-sub2 { display: block; }
    .db2-wf-sk-nums { height: 175px; }
    .db2-wf-sk-head { display: none; }
    .db2-wf-sk-row { height: 72px; }
    .db2-wf-sk-how { height: 84px; }
}
.db2-wf-in > * { animation: db2WfIn 0.25s ease-out; }
@keyframes db2WfIn { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .db2-wf-in > * { animation: none; } }

/* Weekly briefing: when it was last updated (it changes weekly, so not "Live") */
.db2-updated { display: inline-flex; align-items: center; padding: 4px 12px; border-radius: 999px; background: var(--bg-tertiary); color: var(--text-secondary); font-size: 0.75rem; font-weight: 500; white-space: nowrap; }

/* Dashboard couldn't load: error at the top with Retry */
.db2-error { display: flex; align-items: center; justify-content: space-between; gap: 12px; border-color: rgba(247, 90, 109, 0.35) !important; background: rgba(247, 90, 109, 0.06) !important; }
.db2-error-title { font-size: 0.9375rem; font-weight: 600; color: var(--text-primary); }
.db2-error-retry {
    flex-shrink: 0; min-height: 44px; padding: 0 18px; border-radius: 10px; border: 1px solid #474D57;
    background: transparent; color: var(--text-primary); font: 600 0.875rem Inter, -apple-system, BlinkMacSystemFont, sans-serif; cursor: pointer;
}
.db2-error-retry:hover { border-color: var(--text-secondary); }
#dashboardPage > [hidden] { display: none !important; }
