����JFIF��`�`�����Viewing File: /home/u820193700/domains/thereown.com/public_html/test_out.txt
��<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8"/>

<meta name="viewport" content="width=device-width,initial-scale=1.0"/>

<title>Reown   Avahan Motors | Certified Pre-Owned Royal Enfield, Bengaluru</title>

<link href="https://fonts.googleapis.com/css2?family=Oswald:wght@400;500;600;700&family=Archivo:ital,wght@0,400;0,500;0,600;0,700;0,800;0,900;1,400&family=Fraunces:ital,opsz,wght@0,9..144,300;0,9..144,600;1,9..144,400&display=swap" rel="stylesheet"/>

<style>

:root{

  --bg:#fafaf8; --surface:#ffffff; --ink:#141412; --ink2:#4a4a46; --ink3:#8a8a82;

  --gold:#C8102E; --gold-dark:#9F0C24; --gold-bg:#FBEAED;

  --mustard:#EBAB00; --mustard-dark:#C68F00; --mustard-bg:#FCF3D9;

  --line:#e8e8e2; --line2:#d8d8d0;

  --green:#1a7a4a; --green-bg:#e8f5ee;

  --radius:20px; --radius-sm:12px; --pill:980px;

  --shadow-sm:0 1px 3px rgba(20,20,18,.06),0 1px 2px rgba(20,20,18,.04);

  --shadow-md:0 8px 30px rgba(20,20,18,.08);

  --shadow-lg:0 20px 60px rgba(20,20,18,.14);

}

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

html{scroll-behavior:smooth;}

body{font-family:'Archivo',sans-serif;font-weight:500;background:var(--bg);color:var(--ink);line-height:1.5;-webkit-font-smoothing:antialiased;}

button{font-family:inherit;cursor:pointer;border:none;background:none;}

input,select,textarea{font-family:inherit;}

img{display:block;max-width:100%;}



/* %%%%%%%%% NAV %%%%%%%%% */

nav{

  position:sticky;top:0;z-index:100;min-height:56px;

  background:rgba(250,250,248,.82);backdrop-filter:saturate(180%) blur(20px);-webkit-backdrop-filter:saturate(180%) blur(20px);

  border-bottom:1px solid rgba(0,0,0,.06);

  display:flex;align-items:center;justify-content:space-between;

  padding:0 max(24px,calc(50vw - 590px));

}

.nav-logo{font-weight:800;font-size:17px;letter-spacing:-.3px;display:flex;align-items:center;gap:8px;}

.nav-logo em{font-family:'Fraunces',serif;font-style:italic;font-weight:400;color:var(--gold);}

.nav-menu{display:flex;gap:4px;align-items:center;}

.nav-item{white-space:nowrap;flex-shrink:0;font-size:13.5px;font-weight:600;color:var(--ink2);padding:8px 14px;border-radius:var(--pill);transition:.2s;}

.nav-item:hover{background:rgba(0,0,0,.05);color:var(--ink);}

