/* --- CARLOAD AUTOMOTIVE UI (CAR-SCREEN HARDENED) --- */
:root{
  --primary:#00f2ff;
  --primary-dim:rgba(0,242,255,.15);
  --secondary:#7000ff;
  --accent-hot:#ff0055;
  --success:#00ffcc;

  --text:#ffffff;
  --text-soft:rgba(255,255,255,.72);
  --text-dim:rgba(255,255,255,.55);

  --bg-deep:#050508;
  --bg-grad:linear-gradient(135deg,#050508 0%,#0a0a14 100%);
  --glass-surface:rgba(20,20,30,.95);
  --glass-border:rgba(255,255,255,.10);
  --glass-highlight:rgba(255,255,255,.15);

  --font-main:'Cairo',sans-serif;
  --font-tech:'Rajdhani',sans-serif;

/* === تعديلات الزوايا (10px) === */
  --radius-lg: 12px; /* للحاويات الكبيرة */
  --radius-md: 10px; /* للكروت والعناصر المتوسطة */
  --radius-sm: 6px;  /* للعناصر الصغيرة */

  --shadow-soft:0 4px 15px rgba(0,0,0,.30);

  /* Smart sizes (car screens) */
  --pad: clamp(4px, 0.5vw, 8px);
  --gap: clamp(6px, 0.6vw, 10px);
--sidebarW: clamp(70px, 8vw, 100px);
  --topbarH: clamp(60px, 7vw, 80px);
  --hit: 50px; 
  --txt: clamp(14px, 1.4vw, 18px);
  --txt2: clamp(18px, 2.2vw, 28px);
  --txt3: clamp(22px, 3.0vw, 42px);

  --app-vh: 1vh;
  --overscan: 2px; /* ضد قص شاشات السيارات */
}

[data-theme="light"]{
  --bg-deep:#eef2f5;
  --bg-grad:linear-gradient(135deg,#eef2f5 0%,#dde6ee 100%);
  --glass-surface:rgba(255,255,255,.96);
  --glass-border:rgba(0,0,0,.10);
  --glass-highlight:rgba(0,0,0,.06);
  --primary:#0b5cff;
  --primary-dim:rgba(11,92,255,.12);
  --success:#00a884;
  --accent-hot:#e6004c;
  --text:#14161b;
  --text-soft:rgba(20,22,27,.75);
  --text-dim:rgba(20,22,27,.58);
}

*{
  box-sizing:border-box;
  -webkit-tap-highlight-color:transparent;
  outline:none;
  user-select:none;
}

html, body{
  height:100%;
}

body{
  margin:0;
  background-color:var(--bg-deep);
  background-image:var(--bg-grad);
  color:var(--text);
  font-family:var(--font-main);
  overflow:hidden;

  text-rendering:optimizeSpeed;
}

body::before{
  content:'';
  position:absolute;
  inset:0;
  background:url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  z-index:-1;
  pointer-events:none;
}

/* -------- Utilities -------- */
.muted{ color: var(--text-soft); }
.mono{ font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; }

.ico{ font-size: 1.6rem; }
.big-ico{ font-size: 3rem; filter: drop-shadow(0 0 10px rgba(0,242,255,.25)); }

.screen-title{
  margin: 0 0 18px 0;
  font-size: var(--txt2);
  font-weight: 300;
}

.empty-hint{
  grid-column:1/-1;
  text-align:center;
  color: var(--text-dim);
  padding: 40px 10px;
}

/* -------- Layout -------- */
.os-container{
  display:grid;
  grid-template-columns: var(--sidebarW) 1fr;
  grid-template-rows: var(--topbarH) 1fr;
  height: 100%;
  padding: var(--pad);
  gap: var(--gap);
}

/* -------- Sidebar -------- */
.sidebar{
  grid-row:1/-1;
  background:var(--glass-surface);
  border:1px solid var(--glass-border);
  border-radius: 10px;
  display:flex;
  flex-direction:column;
  align-items:center;
  padding: clamp(14px, 2vw, 24px) 0;
  z-index:100;
  box-shadow:var(--shadow-soft);
}

.nav-item{
  width: var(--hit);
  height: var(--hit);
  margin-bottom: 8px;
  border-radius: var(--radius-md);
  border:none;
  background:transparent;
  color: rgba(255,255,255,.45);
  cursor:pointer;
  display:flex;
  align-items:center;
  justify-content:center;
  transition: transform .15s ease, background .15s ease, color .15s ease;
  position:relative;
  overflow:hidden;
}
.nav-item:active{ transform: scale(.97); }
.nav-item:hover{ color:var(--text); background: rgba(255,255,255,.06); }

.nav-item::after{
  content:'';
  position:absolute;
  bottom:8px;
  left:50%;
  transform:translateX(-50%);
  width:4px;
  height:4px;
  border-radius:50%;
  background:var(--primary);
  opacity:0;
  transition:.15s ease;
}
.nav-item.active{
  background: linear-gradient(135deg, rgba(255,255,255,.10), rgba(255,255,255,0));
  color: var(--primary);
  box-shadow: inset 0 0 0 1px var(--glass-border);
}
.nav-item.active::after{
  opacity:1;
  width: 20px;
  height: 3px;
  border-radius: 10px;
}

.sidebar-bottom{
  margin-top:auto;
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:10px;
  padding-bottom: 8px;
}

.mini-btn{
  width: 46px;
  height: 46px;
  border-radius: 14px;
  border:1px solid var(--glass-border);
  background: rgba(0,0,0,.20);
  color:var(--text);
  font-weight:800;
  cursor:pointer;
  transition:.15s;
}
.mini-btn:active{ transform: scale(.95); }
.mini-btn.danger{ border-color: var(--accent-hot); color: var(--accent-hot); }

.mini-btn.install{
  border-color: var(--primary);
  color: var(--primary);
}
.mini-btn.install:hover{
  background: var(--primary);
  color:#000;
}

/* -------- Top Bar -------- */
.top-bar{
  grid-column:2;
  display:flex;
  justify-content:space-between;
  align-items:center;
  padding: 0 16px;
  background:var(--glass-surface);
  border:1px solid var(--glass-border);
  border-radius: var(--radius-md);
  overflow:hidden;
}

.brand-text{
  font-family:var(--font-tech);
  font-weight:700;
  font-size: clamp(18px, 2.1vw, 28px);
  letter-spacing:2px;
  text-transform:uppercase;
  background: linear-gradient(90deg, #fff, var(--primary));
  -webkit-background-clip:text;
  -webkit-text-fill-color:transparent;
}
.brand-pro{
  color: rgba(255,255,255,.55);
  font-size: .9rem;
  margin-inline-start: 6px;
  -webkit-text-fill-color: rgba(255,255,255,.55);
}

.top-right{
  display:flex;
  align-items:center;
  gap: 16px;
  text-align:start;
}

.os-info{ line-height: 1.2; }
.os-name{ display:block; font-weight:700; color:var(--text); font-size: .9rem; letter-spacing:.3px; }
.os-ver{ font-family: var(--font-tech); color: var(--primary); font-size: .9rem; }

.top-sep{
  width:1px; height: 32px;
  background: rgba(255,255,255,.10);
}

#clock{
  font-family:var(--font-tech);
  font-size: clamp(18px, 2.2vw, 34px);
  font-weight: 500;
  letter-spacing: 1.6px;
}

/* -------- Viewport/Screens -------- */
.viewport{
  grid-column:2;
  grid-row:2;
  position:relative;
  overflow:hidden;
  border-radius: var(--radius-lg);
  background: rgba(0,0,0,.20);
}

.screen{
  position:absolute;
  inset:0;
  padding: 10px;
  opacity:0;
  transform: scale(.99);
  pointer-events:none;
  overflow-y:auto;
  transition: opacity .22s ease, transform .22s ease;
  scrollbar-width:none;
  will-change: opacity, transform;
  overscroll-behavior: contain;
}
.screen::-webkit-scrollbar{ display:none; }
.screen.active{
  opacity:1;
  transform: scale(1);
  pointer-events:all;
}

/* -------- Grid/Cards -------- */
.grid{
  display:grid;
  grid-template-columns: repeat(auto-fit, minmax(clamp(130px, 18vw, 200px), 1fr));
  gap: var(--gap);
  margin-top: 10px;
}

/* -------- Model Picker (car WebView safe spacing) -------- */
#step-model #model-grid{
  /* some car WebViews ignore grid gap, so we force flex and use margins */
  display:flex;
  flex-wrap:wrap;
  justify-content:center;
  align-items:stretch;
  margin-top: 10px;

  gap: 0; /* prevent double-spacing in modern browsers */
  margin-inline: calc(var(--gap) * -0.5);
}
#step-model #model-grid .card{
  flex: 0 1 clamp(210px, 18vw, 320px);
  max-width: 380px;
  margin: calc(var(--gap) * 0.5);
}

