/* ═══════════════════════════════════════════════════════════════
   mobile.css — Dedicated mobile experience for all pages
   Industry-standard patterns: bottom sheets, collapsible panels,
   touch-friendly targets, native scrolling, proper stacking.
   ═══════════════════════════════════════════════════════════════ */

/* ── Touch-friendly: minimum 44px tap targets on mobile ── */
@media (max-width: 768px) {
    /* Allow native scrolling on mobile instead of fighting the browser */
    html, body {
        overflow: auto;
        -webkit-overflow-scrolling: touch;
        -webkit-text-size-adjust: 100%;
        text-size-adjust: 100%;
    }

    /* Global mobile polish — industry-standard touch optimizations */
    *, *::before, *::after {
        -webkit-tap-highlight-color: transparent;
    }
    body {
        touch-action: manipulation;
    }

    /* iOS: prevent zoom on input focus (requires font-size >= 16px) */
    input:not([type="checkbox"]):not([type="radio"]),
    select,
    textarea {
        font-size: 16px;
    }

    /* ═══════════════════════════════════════════════════════
       DASHBOARD — Bottom Sheet Detail Panel
       ═══════════════════════════════════════════════════════ */

    /* Detail panel becomes a collapsible bottom sheet */
    #detail-panel {
        position: fixed;
        bottom: 26px; /* above status bar */
        left: 0;
        right: 0;
        z-index: 100;
        max-height: 55vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        background: var(--panel);
        border-top: 2px solid var(--teal);
        border-radius: 12px 12px 0 0;
        box-shadow: 0 -8px 32px rgba(0,0,0,0.5);
        transform: translateY(100%);
        transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
        padding: 0 12px calc(8px + env(safe-area-inset-bottom, 0px));
    }
    #detail-panel.mobile-open {
        transform: translateY(0);
    }

    /* Drag handle + close button area */
    .detail-panel-handle {
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 8px 0 4px;
        position: sticky;
        top: 0;
        background: var(--panel);
        z-index: 1;
    }
    .detail-panel-handle::before {
        content: '';
        display: block;
        width: 40px;
        height: 4px;
        background: var(--border);
        border-radius: 2px;
        opacity: 0.7;
        transition: opacity 0.2s, width 0.2s;
    }
    .detail-panel-handle:active::before {
        width: 48px;
        opacity: 1;
    }
    .detail-panel-close {
        position: absolute;
        right: 4px;
        top: 6px;
        width: 32px;
        height: 32px;
        display: flex;
        align-items: center;
        justify-content: center;
        border: none;
        background: rgba(255,255,255,0.06);
        color: var(--fg2);
        font-size: 18px;
        cursor: pointer;
        border-radius: 50%;
        transition: background 0.15s;
        -webkit-tap-highlight-color: transparent;
    }
    .detail-panel-close:hover,
    .detail-panel-close:active {
        background: rgba(255,255,255,0.12);
        color: var(--fg);
    }

    /* Grid container needs to reclaim full height when panel hidden */
    #grid-container {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        min-height: 0;
    }

    /* Confirmation bar → top banner on mobile (avoids overlapping bottom sheet) */
    #confirmation-bar {
        position: fixed;
        top: 0;
        bottom: auto;
        left: 0;
        right: 0;
        z-index: 200;
        padding: 14px 16px;
        padding-top: calc(14px + env(safe-area-inset-top, 0px));
        gap: 12px;
        border-top: none;
        border-bottom: 2px solid var(--yellow);
        border-radius: 0 0 10px 10px;
        box-shadow: 0 4px 24px rgba(0,0,0,0.5);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        background: rgba(40, 44, 52, 0.95);
        animation: confirmSlideDown 0.25s ease-out;
    }
    #confirmation-bar .confirm-yes,
    #confirmation-bar .confirm-no {
        min-height: 44px;
        min-width: 72px;
        padding: 10px 20px;
        font-size: 15px;
        border-radius: 8px;
    }
    #confirmMessage {
        font-size: 14px;
        line-height: 1.4;
    }

    /* ═══════════════════════════════════════════════════════
       DASHBOARD HEADER — Compact mobile layout
       ═══════════════════════════════════════════════════════ */

    #header {
        padding: 8px 12px;
        gap: 6px;
    }
    .header-left h1 { font-size: 14px; }
    .header-left .subtitle { font-size: 10px; }
    .header-right {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap;
        scrollbar-width: none;
    }
    .header-right::-webkit-scrollbar { display: none; }
    .header-right .hdr-btn {
        min-height: 36px;
        flex-shrink: 0;
    }
    .header-right .clock { display: none; }

    /* ═══════════════════════════════════════════════════════
       KPI BAR — Horizontal scroll strip
       ═══════════════════════════════════════════════════════ */

    #kpi-bar {
        padding: 6px 10px;
        gap: 6px;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    #kpi-bar::-webkit-scrollbar { display: none; }
    .kpi-card {
        min-width: 72px;
        flex: 0 0 auto;
        padding: 6px 8px;
    }
    .kpi-value { font-size: 14px; }
    .kpi-label { font-size: 9px; }
    .kpi-sub { font-size: 9px; }

    /* ═══════════════════════════════════════════════════════
       FILTER BAR — Compact
       ═══════════════════════════════════════════════════════ */

    #filter-bar { padding: 4px 10px; gap: 6px; }
    .filter-btn { min-height: 36px; }
    .search-input { min-width: 120px; min-height: 36px; }

    /* ═══════════════════════════════════════════════════════
       TRADE GRID — Fit phone width, hide excess columns
       ═══════════════════════════════════════════════════════ */

    #tradeGrid { min-width: 0; table-layout: auto; }
    #tradeGrid th, #tradeGrid td { padding: 8px 6px; }
    #tradeGrid tbody tr { min-height: 44px; }
    .hide-mobile { display: none; }

    /* Hide: TF, DIR, SIZE, POSITION, ENTRY, CURRENT, REALIZED, UPDATED, RISK */
    #tradeGrid th:nth-child(3), #tradeGrid td:nth-child(3),
    #tradeGrid th:nth-child(5), #tradeGrid td:nth-child(5),
    #tradeGrid th:nth-child(6), #tradeGrid td:nth-child(6),
    #tradeGrid th:nth-child(7), #tradeGrid td:nth-child(7),
    #tradeGrid th:nth-child(8), #tradeGrid td:nth-child(8),
    #tradeGrid th:nth-child(9), #tradeGrid td:nth-child(9),
    #tradeGrid th:nth-child(12), #tradeGrid td:nth-child(12),
    #tradeGrid th:nth-child(13), #tradeGrid td:nth-child(13),
    #tradeGrid th:nth-child(14), #tradeGrid td:nth-child(14),
    #tradeGrid th:nth-child(15), #tradeGrid td:nth-child(15) { display: none; }

    /* Keep: TICKER, TYPE, STATE, P/L %, UNRLZD */
    #tradeGrid th:nth-child(1), #tradeGrid td:nth-child(1) { width: auto; }
    #tradeGrid th:nth-child(2), #tradeGrid td:nth-child(2) { width: auto; }
    #tradeGrid th:nth-child(4), #tradeGrid td:nth-child(4) { width: auto; }
    #tradeGrid th:nth-child(10), #tradeGrid td:nth-child(10) { width: auto; }
    #tradeGrid th:nth-child(11), #tradeGrid td:nth-child(11) { width: auto; }

    /* Detail panel internals — vertical stack */
    .detail-info { flex-direction: column; gap: 4px; }
    .detail-col { min-width: 0; }
    .detail-col-spark { display: none !important; }
    .detail-col-targets { flex: none; min-width: unset; }
    .detail-ticker { font-size: 15px; }
    .detail-pnl { font-size: 13px; }
    .detail-signal { max-width: 100%; }

    .detail-actions {
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
        gap: 6px;
        padding: 8px 0 4px;
        margin-top: 8px;
        scrollbar-width: none;
    }
    .detail-actions::-webkit-scrollbar { display: none; }
    .action-btn {
        flex-shrink: 0;
        min-height: 44px;
        padding: 10px 16px;
        font-size: 13px;
        border-radius: 6px;
    }
    .action-btn:active:not(:disabled) {
        transform: scale(0.96);
        transition: transform 0.1s;
    }

    /* ═══════════════════════════════════════════════════════
       FOOTER — Compact
       ═══════════════════════════════════════════════════════ */

    #footer {
        font-size: 11px;
        padding: 4px 10px;
        padding-bottom: calc(4px + env(safe-area-inset-bottom, 0px));
    }

    /* ═══════════════════════════════════════════════════════
       TOASTS — Full width on mobile
       ═══════════════════════════════════════════════════════ */

    #toast-container { max-width: 92vw; right: 4%; top: 60px; left: 4%; }
    .toast { min-width: auto; }

    /* ═══════════════════════════════════════════════════════
       MODALS — Full-width bottom sheets on mobile
       ═══════════════════════════════════════════════════════ */

    .modal { align-items: flex-end; }
    .modal-content {
        min-width: auto;
        width: 100%;
        max-width: 100%;
        margin: 0;
        border-radius: 14px 14px 0 0;
        max-height: 85vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    }
    .modal-close-btn {
        min-width: 36px;
        min-height: 36px;
        font-size: 22px;
    }
    .modal-actions {
        gap: 8px;
        padding: 12px 0;
    }
    .modal-actions .action-btn {
        min-height: 44px;
        flex: 1;
    }
    .tradecard-content {
        min-width: auto;
        max-width: 100%;
    }
    .params-content {
        min-width: auto;
        width: 100%;
    }
    .params-field { flex-direction: column; align-items: flex-start; gap: 4px; }
    .params-field label { min-width: auto; font-size: 13px; }
    .params-field input, .params-field select {
        width: 100%;
        min-height: 44px;
        border-radius: 8px;
    }

    /* ═══════════════════════════════════════════════════════
       TRADE FOCUS PAGE (trade.html)
       ═══════════════════════════════════════════════════════ */

    .trade-page-body { padding: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }

    .trade-header {
        flex-direction: column;
        align-items: stretch;
        gap: 6px;
        padding: 8px 12px;
    }
    /* Price + P/L first (most important info) */
    .trade-header-center {
        order: -1;
        display: flex;
        align-items: baseline;
        gap: 8px;
        flex-wrap: wrap;
    }
    .trade-live-price { font-size: 20px; }
    .trade-pnl { font-size: 13px; }
    .hdr-sparkline { display: none; }

    /* Ticker + state row */
    .trade-header-left {
        display: flex;
        align-items: center;
        gap: 6px;
        flex-wrap: wrap;
    }
    .trade-ticker { font-size: 15px; }

    /* Action buttons — horizontal scroll */
    .trade-header-right {
        display: flex;
        gap: 6px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap;
        padding-bottom: 2px;
    }
    .trade-header-right .btn {
        flex-shrink: 0;
        min-height: 44px;
        padding: 10px 16px;
        border-radius: 6px;
    }

    /* Main layout → single column */
    .trade-layout {
        flex-direction: column;
        padding: 8px;
        height: auto;
        gap: 8px;
    }
    .trade-main {
        flex: none;
        overflow-y: visible;
    }
    .trade-sidebar {
        width: auto;
        min-width: unset;
        max-width: unset;
        flex: none;
        overflow-y: visible;
    }

    /* Chart card — reasonable mobile height */
    .trade-chart-container { height: 260px; }
    .trade-chart-toolbar { flex-wrap: wrap; gap: 6px; }

    /* Section cards — tighter padding */
    .trade-sidebar .section-card,
    .trade-main .section-card {
        padding: 10px 12px;
        margin-bottom: 8px;
    }

    /* ═══════════════════════════════════════════════════════
       SPLIT LAYOUT PAGES (Registry, Capital, Import)
       ═══════════════════════════════════════════════════════ */

    .split-layout {
        flex-direction: column;
        height: auto;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }
    .split-layout .split-left {
        flex: none;
        min-width: unset;
        max-width: unset;
        width: auto;
        overflow-y: visible;
        min-height: 30vh;
    }
    .split-layout .split-right {
        flex: none;
        min-width: unset;
        max-width: unset;
        width: auto;
        overflow-y: visible;
    }

    /* ═══════════════════════════════════════════════════════
       DETAIL DRAWER — Full-width on mobile
       ═══════════════════════════════════════════════════════ */

    .detail-drawer {
        width: 100%;
        max-width: 100vw;
        border-left: none;
        border-radius: 0;
    }
    .drawer-header {
        padding: 12px 16px 8px;
    }
    .drawer-body {
        padding: 10px 14px 20px;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }
    .drawer-body .drawer-form-grid {
        grid-template-columns: 1fr;
    }
    .drawer-body .form-row label {
        min-width: unset;
        width: auto;
    }
    .drawer-footer {
        position: relative;
        z-index: 1;
        padding: 10px 16px;
        padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
        touch-action: manipulation;
    }
    .drawer-footer .btn {
        min-height: 44px;
    }

    /* Data grids — auto layout, horizontal scroll when needed */
    .data-grid {
        min-width: 0;
        table-layout: auto;
    }
    .data-grid thead th,
    .data-grid tbody td {
        padding: 8px 6px;
    }
    .data-grid tbody tr { min-height: 44px; }

    /* ═══════════════════════════════════════════════════════
       SIDEBAR LAYOUT (Settings)
       ═══════════════════════════════════════════════════════ */

    .sidebar-layout { flex-direction: column; }
    .sidebar-nav {
        width: 100%;
        min-width: unset;
        display: flex;
        flex-direction: row;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-right: none;
        border-bottom: 1px solid var(--border);
        padding: 0;
        scrollbar-width: none;
    }
    .sidebar-nav::-webkit-scrollbar { display: none; }
    .sidebar-nav .nav-item {
        white-space: nowrap;
        border-left: none;
        border-bottom: 3px solid transparent;
        padding: 10px 14px;
        min-height: 44px;
    }
    .sidebar-nav .nav-item.active {
        border-bottom-color: var(--teal);
        border-left-color: transparent;
    }

    /* ═══════════════════════════════════════════════════════
       FORMS — Stack labels above inputs
       ═══════════════════════════════════════════════════════ */

    .form-row {
        flex-direction: column;
        align-items: stretch;
        gap: 4px;
        padding: 6px;
    }
    .form-row label { width: auto; font-size: 13px; }
    .form-row input, .form-row select {
        max-width: 100%;
        width: 100%;
        min-height: 44px;
        padding: 10px 12px;
        border-radius: 8px;
    }
    .form-row input[type="number"] { max-width: 100%; }
    .form-row input[type="checkbox"] {
        width: 22px;
        height: 22px;
        min-height: auto;
        flex: none;
    }
    .form-2col { grid-template-columns: 1fr; }

    /* ═══════════════════════════════════════════════════════
       PAGE SHELL — Compact
       ═══════════════════════════════════════════════════════ */

    .page-header {
        padding: 8px 12px;
        gap: 8px;
    }
    .page-header .header-left {
        min-width: 0;
    }
    .page-header h1 {
        font-size: 14px;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .page-header .subtitle { display: none; }
    .page-header .btn-group {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap;
        scrollbar-width: none;
    }
    .page-header .btn-group::-webkit-scrollbar { display: none; }
    .page-header .btn-group .btn {
        flex: 0 0 auto;
        min-height: 40px;
        text-align: center;
        white-space: nowrap;
    }

    .page-body { padding: 8px 10px; }
    .page-footer {
        padding: 4px 10px;
        padding-bottom: calc(4px + env(safe-area-inset-bottom, 0px));
        font-size: 11px;
        flex-wrap: wrap;
        gap: 4px;
    }

    .page-nav {
        padding: 4px 8px;
        gap: 2px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap;
        scrollbar-width: none;
        position: sticky;
        top: 0;
        z-index: 100;
        background: var(--panel);
    }
    .page-nav::-webkit-scrollbar { display: none; }
    .page-nav .nav-link {
        padding: 6px 10px;
        font-size: 11px;
        min-height: 36px;
        display: flex;
        align-items: center;
        flex-shrink: 0;
    }
    .page-nav .nav-spacer { flex: 0 0 auto; min-width: 6px; }
    .page-nav .nav-dropdown { flex-shrink: 0; }
    .nav-dropdown-trigger { min-height: 36px; font-size: 11px !important; padding: 6px 10px !important; }
    .nav-dropdown-menu { min-width: 240px; }
    .page-nav:has(.nav-dropdown.open),
    .page-nav:has(.nav-user-menu.open) { overflow-x: visible; }
    .nav-dropdown.open .nav-dropdown-menu,
    .nav-user-menu.open .nav-user-dropdown { max-height: 70vh; overflow-y: auto; -webkit-overflow-scrolling: touch; }
    .page-nav .nav-divider { margin: 0 1px; height: 14px; flex-shrink: 0; }
    .page-nav .nav-clock { font-size: 10px; flex-shrink: 0; white-space: nowrap; }

    /* User pill — proportional to nav, touch-friendly via padding */
    .nav-user-menu { flex-shrink: 0; margin-left: 4px; }
    .nav-user-pill { width: 32px; height: 32px; }
    .nav-user-dropdown { position: fixed; top: 46px; right: 8px; left: auto; min-width: 240px; max-width: calc(100vw - 16px); }
    .nav-user-info { padding: 10px 14px 8px; }
    .nav-user-item { min-height: 44px; padding: 10px 12px; font-size: 13px; }

    /* Drawer action buttons — touch-friendly */
    .drawer-action-btn { min-width: 36px; min-height: 36px; }

    /* App dialog — prevent overflow on narrow phones */
    .app-dialog-content { min-width: auto !important; width: 100%; }

    /* Change password fields — iOS zoom prevention + touch */
    .cpw-fields .app-dialog-input {
        font-size: 16px;
        min-height: 44px;
        padding: 10px 12px;
        border-radius: 8px;
    }
    .cpw-label { font-size: 12px; }
    .cpw-error { font-size: 13px; }

    /* ═══════════════════════════════════════════════════════
       PAGE KPI CARDS
       ═══════════════════════════════════════════════════════ */

    .page-kpi {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .page-kpi::-webkit-scrollbar { display: none; }
    .page-kpi .kpi-card {
        min-width: 72px;
        flex: 0 0 auto;
        padding: 6px 8px;
    }

    /* ═══════════════════════════════════════════════════════
       SECTION CARDS — Tighter
       ═══════════════════════════════════════════════════════ */

    .section-card { padding: 10px 12px; margin-bottom: 8px; }

    /* ═══════════════════════════════════════════════════════
       BUTTONS — Touch-friendly sizes
       ═══════════════════════════════════════════════════════ */

    .btn { min-height: 44px; padding: 10px 16px; border-radius: 6px; }
    .btn-sm { min-height: 40px; padding: 8px 12px; border-radius: 6px; }

    /* ═══════════════════════════════════════════════════════
       JOURNAL PAGE
       ═══════════════════════════════════════════════════════ */

    .journal-filters {
        gap: 6px;
        padding: 6px 10px;
        flex-wrap: wrap;
    }
    .journal-filters input, .journal-filters select {
        min-width: 0;
        flex: 1;
        min-height: 44px;
    }

    /* ═══════════════════════════════════════════════════════
       PULSE PAGE — Mobile fixes
       ═══════════════════════════════════════════════════════ */

    .pulse-grid { overflow: visible; }
    .pulse-panel { overflow: visible; }
    .pulse-kpi-strip { scrollbar-width: none; }
    .pulse-kpi-strip::-webkit-scrollbar { display: none; }

    /* ═══════════════════════════════════════════════════════
       KNOWLEDGE PAGE — Mobile fixes
       ═══════════════════════════════════════════════════════ */

    .ki-kpi-bar { scrollbar-width: none; }
    .ki-kpi-bar::-webkit-scrollbar { display: none; }

    /* ═══════════════════════════════════════════════════════
       HEALTH PAGE
       ═══════════════════════════════════════════════════════ */

    .health-grid { grid-template-columns: 1fr; }
    .health-card-metrics { grid-template-columns: 1fr; }

    /* ═══════════════════════════════════════════════════════
       ANALYTICS PAGE
       ═══════════════════════════════════════════════════════ */

    .analytics-columns { flex-direction: column; }
    .analytics-chart-wrap { height: 220px; }
    .analytics-chart-sm { height: 150px; }
    .analytics-metric-grid { grid-template-columns: 1fr; }
    .analytics-table { font-size: 11px; }
    .analytics-table th,
    .analytics-table td { padding: 5px 6px; }
    .signal-name-badge { font-size: 10px; padding: 2px 6px; }

    /* ═══════════════════════════════════════════════════════
       ALERTS PAGE
       ═══════════════════════════════════════════════════════ */

    .alerts-filter-bar { gap: 8px; padding: 0 10px 8px; }
    .filter-select, .filter-input { min-width: 0; flex: 1; }
    .alert-card-body { padding: 8px 10px; }
    .alert-title { font-size: 12px; }
    .alert-message { font-size: 11px; }
    .alert-category { display: none; }

    /* ═══════════════════════════════════════════════════════
       IMPORT PAGE
       ═══════════════════════════════════════════════════════ */

    .import-config-bar { flex-wrap: wrap; gap: 6px; padding: 6px 10px; }

    /* ═══════════════════════════════════════════════════════
       COMMAND PALETTE — Full width
       ═══════════════════════════════════════════════════════ */

    .cmd-palette {
        border-radius: 12px;
        max-width: 95vw;
        width: 100%;
    }
    .cmd-search {
        min-height: 44px;
    }

    /* ═══════════════════════════════════════════════════════
       STATUS BAR — Compact
       ═══════════════════════════════════════════════════════ */

    .sb-segment.sb-hide-mobile { display: none; }

    /* Safe area padding for notched phones */
    .status-bar {
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }

    /* Global button active state — tactile feedback */
    .btn:active:not(:disabled),
    .hdr-btn:active,
    .filter-btn:active,
    .scale-btn:active {
        transform: scale(0.96);
        transition: transform 0.1s;
    }

    /* Context menu — disabled on mobile (long-press is native OS) */
    #context-menu { display: none !important; }

    /* Scrollable containers — hide native scrollbars */
    #kpi-bar::-webkit-scrollbar,
    .page-kpi::-webkit-scrollbar,
    .trade-header-right::-webkit-scrollbar {
        display: none;
    }
    #kpi-bar, .page-kpi, .trade-header-right {
        scrollbar-width: none;
    }

    /* Scale modal buttons — larger touch targets */
    .scale-btn {
        min-height: 48px;
        min-width: 60px;
        font-size: 15px;
        border-radius: 8px;
    }
    .scale-options {
        gap: 8px;
    }

}


