*{box-sizing:border-box}

:root{
  --bg:#07090b;
  --surface:#0d1115;
  --card:#11171c;
  --card-hover:#151c22;
  --line:#27313a;
  --line-bright:#3a4650;
  --text:#f7f8f9;
  --muted:#8f9ba6;
  --red:#ff2028;
  --red-dark:#bd1117;
  --green:#38d996;
  --shadow:0 24px 70px rgba(0,0,0,.28);
}

html{scroll-behavior:smooth}

body{
  margin:0;
  background:
    radial-gradient(circle at 50% -200px,rgba(255,32,40,.055),transparent 430px),
    var(--bg);
  color:var(--text);
  font-family:Inter,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Arial,sans-serif;
  -webkit-font-smoothing:antialiased;
}

button,input,select,textarea{font:inherit}

button{
  border:1px solid #34404a;
  border-radius:9px;
  background:#151b20;
  color:#fff;
  padding:10px 14px;
  font-weight:800;
  cursor:pointer;
  transition:.18s ease;
}

button:hover{
  background:#1c242b;
  border-color:#4b5964;
  transform:translateY(-1px);
}

button:active{transform:translateY(0)}

button:disabled{
  opacity:.55;
  cursor:not-allowed;
  transform:none;
}

.primary{
  background:var(--red);
  border-color:var(--red);
}

.primary:hover{
  background:#ff3940;
  border-color:#ff3940;
}

.shell{
  width:min(1180px,calc(100% - 40px));
  margin:auto;
}

/* ---------- HEADER ---------- */

header{
  position:sticky;
  top:0;
  z-index:20;
  background:rgba(7,9,11,.88);
  border-bottom:1px solid var(--line);
  backdrop-filter:blur(16px);
}

.header-inner{
  height:72px;
  display:flex;
  align-items:center;
  justify-content:space-between;
}

.brand{
  font-weight:950;
  letter-spacing:-.7px;
}

.brand b{
  color:var(--red);
  font-style:italic;
  font-size:1.4em;
}

.brand small{
  color:var(--muted);
  font-size:10px;
  margin-left:3px;
}

.header-actions{
  display:flex;
  align-items:center;
  gap:8px;
}

.plan-badge{
  font-size:10px;
  font-weight:950;
  letter-spacing:1px;
  padding:7px 10px;
  border:1px solid #4a555f;
  border-radius:999px;
}

.plan-badge.pro{
  background:var(--red);
  border-color:var(--red);
}

/* ---------- AUTH ---------- */

.auth-wrap{
  min-height:100vh;
  display:grid;
  place-items:center;
  padding:24px;
}

