/* =========================================================================
   Crypto Trader — D-Base dark theme
   Mobile-first. CSS custom properties for theming. dbase- prefixed classes.
   ========================================================================= */

:root {
    --dbase-bg: #0d0d0d;
    --dbase-surface: #161616;
    --dbase-surface-2: #1d1d1d;
    --dbase-border: #2a2a2a;
    --dbase-buy: #00c896;
    --dbase-sell: #ff4d4d;
    --dbase-hold: #c9a227;
    --dbase-text: #f0f0f0;
    --dbase-muted: #a3a3a3;
    --dbase-accent: #00c896;

    /* Form fields — lighter than the surface so they read as editable */
    --dbase-input-bg: #242424;
    --dbase-input-border: #3d3d3d;
    --dbase-input-border-hover: #525252;

    --dbase-radius: 10px;
    --dbase-radius-sm: 6px;
    --dbase-sidebar-w: 280px;
    --dbase-gap: 1rem;
    --dbase-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--dbase-bg);
    color: var(--dbase-text);
    font-family: var(--dbase-font);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    /* Render native controls (checkboxes, spinners, scrollbars) for dark UI */
    color-scheme: dark;
}

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

/* ---------- Layout ------------------------------------------------------- */

.dbase-layout {
    display: flex;
    min-height: 100vh;
}

.dbase-sidebar {
    width: var(--dbase-sidebar-w);
    flex-shrink: 0;
    background: var(--dbase-surface);
    border-right: 1px solid var(--dbase-border);
    /* mobile-first: off-canvas overlay */
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 60;
    transform: translateX(0);
    transition: transform 0.22s ease;
    overflow-y: auto;
    padding: 1.25rem;
}

body.dbase-sidebar-collapsed .dbase-sidebar {
    transform: translateX(-100%);
}

.dbase-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 55;
}
body:not(.dbase-sidebar-collapsed) .dbase-backdrop { display: block; }

.dbase-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

/* ---------- Top bar ------------------------------------------------------ */

.dbase-topbar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.25rem;
    background: var(--dbase-surface);
    border-bottom: 1px solid var(--dbase-border);
    position: sticky;
    top: 0;
    z-index: 40;
}

.dbase-hamburger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: var(--dbase-surface-2);
    border: 1px solid var(--dbase-border);
    border-radius: var(--dbase-radius-sm);
    color: var(--dbase-text);
    cursor: pointer;
}
.dbase-hamburger:hover { border-color: var(--dbase-accent); }

.dbase-topbar-title {
    font-weight: 600;
    font-size: 1.05rem;
    letter-spacing: 0.2px;
}

.dbase-topbar-spacer { flex: 1; }

/* Currency segmented switch */
.dbase-ccy-switch {
    display: inline-flex;
    border: 1px solid var(--dbase-border);
    border-radius: var(--dbase-radius-sm);
    overflow: hidden;
    background: var(--dbase-surface-2);
}
.dbase-ccy-btn {
    border: 0;
    background: transparent;
    color: var(--dbase-muted);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    padding: 0.35rem 0.7rem;
    cursor: pointer;
    font-family: inherit;
}
.dbase-ccy-btn:hover { color: var(--dbase-text); }
.dbase-ccy-btn.is-active { background: var(--dbase-accent); color: #04231b; }

/* ---------- Brand / nav -------------------------------------------------- */

.dbase-brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-weight: 700;
    font-size: 1.15rem;
    margin-bottom: 1.25rem;
    color: var(--dbase-text);
}
.dbase-brand svg { color: var(--dbase-accent); }

.dbase-nav { list-style: none; margin: 0 0 1.5rem; padding: 0; }
.dbase-nav li { margin-bottom: 0.25rem; }
.dbase-nav a {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 0.7rem;
    border-radius: var(--dbase-radius-sm);
    color: var(--dbase-muted);
    font-weight: 500;
}
.dbase-nav a:hover { background: var(--dbase-surface-2); color: var(--dbase-text); text-decoration: none; }
.dbase-nav a.is-active { background: var(--dbase-surface-2); color: var(--dbase-text); }
.dbase-nav a.is-active svg { color: var(--dbase-accent); }

.dbase-sidebar-section-title {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.72rem;
    color: var(--dbase-muted);
    margin: 1rem 0 0.6rem;
}

/* Small action sitting on a section title — "+ Add" beside "Watching". Coloured
   rather than muted so it reads as a control, not part of the heading. */
.dbase-sidebar-action {
    color: var(--dbase-buy);
    text-decoration: none;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: none;
}
.dbase-sidebar-action:hover { text-decoration: underline; }

/* ---------- Main content ------------------------------------------------- */

.dbase-main { padding: 1.5rem 1.25rem; }

.content-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}
.content-header h1 { margin: 0; font-size: 1.4rem; font-weight: 700; }
.content-header .content-sub { color: var(--dbase-muted); font-size: 0.85rem; }

/* Header controls sit together; wraps under the heading on narrow screens. */
.dbase-header-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
}
.dbase-autorefresh {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--dbase-muted);
    font-size: 0.8rem;
    cursor: pointer;
    user-select: none;
}
.dbase-autorefresh input { accent-color: var(--dbase-buy); cursor: pointer; }
.dbase-autorefresh:hover { color: var(--dbase-text); }

