:root {
    /* --- COLOR PALETTE (Deep Blue Premium) --- */
    --bg-body: radial-gradient(circle at top left, #1e293b 0%, #0f172a 40%, #020617 100%);
    
    /* Glass Elements */
    --glass-sidebar: rgba(15, 23, 42, 0.75);
    --glass-card: rgba(30, 41, 59, 0.4);
    --glass-border: 1px solid rgba(255, 255, 255, 0.08);
    --glass-blur: blur(20px);
    
    /* Text */
    --text-main: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-dim: #64748b;
    
    /* Accents */
    --primary: #3b82f6;       /* Blue */
    --primary-hover: #2563eb;
    --accent: #8b5cf6;        /* Purple */
    
    /* Status */
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    
    /* Dimensions */
    --radius-lg: 16px;
    --radius-md: 10px;
    --radius-sm: 6px;
    --header-height: 64px;
}

/* --- GLOBAL RESET --- */
* { box-sizing: border-box; outline: none; }

body { 
    background: var(--bg-body); 
    color: var(--text-main); 
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif; 
    margin: 0; 
    height: 100vh; 
    display: flex; 
    flex-direction: column; 
    overflow: hidden; 
}

/* --- SCROLLBARS (General) --- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* --- INPUT CLEANUP (No Spinners) --- */
input[type=number]::-webkit-inner-spin-button, 
input[type=number]::-webkit-outer-spin-button { 
    -webkit-appearance: none; 
    appearance: none; 
    margin: 0; 
}
input[type=number] {
    -moz-appearance: textfield;
    appearance: textfield;
}

/* --- TOM SELECT FIXES --- */
.ts-wrapper.single .ts-control, .ts-wrapper.multi .ts-control {
    background: rgba(0, 0, 0, 0.3) !important;
    border: var(--glass-border) !important;
    color: white !important;
    border-radius: var(--radius-sm) !important;
    padding: 8px 12px !important;
    box-shadow: none !important;
}

.ts-dropdown {
    background: #1e293b !important;
    border: var(--glass-border) !important;
    color: white !important;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5) !important;
    border-radius: var(--radius-sm) !important;
    z-index: 10000 !important;
}

.ts-dropdown .option {
    color: var(--text-secondary) !important;
    padding: 8px 12px !important;
}
.ts-dropdown .active {
    background: var(--primary) !important;
    color: white !important;
}

.ts-control > input { color: white !important; }
.ts-wrapper.single .ts-control::after { border-color: #888 transparent transparent transparent !important; }

/* --- HEADER --- */
.header { 
    height: var(--header-height); 
    background: rgba(15, 23, 42, 0.9); 
    backdrop-filter: var(--glass-blur); 
    border-bottom: var(--glass-border); 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    padding: 0 24px; 
    flex-shrink: 0; 
    z-index: 50; 
}

.brand { 
    font-weight: 800; 
    font-size: 1.1rem; 
    letter-spacing: 0.5px; 
    color: white; 
    display: flex; 
    align-items: center; 
    gap: 12px; 
}

/* Mobile Menu Button (Hidden by default) */
.menu-icon-btn {
    display: none; /* Desktop: hidden */
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 0;
    margin-right: 10px;
}

.brand span { 
    color: var(--primary); 
    font-weight: 400; 
    opacity: 0.9; 
    font-size: 0.85rem; 
    border-left: 1px solid rgba(255,255,255,0.15); 
    padding-left: 12px; 
    letter-spacing: 0;
}

.header-controls { display: flex; gap: 10px; }

/* PREMIUM BUTTON STYLE */
.head-btn {
    background: rgba(255,255,255,0.05); 
    border: var(--glass-border); 
    color: var(--text-secondary);
    padding: 8px 16px; 
    border-radius: var(--radius-sm); 
    cursor: pointer; 
    font-size: 0.75rem; 
    font-weight: 700; 
    text-transform: uppercase; 
    letter-spacing: 1px; 
    transition: all 0.2s ease; 
    white-space: nowrap;
}
.head-btn:hover { 
    background: rgba(255,255,255,0.1); 
    color: white; 
    border-color: rgba(255,255,255,0.2); 
}

/* --- MAIN LAYOUT --- */
.workspace { display: flex; flex: 1; overflow: hidden; position: relative; }

/* --- SIDEBAR --- */
.sidebar { 
    width: 360px; 
    background: var(--glass-sidebar); 
    backdrop-filter: blur(15px);
    border-right: var(--glass-border); 
    display: flex; 
    flex-direction: column; 
    height: 100%;
    transition: transform 0.3s ease;
    z-index: 100;
    position: relative; /* Context for close btn */
}

/* NEW: Sidebar Close Button */
.sidebar-close-btn {
    display: none; /* Hidden on desktop */
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(255,255,255,0.1);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    z-index: 101;
    align-items: center;
    justify-content: center;
}
.sidebar-close-btn:hover { background: rgba(239, 68, 68, 0.5); }

/* Mobile Backdrop */
.mobile-backdrop {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    z-index: 90;
    display: none;
    opacity: 0;
    transition: opacity 0.3s;
}
.mobile-backdrop.open { display: block; opacity: 1; }

.sidebar-content { 
    flex: 1; 
    overflow-y: auto; 
    padding: 20px 24px; 
    display: flex; 
    flex-direction: column; 
    gap: 24px; 
    min-height: 0;
    -ms-overflow-style: none;
    scrollbar-width: none;
}
.sidebar-content::-webkit-scrollbar { display: none; }

.section-group h3 {
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--primary);
    letter-spacing: 1px;
    margin: 0 0 12px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 700;
}