/* ── Extra narrow phones (<480px) ── */
@media (max-width: 480px) {
    .page-nav .nav-link { padding: 5px 8px; font-size: 10px; }
    .page-nav .nav-divider { display: none; }
    .page-nav .nav-clock { display: none; }
    .nav-dropdown-trigger { font-size: 10px !important; padding: 5px 8px !important; }
    .nav-user-pill { width: 30px; height: 30px; }
    .nav-user-dropdown { top: 42px; right: 6px; }

    .trade-live-price { font-size: 18px; }
    .trade-ticker { font-size: 14px; }
    .trade-chart-container { height: 200px; }

    .kpi-card, .page-kpi .kpi-card { min-width: 60px; }
    .kpi-value, .page-kpi .kpi-value { font-size: 13px; }
    .kpi-label, .page-kpi .kpi-label { font-size: 8px; }

    .health-banner { flex-direction: column; gap: 6px; }
    .health-banner .banner-sub { margin-left: 0; }

    .analytics-chart-wrap { height: 180px; }
    .analytics-chart-sm { height: 120px; }
    .period-btn { font-size: 10px; padding: 3px 8px; }

    .alert-card-actions { padding: 0 6px; }
    .btn-dismiss { min-width: 28px; min-height: 28px; font-size: 11px; }

    .metric-row { font-size: 11px; }
    .confidence-bar { width: 60px; }

    #detail-panel { max-height: 60vh; }

    .detail-actions .action-btn { padding: 8px 12px; font-size: 12px; }

    /* Confirmation bar wraps on very narrow screens */
    #confirmation-bar {
        flex-wrap: wrap;
        padding: 12px;
    }
    #confirmMessage {
        width: 100%;
        margin-bottom: 4px;
    }
}