/* ---------- Cards -------------------------------------------------------- */

.dbase-card-grid {
    display: grid;
    /* minmax(0,1fr), not 1fr: a bare 1fr track has an implicit min-width of
       auto, so a nowrap child forces the column past the viewport and the page
       scrolls sideways on mobile. */
    grid-template-columns: minmax(0, 1fr);
    gap: var(--dbase-gap);
}

/* Panels sit raised off the page: a 1px border only four shades above the
   background left adjacent boxes bleeding into one another. A lighter border, a
   lifted surface and a soft shadow give each an edge without adding noise. */
.dbase-card {
    background: var(--dbase-surface-2);
    border: 1px solid #3a3a3a;
    border-radius: var(--dbase-radius);
    padding: 1.1rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
}

/* A panel inside a panel steps back down, so nesting stays legible instead of
   compounding into one flat block. */
.dbase-card .dbase-card {
    background: var(--dbase-surface);
    border-color: var(--dbase-border);
    box-shadow: none;
}

/* Coin tiles inherit the raised look from .dbase-card; these add the hover
   response, since they sit in a dense grid where knowing which one you are on
   matters. Static panels deliberately don't react to the pointer. */
.dbase-coin-card,
.dbase-coin-config {
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.dbase-coin-card:hover,
.dbase-coin-config:hover {
    border-color: #4d4d4d;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.55);
}
/* Nested panels must stay darker than the card they sit on, or they disappear
   now that the card itself is lighter. Inputs keep their own lighter treatment
   so they still read as editable. */
.dbase-coin-card .dbase-metric {
    background: var(--dbase-surface);
    border: 1px solid #303030;
}

/* An excluded coin. Kept on the page so it can be re-enabled or removed, but
   visibly set apart — its figures are whatever was last recorded, not live. */
.dbase-coin-card-inactive {
    opacity: 0.5;
    border-style: dashed;
    box-shadow: none;
}
.dbase-coin-card-inactive:hover { opacity: 0.75; box-shadow: none; }

/* A coin with an open position. Qualified with .dbase-card so it outranks the
   base card border regardless of source order — the specificity trap that has
   bitten this stylesheet three times already. */
.dbase-card.dbase-coin-card-held {
    border-color: var(--dbase-buy);
    box-shadow: 0 0 0 1px var(--dbase-buy) inset;
}

/* "About this coin" link. Sits quietly beside the name until hovered. */
.dbase-coin-info {
    display: inline-flex;
    align-items: center;
    margin-left: 0.35rem;
    color: var(--dbase-muted);
    vertical-align: middle;
    opacity: 0.65;
    transition: color 0.15s ease, opacity 0.15s ease;
}
.dbase-coin-info:hover,
.dbase-coin-info:focus-visible { color: var(--dbase-accent); opacity: 1; }

/* Visible to screen readers only — the icon alone has no accessible name. */
.dbase-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.dbase-coin-card .dbase-coin-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.85rem;
}
.dbase-coin-name { font-weight: 700; font-size: 1.1rem; }
.dbase-coin-symbol { color: var(--dbase-muted); font-size: 0.78rem; }
/* The readable half of the line — lifted out of the muted grey so the eye lands
   on the name rather than the Binance pair beside it. */
.dbase-coin-fullname { color: var(--dbase-text); font-weight: 600; }
.dbase-coin-price { font-size: 1.5rem; font-weight: 700; margin: 0.25rem 0 0.9rem; }
.dbase-coin-price small { color: var(--dbase-muted); font-size: 0.7rem; font-weight: 500; }

/* Candlestick mini chart */
.dbase-coin-chart {
    width: 100%;
    height: 150px;
    margin: 0 0 0.9rem;
    position: relative;
}
.dbase-coin-chart .dbase-chart-loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--dbase-muted);
    font-size: 0.75rem;
}

.dbase-metric-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.6rem;
    margin-bottom: 0.9rem;
}
.dbase-metric {
    background: var(--dbase-surface-2);
    border-radius: var(--dbase-radius-sm);
    padding: 0.5rem 0.65rem;
}
.dbase-metric-label { color: var(--dbase-muted); font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.05em; }
.dbase-metric-value { font-weight: 600; font-variant-numeric: tabular-nums; }

/* An indicator that is displayed but not voting. Kept legible — it is still
   useful context — while making clear it is not driving any decision. */
.dbase-metric-off { opacity: 0.45; }
.dbase-metric-off .dbase-metric-value { font-weight: 500; }
.dbase-off-tag {
    display: inline-block;
    margin-left: 0.3rem;
    padding: 0 0.25rem;
    border: 1px solid currentColor;
    border-radius: 3px;
    font-size: 0.6rem;
    letter-spacing: 0;
    vertical-align: middle;
}

.dbase-coin-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-top: 1px solid var(--dbase-border);
    padding-top: 0.75rem;
    margin-top: 0.25rem;
    font-size: 0.8rem;
    color: var(--dbase-muted);
}

/* ---------- Badges ------------------------------------------------------- */