.card{
  background:var(--glass-surface);
  border:1px solid var(--glass-border);
  border-top:1px solid var(--glass-highlight);
  border-radius: var(--radius-md);
  padding: 12px;
  cursor:pointer;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap: 14px;
  text-align:center;
  transition: transform .15s ease, border-color .15s ease;
  position:relative;
  overflow:hidden;
  min-height: 110px;
}
.card:active{ transform: scale(.985); }
.card:hover{ transform: translateY(-2px); border-color: rgba(0,242,255,.45); }

.card img{
  width: 76px;
  height: 76px;
  object-fit: contain;
}

.card-title{
  font-size: clamp(14px, 1.5vw, 18px);
  font-weight: 800;
  color:var(--text);
}

/* -------- Dashboard Hero -------- */
.hero-card{
  background: radial-gradient(circle at 90% 50%, rgba(0,242,255,.10) 0%, rgba(20,20,30,.95) 60%);
  border:1px solid rgba(255,255,255,.10);
  border-radius: var(--radius-md);
  padding: 16px 24px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 16px;
  position:relative;
  overflow:hidden;
  box-shadow: 0 10px 30px rgba(0,0,0,.20);
}

.car-info h2{
  font-size: var(--txt3);
  margin:0;
  font-family:var(--font-tech);
  text-transform:uppercase;
  letter-spacing:1px;
}

