:root {
    --sc-bg: #0a0a0a;
    --sc-panel: #151515;
    --sc-text: #e0e0e0;
    --sc-label: #888888;
    --sc-red: #d5001c;
    --sc-green: #9fb200;
    --sc-blue: #004c97;
    --sc-amber: #ffb020;
    --sc-border: #333333;
    --brand-accent: #9fb200;
    --rpmcol: #9fb200;
}

.scania-digital[data-mode="day"] {
    --sc-bg: #e8ecf0;
    --sc-panel: #f4f6f8;
    --sc-text: #1a1a1a;
    --sc-label: #5a6470;
    --sc-border: #c5cdd6;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    background: #000;
    color: var(--sc-text);
    font-family: "Rajdhani", "Segoe UI", sans-serif;
    overflow: hidden;
}

.dashboard.scania-digital {
    width: 100%;
    height: 100%;
    background: var(--sc-bg);
    position: relative;
    display: flex;
    flex-direction: column;
    transition: background .25s ease;
}

.statusMessage {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: 0.5em;
    color: var(--sc-red);
}
.statusMessage:empty { display: none; }

/* Edge glow */
.edge-glow {
    position: fixed;
    top: 0;
    bottom: 0;
    width: 22vw;
    max-width: 300px;
    z-index: 15;
    pointer-events: none;
    opacity: 0;
}
.edge-glow.left {
    left: 0;
    background: radial-gradient(circle at 0% 50%, rgba(159, 178, 0, .65) 0%, rgba(159, 178, 0, .2) 40%, transparent 70%);
}
.edge-glow.right {
    right: 0;
    background: radial-gradient(circle at 100% 50%, rgba(159, 178, 0, .65) 0%, rgba(159, 178, 0, .2) 40%, transparent 70%);
}
.edge-glow.on { animation: sc-blink .9s steps(1, end) infinite; }
@keyframes sc-blink {
    0%, 49% { opacity: 1; }
    50%, 100% { opacity: 0; }
}

.sc-cluster {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: clamp(6px, 1vh, 12px) clamp(10px, 2vw, 20px);
    min-height: 0;
}

/* --- Top strip --- */
.sc-top-strip {
    flex: 0 0 auto;
    height: clamp(52px, 12vh, 88px);
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: clamp(6px, 1.5vw, 16px);
    border-bottom: 2px solid var(--sc-border);
    margin-bottom: 0.5vh;
    padding: 0 clamp(4px, 1vw, 12px);
    min-width: 0;
}

.sc-top-left,
.sc-top-right {
    display: flex;
    align-items: center;
    gap: clamp(6px, 1.2vw, 14px);
    min-width: 0;
}
.sc-top-left { justify-self: start; }
.sc-top-right { justify-self: end; flex-wrap: nowrap; }

.sc-adblue-wrap {
    flex: 0 1 auto;
    min-width: 0;
    margin-right: clamp(4px, 1vw, 10px);
}
.sc-theme-btns {
    flex: 0 0 auto;
    display: inline-flex;
    gap: clamp(2px, 0.5vw, 4px);
}

.sc-brand {
    justify-self: center;
    text-align: center;
    flex: 0 0 auto;
}
.sc-brand-text {
    font-size: clamp(1.1rem, 3vh, 1.75rem);
    font-weight: 800;
    letter-spacing: 0.28em;
    color: var(--sc-text);
    line-height: 1;
}

.sc-fuel-wrap, .sc-adblue-wrap, .sc-range-group, .sc-clock-group {
    display: flex;
    align-items: center;
    gap: clamp(4px, 0.8vw, 10px);
    min-width: 0;
}