.dbase-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.dbase-badge-buy { background: rgba(0, 200, 150, 0.15); color: var(--dbase-buy); }
.dbase-badge-sell { background: rgba(255, 77, 77, 0.15); color: var(--dbase-sell); }
.dbase-badge-hold { background: rgba(201, 162, 39, 0.15); color: var(--dbase-hold); }
.dbase-badge-pending { background: rgba(201, 162, 39, 0.15); color: var(--dbase-hold); }
.dbase-badge-success { background: rgba(0, 200, 150, 0.15); color: var(--dbase-buy); }
.dbase-badge-failed { background: rgba(255, 77, 77, 0.15); color: var(--dbase-sell); }
.dbase-badge-muted { background: var(--dbase-surface-2); color: var(--dbase-muted); }

/* Trade execution mode */
.dbase-badge-live { background: rgba(0, 200, 150, 0.18); color: var(--dbase-buy); border: 1px solid rgba(0, 200, 150, 0.55); }
.dbase-badge-paper { background: rgba(74, 158, 255, 0.16); color: #5aa9ff; border: 1px solid rgba(74, 158, 255, 0.45); }
.dbase-badge-dry { background: rgba(255, 255, 255, 0.05); color: var(--dbase-muted); border: 1px dashed #5a5a5a; }

/* ---------- Filter bars --------------------------------------------------- */

/* A row of filter links. Wraps rather than scrolls, so narrow screens stack the
   options instead of hiding them behind a swipe. */
.dbase-filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 1rem;
}

.dbase-filter-label {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--dbase-muted);
    margin-right: 0.15rem;
}

/* The active filter. Solid rather than outlined, so which view you are looking
   at is obvious without reading the label — the difference between "no failed
   trades" and "not currently filtering" matters.
 *
 * Qualified with .dbase-btn deliberately. Both are single-class selectors, so on
 * equal specificity the one defined later wins — and .dbase-btn sets its own
 * background 100 lines further down, silently overriding this. Raising the
 * specificity fixes it regardless of where either rule sits in the file. */
.dbase-btn.dbase-filter-on {
    background: var(--dbase-buy);
    border-color: var(--dbase-buy);
    color: #06231b;
    font-weight: 700;
}
.dbase-btn.dbase-filter-on:hover { background: #00e0a8; border-color: #00e0a8; }

/* Badges that act as filters. Anchors inherit link colour and underline by
   default, which would undo the badge look entirely — hence the explicit
   reset. The pointer and hover lift are the only affordance that these are
   clickable, since a badge otherwise reads as a static label. */
.dbase-badge-link {
    cursor: pointer;
    text-decoration: none;
    transition: background-color 0.15s ease, box-shadow 0.15s ease;
}
.dbase-badge-link:hover,
.dbase-badge-link:focus-visible {
    background: rgba(0, 200, 150, 0.3);
    text-decoration: none;
}
.dbase-badge-link:focus-visible {
    outline: 2px solid var(--dbase-buy);
    outline-offset: 2px;
}

/* The coin currently filtered on. Solid rather than translucent so the active
   filter is obvious at a glance among a grid of otherwise identical badges. */
.dbase-badge-active {
    background: var(--dbase-buy);
    color: #06231b;
}
.dbase-badge-active:hover,
.dbase-badge-active:focus-visible { background: #00e0a8; }

.dbase-text-buy { color: var(--dbase-buy); }
.dbase-text-sell { color: var(--dbase-sell); }

/* ---------- Tables ------------------------------------------------------- */

.dbase-table-wrap {
    background: var(--dbase-surface);
    border: 1px solid var(--dbase-border);
    border-radius: var(--dbase-radius);
    overflow-x: auto;
}
table.dbase-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}
.dbase-table th, .dbase-table td {
    padding: 0.7rem 0.85rem;
    text-align: left;
    white-space: nowrap;
}
.dbase-table thead th {
    color: var(--dbase-muted);
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--dbase-border);
}
.dbase-table tbody tr { border-bottom: 1px solid var(--dbase-border); }
.dbase-table tbody tr:last-child { border-bottom: 0; }
.dbase-table tbody tr:hover { background: var(--dbase-surface-2); }
.dbase-num { font-variant-numeric: tabular-nums; text-align: right; }

/* ---------- Forms -------------------------------------------------------- */

.dbase-form-group { margin-bottom: 0.9rem; }
.dbase-label {
    display: block;
    font-size: 0.78rem;
    color: #b5b5b5;
    margin-bottom: 0.35rem;
    font-weight: 500;
}
.dbase-input, .dbase-select, textarea.dbase-input {
    width: 100%;
    background: var(--dbase-input-bg);
    border: 1px solid var(--dbase-input-border);
    border-radius: var(--dbase-radius-sm);
    color: var(--dbase-text);
    padding: 0.6rem 0.7rem;
    font-size: 0.9rem;
    font-family: inherit;
    /* Subtle recess so fields look "fillable" on the dark theme */
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.35);
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.dbase-input:hover, .dbase-select:hover { border-color: var(--dbase-input-border-hover); }
.dbase-input:focus, .dbase-select:focus {
    outline: none;
    background: #2a2a2a;
    border-color: var(--dbase-accent);
    box-shadow: 0 0 0 3px rgba(0, 200, 150, 0.22);
}
.dbase-input::placeholder { color: #707070; }

/* Number-input spinners shouldn't wash out on dark */
.dbase-input[type="number"]::-webkit-inner-spin-button,
.dbase-input[type="number"]::-webkit-outer-spin-button { opacity: 0.6; }

.dbase-check {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.85rem;
    cursor: pointer;
}
.dbase-check input { width: 16px; height: 16px; accent-color: var(--dbase-accent); }

/* ---------- Buttons ------------------------------------------------------ */

.dbase-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.55rem 0.9rem;
    border-radius: var(--dbase-radius-sm);
    border: 1px solid var(--dbase-border);
    background: var(--dbase-surface-2);
    color: var(--dbase-text);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}