/* ── Desktop: detail panel close button + hide drag bar ── */
@media (min-width: 769px) {
    /* Create clearance for the close button so it doesn't overlap sparkline */
    .detail-info {
        padding-right: 32px;
    }
    /* Match right inset so danger buttons align with sparkline above */
    .detail-actions {
        padding-right: 32px;
    }
    .detail-panel-handle {
        position: absolute;
        right: 10px;
        top: 8px;
        padding: 0;
        z-index: 2;
    }
    .detail-panel-handle::before { display: none; }
    .detail-panel-close {
        display: flex;
        width: 28px;
        height: 28px;
        font-size: 15px;
        border: 1px solid transparent;
        background: transparent;
        color: var(--fg2);
        cursor: pointer;
        align-items: center;
        justify-content: center;
        border-radius: 6px;
        transition: background 0.15s, color 0.15s, border-color 0.15s;
    }
    .detail-panel-close:hover {
        background: rgba(255,255,255,0.06);
        border-color: var(--border);
        color: var(--fg);
    }
    .detail-panel-close:active {
        background: rgba(255,255,255,0.1);
        transform: scale(0.92);
    }
    .detail-panel-close:focus-visible {
        outline: 2px solid var(--teal);
        outline-offset: 2px;
    }
}

/* ── Animations (outside @media for max browser compat) ── */
@keyframes confirmSlideDown {
    from { transform: translateY(-100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