.pill{
  display:inline-block;
  padding: 6px 14px;
  background: rgba(255,255,255,.08);
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,.10);
  margin-top: 12px;
}
.year-pill{
  color: var(--success);
  font-weight: 900;
  font-family: var(--font-tech);
}

#dash-logo{
  width: min(520px, 52%);
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 10px 20px rgba(0,0,0,.40));
  opacity: 1;
}

/* -------- Installer -------- */
.modal-overlay{
  position:fixed;
  inset:0;
  background: rgba(0,0,0,.92);
  z-index:2000;
  display:flex;
  align-items:center;
  justify-content:center;
  opacity:0;
  pointer-events:none;
  transition: opacity .2s ease;
}
.modal-overlay.active{ opacity:1; pointer-events:all; }

.installer-box{
  background:#14141d;
  width: min(520px, 92vw);
  max-height: 85dvh;
  overflow-y:auto;
  padding: clamp(16px, 2.2vw, 24px);
  border-radius: 26px;
  border:1px solid rgba(255,255,255,.10);
  text-align:center;
  box-shadow: 0 0 50px rgba(0,242,255,.05);
  scrollbar-width: thin;
  scrollbar-color: var(--primary) transparent;
}

#inst-icon{
  width: 96px;
  height: 96px;
  border-radius: 22px;
  margin-bottom: 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,.50);
}

#inst-title{
  margin:0;
  font-size: clamp(20px, 2.2vw, 28px);
}

.progress-track{
  background:#222;
  height: 6px;
  width:100%;
  border-radius: 10px;
  margin: 18px 0;
  overflow:hidden;
}
.progress-fill{
  background: var(--primary);
  height:100%;
  width:0%;
  transition: width .10s linear;
}

.step-list{
  text-align: start;
  margin-top: 16px;
  background: rgba(255,255,255,.03);
  padding: 16px;
  border-radius: 18px;
}

/* -------- Wizard -------- */
.wizard-overlay{
  position:fixed;
  inset:0;
  z-index:999;
  background:#050508;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  transition: opacity .35s ease;
  box-sizing:border-box;
  padding:
    calc(env(safe-area-inset-top) + var(--overscan, 14px))
    calc(env(safe-area-inset-right) + var(--overscan, 14px))
    calc(env(safe-area-inset-bottom) + var(--overscan, 14px))
    calc(env(safe-area-inset-left) + var(--overscan, 14px));
  overflow:hidden;
}
.wizard-overlay.hidden{ opacity:0; pointer-events:none; }

.step{
  opacity:0;
  transform: translateY(10px);
  transition: .22s ease;
  display:none;
  width:100%;
  max-width: 1100px;
  max-height: 100%;
  min-height: 0;
  padding: 18px;
  overflow: hidden;
}
.step.active{ display:block; opacity:1; transform: translateY(0); }

.step-center{ text-align:center; }

/* -------- Wizard: center selection screens -------- */
#step-brand, #step-model, #step-year{
  flex: 1 1 auto; /* take full height so we can center vertically */
}

#step-brand.active,
#step-model.active,
#step-year.active{
  display:flex; /* override .step.active{display:block} */
  flex-direction:column;
  align-items:center;
  justify-content:center;
  text-align:center;
  overflow:auto; /* avoid clipping on smaller screens */
  scrollbar-width:none;
  gap: 22px;
}

#step-brand.active{ gap: 14px; }

#step-brand.active::-webkit-scrollbar,
#step-model.active::-webkit-scrollbar,
#step-year.active::-webkit-scrollbar{ display:none; }

/* Wizard grids: keep cards grouped in the center (no full-stretch) */
.wizard-overlay .grid{
  width: min(1100px, 100%);
  margin-inline: auto;
  justify-content: center;
  align-content: center;
  grid-template-columns: repeat(auto-fit, minmax(clamp(160px, 18vw, 220px), 220px));
}

/* Larger titles for model/year */
#step-model .wiz-title,
#step-year .wiz-title{
  font-size: clamp(28px, 4vw, 58px);
  font-weight: 800;
  line-height: 1.15;
  margin: 0;
}


.logo-big{
  font-family: var(--font-tech);
  font-size: clamp(44px, 6vw, 64px);
  font-weight: 900;
  color:var(--text);
  letter-spacing: -2px;
}
.logo-accent{ color: var(--primary); }
.logo-line{
  width: 110px;
  height: 4px;
  background: var(--primary);
  margin: 10px auto 26px;
  box-shadow: 0 0 20px rgba(0,242,255,.35);
}