.dbase-btn:hover { border-color: var(--dbase-accent); text-decoration: none; }
.dbase-btn-primary { background: var(--dbase-accent); border-color: var(--dbase-accent); color: #04231b; }
.dbase-btn-primary:hover { filter: brightness(1.08); }
.dbase-btn-buy { background: var(--dbase-buy); border-color: var(--dbase-buy); color: #04231b; }
.dbase-btn-sell { background: var(--dbase-sell); border-color: var(--dbase-sell); color: #2a0606; }
.dbase-btn-danger { color: var(--dbase-sell); }
.dbase-btn-danger:hover { border-color: var(--dbase-sell); }
.dbase-btn-block { width: 100%; }
.dbase-btn-sm { padding: 0.35rem 0.6rem; font-size: 0.78rem; }

/* Loading state — turns the button amber with a spinning icon */
.dbase-btn-loading,
.dbase-btn-loading:hover {
    background: #f0b90b !important;
    border-color: #f0b90b !important;
    color: #2a2206 !important;
    cursor: progress;
}
@keyframes dbase-spin { to { transform: rotate(360deg); } }
.dbase-btn-loading svg { animation: dbase-spin 0.8s linear infinite; }

/* Indeterminate progress bar across the top of the viewport. Indeterminate
   rather than percentage-based because we genuinely don't know how far along a
   refresh is — a fake percentage would be worse than none. */
.dbase-progress {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    z-index: 100;
    overflow: hidden;
    background: rgba(0, 200, 150, 0.15);
}
.dbase-progress[hidden] { display: none; }
.dbase-progress span {
    display: block;
    height: 100%;
    width: 40%;
    background: var(--dbase-accent);
    box-shadow: 0 0 10px var(--dbase-accent);
    animation: dbase-progress-slide 1s ease-in-out infinite;
}
@keyframes dbase-progress-slide {
    from { transform: translateX(-100%); }
    to { transform: translateX(250%); }
}

/* Activity toast — pinned to the viewport so it stays visible while scrolled. */
.dbase-loading {
    position: fixed;
    right: 1.25rem;
    bottom: 1.25rem;
    z-index: 90;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 0.9rem;
    background: var(--dbase-surface-2);
    border: 1px solid #3a3a3a;
    border-radius: 999px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
    font-size: 0.82rem;
    color: var(--dbase-text);
    animation: dbase-fade-in 0.15s ease;
}
.dbase-loading[hidden] { display: none; }
.dbase-loading svg { animation: dbase-spin 0.8s linear infinite; color: var(--dbase-accent); }

@keyframes dbase-fade-in {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Respect a reduced-motion preference: keep the toast, drop the spin and slide. */
@media (prefers-reduced-motion: reduce) {
    .dbase-loading { animation: none; }
    .dbase-loading svg,
    .dbase-btn-loading svg { animation: none; }
}

/* ---------- Alerts ------------------------------------------------------- */

.dbase-alert {
    border-radius: var(--dbase-radius-sm);
    padding: 0.7rem 0.9rem;
    margin-bottom: 1rem;
    font-size: 0.85rem;
    border: 1px solid transparent;
}
.dbase-alert-success { background: rgba(0, 200, 150, 0.12); border-color: rgba(0, 200, 150, 0.4); color: var(--dbase-buy); }
.dbase-alert-error { background: rgba(255, 77, 77, 0.12); border-color: rgba(255, 77, 77, 0.4); color: var(--dbase-sell); }
.dbase-alert-warn { background: rgba(201, 162, 39, 0.12); border-color: rgba(201, 162, 39, 0.4); color: var(--dbase-hold); }
.dbase-alert ul { margin: 0; padding-left: 1.1rem; }

/* Icon + message alerts (engine health). Icon keeps its size while the text wraps. */
.dbase-alert svg { flex: 0 0 auto; margin-top: 0.1rem; }
.dbase-alert-warn[role="alert"] { display: flex; align-items: flex-start; gap: 0.6rem; }
.dbase-alert code {
    background: rgba(255, 255, 255, 0.07);
    border-radius: 3px;
    padding: 0.05rem 0.3rem;
    font-size: 0.78rem;
}
.dbase-alert .dbase-muted { display: block; margin-top: 0.3rem; }

/* Coins nearing the entry threshold. Each coin stays on one line with its RSI and
   remaining gap aligned in columns, so the list can be scanned down rather than
   read across. Columns collapse to a single flowing row on narrow screens. */
/* The bracketed note explains the heading, so it belongs with it — tight
   underneath, with the breathing room falling after the pair rather than
   between them. Left floating equidistant it read as a separate statement. */
.dbase-approaching-note {
    display: block;
    margin-top: 0.1rem;
    color: var(--dbase-muted);
    font-size: 0.8rem;
}

/* Scoped to .dbase-alert deliberately: the generic `.dbase-alert ul { margin: 0 }`
   above is specificity 0,1,1 and silently beat a bare `.dbase-approaching` (0,1,0),
   so the spacing below never applied no matter what value it was given. */
.dbase-alert .dbase-approaching {
    list-style: none;
    /* Gap sits here — after the heading + note pair, before the list. Enough to
       separate "what this is" from "which coins", without a hole in the panel. */
    margin: 0.8rem 0 0.15rem;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}
.dbase-approaching li {
    position: relative;
    display: flex;
    align-items: baseline;
    column-gap: 0.75rem;
    /* Wrapped lines sit tight under their first line; the list's own gap keeps
       separate rows apart, so a two-line row still reads as one item. */
    row-gap: 0;
    flex-wrap: wrap;
    /* Room for the bullet, which is out of the flow so that a wrapped second
       line starts under the coin name rather than under the bullet. Without
       this, an open position's "to target / at target" pair wrapped to the
       panel's left edge and read as a separate row. */
    padding-left: 0.9rem;
    font-size: 0.85rem;
    /* Explicit, so rows stay evenly spaced regardless of which spans a row
       happens to contain — a TRIGGERED badge is taller than plain text. */
    line-height: 1.6;
}
.dbase-approaching li::before {
    content: "•";
    position: absolute;
    left: 0;
    opacity: 0.6;
}
.dbase-approaching-coin { font-weight: 600; min-width: 6.5rem; }
.dbase-approaching-rsi { font-variant-numeric: tabular-nums; min-width: 5rem; }
/* Full strength: the distance to the trigger is the actionable number in the
   row, not a footnote. It was previously dimmed, which inverted the hierarchy. */
.dbase-approaching-gap { font-variant-numeric: tabular-nums; }
/* Rand result if sold now. Fixed width so the "to target" column after it still
   lines up across rows. */
.dbase-approaching-net { font-variant-numeric: tabular-nums; min-width: 9.5rem; font-weight: 600; }
/* Estimated rand result if the take-profit fires. Follows "to target", which
   gets a fixed width here so this column lines up across rows too. */
.dbase-approaching-gap { min-width: 7.5rem; }
.dbase-approaching-target { font-variant-numeric: tabular-nums; font-weight: 600; }

/* Equity curve. Stretched to the container with preserveAspectRatio="none", so
   the stroke uses non-scaling-stroke to avoid being distorted with it. */
.dbase-equity-chart {
    width: 100%;
    height: 120px;
    display: block;
    overflow: visible;
}
.dbase-equity-axis {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    margin-top: 0.4rem;
    font-size: 0.72rem;
    color: var(--dbase-muted);
    font-variant-numeric: tabular-nums;
}

/* Top row: signal panels beside the recent-trade log. Stacked by default;
   side-by-side once there is width for it, since the signal panels are short
   and otherwise leave a wide empty gutter. */
.dbase-top-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--dbase-gap);
    margin-bottom: 1.25rem;
}
.dbase-top-signals > *:last-child { margin-bottom: 0 !important; }

.dbase-recent-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}
.dbase-recent-trades { align-self: start; }

/* Denser than the full Trade Log — this is a glance, not the record. */
.dbase-table-compact { font-size: 0.8rem; }
.dbase-table-compact th,
.dbase-table-compact td { padding: 0.4rem 0.5rem; }

@media (min-width: 1100px) {
    .dbase-top-grid { grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr); }
}

