:root{
  /* Tesla palette */
  --tesla-red:#E82127;
  --black:#0B0C10;
  --black-2:#07080B;
  --white:#F6F7FB;
  --muted:#A9B1BC;

  /* Surfaces */
  --panel: rgba(255,255,255,.06);
  --panel-2: rgba(255,255,255,.035);
  --stroke: rgba(255,255,255,.10);
  --stroke-2: rgba(255,255,255,.14);

  /* Effects */
  --shadow: 0 24px 80px rgba(0,0,0,.55);
  --shadow-soft: 0 16px 50px rgba(0,0,0,.35);
  --radius: 22px;
  --radius-sm: 16px;

  /* Focus ring */
  --ring: 0 0 0 7px rgba(232,33,39,.12);
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color:var(--white);
  background: radial-gradient(1200px 700px at 15% 10%, rgba(232,33,39,.18), transparent 55%),
              radial-gradient(900px 650px at 85% 60%, rgba(232,33,39,.10), transparent 55%),
              linear-gradient(180deg, var(--black-2), var(--black) 35%, var(--black-2));
  overflow-x:hidden;
}

/* --- Background layers (subtle “Into Your Reach” style) --- */
.bg{position:fixed; inset:0; z-index:-2;}
.glow{position:absolute; filter: blur(34px); opacity:.95; mix-blend-mode: screen;}
.glow-a{
  width:560px;height:560px;left:-170px;top:-210px;
  background: radial-gradient(circle at 30% 30%, rgba(232,33,39,.95), rgba(232,33,39,0) 65%);
  animation: floatA 10s ease-in-out infinite;
}
.glow-b{
  width:620px;height:620px;right:-220px;bottom:-260px;
  background: radial-gradient(circle at 35% 35%, rgba(232,33,39,.55), rgba(232,33,39,0) 65%);
  animation: floatB 12s ease-in-out infinite;
}
.gridlines{
  position:absolute; inset:0; opacity:.22;
  background-image:
    linear-gradient(to right, rgba(255,255,255,.045) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255,255,255,.045) 1px, transparent 1px);
  background-size: 68px 68px;
  mask-image: radial-gradient(circle at 50% 20%, black 0%, transparent 72%);
}

@keyframes floatA{0%,100%{transform:translate(0,0)}50%{transform:translate(22px,34px)}}
@keyframes floatB{0%,100%{transform:translate(0,0)}50%{transform:translate(-26px,-18px)}}

/* --- Layout --- */
.wrap{
  max-width:1120px;
  margin:0 auto;
  padding:34px 16px 46px;
}

/* Header */
.top{
  display:flex;
  align-items:flex-end;
  justify-content:space-between;
  gap:16px;
  margin-bottom:18px;
}

.brand{display:flex; align-items:center; gap:14px;}
.mark{
  width:46px;height:46px;border-radius:18px;
  background:
    radial-gradient(circle at 30% 25%, rgba(232,33,39,.85), rgba(232,33,39,0) 62%),
    linear-gradient(180deg, rgba(255,255,255,.11), rgba(255,255,255,0));
  border:1px solid rgba(232,33,39,.35);
  box-shadow: 0 0 52px rgba(232,33,39,.22);
}

h1{
  margin:0;
  font-size:28px;
  letter-spacing:-.2px;
  line-height:1.08;
}
.sub{
  margin:6px 0 0;
  color:var(--muted);
  font-size:13px;
}

.pill-row{display:flex; gap:10px; flex-wrap:wrap;}
.pill{
  border:1px solid var(--stroke);
  background: rgba(255,255,255,.035);
  color:var(--white);
  padding:10px 12px;
  border-radius:999px;
  cursor:pointer;
  transition: transform .15s ease, border-color .15s ease, background .15s ease;
}
.pill:hover{transform:translateY(-1px); border-color: rgba(232,33,39,.45)}
.pill.active{
  border-color: rgba(232,33,39,.55);
  background: rgba(232,33,39,.14);
  box-shadow: 0 0 0 6px rgba(232,33,39,.06);
}

.layout{
  display:grid;
  grid-template-columns: 1.18fr .92fr;
  gap:14px;
}
@media (max-width: 980px){
  .top{flex-direction:column; align-items:flex-start}
  .layout{grid-template-columns:1fr}
}

/* Cards (premium glass) */
.card{
  position:relative;
  background:
    linear-gradient(180deg, rgba(255,255,255,.075), rgba(255,255,255,.03));
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  padding:18px;
  backdrop-filter: blur(10px);
}
.card:before{
  content:"";
  position:absolute; inset:0;
  border-radius: var(--radius);
  padding:1px;
  background: linear-gradient(180deg, rgba(232,33,39,.22), rgba(255,255,255,.06));

  /* Standard (spec) */
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask-composite: exclude;

  /* WebKit (Safari/iOS) */
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;

  opacity:.55;
  pointer-events:none;
}

.card-title{
  display:flex;
  align-items:baseline;
  justify-content:space-between;
  gap:12px;
  margin-bottom:12px;
}
.card-title h2{
  margin:0;
  font-size:15px;
  letter-spacing:.35px;
  text-transform:uppercase;
}
.tiny{color:var(--muted); font-size:12px}

/* Form fields */
.row{margin-bottom:10px;}
.grid2{display:grid; grid-template-columns:1fr 1fr; gap:12px;}
@media (max-width: 680px){ .grid2{grid-template-columns:1fr} }

.field span{
  display:block;
  color:var(--muted);
  font-size:12px;
  margin-bottom:8px;
}
.field b{color:var(--white); font-weight:900}
.field small{
  display:block;
  color:var(--muted);
  font-size:11px;
  margin-top:7px;
}
.muted{color:var(--muted); font-weight:700}