.wiz-title{
  font-size: clamp(18px, 2.6vw, 34px);
  margin: 0 0 22px 0;
  font-weight: 300;
}
.wiz-title.big{ margin-bottom: 18px; }

.wiz-actions{
  margin-top: 22px;
  display:flex;
  justify-content:center;
  gap: 12px;
  flex-wrap: wrap;
}

.center-actions{
  text-align:center;
  margin-top: 18px;
}

/* ===== WIZARD COMPACT FIT (shrink instead of scroll) ===== */
@media (max-height: 560px){
  .logo-big{ font-size: clamp(34px, 6.2vh, 54px); }
  .logo-line{ margin: 8px auto 16px; }
  .wiz-title{ font-size: clamp(15px, 2.6vh, 24px); margin: 0 0 14px 0; }
  .wiz-actions{ margin-top: 14px; gap: 10px; }
  .btn-action{ padding: 12px 18px; min-height: 50px; }
  .card{ min-height: 120px; padding: 14px; border-radius: 22px; }
  .card img{ width: 64px; height: 64px; }
}

@media (max-height: 460px){
  .step{ padding: 12px; }
  .logo-big{ font-size: clamp(30px, 6vh, 44px); }
  .logo-line{ margin: 6px auto 12px; width: 90px; }
  .wiz-title{ font-size: clamp(14px, 2.4vh, 20px); margin: 0 0 10px 0; }
  .grid{ margin-top: 12px; }
  .card{ min-height: 106px; padding: 12px; border-radius: 20px; gap: 10px; }
  .card img{ width: 56px; height: 56px; }
  .btn-action{ padding: 10px 16px; min-height: 46px; }
}

