:root {
    --bg-color: #000000;
    --panel-bg: #111111;
    --text-primary: #f5f5f7;
    --text-secondary: #86868b;
    --border: #333336;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

header {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 15px 40px;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    z-index: 10;
}
.header-left { justify-self: start; }
.header-center { justify-self: center; text-align: center; }
.header-right { justify-self: end; }

.header-content h1 { font-size: 20px; font-weight: 600; letter-spacing: -0.5px; }
.subtitle { color: var(--text-secondary); font-size: 12px; margin-top: 4px; }
.creator { color: var(--text-secondary); font-size: 10px; margin-top: 2px; }

.user-meta { display: flex; align-items: center; gap: 10px; }
.user-meta label { font-size: 13px; color: var(--text-secondary); }
.user-meta input {
    background: rgba(255,255,255,0.1); border: 1px solid var(--border);
    color: white; padding: 6px 12px; border-radius: 6px; font-size: 13px;
}

.header-actions { display: flex; gap: 12px; }

.btn-action {
    display: flex; align-items: center; gap: 8px;
    background: var(--text-primary); color: var(--bg-color);
    padding: 8px 16px; border-radius: 20px; text-decoration: none;
    font-size: 13px; font-weight: 500; border: none; cursor: pointer;
    transition: transform 0.2s, opacity 0.2s;
}
.btn-action:hover { opacity: 0.9; transform: scale(1.02); }
.btn-pdf { background: #1c1c1e; color: #fff; border: 1px solid var(--border); }

.container { display: flex; flex-direction: row-reverse; flex: 1; overflow: hidden; }

/* Left Panel - Inputs */
.panel-left {
    min-width: 480px; width: 45%; max-width: 750px;
    background: var(--panel-bg); border-right: 1px solid var(--border);
    display: flex; flex-direction: column; overflow-y: auto; overflow-x: hidden;
}

.panel-left::-webkit-scrollbar { width: 8px; }
.panel-left::-webkit-scrollbar-track { background: transparent; }
.panel-left::-webkit-scrollbar-thumb { background: #444; border-radius: 4px; }

.inputs-header { padding: 30px 30px 15px; border-bottom: 1px solid var(--border); }
.header-top { display: flex; justify-content: space-between; align-items: flex-start; }
.inputs-header h2 { font-size: 20px; margin-bottom: 8px; }
.inputs-header p { font-size: 12px; color: var(--text-secondary); line-height: 1.4; max-width: 250px; }

.btn-add {
    display: flex; align-items: center; gap: 6px;
    background: rgba(255,255,255,0.1); color: var(--text-primary);
    border: none; padding: 6px 12px; border-radius: 12px;
    font-size: 12px; cursor: pointer; transition: 0.2s;
}
.btn-add:hover { background: rgba(255,255,255,0.2); }

#lcc-form { padding: 0 30px 30px; }

.machine-headers-row {
    display: flex; margin-left: 200px; margin-bottom: 20px; padding-top: 15px;
    gap: 12px; position: sticky; top: 0; background: var(--panel-bg); z-index: 5; padding-bottom: 10px;
}
.machine-header-wrapper {
    flex: 1; position: relative; display: flex; flex-direction: column; min-width: 100px;
}
.machine-header-input {
    width: 100%; background: rgba(0,0,0,0.2); border: 1px solid var(--border);
    color: white; padding: 8px; border-radius: 6px; font-size: 13px; font-weight: 600; text-align: center;
}
.btn-delete-machine {
    position: absolute; top: -8px; right: -8px; background: #ff3b30; color: white;
    border: none; border-radius: 50%; width: 20px; height: 20px; font-size: 14px;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    opacity: 0; transition: opacity 0.2s; z-index: 2;
}
.machine-header-wrapper:hover .btn-delete-machine { opacity: 1; }


.input-group h3 {
    font-size: 13px; text-transform: uppercase; letter-spacing: 1px;
    color: var(--text-secondary); margin-bottom: 16px; border-bottom: 1px solid var(--border); padding-bottom: 8px;
}

.input-row { display: flex; align-items: center; margin-bottom: 12px; }
.input-row label {
    width: 200px; font-size: 12px; color: #ccc; flex-shrink: 0; padding-right: 15px; line-height: 1.3;
}
.input-row label.has-diff { color: #f5f5f7; font-weight: 600; }
.input-row label.has-diff::before { content: '• '; color: #ff9f0a; }

.input-cols { display: flex; flex: 1; gap: 12px; }

.input-wrapper {
    flex: 1; display: flex; align-items: center; border-radius: 6px; min-width: 100px;
    overflow: hidden; border: 1px solid transparent;
}
.input-wrapper input {
    flex: 1; width: 100%; background: transparent; border: none; color: white;
    padding: 6px 0; font-size: 13px; text-align: center; min-width: 0;
}
.input-wrapper input:focus { outline: none; }
.input-wrapper input::-webkit-outer-spin-button, .input-wrapper input::-webkit-inner-spin-button {
  -webkit-appearance: none; margin: 0;
}

.spin-btn {
    background: rgba(255,255,255,0.05); border: none; color: #888;
    padding: 6px 8px; cursor: pointer; font-size: 14px; display: flex; align-items: center; justify-content: center;
}
.spin-btn:hover { background: rgba(255,255,255,0.15); color: white; }

/* Right Panel - Charts */
.panel-right {
    flex: 1; display: flex; flex-direction: column; padding: 30px; gap: 30px; overflow-y: auto;
    background: radial-gradient(circle at center, #1a1a1a 0%, #000 100%);
}

.chart-container { background: var(--panel-bg); border: 1px solid var(--border); border-radius: 16px; padding: 24px; margin-bottom: 24px; }
.chart-container h2 { font-size: 16px; margin-bottom: 16px; }
.canvas-wrapper { flex: 1; position: relative; width: 100%; height: 100%; }
canvas { position: absolute; left: 0; top: 0; width: 100% !important; height: 100% !important; }

.summary-cards { display: flex; gap: 20px; }
.card { flex: 1; background: rgba(255, 255, 255, 0.03); border: 1px solid var(--border); border-radius: 16px; padding: 24px; }
.card h3 { font-size: 14px; color: var(--text-secondary); margin-bottom: 16px; }
.card-values { display: flex; flex-direction: column; }
.machine-value { display: flex; flex-direction: column; margin-bottom: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.machine-value:last-child { margin-bottom: 0; padding-bottom: 0; border-bottom: none; }
.machine-value .label { font-size: 13px; margin-bottom: 6px; font-weight: 500; color: var(--text-secondary); }
.machine-value .value { font-size: 20px; font-weight: 600; letter-spacing: -0.5px; }

.text-red { color: #ff3b30 !important; }
.text-green { color: #34c759 !important; }

/* App Footer */
.app-footer {
    display: flex; justify-content: center; gap: 20px; padding: 10px;
    background: #050505; border-top: 1px solid var(--border);
    font-size: 11px; z-index: 10;
}
.app-footer a { color: var(--text-secondary); text-decoration: none; transition: color 0.2s; }
.app-footer a:hover { color: var(--text-primary); }

/* Print Elements (Hidden on Screen) */
.print-header, .print-footer { display: none; }

/* Print Layout */

/* Mobile Responsiveness */
@media (max-width: 900px) {
    header {
        flex-direction: column;
        align-items: stretch;
        padding: 15px;
        gap: 15px;
    }
    .header-left { display: grid; grid-template-columns: 1fr; gap: 5px; }
    .header-left input { width: 100% !important; }
    .header-center h1 { font-size: 22px !important; }
    
    .container { flex-direction: column; overflow-y: auto; }
    .panel-right, .panel-left {
        width: 100%; min-width: 0; max-width: none; height: auto; flex: none; overflow: visible;
    }
    
    .panel-right { padding: 15px; gap: 15px; }
    .summary-cards { flex-direction: column; gap: 15px; }
    
    .chart-container { padding: 15px; }
    .chart-container h2 { font-size: 14px; }
    .canvas-wrapper { height: 300px; } /* Fixed height on mobile for chart */
    
    .panel-left { border-right: none; border-top: 1px solid var(--border); padding-bottom: 50px; }
    .inputs-header { padding: 15px; }
    .inputs-header h2 { font-size: 18px; }
    
    #lcc-form { padding: 15px; overflow-x: auto; }
    
    /* Make the input rows horizontally scrollable if too many machines */
    .input-row { flex-wrap: wrap; }
    .input-row label { width: 100%; margin-bottom: 5px; }
    .input-cols { width: 100%; justify-content: flex-start; }
    
    .machine-headers-row { padding: 15px 15px 0 15px; justify-content: flex-start; }
    .machine-header-wrapper { flex: 1; }
    
    .input-group { width: 100%; }
}

@media print {

    @page { margin: 10mm; size: portrait; }
    
    html, body { 
        background: #fff !important; color: #000 !important; 
        overflow: visible !important; height: auto !important; 
        display: block !important; font-size: 9pt !important; 
        position: static !important;
    }
    
    header, .app-footer, .inputs-header, .spin-btn { display: none !important; }
    
    .print-header {
        position: static !important;
        display: flex; justify-content: space-between; align-items: flex-end;
        border-bottom: 2px solid #000; padding-bottom: 3mm; width: 100%;
    }
    .print-header-left { flex: 1; }
    .print-header-right { flex: 0 0 auto; text-align: right; font-size: 9pt; color: #000; }
    .print-header h2 { font-size: 11pt; margin: 0; line-height: 1.2; color: #000; }

    .container { display: none !important; }
    #print-view { display: block !important; width: 100%; }
    
    
    
    .print-page {
        position: relative;
        box-sizing: border-box;
    }
/* Page 1: Charts */
    .panel-right {
        
        
    }
    .summary-cards { display: flex; gap: 10mm; margin-bottom: 5mm !important; }
    .card { flex: 1; background: #fafafa !important; border: 1px solid #ddd; padding: 2mm !important; border-radius: 4px; }
    .card h3 { color: #000; font-weight: bold; margin-top: 0; margin-bottom: 2mm; font-size: 10pt; }
    .machine-value { border-bottom: 1px solid #ddd; padding-bottom: 1mm; margin-bottom: 1mm; }
    .machine-value:last-child { border: none; padding-bottom: 0; margin-bottom: 0; }
    .machine-value .label { color: #555; font-size: 8pt; margin-bottom: 1px; }
    .machine-value .value { font-size: 11pt; }
    
    .chart-container { height: 180mm !important; padding: 2mm !important; margin-bottom: 0 !important; overflow: hidden !important; background: none !important; border: none !important; }
    .chart-container h2 { color: #000; font-weight: bold; margin-bottom: 3mm; font-size: 11pt; }
    
    /* Page 2: Parameters */
    #lcc-form { padding: 0 !important; margin: 0 !important; }

    
    #form-container {
        display: flex;
        flex-wrap: wrap;
        justify-content: space-between;
        align-content: flex-start !important;
        row-gap: 3mm !important;
    }
    .input-group {
        width: 100% !important;
        box-sizing: border-box;
        break-inside: avoid;
        page-break-inside: avoid;
        margin-bottom: 2mm !important; 
        border: 1px solid #eee !important; 
        padding: 2mm !important; 
        border-radius: 4px !important; 
        background: #fafafa !important; 
    }
    .input-group h3 { font-size: 8pt; margin-bottom: 1mm; border-bottom: 1px solid #ddd; padding-bottom: 1mm; margin-top: 0; color: #000; }
    .input-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0 !important; font-size: 7pt; }
    .input-wrapper input { font-size: 7pt; }
    
    
    .machine-headers-row { display: none !important; }
    
    .print-mini-header {
        display: flex !important; justify-content: flex-end; gap: 5mm; 
        margin-left: 0 !important; margin-bottom: 2mm; border-bottom: 1px solid #ccc; padding-bottom: 1mm; width: 100%;
        background: none !important; position: static !important; box-sizing: border-box;
    }
    .print-mini-header .machine-header-wrapper { min-width: 0; flex: 0 0 auto; width: 30mm; }
    .print-mini-header input { 
        background: none !important; border: none !important; color: #000 !important; 
        font-weight: bold; font-size: 8pt; padding: 0; text-align: right; width: 100%; 
    }
    .print-mini-header .btn-delete-machine { display: none !important; }

    
    
    
    .print-mini-header input { 
        background: none !important; border: none !important; color: #000 !important; 
        font-weight: bold; font-size: 8pt; padding: 0; text-align: right; width: 100%; 
    }
    




    
    
    .input-group h3 { font-size: 9pt; border-bottom: 1px solid #ddd; padding-bottom: 1mm; margin-bottom: 3mm; color: #000; margin-top: 0; }
    
    .input-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1mm; font-size: 8pt; }
    .input-row label { color: #000; width: auto; }
    .has-diff::before { display: none !important; }
    
    .input-cols { display: flex; gap: 5mm; justify-content: flex-end; flex: 0 0 auto !important; }
    .input-row label { flex: 1; }
    .input-wrapper { border: none !important; background: none !important; padding: 0; flex: 0 0 auto; width: 30mm; display: flex; justify-content: flex-end; }
    .input-wrapper input { border: none; background: none; font-size: 8pt; text-align: right; width: 100%; padding: 0; color: #000 !important; font-weight: 500; }
}