.nav-item.on{background:var(--ink);color:#fff;}

.admin-toggle{white-space:nowrap;flex-shrink:0;

  font-size:12px;font-weight:600;padding:7px 14px;border-radius:var(--pill);

  border:1.5px solid var(--line2);color:var(--ink3);transition:.2s;display:flex;align-items:center;gap:6px;

}

.admin-toggle:hover{border-color:var(--ink3);}

.admin-toggle.on{background:var(--gold);border-color:var(--gold);color:#fff;}

.admin-dot{width:6px;height:6px;border-radius:50%;background:currentColor;opacity:.6;}



/* %%%%%%%%% HERO (cinematic) %%%%%%%%% */

.hero{

  position:relative;min-height:min(72vh,640px);display:flex;align-items:flex-start;justify-content:flex-start;

  background:radial-gradient(ellipse 120% 90% at 70% 110%,#2a0810 0%,#0c0c0e 45%,#060607 100%);

  overflow:hidden;text-align:left;padding:70px max(24px,calc(50vw - 590px)) 60px;

}

.hero-bg{position:absolute;inset:0;display:flex;align-items:flex-end;justify-content:flex-end;background-size:cover;background-position:center;}

.hero-bike{width:min(700px,62vw);margin-right:-4%;opacity:.9;filter:drop-shadow(0 30px 60px rgba(200,16,46,.25));animation:heroFloat 7s ease-in-out infinite;}

@keyframes heroFloat{0%,100%{transform:translateY(0);}50%{transform:translateY(-10px);}}

.hero-shade{position:absolute;inset:0;background:linear-gradient(90deg,rgba(6,6,7,.82) 0%,rgba(6,6,7,.45) 45%,rgba(6,6,7,.1) 100%);}

.hero-inner{position:relative;z-index:2;max-width:560px;}

.hero-badge{

  display:inline-flex;align-items:center;gap:8px;font-size:11.5px;font-weight:600;

  background:rgba(235,171,0,.12);color:var(--mustard);border:1px solid rgba(235,171,0,.3);

  padding:8px 18px;border-radius:var(--pill);margin-bottom:26px;

  animation:rise .7s cubic-bezier(.2,.7,.3,1) both;backdrop-filter:blur(6px);

}

.hero h1{

  font-size:clamp(36px,5vw,60px);font-weight:600;letter-spacing:.8px;line-height:1.05;color:#fff;

  animation:rise .7s .06s cubic-bezier(.2,.7,.3,1) both;

  text-shadow:0 4px 40px rgba(0,0,0,.5);

}

.hero h1 em{color:var(--gold);font-style:normal;}

.hero-sub{

  font-size:clamp(13px,1.6vw,16px);color:rgba(255,255,255,.6);font-weight:500;margin:14px 0 28px;

  animation:rise .7s .12s cubic-bezier(.2,.7,.3,1) both;letter-spacing:.3px;

}

.hero-cta{display:flex;gap:12px;justify-content:flex-start;flex-wrap:wrap;animation:rise .7s .18s cubic-bezier(.2,.7,.3,1) both;}

.btn-hero-ghost{

  background:rgba(255,255,255,.08);color:#fff;border:1.5px solid rgba(255,255,255,.25);backdrop-filter:blur(6px);

}

.btn-hero-ghost:hover{border-color:var(--mustard);color:var(--mustard);transform:scale(1.03);}

.hero-upload{

  position:absolute;bottom:20px;right:20px;z-index:5;

  font-size:12px;font-weight:700;padding:9px 18px;border-radius:var(--pill);

  background:rgba(255,255,255,.12);color:#fff;border:1.5px solid rgba(255,255,255,.3);backdrop-filter:blur(8px);

}

.hero-upload:hover{background:var(--gold);border-color:var(--gold);}

.nav-by{

  font-family:'Archivo',sans-serif;font-size:9px;font-weight:600;letter-spacing:1.2px;text-transform:uppercase;

  color:var(--ink3);margin-left:10px;white-space:nowrap;

}

.nav-logo{display:flex;align-items:baseline;white-space:nowrap;}

@media(max-width: 840px){

  nav { flex-wrap: wrap; padding: 12px 16px; gap: 12px; }

  .nav-menu { width: 100%; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; -webkit-overflow-scrolling: touch; justify-content: flex-start; }

  .nav-menu::-webkit-scrollbar { display: none; }

}

@media(max-width:560px){.nav-by{display:none;}}

@media(max-width:640px){.hero{min-height:50vh;padding:54px 18px 44px;}.hero-bike{opacity:.5;width:130vw;margin-right:-30%;}.hero-inner{max-width:100%;}}

@keyframes rise{from{opacity:0;transform:translateY(22px);}to{opacity:1;transform:translateY(0);}}

.btn{

  font-size:15px;font-weight:600;padding:13px 28px;border-radius:var(--pill);transition:.25s;

  display:inline-flex;align-items:center;gap:8px;

}

.btn-dark{background:var(--ink);color:#fff;}

.btn-dark:hover{transform:scale(1.03);box-shadow:var(--shadow-md);}

.btn-light{background:#fff;color:var(--ink);border:1.5px solid var(--line2);}

.btn-light:hover{border-color:var(--ink3);transform:scale(1.03);}

.btn-gold{background:var(--gold);color:#fff;}

.btn-gold:hover{background:var(--gold-dark);transform:scale(1.03);}

.btn-sm{font-size:13px;padding:9px 18px;}

.btn-block{width:100%;justify-content:center;}



/* trust strip */

.trust{display:flex;justify-content:center;gap:36px;padding:0 24px 60px;flex-wrap:wrap;}

.trust div{display:flex;align-items:center;gap:9px;font-size:13.5px;font-weight:500;color:var(--ink2);}

.trust svg{width:18px;height:18px;stroke:var(--gold);}



/* %%%%%%%%% SECTIONS %%%%%%%%% */

.section{max-width:1180px;margin:0 auto;padding:70px 24px;}

.sec-head{display:flex;align-items:flex-end;justify-content:space-between;gap:20px;margin-bottom:36px;flex-wrap:wrap;}

.sec-head h2{font-size:clamp(28px,4vw,44px);font-weight:800;letter-spacing:-1.5px;}

.sec-head h2 em{font-family:'Fraunces',serif;font-weight:400;font-style:italic;color:var(--gold);}

.sec-head p{color:var(--ink3);font-size:15px;margin-top:6px;max-width:480px;}



/* chips */

.chips{display:flex;gap:8px;flex-wrap:wrap;margin-bottom:28px;}

.chip{

  font-size:13px;font-weight:500;padding:8px 18px;border-radius:var(--pill);

  background:#fff;border:1.5px solid var(--line);color:var(--ink2);transition:.2s;

}

.chip:hover{border-color:var(--line2);}

.chip.on{background:var(--ink);border-color:var(--ink);color:#fff;}



/* %%%%%%%%% BIKE GRID %%%%%%%%% */

.grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(min(100%, 330px), 1fr));gap:22px;}

.card{

  background:var(--surface);border-radius:var(--radius);overflow:hidden;

  box-shadow:var(--shadow-sm);cursor:pointer;transition:.35s cubic-bezier(.2,.7,.3,1);

  animation:rise .5s both;

}

.card:hover{transform:translateY(-5px);box-shadow:var(--shadow-lg);}

.card-media{

  aspect-ratio:4/3;position:relative;overflow:hidden;background:linear-gradient(160deg,#f2f0ea,#e8e6de);

  display:flex;align-items:center;justify-content:center;

}

.card-media img{width:100%;height:100%;object-fit:cover;transition:.5s;}

.card:hover .card-media img{transform:scale(1.04);}

.card-tag{

  position:absolute;top:14px;left:14px;font-size:11px;font-weight:700;

  background:rgba(255,255,255,.92);backdrop-filter:blur(8px);padding:5px 12px;border-radius:var(--pill);

  color:var(--green);display:flex;align-items:center;gap:5px;

}

.card-tag::before{content:'';width:6px;height:6px;border-radius:50%;background:var(--green);}

.tag-360{

  position:absolute;top:14px;right:14px;font-size:10.5px;font-weight:700;letter-spacing:.5px;

  background:rgba(20,20,18,.85);backdrop-filter:blur(8px);color:#fff;padding:5px 11px;border-radius:var(--pill);

  display:flex;align-items:center;gap:5px;

}

.photo-count{

  position:absolute;bottom:14px;right:14px;font-size:11px;font-weight:600;

  background:rgba(20,20,18,.7);backdrop-filter:blur(8px);color:#fff;padding:4px 10px;border-radius:var(--pill);

}

.card-body{padding:20px 22px 22px;}

.card-name{font-size:19px;font-weight:700;letter-spacing:-.4px;}

.card-variant{font-family:'Fraunces',serif;font-style:italic;font-weight:400;color:var(--ink3);font-size:15px;}

.card-meta{font-size:12px;color:var(--ink3);margin-top:4px;display:flex;gap:10px;}

.card-foot{display:flex;align-items:flex-end;justify-content:space-between;margin-top:16px;}

.card-price{font-size:22px;font-weight:800;letter-spacing:-.5px;}

.card-was{font-size:12px;color:var(--ink3);text-decoration:line-through;}

.card-save{font-size:11.5px;font-weight:600;color:var(--green);margin-top:1px;}

.upload-hint{

  position:absolute;inset:0;background:rgba(154,123,30,.92);backdrop-filter:blur(4px);

  display:flex;flex-direction:column;align-items:center;justify-content:center;gap:8px;

  color:#fff;font-weight:600;font-size:14px;opacity:0;transition:.25s;

}

.card.admin .card-media:hover .upload-hint{opacity:1;}

.upload-hint svg{width:28px;height:28px;stroke:#fff;}



/* placeholder art */

.ph-art{width:70%;opacity:.5;}



/* %%%%%%%%% MODALS %%%%%%%%% */

.overlay{

  position:fixed;inset:0;z-index:400;background:rgba(20,20,18,.4);backdrop-filter:blur(8px);

  display:none;overflow-y:auto;padding:32px 16px;

  animation:fadeIn .25s;

}

.overlay.open{display:block;}

@keyframes fadeIn{from{opacity:0}to{opacity:1}}

.sheet{

  max-width:1080px;margin:0 auto;background:var(--surface);border-radius:28px;

  box-shadow:var(--shadow-lg);overflow:hidden;position:relative;

  animation:sheetUp .4s cubic-bezier(.2,.7,.3,1);

}

@keyframes sheetUp{from{opacity:0;transform:translateY(36px) scale(.98);}to{opacity:1;transform:none;}}

@keyframes shake{0%,100%{transform:translateX(0);}20%{transform:translateX(-10px);}40%{transform:translateX(10px);}60%{transform:translateX(-7px);}80%{transform:translateX(7px);}}

.sheet-sm{max-width:520px;}

.sheet-md{max-width:760px;}

.x{

  position:absolute;top:18px;right:18px;z-index:10;width:36px;height:36px;border-radius:50%;

  background:rgba(20,20,18,.06);display:flex;align-items:center;justify-content:center;

  font-size:15px;color:var(--ink2);transition:.2s;

}

.x:hover{background:rgba(20,20,18,.12);transform:scale(1.06);}



/* %%%%%%%%% 360 / GALLERY VIEWER %%%%%%%%% */

.viewer{background:#f4f2ec;position:relative;user-select:none;}

.stage{

  aspect-ratio:16/9;max-height:520px;width:100%;position:relative;overflow:hidden;

  display:flex;align-items:center;justify-content:center;cursor:grab;touch-action:pan-y;

}

.stage.grabbing{cursor:grabbing;}

.stage img{width:100%;height:100%;object-fit:contain;pointer-events:none;}

.stage .ph-art{width:46%;}

.mode-pill{

  position:absolute;top:16px;left:16px;display:flex;background:rgba(255,255,255,.9);backdrop-filter:blur(10px);

  border-radius:var(--pill);padding:3px;box-shadow:var(--shadow-sm);z-index:5;

}

.mode-btn{font-size:12px;font-weight:600;padding:6px 16px;border-radius:var(--pill);color:var(--ink3);transition:.2s;}

.mode-btn.on{background:var(--ink);color:#fff;}

.deg-badge{

  position:absolute;top:16px;right:16px;font-size:12px;font-weight:700;

  background:rgba(20,20,18,.8);color:#fff;padding:6px 14px;border-radius:var(--pill);z-index:5;

  font-variant-numeric:tabular-nums;

}

.drag-hint{

  position:absolute;bottom:18px;left:50%;transform:translateX(-50%);

  display:flex;align-items:center;gap:8px;font-size:12px;font-weight:600;color:var(--ink2);

  background:rgba(255,255,255,.88);backdrop-filter:blur(10px);padding:8px 18px;border-radius:var(--pill);

  box-shadow:var(--shadow-sm);pointer-events:none;z-index:5;transition:opacity .3s;

}

.frame-bar{

  position:absolute;bottom:0;left:0;right:0;height:3px;background:rgba(0,0,0,.06);z-index:5;

}

.frame-fill{height:100%;background:var(--gold);transition:width .05s linear;}

.gallery-nav{

  position:absolute;top:50%;transform:translateY(-50%);width:42px;height:42px;border-radius:50%;

  background:rgba(255,255,255,.92);backdrop-filter:blur(8px);box-shadow:var(--shadow-sm);

  display:flex;align-items:center;justify-content:center;font-size:16px;z-index:5;transition:.2s;

}

.gallery-nav:hover{transform:translateY(-50%) scale(1.08);}

.gnav-l{left:16px;}.gnav-r{right:16px;}

.thumbs{display:flex;gap:8px;padding:14px 16px;overflow-x:auto;background:#fff;border-top:1px solid var(--line);}

.thumb{

  width:74px;height:52px;border-radius:10px;overflow:hidden;flex-shrink:0;cursor:pointer;

  border:2px solid transparent;transition:.2s;background:#f0eee8;position:relative;

  display:flex;align-items:center;justify-content:center;

}

.thumb img{width:100%;height:100%;object-fit:cover;}

.thumb.on{border-color:var(--gold);}

.thumb-add{

  border:2px dashed var(--line2);color:var(--ink3);font-size:11px;font-weight:600;

  flex-direction:column;gap:2px;

}

.thumb-add:hover{border-color:var(--gold);color:var(--gold);}

.empty-stage{

  display:flex;flex-direction:column;align-items:center;gap:14px;color:var(--ink3);

}

.empty-stage p{font-size:14px;font-weight:500;}



/* detail body */

.detail-body{display:grid;grid-template-columns:1.5fr 1fr;gap:0;}

.detail-left{padding:32px 36px;border-right:1px solid var(--line);}

.detail-right{padding:32px 32px;background:#fcfcfa;}

.d-name{font-size:30px;font-weight:800;letter-spacing:-1px;}

.d-variant{font-family:'Fraunces',serif;font-style:italic;font-size:19px;color:var(--ink3);margin-bottom:20px;}

.spec-row{display:grid;grid-template-columns:repeat(4,1fr);gap:10px;margin-bottom:26px;}

.spec{background:#f6f5f0;border-radius:var(--radius-sm);padding:14px 10px;text-align:center;}

.spec b{font-size:16px;font-weight:700;display:block;letter-spacing:-.3px;}

.spec span{font-size:10px;font-weight:600;color:var(--ink3);text-transform:uppercase;letter-spacing:1px;}

.check-list{display:grid;grid-template-columns:1fr 1fr;gap:8px;}

.check-item{display:flex;align-items:center;gap:9px;font-size:13.5px;color:var(--ink2);padding:7px 0;}

.check-item svg{width:17px;height:17px;stroke:var(--green);flex-shrink:0;}

/* accordion checklist */

.acc{border:1.5px solid var(--line);border-radius:var(--radius-sm);overflow:hidden;}

.acc-item{border-bottom:1px solid var(--line);}

.acc-item:last-child{border-bottom:none;}

.acc-head{

  width:100%;display:flex;align-items:center;justify-content:space-between;

  padding:12px 16px;font-size:14px;font-weight:600;color:var(--ink);

  background:#fff;transition:background .15s;text-align:left;

}

.acc-head:hover{background:#fbfaf6;}

.acc-plus{

  font-size:18px;font-weight:400;color:var(--ink3);transition:transform .25s;

  width:22px;height:22px;display:flex;align-items:center;justify-content:center;

}

.acc-item.open .acc-plus{transform:rotate(45deg);color:var(--gold);}

.acc-body{

  max-height:0;overflow:hidden;transition:max-height .3s cubic-bezier(.2,.7,.3,1);

  background:#fbfaf6;

}

.acc-item.open .acc-body{max-height:240px;}

.acc-sub{

  font-size:13px;color:var(--ink2);padding:6px 16px 6px 43px;

}

.acc-item.open .acc-sub:last-child{padding-bottom:14px;}

.d-label{font-size:11px;font-weight:700;letter-spacing:1.5px;text-transform:uppercase;color:var(--ink3);margin-bottom:14px;}

.d-price{font-size:36px;font-weight:900;letter-spacing:-1.5px;}

.d-was{font-size:14px;color:var(--ink3);}

.d-was s{margin-right:8px;}

.d-save{color:var(--green);font-weight:600;}

.emi-box{background:#fff;border:1.5px solid var(--line);border-radius:var(--radius-sm);padding:18px;margin:20px 0;}

.emi-num{font-size:26px;font-weight:800;letter-spacing:-1px;text-align:center;margin:10px 0 4px;}

.emi-note{font-size:11.5px;color:var(--ink3);text-align:center;}

.seg{display:flex;background:#f2f1ec;border-radius:var(--pill);padding:3px;margin-top:8px;}

.seg button{flex:1;font-size:12px;font-weight:600;padding:7px 0;border-radius:var(--pill);color:var(--ink3);transition:.2s;}

.seg button.on{background:#fff;color:var(--ink);box-shadow:var(--shadow-sm);}

.stack{display:flex;flex-direction:column;gap:10px;margin-top:18px;}

.mono{font-size:12px;color:var(--ink3);font-variant-numeric:tabular-nums;}



/* %%%%%%%%% UPLOAD MANAGER %%%%%%%%% */

.up-head{padding:30px 36px 0;}

.up-title{font-size:24px;font-weight:800;letter-spacing:-.7px;}

.up-sub{font-size:14px;color:var(--ink3);margin-top:4px;}

.up-tabs{display:flex;gap:6px;padding:20px 36px 0;}

.up-tab{

  font-size:13.5px;font-weight:600;padding:10px 20px;border-radius:var(--pill);color:var(--ink3);transition:.2s;

  display:flex;align-items:center;gap:7px;

}

.up-tab.on{background:var(--ink);color:#fff;}

.up-count{font-size:11px;background:rgba(0,0,0,.1);padding:1px 8px;border-radius:var(--pill);}

.up-tab.on .up-count{background:rgba(255,255,255,.2);}

.up-body{padding:24px 36px 36px;}

.dropzone{

  border:2px dashed var(--line2);border-radius:var(--radius);padding:44px 24px;text-align:center;

  transition:.25s;cursor:pointer;background:#fcfcfa;

}

.dropzone:hover,.dropzone.drag{border-color:var(--gold);background:var(--gold-bg);}

.dz-icon{

  width:52px;height:52px;border-radius:50%;background:var(--gold-bg);margin:0 auto 14px;

  display:flex;align-items:center;justify-content:center;transition:.25s;

}

.dropzone.drag .dz-icon{transform:scale(1.1);}

.dz-icon svg{width:24px;height:24px;stroke:var(--gold);}

.dz-title{font-size:16px;font-weight:700;letter-spacing:-.3px;}

.dz-sub{font-size:13px;color:var(--ink3);margin-top:4px;}

.dz-sub b{color:var(--gold);}

.preview-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(120px,1fr));gap:10px;margin-top:18px;}

.pv{

  aspect-ratio:4/3;border-radius:var(--radius-sm);overflow:hidden;position:relative;

  background:#f0eee8;animation:pop .3s cubic-bezier(.2,.7,.3,1);

}

@keyframes pop{from{opacity:0;transform:scale(.9);}to{opacity:1;transform:scale(1);}}

.pv img{width:100%;height:100%;object-fit:cover;}

.pv-x{

  position:absolute;top:6px;right:6px;width:24px;height:24px;border-radius:50%;

  background:rgba(20,20,18,.75);color:#fff;font-size:11px;

  display:flex;align-items:center;justify-content:center;opacity:0;transition:.2s;

}

.pv:hover .pv-x{opacity:1;}

.pv-n{

  position:absolute;bottom:6px;left:6px;font-size:10px;font-weight:700;

  background:rgba(20,20,18,.75);color:#fff;padding:2px 8px;border-radius:var(--pill);

}

.pv-star{

  position:absolute;top:6px;left:6px;font-size:10px;font-weight:700;

  background:rgba(20,20,18,.78);color:#fff;padding:4px 9px;border-radius:980px;

  opacity:0;transition:.2s;

}

.pv:hover .pv-star{opacity:1;}

.pv-star:hover{background:var(--gold);}

@media(hover:none){.pv-star{opacity:1;}}

.pv-cover{

  position:absolute;top:6px;left:6px;font-size:9.5px;font-weight:700;

  background:var(--gold);color:#fff;padding:3px 8px;border-radius:var(--pill);

}

.up-tip{

  display:flex;gap:12px;background:var(--gold-bg);border-radius:var(--radius-sm);

  padding:14px 16px;margin-top:18px;font-size:13px;color:var(--gold-dark);line-height:1.55;

}

.up-tip svg{width:18px;height:18px;stroke:var(--gold);flex-shrink:0;margin-top:2px;}



/* %%%%%%%%% SELL FLOW %%%%%%%%% */

.sell-wrap{max-width:680px;margin:0 auto;}

.steps{display:flex;align-items:center;gap:0;margin-bottom:36px;}

.step{display:flex;align-items:center;gap:10px;flex:1;}

.step-dot{

  width:32px;height:32px;border-radius:50%;background:#eeede8;color:var(--ink3);

  display:flex;align-items:center;justify-content:center;font-size:13px;font-weight:700;

  transition:.3s;flex-shrink:0;

}

.step.on .step-dot{background:var(--ink);color:#fff;}

.step.done .step-dot{background:var(--green);color:#fff;}

.step-name{font-size:13px;font-weight:600;color:var(--ink3);}

.step.on .step-name{color:var(--ink);}

.step-line{flex:1;height:2px;background:#eeede8;margin:0 12px;}

.step.done + .step .step-line{background:var(--green);}

.sell-card{background:#fff;border-radius:var(--radius);box-shadow:var(--shadow-sm);padding:32px;}

.f-row{margin-bottom:16px;}

.f-label{font-size:12.5px;font-weight:600;color:var(--ink2);margin-bottom:7px;display:block;}

.f-inp{

  width:100%;font-size:15px;padding:13px 16px;border-radius:var(--radius-sm);

  border:1.5px solid var(--line);background:#fcfcfa;transition:.2s;outline:none;color:var(--ink);

}

.f-inp:focus{border-color:var(--gold);background:#fff;box-shadow:0 0 0 4px rgba(154,123,30,.08);}

.f-2col{display:grid;grid-template-columns:1fr 1fr;gap:12px;}

.estimate-card{

  text-align:center;padding:36px 24px;background:linear-gradient(160deg,#fdfcf8,var(--gold-bg));

  border-radius:var(--radius);border:1.5px solid #ece2c2;

}

.est-label{font-size:12px;font-weight:700;letter-spacing:1.5px;text-transform:uppercase;color:var(--gold-dark);}

.est-value{font-family:'Fraunces',serif;font-size:46px;font-weight:600;letter-spacing:-1px;margin:10px 0 4px;}

.est-range{font-size:14px;color:var(--ink2);}

.est-note{font-size:12px;color:var(--ink3);margin-top:14px;max-width:380px;margin-left:auto;margin-right:auto;line-height:1.6;}



/* %%%%%%%%% HOW IT WORKS %%%%%%%%% */

.how{display:grid;grid-template-columns:repeat(3,1fr);gap:20px;}

.how-card{background:#fff;border-radius:var(--radius);padding:30px 26px;box-shadow:var(--shadow-sm);transition:.3s;}

.how-card:hover{transform:translateY(-4px);box-shadow:var(--shadow-md);}

.how-num{

  font-family:'Fraunces',serif;font-size:15px;font-weight:600;color:var(--gold);

  width:34px;height:34px;border-radius:50%;background:var(--gold-bg);

  display:flex;align-items:center;justify-content:center;margin-bottom:16px;

}

.how-card h3{font-size:17px;font-weight:700;letter-spacing:-.3px;margin-bottom:6px;}

.how-card p{font-size:13.5px;color:var(--ink2);line-height:1.6;}



/* %%%%%%%%% FOOTER %%%%%%%%% */

footer{border-top:1px solid var(--line);margin-top:40px;padding:44px 24px;text-align:center;}

.foot-logo{font-weight:800;font-size:18px;letter-spacing:-.4px;}

.foot-logo em{font-family:'Fraunces',serif;font-style:italic;font-weight:400;color:var(--gold);}

footer p{font-size:12.5px;color:var(--ink3);margin-top:8px;}



/* %%%%%%%%% TOAST %%%%%%%%% */

.toast{

  position:fixed;bottom:28px;left:50%;transform:translate(-50%,80px);z-index:600;

  background:var(--ink);color:#fff;font-size:14px;font-weight:500;

  padding:14px 26px;border-radius:var(--pill);box-shadow:var(--shadow-lg);

  transition:transform .4s cubic-bezier(.2,.7,.3,1);display:flex;align-items:center;gap:10px;

  max-width:calc(100vw - 40px);

}

.toast.show{transform:translate(-50%,0);}

.toast svg{width:18px;height:18px;stroke:#4ade80;flex-shrink:0;}



/* whatsapp fab */

.fab-call{bottom:88px!important;background:var(--gold)!important;box-shadow:0 8px 24px rgba(200,16,46,.4)!important;text-decoration:none;}

.fab{

  position:fixed;bottom:24px;right:24px;z-index:300;width:54px;height:54px;border-radius:50%;

  background:#25D366;display:flex;align-items:center;justify-content:center;

  box-shadow:0 8px 24px rgba(37,211,102,.4);transition:.25s;

}

.fab:hover{transform:scale(1.1);}

.fab svg{width:26px;height:26px;fill:#fff;}



::-webkit-scrollbar{width:5px;height:5px;}

::-webkit-scrollbar-thumb{background:var(--line2);border-radius:3px;}



@media(max-width:840px){

  .fab{width:48px;height:48px;bottom:16px;right:16px;}

  .fab-call{bottom:72px!important;}

  .fab svg{width:22px;height:22px;}

  .section{padding-bottom:56px;}

  .detail-body{grid-template-columns:1fr;}

  .detail-left{border-right:none;border-bottom:1px solid var(--line);padding:24px 22px;}

  .detail-right{padding:24px 22px;}

  /* .nav-menu .nav-item{white-space:nowrap;flex-shrink:0;display:none;} removed for mobile */

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

  .spec-row{grid-template-columns:1fr 1fr;}

  .f-2col{grid-template-columns:1fr;}

  .steps .step-name{display:none;}

  .up-head,.up-body{padding-left:20px;padding-right:20px;}

  .up-tabs{padding-left:20px;}

  .sell-card{padding:22px;}

  .sheet{border-radius:20px;}

  .overlay{padding:16px 10px;}

}





/* new arrivals strip */

@keyframes pulse{0%,100%{opacity:1;transform:scale(1);}50%{opacity:.4;transform:scale(.8);}}

.arrivals-row{display:flex;gap:16px;overflow-x:auto;padding:4px 4px 20px;scroll-snap-type:x mandatory;}

.arr-card{

  min-width:250px;max-width:250px;scroll-snap-align:start;background:#fff;border-radius:var(--radius-sm);

  overflow:hidden;box-shadow:var(--shadow-sm);cursor:pointer;transition:.3s;position:relative;

}

.arr-card:hover{transform:translateY(-3px);box-shadow:var(--shadow-md);}

.arr-media{aspect-ratio:16/10;background:linear-gradient(160deg,#f2f0ea,#e8e6de);display:flex;align-items:center;justify-content:center;position:relative;overflow:hidden;}

.arr-media img{width:100%;height:100%;object-fit:cover;}

.arr-media .ph-art{width:82%;}

.arr-new{

  position:absolute;top:10px;left:10px;font-size:9.5px;font-weight:700;letter-spacing:1.5px;

  background:var(--gold);color:#fff;padding:4px 10px;border-radius:var(--pill);

  font-family:'Oswald',sans-serif;text-transform:uppercase;

}

.arr-body{padding:14px 16px 16px;}

.arr-name{font-family:'Oswald',sans-serif;text-transform:uppercase;font-size:15px;font-weight:600;letter-spacing:.4px;}

.arr-meta{font-size:11.5px;color:var(--ink3);margin-top:2px;}

.arr-price{font-family:'Oswald',sans-serif;font-size:17px;font-weight:600;margin-top:8px;}

.arr-days{font-size:11px;font-weight:600;color:var(--green);margin-top:2px;}

.badge-newcard{

  position:absolute;bottom:14px;left:14px;font-size:9.5px;font-weight:700;letter-spacing:1.5px;

  background:var(--mustard);color:#141412;padding:4px 10px;border-radius:var(--pill);

  font-family:'Oswald',sans-serif;text-transform:uppercase;

}





/* booking status */

.tag-booked{color:#a06a00!important;}

.tag-booked::before{background:#e8a000!important;}

.tag-sold{color:#b03030!important;}

.tag-sold::before{background:#b03030!important;}

.card.st-sold .card-media img,.card.st-sold .ph-art{filter:grayscale(.85) opacity(.75);}

.card.st-sold{opacity:.78;}

.card.st-booked .card-media img,.card.st-booked .ph-art{filter:saturate(.75);}

.status-banner{

  display:flex;align-items:center;gap:10px;padding:12px 16px;border-radius:var(--radius-sm);

  font-size:13px;font-weight:600;margin-bottom:16px;

}

.sb-booked{background:#FDF3DC;color:#8a5c00;border:1.5px solid #eed9a0;}

.sb-sold{background:#FBEAEA;color:#8a2020;border:1.5px solid #ecc0c0;}

.st-pills{display:flex;gap:6px;}

.st-pill{

  font-size:11px;font-weight:700;letter-spacing:1px;text-transform:uppercase;

  padding:7px 14px;border-radius:var(--pill);border:1.5px solid var(--line);color:var(--ink3);transition:.2s;

  font-family:'Oswald',sans-serif;

}

.st-pill.on-available{background:var(--green);border-color:var(--green);color:#fff;}

.st-pill.on-booked{background:#e8a000;border-color:#e8a000;color:#fff;}

.st-pill.on-sold{background:#b03030;border-color:#b03030;color:#fff;}

.rules-list{counter-reset:rule;}

.rule-item{display:flex;gap:16px;padding:18px 0;border-bottom:1px solid var(--line);}

.rule-item:last-child{border-bottom:none;}

.rule-num{

  counter-increment:rule;font-family:'Oswald',sans-serif;font-weight:600;font-size:14px;

  width:34px;height:34px;border-radius:50%;background:var(--gold-bg);color:var(--gold);

  display:flex;align-items:center;justify-content:center;flex-shrink:0;

}

.rule-num::before{content:counter(rule);}

.rule-t{font-size:15px;font-weight:700;letter-spacing:-.2px;}

.rule-d{font-size:13.5px;color:var(--ink2);margin-top:3px;line-height:1.6;}





/* delivery wall marquee */

.dwall{background:#0c0c0e;border-top:1px solid #1c1c20;border-bottom:1px solid var(--line);padding:22px 0 26px;overflow:hidden;}

.dwall-head{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:0 24px;margin-bottom:16px;max-width:1180px;margin-left:auto;margin-right:auto;}

.dwall-title{font-family:'Oswald',sans-serif;text-transform:uppercase;font-size:13px;font-weight:600;letter-spacing:1.5px;color:var(--mustard);}

.marquee{overflow:hidden;position:relative;}

.marquee::before,.marquee::after{content:'';position:absolute;top:0;bottom:0;width:70px;z-index:2;pointer-events:none;}

.marquee::before{left:0;background:linear-gradient(90deg,#0c0c0e,transparent);}

.marquee::after{right:0;background:linear-gradient(-90deg,#0c0c0e,transparent);}

.marquee-track{display:flex;gap:14px;width:max-content;animation:mscroll 40s linear infinite;}

.marquee:hover .marquee-track{animation-play-state:paused;}

@keyframes mscroll{from{transform:translateX(0);}to{transform:translateX(-50%);}}

.dcard{

  width:210px;flex-shrink:0;border-radius:14px;overflow:hidden;background:#16161a;

  border:1px solid #26262c;

  transition: transform 0.1s ease, box-shadow 0.1s ease, border-color 0.1s ease;

  cursor: pointer;

}

.dcard:hover{

  transform: translateY(-4px);

  box-shadow: 0 12px 24px rgba(0,0,0,0.6);

  border-color: var(--mustard);

}

.dcard-img{aspect-ratio:4/3;position:relative;overflow:hidden;display:flex;align-items:center;justify-content:center;background:linear-gradient(160deg,#1c1c22,#101014);}

.dcard-img img{width:100%;height:100%;object-fit:cover; transition: transform 0.15s ease;}

.dcard:hover .dcard-img img{transform: scale(1.03);}

.dcard-img .ph-art{width:85%;opacity:.85;}

.dcard-tick{

  position:absolute;top:8px;right:8px;font-size:9px;font-weight:700;letter-spacing:1px;

  background:var(--green);color:#fff;padding:3px 9px;border-radius:980px;

  font-family:'Oswald',sans-serif;text-transform:uppercase;

}

.dcard-cap{padding:10px 12px;}

.dcard-name{font-family:'Oswald',sans-serif;text-transform:uppercase;font-size:12px;font-weight:600;letter-spacing:.5px;color:#f0ece4;}

.dcard-sub{font-size:10.5px;color:#77777e;margin-top:2px;}

@media(max-width:640px){.dcard{width:170px;}.marquee-track{animation-duration:30s;}}





/* accessories chips */

.acc-chips{display:flex;flex-wrap:wrap;gap:5px;margin-top:9px;}

.acc-chip{

  font-size:10px;font-weight:700;letter-spacing:.3px;

  background:var(--mustard-bg);color:#7a5c00;border:1px solid #eeddb0;

  padding:3px 9px;border-radius:980px;white-space:nowrap;

}

.acc-chip-lg{font-size:11.5px;padding:5px 12px;}



/* P%P%P% ROYAL ENFIELD BRAND LAYER P%P%P% */

/* Condensed uppercase display type, crest red + mustard gold accents */

.hero h1,.sec-head h2,.nav-logo,.foot-logo,.up-title,.d-name,.card-name,.d-price,.card-price,.est-value{

  font-family:'Oswald',sans-serif;text-transform:uppercase;

}

.hero h1{font-weight:700;letter-spacing:.5px;line-height:1.04;}

.sec-head h2{font-weight:700;letter-spacing:.5px;}

.hero h1 em,.sec-head h2 em{font-family:'Oswald',sans-serif;font-style:normal;color:var(--gold);}

.nav-logo{font-weight:700;letter-spacing:2px;line-height:1;}

.nav-logo em,.foot-logo em{font-family:'Oswald',sans-serif;font-style:normal;font-weight:400;color:var(--gold);}

.card-name{font-weight:700;letter-spacing:.5px;font-size:18px;}

.card-variant{font-family:'Archivo',sans-serif;font-style:normal;text-transform:none;font-size:13px;font-weight:500;color:var(--ink3);}

.d-variant{font-family:'Archivo',sans-serif;font-style:normal;font-weight:500;font-size:15px;}

.d-price,.card-price{font-weight:700;letter-spacing:.5px;}

.est-value{font-weight:600;color:var(--gold);}

.how-num{font-family:'Oswald',sans-serif;font-style:normal;font-weight:600;background:var(--mustard-bg);color:var(--mustard-dark);}

.hero-badge{background:var(--mustard-bg);color:var(--mustard-dark);border:1px solid #f0dfa8;text-transform:uppercase;letter-spacing:1px;font-size:11.5px;font-family:'Oswald',sans-serif;font-weight:500;}

.trust svg{stroke:var(--gold);}

.step.on .step-dot{background:var(--gold);}

.nav-item.on{background:var(--gold);}

.chip.on{background:var(--gold);border-color:var(--gold);}

.btn-dark{background:var(--gold);}

.btn-dark:hover{background:var(--gold-dark);}

.btn-gold{background:var(--ink);}

.btn-gold:hover{background:#000;}

.thumb.on{border-color:var(--gold);}

.frame-fill{background:var(--gold);}

.mode-btn.on{background:var(--gold);}

.up-tab.on{background:var(--gold);}

.dz-icon{background:var(--gold-bg);}

.dz-icon svg{stroke:var(--gold);}

.dropzone:hover,.dropzone.drag{border-color:var(--gold);background:#FDF6F7;}

.dz-sub b{color:var(--gold);}

.pv-cover{background:var(--gold);}

.f-inp:focus{border-color:var(--gold);box-shadow:0 0 0 4px rgba(200,16,46,.08);}

.estimate-card{background:linear-gradient(160deg,#fffdf6,var(--mustard-bg));border-color:#efe0b0;}

.est-label{color:var(--mustard-dark);}

.up-tip{background:var(--mustard-bg);color:#7a5c00;}

.up-tip svg{stroke:var(--mustard-dark);}

/* mustard divider under section titles */

.sec-head h2{position:relative;padding-bottom:14px;}

.sec-head h2::after{content:'';position:absolute;left:0;bottom:0;width:56px;height:4px;background:var(--gold);}

.sec-head h2::before{content:'';position:absolute;left:60px;bottom:0;width:18px;height:4px;background:var(--mustard);}

</style>

</head>

<body>



<!-- NAV -->

<nav>

  <div class="nav-logo" style="cursor:pointer;" onclick="window.scrollTo({top:0, behavior:'smooth'})"><em>RE</em>OWN<span class="nav-by">Authorized Partner &middot; Avahan Motors, Bengaluru</span></div>

  <div class="nav-menu">

    <button class="nav-item on" onclick="go('buy',this)">Buy</button>

    <button class="nav-item" onclick="go('sell',this)">Sell</button>

    <button class="nav-item" onclick="openRules()">Booking rules</button>

    <button class="nav-item" onclick="go('how',this)">How it works</button>

    <button class="btn btn-dark" id="headerDashBtn" style="display:none; font-size:12px; padding:6px 12px; white-space:nowrap;" onclick="openStaffDashboard()">=��� Dashboard</button>

    <button class="admin-toggle" id="adminBtn" onclick="toggleAdmin()">

      <span class="admin-dot"></span><span id="adminLabel">Staff login</span>

    </button>

  </div>

</nav>



<!-- HERO -->

<header class="hero" id="heroSec">

  <div class="hero-bg" id="heroBg" >

    <svg class="hero-bike"  viewBox="0 0 900 480" fill="none">

      <defs>

        <linearGradient id="hTank" x1="0" y1="0" x2="0" y2="1">

          <stop offset="0%" stop-color="#C8102E"/><stop offset="60%" stop-color="#8a0a20"/><stop offset="100%" stop-color="#3a040d"/>

        </linearGradient>

        <radialGradient id="hGlow" cx="55%" cy="55%" r="60%">

          <stop offset="0%" stop-color="#C8102E" stop-opacity=".22"/><stop offset="55%" stop-color="#EBAB00" stop-opacity=".06"/><stop offset="100%" stop-opacity="0"/>

        </radialGradient>

      </defs>

      <rect width="900" height="480" fill="url(#hGlow)"/>

      <ellipse cx="460" cy="420" rx="380" ry="20" fill="#000" opacity=".5"/>

      <circle cx="235" cy="345" r="102" stroke="#0c0c0c" stroke-width="30"/>

      <circle cx="235" cy="345" r="102" stroke="#3a3a40" stroke-width="7"/>

      <circle cx="235" cy="345" r="52" stroke="#55555c" stroke-width="4"/>

      <circle cx="235" cy="345" r="13" fill="#77777e"/>

      <circle cx="685" cy="345" r="102" stroke="#0c0c0c" stroke-width="30"/>

      <circle cx="685" cy="345" r="102" stroke="#3a3a40" stroke-width="7"/>

      <circle cx="685" cy="345" r="52" stroke="#55555c" stroke-width="4"/>

      <circle cx="685" cy="345" r="13" fill="#77777e"/>

      <path d="M235 243 L340 155 L480 125 L600 145 L685 243" stroke="#26262c" stroke-width="13"/>

      <path d="M340 155 L392 243 L235 243" stroke="#26262c" stroke-width="9"/>

      <ellipse cx="470" cy="146" rx="118" ry="42" fill="url(#hTank)" stroke="#000" stroke-width="4"/>

      <ellipse cx="452" cy="132" rx="62" ry="15" fill="#fff" opacity=".14"/>

      <path d="M368 152 Q470 118 572 152" stroke="#EBAB00" stroke-width="4"/>

      <circle cx="470" cy="146" r="15" fill="#EBAB00"/>

      <circle cx="470" cy="146" r="15" stroke="#0c0c0c" stroke-width="2.5"/>

      <path d="M348 172 Q470 140 592 172" stroke="#0c0c0c" stroke-width="9"/>

      <path d="M600 145 L655 92 L718 82" stroke="#26262c" stroke-width="8"/>

      <circle cx="705" cy="170" r="27" fill="#F2E9CE" stroke="#0c0c0c" stroke-width="6"/>

      <circle cx="705" cy="170" r="14" fill="#fff" opacity=".7"/>

      <rect x="388" y="208" width="132" height="92" rx="12" fill="#1c1c22" stroke="#000" stroke-width="4"/>

      <rect x="402" y="222" width="104" height="10" rx="5" fill="#3f3f46"/>

      <rect x="402" y="242" width="104" height="10" rx="5" fill="#3f3f46"/>

      <rect x="402" y="262" width="104" height="10" rx="5" fill="#3f3f46"/>

      <path d="M400 325 Q310 318 245 368" stroke="#8a8a92" stroke-width="11"/>

      <path d="M330 168 Q470 142 590 168" stroke="#EBAB00" stroke-width="2" opacity=".6"/>

    </svg>

  </div>

  <div class="hero-shade"></div>

  <div class="hero-inner">

    <div class="hero-badge">&' &nbsp;12 certified motorcycles � Bengaluru � Showroom &amp; Service Centre</div>

    <h1>Re-Own the <em>Legend.</em></h1>

    <div class="hero-sub">India&rsquo;s certified pre-owned Royal Enfield programme &mdash; now in Bengaluru</div>

    <div class="hero-cta">

      <button class="btn btn-dark" onclick="go('buy')">Browse bikes</button>

      <button class="btn btn-hero-ghost" onclick="go('sell')">Sell your bike</button>

    </div>

  </div>

  <button class="hero-upload" id="heroUploadBtn" style="display:none;" onclick="document.getElementById('heroFile').click()">=�� Set hero photo</button>

  <input type="file" id="heroFile" accept="image/*" hidden onchange="setHeroPhoto(this.files)"/>

</header>



<!-- P%P%P%P%P%P%P% DELIVERY WALL (auto-scrolling) P%P%P%P%P%P%P% -->

<section class="dwall">

  <div class="dwall-head">

    <span class="dwall-title"><���� Recent deliveries   legends finding new riders</span>

    <button class="btn btn-sm" id="dwallAdd" style="display:none;background:var(--gold);color:#fff;" onclick="document.getElementById('dwallFile').click()">+ Add delivery photo</button>

    <input type="file" id="dwallFile" accept="image/*" multiple hidden onchange="addDeliveries(this.files)"/>

  </div>

  <div class="marquee">

    <div class="marquee-track" id="dwallTrack"></div>

  </div>

</section>





<div class="trust">

  <div><svg fill="none" stroke-width="2" viewBox="0 0 24 24"><path d="M13 10V3L4 14h7v7l9-11h-7z" stroke-linecap="round" stroke-linejoin="round"/></svg><b style="color:var(--gold);">100-min delivery</b>&nbsp;in Bengaluru</div>

  <div><svg fill="none" stroke-width="2" viewBox="0 0 24 24"><path d="M4 4v5h5M20 20v-5h-5M4 9a8 8 0 0114-3M20 15a8 8 0 01-14 3" stroke-linecap="round" stroke-linejoin="round"/></svg>6-month buyback @ 80%</div>

  <div><svg fill="none" stroke-width="2" viewBox="0 0 24 24"><path d="M8 7h12m0 0l-4-4m4 4l-4 4M16 17H4m0 0l4 4m-4-4l4-4" stroke-linecap="round" stroke-linejoin="round"/></svg>Instant exchange</div>

  <div><svg fill="none" stroke-width="2" viewBox="0 0 24 24"><path d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z" stroke-linecap="round" stroke-linejoin="round"/></svg>Reown 200-checkpoint Certified</div>

  <div><svg fill="none" stroke-width="2" viewBox="0 0 24 24"><path d="M12 8v8m-4-4h8M21 12a9 9 0 11-18 0 9 9 0 0118 0z" stroke-linecap="round" stroke-linejoin="round"/></svg>EMI from � 2,500/mo</div>

</div>



<!-- P%P%P%P%P%P%P% BUY P%P%P%P%P%P%P% -->

<section class="section" id="buy">

  <div class="sec-head">

    <div>

      <h2>The <em>showroom</em></h2>

      <p>Tap any bike to view its photos, spin it in 360�, and calculate your EMI.</p>

    </div>

    <div style="display:flex;gap:8px;flex-wrap:wrap;">

      <button class="btn btn-sm" id="addBikeBtn" style="display:none;background:var(--green);color:#fff;" onclick="openAddBike()">+ Add motorcycle</button>

      <button class="btn btn-sm" id="monitorBtn" style="display:none;background:#141412;color:#fff;" onclick="openMonitor()">=��� Activity</button>

      <button class="btn btn-light btn-sm" id="showroomBookBtn" onclick="openBook()">Book a visit</button>

    </div>

  </div>

  <div class="chips" id="chips">

    <button class="chip on" data-f="all" onclick="setChip('all',this)">All</button>

    <button class="chip" data-f="350" onclick="setChip('350',this)">350cc</button>

    <button class="chip" data-f="411" onclick="setChip('411',this)">Adventure 411</button>

    <button class="chip" data-f="650" onclick="setChip('650',this)">650 Twins</button>

    <button class="chip" data-f="under15" onclick="setChip('under15',this)">Under � 1.5L</button>

  </div>

  <div class="grid" id="grid"></div>

</section>



<!-- P%P%P%P%P%P%P% SELL P%P%P%P%P%P%P% -->

<section class="section" id="sell" style="background:linear-gradient(180deg,transparent,#f5f4ef 30%,#f5f4ef 70%,transparent);">

  <div class="sec-head" style="justify-content:center;text-align:center;">

    <div style="margin:0 auto;">

      <h2>Sell your bike in <em>three steps</em></h2>

      <p style="margin-left:auto;margin-right:auto;">Get an instant estimate. Upload photos. We handle the rest   inspection, paperwork, payment.</p>

    </div>

  </div>

  <div class="sell-wrap">

    <div class="steps" id="sellSteps">

      <div class="step on" id="st1"><div class="step-dot">1</div><div class="step-name">Your bike</div></div>

      <div class="step-line"></div>

      <div class="step" id="st2"><div class="step-dot">2</div><div class="step-name">Photos</div></div>

      <div class="step-line"></div>

      <div class="step" id="st3"><div class="step-dot">3</div><div class="step-name">Estimate</div></div>

    </div>



    <!-- STEP 1 -->

    <div class="sell-card" id="sellStep1">

      <div class="f-2col">

        <div class="f-row">

          <label class="f-label">Model</label>

          <select class="f-inp" id="sModel">

            <option>Classic 350</option><option>Bullet 350</option><option>Hunter 350</option>

            <option>Meteor 350</option><option>Scram 411</option><option>Himalayan</option>

            <option>Interceptor 650</option><option>Continental GT 650</option><option>Other</option>

          </select>

        </div>

        <div class="f-row">

          <label class="f-label">Year of purchase</label>

          <select class="f-inp" id="sYear">

            <option>2025</option><option>2024</option><option>2023</option><option selected>2022</option>

            <option>2021</option><option>2020</option><option>2019</option><option>2018 or older</option>

          </select>

        </div>

      </div>

      <div class="f-2col">

        <div class="f-row">

          <label class="f-label">Kilometres driven</label>

          <select class="f-inp" id="sKm">

            <option>Under 5,000 km</option><option selected>5,000   15,000 km</option>

            <option>15,000   30,000 km</option><option>30,000   50,000 km</option><option>50,000+ km</option>

          </select>

        </div>

        <div class="f-row">

          <label class="f-label">Overall condition</label>

          <select class="f-inp" id="sCond">

            <option>Excellent   like new</option><option selected>Good   minor wear</option>

            <option>Fair   visible wear</option><option>Needs work</option>

          </select>

        </div>

      </div>

      <div class="f-row">

        <label class="f-label">Registration number</label>

        <input class="f-inp" id="sReg" placeholder="KA 05 XX 0000" oninput="formatReg(this)"/>

      </div>

      <button class="btn btn-dark btn-block" onclick="sellNext(2)">Continue �!</button>

    </div>



    <!-- STEP 2 -->

    <div class="sell-card" id="sellStep2" style="display:none;">

      <div class="dropzone" id="sellDrop" style="cursor:default;">

        <div class="dz-icon"><svg fill="none" stroke-width="2" viewBox="0 0 24 24"><path d="M3 16.5V19a2 2 0 002 2h14a2 2 0 002-2v-2.5M12 3v13m0-13l-4 4m4-4l4 4" stroke-linecap="round" stroke-linejoin="round"/></svg></div>

        <div class="dz-title">Add photos of your bike</div>

        <div class="dz-sub" style="margin-bottom:16px;">Drag &amp; drop or use the buttons below</div>

        <div style="display:flex;gap:12px;justify-content:center;flex-wrap:wrap;">

          <button class="btn btn-dark btn-sm" onclick="document.getElementById('sellFileCam').click()">=�� Take Photo</button>

          <button class="btn btn-light btn-sm" onclick="document.getElementById('sellFileGal').click()">=�� Upload Gallery</button>

        </div>

      </div>

      <input type="file" id="sellFileCam" accept="image/*" capture="environment" multiple hidden onchange="addSellPhotos(this.files)"/>

      <input type="file" id="sellFileGal" accept="image/*" multiple hidden onchange="addSellPhotos(this.files)"/>

      <div class="preview-grid" id="sellPreviews"></div>

      <div class="up-tip">

        <svg fill="none" stroke-width="2" viewBox="0 0 24 24"><path d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" stroke-linecap="round" stroke-linejoin="round"/></svg>

        <span>Better photos = faster, more accurate quote. Natural daylight works best. You can skip this and send photos on WhatsApp later.</span>

      </div>

      <div style="display:flex;gap:10px;margin-top:20px;">

        <button class="btn btn-light" onclick="sellNext(1)">�! Back</button>

        <button class="btn btn-dark" style="flex:1;justify-content:center;" onclick="computeEstimate()">Get my estimate �!</button>

      </div>

    </div>



    <!-- STEP 3 -->

    <div class="sell-card" id="sellStep3" style="display:none;">

      <div class="estimate-card">

        <div class="est-label">Estimated value</div>

        <div class="est-value" id="estValue">� 1,18,000</div>

        <div class="est-range" id="estRange">Range: � 1,10,000   � 1,26,000</div>

        <div class="est-note">Final offer after a free 15-minute physical inspection at our Bengaluru showroom. Instant bank transfer on agreement.</div>

      </div>

      <div class="f-row" style="margin-top:22px;">

        <label class="f-label">Your name</label>

        <input class="f-inp" id="sName" placeholder="Full name"/>

      </div>

      <div class="f-row">

        <label class="f-label">Mobile number</label>

        <input class="f-inp" id="sPhone" placeholder="+91"/>

      </div>

      <button class="btn btn-gold btn-block" onclick="submitSell()">Lock my estimate &amp; book inspection</button>

      <button class="btn btn-light btn-block" style="margin-top:10px;" onclick="sellNext(1)">Start over</button>

    </div>

  </div>

</section>



<!-- P%P%P%P%P%P%P% HOW P%P%P%P%P%P%P% -->

<section class="section" id="how">

  <div class="sec-head"><div><h2>How it <em>works</em></h2></div></div>

  <div class="how">

    <div class="how-card">

      <div class="how-num">1</div>

      <h3>Inspect from home</h3>

      <p>Every bike carries real gallery photos and a 36-frame 360� spin. Zoom into the tank, the chain, the odometer   before you leave your couch.</p>

    </div>

    <div class="how-card">

      <div class="how-num">2</div>

      <h3>Ride before you decide</h3>

      <p>Book a test ride slot in two taps. Bikes are fuelled and ready at our Bengaluru showroom. No obligation, ever.</p>

    </div>

    <div class="how-card">

      <div class="how-num">3</div>

      <h3>Paperwork, done for you</h3>

      <p>RC transfer, insurance, finance   our desk handles everything the same day. After the sale, our <b>Bengaluru Service Centre</b> keeps your Enfield in top shape.</p>

    </div>

  </div>

</section>



<!-- P%P%P%P%P%P%P% EXPERT LINE BANNER P%P%P%P%P%P%P% -->

<section style="max-width:1180px;margin:0 auto;padding:0 24px 70px;">

  <div style="background:var(--ink);border-radius:var(--radius);padding:40px 44px;display:flex;align-items:center;justify-content:space-between;gap:24px;flex-wrap:wrap;">

    <div>

      <div style="font-size:12px;font-weight:700;letter-spacing:1.5px;text-transform:uppercase;color:var(--mustard);margin-bottom:8px;">Talk to a Re-Own expert</div>

      <div style="font-family:'Oswald',sans-serif;text-transform:uppercase;font-size:clamp(22px,3vw,32px);font-weight:600;letter-spacing:.5px;color:#fff;">Re-Own Expert Line � <a href="tel:+919035045535" onclick="callUs();return false;" style="color:var(--mustard);text-decoration:none;">+91 90350 45535</a></div>

      <div style="font-size:14px;color:rgba(255,255,255,.55);margin-top:8px;max-width:520px;">Not sure which model fits you? Questions on condition, finance, or exchange? Our specialists answer directly   no call centre. Post-sale service &amp; repairs at our <b style="color:rgba(255,255,255,.85);">Bengaluru Service Centre</b>.</div>

    </div>

    <div style="display:flex;gap:12px;flex-wrap:wrap;">

      <a href="tel:+919035045535" class="btn" style="background:var(--gold);color:#fff;" onclick="callUs();return false;">=��� Call the Expert Line</a>

      <button class="btn" style="background:rgba(255,255,255,.1);color:#fff;border:1.5px solid rgba(255,255,255,.2);" onclick="window.open('https://wa.me/919035045535?text='+encodeURIComponent('Hi! I have a question for the Re-Own Expert Line.'),'_blank')">WhatsApp instead</button>

    </div>

  </div>

</section>



<footer>

  <div class="foot-logo"><em>RE</em>OWN &middot; AVAHAN MOTORS</div>

  <p>Reown Authorized Partner   Avahan Motors, Bengaluru � Ref 11269V</p>

  <p style="margin-top:4px;"><b style="color:var(--gold);">Service Centre:</b> Bengaluru   all brands of Royal Enfield serviced</p>

  <p style="margin-top:4px;"><b style="color:var(--gold);">Re-Own Expert Line:</b> +91 90350 45535 (Mon Sat, 9 AM   7 PM) � sales@avahanmotors.in</p>

</footer>



<!-- P%P%P%P%P%P%P% BIKE DETAIL SHEET P%P%P%P%P%P%P% -->

<div class="overlay" id="detailOv" onclick="if(event.target===this)closeDetail()">

  <div class="sheet">

    <button class="x" onclick="closeDetail()">'</button>

    <div id="detailInner"></div>

  </div>

</div>



<!-- P%P%P%P%P%P%P% UPLOAD MANAGER SHEET P%P%P%P%P%P%P% -->

<div class="overlay" id="uploadOv" onclick="if(event.target===this)closeUpload()">

  <div class="sheet sheet-md">

    <button class="x" onclick="closeUpload()">'</button>

    <div class="up-head">

      <div class="up-title" id="upTitle">Manage photos</div>

      <div class="up-sub" id="upSub"></div>

      <div class="st-pills" style="margin-top:14px;" id="stPills"></div>

    </div>

    <div class="up-tabs">

      <button class="up-tab on" id="tabGal" onclick="setUpTab('gallery')">

        Gallery <span class="up-count" id="cntGal">0</span>

      </button>

      <button class="up-tab" id="tab360" onclick="setUpTab('spin')">

        360� frames <span class="up-count" id="cnt360">0</span>

      </button>

      <button class="up-tab" id="tabVid" onclick="setUpTab('video')">

        Video <span class="up-count" id="cntVid">0</span>

      </button>

    </div>

    <div class="up-body">

      <div class="dropzone" id="upDrop" onclick="document.getElementById('upFile').click()">

        <div class="dz-icon"><svg fill="none" stroke-width="2" viewBox="0 0 24 24"><path d="M3 16.5V19a2 2 0 002 2h14a2 2 0 002-2v-2.5M12 3v13m0-13l-4 4m4-4l4 4" stroke-linecap="round" stroke-linejoin="round"/></svg></div>

        <div class="dz-title" id="dzTitle">Drop gallery photos here</div>

        <div class="dz-sub" id="dzSub">or <b>browse</b>   JPG / PNG, any size. First photo becomes the cover.</div>

      </div>

      <input type="file" id="upFile" accept="image/*" multiple hidden onchange="handleUpload(this.files)"/>

      <div class="preview-grid" id="upPreviews"></div>

      <div class="up-tip" id="upTip">

        <svg fill="none" stroke-width="2" viewBox="0 0 24 24"><path d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" stroke-linecap="round" stroke-linejoin="round"/></svg>

        <span id="tipText">Shoot in landscape, consistent height, plain background. 6 10 photos per bike is ideal.</span>

      </div>

      <button class="btn btn-dark btn-block" style="margin-top:20px;" onclick="closeUpload();showToast('Photos saved to listing')">Done</button>

    </div>

  </div>

</div>



<!-- P%P%P%P%P%P%P% BOOKING SHEET P%P%P%P%P%P%P% -->

<div class="overlay" id="bookOv" onclick="if(event.target===this)this.classList.remove('open')">

  <div class="sheet sheet-sm">

    <button class="x" onclick="document.getElementById('bookOv').classList.remove('open')">'</button>

    <div style="padding:34px;">

      <div style="font-size:24px;font-weight:800;letter-spacing:-.7px;">Book a test ride</div>

      <div style="font-size:14px;color:var(--ink3);margin:4px 0 24px;">Free � 15 minutes � No obligation</div>

      <div class="f-row">

        <label class="f-label">Motorcycle</label>

        <select class="f-inp" id="bookBike"></select>

      </div>

      <div class="f-2col">

        <div class="f-row"><label class="f-label">Date</label><input type="date" class="f-inp" id="bookDate"/></div>

        <div class="f-row"><label class="f-label">Time</label>

          <select class="f-inp" id="bookTime"><option>10:00 AM</option><option>11:00 AM</option><option>12:00 PM</option><option>2:00 PM</option><option>4:00 PM</option><option>6:00 PM</option></select>

        </div>

      </div>

      <div class="f-row"><label class="f-label">Name</label><input class="f-inp" id="bookName" placeholder="Full name"/></div>

      <div class="f-row"><label class="f-label">Mobile</label><input class="f-inp" id="bookPhone" placeholder="+91"/></div>

      <button class="btn btn-dark btn-block" onclick="submitBooking()">Confirm booking</button>

      <a class="btn btn-block" style="background:#25D366;color:#fff;justify-content:center;margin-top:10px;text-decoration:none;" href="https://wa.me/919035045535" target="_blank">=ج� WhatsApp us</a>

      <a class="btn btn-block btn-light" style="justify-content:center;margin-top:10px;text-decoration:none;" href="tel:+919035045535" onclick="callUs();return false;">=��� Call +91 90350 45535</a>

    </div>

  </div>

</div>



<!-- P%P%P%P%P%P%P% DEALER PASSWORD SHEET P%P%P%P%P%P%P% -->

<div class="overlay" id="pinOv" onclick="if(event.target===this)this.classList.remove('open')">

  <div class="sheet sheet-sm" style="max-width:400px;" id="pinSheet">

    <button class="x" onclick="document.getElementById('pinOv').classList.remove('open')">'</button>

    <div style="padding:36px;text-align:center;">

      <div style="width:56px;height:56px;border-radius:50%;background:var(--gold-bg);margin:0 auto 16px;display:flex;align-items:center;justify-content:center;">

        <svg width="24" height="24" fill="none" stroke="var(--gold)" stroke-width="2" viewBox="0 0 24 24"><path d="M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z" stroke-linecap="round" stroke-linejoin="round"/></svg>

      </div>

      <div style="font-family:'Oswald',sans-serif;text-transform:uppercase;font-size:20px;font-weight:600;letter-spacing:.5px;">Staff Access</div>

      <div style="font-size:13.5px;color:var(--ink3);margin:6px 0 22px;">Executive � Manager � Director</div>

      <input class="f-inp" type="password" id="pinInput" placeholder="Password" style="text-align:center;font-size:17px;letter-spacing:3px;" onkeydown="if(event.key==='Enter')checkPin()"/>

      <div id="pinErr" style="display:none;font-size:12.5px;color:var(--gold);font-weight:600;margin-top:10px;">Incorrect password   try again</div>

      <button class="btn btn-dark btn-block" style="margin-top:16px;" onclick="checkPin()">Sign in</button>

    </div>

  </div>

</div>





<!-- P%P%P%P%P%P%P% BOOKING RULES SHEET P%P%P%P%P%P%P% -->

<div class="overlay" id="rulesOv" onclick="if(event.target===this)this.classList.remove('open')">

  <div class="sheet sheet-md">

    <button class="x" onclick="document.getElementById('rulesOv').classList.remove('open')">'</button>

    <div style="padding:40px 40px 36px;">

      <div style="font-size:11px;font-weight:700;letter-spacing:2px;text-transform:uppercase;color:var(--gold);margin-bottom:8px;">The Re-Own Rules</div>

      <div style="font-family:'Oswald',sans-serif;text-transform:uppercase;font-size:28px;font-weight:600;letter-spacing:.5px;">How booking works</div>

      <div style="font-size:14px;color:var(--ink3);margin:6px 0 10px;">Simple, transparent, no fine print games.</div>

      <div class="rules-list">

        <div class="rule-item">

          <div class="rule-num"></div>

          <div>

            <div class="rule-t">10% blocks it   and books your test ride.</div>

            <div class="rule-d">Pay 10% of the listed price (UPI / bank transfer) and the motorcycle is blocked in your name with a test-ride slot confirmed. Nobody else can take it while you decide.</div>

          </div>

        </div>

        <div class="rule-item">

          <div class="rule-num"></div>

          <div>

            <div class="rule-t">20% reserves it for 7 days   finance, payment &amp; delivery.</div>

            <div class="rule-d">Pay 20% and the bike is held for <b>7 full days</b> while you complete finance approval or payment. Our desk processes the loan, paperwork and delivery within this window. The listing shows <b style="color:#a06a00;">Booked</b> to everyone else.</div>

          </div>

        </div>

        <div class="rule-item">

          <div class="rule-num"></div>

          <div>

            <div class="rule-t">After your test ride   you have two options.</div>

            <div class="rule-d">

              <b>`$ Love it?</b> Top up another 10% (total 20%)   the bike is reserved for 7 days while finance, payment and delivery are completed.<br/><br/>

              <b>a$ Not convinced?</b> Walk away, no questions asked   your 10% is <b>auto-refunded to your account</b> and the bike returns to Available. No forms, no follow-ups.

            </div>

          </div>

        </div>

        <div class="rule-item">

          <div class="rule-num"></div>

          <div>

            <div class="rule-t">Not completed in 7 days? Auto-refund. No follow-ups needed.</div>

            <div class="rule-d">If payment or finance isn't completed within the 7-day window, your blocking amount is <b>refunded automatically to your account</b>   no forms, no chasing   and the bike returns to <b style="color:var(--green);">Available</b> with the waitlist notified.</div>

          </div>

        </div>

        <div class="rule-item">

          <div class="rule-num"></div>

          <div>

            <div class="rule-t">Sold bikes stay on the site.</div>

            <div class="rule-d">We keep sold listings visible (at the bottom) so you can see real turnover, real prices, and what moves fast. What you see is what actually sells.</div>

          </div>

        </div>

        <div class="rule-item">

          <div class="rule-num"></div>

          <div>

            <div class="rule-t">Delivery with complete papers.</div>

            <div class="rule-d">RC transfer initiated on full payment, insurance assistance included, all documents handed over at delivery. The Re-Own Expert Line stays with you after the sale.</div>

          </div>

        </div>

        <div class="rule-item">

          <div class="rule-num"></div>

          <div>

            <div class="rule-t">�& Pay in full online   delivered in 100 minutes.</div>

            <div class="rule-d">Transfer the full amount via RTGS / IMPS / UPI and skip the wait entirely: within <b>Bengaluru city limits</b>, the bike reaches your doorstep in <b>100 minutes</b>   fuelled, cleaned, papers in the tank bag. Video-call inspection before you pay, doorstep signature at delivery.</div>

          </div>

        </div>

        <div class="rule-item">

          <div class="rule-num"></div>

          <div>

            <div class="rule-t">�! 6-month buyback guarantee   80% of your price.</div>

            <div class="rule-d">Changed your mind, upgrading, or moving cities? Return the bike within <b>6 months</b> with <b>under 5,000 km added</b> and we buy it back at <b>80% of what you paid</b> (20% depreciation)   on the spot, bank transfer same day. Bike must clear the same 200-checkpoint inspection with no accident damage.</div>

          </div>

        </div>

        <div class="rule-item">

          <div class="rule-num"></div>

          <div>

            <div class="rule-t">�! Instant exchange, any time.</div>

            <div class="rule-d">Swap your current Re-Own bike (or any Royal Enfield) against another in our inventory   valuation in 15 minutes at our Bengaluru showroom, difference settled immediately either way, and you ride out on the new one the same visit.</div>

          </div>

        </div>

      </div>

      <button class="btn btn-dark btn-block" style="margin-top:24px;" onclick="document.getElementById('rulesOv').classList.remove('open');go('buy')">Browse available bikes</button>

      <button class="btn btn-light btn-block" style="margin-top:10px;" onclick="window.open('https://wa.me/919035045535?text='+encodeURIComponent('Hi! I want to book a bike   please share payment details.'),'_blank')">Book via WhatsApp   get payment details</button>

    </div>

  </div>

</div>





<!-- P%P%P%P%P%P%P% ADD MOTORCYCLE SHEET (staff) P%P%P%P%P%P%P% -->

<div class="overlay" id="addOv" onclick="if(event.target===this)this.classList.remove('open')">

  <div class="sheet sheet-sm" style="max-width:520px;">

    <button class="x" onclick="document.getElementById('addOv').classList.remove('open')">'</button>

    <div style="padding:34px;">

      <div style="font-family:'Oswald',sans-serif;text-transform:uppercase;font-size:22px;font-weight:600;">Add motorcycle</div>

      <div style="font-size:13px;color:var(--ink3);margin:4px 0 20px;">Executive listings go to the Manager for approval before going live.</div>

      <div class="f-2col">

        <div class="f-row"><label class="f-label">Model</label>

          <select class="f-inp" id="abModel"><option>Classic 350</option><option>Bullet 350</option><option>Hunter 350</option><option>Meteor 350</option><option>Scram 411</option><option>Himalayan</option><option>Interceptor 650</option><option>Continental GT 650</option></select></div>

        <div class="f-row"><label class="f-label">Colour / variant</label><input class="f-inp" id="abVariant" placeholder="e.g. Halcyon Green"/></div>

      </div>

      <div class="f-2col">

        <div class="f-row"><label class="f-label">Model year</label>

          <select class="f-inp" id="abYear"><option>2025</option><option>2024</option><option selected>2023</option><option>2022</option><option>2021</option><option>2020</option></select></div>

        <div class="f-row"><label class="f-label">Reg number</label><input class="f-inp" id="abReg" placeholder="KA05XX0000"/></div>

      </div>

      <div class="f-2col">

        <div class="f-row"><label class="f-label">Kms driven</label><input class="f-inp" id="abKm" placeholder="e.g. 8,500 km"/></div>

        <div class="f-row"><label class="f-label">Owner</label>

          <select class="f-inp" id="abOwner"><option>1st Owner</option><option>2nd Owner</option><option>3rd Owner</option></select></div>

      </div>

      <div class="f-2col">

        <div class="f-row"><label class="f-label">Insurance valid till</label><input class="f-inp" id="abIns" placeholder="e.g. Mar 2027"/></div>

        <div class="f-row"><label class="f-label">Asking price (� )</label><input class="f-inp" id="abPrice" type="number" placeholder="128000"/></div>

      </div>

      <div class="f-row"><label class="f-label">Accessories (comma-separated)</label><input class="f-inp" id="abAcc" placeholder="Engine guard, Touring seat, Fog lamps"/></div>

      <button class="btn btn-dark btn-block" onclick="submitBike()">Submit motorcycle</button>

      <div style="font-size:11.5px;color:var(--ink3);margin-top:10px;text-align:center;">Photos, 360� &amp; video can be added right after via Manage photos.</div>

    </div>

  </div>

</div>



<!-- P%P%P%P%P%P%P% DIRECTOR MONITOR SHEET P%P%P%P%P%P%P% -->

<div class="overlay" id="monOv" onclick="if(event.target===this)this.classList.remove('open')">

  <div class="sheet sheet-md">

    <button class="x" onclick="document.getElementById('monOv').classList.remove('open')">'</button>

    <div style="padding:36px;">

      <div style="font-size:11px;font-weight:700;letter-spacing:2px;text-transform:uppercase;color:var(--gold);margin-bottom:6px;">Director console</div>

      <div style="font-family:'Oswald',sans-serif;text-transform:uppercase;font-size:26px;font-weight:600;margin-bottom:20px;">Activity monitor</div>

      <div id="monBody"></div>

    </div>

  </div>

</div>



<!-- P%P%P%P%P%P%P% UNIFIED STAFF DASHBOARD P%P%P%P%P%P%P% -->

<div class="overlay" id="staffDashOv" onclick="if(event.target===this)this.classList.remove('open')">

  <div class="sheet sheet-md">

    <button class="x" onclick="document.getElementById('staffDashOv').classList.remove('open')">'</button>

    <div style="padding:36px;">

      <div style="font-size:11px;font-weight:700;letter-spacing:2px;text-transform:uppercase;color:var(--mustard);margin-bottom:6px;">Staff dashboard</div>

      <div style="display:flex;gap:20px;margin-bottom:20px;border-bottom:1px solid var(--line);padding-bottom:12px;">

        <div id="tabSell" style="font-family:'Oswald',sans-serif;text-transform:uppercase;font-size:22px;font-weight:600;cursor:pointer;color:var(--gold);" onclick="switchDashTab('sell')">Sell Requests</div>

        <div id="tabBook" style="font-family:'Oswald',sans-serif;text-transform:uppercase;font-size:22px;font-weight:600;cursor:pointer;color:var(--ink3);" onclick="switchDashTab('book')">Bookings</div>

      </div>

      <div id="sellReqBody" style="max-height: 60vh; overflow-y: auto;"></div>

      <div id="bookReqBody" style="max-height: 60vh; overflow-y: auto; display:none;"></div>

    </div>

  </div>

</div>



<a class="fab fab-call" href="tel:+919035045535" onclick="callUs();return false;" title="Call us">

  <svg viewBox="0 0 24 24" fill="#fff"><path d="M6.62 10.79a15.05 15.05 0 006.59 6.59l2.2-2.2a1 1 0 011.01-.24c1.12.37 2.33.57 3.58.57a1 1 0 011 1V20a1 1 0 01-1 1C10.85 21 3 13.15 3 3.5a1 1 0 011-1h3.5a1 1 0 011 1c0 1.25.2 2.46.57 3.58a1 1 0 01-.24 1.01l-2.21 2.2z"/></svg>

</a>

<button class="fab" onclick="window.open('https://wa.me/919035045535?text='+encodeURIComponent('Hi Avahan Motors!'),'_blank')" title="WhatsApp">

  <svg viewBox="0 0 24 24"><path d="M17.472 14.382c-.297-.149-1.758-.867-2.03-.967-.273-.099-.471-.148-.67.15-.197.297-.767.966-.94 1.164-.173.199-.347.223-.644.075-.297-.15-1.255-.463-2.39-1.475-.883-.788-1.48-1.761-1.653-2.059-.173-.297-.018-.458.13-.606.134-.133.298-.347.446-.52.149-.174.198-.298.298-.497.099-.198.05-.371-.025-.52-.075-.149-.669-1.612-.916-2.207-.242-.579-.487-.5-.669-.51-.173-.008-.371-.01-.57-.01-.198 0-.52.074-.792.372-.272.297-1.04 1.016-1.04 2.479 0 1.462 1.065 2.875 1.213 3.074.149.198 2.096 3.2 5.077 4.487.709.306 1.262.489 1.694.625.712.227 1.36.195 1.871.118.571-.085 1.758-.719 2.006-1.413.248-.694.248-1.289.173-1.413-.074-.124-.272-.198-.57-.347m-5.421 7.403h-.004a9.87 9.87 0 01-5.031-1.378l-.361-.214-3.741.982.998-3.648-.235-.374a9.86 9.86 0 01-1.51-5.26c.001-5.45 4.436-9.884 9.888-9.884 2.64 0 5.122 1.03 6.988 2.898a9.825 9.825 0 012.893 6.994c-.003 5.45-4.437 9.884-9.885 9.884m8.413-18.297A11.815 11.815 0 0012.05 0C5.495 0 .16 5.335.157 11.892c0 2.096.547 4.142 1.588 5.945L.057 24l6.305-1.654a11.882 11.882 0 005.683 1.448h.005c6.554 0 11.89-5.335 11.893-11.893a11.821 11.821 0 00-3.48-8.413z"/></svg>

</button>



<div class="toast" id="toast"><svg fill="none" stroke-width="2.5" viewBox="0 0 24 24"><path d="M5 13l4 4L19 7" stroke-linecap="round" stroke-linejoin="round"/></svg><span id="toastMsg"></span></div>



<script>

function esc(str) {

  if(!str) return '';

  return String(str).replace(/[&<>'"]/g, tag => ({

    '&': '&amp;', '<': '&lt;', '>': '&gt;', "'": '&#39;', '"': '&quot;'

  }[tag] || tag));

}

/* P%P%P%P%P%P%P%P%P%P% DATA P%P%P%P%P%P%P%P%P%P% */

/* hue = actual RE paint colour of that variant (approx), hue2 = accent/pinstripe */

let BIKES=[]; let SELL_REQUESTS=[]; let BOOKING_REQUESTS=[];

// photos live in memory: {gallery:[dataURL...], spin:[dataURL...]}

const media={}; BIKES.forEach(b=>media[b.id]={gallery:[],spin:[],videos:[]});



const fmt=n=>"� "+Number(n).toLocaleString("en-IN");

function listId(b){return "REO-"+String(b.id).padStart(3,"0");}

function maskReg(r){return r.slice(0,2)+"-"+r.slice(2,4)+"-******";}

function dispReg(b){return admin?b.reg:maskReg(b.reg);}

const CHECKS=[

 {t:"Engine & compression",pts:38,subs:["Cold-start test","Compression reading","Oil condition & leak check","Abnormal noise / vibration","Clutch engagement & play"]},

 {t:"Chain & sprocket",pts:16,subs:["Chain slack & lubrication","Sprocket teeth wear","Chain stretch measurement","Rear hub & cush drive"]},

 {t:"Brakes & pads",pts:24,subs:["Front & rear pad depth","Disc condition & thickness","Brake fluid level & colour","ABS function test","Lever & pedal free play"]},

 {t:"Tyres & tread",pts:14,subs:["Tread depth (both tyres)","Sidewall cracks & tyre age","Correct pressure","Rim trueness   no bends"]},

 {t:"Battery health",pts:10,subs:["Voltage & load test","Terminal corrosion check","Charging output (regulator)"]},

 {t:"Electricals & lights",pts:30,subs:["Headlamp, tail & indicators","Horn & switches","Console & warning lights","Wiring, fuses & starter motor"]},

 {t:"Frame & body",pts:26,subs:["Chassis straightness","Accident / re-weld marks","Rust & corrosion points","Tank dents & paint condition"]},

 {t:"Suspension",pts:18,subs:["Front fork seals & travel","Rear shock damping & leaks","Steering bearing play"]},

 {t:"Odometer verified",pts:10,subs:["Km matched with service records","Tampering inspection","Full service history reviewed"]},

 {t:"RC & insurance",pts:14,subs:["Original RC   chassis no. matched","Insurance validity","No hypothecation or pending challans","Ownership count verified"]},

];



let admin=false, chip="all";



/* P%P%P%P%P%P%P%P%P%P% PLACEHOLDER ART P%P%P%P%P%P%P%P%P%P% */

function art(b){

 const c=b.hue, a=b.hue2||"#C9A84C";

 return `<svg class="ph-art" viewBox="0 0 400 240" fill="none" style="opacity:.95;">

  <defs>

   <linearGradient id="tank${b.id}" x1="0" y1="0" x2="0" y2="1">

    <stop offset="0%" stop-color="${c}"/><stop offset="55%" stop-color="${c}"/><stop offset="100%" stop-color="#000" stop-opacity=".45"/>

   </linearGradient>

   <radialGradient id="glow${b.id}" cx="50%" cy="60%" r="65%">

    <stop offset="0%" stop-color="${c}" stop-opacity=".14"/><stop offset="100%" stop-color="${c}" stop-opacity="0"/>

   </radialGradient>

  </defs>

  <rect x="0" y="0" width="400" height="240" fill="url(#glow${b.id})" rx="16"/>

  <ellipse cx="205" cy="212" rx="185" ry="12" fill="#000" opacity=".08"/>

  <circle cx="95" cy="175" r="52" stroke="#1c1c1e" stroke-width="8"/>

  <circle cx="95" cy="175" r="26" stroke="#8a8a90" stroke-width="2.5"/>

  <circle cx="95" cy="175" r="6" fill="#1c1c1e"/>

  <circle cx="315" cy="175" r="52" stroke="#1c1c1e" stroke-width="8"/>

  <circle cx="315" cy="175" r="26" stroke="#8a8a90" stroke-width="2.5"/>

  <circle cx="315" cy="175" r="6" fill="#1c1c1e"/>

  <path d="M95 123 L145 78 L215 62 L275 72 L315 123" stroke="#232326" stroke-width="6"/>

  <path d="M145 78 L172 123 L95 123" stroke="#232326" stroke-width="4.5"/>

  <ellipse cx="222" cy="72" rx="58" ry="21" fill="url(#tank${b.id})" stroke="#141414" stroke-width="2.5"/>

  <ellipse cx="222" cy="70" rx="34" ry="9" fill="#fff" opacity=".18"/>

  <path d="M170 74 Q222 60 274 74" stroke="${a}" stroke-width="2.5" opacity=".95"/>

  <circle cx="222" cy="72" r="7" fill="${a}" opacity=".9"/>

  <path d="M160 84 Q222 70 284 84" stroke="#141414" stroke-width="4.5"/>

  <path d="M275 72 L302 48 L330 44" stroke="#232326" stroke-width="4"/>

  <circle cx="322" cy="86" r="13" fill="#F2E9CE" stroke="#232326" stroke-width="3"/>

  <rect x="168" y="102" width="66" height="46" rx="7" fill="#3a3a3e" stroke="#141414" stroke-width="2"/>

  <rect x="176" y="108" width="50" height="6" rx="3" fill="#6a6a70"/>

  <rect x="176" y="120" width="50" height="6" rx="3" fill="#6a6a70"/>

  <path d="M172 162 Q130 158 100 182" stroke="#9a9aa0" stroke-width="5"/>

  <path d="M330 82 L348 82" stroke="${a}" stroke-width="3"/>

 </svg>`;

}



/* P%P%P%P%P%P%P%P%P%P% GRID P%P%P%P%P%P%P%P%P%P% */

function matches(b){

 if(chip==="all")return true;

 if(chip==="350")return b.cc===350;

 if(chip==="411")return b.cc===411;

 if(chip==="650")return b.cc>=640;

 if(chip==="under15")return b.asking<150000;

 return true;

}

function setChip(f,el){chip=f;document.querySelectorAll(".chip").forEach(c=>c.classList.remove("on"));el.classList.add("on");renderGrid();}



/* status: available (default) | booked (20% paid, 7-day hold) | sold */

function stat(b){return b.status||"available";}

function holdDaysLeft(b){

 if(stat(b)!=="booked"||!b.bookedOn)return 0;

 return Math.max(0,7-Math.floor((Date.now()-new Date(b.bookedOn))/864e5));

}

const STATUS_ORDER={available:0,booked:1,sold:2};



function visibleToPublic(b){return b.approval!=="pending"&&b.approval!=="denied";}

function renderGrid(){

 const g=document.getElementById("grid");

 const pool=BIKES.filter(b=>admin?true:visibleToPublic(b));

 const APPR_ORDER={pending:0,undefined:1,approved:1,denied:2};

 const sorted=pool.filter(matches).sort((a,b)=>

  (admin?(APPR_ORDER[a.approval]-APPR_ORDER[b.approval]):0)||(STATUS_ORDER[stat(a)]-STATUS_ORDER[stat(b)]));

 g.innerHTML=sorted.map((b,i)=>{

  const m=media[b.id];

  const cover=m.gallery[0]||m.spin[0];

  const nPhotos=m.gallery.length+m.spin.length;

  return `<div class="card ${admin?'admin':''} st-${stat(b)}" style="animation-delay:${i*.04}s" onclick="openDetail(${b.id})">

   <div class="card-media">

    ${cover?`<img src="${cover}" alt="${b.name}"/>`:art(b)}

    ${stat(b)==="available"?'<div class="card-tag">Available</div>':''}

    ${stat(b)==="booked"?`<div class="card-tag tag-booked">Booked � ${holdDaysLeft(b)}d hold</div>`:''}

    ${stat(b)==="sold"?'<div class="card-tag tag-sold">Sold</div>':''}

    ${admin&&b.approval==="pending"?'<div class="card-tag" style="top:44px;color:#a06a00;">�# Pending approval</div>':''}

    ${admin&&b.approval==="denied"?'<div class="card-tag tag-sold" style="top:44px;">' Denied</div>':''}

    ${m.spin.length>1?`<div class="tag-360">�! 360�</div>`:''}

    ${m.videos&&m.videos.length?`<div class="tag-360" style="top:${m.spin.length>1?'42':'14'}px;">�% Video</div>`:''}

    ${nPhotos?`<div class="photo-count">${nPhotos} photos</div>`:''}

    ${admin?`<div class="upload-hint" onclick="event.stopPropagation();openUpload(${b.id})">

      <svg fill="none" stroke-width="2" viewBox="0 0 24 24"><path d="M3 16.5V19a2 2 0 002 2h14a2 2 0 002-2v-2.5M12 3v13m0-13l-4 4m4-4l4 4" stroke-linecap="round" stroke-linejoin="round"/></svg>

      ${nPhotos?'Manage photos':'Add photos'}

    </div>`:''}

   </div>

   <div class="card-body">

    <div class="card-name">${b.name} <span class="card-variant">${b.variant}</span></div>

    <div class="card-meta"><span style="color:var(--gold);font-weight:700;">${listId(b)}</span><span>�</span><span><b style="color:var(--ink2);">${b.year}</b></span><span>�</span><span>${b.km}</span><span>�</span><span>${b.owner}</span><span>�</span><span>${dispReg(b)}</span></div>

    ${b.acc&&b.acc.length?`<div class="acc-chips">${b.acc.map(a=>`<span class="acc-chip">� ${a}</span>`).join("")}</div>`:''}

    <div class="card-foot">

     <div>

      <div class="card-was">New: ${fmt(b.newPrice)} on-road</div>

      <div class="card-price">${fmt(b.asking)}</div>

      <div class="card-save">${Math.round((1-b.asking/b.newPrice)*100)}% below new � save ${fmt(b.newPrice-b.asking)}</div>

     </div>

     <button class="btn btn-dark btn-sm" onclick="event.stopPropagation();openDetail(${b.id})">View</button>

    </div>

    ${admin&&can.approve()&&b.approval==="pending"?`

     <div style="display:flex;gap:8px;margin-top:12px;" onclick="event.stopPropagation()">

      <button class="btn btn-sm" style="flex:1;background:var(--green);color:#fff;justify-content:center;" onclick="approveBike(${b.id})">' Approve</button>

      <button class="btn btn-sm" style="flex:1;background:#b03030;color:#fff;justify-content:center;" onclick="denyBike(${b.id})">' Deny</button>

     </div>`:''}

    ${admin&&can.del()&&b.approval!=="pending"?`

     <div style="display:flex;gap:8px;margin-top:12px;" onclick="event.stopPropagation()">

      <button class="btn btn-sm btn-light" style="flex:1;justify-content:center;" onclick="editPrice(${b.id})">' Price</button>

      <button class="btn btn-sm" style="background:transparent;border:1.5px solid #ecc0c0;color:#b03030;" onclick="deleteBike(${b.id})">=���</button>

     </div>`:''}

   </div>

  </div>`;

 }).join('');

}





/* P%P%P%P%P%P%P%P%P%P% STAFF: SHARE BIKE DETAILS P%P%P%P%P%P%P%P%P%P% */

function shareBike(id){

 const b=BIKES.find(x=>x.id===id);

 const dep=fmt(Math.round(b.asking*0.2/500)*500);

 const msg=[

  "<���� *REOWN � Avahan Motors   Bengaluru*","",

  "*"+b.name+" "+b.variant+"*",

  "Listing ID: "+listId(b),

  "            ",

  "=��� Model Year: "+b.year,

  "=���� Kms Driven: "+b.km,

  "=�d� Owner: "+b.owner,

  "=���� Insurance valid till: "+b.insValid,

  "=��� Reg No: "+b.reg,

  (b.acc&&b.acc.length?"<؁� Accessories FREE: "+b.acc.join(", "):null),

  "            ",

  "=ذ� *Price: "+fmt(b.asking)+"*",

  "<ؕ� Same bike new (on-road): "+fmt(b.newPrice)+"   you save "+fmt(b.newPrice-b.asking),

  "=س� EMI from ~"+fmt(Math.round((b.asking*0.8*0.0108*Math.pow(1.0108,36))/(Math.pow(1.0108,36)-1)))+"/mo",

  "=�� Block + test ride: 10% ("+fmt(Math.round(b.asking*0.1/500)*500)+")   love it? top up 10% to reserve � not convinced? 10% auto-refunded",

  "=�� Reserve 7 days (finance & delivery): 20% ("+dep+")   auto-refund if not completed",

  "            ",

  "' Reown 200-checkpoint certified",

  "�& Delivered in 100 mins (Bengaluru)",

  "�!� 6-month buyback @ 80% (under 5,000 km)",

  "",

  "=��� Re-Own Expert Line: +91 90350 45535",

 ].filter(Boolean).join("\n");

 logEvt("Shared bike details",b.name+" ("+listId(b)+")");

 window.open("https://wa.me/?text="+encodeURIComponent(msg),"_blank");

}





/* P%P%P%P%P%P%P%P%P%P% PHONE DIALER P%P%P%P%P%P%P%P%P%P% */

const PHONE="+919035045535";

function callUs(){

 logEvt("Call tapped","");

 try{window.location.href="tel:"+PHONE;}

 catch(err){window.open("tel:"+PHONE,"_self");}

}



/* P%P%P%P%P%P%P%P%P%P% STAFF ROLES (password-protected) P%P%P%P%P%P%P%P%P%P% */

/* �! change passwords here */

const ROLE_PINS={"exec2026":"Executive","mgr2026":"Manager","dir2026":"Director","reown2026":"Manager"};

let role=null;

async function api(action, payload={}) {

  try {

    const res = await fetch('api/index.php?action='+action, {

      method: 'POST',

      headers: {'Content-Type':'application/json'},

      body: JSON.stringify(payload)

    });

    return await res.json();

  } catch(e) { return {error:e.message}; }

}

async function loadMedia(id) {

  const mRes = await api('media&bike_id='+id);

  if(Array.isArray(mRes)) {

     media[id] = {

       gallery: mRes.filter(x=>x.kind==='gallery').map(x=>x.file_path),

       spin: mRes.filter(x=>x.kind==='spin').map(x=>x.file_path),

       videos: mRes.filter(x=>x.kind==='video').map(x=>x.file_path)

     };

  }

}

const can={

 upload:()=>!!role,

 addBike:()=>!!role,

 approve:()=>role==="Manager"||role==="Director",

 edit:()=>role==="Manager"||role==="Director",

 del:()=>role==="Manager"||role==="Director",

 monitor:()=>role==="Director",

};

/* activity log */

const activity=[];

function logEvt(action,detail){

 activity.push({t:new Date(),role:role||"Visitor",action,detail:detail||""});

 const reqs=JSON.parse(localStorage.getItem("requests")||"[]");

 reqs.push({t:new Date().toISOString(),action,detail});

 localStorage.setItem("requests",JSON.stringify(reqs));

}

logEvt("Site opened","");



function toggleAdmin(){

 if(!admin && !role){

  document.getElementById("pinInput").value=""; if(document.getElementById("phoneInput")) document.getElementById("phoneInput").value="";

  document.getElementById("pinErr").style.display="none";

  document.getElementById("pinOv").classList.add("open");

  setTimeout(()=>document.getElementById("pinInput").focus(),100);

  return;

 }

 if(admin){logEvt("Logout",role);role=null;}

 setAdmin(!admin);

}

async function checkPin(){

  const pass = document.getElementById("pinInput").value;

  const err = document.getElementById("pinErr");

  

  const res = await api('login', {password: pass});

  if(res.ok){

   role=res.role;

   logEvt("Login",role);

   document.getElementById("pinOv").classList.remove("open");

   setAdmin(true);

  }else{

   err.textContent = res.error || "Incorrect login";

   err.style.display="block";

   const sh=document.getElementById("pinSheet");

   sh.style.animation="none";sh.offsetHeight;

   sh.style.animation="shake .4s";

  }

}

function setAdmin(on){

 admin=on;

 document.getElementById("adminBtn").classList.toggle("on",admin);

 document.getElementById("adminLabel").textContent=admin?(role+" � logout"):"Staff login";

 renderGrid();

 document.getElementById("heroUploadBtn").style.display=admin?"block":"none";

 const da=document.getElementById("dwallAdd");if(da)da.style.display=admin?"inline-flex":"none";

 const ab=document.getElementById("addBikeBtn");if(ab)ab.style.display=admin?"inline-flex":"none";

 const mb=document.getElementById("monitorBtn");if(mb)mb.style.display=(admin&&can.monitor())?"inline-flex":"none";

  const hdb=document.getElementById("headerDashBtn");if(hdb)hdb.style.display=admin?"inline-flex":"none";

  const sbb=document.getElementById("showroomBookBtn");if(sbb)sbb.style.display=admin?"none":"inline-flex";

  showToast(admin?("Signed in as "+role):"Signed out");

}



/* P%P%P%P%P%P%P%P%P%P% UPLOAD MANAGER P%P%P%P%P%P%P%P%P%P% */

let upBikeId=null, upTab="gallery";

function openUpload(id){

 upBikeId=id; upTab="gallery";

 const b=BIKES.find(x=>x.id===id);

 document.getElementById("upTitle").textContent=b.name+" � "+b.variant;

 document.getElementById("upSub").textContent=b.reg+"   photos appear instantly on the listing";

 renderStPills(b);

 setUpTab("gallery");

 document.getElementById("uploadOv").classList.add("open");

}

function closeUpload(){document.getElementById("uploadOv").classList.remove("open");renderGrid();}

function setUpTab(t){

 upTab=t;

 document.getElementById("tabGal").classList.toggle("on",t==="gallery");

 document.getElementById("tab360").classList.toggle("on",t==="spin");

 document.getElementById("tabVid").classList.toggle("on",t==="video");

 const f=document.getElementById("upFile");

 f.accept=t==="video"?"video/*":"image/*";

 document.getElementById("dzTitle").textContent=

   t==="gallery"?"Drop gallery photos here":t==="spin"?"Drop your 360� frame sequence here":"Drop a walkaround / start-up video here";

 document.getElementById("dzSub").innerHTML=

   t==="gallery"?'or <b>browse</b>   JPG / PNG. Tap the star on any photo to make it the cover.'

   :t==="spin"?'or <b>browse</b>   select all 24 36 frames at once. They sort by filename automatically.'

   :'or <b>browse</b>   MP4 / MOV, up to ~60s works best. Engine start-up + walkaround sells bikes.';

 document.getElementById("tipText").textContent=

   t==="gallery"?"Shoot landscape, consistent height, plain background. 6 10 photos per bike is ideal."

   :t==="spin"?"Shoot 1 frame every 10 15� on a turntable (24 36 total). Name files 01.jpg, 02.jpg&  and the spin plays perfectly."

   :"One take, phone in landscape: cold start, exhaust note, slow walkaround, close-up of odometer. 30 60 seconds.";

 renderUpPreviews();

}

// drag & drop

const upDrop=document.getElementById("upDrop");

["dragover","dragenter"].forEach(e=>upDrop.addEventListener(e,ev=>{ev.preventDefault();upDrop.classList.add("drag");}));

["dragleave","drop"].forEach(e=>upDrop.addEventListener(e,ev=>{ev.preventDefault();upDrop.classList.remove("drag");}));

upDrop.addEventListener("drop",ev=>handleUpload(ev.dataTransfer.files));



async function handleUpload(files){

  if(!files||!files.length)return;

  const kind = upTab==="video" ? "video" : (upTab==="spin" ? "spin" : "gallery");

  const prefix = upTab==="video" ? "video/" : "image/";

  

  const valid = [...files].filter(f=>f.type.startsWith(prefix));

  valid.sort((a,b)=>a.name.localeCompare(b.name,undefined,{numeric:true}));

  if(!valid.length) return;

  

  const fd = new FormData();

  fd.append('action', 'upload');

  fd.append('bike_id', upBikeId);

  fd.append('kind', kind);

  for(let f of valid) fd.append('files[]', f);

  

  showToast("Uploading "+valid.length+" file(s)...");

  try {

    const res = await fetch('api/index.php?action=upload', { method:'POST', body: fd });

    const data = await res.json();

    if(data.ok) {

       showToast(valid.length+" file(s) saved!");

       await loadMedia(upBikeId);

       renderUpPreviews();

       await initApp();

    } else {

       showToast("Upload failed: "+data.error);

    }

  } catch(e) {

    showToast("Upload error");

  }

  document.getElementById("upFile").value="";

}

function removeMedia(kind,i){media[upBikeId][kind].splice(i,1);renderUpPreviews();}

function renderUpPreviews(){

 const m=media[upBikeId]||{gallery:[],spin:[],videos:[]};

 document.getElementById("cntGal").textContent=m.gallery.length;

 document.getElementById("cnt360").textContent=m.spin.length;

 document.getElementById("cntVid").textContent=(m.videos||[]).length;

 if(upTab==="video"){

  document.getElementById("upPreviews").innerHTML=(m.videos||[]).map((src,i)=>`

   <div class="pv" style="aspect-ratio:16/9;">

    <video src="${src}" muted style="width:100%;height:100%;object-fit:cover;"></video>

    <div class="pv-n">�% Video ${i+1}</div>

    <button class="pv-x" onclick="removeMedia('videos',${i})">'</button>

   </div>`).join('');

  return;

 }

 const list=upTab==="gallery"?m.gallery:m.spin;

 document.getElementById("upPreviews").innerHTML=list.map((src,i)=>`

  <div class="pv">

   <img src="${src}"/>

   ${upTab==="gallery"?(i===0?'<div class="pv-cover">& COVER</div>':`<button class="pv-star" onclick="setCover(${i})" title="Make this the cover">& Set cover</button>`):''}

   ${upTab==="spin"?`<div class="pv-n">${i+1}</div>`:''}

   <button class="pv-x" onclick="removeMedia('${upTab==="gallery"?"gallery":"spin"}',${i})">'</button>

  </div>`).join('');

}

function setCover(i){

 const g=media[upBikeId].gallery;

 g.unshift(g.splice(i,1)[0]);

 renderUpPreviews();

 showToast("Cover photo updated");

}



/* P%P%P%P%P%P%P%P%P%P% DETAIL + VIEWER P%P%P%P%P%P%P%P%P%P% */

let curId=null, mode="gallery", galIdx=0, spinIdx=0, dragging=false, dragX=0, dragStart=0;



async function openDetail(id){

 curId=id;

 const _b=BIKES.find(x=>x.id===id);if(_b){_b.views=(_b.views||0)+1;logEvt("Viewed bike",_b.name+" ("+_b.reg+")");} galIdx=0; spinIdx=0;

 await loadMedia(id);

 const b=BIKES.find(x=>x.id===id);

 const m=media[id];

 mode=m.spin.length>1?"spin":"gallery";





 document.getElementById("detailInner").innerHTML=`

  <div class="viewer">

   <div class="stage" id="stage"></div>

   <div class="mode-pill">

    <button class="mode-btn ${mode==='gallery'?'on':''}" id="mGal" onclick="setMode('gallery')">Photos</button>

    <button class="mode-btn ${mode==='spin'?'on':''}" id="mSpin" onclick="setMode('spin')">360� spin</button>

    ${media[b.id].videos&&media[b.id].videos.length?`<button class="mode-btn" id="mVid" onclick="setMode('video')">�% Video</button>`:''}

   </div>

   <div class="deg-badge" id="degBadge" style="display:none;">0�</div>

   <button class="gallery-nav gnav-l" id="gnavL" onclick="galStep(-1)">9 </button>

   <button class="gallery-nav gnav-r" id="gnavR" onclick="galStep(1)">: </button>

   <div class="drag-hint" id="dragHint" style="display:none;">�! &nbsp;Drag to spin</div>

   <div class="frame-bar" id="frameBar" style="display:none;"><div class="frame-fill" id="frameFill"></div></div>

  </div>

  <div class="thumbs" id="thumbs"></div>

  <div class="detail-body">

   <div class="detail-left">

    <div class="d-name">${b.name}</div>

    <div class="d-variant"><span style="color:var(--gold);font-weight:700;">${listId(b)}</span> � ${b.variant} � ${b.year} model � Bengaluru</div>

    <div style="display:flex;align-items:center;gap:10px;margin:-8px 0 16px;">

     <button style="font-size:20px;line-height:1;" id="heartBtn" onclick="toggleShortlist(${b.id})">${b.hearted?'d'�':'>�
�'}</button>

     <span style="font-size:12.5px;font-weight:600;color:var(--gold);" id="shortCount">${b.shortlisted} people have shortlisted this bike</span>

    </div>

    <div class="spec-row" style="grid-template-columns:repeat(3,1fr);">

     <div class="spec"><b>${b.km}</b><span>Kms Driven</span></div>

     <div class="spec"><b>${b.year}</b><span>Model Year</span></div>

     <div class="spec"><b>${b.owner}</b><span>Owner</span></div>

     <div class="spec"><b>${b.insValid}</b><span>Insurance Valid</span></div>

     <div class="spec"><b>${b.cc}cc</b><span>Engine</span></div>

     <div class="spec"><b>${dispReg(b)}</b><span>Reg No</span></div>

    </div>

    ${b.acc&&b.acc.length?`

    <div class="d-label">Accessories included   free with this bike</div>

    <div class="acc-chips" style="margin:-4px 0 22px;">${b.acc.map(a=>`<span class="acc-chip acc-chip-lg">� ${a}</span>`).join("")}</div>`:''}

    <div class="d-label">Reown 200-checkpoint certification   all passed � 10 categories, tap to expand</div>

    <div class="acc">

     ${CHECKS.map((c,i)=>`

      <div class="acc-item" id="acc${i}">

       <button class="acc-head" onclick="toggleAcc(${i})">

        <span style="display:flex;align-items:center;gap:10px;">

         <svg fill="none" stroke-width="2.5" viewBox="0 0 24 24" style="width:17px;height:17px;stroke:var(--green);flex-shrink:0;"><path d="M5 13l4 4L19 7" stroke-linecap="round" stroke-linejoin="round"/></svg>

         ${c.t}

        </span>

        <span style="display:flex;align-items:center;gap:8px;">

         <span style="font-size:10.5px;font-weight:700;background:var(--green-bg);color:var(--green);padding:3px 9px;border-radius:980px;">${c.pts} checks</span>

         <span class="acc-plus">+</span>

        </span>

       </button>

       <div class="acc-body">

        ${c.subs.map(s=>`<div class="acc-sub">� ${s}</div>`).join('')}

       </div>

      </div>`).join('')}

    </div>

   </div>

   <div class="detail-right">

    <div class="d-label">Price</div>

    <div class="d-price">${fmt(b.asking)}</div>

    <div class="d-was"><s>${fmt(b.market)}</s><span class="d-save">used market avg</span></div>

    <div style="margin-top:14px;background:#fff;border:1.5px solid var(--line);border-radius:var(--radius-sm);padding:14px 16px;">

     <div style="display:flex;justify-content:space-between;font-size:13px;padding:5px 0;">

      <span style="color:var(--ink3);">New ${b.newRef} (on-road, BLR)</span><b>${fmt(b.newPrice)}</b>

     </div>

     <div style="display:flex;justify-content:space-between;font-size:13px;padding:5px 0;border-top:1px solid var(--line);">

      <span style="color:var(--ink3);">This bike</span><b>${fmt(b.asking)}</b>

     </div>

     <div style="display:flex;justify-content:space-between;font-size:13.5px;padding:7px 0 2px;border-top:1px solid var(--line);">

      <b style="color:var(--green);">You save vs new</b><b style="color:var(--green);">${fmt(b.newPrice-b.asking)} (${Math.round((1-b.asking/b.newPrice)*100)}%)</b>

     </div>

    </div>

    <div class="emi-box">

     <div class="d-label" style="margin-bottom:4px;">EMI calculator</div>

     <div class="emi-num" id="emiNum"></div>

     <div style="margin-top:10px;">

      <div style="display:flex;justify-content:space-between;font-size:11.5px;font-weight:600;color:var(--ink3);"><span>Down payment</span><span id="dpLabel"></span></div>

      <input type="range" id="dpSlider" min="10" max="60" step="5" value="20" oninput="calcEmi(${b.asking})"/>

      <div style="display:flex;justify-content:space-between;font-size:11.5px;font-weight:600;color:var(--ink3);"><span>Tenure</span><span id="tenLabel"></span></div>

      <input type="range" id="tenSlider" min="6" max="48" step="6" value="24" oninput="calcEmi(${b.asking})"/>

      <div style="display:flex;justify-content:space-between;font-size:11.5px;font-weight:600;color:var(--ink3);"><span>Interest rate</span><span id="rateLabel"></span></div>

      <input type="range" id="rateSlider" min="9" max="18" step="0.5" value="13" oninput="calcEmi(${b.asking})"/>

     </div>

     <div class="emi-note" id="emiBreak"></div>

    </div>

    ${stat(b)==="booked"?`<div class="status-banner sb-booked">�# Reserved   20% received. ${holdDaysLeft(b)} day${holdDaysLeft(b)===1?"":"s"} left to complete finance/payment & delivery. If not completed, the amount is auto-refunded and the bike returns to Available.</div>`:''}

    ${stat(b)==="sold"?'<div class="status-banner sb-sold">' Sold   this motorcycle has found its rider. Similar stock arrives weekly.</div>':''}

    <div class="stack">

     ${stat(b)==="available"?`<button class="btn btn-gold btn-block" style="background:var(--gold);" onclick="openRules(${b.id})">�& Buy online (RTGS) � Delivered in 100 mins</button>`:''}

     ${stat(b)==="available"?`<button class="btn btn-block" style="background:var(--mustard);color:#141412;justify-content:center;" onclick="openRules(${b.id})">Block + test ride � 10% (${fmt(Math.round(b.asking*0.1/500)*500)})   refundable</button>`:''}

     ${stat(b)==="available"?`<button class="btn btn-block btn-light" style="justify-content:center;" onclick="openRules(${b.id})">Reserve 7 days � 20% (${fmt(Math.round(b.asking*0.2/500)*500)})   finance & delivery</button>`:''}

     ${(stat(b)==="available" && !admin)?`<button class="btn btn-dark btn-block" style="background:var(--ink);" onclick="openBook(${b.id})">Book test ride</button>`:''}

     ${stat(b)==="booked"?`<button class="btn btn-light btn-block" onclick="showToast('Added to waitlist   we\\'ll message if this booking releases')">Join waitlist   notify if released</button>`:''}

     ${stat(b)==="sold"?`<button class="btn btn-light btn-block" onclick="showToast('Noted! We\\'ll WhatsApp you when a similar ${b.name} arrives')">Notify me when similar arrives</button>`:''}

     <a class="btn btn-light btn-block" style="justify-content:center;text-decoration:none;" href="tel:+919035045535" onclick="callUs();return false;">=��� Call +91 90350 45535</a>

     ${admin?`<button class="btn btn-block" style="background:#141412;color:#fff;justify-content:center;" onclick="shareBike(${b.id})">=��� Send bike details on WhatsApp</button>`:''}

     <button class="btn btn-gold btn-block" onclick="window.open('https://wa.me/919035045535?text='+encodeURIComponent('Hi! I\\'m interested in the ${b.name} ${b.variant} (${dispReg(b)}) at ${fmt(b.asking)}.'),'_blank')">Enquire on WhatsApp</button>

     ${admin?`<button class="btn btn-light btn-block" onclick="closeDetail();openUpload(${b.id})">+ Manage photos (dealer)</button>`:''}

    </div>

    <div style="display:flex;flex-wrap:wrap;gap:6px;margin-top:16px;">

     <span style="font-size:11px;font-weight:700;background:var(--gold-bg);color:var(--gold-dark);padding:5px 11px;border-radius:var(--pill);">�& 100-min BLR delivery</span>

     <span style="font-size:11px;font-weight:700;background:var(--mustard-bg);color:#7a5c00;padding:5px 11px;border-radius:var(--pill);">�! 6-mo buyback @ 80%</span>

     <span style="font-size:11px;font-weight:700;background:var(--green-bg);color:var(--green);padding:5px 11px;border-radius:var(--pill);">�! Instant exchange</span>

    </div>

    <div style="margin-top:12px;" class="mono">Reown Certified � Chassis-verified � Ref 11269V</div>

    <button style="margin-top:8px;font-size:12.5px;font-weight:600;color:var(--gold);text-decoration:underline;" onclick="openRules()">How booking works   the Re-Own rules �!</button>

   </div>

  </div>`;



 document.getElementById("detailOv").classList.add("open");

 document.getElementById("detailOv").scrollTop=0;

 bindStage();

 setMode(mode);

 calcEmi(b.asking);

}

function closeDetail(){document.getElementById("detailOv").classList.remove("open");}



function setMode(m){

 const b=BIKES.find(x=>x.id===curId), md=media[curId];

 mode=m;

 document.getElementById("mGal").classList.toggle("on",m==="gallery");

 document.getElementById("mSpin").classList.toggle("on",m==="spin");

 const mv=document.getElementById("mVid"); if(mv)mv.classList.toggle("on",m==="video");

 const hasSpin=md.spin.length>1, hasGal=md.gallery.length>0;

 document.getElementById("degBadge").style.display=m==="spin"&&hasSpin?"block":"none";

 document.getElementById("dragHint").style.display=m==="spin"&&hasSpin?"flex":"none";

 document.getElementById("frameBar").style.display=m==="spin"&&hasSpin?"block":"none";

 document.getElementById("gnavL").style.display=m==="gallery"&&md.gallery.length>1?"flex":"none";

 document.getElementById("gnavR").style.display=m==="gallery"&&md.gallery.length>1?"flex":"none";

 renderStage(); renderThumbs();

}



function renderStage(){

 const b=BIKES.find(x=>x.id===curId), md=media[curId], st=document.getElementById("stage");

 if(mode==="video"){

  st.innerHTML=md.videos.length

   ?`<video src="${md.videos[0]}" controls playsinline style="width:100%;height:100%;object-fit:contain;background:#000;"></video>`

   :`<div class="empty-stage">${art(b)}<p>No video yet</p></div>`;

  return;

 }

 if(mode==="spin"){

  if(md.spin.length>1){

   st.innerHTML=`<img src="${md.spin[spinIdx]}" draggable="false"/>`;

   const deg=Math.round(spinIdx/md.spin.length*360);

   document.getElementById("degBadge").textContent=deg+"�";

   document.getElementById("frameFill").style.width=(spinIdx/(md.spin.length-1)*100)+"%";

  }else{

   st.innerHTML=`<div class="empty-stage">${art(b)}<p>No 360� frames yet${admin?'   switch to dealer upload to add a spin':''}</p>

    ${admin?`<button class="btn btn-gold btn-sm" onclick="closeDetail();openUpload(${b.id})">Upload 360� frames</button>`:''}</div>`;

  }

 }else{

  if(md.gallery.length){

   st.innerHTML=`<img src="${md.gallery[galIdx]}" draggable="false"/>`;

  }else{

   st.innerHTML=`<div class="empty-stage">${art(b)}<p>Professional photos coming soon${admin?'':'   enquire for a live video call inspection'}</p>

    ${admin?`<button class="btn btn-gold btn-sm" onclick="closeDetail();openUpload(${b.id})">Upload photos</button>`:''}</div>`;

  }

 }

}

function renderThumbs(){

 const md=media[curId], t=document.getElementById("thumbs");

 if(mode==="video"){

  t.innerHTML=md.videos.map((src,i)=>`<div class="thumb ${i===0?'on':''}" onclick="playVid(${i})"><video src="${src}" muted style="width:100%;height:100%;object-fit:cover;"></video></div>`).join('')

   +(admin?`<div class="thumb thumb-add" onclick="closeDetail();openUpload(${curId})"><span style="font-size:16px;">+</span><span>Add</span></div>`:'');

  return;

 }

 if(mode==="gallery"){

  t.innerHTML=md.gallery.map((src,i)=>`<div class="thumb ${i===galIdx?'on':''}" onclick="galIdx=${i};renderStage();renderThumbs();"><img src="${src}"/></div>`).join('')

   +(admin?`<div class="thumb thumb-add" onclick="closeDetail();openUpload(${curId})"><span style="font-size:16px;">+</span><span>Add</span></div>`:'');

 }else{

  t.innerHTML=md.spin.length>1

   ?`<div style="font-size:12.5px;color:var(--ink3);padding:6px 4px;font-weight:500;">�! ${md.spin.length} frames � drag the image left or right to rotate</div>`

   :(admin?`<div class="thumb thumb-add" onclick="closeDetail();openUpload(${curId})" style="width:auto;padding:0 16px;"><span>+ Upload 360� frame set</span></div>`

          :`<div style="font-size:12.5px;color:var(--ink3);padding:6px 4px;">360� spin being photographed   check back soon</div>`);

 }

}

function galStep(d){

 const md=media[curId]; if(!md.gallery.length)return;

 galIdx=(galIdx+d+md.gallery.length)%md.gallery.length;

 renderStage();renderThumbs();

}

function bindStage(){

 const st=document.getElementById("stage");

 const start=x=>{if(mode!=="spin")return;dragging=true;dragX=x;dragStart=spinIdx;st.classList.add("grabbing");};

 const move=x=>{

  if(!dragging||mode!=="spin")return;

  const md=media[curId]; if(md.spin.length<2)return;

  const per=Math.max(4, 320/md.spin.length); // px per frame

  let idx=Math.round(dragStart+(x-dragX)/per);

  spinIdx=((idx%md.spin.length)+md.spin.length)%md.spin.length;

  renderStage();

 };

 const end=()=>{dragging=false;st.classList.remove("grabbing");};

 st.onmousedown=e=>start(e.clientX);

 window.onmousemove=e=>move(e.clientX);

 window.onmouseup=end;

 st.ontouchstart=e=>start(e.touches[0].clientX);

 st.ontouchmove=e=>{move(e.touches[0].clientX);};

 st.ontouchend=end;

 // gallery swipe

 let gx=null;

 st.addEventListener("touchstart",e=>{if(mode==="gallery")gx=e.touches[0].clientX;});

 st.addEventListener("touchend",e=>{

  if(mode==="gallery"&&gx!==null){

   const dx=e.changedTouches[0].clientX-gx;

   if(Math.abs(dx)>40)galStep(dx<0?1:-1);

   gx=null;

  }

 });

}

function toggleAcc(i){

 document.getElementById("acc"+i).classList.toggle("open");

}

function emi(p,mo){const r=.014;return Math.round(p*.8*r*Math.pow(1+r,mo)/(Math.pow(1+r,mo)-1));}

function pickEmi(btn,mo,price){

 btn.parentElement.querySelectorAll("button").forEach(b=>b.classList.remove("on"));

 btn.classList.add("on");

 document.getElementById("emiNum").innerHTML=fmt(emi(price,mo))+'<span style="font-size:14px;font-weight:600;color:var(--ink3);">/mo</span>';

}



/* P%P%P%P%P%P%P%P%P%P% BOOKING P%P%P%P%P%P%P%P%P%P% */

const bookSel=document.getElementById("bookBike");

BIKES.forEach(b=>{const o=document.createElement("option");o.value=b.id;o.textContent=`${b.name} ${b.variant}   ${maskReg(b.reg)}`;bookSel.appendChild(o);});

function openBook(id){

 logEvt("Booking opened",id?("bike #"+id):"general");

 if(id)bookSel.value=id;

 closeDetail();

 document.getElementById("bookOv").classList.add("open");

}



/* P%P%P%P%P%P%P%P%P%P% SELL FLOW P%P%P%P%P%P%P%P%P%P% */

const sellPhotos=[];

function sellNext(step){

 [1,2,3].forEach(s=>{

  document.getElementById("sellStep"+s).style.display=s===step?"block":"none";

  const el=document.getElementById("st"+s);

  el.classList.toggle("on",s===step);

  el.classList.toggle("done",s<step);

 });

 if(step===1){sellPhotos.length=0;document.getElementById("sellPreviews").innerHTML="";}

}

const sellDrop=document.getElementById("sellDrop");

["dragover","dragenter"].forEach(e=>sellDrop.addEventListener(e,ev=>{ev.preventDefault();sellDrop.classList.add("drag");}));

["dragleave","drop"].forEach(e=>sellDrop.addEventListener(e,ev=>{ev.preventDefault();sellDrop.classList.remove("drag");}));

sellDrop.addEventListener("drop",ev=>addSellPhotos(ev.dataTransfer.files));

function addSellPhotos(files){

 [...files].filter(f=>f.type.startsWith("image/")).forEach(f=>{

  const r=new FileReader();

  r.onload=e=>{sellPhotos.push(e.target.result);renderSellPreviews();};

  r.readAsDataURL(f);

 });

  const cam = document.getElementById("sellFileCam"); if(cam) cam.value="";

  const gal = document.getElementById("sellFileGal"); if(gal) gal.value="";

}

function renderSellPreviews(){

 document.getElementById("sellPreviews").innerHTML=sellPhotos.map((src,i)=>`

  <div class="pv"><img src="${src}"/><button class="pv-x" onclick="sellPhotos.splice(${i},1);renderSellPreviews();">'</button></div>`).join('');

}

function computeEstimate(){

 const base={"Classic 350":128000,"Bullet 350":92000,"Hunter 350":115000,"Meteor 350":112000,"Scram 411":120000,"Himalayan":150000,"Interceptor 650":235000,"Continental GT 650":245000,"Other":100000};

 const yr={"2025":1.06,"2024":1.0,"2023":.92,"2022":.84,"2021":.76,"2020":.68,"2019":.6,"2018 or older":.5};

 const km={"Under 5,000 km":1.05,"5,000   15,000 km":1.0,"15,000   30,000 km":.92,"30,000   50,000 km":.82,"50,000+ km":.7};

 const cond={"Excellent   like new":1.06,"Good   minor wear":1.0,"Fair   visible wear":.88,"Needs work":.72};

 const v=Math.round(base[val("sModel")]*yr[val("sYear")]*km[val("sKm")]*cond[val("sCond")]/1000)*1000;

 document.getElementById("estValue").textContent=fmt(v);

 document.getElementById("estRange").textContent=`Range: ${fmt(Math.round(v*.94/1000)*1000)}   ${fmt(Math.round(v*1.06/1000)*1000)}`;

 sellNext(3);

}

function val(id){return document.getElementById(id).value;}



async function submitSell(){

 const n=val("sName");

 const req = {

  id: Date.now(),

  name: n || "Unknown",

  phone: val("sPhone") || "N/A",

  model: val("sModel"),

  year: val("sYear"),

  km: val("sKm"),

  cond: val("sCond"),

  estimate: document.getElementById("estValue").textContent,

  photos: [...sellPhotos],

  status: "new",

  date: new Date().toISOString()

 };

 await api('lead', {kind:'sell', name:n, phone:val('sPhone'), payload: req});

 showToast((n?n.split(" ")[0]+", your":"Your")+" estimate is locked   we'll call within 2 hours");

 sellNext(1);

 window.scrollTo({top:document.getElementById("sell").offsetTop-80,behavior:"smooth"});

}



async function submitBooking(){

 const bBikeId = val("bookBike");

 const bBike = BIKES.find(x => x.id == bBikeId) || {};

 const req = {

  id: Date.now(),

  bikeName: `${bBike.name} ${bBike.variant} (${bBike.reg})`,

  date: val("bookDate"),

  time: val("bookTime"),

  name: val("bookName") || "Unknown",

  phone: val("bookPhone") || "N/A",

  status: "new",

  submittedOn: new Date().toISOString()

 };

 await api('lead', {kind:'booking', bike_id:bBikeId, name:val('bookName'), phone:val('bookPhone'), payload: req});

 document.getElementById('bookOv').classList.remove('open');

 showToast("Test ride booked   we'll confirm on WhatsApp");

}



function openStaffDashboard(){

 document.getElementById("staffDashOv").classList.add("open");

 switchDashTab('sell');

}



function switchDashTab(tab){

 const tSell = document.getElementById("tabSell");

 const tBook = document.getElementById("tabBook");

 const bSell = document.getElementById("sellReqBody");

 const bBook = document.getElementById("bookReqBody");

 if(tab === 'sell'){

  tSell.style.color = "var(--gold)"; tBook.style.color = "var(--ink3)";

  bSell.style.display = "block"; bBook.style.display = "none";

  renderSellRequests();

 } else {

  tSell.style.color = "var(--ink3)"; tBook.style.color = "var(--gold)";

  bSell.style.display = "none"; bBook.style.display = "block";

  renderBookings();

 }

}



async function updateSellReqStatus(id, st){

 const r = SELL_REQUESTS.find(x => x.id === id);

 if(r){ r.status = st; await api('update_lead_status', {id, status:st}); renderSellRequests(); }

}

async function updateBookReqStatus(id, st){

 const r = BOOKING_REQUESTS.find(x => x.id === id);

 if(r){ r.status = st; await api('update_lead_status', {id, status:st}); renderBookings(); }

}



async function renderBookings(){

  const data = await api('get_leads');

  if(Array.isArray(data)) BOOKING_REQUESTS = data.filter(x => x.kind === 'booking').map(x => { let p = JSON.parse(x.payload||'{}'); return {id:x.id, status:x.status, submittedOn:x.created_at, name:x.name, phone:x.phone, bikeName: BIKES.find(b=>b.id==x.bike_id)?.name || ('Bike #'+x.bike_id), date:p.date, time:p.time}; });

 const body = document.getElementById("bookReqBody");

 if(BOOKING_REQUESTS.length===0){

  body.innerHTML = "<div style='color:var(--ink3);text-align:center;padding:40px;'>No booking requests yet.</div>"; return;

 }

 body.innerHTML = BOOKING_REQUESTS.map(r => `

  <div style="background:#f9f9f9;border-radius:var(--radius);padding:20px;border:1px solid var(--line);margin-bottom:16px;">

   <div style="display:flex;justify-content:space-between;align-items:flex-start;flex-wrap:wrap;gap:12px;">

    <div>

     <h3 style="margin:0;">${esc(r.name)} � <a href="tel:${esc(r.phone)}" style="color:var(--gold);text-decoration:none;">${esc(r.phone)}</a></h3>

     <div style="color:var(--ink3);font-size:14px;margin-top:6px;"><b>${esc(r.bikeName)}</b></div>

     <div style="font-weight:700;color:var(--mustard-dark);margin-top:6px;">Schedule: ${r.date} at ${r.time}</div>

    </div>

    <div style="text-align:right;">

     <div style="font-size:12px;color:var(--ink3);margin-bottom:12px;">${new Date(r.submittedOn).toLocaleString()}</div>

     ${r.status==='new' ? `<button class="btn btn-sm btn-dark" onclick="updateBookReqStatus(${r.id}, 'contacted')">Mark Contacted</button>` : 

       r.status==='contacted' ? `<span style="display:inline-block;padding:4px 8px;background:var(--mustard-bg);color:var(--mustard-dark);border-radius:4px;font-size:12px;font-weight:600;">Contacted</span> <button class="btn btn-sm btn-light" style="margin-left:8px;" onclick="updateBookReqStatus(${r.id}, 'closed')">Close</button>` : 

       `<span style="color:var(--green);font-weight:700;font-size:13px;">' Closed</span>`}

    </div>

   </div>

  </div>

 `).join('');

}



async function renderSellRequests(){

  const data = await api('get_leads');

  if(Array.isArray(data)) SELL_REQUESTS = data.filter(x => x.kind === 'sell').map(x => { let p = JSON.parse(x.payload||'{}'); return {id:x.id, status:x.status, date:x.created_at, name:x.name, phone:x.phone, model:p.model, year:p.year, km:p.km, cond:p.cond, estimate:p.estimate, photos:p.photos}; });

 const body = document.getElementById("sellReqBody");

 if(SELL_REQUESTS.length===0){

  body.innerHTML = "<div style='color:var(--ink3);text-align:center;padding:40px;'>No sell requests yet.</div>"; return;

 }

 body.innerHTML = SELL_REQUESTS.map(r => `

  <div style="background:#f9f9f9;border-radius:var(--radius);padding:20px;border:1px solid var(--line);margin-bottom:16px;">

   <div style="display:flex;justify-content:space-between;align-items:flex-start;flex-wrap:wrap;gap:12px;">

    <div>

     <h3 style="margin:0;">${esc(r.name)} � <a href="tel:${esc(r.phone)}" style="color:var(--gold);text-decoration:none;">${esc(r.phone)}</a></h3>

     <div style="color:var(--ink3);font-size:14px;margin-top:6px;"><b>${esc(r.model)}</b> (${esc(r.year)}) � ${esc(r.km)} � ${esc(r.cond)}</div>

     <div style="font-weight:700;color:var(--green);margin-top:6px;">Est: ${r.estimate}</div>

    </div>

    <div style="text-align:right;">

     <div style="font-size:12px;color:var(--ink3);margin-bottom:12px;">${new Date(r.date).toLocaleString()}</div>

     ${r.status==='new' ? `<button class="btn btn-sm btn-dark" onclick="updateSellReqStatus(${r.id}, 'contacted')">Mark Contacted</button>` : 

       r.status==='contacted' ? `<span style="display:inline-block;padding:4px 8px;background:var(--mustard-bg);color:var(--mustard-dark);border-radius:4px;font-size:12px;font-weight:600;">Contacted</span> <button class="btn btn-sm btn-light" style="margin-left:8px;" onclick="updateSellReqStatus(${r.id}, 'closed')">Close</button>` : 

       `<span style="color:var(--green);font-weight:700;font-size:13px;">' Closed</span>`}

    </div>

   </div>

   ${r.photos.length > 0 ? `

   <div style="display:flex;gap:8px;margin-top:16px;overflow-x:auto;">

    ${r.photos.map(p => `<a href="${p}" target="_blank"><img src="${p}" style="height:80px;border-radius:4px;object-fit:cover;width:100px;border:1px solid var(--line);"/></a>`).join('')}

   </div>` : '<div style="margin-top:12px;font-size:13px;color:var(--ink3);">No photos provided.</div>'}

  </div>

 `).join('');

}



function formatReg(el) {

 let v = el.value.toUpperCase().replace(/[^A-Z0-9]/g, '');

 let res = '';

 if (v.length > 0) res += v.slice(0, 2);

 if (v.length > 2) res += ' ' + v.slice(2, 4);

 if (v.length > 4) res += ' ' + v.slice(4, 6);

 if (v.length > 6) res += ' ' + v.slice(6, 10);

 el.value = res;

}



/* P%P%P%P%P%P%P%P%P%P% MISC P%P%P%P%P%P%P%P%P%P% */

function go(id,el){

 document.getElementById(id).scrollIntoView({behavior:"smooth"});

 if(el){document.querySelectorAll(".nav-item").forEach(n=>n.classList.remove("on"));el.classList.add("on");}

}

let toastT;

function showToast(msg){

 document.getElementById("toastMsg").textContent=msg;

 const t=document.getElementById("toast");

 t.classList.add("show");

 clearTimeout(toastT);

 toastT=setTimeout(()=>t.classList.remove("show"),3500);

}



renderGrid();











function playVid(i){

 const md=media[curId];

 const st=document.getElementById("stage");

 st.innerHTML=`<video src="${md.videos[i]}" controls autoplay playsinline style="width:100%;height:100%;object-fit:contain;background:#000;"></video>`;

}

/* P%P%P%P%P%P%P%P%P%P% REOWN PDP FEATURES P%P%P%P%P%P%P%P%P%P% */

function calcEmi(price){

 const dp=Number(document.getElementById("dpSlider").value);

 const ten=Number(document.getElementById("tenSlider").value);

 const rate=Number(document.getElementById("rateSlider").value);

 document.getElementById("dpLabel").textContent=dp+"% ("+fmt(Math.round(price*dp/100))+")";

 document.getElementById("tenLabel").textContent=ten+" months";

 document.getElementById("rateLabel").textContent=rate+"% p.a.";

 const P=price*(1-dp/100), r=rate/1200;

 const e=Math.round(P*r*Math.pow(1+r,ten)/(Math.pow(1+r,ten)-1));

 document.getElementById("emiNum").innerHTML=fmt(e)+'<span style="font-size:14px;font-weight:600;color:var(--ink3);">/mo</span>';

 document.getElementById("emiBreak").textContent="Loan "+fmt(Math.round(P))+" | Total interest "+fmt(Math.round(e*ten-P));

}

function toggleShortlist(id){

 const b=BIKES.find(x=>x.id===id);

 b.hearted=!b.hearted;

 b.shortlisted+=b.hearted?1:-1;

 const h=document.getElementById("heartBtn"),c=document.getElementById("shortCount");

 if(h)h.textContent=b.hearted?"d'�":">�
�";

 if(c)c.textContent=b.shortlisted+" people have shortlisted this bike";

 showToast(b.hearted?"Added to your shortlist":"Removed from shortlist");

}







/* P%P%P%P%P%P%P%P%P%P% WORKFLOW: ADD / APPROVE / EDIT / DELETE P%P%P%P%P%P%P%P%P%P% */

const MODEL_DEFAULTS={

 "Classic 350":{cc:350,power:"20.2 bhp",type:"Cruiser",hue:"#2E5C43",hue2:"#C9A84C",newPrice:240000,newRef:"Classic 350"},

 "Bullet 350":{cc:350,power:"19.1 bhp",type:"Classic",hue:"#141414",hue2:"#C9A84C",newPrice:210000,newRef:"Bullet 350"},

 "Hunter 350":{cc:350,power:"20.2 bhp",type:"Roadster",hue:"#191919",hue2:"#C8102E",newPrice:177000,newRef:"Hunter 350"},

 "Meteor 350":{cc:350,power:"20.2 bhp",type:"Tourer",hue:"#6E3F23",hue2:"#D8A868",newPrice:260000,newRef:"Meteor 350"},

 "Scram 411":{cc:411,power:"24.3 bhp",type:"Scrambler",hue:"#E8B400",hue2:"#2b2b2e",newPrice:270000,newRef:"Scram 440"},

 "Himalayan":{cc:411,power:"24.3 bhp",type:"Adventure",hue:"#3E7CB8",hue2:"#1c3a58",newPrice:390000,newRef:"Himalayan 450"},

 "Interceptor 650":{cc:650,power:"47 bhp",type:"Roadster",hue:"#55565a",hue2:"#1b1b1d",newPrice:425000,newRef:"Interceptor 650"},

 "Continental GT 650":{cc:650,power:"47 bhp",type:"Caf� Racer",hue:"#B01E28",hue2:"#F2E6C8",newPrice:450000,newRef:"Continental GT 650"},

};

function openAddBike(){

 document.getElementById("addOv").classList.add("open");

}

async function submitBike(){

 const g=id=>document.getElementById(id).value;

 const model=g("abModel"),variant=g("abVariant")||"Standard",reg=g("abReg").toUpperCase()||"KA00XX0000";

 const yr=Number(g("abYear")),km=g("abKm")||" ",price=Number(g("abPrice"))||100000;

 const d=MODEL_DEFAULTS[model]||MODEL_DEFAULTS["Classic 350"];

 

 const res = await api('add_bike', {

  name: model, variant: variant, reg: reg, year: yr, km: km, owner: g("abOwner"), ins: g("abIns"),

  cc: d.cc, asking: price, market: Math.round(price*1.15), newPrice: d.newPrice, newRef: d.newRef,

  hue: d.hue, hue2: d.hue2, type: d.type, power: d.power

 });

 

 document.getElementById("addOv").classList.remove("open");

 if (res && res.ok) {

   showToast(res.approval === 'approved' ? "Motorcycle published to showroom" : "Submitted   waiting for Manager approval");

   await initApp();

 } else {

   showToast("Failed to submit bike");

 }

}

async function approveBike(id){

 const res = await api('approve', {id});

 if(res && res.ok){ showToast("Bike approved & live"); await initApp(); }

}

async function denyBike(id){

 const res = await api('deny', {id});

 if(res && res.ok){ showToast("Bike denied"); await initApp(); }

}

async function deleteBike(id){

 if(!confirm("Delete this bike permanently?"))return;

 const res = await api('delete_bike', {id});

 if(res && res.ok){ showToast("Listing deleted"); await initApp(); }

}

async function editPrice(id){

 const b=BIKES.find(x=>x.id===id);

 const v=prompt("New asking price for "+b.name+" ("+b.reg+"):",b.asking);

 if(v===null)return;

 const asking=Number(v);

 if(asking) {

  const res = await api('set_price', {id, asking});

  if(res && res.ok){ showToast("Price updated to "+fmt(asking)); await initApp(); }

 }

}



/* P%P%P%P%P%P%P%P%P%P% DIRECTOR DASHBOARD P%P%P%P%P%P%P%P%P%P% */

async function openMonitor(){

 const d=document.getElementById("monBody");

 const res = await api('monitor');

 if(!res || res.error) { showToast("Monitor data not available"); return; }

 const {stats, log, top_bikes, by_role} = res;

 d.innerHTML=`

  <div style="display:grid;grid-template-columns:repeat(3,1fr);gap:10px;margin-bottom:20px;">

   ${[["Logins",stats.logins],["Bike views",stats.views],["Enquiries",stats.leads],["Bikes added",stats.added],["Total events",stats.total_events]].map(([l,v])=>`

    <div style="background:#f6f5f0;border-radius:12px;padding:14px;text-align:center;">

     <div style="font-family:'Oswald',sans-serif;font-size:24px;font-weight:700;color:var(--gold);">${v||0}</div>

     <div style="font-size:10px;font-weight:700;letter-spacing:1.5px;text-transform:uppercase;color:var(--ink3);margin-top:2px;">${l}</div>

    </div>`).join("")}

  </div>

  <div class="d-label">Activity by role</div>

  <div style="display:flex;gap:8px;flex-wrap:wrap;margin-bottom:20px;">

   ${by_role.map(r=>`<span style="font-size:12px;font-weight:700;background:var(--gold-bg);color:var(--gold-dark);padding:6px 14px;border-radius:980px;">${r.role}: ${r.c} actions</span>`).join("")}

  </div>

  <div class="d-label">Most viewed bikes</div>

  ${top_bikes.length?top_bikes.map(b=>`

   <div style="display:flex;justify-content:space-between;padding:8px 0;border-bottom:1px solid var(--line);font-size:13.5px;">

    <span><b>${b.name}</b> ${b.variant} � ${b.reg}</span><b style="color:var(--gold);">${b.views} views</b>

   </div>`).join(""):'<div style="font-size:13px;color:var(--ink3);padding:8px 0;">No bike views yet.</div>'}

  <div class="d-label" style="margin-top:20px;">Activity log (latest first)</div>

  <div style="max-height:260px;overflow-y:auto;border:1.5px solid var(--line);border-radius:12px;">

   ${log.map(a=>`

    <div style="display:flex;gap:10px;padding:9px 14px;border-bottom:1px solid var(--line);font-size:12.5px;align-items:baseline;">

     <span style="color:var(--ink3);white-space:nowrap;font-variant-numeric:tabular-nums;">${new Date(a.created_at).toLocaleTimeString()}</span>

     <b style="color:${a.role==="Director"?"#6a3a8a":a.role==="Manager"?"var(--gold)":a.role==="Executive"?"var(--green)":"var(--ink3)"};white-space:nowrap;">${a.role}</b>

     <span><b>${a.action}</b>${a.detail?"   "+a.detail:""}</span>

    </div>`).join("")}

  </div>`;

 document.getElementById("monOv").classList.add("open");

}



/* P%P%P%P%P%P%P%P%P%P% DELIVERY WALL P%P%P%P%P%P%P%P%P%P% */

const dummyDeliveries=[

 {img:null,bikeId:12,name:"GT 640 Rocker",sub:"Delivered � Indiranagar � \u2605\u2605\u2605\u2605\u2605"},

 {img:null,bikeId:11,name:"Interceptor 650",sub:"Delivered in 100 mins � Whitefield"},

 {img:null,bikeId:1,name:"Classic 350",sub:"First bike! � Koramangala � \u2605\u2605\u2605\u2605\u2605"},

 {img:null,bikeId:9,name:"Himalayan",sub:"Ladakh-ready � HSR Layout"},

 {img:null,bikeId:4,name:"Hunter 350",sub:"Same-day delivery � JP Nagar"},

 {img:null,bikeId:5,name:"Meteor 350",sub:"Weekend cruiser � Hebbal � \u2605\u2605\u2605\u2605\u2605"},

 {img:null,bikeId:2,name:"Scram 411",sub:"Trail time � Sarjapur"},

 {img:null,bikeId:7,name:"Bullet 350",sub:"The classic choice � Jayanagar"},

];

let deliveries=[...dummyDeliveries];

function renderDeliveries(){

 const t=document.getElementById("dwallTrack");

 if(!t)return;

 const card=d=>{

  const b=BIKES.find(x=>x.id===d.bikeId)||BIKES[0];

  return `<div class="dcard">

   <div class="dcard-img">${d.img?`<img src="${d.img}"/>`:art(b)}<div class="dcard-tick">\u2713 Delivered</div></div>

   <div class="dcard-cap"><div class="dcard-name">${d.name}</div><div class="dcard-sub">${d.sub}</div></div>

  </div>`;

 };

 const half=deliveries.map(card).join("");

 t.innerHTML=half+half; /* duplicate for seamless loop */

}

async function addDeliveries(files){

 const imgs=[...files].filter(f=>f.type.startsWith("image/"));

 let n=0;

 for (const f of imgs) {

  const r=new FileReader();

  r.onload=async e=>{

   const res = await api('add_delivery', {

    bike_id: 1, name: "Happy Rider", sub: "Delivered", img: e.target.result

   });

   n++;

   if(n===imgs.length){

    await initApp();

    showToast(n+" delivery photo"+(n>1?"s":"")+" added to the wall");

   }

  };

  r.readAsDataURL(f);

 }

 document.getElementById("dwallFile").value="";

}



/* P%P%P%P%P%P%P%P%P%P% HERO PHOTO (dealer) P%P%P%P%P%P%P%P%P%P% */

async function setHeroPhoto(files){

  if(!files||!files[0])return;

  const fd = new FormData();

  fd.append('files[]', files[0]);

  fd.append('kind', 'hero');

  try {

    const res = await fetch('api/index.php?action=upload', {method: 'POST', body: fd});

    const data = await res.json();

    if(data.ok && data.files.length) {

      const bg=document.getElementById("heroBg");

      bg.style.backgroundImage=`url(${data.files[0]})`;

      const bike = bg.querySelector(".hero-bike");

      if(bike) bike.style.display="none";

      showToast("Hero photo updated");

    } else {

      showToast("Upload failed");

    }

  } catch(e) {

    showToast("Upload error");

  }

}



/* P%P%P%P%P%P%P%P%P%P% DEALER STATUS CONTROL P%P%P%P%P%P%P%P%P%P% */

function renderStPills(b){

 const el=document.getElementById("stPills");

 if(!el)return;

 const s=stat(b);

 el.innerHTML=["available","booked","sold"].map(x=>

  `<button class="st-pill ${s===x?'on-'+x:''}" onclick="setStatus(${b.id},'${x}')">${x==="booked"?"Booked (20%)":x}</button>`).join("");

}

async function setStatus(id,s){

 const res = await api('set_status', {id, status: s});

 if(res && res.ok){

  await initApp();

  showToast("Bike marked "+(s==="booked"?"Booked   7-day hold started":s.charAt(0).toUpperCase()+s.slice(1)));

 }

}

function openRules(bikeId){

 closeDetail();

 document.getElementById("rulesOv").classList.add("open");

 document.getElementById("rulesOv").scrollTop=0;

}



/* P%P%P%P%P%P%P%P%P%P% NEW ARRIVALS P%P%P%P%P%P%P%P%P%P% */

function daysAgo(d){return Math.max(0,Math.floor((Date.now()-new Date(d))/(864e5)));}

function isFresh(b){return daysAgo(b.arrived)<=10;}

function renderArrivals(){

 const row=document.getElementById("arrivalsRow");

 if(!row)return;

 const recent=[...BIKES].filter(b=>stat(b)!=="sold").sort((a,b)=>new Date(b.arrived)-new Date(a.arrived)).slice(0,6);

 row.innerHTML=recent.map(b=>{

  const m=media[b.id];const cover=m.gallery[0]||m.spin[0];const d=daysAgo(b.arrived);

  return `<div class="arr-card" onclick="openDetail(${b.id})">

   <div class="arr-media">

    ${cover?`<img src="${cover}"/>`:art(b)}

    ${isFresh(b)?'<div class="arr-new">New</div>':''}

    ${m.spin.length>1?'<div class="tag-360" style="top:10px;right:10px;">�! 360�</div>':''}

   </div>

   <div class="arr-body">

    <div class="arr-name">${b.name}</div>

    <div class="arr-meta">${b.year} � ${b.variant} � ${b.reg}</div>

    <div class="arr-price">${fmt(b.asking)}</div>

    <div class="arr-days">${d===0?"Arrived today":d===1?"Arrived yesterday":"Arrived "+d+" days ago"}</div>

   </div>

  </div>`;

 }).join("");

}







async function initApp() {

  const me = await api('me');

  if(me.role) { role = me.role; setAdmin(true); }

  const data = await api('bikes');

  if(Array.isArray(data)) { 

    BIKES = data.map(db => ({

       ...db, 

       year: db.model_year,

       newPrice: db.new_price,

       owner: db.owner_count,

       insValid: db.ins_valid,

       arrived: db.created_at,

       newRef: db.new_ref,

       acc: []

    }));

    BIKES.forEach(b => { 

      media[b.id] = {gallery: b.cover ? [b.cover] : [], spin:[], videos:[]};

    });

    renderGrid();

  }

  const delivs = await api('get_deliveries');

  if(Array.isArray(delivs)) {

    deliveries = [...delivs, ...dummyDeliveries];

  }

  renderDeliveries();

  if (role) {

    await renderSellRequests();

    await renderBookings();

  }

}

initApp();

</script>

</body>

</html>



Back to Directory �������}�!1AQa"q2���#B��R��$3br� %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz�������������������������������������������������������������������������������� ������w�!1AQaq"2�B���� #3R�br� $4�%�&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz������������������������������������������������������������������������ ��?��_��+��?��(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(�����