/* Info Icon (No Tooltip) */
.info-icon {
    color: var(--text-dim);
    margin-left: 6px;
    font-size: 0.75rem;
    opacity: 0.7;
    cursor: default;
}

.control-links { font-size: 0.65rem; letter-spacing: 0; font-weight: 500; }
.control-links a { text-decoration: none; color: var(--text-dim); margin-left: 10px; transition: 0.2s; cursor: pointer; }
.control-links a:hover { color: white; }

/* Inputs */
.input-group { margin-bottom: 12px; position: relative; }
.input-label { display: flex; align-items: center; font-size: 0.75rem; color: var(--text-secondary); margin-bottom: 6px; font-weight: 500; }

input[type="text"], input[type="number"], select {
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border: var(--glass-border);
    color: white;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.9rem;
    transition: 0.2s;
}
input:focus, select:focus {
    border-color: var(--primary);
    background: rgba(0, 0, 0, 0.5);
    box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.3);
}

/* NEW: Ticker Chips with Delete */
.chips-row { 
    display: flex; 
    flex-wrap: wrap; 
    gap: 8px; 
    margin-top: 10px; 
}
.chip-wrapper {
    display: inline-flex;
    align-items: center;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: 6px;
    overflow: hidden;
    transition: 0.2s;
}
.chip-wrapper:hover { border-color: var(--primary); background: rgba(59, 130, 246, 0.1); }

.chip-label {
    font-size: 0.7rem;
    padding: 6px 10px;
    color: var(--text-secondary);
    cursor: pointer;
    border-right: 1px solid rgba(255,255,255,0.05);
}
.chip-label:hover { color: white; }

.chip-del {
    font-size: 0.7rem;
    padding: 6px 8px;
    color: #64748b;
    cursor: pointer;
    transition: 0.2s;
    font-weight: bold;
}
.chip-del:hover { background: rgba(239, 68, 68, 0.2); color: var(--danger); }


/* Checkbox Lists (INCREASED HEIGHT) */
.checklist {
    background: rgba(0, 0, 0, 0.2);
    border: var(--glass-border);
    border-radius: var(--radius-md);
    max-height: 320px; 
    min-height: 100px;
    overflow-y: auto;
}
.check-row {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    border-bottom: 1px solid rgba(255,255,255,0.03);
    cursor: pointer;
    transition: 0.15s;
}
.check-row:last-child { border-bottom: none; }
.check-row:hover { background: rgba(255,255,255,0.05); }

.check-row input {
    appearance: none;
    width: 16px; 
    height: 16px;
    border: 1px solid var(--text-secondary);
    border-radius: 4px;
    margin-right: 12px;
    cursor: pointer;
    position: relative;
    background: transparent;
    flex-shrink: 0;
}
.check-row input:checked {
    background: var(--primary);
    border-color: var(--primary);
}
.check-row input:checked::after {
    content: '✓';
    position: absolute;
    color: white;
    font-size: 10px;
    left: 2px;
    top: 0px;
    font-weight: bold;
}
.check-name { 
    font-size: 0.85rem; 
    color: var(--text-main); 
    flex: 1; 
    white-space: nowrap; 
    overflow: hidden; 
    text-overflow: ellipsis; 
}