/* Buttons */
.btn-action{
  min-height: var(--hit);
  padding: 14px 22px;
  border-radius: 999px;
  border:1px solid rgba(255,255,255,.20);
  background: rgba(255,255,255,.06);
  color:var(--text);
  cursor:pointer;
  font-weight: 900;
  font-size: clamp(14px, 1.5vw, 18px);
  font-family: var(--font-main);
  transition: transform .15s ease, background .15s ease, border-color .15s ease, color .15s ease;
}
.btn-action:active{ transform: scale(.98); }
.btn-action:hover{ background: var(--primary); border-color: var(--primary); color:#000; }

.btn-done{
  width:100%;
  margin-top: 14px;
  border-color: var(--success);
  background: rgba(0,255,200,.10);
  color: var(--success);
}
.btn-done:hover{ background: var(--success); border-color: var(--success); color:#000; }

.btn-gps{
  border-color: var(--primary);
  color: var(--primary);
}

/* Badge */
.dl-badge{
  position:absolute;
  top: 12px;
  inset-inline-end: 12px;
  background: rgba(0,0,0,.80);
  padding: 5px 10px;
  border:1px solid rgba(255,255,255,.10);
  border-radius: 8px;
  font-size: .72rem;
  font-weight: 900;
  color: rgba(255,255,255,.60);
}

/* -------- Centers -------- */
.centers-head{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

/* شبكة المراكز */
#centers-grid{
  display:grid;
  grid-template-columns: repeat(auto-fill, minmax(clamp(220px, 25vw, 320px), 1fr));
  gap: var(--gap);
  padding-bottom: 40px;
}

.service-card{
  background:var(--glass-surface);
  border:1px solid var(--glass-border);
  border-radius: 18px;
  padding: 16px;
  position:relative;
  transition: transform .15s ease, border-color .15s ease;
  display:flex;
  flex-direction:column;
  gap: 12px;
  min-height: 170px;
}
.service-card:hover{ transform: translateY(-3px); border-color: var(--primary); }

.service-top{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap: 12px;
}
.status-badge{
  font-size: .72rem;
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 900;
  border:1px solid var(--glass-border);
  background: rgba(0,0,0,.35);
  backdrop-filter: blur(6px);
  white-space:nowrap;
}
[data-theme="light"] .status-badge{
  background: rgba(255,255,255,.75);
}
.status-badge.open{ background: rgba(0,255,204,.18); color: var(--success); }
.status-badge.closed{ background: rgba(255,0,85,.18); color: var(--accent-hot); }

.service-icon{
  width: 50px;
  height: 50px;
  background: rgba(255,255,255,.06);
  border-radius: 12px;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size: 1.8rem;
}

.service-info h3{
  margin: 0 0 6px 0;
  font-size: clamp(14px, 1.5vw, 18px);
  color:var(--text);
}
.service-info .address{
  margin:0;
  font-size: .86rem;
  opacity:.70;
  line-height: 1.35;
}

.meta-row{
  display:flex;
  gap: 12px;
  font-size: .86rem;
  color: var(--primary);
  margin-bottom: 6px;
  font-weight: 900;
  font-family: var(--font-tech);
  flex-wrap: wrap;
}

.action-row{
  display:flex;
  gap: 10px;
  margin-top:auto;
}

.btn-map{
  flex:1;
  min-height: 44px;
  background: var(--primary-dim);
  border: 1px solid var(--primary);
  color: var(--primary);
  padding: 8px 10px;
  border-radius: 12px;
  cursor:pointer;
  font-weight: 900;
  font-size: .95rem;
  transition: .15s;
}
.btn-map:hover{ background: var(--primary); color:#000; }

.btn-call{
  width: 52px;
  min-height: 44px;
  background: rgba(255,255,255,.06);
  border:1px solid var(--glass-border);
  color:var(--text);
  border-radius: 12px;
  cursor:pointer;
}
.btn-call:hover{ background:var(--text); color:#000; }

/* Filter tabs */
.filter-btn{
  min-height: 44px;
  background: transparent;
  border: 1px solid var(--glass-border);
  color: rgba(255,255,255,.70);
  padding: 8px 16px;
  border-radius: 999px;
  cursor:pointer;
  white-space:nowrap;
}
.filter-btn.active{
  background: var(--primary);
  color:#000;
  border-color: var(--primary);
  font-weight: 900;
}

/* Join card */
.join-card{
  border: 1px dashed rgba(255,215,0,.55) !important;
  background: linear-gradient(135deg, rgba(255,215,0,.06) 0%, rgba(0,0,0,0) 100%) !important;
  cursor:pointer;
  justify-content:center;
  text-align:center;
}
.join-card:hover{
  background: rgba(255,215,0,.10) !important;
  border-color: #ffd700 !important;
}
.join-card .service-info{ align-items:center; }

/* -------- Portrait / Compact / Wide Modes -------- */
body.is-portrait .os-container{
  grid-template-columns: 1fr;
  grid-template-rows: var(--topbarH) 1fr clamp(76px, 9vw, 96px);
}
body.is-portrait .sidebar{
  grid-row:3;
  flex-direction: row;
  justify-content: space-around;
  width: 100%;
  border-radius: var(--radius-md);
  padding: 10px 10px;
}
body.is-portrait .sidebar-bottom{
  margin-top: 0;
  flex-direction: row;
  gap: 10px;
  padding-bottom: 0;
}
body.is-portrait .top-bar{
  grid-column: 1;
}
body.is-portrait .viewport{
  grid-column: 1;
}
body.is-portrait .hero-card{
  flex-direction: column-reverse;
  text-align: center;
}
body.is-portrait #dash-logo{
  width: min(360px, 78%);
}

body.is-compact .hero-card{
  padding: 14px 16px;
  border-radius: 26px;
}
body.is-compact .card{
  border-radius: 10px;
  padding: 14px;
  min-height: 120px;
}
body.is-compact .nav-item{
  width: 52px;
  height: 52px;
  border-radius: 18px;
}

body.is-wide .hero-card{
  border-radius: var(--radius-md);
}

/* Reduce motion */
@media (prefers-reduced-motion: reduce){
  *{ transition: none !important; animation: none !important; }
}

/* Touch devices: disable hover styling noise */
@media (hover: none){
  .card:hover{ transform: none; }
  .nav-item:hover{ background: transparent; }
}

[data-theme="light"] body::before{ opacity:.35; }

/* =========================================================
   Centers — badge/icon overlay fix (scoped to #centers-grid)
   Prevents the status badge from becoming a full-width bar,
   and prevents overlap with title on car screens.
   ========================================================= */
#centers-grid .service-card{
  padding-top: 58px; /* reserve space for overlay row */
}

#centers-grid .status-badge{
  position: absolute;
  top: 12px;
  inset-inline-start: 12px; /* RTL/LTR friendly */
  z-index: 3;

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

  width: max-content;
  max-width: calc(100% - 110px); /* leave room for icon */
  overflow: hidden;
  text-overflow: ellipsis;

  padding: 7px 12px;
  font-size: .78rem;
  line-height: 1;
}

#centers-grid .service-icon{
  position: absolute;
  top: 12px;
  inset-inline-end: 12px;
  z-index: 3;
}

/* =========================================================
   Manual (Vehicle Guide) — Scoped to #screen-manual only
   ========================================================= */
