/* MJ Auto Dashboard - Dark Theme */

:root {
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-card: #1e2a4a;
    --bg-input: #0f3460;
    --text-primary: #e0e0e0;
    --text-secondary: #a0a0b0;
    --text-muted: #6c6c80;
    --border: #2a3a5e;
    --accent: #4a9eff;
    --green: #4caf50;
    --red: #f44336;
    --orange: #ff9800;
    --grey: #666;
    --blue: #2196f3;
    --urgent: #f44336;
    --high: #ff9800;
    --normal: #2196f3;
    --low: #666;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
}

/* Layout */
.layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 220px;
    background: var(--bg-secondary);
    padding: 20px 0;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border);
    position: fixed;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-header {
    padding: 0 20px 20px;
    border-bottom: 1px solid var(--border);
}

.sidebar-header h2 {
    color: var(--accent);
    font-size: 1.3rem;
}

.nav-links {
    list-style: none;
    padding: 10px 0;
    flex: 1;
}

.nav-links li a {
    display: block;
    padding: 10px 20px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: background 0.2s;
}

.nav-links li a:hover,
.nav-links li a.active {
    background: var(--bg-card);
    color: var(--text-primary);
}

.sidebar-footer {
    padding: 10px 20px;
    border-top: 1px solid var(--border);
}

.sidebar-footer a {
    color: var(--text-muted);
    text-decoration: none;
}

.content {
    flex: 1;
    margin-left: 220px;
    padding: 20px 30px;
    max-width: 1600px;
}

/* Health Bar */
.health-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border-radius: 6px;
    margin-bottom: 20px;
}

.health-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px 3px 7px;
    border-radius: 12px;
    font-size: 11px;
    background: var(--bg-card);
    border: 1px solid var(--border);
}

.health-pill .health-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.health-pill .health-label {
    color: var(--text-primary);
    white-space: nowrap;
}

.health-pill .health-time {
    color: var(--text-muted);
    font-size: 10px;
    white-space: nowrap;
}

.health-pill.ok .health-indicator { background: var(--green); }
.health-pill.success .health-indicator { background: var(--green); }
.health-pill.error .health-indicator { background: var(--red); }
.health-pill.overdue .health-indicator { background: var(--red); }
.health-pill.unknown .health-indicator { background: var(--grey); }

.health-detail {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px 18px;
    margin-bottom: 16px;
    max-width: 480px;
}

.health-detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.health-detail-header strong { color: var(--accent); font-size: 14px; }

.health-detail-close {
    cursor: pointer;
    color: var(--text-muted);
    font-size: 18px;
    line-height: 1;
}

.health-detail-close:hover { color: var(--text-primary); }

.health-detail-desc {
    color: var(--text-secondary);
    font-size: 13px;
    margin-bottom: 10px;
    line-height: 1.5;
}

.health-detail-grid {
    display: flex;
    gap: 20px;
    font-size: 12px;
}

.health-detail-grid > div { display: flex; flex-direction: column; gap: 2px; }

.health-detail-label { color: var(--text-muted); text-transform: uppercase; font-size: 10px; letter-spacing: 0.5px; }
.health-detail-value { color: var(--text-primary); }

.health-status-ok, .health-status-success { color: var(--green); }
.health-status-error { color: var(--red); }
.health-status-overdue { color: var(--orange); }
.health-status-unknown { color: var(--text-muted); }

.health-detail-error {
    margin-top: 8px;
    padding: 8px;
    background: rgba(244, 67, 54, 0.1);
    border-left: 3px solid var(--red);
    border-radius: 4px;
    font-size: 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.health-detail-error .health-detail-value { color: var(--red); word-break: break-word; }

/* Flash Messages */
.flash {
    padding: 10px 15px;
    border-radius: 6px;
    margin-bottom: 15px;
    font-size: 0.9rem;
}

.flash.success { background: rgba(76, 175, 80, 0.2); border: 1px solid var(--green); }
.flash.error { background: rgba(244, 67, 54, 0.2); border: 1px solid var(--red); }

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-bottom: 25px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: 8px;
    padding: 20px;
    text-align: center;
}