/* Trash Icon */
.btn-trash {
    background: none; 
    border: none; 
    color: #555; 
    cursor: pointer; 
    padding: 4px; 
    border-radius: 4px; 
    opacity: 0; 
    transition: 0.2s;
    font-size: 0.9rem;
}
.check-row:hover .btn-trash { opacity: 1; }
.btn-trash:hover { color: var(--danger); background: rgba(239, 68, 68, 0.1); }

/* Sidebar Footer */
.sidebar-footer {
    padding: 20px 24px; 
    border-top: var(--glass-border);
    background: rgba(10, 15, 30, 0.4);
    flex-shrink: 0; 
    margin-top: auto; 
}

.btn-hero {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: var(--radius-md);
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    text-transform: uppercase;
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.btn-launch {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 20px rgba(59, 130, 246, 0.3);
}
.btn-launch:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(59, 130, 246, 0.4);
}

.btn-abort {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid var(--danger);
    color: var(--danger);
}
.btn-abort:hover { background: rgba(239, 68, 68, 0.25); }

/* --- MAIN VIEW --- */
.main-view { flex: 1; display: flex; flex-direction: column; overflow: hidden; position: relative; }

/* Tabs (RESPONSIVE GRID REFACTOR) */
.tabs-wrapper {
    display: grid;
    grid-template-columns: 1fr auto 1fr; /* Spacer / Center / Status */
    align-items: center;
    padding: 16px 24px;
    border-bottom: var(--glass-border);
    background: rgba(15, 23, 42, 0.3);
}

.tw-spacer { visibility: hidden; pointer-events: none; } /* Left Balancer */

.segmented-control {
    display: flex;
    background: rgba(0, 0, 0, 0.4);
    padding: 4px;
    border-radius: 12px;
    border: var(--glass-border);
    /* No margins needed with grid */
}