#screen-manual .manual-shell{
  display:grid;
  grid-template-columns: clamp(260px, 28vw, 360px) 1fr;
  gap: var(--gap);
  height: calc(100% - 12px);
  min-height: 0;
}
#screen-manual .manual-panel{
  background: var(--glass-surface);
  border:1px solid var(--glass-border);
  border-top:1px solid var(--glass-highlight);
  border-radius: 22px;
  overflow:hidden;
  display:flex;
  flex-direction:column;
  min-height: 0;
}
#screen-manual .manual-head{
  padding: 14px 16px;
  border-bottom: 1px solid var(--glass-border);
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 10px;
}
#screen-manual .manual-title{
  font-size: clamp(16px, 1.8vw, 22px);
  font-weight: 900;
  margin:0;
  color: var(--text);
}
#screen-manual .manual-sub{
  font-size: .86rem;
  color: var(--text-soft);
  margin-top: 2px;
}
#screen-manual .manual-btn{
  height: 44px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--glass-border);
  background: rgba(255,255,255,.06);
  color: var(--text);
  cursor:pointer;
  font-weight: 900;
  transition:.15s;
}
#screen-manual .manual-btn:hover{ background: var(--primary); color:#000; border-color: var(--primary); }
#screen-manual .manual-btn:active{ transform: scale(.98); }
#screen-manual .manual-search{
  padding: 12px 16px;
  border-bottom: 1px solid var(--glass-border);
}
#screen-manual .manual-search input{
  width:100%;
  height: 46px;
  border-radius: 14px;
  border: 1px solid var(--glass-border);
  background: rgba(0,0,0,.18);
  color: var(--text);
  padding: 0 14px;
  font-size: 15px;
  font-weight: 700;
}
[data-theme="light"] #screen-manual .manual-search input{ background: rgba(255,255,255,.75); }
#screen-manual .manual-list{
  overflow:auto;
  padding: 12px;
  display:flex;
  flex-direction:column;
  gap: 10px;
  min-height: 0;
}
#screen-manual .manual-item{
  background: rgba(255,255,255,.05);
  border:1px solid var(--glass-border);
  border-radius: 16px;
  padding: 12px 12px;
  cursor:pointer;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 10px;
  transition:.15s;
}
#screen-manual .manual-item:hover{ border-color: rgba(0,242,255,.40); transform: translateY(-1px); }
#screen-manual .manual-item:active{ transform: scale(.99); }
#screen-manual .manual-item .left{
  display:flex;
  align-items:center;
  gap: 10px;
  min-width: 0;
}
#screen-manual .manual-ico{
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display:flex;
  align-items:center;
  justify-content:center;
  background: rgba(0,242,255,.10);
  border: 1px solid rgba(0,242,255,.25);
  font-size: 1.3rem;
  flex: 0 0 auto;
}
#screen-manual .manual-name{
  font-weight: 900;
  color: var(--text);
  white-space: nowrap;
  overflow:hidden;
  text-overflow: ellipsis;
}
#screen-manual .manual-meta{
  font-size: .82rem;
  color: var(--text-soft);
  margin-top: 3px;
}
#screen-manual .manual-item .chev{
  color: var(--primary);
  font-weight: 900;
  flex: 0 0 auto;
}
#screen-manual .manual-item.active{
  background: linear-gradient(135deg, rgba(0,242,255,.14), rgba(255,255,255,.03));
  border-color: rgba(0,242,255,.55);
}
#screen-manual .manual-content{
  overflow:auto;
  padding: 16px;
  min-height: 0;
}
#screen-manual .manual-breadcrumb{
  display:flex;
  align-items:center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  color: var(--text-soft);
  font-weight: 800;
  font-size: .9rem;
}
#screen-manual .manual-breadcrumb .crumb{
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--glass-border);
  background: rgba(255,255,255,.05);
}
#screen-manual .manual-h1{
  margin: 0 0 8px 0;
  color: var(--primary);
  font-size: clamp(18px, 2.2vw, 30px);
  font-weight: 900;
}
#screen-manual .manual-h2{
  margin: 14px 0 8px 0;
  color: var(--text);
  font-size: clamp(15px, 1.7vw, 22px);
  font-weight: 900;
}
#screen-manual .manual-p{
  margin: 0 0 10px 0;
  color: var(--text-soft);
  line-height: 1.7;
  font-size: clamp(14px, 1.35vw, 17px);
  white-space: pre-line;
}
#screen-manual .kb-card{
  border-radius: 18px;
  border: 1px solid var(--glass-border);
  background: rgba(255,255,255,.05);
  padding: 14px;
  margin: 10px 0;
}
#screen-manual .kb-card .tag{
  display:inline-flex;
  align-items:center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  font-weight: 900;
  font-size: .82rem;
  border: 1px solid var(--glass-border);
  background: rgba(0,0,0,.25);
  margin-bottom: 10px;
}
#screen-manual .kb-card.warn .tag{ color: #ffcc00; border-color: rgba(255,204,0,.35); background: rgba(255,204,0,.10); }
#screen-manual .kb-card.info .tag{ color: var(--primary); border-color: rgba(0,242,255,.35); background: rgba(0,242,255,.10); }
#screen-manual .kb-card.step .tag{ color: var(--success); border-color: rgba(0,255,204,.35); background: rgba(0,255,204,.10); }
#screen-manual .kb-steps{ margin: 0; padding-inline-start: 18px; }
#screen-manual .kb-steps li{
  margin: 6px 0;
  color: var(--text-soft);
  line-height: 1.65;
  font-weight: 700;
}
body.is-portrait #screen-manual .manual-shell{ grid-template-columns: 1fr; }