.stat-card.stat-good { border-left: 3px solid var(--green); }
.stat-card.stat-bad { border-left: 3px solid var(--red); }
.stat-card.stat-clickable { cursor: pointer; }

.stat-number {
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent);
}

.stat-number-sm {
    font-size: 1rem;
    font-weight: 700;
    color: var(--accent);
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-top: 5px;
}

/* Action Cards */
.actions-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.action-card {
    background: var(--bg-card);
    border-radius: 8px;
    padding: 15px 20px;
    margin-bottom: 12px;
    border-left: 4px solid var(--normal);
}

.action-card.priority-urgent { border-left-color: var(--urgent); }
.action-card.priority-high { border-left-color: var(--high); }
.action-card.priority-normal { border-left-color: var(--normal); }
.action-card.priority-low { border-left-color: var(--low); }

.action-card.stale {
    opacity: 0.6;
}

.action-header {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.action-body h3 {
    font-size: 1rem;
    margin-bottom: 8px;
}

.value-change {
    font-family: monospace;
    font-size: 0.95rem;
    margin-bottom: 8px;
}

.value-change .current { color: var(--red); }
.value-change .arrow { color: var(--text-muted); margin: 0 8px; }
.value-change .suggested { color: var(--green); }

.reasoning {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 8px;
}

.timestamp {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.confidence {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-left: auto;
}

.action-buttons {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.alert-warning {
    background: rgba(255, 152, 0, 0.15);
    border: 1px solid var(--orange);
    color: var(--orange);
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 0.85rem;
    margin-bottom: 8px;
}

/* Diff View */
.diff-view {
    font-family: monospace;
    font-size: 0.85rem;
    margin: 10px 0;
    border-radius: 4px;
    overflow: hidden;
}

.diff-removed {
    background: rgba(244, 67, 54, 0.15);
    padding: 8px 12px;
    border-left: 3px solid var(--red);
    white-space: pre-wrap;
    word-break: break-word;
}

.diff-added {
    background: rgba(76, 175, 80, 0.15);
    padding: 8px 12px;
    border-left: 3px solid var(--green);
    white-space: pre-wrap;
    word-break: break-word;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.module-ppc { background: rgba(33, 150, 243, 0.2); color: var(--blue); }
.module-listings { background: rgba(156, 39, 176, 0.2); color: #ce93d8; }
.module-stock { background: rgba(255, 152, 0, 0.2); color: var(--orange); }
.action-type { background: rgba(255, 255, 255, 0.1); color: var(--text-secondary); }
.stale-badge { background: rgba(102, 102, 102, 0.3); color: #999; }

.priority-badge.priority-urgent { background: rgba(244, 67, 54, 0.2); color: var(--urgent); }
.priority-badge.priority-high { background: rgba(255, 152, 0, 0.2); color: var(--high); }
.priority-badge.priority-normal { background: rgba(33, 150, 243, 0.2); color: var(--normal); }
.priority-badge.priority-low { background: rgba(102, 102, 102, 0.2); color: var(--low); }

.status-approved { background: rgba(76, 175, 80, 0.2); color: var(--green); }
.status-executed { background: rgba(33, 150, 243, 0.2); color: var(--blue); }
.status-rejected { background: rgba(244, 67, 54, 0.2); color: var(--red); }
.status-failed { background: rgba(244, 67, 54, 0.3); color: var(--red); }
.status-dismissed { background: rgba(102, 102, 102, 0.2); color: var(--grey); }

.outcome-improved { background: rgba(76, 175, 80, 0.2); color: var(--green); }
.outcome-worsened { background: rgba(244, 67, 54, 0.2); color: var(--red); }
.outcome-neutral { background: rgba(102, 102, 102, 0.2); color: var(--text-muted); }
.outcome-pending { background: transparent; color: var(--text-muted); }

/* Delta colours for metric changes */
.delta-positive { color: var(--green); font-weight: 600; }
.delta-negative { color: var(--red); font-weight: 600; }

/* Performance date range filter */
.perf-filter-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.perf-presets {
    display: flex;
    gap: 4px;
}

.perf-preset {
    padding: 5px 14px;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--bg-card);
    border: 1px solid var(--border);
    text-decoration: none;
    transition: background 0.2s, color 0.2s;
}

.perf-preset:hover {
    background: var(--bg-input);
    color: var(--text-primary);
}

.perf-preset.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.perf-custom-range {
    display: flex;
    align-items: center;
    gap: 8px;
}

.perf-custom-range input[type="date"] {
    width: 140px;
    padding: 5px 8px;
    font-size: 0.85rem;
}

.brand-branded { background: rgba(33, 150, 243, 0.2); color: var(--blue); }
.brand-generic_clearance { background: rgba(255, 152, 0, 0.2); color: var(--orange); }
.override-active { background: rgba(255, 152, 0, 0.2); color: var(--orange); }

/* Buttons */
.btn {
    display: inline-block;
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    color: white;
    background: var(--bg-input);
    transition: opacity 0.2s;
}

.btn:hover { opacity: 0.85; }
.btn-sm { padding: 4px 10px; font-size: 0.8rem; }
.btn-green { background: var(--green); }
.btn-red { background: var(--red); }
.btn-orange { background: var(--orange); }
.btn-grey { background: var(--grey); }

/* Tables */
.data-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
}

.data-table th,
.data-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
}

.data-table th {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
}

.data-table th[data-tip] {
    cursor: help;
    position: relative;
    text-decoration: underline dotted var(--text-muted);
    text-underline-offset: 3px;
}

.data-table th[data-tip]:hover::after {
    content: attr(data-tip);
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #222;
    color: #e0e0e0;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 400;
    text-transform: none;
    white-space: nowrap;
    z-index: 100;
    pointer-events: none;
    border: 1px solid var(--border);
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

.data-table tr:hover {
    background: rgba(255, 255, 255, 0.03);
}

.value-change-compact {
    font-family: monospace;
    font-size: 0.8rem;
}

/* Forms */
.filters {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.form-row {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.form-row .form-group {
    flex: 1;
    min-width: 150px;
}

input[type="text"],
input[type="number"],
input[type="password"],
input[type="date"],
input[type="file"],
select,
.input-sm {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 0.9rem;
}

input:focus, select:focus {
    outline: none;
    border-color: var(--accent);
}

.input-sm {
    padding: 4px 8px;
    font-size: 0.85rem;
}

/* Upload */
.upload-section {
    background: var(--bg-card);
    border-radius: 8px;
    padding: 25px;
    max-width: 600px;
}

/* Edit Row */
.edit-row td {
    background: var(--bg-secondary);
    padding: 15px;
}

.edit-form {
    max-width: 800px;
}

/* Misc */
h1 { margin-bottom: 20px; font-size: 1.5rem; }
h2 { margin: 20px 0 15px; font-size: 1.2rem; }
h3 { font-size: 1rem; }

.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 40px;
    font-size: 0.95rem;
}

.help-text {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin: 10px 0;
}

.info-text {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 15px;
}

code {
    font-family: monospace;
    background: rgba(255, 255, 255, 0.05);
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 0.85rem;
}

/* Login */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

.login-box {
    background: var(--bg-card);
    padding: 40px;
    border-radius: 12px;
    text-align: center;
    width: 320px;
}

.login-box h1 {
    color: var(--accent);
    margin-bottom: 5px;
}

.login-box p {
    color: var(--text-muted);
    margin-bottom: 25px;
}

.login-box input {
    margin-bottom: 15px;
}

.login-box button {
    width: 100%;
}

/* Category Sections */
.category-section {
    margin-bottom: 20px;
}

.category-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-card);
    padding: 12px 18px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
    user-select: none;
}

.category-header:hover {
    background: var(--bg-input);
}

.category-title {
    font-size: 1.05rem;
    font-weight: 600;
}

.category-count {
    color: var(--text-secondary);
    font-weight: 400;
}

.category-stats {
    display: flex;
    gap: 20px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.collapse-icon {
    display: inline-block;
    width: 16px;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-right: 6px;
}

.category-body {
    margin-top: 4px;
}

.edit-meta {
    display: flex;
    gap: 20px;
    margin-bottom: 12px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.est-tag {
    color: var(--orange);
    font-size: 0.75rem;
    margin-left: 2px;
}

/* Product name - allow wrapping instead of truncating */
.product-name {
    min-width: 250px;
    max-width: 400px;
    line-height: 1.3;
}

/* Parent/Child product rows */
.parent-row {
    cursor: pointer;
    background: rgba(74, 158, 255, 0.04);
}

.parent-row:hover {
    background: rgba(74, 158, 255, 0.08) !important;
}

.parent-toggle {
    display: inline-block;
    width: 18px;
    text-align: center;
    font-size: 0.7rem;
    color: var(--accent);
    margin-right: 6px;
}

.variant-count {
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 400;
    margin-left: 4px;
}

.parent-spacer {
    color: var(--text-muted);
    font-style: italic;
    font-size: 0.8rem;
}

.child-row {
    background: rgba(0, 0, 0, 0.12);
}

.child-row:hover {
    background: rgba(0, 0, 0, 0.2) !important;
}

.variant-indent {
    padding-left: 32px !important;
}

.sku-codes {
    margin-top: 2px;
    line-height: 1;
}

.sku-codes code {
    font-size: 0.7rem;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.05);
    padding: 1px 5px;
    border-radius: 3px;
    cursor: pointer;
    user-select: all;
}

.sku-codes code:hover {
    color: var(--accent);
    background: rgba(74, 158, 255, 0.15);
}

/* Bulk Action Bar */
.bulk-bar {
    position: fixed;
    bottom: 0;
    left: 220px;
    right: 0;
    background: var(--bg-secondary);
    border-top: 2px solid var(--accent);
    padding: 12px 30px;
    z-index: 50;
    box-shadow: 0 -4px 12px rgba(0,0,0,0.3);
}

.bulk-bar form {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.bulk-bar label {
    color: var(--text-secondary);
    font-size: 0.85rem;
    white-space: nowrap;
}

.bulk-bar input[type="number"] {
    width: 80px;
    padding: 6px 10px;
}

#bulk-count {
    color: var(--accent);
    font-weight: 600;
    white-space: nowrap;
    min-width: 90px;
}

/* Sync Status Bar */
.sync-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-card);
    border-radius: 8px;
    padding: 12px 18px;
    margin-bottom: 20px;
    border-left: 3px solid var(--green);
    flex-wrap: wrap;
    gap: 10px;
}

.sync-bar.sync-stale {
    border-left-color: var(--orange);
}

.sync-info {
    display: flex;
    gap: 18px;
    flex-wrap: wrap;
    align-items: center;
}

.sync-item {
    font-size: 0.85rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.sync-type {
    font-weight: 600;
    color: var(--text-primary);
    text-transform: capitalize;
}

.sync-age {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.sync-records {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.sync-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Chart Grid */
.chart-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 25px;
}

.chart-container {
    background: var(--bg-card);
    border-radius: 8px;
    padding: 20px;
    min-height: 300px;
}

.chart-container h2 {
    margin: 0 0 15px;
    font-size: 1rem;
}

.chart-container canvas {
    max-height: 280px;
}

/* ACOS colour coding */
.acos-good { color: var(--green); font-weight: 600; }
.acos-warn { color: var(--orange); font-weight: 600; }
.acos-bad { color: var(--red); font-weight: 600; }

/* Search Term Sub-sections */
.st-subsection {
    margin: 4px 0 4px 20px;
}

.st-subheader {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    cursor: pointer;
    border-radius: 4px;
    font-size: 0.9rem;
    font-weight: 600;
    user-select: none;
    transition: background 0.2s;
}

.st-subheader:hover {
    background: rgba(255, 255, 255, 0.04);
}

.st-subheader-top {
    border-left: 3px solid var(--green);
}

.st-subheader-bleeding {
    border-left: 3px solid var(--red);
}

.st-subheader-neutral {
    border-left: 3px solid var(--grey);
}

.st-subheader-products {
    border-left: 3px solid var(--accent);
}

/* Profit/Loss indicators */
.profit-profitable { color: var(--green); font-weight: 600; }
.profit-loss { color: var(--red); font-weight: 600; }
.profit-no-sales { color: var(--text-muted); font-weight: 600; }
.profit-unknown { color: var(--text-secondary); }

.breakeven-warning {
    color: var(--orange);
    font-size: 0.75rem;
    font-weight: 600;
    margin-top: 2px;
}

.est-profit-positive { color: var(--green); font-weight: 600; }
.est-profit-negative { color: var(--red); font-weight: 600; }

/* Module Section Headers */
.module-section {
    margin-bottom: 24px;
}

.module-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    border-radius: 6px;
    margin-bottom: 10px;
    border-left: 4px solid var(--text-muted);
}

.module-header-ppc { border-left-color: var(--blue); background: rgba(33, 150, 243, 0.08); }
.module-header-listings { border-left-color: #ce93d8; background: rgba(156, 39, 176, 0.08); }
.module-header-stock { border-left-color: var(--orange); background: rgba(255, 152, 0, 0.08); }

.module-title {
    font-weight: 700;
    font-size: 0.95rem;
    letter-spacing: 0.5px;
}

.module-header-ppc .module-title { color: var(--blue); }
.module-header-listings .module-title { color: #ce93d8; }
.module-header-stock .module-title { color: var(--orange); }

.module-count {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.module-body {
    display: none;
}

.module-section.expanded .module-body {
    display: block;
}

.section-arrow {
    font-size: 0.65rem;
    color: var(--text-muted);
    transition: transform 0.2s;
}

.module-section:not(.expanded) .section-arrow {
    transform: rotate(-90deg);
}

/* Batch Action Cards */
.batch-card .batch-children {
    display: none;
    margin: 12px 0;
    border-top: 1px solid var(--border);
    padding-top: 12px;
}

.batch-card.expanded .batch-children {
    display: block;
}

.batch-card.expanded .batch-arrow {
    transform: rotate(90deg);
}

.batch-toggle {
    cursor: pointer;
    user-select: none;
}

.batch-arrow {
    display: inline-block;
    font-size: 0.7rem;
    color: var(--accent);
    margin-right: 8px;
    transition: transform 0.2s;
}

.batch-child {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 6px;
    padding: 10px 14px;
    margin-bottom: 8px;
    border-left: 3px solid var(--normal);
}

.batch-child.priority-urgent { border-left-color: var(--urgent); }
.batch-child.priority-high { border-left-color: var(--high); }
.batch-child.priority-normal { border-left-color: var(--normal); }
.batch-child.priority-low { border-left-color: var(--low); }

.child-header {
    display: flex;
    gap: 6px;
    align-items: center;
    margin-bottom: 6px;
}

.child-body strong {
    font-size: 0.9rem;
    display: block;
    margin-bottom: 4px;
}

.child-body .value-change {
    font-size: 0.85rem;
    margin-bottom: 4px;
}

.child-body .reasoning {
    font-size: 0.8rem;
    margin-bottom: 6px;
}

.child-buttons {
    display: flex;
    gap: 6px;
    margin-top: 6px;
}

/* Stock Status Badges */
.status-oos { background: rgba(244, 67, 54, 0.2); color: var(--red); }
.status-low { background: rgba(255, 152, 0, 0.2); color: var(--orange); }
.status-ok { background: rgba(76, 175, 80, 0.2); color: var(--green); }
.status-monitor { background: rgba(255, 224, 178, 0.3); color: #e6a23c; }

/* Stock Detail Row */
.stock-detail-row td {
    padding: 0 !important;
    border-bottom: 1px solid var(--border);
}
.stock-detail {
    padding: 12px 18px;
    background: var(--bg-card);
    border-left: 3px solid var(--accent);
}
.stock-detail-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 8px;
}
.stock-detail-stats {
    display: flex;
    gap: 32px;
}
.stock-detail-stat {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.stock-detail-value {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}
.stock-detail-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
}
.text-red { color: var(--red) !important; }
.text-orange { color: var(--orange) !important; }
.text-green { color: var(--green) !important; }

/* Trend Indicators */
.trend-up { color: var(--green); font-weight: 600; }
.trend-down { color: var(--red); font-weight: 600; }
.trend-stable { color: var(--text-muted); }

/* Totals Row */
.totals-row td {
    background: var(--bg-secondary);
    border-top: 2px solid var(--border);
}

/* Diagnostic Flags */
.flag-row td {
    padding: 4px 12px 8px !important;
    border-bottom: 1px solid var(--border);
    background: rgba(255, 152, 0, 0.06);
}

.flag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 16px;
}

.flag-item {
    font-size: 0.8rem;
    color: var(--orange);
}

.flag-icon {
    color: var(--orange);
    font-size: 0.8rem;
    margin-left: 4px;
    cursor: help;
}

.diagnosis-content {
    padding: 4px 0;
}

.ai-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 6px;
    letter-spacing: 0.5px;
}

.ai-bullet {
    font-size: 0.85rem;
    color: var(--text-primary);
    padding: 3px 0 3px 12px;
    border-left: 2px solid var(--accent);
    margin-bottom: 4px;
    line-height: 1.4;
}

/* Sort Arrow (CSS-driven, no span needed) */
.data-table th[data-sort-dir]::after {
    font-size: 0.65rem;
    color: var(--accent);
    margin-left: 4px;
}
.data-table th[data-sort-dir="asc"]::after { content: " \25B2"; }
.data-table th[data-sort-dir="desc"]::after { content: " \25BC"; }

/* P&L Breakdown Panel (Sellerboard-style) */
.breakdown-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 420px;
    height: 100vh;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border);
    z-index: 200;
    overflow-y: auto;
    box-shadow: -4px 0 20px rgba(0,0,0,0.4);
}

.breakdown-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--bg-secondary);
    z-index: 1;
}