input, select{
  width:100%;
  border-radius: var(--radius-sm);
  padding:12px 12px;
  border:1px solid var(--stroke);
  background: rgba(7,8,11,.62);
  color:var(--white);
  outline:none;
  transition: border-color .15s ease, box-shadow .15s ease, transform .08s ease;
}
input:focus, select:focus{
  border-color: rgba(232,33,39,.55);
  box-shadow: var(--ring);
}
input:active, select:active{transform: scale(.995)}

/* Better select arrow (still native) */
select{
  appearance:none;
  background-image:
    linear-gradient(45deg, transparent 50%, rgba(255,255,255,.65) 50%),
    linear-gradient(135deg, rgba(255,255,255,.65) 50%, transparent 50%),
    linear-gradient(to right, transparent, transparent);
  background-position:
    calc(100% - 18px) calc(50% - 3px),
    calc(100% - 12px) calc(50% - 3px),
    0 0;
  background-size: 6px 6px, 6px 6px, 100% 100%;
  background-repeat: no-repeat;
}

/* Range sliders */
input[type="range"]{
  padding:10px 10px;
  height:46px;
  accent-color: var(--tesla-red);
  background: rgba(7,8,11,.42);
  border-radius: var(--radius-sm);
}

/* Buttons */
.actions{
  display:flex;
  gap:10px;
  justify-content:flex-end;
  margin-top:14px;
  flex-wrap:wrap;
}

.btn{
  border:1px solid rgba(232,33,39,.55);
  background: linear-gradient(180deg, rgba(232,33,39,.95), rgba(232,33,39,.78));
  color: #07080B;
  font-weight: 900;
  padding:12px 14px;
  border-radius: var(--radius-sm);
  cursor:pointer;
  letter-spacing:.15px;
  transition: transform .15s ease, filter .15s ease, box-shadow .15s ease;
  box-shadow: 0 18px 44px rgba(232,33,39,.16);
}
.btn:hover{
  transform: translateY(-1px);
  filter: brightness(1.03);
  box-shadow: 0 22px 52px rgba(232,33,39,.22);
}
.btn:active{transform: translateY(0); filter: brightness(.98);}

.btn.ghost{
  background: rgba(255,255,255,.04);
  border: 1px solid var(--stroke-2);
  color: var(--white);
  font-weight: 800;
  box-shadow:none;
}
.btn.ghost:hover{
  border-color: rgba(232,33,39,.35);
  box-shadow: 0 0 0 6px rgba(232,33,39,.06);
}

/* Error */
.error{
  border: 1px solid rgba(232,33,39,.65);
  background: rgba(232,33,39,.11);
  color: var(--white);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  margin-top: 10px;
}
.hidden{display:none}

/* Results card sticky */
.results{
  position:sticky;
  top:16px;
  align-self:start;
}
@media (max-width: 980px){ .results{position:relative; top:auto} }

/* Stats grid */
.stat-grid{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:12px;
}
@media (max-width: 560px){ .stat-grid{grid-template-columns:1fr} }

.stat{
  border:1px solid var(--stroke);
  background: rgba(7,8,11,.56);
  border-radius: 18px;
  padding: 12px;
  transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.stat:hover{
  transform: translateY(-1px);
  border-color: rgba(255,255,255,.16);
  box-shadow: 0 14px 40px rgba(0,0,0,.35);
}
.stat .k{color:var(--muted); font-size:12px;}
.stat .v{
  margin-top:6px;
  font-size:16px;
  font-weight: 900;
  letter-spacing:.2px;
}
.stat .v.big{font-size:24px; letter-spacing:.1px;}
.stat.highlight{
  border-color: rgba(232,33,39,.60);
  box-shadow: 0 0 0 7px rgba(232,33,39,.06);
}
.stat.highlight .v.big{
  text-shadow: 0 0 28px rgba(232,33,39,.22);
}

/* Note blocks */
.note{
  margin-top:12px;
  border:1px solid var(--stroke);
  background: rgba(255,255,255,.03);
  padding: 12px;
  border-radius: 18px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}
.note b{color:var(--white)}
.fine{
  margin-top:10px;
  color:var(--muted);
  font-size:12px
}
.fine span{color:var(--tesla-red); font-weight:900}

/* Footer */
.foot{
  margin-top:16px;
  display:flex;
  justify-content:space-between;
  gap:10px;
  color:var(--muted);
  font-size:12px;
  flex-wrap:wrap;
}
.foot-links a{color:var(--muted); text-decoration:none}
.foot-links a:hover{color:var(--white)}
.dot{opacity:.5; margin:0 6px}

/* Modal */
.modal{border:none; padding:0; background:transparent;}
.modal::backdrop{
  background: rgba(0,0,0,.68);
  backdrop-filter: blur(7px);
}
.modal-inner{
  width: min(740px, calc(100vw - 28px));
  margin: 10vh auto;
  border-radius: var(--radius);
  border: 1px solid var(--stroke-2);
  background: linear-gradient(180deg, rgba(255,255,255,.085), rgba(255,255,255,.03));
  box-shadow: var(--shadow);
  overflow: hidden;
}
.modal-head{
  display:flex; align-items:center; justify-content:space-between;
  padding: 14px 14px;
  border-bottom: 1px solid var(--stroke);
}
.modal-title{font-weight:900; letter-spacing:.2px;}
.x{
  border: 1px solid var(--stroke-2);
  background: rgba(255,255,255,.05);
  color: var(--white);
  border-radius: 14px;
  padding: 8px 10px;
  cursor: pointer;
}
.modal-body{
  padding: 14px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}
.modal-body b{color: var(--white);}
.modal-actions{
  padding: 14px;
  display:flex;
  justify-content:flex-end;
  border-top: 1px solid var(--stroke);
}
