﻿/* ─────────────────────────────────────────────────────────────────────────────
   Crisab — stile "auto": fondo scuro, numeri grandi, accenti caldi.
   Pensato per essere leggibile sia sul telefono sia sul tablet dell'auto
   (landscape, a distanza), con la stessa base.
   ───────────────────────────────────────────────────────────────────────────── */

:root {
    --bg: #070b10;
    --bg-soft: #0d141c;
    --card: rgba(20, 30, 41, 0.72);
    --card-solid: #121b25;
    --line: rgba(255, 255, 255, 0.08);
    --text: #e9f0f6;
    --muted: #8ea0b3;
    --accent: #ff8a3d;
    --accent-2: #38e0c4;
    --ok: #3ddc84;
    --warn: #ffcf5c;
    --bad: #ff5d5d;
    --radius: 20px;
    --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
    --font: "Segoe UI", "Inter", system-ui, -apple-system, sans-serif;
}

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

html, body { height: 100%; }

body {
    font-family: var(--font);
    color: var(--text);
    background:
        radial-gradient(1200px 600px at 15% -10%, rgba(255, 138, 61, 0.14), transparent 60%),
        radial-gradient(900px 500px at 100% 0%, rgba(56, 224, 196, 0.10), transparent 55%),
        var(--bg);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
.hidden { display: none !important; }

/* ── shell ─────────────────────────────────────────────────────────────── */
.app {
    max-width: 1320px;
    margin: 0 auto;
    padding: clamp(14px, 2.2vw, 30px);
    padding-bottom: 110px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: clamp(14px, 2vw, 24px);
}

.brand { display: flex; align-items: center; gap: 12px; }

.brand-mark {
    width: 44px; height: 44px; border-radius: 14px;
    display: grid; place-items: center;
    background: linear-gradient(145deg, var(--accent), #ff5f2e);
    box-shadow: 0 8px 24px rgba(255, 101, 46, 0.35);
    font-weight: 800; font-size: 18px; color: #160a04;
}

.brand-txt strong { display: block; font-size: 17px; letter-spacing: 0.14em; }
.brand-txt span { font-size: 12px; color: var(--muted); letter-spacing: 0.04em; }

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

.pill {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 8px 14px; border-radius: 999px;
    background: var(--card); border: 1px solid var(--line);
    font-size: 12.5px; color: var(--muted); white-space: nowrap;
}

.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.dot.live { background: var(--ok); box-shadow: 0 0 12px var(--ok); }
.dot.demo { background: var(--warn); box-shadow: 0 0 12px var(--warn); }
.dot.off { background: var(--bad); }

.icon-btn {
    width: 42px; height: 42px; border-radius: 13px;
    display: grid; place-items: center;
    background: var(--card); border: 1px solid var(--line);
    color: var(--text); font-size: 17px;
    transition: transform .15s ease, border-color .15s;
}
.icon-btn:hover { transform: translateY(-1px); border-color: rgba(255,255,255,.2); }

/* ── tabs ──────────────────────────────────────────────────────────────── */
.tabs {
    display: flex; gap: 6px; padding: 6px;
    background: rgba(13, 20, 28, 0.8);
    border: 1px solid var(--line);
    border-radius: 16px;
    margin-bottom: clamp(16px, 2vw, 24px);
    overflow-x: auto;
    scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
    flex: 1 0 auto;
    padding: 11px 20px;
    border-radius: 11px;
    color: var(--muted);
    font-size: 14px; font-weight: 600;
    letter-spacing: .02em;
    transition: background .18s, color .18s;
    white-space: nowrap;
}
.tab.active { background: var(--card-solid); color: var(--text); box-shadow: 0 6px 18px rgba(0,0,0,.35); }
.tab:hover:not(.active) { color: var(--text); }

.panel { display: none; animation: fade .25s ease; }
.panel.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; } }

/* ── hero ──────────────────────────────────────────────────────────────── */
.hero {
    display: grid;
    grid-template-columns: minmax(220px, 0.9fr) minmax(280px, 1.6fr);
    gap: clamp(14px, 2vw, 22px);
    margin-bottom: clamp(14px, 2vw, 22px);
}

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    backdrop-filter: blur(10px);
    padding: clamp(16px, 2vw, 24px);
}

.soc-card { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; }