.breakdown-header h2 {
    margin: 0;
    font-size: 1.1rem;
}

.breakdown-body {
    padding: 12px 20px 30px;
}

.bd-rows {
    display: flex;
    flex-direction: column;
}

.bd-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 0.9rem;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}

.bd-row.bd-top {
    font-weight: 500;
}

.bd-row.bd-bold {
    font-weight: 700;
    font-size: 1rem;
}

.bd-row.bd-child {
    padding-left: 20px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.bd-row.bd-metric {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.bd-toggle:hover {
    background: rgba(255,255,255,0.03);
    border-radius: 4px;
}

.bd-positive { color: var(--green); }
.bd-negative { color: var(--red); }

.bd-divider {
    height: 1px;
    background: var(--border);
    margin: 8px 0;
}

.bd-sub {
    border-left: 2px solid var(--border);
    margin-left: 8px;
    margin-bottom: 4px;
}

@media (max-width: 768px) {
    .breakdown-panel {
        width: 100%;
    }
}

/* Date Range Form */
.date-range-form input[type="date"] {
    padding: 4px 8px;
    font-size: 0.85rem;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        position: static;
        width: 100%;
        height: auto;
        flex-direction: row;
        flex-wrap: wrap;
    }

    .sidebar-header {
        border-bottom: none;
        padding: 10px 15px;
    }

    .nav-links {
        display: flex;
        flex-wrap: wrap;
        padding: 0;
    }

    .nav-links li a {
        padding: 8px 12px;
        font-size: 0.85rem;
    }

    .content {
        margin-left: 0;
        padding: 15px;
    }

    .layout {
        flex-direction: column;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .form-row {
        flex-direction: column;
    }

    .data-table {
        font-size: 0.8rem;
    }

    .data-table th,
    .data-table td {
        padding: 6px 8px;
    }

    .bulk-bar {
        left: 0;
    }

    .chart-grid {
        grid-template-columns: 1fr;
    }
}

/* Performance filter separator */
.perf-filter-sep {
    width: 1px;
    height: 24px;
    background: var(--border);
    flex-shrink: 0;
}

/* Override badges */
.badge.override-expected { background: rgba(255, 152, 0, 0.2); color: var(--orange); }
.badge.override-ignore { background: rgba(102, 102, 102, 0.2); color: var(--text-muted); text-decoration: line-through; }

/* Performance actions cell layout */
.perf-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
}

/* Text alignment utilities */
.text-right { text-align: right !important; }
.text-center { text-align: center !important; }
.text-muted { color: var(--text-muted); }
.text-muted-sm { color: var(--text-secondary); font-size: 0.8rem; }
.text-accent { color: var(--accent); }

/* Text truncation for long content in table cells */
.text-truncate {
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Inline flex row utility */
.row-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    flex-wrap: wrap;
    align-items: center;
}

/* Kill Switch Banner */
.kill-switch-banner {
    background: var(--red);
    color: #fff;
    padding: 12px 20px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.kill-switch-banner .btn {
    background: #fff;
    color: var(--red);
    border: none;
    font-weight: bold;
}

/* Kill Switch Stat Card States */
.stat-card.kill-switch-on {
    border: 2px solid var(--red);
    background: rgba(244, 67, 54, 0.15);
}

.stat-card.kill-switch-on .stat-number,
.stat-card.kill-switch-on .stat-number-sm {
    color: var(--red);
}

.stat-card.kill-switch-off {
    border: 2px solid var(--green);
    background: rgba(76, 175, 80, 0.08);
}

.stat-card.kill-switch-off .stat-number,
.stat-card.kill-switch-off .stat-number-sm {
    color: var(--green);
}

/* Admin Status Page */
.status-section { margin-bottom: 32px; }
.status-section h2 { margin-bottom: 16px; }
.status-section h3 { margin: 16px 0 8px; color: var(--text-secondary); }

.status-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; margin-bottom: 20px; }
.status-card { background: var(--bg-card); border-radius: 8px; padding: 20px; border-left: 4px solid var(--border); }
.status-card.status-danger { border-left-color: var(--red); }
.status-card.status-ok { border-left-color: var(--green); }
.status-indicator { font-size: 1.5rem; font-weight: bold; }
.status-card.status-danger .status-indicator { color: var(--red); }
.status-card.status-ok .status-indicator { color: var(--green); }
.status-label { color: var(--text-secondary); margin-top: 4px; }
.status-detail { color: var(--text-muted); font-size: 0.85rem; margin-top: 8px; }

.badge-danger { background: var(--red); color: #fff; }
.badge-ok { background: var(--green); color: #fff; }
.badge-warning { background: var(--orange); color: #fff; }
.badge-info { background: rgba(74, 158, 255, 0.2); color: var(--accent); }

.progress-bar-container {
    position: relative; background: var(--bg-input); border-radius: 8px;
    height: 32px; overflow: hidden; margin: 8px 0;
}
.progress-bar { height: 100%; border-radius: 8px; transition: width 0.3s; }
.progress-ok { background: var(--green); }
.progress-warning { background: var(--orange); }
.progress-danger { background: var(--red); }
.progress-label {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    font-weight: bold; text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

/* Verification Status Badges */
.verified-badge {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    white-space: nowrap;
}

.verified-yes {
    background: rgba(76, 175, 80, 0.2);
    color: var(--green);
}

.verified-no {
    background: rgba(244, 67, 54, 0.2);
    color: var(--red);
    cursor: help;
}

.verified-pending {
    background: transparent;
    color: var(--text-muted);
}