.auth-card{
  width:min(430px,100%);
  padding:36px;
  background:linear-gradient(180deg,#12181d,#0e1317);
  border:1px solid var(--line);
  border-radius:22px;
  box-shadow:0 35px 100px rgba(0,0,0,.55);
}

.tag,.eyebrow{
  color:var(--red);
  font-size:11px;
  font-weight:950;
  letter-spacing:1.6px;
  text-transform:uppercase;
}

.auth-card h1{
  font-size:38px;
  margin:26px 0;
  letter-spacing:-1px;
}

label{
  display:block;
  font-size:13px;
  font-weight:750;
  margin:15px 0;
}

input,select,textarea{
  display:block;
  width:100%;
  margin-top:7px;
  padding:13px 14px;
  border-radius:10px;
  border:1px solid #34404a;
  background:#090d10;
  color:white;
  outline:none;
}

input:focus,select:focus,textarea:focus{
  border-color:#657480;
  box-shadow:0 0 0 3px rgba(255,255,255,.04);
}

textarea{
  min-height:88px;
  resize:vertical;
}

.auth-card .primary{
  width:100%;
  margin-top:8px;
  padding:14px;
}

.linkbtn{
  width:100%;
  border:0;
  background:none;
  color:#c7ced5;
  margin-top:12px;
}

.linkbtn:hover{
  background:none;
  color:#fff;
  transform:none;
}

.msg{
  color:#ff6a6f;
  font-size:13px;
  min-height:18px;
}

/* ---------- GENERAL ---------- */

main{
  padding:52px 0 90px;
}

.hero{
  padding:35px 0 54px;
}

.hero p{
  color:var(--red);
  font-weight:950;
  letter-spacing:2px;
  font-size:12px;
}

.hero h1{
  font-size:clamp(42px,6vw,66px);
  letter-spacing:-2.7px;
  line-height:.98;
  margin:24px 0 28px;
}

.stats{
  display:grid;
  grid-template-columns:repeat(2,minmax(0,180px));
  gap:12px;
}

.stats article,
.summary-grid article,
.insights article,
.budget-pill{
  background:linear-gradient(180deg,#12181d,#10161a);
  border:1px solid var(--line);
  border-radius:15px;
}

.stats article{
  padding:18px;
}

.stats small,
.summary-grid small,
.insights small,
.budget-pill small{
  display:block;
  color:#8fa0ad;
  font-size:10px;
  font-weight:900;
  text-transform:uppercase;
  letter-spacing:.35px;
}

.stats strong,
.summary-grid strong,
.budget-pill strong{
  display:block;
  font-size:24px;
  margin-top:7px;
}

.toolbar{
  display:flex;
  align-items:end;
  justify-content:space-between;
  gap:16px;
  margin:18px 0;
}

.toolbar h2{
  margin:5px 0 0;
  font-size:28px;
  letter-spacing:-.8px;
}

/* ---------- GARAGE ---------- */

.garage-grid{
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:16px;
}

.vehicle-card{
  display:flex;
  justify-content:space-between;
  gap:20px;
  background:linear-gradient(145deg,#12181d,#0f1418);
  border:1px solid var(--line);
  border-radius:17px;
  padding:22px;
  transition:.2s ease;
  box-shadow:0 10px 30px rgba(0,0,0,.1);
}

.vehicle-card:hover{
  border-color:#46525d;
  transform:translateY(-3px);
  box-shadow:0 18px 45px rgba(0,0,0,.22);
}

.vehicle-card h3{
  font-size:25px;
  margin:7px 0;
  letter-spacing:-.5px;
}

.vehicle-card p{
  color:var(--muted);
  margin:0;
}

.open-build{
  cursor:pointer;
  flex:1;
}

.budget{
  text-align:right;
  min-width:125px;
}

.budget small{
  color:var(--muted);
  font-size:9px;
  font-weight:850;
}

.budget strong{
  display:block;
  font-size:21px;
  margin:5px 0 14px;
}

.budget button{
  font-size:11px;
  padding:6px 9px;
}

.mini-actions{
  display:flex;
  gap:8px;
  justify-content:flex-end;
  margin-top:10px;
}

/* ---------- BUILD TOP ---------- */

.build-top{
  display:flex;
  justify-content:space-between;
  gap:12px;
  align-items:center;
  margin-bottom:30px;
}

.back{
  color:#dbe1e5;
}

.build-head{
  position:relative;
  display:grid;
  grid-template-columns:300px minmax(0,1fr) 185px;
  align-items:center;
  gap:32px;
  margin-bottom:24px;
  padding:28px;
  background:
    linear-gradient(100deg,rgba(255,32,40,.045),transparent 42%),
    linear-gradient(180deg,#10161a,#0d1216);
  border:1px solid var(--line);
  border-radius:22px;
  overflow:hidden;
}

.build-head:after{
  content:"";
  position:absolute;
  width:280px;
  height:280px;
  right:-130px;
  bottom:-190px;
  background:var(--red);
  opacity:.035;
  border-radius:50%;
  pointer-events:none;
}

.vehicle-photo-wrap{
  position:relative;
  display:flex;
  flex-direction:column;
  gap:10px;
}

.vehicle-photo{
  width:100%;
  height:185px;
  object-fit:cover;
  border-radius:15px;
  border:1px solid #35414a;
  background:#090d10;
  box-shadow:0 15px 35px rgba(0,0,0,.32);
}

.vehicle-photo-wrap button{
  width:100%;
  font-size:12px;
  background:#0d1216;
}

.build-head h1{
  font-size:clamp(42px,5vw,64px);
  line-height:.95;
  letter-spacing:-2px;
  margin:10px 0 14px;
}

.build-head p{
  color:#a1adb7;
  margin:0;
  font-size:14px;
}

.budget-pill{
  min-width:170px;
  padding:20px;
  align-self:center;
}

.budget-pill strong{
  font-size:28px;
}

/* ---------- BUILD STATS ---------- */

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

.summary-grid article{
  padding:20px;
  min-height:102px;
}

.summary-grid strong{
  font-size:27px;
}

.bar{
  height:7px;
  background:#242c33;
  border-radius:20px;
  margin-top:14px;
  overflow:hidden;
}

.bar i{
  display:block;
  height:100%;
  width:0;
  background:linear-gradient(90deg,var(--red-dark),var(--red));
  border-radius:20px;
  transition:width .4s ease;
}

.insights{
  display:grid;
  grid-template-columns:repeat(3,1fr);
  gap:12px;
  margin:0 0 28px;
}

.insights article{
  padding:17px 20px;
}

.insights strong{
  display:block;
  font-size:23px;
  margin-top:6px;
}

.over{
  color:#ff454b!important;
}

/* ---------- TABS ---------- */

.tabs{
  display:flex;
  gap:8px;
  overflow:auto;
  padding:2px 0 4px;
  margin:0 0 18px;
  scrollbar-width:none;
}

.tabs::-webkit-scrollbar{display:none}

.tabs button{
  white-space:nowrap;
  padding:10px 16px;
}

.tabs button.active{
  background:var(--red);
  border-color:var(--red);
  box-shadow:0 6px 18px rgba(255,32,40,.16);
}

/* ---------- BUILD LOG ---------- */

.panel{
  background:linear-gradient(180deg,#0d1216,#0b0f13);
  border:1px solid var(--line);
  border-radius:20px;
  padding:24px;
}

.item-list{
  display:grid;
  gap:10px;
}

.item{
  display:grid;
  grid-template-columns:1fr auto auto;
  align-items:center;
  gap:20px;
  background:linear-gradient(145deg,#12181d,#101519);
  border:1px solid var(--line);
  border-radius:13px;
  padding:17px;
  transition:.15s ease;
}

.item:hover{
  border-color:#3c4852;
}

.item h3{
  margin:0 0 6px;
  font-size:17px;
}

.item p{
  margin:0;
  color:var(--muted);
  font-size:13px;
}

.item .amount{
  font-size:17px;
  font-weight:900;
}

.actions{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
}

.item .actions button,
.mini-actions button{
  padding:8px 10px;
}

.notes{
  margin-top:8px!important;
  color:#d0d7de!important;
}

.badge{
  font-size:9px;
  padding:4px 7px;
  border:1px solid #4d5b63;
  border-radius:999px;
  color:#b9c4cb;
  vertical-align:middle;
}

.section-status{
  display:inline-block;
  color:#c8d0d7;
  background:#20272e;
  padding:4px 8px;
  border-radius:20px;
  font-size:11px;
  margin-left:6px;
}

.danger{
  color:#ff777c;
}

.empty{
  grid-column:1/-1;
  padding:46px 20px;
  border:1px dashed #34404a;
  border-radius:14px;
  color:var(--muted);
  text-align:center;
  background:rgba(255,255,255,.008);
}

.muted{
  color:#87939b;
  display:block;
  margin-top:5px;
}

/* ---------- DIALOGS ---------- */

dialog{
  width:min(540px,calc(100% - 30px));
  background:#11171c;
  color:white;
  border:1px solid var(--line);
  border-radius:19px;
  padding:0;
  box-shadow:0 35px 100px rgba(0,0,0,.65);
}

dialog::backdrop{
  background:rgba(0,0,0,.76);
  backdrop-filter:blur(3px);
}

dialog form{
  padding:26px;
}

dialog h2{
  margin-top:0;
  font-size:26px;
}

menu{
  display:flex;
  justify-content:flex-end;
  gap:10px;
  padding:12px 0 0;
}

.grid2{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:12px;
}

.check{
  display:flex!important;
  flex-direction:row!important;
  align-items:center;
  gap:10px;
}

.check input{
  width:auto!important;
}

/* ---------- MOBILE ---------- */

@media(max-width:850px){
  .build-head{
    grid-template-columns:240px 1fr;
  }

  .budget-pill{
    grid-column:1/-1;
    width:100%;
  }

  .vehicle-photo{
    height:160px;
  }
}

@media(max-width:700px){
  .shell{
    width:min(100% - 24px,1180px);
  }

  header .brand{
    font-size:12px;
  }

  .header-inner{
    height:62px;
  }

  .header-actions{
    gap:5px;
  }

  .header-actions button{
    padding:8px 9px;
    font-size:11px;
  }

  main{
    padding-top:24px;
  }

  .hero{
    padding:22px 0 34px;
  }

  .hero h1{
    font-size:42px;
  }

  .stats{
    grid-template-columns:1fr 1fr;
  }

  .garage-grid{
    grid-template-columns:1fr;
  }

  .vehicle-card{
    padding:17px;
  }

  .build-top{
    align-items:flex-start;
    margin-bottom:18px;
  }

  .build-top>div{
    display:flex;
    gap:6px;
  }

  .build-top button{
    font-size:11px;
    padding:9px;
  }

  .build-head{
    display:flex;
    flex-direction:column;
    align-items:stretch;
    gap:20px;
    padding:16px;
    border-radius:18px;
  }

  .vehicle-photo-wrap{
    width:100%;
  }

  .vehicle-photo{
    height:220px;
  }

  .build-head h1{
    font-size:46px;
    margin:8px 0 12px;
  }

  .budget-pill{
    width:100%;
  }

  .summary-grid{
    grid-template-columns:1fr 1fr;
  }

  .summary-grid article:nth-child(3){
    grid-column:1/-1;
  }

  .insights{
    grid-template-columns:repeat(3,1fr);
  }

  .insights article{
    padding:13px 11px;
  }

  .insights small{
    font-size:8px;
  }

  .insights strong{
    font-size:19px;
  }

  .tabs{
    margin-left:-12px;
    margin-right:-12px;
    padding-left:12px;
    padding-right:12px;
  }

  .panel{
    padding:15px;
  }

  .item{
    grid-template-columns:1fr!important;
  }

  .amount{
    text-align:left!important;
  }

  .actions{
    justify-content:flex-start!important;
  }

  .grid2{
    grid-template-columns:1fr;
  }

  .toolbar h2{
    font-size:23px;
  }

  .toolbar .primary{
    padding:10px 12px;
  }
}

@media(max-width:420px){
  .plan-badge{
    padding:6px 7px;
  }

  #accountBtn,#logoutBtn{
    padding:7px 8px;
  }

  .vehicle-photo{
    height:190px;
  }

  .summary-grid{
    grid-template-columns:1fr;
  }

  .summary-grid article:nth-child(3){
    grid-column:auto;
  }

  .build-head h1{
    font-size:40px;
  }
}

/* Hidden views must never occupy layout space */
[hidden]{
  display:none!important;
}
.clickable-card{cursor:pointer;transition:.2s}
.clickable-card:hover{border-color:#56616b;transform:translateY(-2px)}


/* =========================================================
   REDLINE BUILDBOOK V4
   Mobile-first vehicle dashboard
   ========================================================= */

.v4-build-head{
  position:relative;
  overflow:hidden;
  display:grid;
  grid-template-columns:280px 1fr 190px;
  align-items:center;
  gap:30px;
  padding:26px;
  background:
    radial-gradient(circle at 100% 100%,rgba(255,32,40,.07),transparent 280px),
    var(--surface,#0d1115);
  border:1px solid var(--line);
  border-radius:20px;
}

.v4-build-head .vehicle-photo-wrap{
  display:flex;
  flex-direction:column;
  gap:10px;
  width:100%;
}

.v4-build-head .vehicle-photo{
  width:100%;
  height:175px;
  object-fit:cover;
  border-radius:15px;
  border:1px solid var(--line);
}

.v4-build-head #photoBtn{
  width:100%;
}

.vehicle-identity{
  min-width:0;
}

.vehicle-identity h1{
  margin:10px 0 8px;
}

.vehicle-identity > p{
  color:var(--muted);
}

.v4-quick-info{
  display:flex;
  flex-wrap:wrap;
  gap:10px;
  margin-top:20px;
}

.v4-quick-info > div{
  min-width:145px;
  padding:12px 14px;
  background:rgba(255,255,255,.025);
  border:1px solid var(--line);
  border-radius:11px;
}

.v4-quick-info small{
  display:block;
  color:var(--muted);
  font-size:10px;
  font-weight:900;
  letter-spacing:.7px;
}

.v4-quick-info strong{
  display:block;
  margin-top:5px;
  font-size:15px;
}

.v4-build-head .budget-pill{
  width:100%;
  min-width:0;
  align-self:start;
}

.v4-action-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:20px;
  margin:18px 0 24px;
  padding:16px 18px;
  background:linear-gradient(
    90deg,
    rgba(255,32,40,.08),
    rgba(255,32,40,.015)
  );
  border:1px solid rgba(255,32,40,.22);
  border-radius:14px;
}

.v4-action-row strong{
  display:block;
  margin-top:3px;
  font-size:15px;
}

.v4-add-entry{
  min-width:135px;
}

#maintenanceDueCard.due{
  border-color:rgba(255,32,40,.55);
}

#maintenanceDueCard.due strong{
  color:var(--red);
}


/* ---------- TABLET ---------- */

@media(max-width:900px){

  .v4-build-head{
    grid-template-columns:220px 1fr;
  }

  .v4-build-head .budget-pill{
    grid-column:1/-1;
  }

}


/* ---------- MOBILE ---------- */

@media(max-width:700px){

  .build-top{
    margin-bottom:16px;
  }

  .build-top > div{
    display:flex;
    gap:6px;
  }

  .build-top button{
    font-size:12px;
    padding:9px 10px;
  }

  .v4-build-head{
    display:flex;
    flex-direction:column;
    align-items:stretch;
    gap:18px;
    padding:14px;
    border-radius:16px;
  }

  .v4-build-head .vehicle-photo-wrap{
    display:block;
  }

  .v4-build-head .vehicle-photo{
    width:100%;
    height:auto;
    max-height:280px;
    aspect-ratio:16/10;
    object-fit:cover;
  }

  .v4-build-head #photoBtn{
    margin-top:8px;
  }

  .vehicle-identity{
    order:2;
  }

  .vehicle-identity h1{
    font-size:38px;
    margin:7px 0;
  }

  .v4-quick-info{
    display:grid;
    grid-template-columns:1fr 1fr;
    gap:8px;
    margin-top:16px;
  }

  .v4-quick-info > div{
    min-width:0;
    padding:11px;
  }

  .v4-build-head .budget-pill{
    order:3;
  }

  .v4-action-row{
    position:sticky;
    bottom:10px;
    z-index:8;
    padding:10px;
    margin:12px 0 20px;
    background:rgba(13,17,21,.96);
    backdrop-filter:blur(12px);
    box-shadow:0 12px 35px rgba(0,0,0,.45);
  }

  .v4-action-row > div{
    display:none;
  }

  .v4-add-entry{
    width:100%;
    min-height:48px;
    font-size:15px;
  }

  .summary-grid{
    grid-template-columns:1fr 1fr;
    gap:8px;
  }

  .summary-grid article{
    padding:14px;
  }

  .summary-grid article:nth-child(3){
    grid-column:1/-1;
  }

  .summary-grid strong{
    font-size:21px;
  }

  .insights{
    gap:8px;
  }

  .insights article{
    min-width:0;
    padding:11px;
  }

  .insights small{
    font-size:9px;
  }

  .insights strong{
    font-size:20px;
  }

  .tabs{
    scrollbar-width:none;
  }

  .tabs::-webkit-scrollbar{
    display:none;
  }

}


/* ---------- VERY SMALL PHONES ---------- */

@media(max-width:390px){

  .header-inner .brand small{
    display:none;
  }

  .header-actions{
    gap:4px;
  }

  .header-actions button{
    font-size:11px;
    padding:7px;
  }

  .plan-badge{
    font-size:8px;
    padding:5px 7px;
  }

  .v4-quick-info{
    grid-template-columns:1fr;
  }

}