.gauge { position: relative; width: min(210px, 46vw); aspect-ratio: 1; }
.gauge svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.gauge .track { fill: none; stroke: rgba(255,255,255,.07); stroke-width: 12; }
.gauge .bar { fill: none; stroke: url(#socGrad); stroke-width: 12; stroke-linecap: round;
              transition: stroke-dashoffset .8s ease; }
.gauge-label {
    position: absolute; inset: 0; display: grid; place-content: center; text-align: center;
}
.gauge-label b { font-size: clamp(38px, 5.4vw, 56px); font-weight: 700; letter-spacing: -.02em; }
.gauge-label span { font-size: 12px; color: var(--muted); letter-spacing: .18em; text-transform: uppercase; }

.hero-side { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }

.stat {
    background: rgba(255,255,255,.03);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 16px;
    display: flex; flex-direction: column; gap: 6px;
}
.stat .k { font-size: 11.5px; color: var(--muted); letter-spacing: .12em; text-transform: uppercase; }
.stat .v { font-size: clamp(22px, 2.8vw, 30px); font-weight: 700; letter-spacing: -.02em; }
.stat .v small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 4px; }

.charge-strip { grid-column: 1 / -1; display: flex; align-items: center; gap: 14px; }
.charge-bar { flex: 1; height: 8px; border-radius: 99px; background: rgba(255,255,255,.08); overflow: hidden; }
.charge-bar i { display: block; height: 100%; border-radius: 99px;
                background: linear-gradient(90deg, var(--accent-2), #6ef2c8); }

/* ── griglia ───────────────────────────────────────────────────────────── */
.grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: clamp(12px, 1.6vw, 18px); }

.tile { padding: 18px; }
.tile h3 {
    font-size: 12px; letter-spacing: .14em; text-transform: uppercase;
    color: var(--muted); margin-bottom: 14px; display: flex; justify-content: space-between;
}
.tile h3 .state { color: var(--text); letter-spacing: 0; text-transform: none; font-size: 12.5px; }

.rows { display: flex; flex-direction: column; gap: 9px; }
.row { display: flex; justify-content: space-between; align-items: center; font-size: 14px; }
.row span:first-child { color: var(--muted); }
.row b { font-weight: 600; }

.badge-ok { color: var(--ok); }
.badge-bad { color: var(--bad); }

/* porte/finestrini */
.car-mini { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.car-part {
    display: flex; align-items: center; gap: 8px;
    padding: 9px 11px; border-radius: 11px;
    background: rgba(255,255,255,.03); border: 1px solid var(--line);
    font-size: 13px;
}
.car-part.open { border-color: rgba(255, 93, 93, .5); background: rgba(255, 93, 93, .08); }
.car-part i { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.car-part.open i { background: var(--bad); }

/* pneumatici */
.tires { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.tire {
    padding: 10px; border-radius: 12px; text-align: center;
    background: rgba(255,255,255,.03); border: 1px solid var(--line);
}
.tire b { display: block; font-size: 18px; }
.tire span { font-size: 11px; color: var(--muted); }
.tire.low b { color: var(--warn); }

/* ricarica */
.charge-big { font-size: 34px; font-weight: 700; letter-spacing: -.02em; }
.charge-sub { color: var(--muted); font-size: 13px; margin-top: 4px; }

/* mappa */
.map {
    height: 130px; border-radius: 12px;
    background:
        linear-gradient(rgba(255,255,255,.04) 1px, transparent 1px) 0 0 / 22px 22px,
        linear-gradient(90deg, rgba(255,255,255,.04) 1px, transparent 1px) 0 0 / 22px 22px,
        #0b1219;
    border: 1px solid var(--line);
    position: relative; overflow: hidden;
}
.map .pin {
    position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
    width: 14px; height: 14px; border-radius: 50%; background: var(--accent);
    box-shadow: 0 0 0 8px rgba(255,138,61,.15), 0 0 22px rgba(255,138,61,.7);
}
.map .coords { position: absolute; left: 10px; bottom: 8px; font-size: 11px; color: var(--muted); }

/* ── viaggi ────────────────────────────────────────────────────────────── */
.trips-head { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: end; margin-bottom: 18px; }
.trips-sum { display: flex; gap: 26px; }
.trips-sum div span { display: block; font-size: 11.5px; color: var(--muted); letter-spacing: .1em; text-transform: uppercase; }
.trips-sum div b { font-size: 24px; }

.trip {
    display: grid; grid-template-columns: 92px 1fr auto auto auto;
    gap: 16px; align-items: center;
    padding: 14px 4px; border-bottom: 1px solid var(--line);
    font-size: 14px;
}
.trip:last-child { border-bottom: 0; }
.trip .when { color: var(--muted); font-size: 13px; }
.trip .who { font-weight: 600; }
.trip .km { font-weight: 700; }
.trip .energy { color: var(--muted); font-size: 13px; }
.trip .cost { font-weight: 600; color: var(--accent-2); }

.empty { padding: 34px; text-align: center; color: var(--muted); font-size: 14px; }

/* ── comandi ───────────────────────────────────────────────────────────── */
.cmd-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }

.cmd {
    display: flex; flex-direction: column; align-items: flex-start; gap: 8px;
    padding: 18px; border-radius: 16px;
    background: rgba(255,255,255,.03); border: 1px solid var(--line);
    text-align: left; transition: transform .15s, border-color .15s, background .15s;
}
.cmd:hover:not([disabled]) { transform: translateY(-2px); border-color: rgba(255,138,61,.45); background: rgba(255,138,61,.06); }
.cmd[disabled] { opacity: .45; cursor: not-allowed; }
.cmd i { font-size: 22px; font-style: normal; }
.cmd b { font-size: 14.5px; }
.cmd small { color: var(--muted); font-size: 12px; }

.notice {
    padding: 14px 16px; border-radius: 14px; font-size: 13.5px;
    background: rgba(255, 207, 92, .08); border: 1px solid rgba(255, 207, 92, .3);
    color: #ffe4a3; margin-bottom: 16px;
}

/* ── HUD ───────────────────────────────────────────────────────────────── */
.hud {
    position: fixed; inset: 0; z-index: 60;
    background: #04070a;
    display: grid; grid-template-rows: 1fr auto;
    padding: clamp(20px, 4vw, 56px);
}
.hud-main { display: grid; place-items: center; text-align: center; }
.hud-main .big { font-size: clamp(90px, 22vw, 260px); font-weight: 800; line-height: .9; letter-spacing: -.04em; }
.hud-main .unit { font-size: clamp(18px, 2.4vw, 34px); color: var(--muted); letter-spacing: .2em; text-transform: uppercase; margin-top: 10px; }
.hud-main .sub { margin-top: 18px; color: var(--muted); font-size: clamp(14px, 1.6vw, 22px); }
.hud-foot { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 13px; }
.hud-dots { display: flex; gap: 7px; }
.hud-dots i { width: 7px; height: 7px; border-radius: 50%; background: rgba(255,255,255,.2); }
.hud-dots i.on { background: var(--accent); }

/* ── login ─────────────────────────────────────────────────────────────── */
.sheet {
    position: fixed; inset: 0; z-index: 70;
    background: rgba(4, 7, 10, .82);
    backdrop-filter: blur(8px);
    display: grid; place-items: center;
    padding: 20px;
}
.sheet .card { width: min(430px, 100%); }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: var(--muted); letter-spacing: .1em; text-transform: uppercase; margin-bottom: 7px; }
.field input {
    width: 100%; padding: 13px 14px; border-radius: 12px;
    background: rgba(255,255,255,.05); border: 1px solid var(--line);
    font-size: 16px; letter-spacing: .06em;
}
.field input:focus { outline: none; border-color: rgba(255,138,61,.6); box-shadow: 0 0 0 3px rgba(255,138,61,.12); }

.btn {
    width: 100%; padding: 14px; border-radius: 12px;
    font-weight: 700; font-size: 15px; letter-spacing: .01em;
    background: linear-gradient(145deg, var(--accent), #ff6230);
    color: #1a0a03; transition: filter .15s, transform .15s;
}
.btn:hover { filter: brightness(1.06); transform: translateY(-1px); }
.btn:disabled { opacity: .5; filter: none; transform: none; cursor: not-allowed; }
.btn.ghost { background: rgba(255,255,255,.05); color: var(--text); border: 1px solid var(--line); }

.hint { font-size: 12.5px; color: var(--muted); line-height: 1.5; margin-top: 10px; }
.msg { font-size: 13.5px; padding: 10px 12px; border-radius: 10px; margin: 10px 0; display: none; }
.msg.show { display: block; }
.msg.err { background: rgba(255,93,93,.1); border: 1px solid rgba(255,93,93,.35); color: #ffb3b3; }
.msg.ok { background: rgba(61,220,132,.1); border: 1px solid rgba(61,220,132,.35); color: #a7f3c8; }

/* ── toast ─────────────────────────────────────────────────────────────── */
.toast {
    position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(20px);
    background: #17212c; border: 1px solid var(--line);
    padding: 12px 20px; border-radius: 12px; font-size: 13.5px;
    opacity: 0; pointer-events: none; transition: .25s; z-index: 90;
    box-shadow: var(--shadow); max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── responsive ────────────────────────────────────────────────────────── */
@media (max-width: 1000px) {
    .grid { grid-template-columns: repeat(2, 1fr); }
    .hero { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
    .app { padding-bottom: 40px; }
    .hero-side { grid-template-columns: repeat(2, 1fr); }
    .grid { grid-template-columns: 1fr; }
    .trip { grid-template-columns: 70px 1fr auto; row-gap: 4px; }
    .trip .energy { grid-column: 2 / -1; }
    .trip .cost { grid-column: 3; }
    .brand-txt span { display: none; }
    .pill { padding: 7px 11px; font-size: 11.5px; }
    .tabs { position: sticky; top: 0; z-index: 20; backdrop-filter: blur(12px); }
}

/* tablet in orizzontale: più colonne, testo più grande */
@media (min-width: 1100px) {
    body { font-size: 16px; }
    .grid { grid-template-columns: repeat(4, 1fr); }
}