/* ===== FINAL VIEWPORT OVERRIDES (KEEP THIS LAST) ===== */

html, body{
  margin: 0;
  height: 100%;
  overflow: hidden;
}

body{
  /* الارتفاع الحقيقي (يتغذّى من JS) */
  height: calc(var(--app-vh, 1vh) * 100);
  min-height: calc(var(--app-vh, 1vh) * 100);

  /* Safe area + overscan حتى ما ينقص فوق/جوه ببعض شاشات/لانشرات */
  padding:
    calc(env(safe-area-inset-top) + var(--overscan, 14px))
    calc(env(safe-area-inset-right) + var(--overscan, 14px))
    calc(env(safe-area-inset-bottom) + var(--overscan, 14px))
    calc(env(safe-area-inset-left) + var(--overscan, 14px));
}

/* خلي كل الحاويات تاخذ 100% بدون ما تكسر الحساب */
.app-container,
.os-container,
.viewport{
  height: 100%;
  min-height: 0;
}





/* =========================================
   RE-DESIGNED INSTALLER MODAL (V3 - Compact & Pro)
   ========================================= */

/* الصندوق الرئيسي - مضغوط وأنيق */
.installer-box.wide-layout {
  display: flex;
  flex-direction: row;
  /* عرض أصغر بكثير ومحدد */
  width: min(620px, 92vw);
  /* الارتفاع تلقائي بناء على المحتوى */
  height: auto;
  min-height: 220px; 
  text-align: right;
  /* خلفية داكنة موحدة وهادئة */
  background: #1a1a22;
  border: 1px solid rgba(255, 255, 255, 0.06);
  /* زوايا نصف قطرها أصغر لتبدو أكثر جدية */
  border-radius: 12px;
  /* ظل ناعم جداً وغير مشتت */
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.4);
  padding: 0;
  overflow: hidden;
}

/* فواصل رفيعة جداً بين الأعمدة */
.inst-col-meta, .inst-col-steps {
    border-left: 1px solid rgba(255, 255, 255, 0.05);
}

/* --- 1. Right Column: App Info (مصغر) --- */
.inst-col-meta {
  flex: 0 0 160px; /* عرض عمود أصغر */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px 15px; /* هوامش ضيقة */
  background: rgba(255,255,255,0.01);
}

#inst-icon {
  width: 64px; /* أيقونة بحجم قياسي */
  height: 64px;
  border-radius: 14px;
  margin-bottom: 12px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

#inst-title {
  font-size: 1.1rem; /* خط عنوان أصغر وأنيق */
  font-weight: 600;
  margin: 0 0 6px 0;
  color: rgba(255,255,255,0.95);
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#inst-status {
  font-size: 0.75rem; /* نص حالة دقيق */
  letter-spacing: 0.5px;
  padding: 3px 8px;
  border-radius: 4px;
  background: rgba(0, 255, 204, 0.08);
  color: var(--primary);
}

.progress-track.compact {
  margin-top: 12px;
  height: 3px; /* شريط تقدم رفيع جداً */
  background: rgba(255,255,255,0.08);
}

/* --- 2. Center Column: Steps (قائمة نظيفة) --- */
.inst-col-steps {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 20px 25px;
}

.step-list.clean-list {
  gap: 6px; /* مسافة قريبة بين الخطوات */
}

.step-item {
  display: flex;
  align-items: baseline;
  font-size: 0.92rem; /* خط خطوات صغير ومقروء */
  color: rgba(255,255,255,0.75);
  padding: 4px 0;
  background: transparent;
  border: none;
}

/* تنسيق الأرقام (يتطلب تعديل الـ JS أعلاه ليعمل بدقة) */
.step-num {
    color: var(--primary);
    font-family: var(--font-tech);
    font-weight: 500;
    margin-left: 8px;
    opacity: 0.8;
    font-size: 0.9rem;
}
.step-text {
    line-height: 1.4;
}

/* --- 3. Left Column: Action (زر قياسي) --- */
.inst-col-action {
  flex: 0 0 130px; /* مساحة ضيقة للزر */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 15px;
  background: rgba(255,255,255,0.01);
}

.btn-wide-cta {
  width: 100%;
  height: 44px; /* ارتفاع زر قياسي احترافي */
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: 8px; /* زوايا صغيرة */
  gap: 8px;
  background: var(--success);
  color: #000;
  box-shadow: none; /* إزالة التوهج لتبدو أكثر جدية */
  border: 1px solid rgba(0,0,0,0.1);
  transition: all 0.2s ease;
}

.btn-wide-cta:hover {
    background: #00e6b8; /* تفتيح بسيط عند التحويم */
    transform: translateY(-1px);
}

.btn-wide-cta .ico {
  font-size: 1.1rem;
}

