/* Custom additions on top of Tailwind CDN */

html, body {
    background: #09090b;       /* zinc-950 */
    color: #fafafa;             /* zinc-50 */
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
                 'Helvetica Neue', Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    font-feature-settings: 'cv11', 'ss01', 'ss03';
    overflow-x: hidden;
    max-width: 100vw;
}

/* ── App shell (sidebar + main) ─────────────────────────────────── */
.app-shell {
    min-height: 100vh;
    min-height: 100dvh;
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
}
.app-body {
    display: flex;
    min-height: calc(100vh - 3rem);
    min-height: calc(100dvh - 3rem);
    width: 100%;
    max-width: 100vw;
}
.app-main {
    flex: 1 1 0%;
    min-width: 0;
    max-width: 100%;
    overflow-x: hidden;
}

/* Mobile top bar + drawer sidebar */
.mobile-topbar {
    display: none;
    position: sticky;
    top: 0;
    z-index: 40;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.625rem 1rem;
    background: #09090b;
    border-bottom: 1px solid #27272a;
}
.mobile-menu-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    padding: 0.5rem;
    border-radius: 0.5rem;
    border: 1px solid #3f3f46;
    background: #18181b;
    color: #fafafa;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.mobile-menu-btn:active { background: #27272a; }
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 45;
    background: rgba(0, 0, 0, 0.55);
    -webkit-tap-highlight-color: transparent;
}
.dashboard-sidebar {
    flex-shrink: 0;
}
.sidebar-drawer-open .sidebar-overlay { display: block; }

@media (max-width: 1023px) {
    .mobile-topbar { display: flex !important; }
    .app-shell.flex,
    .app-body {
        display: block !important;
        width: 100% !important;
        max-width: 100vw !important;
    }
    /* Sidebar host must not consume horizontal space */
    #sidebar {
        position: fixed !important;
        top: 0;
        left: 0;
        width: 0 !important;
        height: 0 !important;
        overflow: visible !important;
        flex: none !important;
        z-index: 50;
        pointer-events: none;
    }
    .sidebar-drawer-open #sidebar { pointer-events: auto; }
    .app-body > main,
    .app-main,
    main.flex-1 {
        width: 100% !important;
        max-width: 100vw !important;
        margin-left: 0 !important;
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
        overflow-x: hidden;
    }
    .dashboard-sidebar {
        position: fixed !important;
        top: 0;
        left: 0;
        z-index: 51;
        height: 100dvh;
        width: min(17.5rem, 88vw) !important;
        max-width: 88vw;
        transform: translateX(-105%);
        transition: transform 0.22s ease;
        box-shadow: 8px 0 32px rgba(0, 0, 0, 0.45);
        pointer-events: auto;
    }
    .sidebar-drawer-open .dashboard-sidebar {
        transform: translateX(0);
    }
    .dashboard-sidebar .sticky,
    .dashboard-sidebar.h-screen {
        position: static !important;
        height: 100dvh !important;
    }
    /* Desktop-only wide subtitle */
    .section-subtitle { display: none; }
}

/* Contained table scroll — never page-level horizontal scroll */
.table-scroll-wrap {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
}
.table-scroll-wrap .data-table {
    min-width: 720px;
}

/* Journal: hide detail columns on mobile; core monitoring cols stay */
@media (max-width: 767px) {
    .journal-col-detail { display: none !important; }
    .journal-desktop-table { display: none !important; }
    .journal-mobile-feed { display: block !important; }
    .table-scroll-wrap .data-table { min-width: 36rem; }
    .data-table thead th,
    .data-table tbody td {
        padding: 0.5rem 0.4rem;
        font-size: 0.75rem;
    }
    .kpi-value { font-size: 1.35rem; }
    .section-title { font-size: 1.25rem; }
    .section-subtitle { font-size: 0.8125rem; line-height: 1.4; }
}

/* Quick-view chip scroller */
.qv-scroll {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.5rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    padding-bottom: 0.25rem;
    max-width: 100%;
}
.qv-scroll button { flex-shrink: 0; min-height: 44px; }

/* Mobile trade cards (journal) */
.journal-mobile-feed { display: none; }
.journal-mobile-card {
    border: 1px solid #27272a;
    border-radius: 0.625rem;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    background: #0f0f12;
    -webkit-tap-highlight-color: transparent;
}
.journal-mobile-card:active { background: #18181b; }
.journal-mobile-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.35rem;
}
.journal-mobile-card-symbol { font-weight: 700; font-size: 0.9375rem; }
.journal-mobile-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 0.5rem;
    font-size: 0.6875rem;
    color: #71717a;
    margin-bottom: 0.35rem;
}
.journal-mobile-card-pnl {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem;
    font-variant-numeric: tabular-nums;
}
.journal-mobile-card-pnl .big {
    font-size: 1.125rem;
    font-weight: 700;
}