/* RSI direction of travel. Green when falling — this strategy buys weakness, so
   a falling RSI is a coin closing in on an entry. Rising is muted rather than
   red: it isn't bad news, just an opportunity receding. */
.dbase-rsi-trend {
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
    margin-left: 0.25rem;
}
.dbase-rsi-trend.is-falling { color: var(--dbase-buy); }
.dbase-rsi-trend.is-rising { color: var(--dbase-muted); opacity: 0.8; }

@media (max-width: 480px) {
    .dbase-approaching-coin,
    .dbase-approaching-rsi { min-width: 0; }
}

/* ---------- Misc --------------------------------------------------------- */

.dbase-empty {
    text-align: center;
    padding: 2.5rem 1rem;
    color: var(--dbase-muted);
}
.dbase-muted { color: var(--dbase-muted); }
.dbase-mono { font-variant-numeric: tabular-nums; font-feature-settings: 'tnum'; }
.dbase-section-gap { margin-top: 2rem; }
.dbase-inline-form { display: inline; }
.dbase-flex { display: flex; align-items: center; gap: 0.5rem; }
.dbase-flex-wrap { flex-wrap: wrap; }

/* status pill for live trading */
.dbase-status-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.75rem;
    padding: 0.25rem 0.6rem;
    border-radius: 999px;
    border: 1px solid var(--dbase-border);
    background: var(--dbase-surface-2);
}
.dbase-dot { width: 8px; height: 8px; border-radius: 50%; }
.dbase-dot-on { background: var(--dbase-buy); }
.dbase-dot-off { background: var(--dbase-sell); }