/* --- Mobile Fallback (Responsive) --- */
@media (max-width: 650px) {
  .installer-box.wide-layout {
    flex-direction: column;
    width: 90vw;
    min-height: auto;
    padding: 15px;
  }
  .inst-col-meta, .inst-col-steps, .inst-col-action {
    border-left: none;
    width: 100%;
    padding: 10px 5px;
    flex: auto;
  }
  .inst-col-meta { 
      border-bottom: 1px solid rgba(255,255,255,0.05); 
      flex-direction: row; /* في الموبايل نجعل الأيقونة بجانب الاسم لتوفير الطول */
      justify-content: flex-start;
      gap: 15px;
      text-align: right;
      align-items: center;
  }
  .inst-meta-text { align-items: flex-start; display: flex; flex-direction: column; }
  #inst-icon { margin-bottom: 0; width: 50px; height: 50px; }
  .inst-col-steps { padding-top: 15px; }
}

/* =========================================
   INSTALLER MODAL (V4 - CAR SCREEN PRO)
   - Bigger touch targets
   - Readable from distance
   - Fits short-height displays (cars)
   ========================================= */

.modal-overlay{
  background: rgba(0,0,0,.86);
  box-sizing: border-box;
  padding:
    calc(env(safe-area-inset-top) + var(--overscan, 14px))
    calc(env(safe-area-inset-right) + var(--overscan, 14px))
    calc(env(safe-area-inset-bottom) + var(--overscan, 14px))
    calc(env(safe-area-inset-left) + var(--overscan, 14px));
}

.installer-box.wide-layout{
  width: min(980px, 94vw);
  max-height: calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 28px);
  border-radius: 22px;
  background: rgba(18,18,24,.96);
  border: 1px solid rgba(255,255,255,.08);
  box-shadow: 0 18px 60px rgba(0,0,0,.55);
}

/* Column sizing tuned for 800x480 and 1024x600 */
.installer-box.wide-layout .inst-col-meta{ flex: 0 0 220px; padding: 22px 18px; }
.installer-box.wide-layout .inst-col-steps{ padding: 22px 28px; }
.installer-box.wide-layout .inst-col-action{ flex: 0 0 220px; padding: 18px; }

.installer-box.wide-layout #inst-icon{
  width: 72px;
  height: 72px;
  border-radius: 16px;
  margin-bottom: 12px;
}

.installer-box.wide-layout #inst-title{
  font-size: clamp(18px, 1.9vw, 22px);
  font-weight: 800;
  margin: 0 0 8px 0;
}

.installer-box.wide-layout #inst-status{
  font-size: clamp(12px, 1.2vw, 14px);
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(0, 255, 204, 0.10);
  color: var(--primary);
}

.installer-box.wide-layout .progress-track.compact{
  height: 4px;
  margin-top: 14px;
}

.installer-box.wide-layout .step-list.clean-list{
  display:flex;
  flex-direction: column;
  gap: 10px;
  background: transparent;
  padding: 0;
  margin-top: 0;
}

.installer-box.wide-layout .step-item{
  font-size: clamp(16px, 1.7vw, 20px);
  line-height: 1.35;
  padding: 10px 0;
  color: rgba(255,255,255,.86);
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.installer-box.wide-layout .step-item:last-child{ border-bottom: 0; }

.installer-box.wide-layout .step-num{
  font-size: clamp(14px, 1.3vw, 16px);
  opacity: .95;
}
.installer-box.wide-layout .step-text{ flex: 1; }

html[dir="rtl"] .installer-box.wide-layout .step-item{ flex-direction: row-reverse; }
html[dir="rtl"] .installer-box.wide-layout .step-num{ margin-left: 12px; margin-right: 0; }
html[dir="ltr"] .installer-box.wide-layout .step-num{ margin-right: 12px; margin-left: 0; }

.installer-box.wide-layout .step-item.is-ok .step-text{ color: rgba(255,255,255,.95); }

/* Primary CTA for car touch screens */
.installer-box.wide-layout .btn-wide-cta{
  height: 60px;
  font-size: clamp(18px, 1.6vw, 20px);
  border-radius: 14px;
  touch-action: manipulation;
}

/* Disabled state if you choose to disable it via JS */
.installer-box.wide-layout .btn-wide-cta[disabled],
.installer-box.wide-layout .btn-wide-cta.disabled{
  opacity: .55;
  filter: grayscale(.2);
  box-shadow: none;
  pointer-events: none;
}

/* Short-height (common in-car) */
@media (max-height: 520px){
  .installer-box.wide-layout{ width: min(920px, 96vw); }
  .installer-box.wide-layout .inst-col-meta{ flex-basis: 200px; padding: 18px 14px; }
  .installer-box.wide-layout .inst-col-steps{ padding: 18px 20px; }
  .installer-box.wide-layout .inst-col-action{ flex-basis: 200px; padding: 14px; }
  .installer-box.wide-layout #inst-icon{ width: 64px; height: 64px; }
  .installer-box.wide-layout .btn-wide-cta{ height: 54px; }
  .installer-box.wide-layout .step-item{ padding: 8px 0; }
}