/* Touch-friendly controls on small screens */
@media (max-width: 767px) {
    .env-toggle-btn,
    #filter-apply,
    #export-csv,
    select {
        min-height: 44px;
    }
}

/* Mobile login gate (basic auth helper) */
.auth-gate {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
    background: #09090b;
}
.auth-gate-card {
    width: 100%;
    max-width: 22rem;
    background: #18181b;
    border: 1px solid #3f3f46;
    border-radius: 0.75rem;
    padding: 1.5rem;
}
.auth-gate input {
    width: 100%;
    min-height: 44px;
    padding: 0.625rem 0.75rem;
    border-radius: 0.5rem;
    border: 1px solid #3f3f46;
    background: #09090b;
    color: #fafafa;
    font-size: 16px; /* prevents iOS zoom on focus */
}
.auth-gate button[type="submit"] {
    width: 100%;
    min-height: 48px;
    margin-top: 0.75rem;
    border-radius: 0.5rem;
    background: #059669;
    color: #fff;
    font-weight: 600;
    font-size: 1rem;
    border: none;
    cursor: pointer;
}
.auth-gate .auth-error {
    margin-top: 0.75rem;
    font-size: 0.8125rem;
    color: #fca5a5;
}

/* Sidebar nav items */
.nav-item {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    color: #a1a1aa;
    transition: all 0.15s;
}
.nav-item:hover {
    background: #18181b;
    color: #f4f4f5;
}
.nav-active {
    background: linear-gradient(90deg, rgba(16, 185, 129, 0.15), rgba(16, 185, 129, 0.05));
    color: #6ee7b7;
    border-left: 2px solid #10b981;
}

/* KPI tile */
.kpi {
    background: linear-gradient(135deg, #18181b, #0f0f12);
    border: 1px solid #27272a;
    border-radius: 0.75rem;
    padding: 1.25rem;
    transition: border-color 0.2s;
}
.kpi:hover { border-color: #3f3f46; }
.kpi-label {
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #71717a;
    font-weight: 600;
}
.kpi-value {
    font-size: 1.875rem;
    font-weight: 700;
    color: #fafafa;
    margin-top: 0.25rem;
    font-variant-numeric: tabular-nums;
}
.kpi-sub {
    font-size: 0.75rem;
    color: #71717a;
    margin-top: 0.25rem;
    font-variant-numeric: tabular-nums;
}

/* Card */
.card {
    background: #18181b;
    border: 1px solid #27272a;
    border-radius: 0.75rem;
    padding: 1.25rem;
}
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}
.card-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: #fafafa;
}
.card-subtitle {
    font-size: 0.75rem;
    color: #71717a;
    margin-top: 0.125rem;
}

/* Tables */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-variant-numeric: tabular-nums;
}
.data-table thead th {
    text-align: left;
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #71717a;
    font-weight: 600;
    padding: 0.625rem 0.75rem;
    border-bottom: 1px solid #27272a;
}
.data-table tbody td {
    padding: 0.625rem 0.75rem;
    border-bottom: 1px solid #1c1c1f;
    font-size: 0.8125rem;
    color: #d4d4d8;
}
.data-table tbody tr:hover { background: #1c1c1f; }
.data-table tbody tr:last-child td { border-bottom: none; }

/* Pill badges */
.pill {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}
.pill-long  { background: rgba(16, 185, 129, 0.15); color: #6ee7b7; }
.pill-short { background: rgba(244, 63, 94, 0.15);  color: #fda4af; }
.pill-pending { background: rgba(245, 158, 11, 0.15); color: #fcd34d; }
.pill-closed  { background: rgba(99, 102, 241, 0.15); color: #a5b4fc; }
.pill-venue   { background: rgba(6, 182, 212, 0.15);  color: #67e8f9; }

/* Loading skeleton */
.skel {
    background: linear-gradient(90deg, #18181b 0%, #27272a 50%, #18181b 100%);
    background-size: 200% 100%;
    animation: skel-shimmer 1.4s ease-in-out infinite;
    border-radius: 0.375rem;
}
@keyframes skel-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: #09090b; }
::-webkit-scrollbar-thumb { background: #27272a; border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: #3f3f46; }

/* Page section heading */
.section-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #fafafa;
    letter-spacing: -0.025em;
}
.section-subtitle {
    font-size: 0.875rem;
    color: #71717a;
    margin-top: 0.25rem;
}
