/* Pure Monochrome (Strict Black & White) Theme System */

:root[data-theme="dark"] {
    --bg-page: #000000;
    --bg-card: #0a0a0a;
    --bg-input: #121212;
    --border-color: #262626;
    --border-active: #ffffff;
    
    --text-primary: #ffffff;
    --text-secondary: #a3a3a3;
    --text-muted: #737373;

    --badge-bg: #ffffff;
    --badge-text: #000000;
    
    --btn-primary-bg: #ffffff;
    --btn-primary-text: #000000;

    --chart-line: #ffffff;
    --chart-fill: rgba(255, 255, 255, 0.05);
    --chart-bar: #ffffff;
    --chart-grid: #262626;
}

:root[data-theme="light"] {
    --bg-page: #ffffff;
    --bg-card: #fafafa;
    --bg-input: #f5f5f5;
    --border-color: #e5e5e5;
    --border-active: #000000;
    
    --text-primary: #000000;
    --text-secondary: #525252;
    --text-muted: #a3a3a3;

    --badge-bg: #000000;
    --badge-text: #ffffff;

    --btn-primary-bg: #000000;
    --btn-primary-text: #ffffff;

    --chart-line: #000000;
    --chart-fill: rgba(0, 0, 0, 0.04);
    --chart-bar: #000000;
    --chart-grid: #e5e5e5;
}

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

html, body {
    height: 100%;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-page);
    color: var(--text-primary);
    transition: background-color 0.15s ease, color 0.15s ease;
}

/* App Layout - Single Screen 100vh on Desktop */
.app-layout {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    padding: 0.75rem 1rem;
    gap: 0.75rem;
}

@media (max-width: 768px) {
    .app-layout {
        height: auto;
        min-height: 100vh;
        overflow: auto;
    }
}

/* Top Bar */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.75rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    flex-shrink: 0;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.brand-title {
    font-size: 1.05rem;
    font-weight: 700;
}

.formula-tag {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    background: var(--bg-input);
    color: var(--text-primary);
    padding: 0.2rem 0.5rem;
    border-radius: 3px;
    border: 1px solid var(--border-color);
}

.btn-icon {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.35rem 0.75rem;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-icon:hover {
    border-color: var(--border-active);
}

/* Dashboard Container */
.dashboard-container {
    display: grid;
    grid-template-columns: 310px 1fr;
    gap: 0.75rem;
    flex: 1;
    min-height: 0;
}

@media (max-width: 768px) {
    .dashboard-container {
        grid-template-columns: 1fr;
    }
}

/* Sidebar & Main Panels */
.sidebar-panel, .main-panel {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-height: 0;
}

.panel-box {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.box-title {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Presets & Inputs */
.preset-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.35rem;
}

.btn-chip {
    padding: 0.35rem 0.4rem;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 3px;
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-chip.active, .btn-chip:hover {
    background: var(--btn-primary-bg);
    color: var(--btn-primary-text);
    border-color: var(--border-active);
    font-weight: 600;
}

.inputs-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0.4rem;
}

.inputs-row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.4rem;
}

.input-field label {
    display: block;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.2rem;
}

input[type="number"], select {
    width: 100%;
    padding: 0.35rem 0.5rem;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 3px;
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    outline: none;
}

input[type="number"]:focus, select:focus {
    border-color: var(--border-active);
}

.btn-action {
    background: var(--btn-primary-bg);
    color: var(--btn-primary-text);
    border: 1px solid var(--border-active);
    padding: 0.55rem;
    border-radius: 4px;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    transition: opacity 0.15s ease;
}

.btn-action:hover {
    opacity: 0.85;
}

/* Stats Box */
.stats-box {
    flex: 1;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.3rem 0;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.8rem;
}

.stat-row:last-child {
    border-bottom: none;
}

.stat-lbl {
    color: var(--text-secondary);
}

.stat-val {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 600;
}

.badge {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.15rem 0.5rem;
    border-radius: 2px;
    text-transform: uppercase;
    background: var(--badge-bg);
    color: var(--badge-text);
    border: 1px solid var(--text-primary);
}

.badge-fail {
    background: transparent;
    color: var(--text-primary);
    border: 1px dashed var(--text-primary);
}

.badge-info {
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

/* Main Panel Right */
.chart-box {
    flex: 1;
    min-height: 0;
}

.chart-header {
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.4rem;
}

.tab-selectors {
    display: flex;
    gap: 0.5rem;
}

.tab-link {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.2rem 0.4rem;
    cursor: pointer;
}

.tab-link.active {
    color: var(--text-primary);
    border-bottom: 2px solid var(--text-primary);
}

.chart-wrapper {
    flex: 1;
    position: relative;
    min-height: 0;
    height: 100%;
}

.tab-pane {
    display: none;
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
}

.tab-pane.active {
    display: block;
}

/* Table Box */
.table-box {
    height: 190px;
    flex-shrink: 0;
}

.table-container {
    flex: 1;
    overflow-y: auto;
}

.simple-table {
    width: 100%;
    border-collapse: collapse;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
}

.simple-table th, .simple-table td {
    padding: 0.35rem 0.5rem;
    text-align: left;
}

.simple-table th {
    position: sticky;
    top: 0;
    background: var(--bg-card);
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
    font-weight: 700;
}

.simple-table td {
    border-bottom: 1px solid var(--border-color);
}

.simple-table td:nth-child(4) {
    color: var(--text-primary);
    font-weight: 700;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 4px;
    height: 4px;
}
::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 2px;
}