/* ---------- Desktop (> 768px) ------------------------------------------- */

@media (min-width: 769px) {
    /* Sidebar stays fixed; the content's left margin reserves its width so the
       topbar (and hamburger) never render underneath it. */
    .dbase-content {
        margin-left: var(--dbase-sidebar-w);
        transition: margin-left 0.22s ease;
    }
    body.dbase-sidebar-collapsed .dbase-sidebar {
        transform: translateX(-100%);
    }
    body.dbase-sidebar-collapsed .dbase-content {
        margin-left: 0;
    }
    .dbase-backdrop { display: none !important; }

    .dbase-card-grid {
        grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    }
    .dbase-main { padding: 1.75rem 2rem; }
}

@media (min-width: 1200px) {
    .dbase-card-grid {
        grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    }
}

/* Coin removal on Settings: separated from Save so the two can't be confused. */
.dbase-coin-remove {
    margin-top: 0.9rem;
    padding-top: 0.75rem;
    border-top: 1px dashed var(--dbase-border);
}

/* ---------- News ---------------------------------------------------------- */

.dbase-news-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--dbase-gap);
}
.dbase-news-card {
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
}
/* Fixed height keeps the grid even when feeds return wildly different images. */
.dbase-news-img {
    width: 100%;
    height: 150px;
    object-fit: cover;
    display: block;
    background: var(--dbase-surface);
}
.dbase-news-body { padding: 0.9rem 1rem 1rem; }
.dbase-news-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-bottom: 0.5rem;
}
.dbase-news-date { color: var(--dbase-muted); font-size: 0.72rem; margin-left: auto; }
.dbase-news-title { font-size: 0.95rem; line-height: 1.4; margin: 0 0 0.4rem; }
.dbase-news-title a { color: var(--dbase-text); }
.dbase-news-title a:hover { color: var(--dbase-accent); }
.dbase-news-blurb {
    color: var(--dbase-muted);
    font-size: 0.82rem;
    line-height: 1.5;
    margin: 0;
}