.tab-btn {
    padding: 8px 20px;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    border-radius: 8px;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.tab-btn:hover { color: white; }
.tab-btn.active {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

/* Status & Cost Indicator */
.status-pill {
    display: flex;
    align-items: center;
    gap: 15px; 
    justify-self: end; /* Grid align right */
}

/* NEW: Cost Display */
.cost-stat {
    display: flex; flex-direction: column; align-items: flex-end; justify-content: center;
    text-align: right;
    margin-right: 10px;
}
.cost-label { font-size: 0.6rem; color: #64748b; letter-spacing: 1px; font-weight: 700; }
.cost-value { font-family: 'JetBrains Mono'; font-size: 0.9rem; color: #fbbf24; font-weight: 700; }

.status-box {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: rgba(255,255,255,0.05);
    padding: 6px 12px;
    border-radius: 20px;
    border: var(--glass-border);
}

#statusText {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 120px; 
    display: block;
}

.led { width: 8px; height: 8px; border-radius: 50%; background: #666; box-shadow: 0 0 5px rgba(0,0,0,0.5); flex-shrink: 0; }
.led.on { background: var(--success); box-shadow: 0 0 8px var(--success); }
.led.busy { background: var(--warning); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: 0.5; } }

/* Pages */
.page-content { flex: 1; overflow-y: auto; padding: 30px; display: none; }
.page-content.active { display: block; animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* --- CARDS & GRID --- */
.analysis-grid { 
    display: grid; 
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); /* FIX: Reduced min width for mobile */
    gap: 24px; 
}

.glass-card {
    background: var(--glass-card);
    backdrop-filter: blur(12px);
    border: var(--glass-border);
    border-radius: var(--radius-md);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform 0.2s;
}
.glass-card:hover { border-color: rgba(255,255,255,0.2); transform: translateY(-2px); }

.gc-head {
    padding: 16px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0,0,0,0.2);
}
.gc-model { font-size: 0.85rem; font-weight: 700; color: white; letter-spacing: 0.5px; }
.gc-tag {
    font-size: 0.7rem; font-weight: 800; text-transform: uppercase; padding: 4px 8px; border-radius: 4px;
}
.tag-buy { background: rgba(16, 185, 129, 0.15); color: #34d399; }
.tag-sell { background: rgba(239, 68, 68, 0.15); color: #f87171; }
.tag-hold { background: rgba(148, 163, 184, 0.15); color: #cbd5e1; }

.gc-body { padding: 16px; display: flex; flex-direction: column; gap: 12px; font-size: 0.9rem; }
.stat-row { display: flex; justify-content: space-between; border-bottom: 1px solid rgba(255,255,255,0.03); padding-bottom: 6px; }
.stat-k { color: var(--text-dim); font-size: 0.8rem; }
.stat-v { font-family: 'JetBrains Mono'; color: var(--text-main); font-weight: 600; }

.gc-thesis {
    background: rgba(0,0,0,0.25);
    padding: 12px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    color: #e2e8f0;
    line-height: 1.5;
    margin-top: 8px;
    border: 1px solid rgba(255,255,255,0.05);
}
.gc-devil {
    font-size: 0.75rem; color: #f87171; margin-top: 5px; font-style: italic; opacity: 0.9;
}

/* --- LOGS --- */
.log-stream { font-family: 'JetBrains Mono'; font-size: 0.8rem; display: flex; flex-direction: column; gap: 8px; padding-bottom: 50px; }
.log-msg { 
    display: flex; gap: 15px; padding: 10px 14px; 
    border-left: 3px solid #333; 
    background: rgba(0,0,0,0.15); 
    border-radius: 0 6px 6px 0; 
}
.log-ts { color: #555; width: 50px; }
.log-cat { font-weight: bold; color: var(--primary); width: 100px; text-transform: uppercase; }
.log-txt { color: #ccc; flex: 1; line-height: 1.4; word-break: break-word; }

.log-msg.err { border-left-color: var(--danger); background: rgba(239,68,68,0.05); }
.log-msg.err .log-cat { color: var(--danger); }

.log-msg.ok { border-left-color: var(--success); }
.log-msg.ok .log-cat { color: var(--success); }

/* --- BOSS PANEL --- */
.boss-wrap { max-width: 800px; margin: 20px auto; }
.boss-panel { 
    background: linear-gradient(180deg, rgba(30, 58, 138, 0.25) 0%, rgba(15, 23, 42, 0.8) 100%); 
    border: 1px solid rgba(59, 130, 246, 0.4); 
    border-radius: var(--radius-lg); 
    padding: 40px; 
    text-align: center; 
    box-shadow: 0 20px 60px rgba(0,0,0,0.5); 
}
.boss-title { font-size: 0.8rem; letter-spacing: 3px; color: #93c5fd; text-transform: uppercase; margin-bottom: 15px; }
.boss-verdict { 
    font-size: 4rem; 
    font-weight: 900; 
    margin: 10px 0 30px 0; 
    background: linear-gradient(to right, #ffffff, #60a5fa); 
    -webkit-background-clip: text; 
    background-clip: text; 
    -webkit-text-fill-color: transparent; 
    letter-spacing: -2px;
}
.boss-summary { font-size: 1.1rem; line-height: 1.6; color: #cbd5e1; margin-bottom: 40px; }

.boss-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }
.b-stat { 
    background: rgba(255,255,255,0.05); 
    padding: 20px; 
    border-radius: 12px; 
    border: 1px solid rgba(255,255,255,0.05);
}
.b-lbl { font-size: 0.7rem; text-transform: uppercase; color: #64748b; margin-bottom: 8px; font-weight: 700; letter-spacing: 1px; }
.b-val { font-size: 1.5rem; font-family: 'JetBrains Mono'; font-weight: 700; color: white; }

/* --- MODALS --- */
.modal-backdrop { 
    position: fixed; top: 0; left: 0; width: 100%; height: 100%; 
    background: rgba(0,0,0,0.85); backdrop-filter: blur(8px); 
    z-index: 999; display: none; justify-content: center; align-items: center; 
    opacity: 0; transition: opacity 0.2s; 
}
.modal-backdrop.open { display: flex; opacity: 1; }

.modal-window { 
    background: #0f172a; 
    width: 1000px; max-height: 85vh; 
    border: var(--glass-border); 
    border-radius: var(--radius-lg); 
    display: flex; flex-direction: column; 
    box-shadow: 0 50px 100px rgba(0,0,0,0.8); 
    transform: scale(0.95); transition: transform 0.2s; 
}
.modal-backdrop.open .modal-window { transform: scale(1); }

.mw-header { 
    padding: 20px 30px; 
    border-bottom: var(--glass-border); 
    display: flex; justify-content: space-between; align-items: center; 
    background: rgba(255,255,255,0.02); 
}
.mw-body { flex: 1; overflow-y: auto; padding: 0; }
.close-icon { background: none; border: none; color: #666; font-size: 1.8rem; cursor: pointer; transition: 0.2s; }
.close-icon:hover { color: white; }

/* --- CATALOG TOOLBAR --- */
.cat-toolbar { 
    padding: 20px 30px; 
    border-bottom: var(--glass-border); 
    display: flex; flex-direction: column; gap: 16px; 
    background: rgba(0,0,0,0.2); 
}
.cat-row-top { display: flex; gap: 16px; width: 100%; }
.cat-row-chips { display: flex; gap: 8px; flex-wrap: wrap; }

.cat-search { 
    flex: 1; background: rgba(0,0,0,0.3); border: var(--glass-border); 
    padding: 12px 16px; color: white; border-radius: 8px; font-size: 0.9rem;
}
.cat-search:focus { border-color: var(--primary); background: rgba(0,0,0,0.5); }

.chip-btn { 
    background: rgba(255,255,255,0.05); 
    border: 1px solid rgba(255,255,255,0.1); 
    color: var(--text-secondary); 
    padding: 6px 16px; border-radius: 20px; 
    font-size: 0.8rem; cursor: pointer; transition: 0.2s; 
    font-weight: 500;
}
.chip-btn:hover { background: rgba(255,255,255,0.1); color: white; }
.chip-btn.active { background: var(--primary); color: white; border-color: var(--primary); }

.cat-grid { display: flex; flex-direction: column; }

.cat-row { 
    display: flex; justify-content: space-between; align-items: center; 
    padding: 20px 30px; border-bottom: 1px solid rgba(255,255,255,0.03); 
    transition: 0.1s; 
}
.cat-row:hover { background: rgba(255,255,255,0.02); }

.cat-info h4 { margin: 0 0 4px 0; color: white; font-size: 0.95rem; }
.cat-info p { margin: 0; color: var(--text-dim); font-family: monospace; font-size: 0.8rem; }

.cat-meta { display: flex; align-items: center; gap: 20px; }

.price-pill { 
    font-family: 'JetBrains Mono'; font-size: 0.75rem; 
    background: rgba(16, 185, 129, 0.1); color: var(--success); 
    padding: 6px 12px; border-radius: 6px; 
    border: 1px solid rgba(16, 185, 129, 0.2); 
}

.btn-add { 
    background: transparent; border: 1px solid #444; color: #ccc; 
    padding: 8px 16px; border-radius: 6px; cursor: pointer; 
    font-size: 0.8rem; transition: 0.2s; font-weight: 600; text-transform: uppercase;
}
.btn-add:hover { border-color: var(--primary); color: var(--primary); }
.btn-add.added { background: var(--success); border-color: var(--success); color: #000; }

/* --- PROMPT EDITOR --- */
.pe-area { 
    width: 100%; height: 200px; 
    background: #0b0f19; border: 1px solid #333; 
    color: #a5f3fc; padding: 15px; 
    font-family: 'JetBrains Mono'; font-size: 0.85rem; 
    border-radius: 8px; resize: vertical; margin-bottom: 20px; 
    line-height: 1.5;
}
.pe-label { margin-bottom: 8px; display: block; font-weight: 700; color: white; font-size: 0.85rem; }

/* --- HISTORY STYLES --- */
.hist-grid { display: flex; flex-direction: column; gap: 8px; }
.hist-item { 
    display: flex; align-items: center; justify-content: space-between; 
    padding: 16px 20px; background: rgba(255,255,255,0.03); 
    border: 1px solid rgba(255,255,255,0.05); border-radius: 8px; 
    cursor: pointer; transition: 0.2s; 
}
.hist-item:hover { background: rgba(255,255,255,0.05); border-color: var(--primary); }
.h-icon { font-size: 1.2rem; margin-right: 15px; opacity: 0.7; }
.h-info { flex: 1; }
.h-title { font-weight: 700; color: white; font-size: 0.95rem; }
.h-date { font-family: 'JetBrains Mono'; font-size: 0.75rem; color: var(--text-dim); margin-top: 4px; }
.h-arrow { color: var(--primary); font-weight: bold; opacity: 0; transform: translateX(-10px); transition: 0.2s; }
.hist-item:hover .h-arrow { opacity: 1; transform: translateX(0); }

/* --- V6 NEW STYLES (Probability Badges) --- */
.prob-badge {
    font-size: 0.65rem; padding: 2px 6px; border-radius: 4px; margin-left: 6px; font-weight: 700; opacity: 0.9;
}
.p-0, .p-1 { background: rgba(239, 68, 68, 0.2); color: #f87171; border: 1px solid rgba(239, 68, 68, 0.3); } /* Low */
.p-2, .p-3 { background: rgba(245, 158, 11, 0.2); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.3); } /* Mid */
.p-4, .p-5 { background: rgba(16, 185, 129, 0.2); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.3); } /* High */

/* ... (весь код выше до строки @media оставляем как был) ... */

/* --- RESPONSIVE / MOBILE OPTIMIZATION (FIXED v2) --- */
@media screen and (max-width: 1024px) {
    
    /* 1. SIDEBAR: Off-canvas mechanics */
    .sidebar {
        position: fixed;
        left: -100%; /* Спрятан влево */
        top: 0;
        width: 85%; /* Ширина 85% экрана, а не фикс пиксели */
        max-width: 320px; /* Но не шире 320px */
        
        /* Исправление высоты для мобильных браузеров (Safari/Chrome) */
        height: 100vh; 
        height: 100dvh; 
        
        box-shadow: 10px 0 50px rgba(0,0,0,0.8);
        display: flex;
        flex-direction: column;
        z-index: 2000; /* Поверх всего */
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
    .sidebar.open {
        left: 0; /* Выезжает */
    }
    
    /* Кнопка закрытия внутри сайдбара */
    .sidebar-close-btn { display: flex; }

    /* Контент сайдбара скроллится */
    .sidebar-content {
        flex: 1;
        overflow-y: auto;
        padding-bottom: 20px;
    }

    /* Футер сайдбара прибит к низу */
    .sidebar-footer {
        flex-shrink: 0;
        background: #0f172a; 
        border-top: 1px solid rgba(255,255,255,0.1);
        padding: 15px 20px;
        position: relative;
        z-index: 10;
    }

    /* Списки моделей не такие огромные */
    .checklist { max-height: 200px; }
    
    /* 2. HEADER: Адаптация шапки */
    .menu-icon-btn { display: block; margin-right: 15px; }
    
    .header { 
        padding: 0 15px; 
        height: auto; 
        min-height: 60px;
        flex-wrap: wrap; /* Разрешаем перенос кнопок если не влезают */
        gap: 10px;
    }
    
    .brand { font-size: 0.9rem; flex: 1; }
    .brand span { display: none; } /* Скрываем подзаголовок на мобильных */
    
    /* Кнопки в шапке */
    .header-controls {
        gap: 8px;
        width: 100%; /* Кнопки на новой строке если надо */
        justify-content: space-between;
        padding-bottom: 10px;
        overflow-x: auto; /* Скролл если кнопок много */
    }
    .head-btn {
        padding: 8px 12px;
        font-size: 0.7rem;
        flex-shrink: 0;
    }
    
    /* 3. TABS & STATUS: Полный сброс десктопной математики */
    .tabs-wrapper {
        display: flex;
        flex-direction: column; /* Столбик */
        align-items: stretch; /* На всю ширину */
        gap: 15px;
        padding: 15px;
        background: rgba(15, 23, 42, 0.5);
        
        /* ВАЖНО: Сбрасываем десктопные отступы */
        padding-right: 15px !important; 
    }

    /* Спейсер не нужен */
    .tw-spacer { display: none; } 

    /* Табы */
    .segmented-control {
        margin: 0 !important; /* Сброс margin-left */
        width: 100%;
        overflow-x: auto; /* Горизонтальный скролл табов */
        justify-content: flex-start;
    }
    
    .tab-btn {
        flex: 1;
        text-align: center;
        padding: 10px 15px;
        font-size: 0.75rem;
    }

    /* Статус и деньги - под табами */
    .status-pill {
        position: static; /* Отключаем абсолют */
        transform: none;
        width: 100%;
        justify-content: space-between; /* Разносим по краям */
        margin-top: 0;
    }
    
    /* 4. CONTENT & GRID */
    .page-content { padding: 15px 10px; } /* Меньше отступы */
    
    /* Карточки одна под другой */
    .analysis-grid { 
        grid-template-columns: 1fr; 
    }
    
    /* Стили для босса и модалок */
    .boss-grid { grid-template-columns: 1fr; }
    .boss-panel { padding: 20px; }
    .boss-verdict { font-size: 2.5rem; }
    
    .modal-window { width: 95%; max-height: 90vh; }
    .cat-row { flex-direction: column; align-items: flex-start; gap: 10px; }
    .cat-meta { width: 100%; justify-content: space-between; }
}