:root {
    --bg-color: #fbfbfd;
    --card-bg: #ffffff;
    --text-primary: #1d1d1f;
    --text-sec: #86868b;
    --track-bg: #e5e5ea;
    --tick-color: #d1d1d6;
    --btn-blue: #0071e3;
    --btn-blue-hover: #0077ED;
}

body.dark-mode {
    --bg-color: #000000;
    --card-bg: #1c1c1e;
    --text-primary: #f5f5f7;
    --text-sec: #98989d;
    --track-bg: #38383a;
    --tick-color: #48484a;
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    -webkit-font-smoothing: antialiased;
    display: flex;
    justify-content: center;
    align-items: center; 
    height: 100vh;
    overflow: hidden; 
    padding: 20px;
}

.apple-layout {
    width: 100%;
    max-width: 1000px;
    height: 100%;
    max-height: 800px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 40px;
}

/* ================== TOP SPLIT ================== */
.top-row {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: stretch;
    width: 100%;
    gap: 40px;
}

.hero-left {
    width: 50%;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.hero-left h1 {
    font-size: 52px;
    font-weight: 800;
    letter-spacing: -0.02em;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.hero-left p {
    font-size: 20px;
    font-weight: 400;
    color: var(--text-sec);
    margin-bottom: 40px;
}

.metrics-panel {
    display: flex;
    gap: 40px;
}

.metric-box {
    display: flex;
    flex-direction: column;
}

.metric-val {
    font-size: 42px;
    font-weight: 700;
    color: var(--btn-blue);
    letter-spacing: -2px;
    margin-bottom: 2px;
}

.metric-lbl {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-sec);
    letter-spacing: 1px;
}

/* Form Right Side */
.form-right {
    width: 50%;
    display: flex;
    align-items: center;
}

.input-card {
    background: var(--card-bg);
    border-radius: 24px;
    padding: 30px;
    width: 100%;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.04), 0 1px 3px rgba(0,0,0,0.02);
    border: 1px solid rgba(0,0,0,0.02);
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.status-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}

.badge {
    padding: 6px 14px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.3s;
}

.badge.default { background: #f2f2f7; color: var(--text-sec); }
.badge.passed { background: #e3f8e9; color: #1e8e3e; }
.badge.failed { background: #fce8e6; color: #d93025; }

.error-text {
    color: #d93025;
    font-size: 13px;
    font-weight: 500;
}

form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

textarea {
    width: 100%;
    height: 110px; 
    background: #fbfbfd;
    border: 1px solid #d1d1d6;
    border-radius: 12px;
    padding: 15px;
    font-family: inherit;
    font-size: 16px;
    color: var(--text-primary);
    line-height: 1.5;
    resize: none;
    outline: none;
    transition: all 0.2s;
}

textarea:focus {
    border-color: var(--btn-blue);
    background: #fff;
    box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.1);
}

.form-actions {
    display: flex;
    justify-content: flex-end;
}

.apple-btn {
    background: var(--btn-blue);
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 14px 28px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    justify-content: center;
    align-items: center;
}

.apple-btn:hover { background: var(--btn-blue-hover); }
.apple-btn:active { transform: scale(0.98); }
.apple-btn:disabled { background: #a1c6ea; cursor: not-allowed; }

/* ================== BOTTOM ROW ================== */
.gauges-container {
    display: flex;
    flex-direction: row;
    gap: 30px;
    width: 100%;
    justify-content: center;
    align-items: stretch;
    flex-grow: 1;
    min-height: 0;
}

.gauge-card {
    background: var(--card-bg);
    border-radius: 20px;
    padding: 25px 30px;
    width: 50%;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.03), 0 1px 3px rgba(0,0,0,0.02);
    border: 1px solid rgba(0,0,0,0.02);
    display: flex;
    flex-direction: column;
}

.gauge-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 5px;
}

.card-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-sec);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.readout-digital {
    font-size: 36px;
    font-weight: 700;
    letter-spacing: -1px;
    color: var(--text-primary);
    line-height: 1;
}

.gauge-wrapper {
    position: relative;
    width: 100%;
    height: 100%; 
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.minimal-speedometer {
    width: auto;
    height: 100%; 
    max-height: 200px;
    overflow: visible;
}

.track-bg { fill: none; stroke: var(--track-bg); stroke-width: 8; stroke-linecap: round; }
.tick-marks { fill: none; stroke: #ffffff; stroke-width: 10; stroke-dasharray: 2 35.69; }

.track-fill {
    fill: none;
    stroke-width: 8;
    stroke-linecap: round;
    stroke-dasharray: 376.99;
    stroke-dashoffset: 376.99;
    transition: stroke-dashoffset 1.5s cubic-bezier(0.2, 1, 0.3, 1);
}

.needle-group {
    transform-origin: 100px 100px; 
    transform: rotate(-135deg);
    transition: transform 1.5s cubic-bezier(0.2, 1, 0.3, 1);
}

.calibration-labels {
    width: 100%;
    max-width: 300px; 
    display: flex;
    justify-content: space-between;
    margin-top: 10px;
    font-size: 12px;
    color: var(--text-sec);
    font-weight: 500;
}

/* =========================================
   MOBILE RESPONSIVENESS
========================================= */
@media (max-width: 800px) {
    body {
        height: auto;
        overflow-y: auto;
        padding: 30px 20px;
    }
    
    .apple-layout {
        max-height: none;
    }
    
    .top-row {
        flex-direction: column;
    }
    
    .hero-left, .form-right {
        width: 100%;
    }
    
    .hero-left { text-align: center; align-items: center; }
    
    .gauges-container {
        flex-direction: column;
    }

    .gauge-card {
        width: 100%;
    }
}

/* Theme Toggle Button */
.theme-toggle-btn {
    position: fixed;
    top: 25px;
    right: 25px;
    background: var(--card-bg);
    border: 1px solid rgba(0,0,0,0.05);
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    color: var(--text-primary);
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    transition: all 0.3s;
    z-index: 100;
}

body.dark-mode .theme-toggle-btn {
    border: 1px solid rgba(255,255,255,0.05);
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

.theme-toggle-btn:hover {
    transform: scale(1.05);
}

.theme-toggle-btn svg {
    width: 20px;
    height: 20px;
}

/* Hard CSS injection to strip hardcoded SVG colors to inherit dynamic theme variables properly */
.needle-group line { stroke: var(--text-primary) !important; }
.needle-group circle:first-of-type { fill: var(--text-primary) !important; }
.needle-group circle:last-of-type { fill: var(--card-bg) !important; }

body.dark-mode textarea {
    background: #2c2c2e;
    border-color: #38383a;
}
body.dark-mode .badge.default {
    background: #2c2c2e;
}