@media (min-width: 700px) {
    .dbase-news-grid { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
}

/* Single-line headline on the dashboard. Quiet by design — a trading screen
   should not be led by news the engine ignores. Truncates rather than wraps so
   it can never push the signal panels down the page. */
.dbase-news-ticker {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.8rem;
    margin-bottom: 1rem;
    background: var(--dbase-surface);
    border: 1px solid var(--dbase-border);
    border-radius: var(--dbase-radius-sm);
    color: var(--dbase-muted);
    font-size: 0.82rem;
    overflow: hidden;
}
.dbase-news-ticker:hover {
    text-decoration: none;
    border-color: #4d4d4d;
    color: var(--dbase-text);
}
.dbase-news-ticker-label {
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-size: 0.66rem;
    color: var(--dbase-muted);
    flex-shrink: 0;
}
.dbase-news-ticker-title {
    color: var(--dbase-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}
.dbase-news-ticker-meta { margin-left: auto; flex-shrink: 0; white-space: nowrap; }

@media (max-width: 700px) {
    .dbase-news-ticker-meta { display: none; }
}

/* Three stacked headlines read as one block; collapsing the gaps and rounding
   only the outer corners keeps it a single element rather than three boxes
   competing with the signal panels below. */
.dbase-news-ticker-group { margin-bottom: 1rem; }
.dbase-news-ticker-group .dbase-news-ticker {
    margin-bottom: 0;
    border-radius: 0;
    border-bottom: none;
    /* Tighter than a standalone row: three stacked lines should read as a
       compact block, not three separate bars. */
    padding-top: 0.3rem;
    padding-bottom: 0.3rem;
}
.dbase-news-ticker-group .dbase-news-ticker:first-child {
    border-radius: var(--dbase-radius-sm) var(--dbase-radius-sm) 0 0;
}
.dbase-news-ticker-group .dbase-news-ticker:last-of-type { border-bottom: 1px solid var(--dbase-border); }

/* The label column stays reserved on rows 2 and 3 so titles align vertically. */
.dbase-news-ticker-label { min-width: 3.1rem; }

.dbase-news-ticker-more {
    display: block;
    padding: 0.35rem 0.8rem;
    background: var(--dbase-surface);
    border: 1px solid var(--dbase-border);
    border-top: none;
    border-radius: 0 0 var(--dbase-radius-sm) var(--dbase-radius-sm);
    font-size: 0.75rem;
    color: var(--dbase-muted);
    text-align: right;
}
.dbase-news-ticker-more:hover { color: var(--dbase-accent); text-decoration: none; }

/* Weekly brief by Claude, under Recent trades in the right column, which spaces
   its panels with its own gap. */
.dbase-brief-meta { font-size: 0.78rem; }
.dbase-brief-headline {
    margin: 0.6rem 0 0.35rem;
    font-weight: 600;
    line-height: 1.4;
}
.dbase-brief-summary { margin: 0 0 0.5rem; font-size: 0.88rem; line-height: 1.5; }
.dbase-brief-subhead {
    margin: 0.6rem 0 0.2rem;
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--dbase-muted);
}
.dbase-brief-list {
    margin: 0;
    padding-left: 1.1rem;
    font-size: 0.85rem;
    line-height: 1.5;
}
.dbase-brief-list li + li { margin-top: 0.2rem; }
.dbase-brief-foot { margin: 0.7rem 0 0; font-size: 0.75rem; }
.dbase-brief-error { margin: 0.7rem 0 0; font-size: 0.8rem; }

/* Right column of the top grid: informational panels stacked. */
.dbase-top-side {
    display: flex;
    flex-direction: column;
    gap: var(--dbase-gap);
    align-self: start;
}
.dbase-side-panel { align-self: stretch; }

/* Latest headlines, matching the compact table pattern beside it rather than
   inventing a second visual language for the same job. */
.dbase-news-list {
    list-style: none;
    margin: 0.5rem 0 0;
    padding: 0;
}
.dbase-news-list li + li {
    /* 0.25 each side of the divider — the row itself is line-height 1rem, so
       the gap was doing more work than the content. */
    margin-top: 0.25rem;
    padding-top: 0.25rem;
    border-top: 1px solid var(--dbase-border);
}
.dbase-news-list a {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    min-width: 0;
    color: var(--dbase-text);
    /* Tight: three headlines should occupy three lines, not six. */
    line-height: 1rem;
}
.dbase-news-list a:hover { text-decoration: none; }
.dbase-news-list a:hover .dbase-news-list-title { color: var(--dbase-accent); }


.dbase-news-list-meta {
    margin-left: auto;
    color: var(--dbase-muted);
    font-size: 0.7rem;
    white-space: nowrap;
}
.dbase-news-list-title {
    flex: 1;
    min-width: 0;
    font-size: 0.8rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Source label drops out when the right column gets tight, so the headline keeps
   its width. The age stays — that is what gets scanned. Full source is always in
   the link's title attribute and on the News page. */
@media (max-width: 1250px) {
    .dbase-news-source { display: none; }
}

/* Compact badge inside the news list. The standard badge is ~1.4rem tall against
   a 1rem line-height, so it — not the text — was setting the row height and
   holding the rows apart. Scoped, so badges elsewhere keep their normal size. */
.dbase-news-list .dbase-badge {
    padding: 0.05rem 0.4rem;
    font-size: 0.62rem;
    line-height: 1.1;
    letter-spacing: 0.03em;
}

/* ---------- Mobile safety ------------------------------------------------ */

/* Nothing should be able to scroll the page sideways. Overflow belongs to the
   element that needs it (tables, charts), never to the document. */
html, body { max-width: 100%; overflow-x: hidden; }

/* Long unbroken strings — a URL in a blurb, a symbol — must wrap rather than
   widen their container. */
.dbase-news-blurb,
.dbase-news-title { overflow-wrap: anywhere; }

@media (max-width: 700px) {
    /* Release the aligned columns: on a narrow screen an even grid matters less
       than fitting, and these min-widths sum past a phone's width. */
    .dbase-approaching-coin,
    .dbase-approaching-rsi { min-width: 0; }

    /* Reclaim horizontal padding for content. */
    .dbase-main { padding: 1rem 0.75rem; }
    .dbase-card { padding: 0.9rem; }
}

/* News rows go two-line on narrow screens.
   Inline works where there is width for it; on a phone the headline would be
   truncated to a few words, which is worse than a second line. Badge and meta
   share the first row, the headline gets the full width below and is allowed to
   wrap — so nothing is hidden and nothing overflows. */
@media (max-width: 700px) {
    .dbase-news-list a { flex-wrap: wrap; }

    .dbase-news-list-title {
        order: 3;
        flex: 0 0 100%;
        white-space: normal;
        overflow: visible;
        text-overflow: clip;
        line-height: 1.35;
        margin-top: 0.15rem;
    }

    /* The first row now has room to spare, so the source comes back — it was
       only hidden because it competed with the headline on one line. */
    .dbase-news-source { display: inline; }
}

/* A recently published headline.
   Static rather than animated on purpose: the dashboard reloads every 60s, so a
   flash would re-fire on every refresh for the whole hour — a cue that nags
   instead of informs. Weight, colour and an accent edge carry it without motion. */
/* A recently published row. The badge does the signalling; the title just
   carries a little more weight. No tint or edge — layering amber on amber made
   the badge look like it had a halo. */
.dbase-news-new .dbase-news-list-title { font-weight: 600; }

/* "New" badge attention pulse.
   A soft fade in and out rather than a blink — enough to catch peripheral vision
   without behaving like an alert. Runs for two minutes from first sight (handled
   in JS), then the class is removed and the badge settles to its normal state. */
@keyframes dbase-badge-pulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(201, 162, 39, 0); }
    50% { opacity: 0.55; box-shadow: 0 0 0 3px rgba(201, 162, 39, 0.18); }
}
.dbase-news-flash.is-flashing {
    animation: dbase-badge-pulse 1.6s ease-in-out infinite;
    /* Brighter only while pulsing. The badge drops back to the standard muted
       --dbase-hold the moment the class is removed, so the emphasis is tied to
       the flash rather than becoming a second permanent badge style. */
    color: #ffdf6b;
    background: rgba(201, 162, 39, 0.28);
}