.sc-fuel-icon, .sc-adblue-icon {
    width: clamp(18px, 3vh, 26px);
    height: clamp(18px, 3vh, 26px);
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.sc-fuel-icon svg, .sc-adblue-icon svg { width: 100%; height: 100%; }
.sc-fuel-icon.low { color: var(--sc-red); }
.sc-fuel-icon.warn { color: var(--sc-amber); }
.sc-fuel-icon.ok { color: var(--sc-green); }
.sc-adblue-icon { color: var(--sc-blue); }

.sc-fuel-bars {
    display: flex;
    gap: 2px;
    align-items: stretch;
    height: clamp(8px, 1.6vh, 14px);
}
.fuel-unit {
    width: clamp(5px, 0.9vw, 10px);
    border-radius: 2px;
    background: #222;
    opacity: 0.35;
    transition: opacity .15s, background .15s;
}
.fuel-unit.on { opacity: 1; }
.fuel-unit.on.red { background: var(--sc-red); box-shadow: 0 0 6px var(--sc-red); }
.fuel-unit.on.amber { background: var(--sc-amber); box-shadow: 0 0 6px var(--sc-amber); }
.fuel-unit.on.green { background: var(--sc-green); box-shadow: 0 0 6px var(--sc-green); }

.sc-label {
    font-size: clamp(0.55rem, 1.4vh, 0.75rem);
    color: var(--sc-label);
    font-weight: 700;
    letter-spacing: 0.12em;
}

.sc-val {
    font-size: clamp(1rem, 2.8vh, 2rem);
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.sc-unit {
    font-size: clamp(0.6rem, 1.6vh, 1rem);
    color: var(--sc-label);
    font-weight: 600;
}

.sc-theme-btn {
    border: 1px solid var(--sc-border);
    background: var(--sc-panel);
    color: var(--sc-text);
    border-radius: 6px;
    padding: 6px 8px;
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
}
.sc-theme-btn:active { transform: scale(.94); }

/* --- Middle --- */
.sc-middle {
    flex: 1;
    display: flex;
    gap: clamp(8px, 1.5vw, 20px);
    align-items: stretch;
    min-height: 0;
}

.sc-gauge-bar {
    width: clamp(80px, 11vw, 150px);
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    cursor: pointer;
}

.sc-bar-labels {
    position: absolute;
    left: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    font-size: clamp(0.7rem, 1.8vh, 1.2rem);
    color: var(--sc-label);
    font-weight: 700;
    padding: 0.5vh 0;
    z-index: 2;
}

.sc-vertical-bar-bg {
    width: clamp(24px, 3.5vw, 56px);
    flex: 1;
    min-height: 80px;
    background: #111;
    border-radius: 6px;
    position: relative;
    overflow: hidden;
    margin-left: 2.5vw;
    border: 1px solid #222;
}

.sc-vertical-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 0%;
    transition: height 0.1s linear;
}
.speed-bar .sc-vertical-bar {
    background: linear-gradient(to top, var(--sc-green) 55%, var(--sc-amber) 78%, var(--sc-red) 95%);
    box-shadow: 0 0 16px rgba(159, 178, 0, 0.25);
    transition: height 0.1s linear, background 0.2s ease, box-shadow 0.2s ease;
}
.speed-bar .sc-vertical-bar.zone-ok,
.speed-bar.speed-ok .sc-vertical-bar {
    background: linear-gradient(to top, var(--sc-green), #c4d400);
    box-shadow: 0 0 16px rgba(159, 178, 0, 0.35);
}
.speed-bar .sc-vertical-bar.zone-warn,
.speed-bar.speed-warn .sc-vertical-bar {
    background: linear-gradient(to top, var(--sc-amber), #ffc84a);
    box-shadow: 0 0 16px rgba(255, 176, 32, 0.35);
}
.speed-bar .sc-vertical-bar.zone-over,
.speed-bar.speed-over .sc-vertical-bar {
    background: linear-gradient(to top, var(--sc-red), #ff4a5a);
    box-shadow: 0 0 18px rgba(213, 0, 28, 0.45);
}
.speed-bar .sc-gauge-big.zone-ok { color: var(--sc-green); }
.speed-bar .sc-gauge-big.zone-warn { color: var(--sc-amber); }
.speed-bar .sc-gauge-big.zone-over { color: var(--sc-red); }
.rpm-bar .sc-vertical-bar.zone-green {
    background: linear-gradient(to top, var(--sc-green), #c4d400);
    box-shadow: 0 0 16px rgba(159, 178, 0, 0.35);
}
.rpm-bar .sc-vertical-bar.zone-amber {
    background: linear-gradient(to top, var(--sc-amber), #ffc84a);
    box-shadow: 0 0 16px rgba(255, 176, 32, 0.35);
}
.rpm-bar .sc-vertical-bar.zone-red {
    background: linear-gradient(to top, var(--sc-red), #ff4a5a);
    box-shadow: 0 0 16px rgba(213, 0, 28, 0.35);
}
.rpm-bar .sc-vertical-bar.zone-white {
    background: linear-gradient(to top, #ccc, #fff);
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.45);
}

.sc-gauge-big {
    font-size: clamp(1.4rem, 4vh, 2.8rem);
    font-weight: 900;
    margin-top: 6px;
    line-height: 1;
}
.sc-gauge-unit {
    margin-top: 4px;
    font-size: clamp(0.55rem, 1.4vh, 0.75rem);
    color: var(--sc-label);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.sc-rpm-readout {
    text-align: center;
    margin-top: 6px;
    line-height: 1.1;
}
.sc-trans {
    display: block;
    font-size: clamp(0.55rem, 1.3vh, 0.7rem);
    color: var(--sc-label);
    font-weight: 800;
    letter-spacing: 0.1em;
}
.sc-trans.auto { color: var(--sc-blue); }
.sc-gear {
    display: block;
    font-size: clamp(1.8rem, 5vh, 3.5rem);
    font-weight: 900;
    color: #fff;
    text-shadow: 0 0 12px rgba(255,255,255,0.2);
}
.sc-rpm-num {
    display: block;
    font-size: clamp(0.7rem, 1.6vh, 0.9rem);
    color: var(--rpmcol);
    font-weight: 800;
}

/* --- Display --- */
.sc-display-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
}

.sc-screen-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 4px 8px;
    flex: 0 0 auto;
}

.screen-label {
    flex: 1;
    text-align: center;
    font-size: clamp(0.65rem, 1.6vh, 0.85rem);
    font-weight: 800;
    letter-spacing: 0.14em;
    color: var(--sc-green);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.screen-cycle-btn {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    min-height: 28px;
    padding: 4px 8px;
    background: var(--sc-panel);
    border: 1px solid var(--sc-green);
    border-radius: 4px;
    color: var(--sc-green);
    cursor: pointer;
}
.screen-cycle-btn svg { width: 16px; height: 16px; display: block; }
.screen-cycle-btn:active { transform: scale(.92); background: rgba(159, 178, 0, 0.12); }

.sc-display {
    flex: 1;
    background: var(--sc-panel);
    border: 1px solid var(--sc-border);
    border-radius: 10px;
    position: relative;
    overflow: hidden;
    min-height: 0;
}

.sc-screen {
    display: none;
    flex-direction: column;
    padding: clamp(10px, 2vh, 20px);
    justify-content: center;
    height: 100%;
    overflow: auto;
}
.sc-screen.active { display: flex; }

.sc-tells {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: clamp(6px, 1.2vh, 10px);
    justify-items: center;
    align-content: center;
    padding: 8px 4px;
}
.sc-tells .tell {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: clamp(28px, 5.5vh, 44px);
    height: clamp(28px, 5.5vh, 44px);
    padding: 5px;
    border-radius: 6px;
    border: 1px solid #333;
    background: #1a1a1a;
    color: #555;
    opacity: 0.35;
    line-height: 0;
    transition: opacity .15s, color .15s, box-shadow .15s, border-color .15s;
}
.sc-tells .tell svg {
    width: 100%;
    height: 100%;
    display: block;
}
.sc-tells .tell.on {
    opacity: 1;
    color: #fff;
    box-shadow: 0 0 10px currentColor;
}
.sc-tells .tell.on svg { filter: drop-shadow(0 0 4px currentColor); }
.sc-tells .js-tell-side.on, .sc-tells .js-tell-low.on, .sc-tells .js-tell-trailer.on,
.sc-tells .js-tell-cruise.on, .sc-tells .js-tell-wipers.on { color: var(--sc-green); border-color: var(--sc-green); }
.sc-tells .js-tell-high.on { color: var(--sc-blue); border-color: var(--sc-blue); }
.sc-tells .js-tell-fogr.on, .sc-tells .js-tell-beacon.on, .sc-tells .js-tell-diff.on,
.sc-tells .js-tell-ebrake.on, .sc-tells .js-tell-ret.on, .sc-tells .js-tell-lift.on,
.sc-tells .js-tell-fuel.on, .sc-tells .js-tell-adblue.on { color: var(--sc-amber); border-color: var(--sc-amber); }
.sc-tells .js-tell-hazard.on, .sc-tells .js-tell-park.on, .sc-tells .js-tell-batt.on,
.sc-tells .js-tell-oil.on, .sc-tells .js-tell-temp.on, .sc-tells .js-tell-air.on { color: var(--sc-red); border-color: var(--sc-red); }

.sc-screen.active:not([data-id="0"]):not([data-id="5"]):not([data-id="8"]) {
    align-items: flex-start;
    padding-left: clamp(12px, 3vw, 28px);
    padding-right: clamp(12px, 3vw, 28px);
}

.sc-row {
    display: flex;
    align-items: baseline;
    justify-content: flex-start;
    gap: 0.6em;
    width: 100%;
    max-width: min(100%, 340px);
    margin-bottom: clamp(6px, 1.2vh, 12px);
    padding: 0;
}
.sc-row span {
    flex: 0 0 clamp(4.2em, 26%, 6.5em);
    font-size: clamp(0.85rem, 2vh, 1.1rem);
    color: var(--sc-label);
    font-weight: 600;
    text-align: left;
}
.sc-row b {
    flex: 0 1 auto;
    font-size: clamp(1.2rem, 4.5vh, 2.8rem);
    font-weight: 900;
    color: #fff;
    text-align: left;
}
.sc-row i { flex: 0 0 auto; font-style: normal; color: var(--sc-label); font-size: 0.85em; margin-left: 0; }

.sc-limit {
    width: clamp(70px, 18vh, 140px);
    height: clamp(70px, 18vh, 140px);
    border: clamp(6px, 1.5vh, 14px) solid var(--sc-red);
    border-radius: 50%;
    background: #fff;
    color: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(2rem, 7vh, 4.5rem);
    font-weight: 900;
    margin: 0 auto;
    box-shadow: 0 0 24px rgba(213, 0, 28, 0.35);
}
.sc-limit:empty { display: none; }
.sc-limit-group:empty, .sc-limit-group:has(.sc-limit:empty) { display: none; }

.sc-cruise-group {
    margin-top: 1.5vh;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: var(--sc-green);
    font-size: clamp(1.2rem, 3.5vh, 2.2rem);
    font-weight: 800;
}
.sc-cruise-group .js-cruise:not(.active) { color: var(--sc-label); font-size: 0.9em; }

.sc-big-speed {
    font-size: clamp(4rem, 18vh, 14rem);
    font-weight: 900;
    text-align: center;
    line-height: 0.9;
}
.sc-big-unit {
    font-size: clamp(1rem, 3vh, 2rem);
    color: var(--sc-label);
    text-align: center;
    font-weight: 700;
    letter-spacing: 0.1em;
}

/* --- Bottom strip --- */
.sc-bottom-strip {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: clamp(8px, 1.5vw, 16px);
    border-top: 1px solid var(--sc-border);
    margin-top: 0.5vh;
    padding: clamp(4px, 1vh, 8px) 0;
    min-width: 0;
}

.sc-indicators {
    display: flex;
    gap: clamp(4px, 1vw, 12px);
    flex: 0 0 auto;
}

.sc-tell {
    width: clamp(22px, 4.5vh, 40px);
    height: clamp(22px, 4.5vh, 40px);
    opacity: 0.08;
    transition: opacity .15s, filter .15s;
    color: var(--sc-green);
}
.sc-tell svg { width: 100%; height: 100%; display: block; }
.sc-tell.on { opacity: 1; filter: drop-shadow(0 0 4px currentColor); }
.sc-tell.js-tell-high.on { color: var(--sc-blue); }
.sc-tell.js-tell-park.on, .sc-tell.js-tell-hazard.on { color: var(--sc-red); }
.sc-tell.js-tell-ret.on, .sc-tell.js-tell-diff.on { color: var(--sc-amber); }
.sc-tell.js-tell-blinkL.on, .sc-tell.js-tell-blinkR.on { animation: sc-blink .9s steps(1, end) infinite; }

.sc-trip-bar {
    flex: 1 1 auto;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-start;
    gap: clamp(8px, 1.4vw, 16px);
    font-size: clamp(0.55rem, 1.4vh, 0.78rem);
    font-weight: 700;
    letter-spacing: 0.06em;
    color: var(--sc-label);
    min-width: 0;
    padding-left: clamp(4px, 1vw, 10px);
}
.sc-trip-bar .trip-item {
    display: inline-flex;
    align-items: baseline;
    gap: 0.35em;
    white-space: nowrap;
}
.sc-trip-bar b {
    color: #fff;
    font-size: clamp(0.75rem, 1.8vh, 1rem);
    font-weight: 800;
    margin-left: 0;
}
.sc-trip-bar i { font-style: normal; margin-left: 2px; opacity: 0.8; }
.sc-trip-bar .eta b { color: #fff; }
.sc-trip-bar .ttg b { color: var(--sc-amber); }
.sc-trip-bar .job b { color: var(--sc-red); }
.sc-trip-bar .rest b { color: var(--sc-blue); }

.sc-country {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: clamp(80px, 18vw, 160px);
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid var(--sc-border);
    background: rgba(0,0,0,.25);
    min-width: 0;
}
.sc-country-flag { font-size: clamp(0.9rem, 2.2vh, 1.2rem); line-height: 1; }
.sc-country-name {
    font-size: clamp(0.55rem, 1.3vh, 0.72rem);
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--sc-label);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sc-country.country-flash { animation: sc-country-flash .4s ease-out; }
@keyframes sc-country-flash {
    0% { border-color: var(--sc-green); background: rgba(159, 178, 0, .18); }
    100% { border-color: var(--sc-border); background: rgba(0,0,0,.25); }
}

.icon-cruise { width: 28px; height: 28px; display: inline-flex; }
.icon-cruise svg { width: 100%; height: 100%; }

/* Accent themes */
.scania-digital[data-accent="lime"]   { --brand-accent: #b6ff1f; --sc-green: #b6ff1f; --rpmcol: #b6ff1f; }
.scania-digital[data-accent="amber"]  { --brand-accent: #ffc24a; --sc-green: #ffc24a; --rpmcol: #ffc24a; }
.scania-digital[data-accent="red"]    { --brand-accent: #ff5a4d; --sc-green: #ff5a4d; --rpmcol: #ff5a4d; }
.scania-digital[data-accent="blue"]   { --brand-accent: #46b6ff; --sc-green: #46b6ff; --sc-blue: #46b6ff; --rpmcol: #46b6ff; }
.scania-digital[data-accent="green"]  { --brand-accent: #39e07a; --sc-green: #39e07a; --rpmcol: #39e07a; }
.scania-digital[data-accent="ice"]    { --brand-accent: #dfe9f2; --sc-green: #dfe9f2; --sc-label: #7d8a99; --rpmcol: #dfe9f2; }
.scania-digital[data-accent="violet"] { --brand-accent: #b07cff; --sc-green: #b07cff; --rpmcol: #b07cff; }
.scania-digital[data-mode="day"][data-accent="lime"]   { --brand-accent: #3a7d12; --sc-green: #3a7d12; --rpmcol: #3a7d12; }
.scania-digital[data-mode="day"][data-accent="amber"]  { --brand-accent: #b07415; --sc-green: #b07415; --rpmcol: #b07415; }
.scania-digital[data-mode="day"][data-accent="red"]    { --brand-accent: #c62828; --sc-green: #c62828; --rpmcol: #c62828; }
.scania-digital[data-mode="day"][data-accent="blue"]   { --brand-accent: #1565c0; --sc-green: #1565c0; --sc-blue: #1565c0; --rpmcol: #1565c0; }
.scania-digital[data-mode="day"][data-accent="green"]  { --brand-accent: #1b8a45; --sc-green: #1b8a45; --rpmcol: #1b8a45; }
.scania-digital[data-mode="day"][data-accent="ice"]    { --brand-accent: #41566b; --sc-green: #41566b; --rpmcol: #41566b; }
.scania-digital[data-mode="day"][data-accent="violet"] { --brand-accent: #6a3fb0; --sc-green: #6a3fb0; --rpmcol: #6a3fb0; }
.scania-digital .sc-theme-btn .js-theme-swatch {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--brand-accent);
    box-shadow: 0 0 8px var(--brand-accent);
}

@media (max-aspect-ratio: 1/1) {
    .sc-middle { gap: 6px; }
    .sc-gauge-bar { width: clamp(64px, 14vw, 100px); }
    .sc-indicators { gap: 4px; }
    .sc-trip-bar { font-size: 0.5rem; }
}