/* Motion-sensitive users get the badge without the movement. */
@media (prefers-reduced-motion: reduce) {
    .dbase-news-flash.is-flashing { animation: none; }
}

/* Portfolio tabs: Live / Paper, drawn as classic folder tabs. Inactive tabs
   sit raised on the surface colour; the selected tab takes the page colour and
   covers the baseline beneath it, so it reads as joined to the content below,
   with an accent strip along its top. Mobile-first: two short labels fit any
   screen, so the bar never needs to scroll (overflow would clip the 1px overlap
   that makes the join). */
.dbase-tabs {
    display: flex;
    align-items: flex-end;
    gap: 0.35rem;
    padding: 0 0.25rem;
    border-bottom: 1px solid var(--dbase-border);
    margin-bottom: 1.5rem;
}
/* display:flex above would otherwise override the hidden attribute, which keeps
   the bar out of sight until the script has chosen a tab. */
.dbase-tabs[hidden] { display: none; }
.dbase-tab {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: -1px;
    padding: 0.6rem 0.95rem;
    background: var(--dbase-surface);
    border: 1px solid var(--dbase-border);
    border-radius: 8px 8px 0 0;
    color: var(--dbase-muted);
    font: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}
.dbase-tab:hover {
    background: var(--dbase-surface-2);
    color: var(--dbase-text);
}
.dbase-tab[aria-selected="true"] {
    z-index: 1;
    background: var(--dbase-bg);
    border-bottom-color: var(--dbase-bg);
    color: var(--dbase-text);
    box-shadow: inset 0 2px 0 var(--dbase-accent);
    cursor: default;
}
.dbase-tab:focus-visible {
    outline: 2px solid var(--dbase-accent);
    outline-offset: 2px;
}
.dbase-tab .dbase-badge { font-size: 0.65rem; padding: 0.1rem 0.45rem; }
.dbase-tab-panel[hidden] { display: none; }
@media (min-width: 769px) {
    .dbase-tab { padding: 0.7rem 1.3rem; font-size: 0.95rem; }
}
@media (prefers-reduced-motion: reduce) {
    .dbase-tab { transition: none; }
}

/* Dashboard coin tabs reuse .dbase-tabs / .dbase-tab above. "Open positions"
   is a filter over the one card grid, so cards are hidden, not re-rendered. */
.dbase-card-grid.dbase-show-held-only > .dbase-coin-card:not(.dbase-coin-card-held) { display: none; }
.dbase-tab-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.4rem;
    padding: 0.05rem 0.4rem;
    border-radius: 999px;
    background: var(--dbase-surface-2);
    color: var(--dbase-muted);
    font-size: 0.72rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}
.dbase-tab[aria-selected="true"] .dbase-tab-count {
    background: rgba(0, 200, 150, 0.15);
    color: var(--dbase-accent);
}

/* ---------- Sign-in (password + authenticator code) ---------------------- */

.dbase-auth {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem 1rem;
}
.dbase-auth-card {
    width: 100%;
    max-width: 380px;
    background: var(--dbase-surface);
    border: 1px solid var(--dbase-border);
    border-radius: var(--dbase-radius);
    padding: 1.5rem;
}
.dbase-auth-brand { margin-bottom: 1.25rem; }
.dbase-auth-title { font-size: 1.15rem; font-weight: 600; margin: 0 0 1rem; }
.dbase-auth-form { margin-top: 0.5rem; }
.dbase-auth-note { color: var(--dbase-muted); font-size: 0.8rem; margin: 1rem 0 0; }
.dbase-auth-lead { margin: 0 0 1rem; }
.dbase-auth-code {
    font-size: 1.3rem;
    letter-spacing: 0.3em;
    text-align: center;
    font-variant-numeric: tabular-nums;
}
.dbase-auth-steps { padding-left: 1.2rem; margin: 0 0 1rem; font-size: 0.85rem; }
.dbase-auth-steps li { margin-bottom: 0.3rem; }
/* White quiet zone around the code: scanners struggle with a QR on dark. */
.dbase-auth-qr {
    background: #fff;
    border-radius: var(--dbase-radius-sm);
    padding: 0.75rem;
    width: fit-content;
    margin: 0 auto 1rem;
    line-height: 0;
}
.dbase-auth-qr svg { width: 200px; height: 200px; }
.dbase-auth-manual { font-size: 0.82rem; margin-bottom: 1rem; }
.dbase-auth-manual summary { cursor: pointer; color: var(--dbase-accent); }
.dbase-auth-secret {
    display: block;
    margin-top: 0.5rem;
    padding: 0.5rem 0.6rem;
    background: var(--dbase-input-bg);
    border: 1px solid var(--dbase-input-border);
    border-radius: var(--dbase-radius-sm);
    color: var(--dbase-text);
    font-size: 0.85rem;
    word-break: break-all;
    user-select: all;
}

.dbase-signout {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    border-top: 1px solid var(--dbase-border);
    padding-top: 1rem;
    margin-top: 1rem;
}
.dbase-signout-who { font-size: 0.8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
