:root{
  --navy:#061b33;--navy2:#0b315f;--blue:#144bff;--blue2:#2b67ff;--bg:#eef3fa;--card:#ffffff;
  --text:#111827;--muted:#667085;--border:#d9e3ef;--ok:#079455;--warn:#dc8900;--danger:#d92d20;--purple:#5b5fc7;
  --shadow:0 18px 50px rgba(16,24,40,.08);--shadow2:0 8px 25px rgba(16,24,40,.08)
}
*{box-sizing:border-box}
body{margin:0;font-family:"Segoe UI",Arial,sans-serif;background:
radial-gradient(circle at top left,rgba(20,75,255,.10),transparent 32%),
linear-gradient(180deg,#f7faff,var(--bg));color:var(--text)}
.app-shell{min-height:100vh}
.sidebar{position:fixed;left:18px;top:18px;bottom:18px;width:292px;background:linear-gradient(180deg,var(--navy),var(--navy2));color:white;padding:18px;border-radius:28px;box-shadow:0 24px 60px rgba(6,27,51,.28);overflow:hidden}
.sidebar:before{content:"";position:absolute;right:-80px;top:-70px;width:190px;height:190px;background:rgba(20,75,255,.28);border-radius:50%}
.brand{position:relative;display:flex;align-items:center;gap:13px;margin-bottom:24px;padding-bottom:18px;border-bottom:1px solid rgba(255,255,255,.12)}
.logo-wrap{width:76px;height:64px;background:white;border-radius:18px;display:flex;align-items:center;justify-content:center;box-shadow:0 8px 22px rgba(0,0,0,.18)}
.side-logo{width:68px;height:56px;object-fit:contain}
.brand-title{font-size:27px;font-weight:900;letter-spacing:.5px}
.brand-sub{font-size:12px;color:#d5e2f2;line-height:1.35}
.nav-section{font-size:11px;text-transform:uppercase;letter-spacing:.12em;color:#91a8c4;margin:18px 10px 8px}
.nav{display:flex;align-items:center;gap:10px;color:white;text-decoration:none;padding:13px 14px;border-radius:15px;margin:6px 0;font-weight:650;transition:.18s}
.nav:hover{background:rgba(255,255,255,.12);transform:translateX(3px)}
.powered{position:absolute;bottom:16px;left:18px;right:18px;font-size:12px;color:#dce7f5;text-align:center;border-top:1px solid rgba(255,255,255,.16);padding-top:14px}
.powered span{display:block;color:#99adc8}.powered b{font-size:14px}
.main{margin-left:328px;padding:18px 18px 18px 0}
.topbar{height:78px;background:rgba(255,255,255,.82);backdrop-filter:blur(12px);border:1px solid rgba(217,227,239,.9);border-radius:24px;display:flex;align-items:center;justify-content:space-between;padding:0 24px;box-shadow:var(--shadow2)}
.top-title{font-weight:850;color:#14213d}.top-sub{font-size:12px;color:var(--muted);margin-top:4px}
.user-box{display:flex;align-items:center;gap:12px}.avatar{width:42px;height:42px;border-radius:14px;background:linear-gradient(135deg,var(--blue),#78a2ff);color:white;display:flex;align-items:center;justify-content:center;font-weight:900}.user-box span{display:block;color:var(--muted);font-size:12px;margin-top:2px}.logout{color:var(--navy);text-decoration:none;font-weight:800;background:#eef4ff;padding:9px 13px;border-radius:12px}
.content{padding:24px 4px}
.hero{background:linear-gradient(135deg,#0b315f,#144bff);color:white;border-radius:28px;padding:28px;display:flex;justify-content:space-between;align-items:center;margin-bottom:20px;box-shadow:0 20px 45px rgba(20,75,255,.22);position:relative;overflow:hidden}
.hero:after{content:"";position:absolute;right:-70px;bottom:-90px;width:240px;height:240px;background:rgba(255,255,255,.12);border-radius:50%}
.hero.compact{padding:24px}.hero h1{margin:0;font-size:34px}.hero p{margin:8px 0 0;color:#dbe8ff}.hero-badge{position:relative;background:rgba(255,255,255,.16);padding:10px 14px;border-radius:999px;font-weight:800}
.card{background:rgba(255,255,255,.92);border:1px solid rgba(217,227,239,.95);border-radius:24px;padding:22px;margin-bottom:18px;box-shadow:var(--shadow)}
.card-head{display:flex;justify-content:space-between;align-items:flex-start;margin-bottom:12px}.card-title{font-size:19px;font-weight:900}.card-head p,.upload-card p{color:var(--muted);margin:6px 0 0}
.stats{display:grid;grid-template-columns:repeat(6,1fr);gap:14px;margin-bottom:20px}.stat{position:relative;overflow:hidden}.stat:after{content:"";position:absolute;right:-28px;top:-28px;width:88px;height:88px;border-radius:50%;background:#edf4ff}.stat span{display:block;color:var(--muted);font-size:13px;font-weight:750}.stat b{display:block;font-size:30px;margin-top:8px}.stat small{display:block;color:var(--muted);margin-top:6px}.stat.ok b{color:var(--ok)}.stat.warning b{color:var(--warn)}.stat.danger b{color:var(--danger)}.stat.purple b{color:var(--purple)}.stat.premium b{color:var(--blue)}
.table-card{overflow:auto}table{width:100%;border-collapse:separate;border-spacing:0}th,td{padding:14px 12px;border-bottom:1px solid var(--border);text-align:left;vertical-align:top}th{font-size:11px;text-transform:uppercase;letter-spacing:.04em;color:var(--muted);background:#f8fbff}tr:hover td{background:#fbfdff}a{color:#0b5cab;font-weight:800;text-decoration:none}
.badge{display:inline-flex;align-items:center;padding:7px 11px;border-radius:999px;background:#e8eef5;font-size:12px;font-weight:850}.badge.big{font-size:14px;padding:10px 14px}.badge.working{background:#e6f7ef;color:var(--ok)}.badge.out-of-service{background:#feeceb;color:var(--danger)}.badge.under-maintenance{background:#fff3dc;color:var(--warn)}.badge.waiting-parts{background:#edeeff;color:var(--purple)}
.btn,button{background:linear-gradient(135deg,var(--blue),var(--blue2));color:white;border:0;border-radius:14px;padding:12px 17px;font-weight:850;cursor:pointer;text-decoration:none;display:inline-block;box-shadow:0 10px 22px rgba(20,75,255,.22)}.btn.ghost{background:#eef4ff;color:var(--blue);box-shadow:none}
input,select,textarea{width:100%;padding:12px 13px;border:1px solid #cfd8e3;border-radius:14px;background:white;margin:6px 0 14px;font-family:inherit;outline:none}input:focus,select:focus,textarea:focus{border-color:var(--blue);box-shadow:0 0 0 4px rgba(20,75,255,.10)}textarea{min-height:90px}label{font-size:13px;font-weight:800;color:#344054}.form-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:14px}.grid-2{display:grid;grid-template-columns:1fr 1fr;gap:18px}.search{display:flex;gap:12px}.search input{margin:0}.search button{white-space:nowrap}.muted{color:var(--muted)}.small{font-size:12px}
.login-page{min-height:100vh;display:flex;align-items:center;justify-content:center;background:radial-gradient(circle at 20% 20%,rgba(20,75,255,.35),transparent 30%),linear-gradient(135deg,var(--navy),#0a2f5a 55%,#0e48a5);position:relative;overflow:hidden}.login-bg-card{position:absolute;width:700px;height:700px;border-radius:90px;background:rgba(255,255,255,.08);transform:rotate(18deg);right:-170px;top:-170px}.login-card{width:500px;background:rgba(255,255,255,.94);backdrop-filter:blur(15px);border:1px solid rgba(255,255,255,.55);border-radius:32px;padding:38px;box-shadow:0 30px 80px rgba(0,0,0,.32);text-align:center}.login-logo-img{width:200px;height:138px;object-fit:contain;margin-bottom:8px}.login-chip{display:inline-block;background:#eef4ff;color:var(--blue);font-weight:900;font-size:12px;padding:7px 12px;border-radius:999px;margin-bottom:8px}.login-card h1{font-size:44px;margin:0;color:var(--navy);letter-spacing:.5px}.login-card h2{font-size:18px;margin:6px 0 4px;color:#23324a}.login-card form{text-align:left;margin-top:24px}.login-card button{width:100%;margin-top:8px}.powered-login{font-weight:900;color:var(--blue);margin-top:18px}.error{background:#feeceb;color:var(--danger);padding:10px;border-radius:14px;margin:14px 0}
@media(max-width:1200px){.stats{grid-template-columns:repeat(3,1fr)}.form-grid{grid-template-columns:1fr 1fr}.grid-2{grid-template-columns:1fr}}
.powered em{
  display:block;
  margin-top:8px;
  font-style:normal;
  font-weight:900;
  color:#ffffff;
  background:rgba(255,255,255,.12);
  padding:7px 10px;
  border-radius:999px;
}
.made-saudi{
  margin:6px 0 0;
  font-weight:900;
  color:#0b7a45;
  background:#e8f7ef;
  display:inline-block;
  padding:7px 13px;
  border-radius:999px;
}

/* HDAMS V8 - Real Leaflet Map */
.grid-map{
  display:grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap:18px;
  margin-bottom:18px;
}
.map-card-real{
  min-height:610px;
}
#saudiLeafletMap{
  height:510px;
  width:100%;
  border-radius:22px;
  overflow:hidden;
  border:1px solid var(--border);
  background:#dbeafe;
  box-shadow:inset 0 0 0 1px rgba(255,255,255,.55);
}
.leaflet-container{
  font-family:"Segoe UI",Arial,sans-serif;
}
.asset-count-label{
  background:transparent;
  border:0;
}
.asset-count-label span{
  width:26px;
  height:26px;
  border-radius:50%;
  color:white;
  display:flex;
  align-items:center;
  justify-content:center;
  font-weight:1000;
  font-size:13px;
  text-shadow:0 1px 2px rgba(0,0,0,.45);
}
.map-note{
  display:flex;
  gap:16px;
  align-items:center;
  margin-top:12px;
  color:var(--muted);
  font-weight:800;
  font-size:13px;
}
.map-note .dot{
  display:inline-block;
  width:11px;
  height:11px;
  border-radius:50%;
  margin-right:6px;
}
.dot.ok{background:var(--ok)}
.dot.warning{background:var(--warn)}
.dot.danger{background:var(--danger)}
.map-popup h3{
  margin:0 0 10px;
  color:#061b33;
}
.popup-kpis{
  display:grid;
  grid-template-columns:repeat(2,1fr);
  gap:6px;
  margin-bottom:10px;
}
.popup-kpis span{
  background:#f3f7fd;
  border:1px solid #d9e3ef;
  border-radius:10px;
  padding:7px;
  font-size:12px;
  color:#667085;
}
.popup-kpis b{
  display:block;
  color:#061b33;
  font-size:16px;
}
.popup-list{
  max-height:230px;
  overflow:auto;
}
.popup-asset{
  border-top:1px solid #e5edf6;
  padding:8px 0;
}
.popup-asset span,.popup-asset small{
  display:block;
  color:#667085;
  margin-top:2px;
}
.sites-panel{
  min-height:610px;
}
@media(max-width:1200px){
  .grid-map{grid-template-columns:1fr}
  .sites-panel{min-height:auto}
}

.danger-btn{
  background:linear-gradient(135deg,#d92d20,#f04438)!important;
}

/* HDAMS language selector */
.language-selector{
  width:auto;
  min-width:118px;
  margin:0;
  padding:9px 12px;
  border-radius:12px;
  font-weight:800;
  background:#eef4ff;
  color:#061b33;
  border:1px solid #d9e3ef;
}
html[dir="rtl"] body{
  direction:rtl;
}
html[dir="rtl"] .sidebar{
  left:auto;
  right:18px;
}
html[dir="rtl"] .main{
  margin-left:18px;
  margin-right:328px;
  padding:18px 0 18px 18px;
}
html[dir="rtl"] th, html[dir="rtl"] td{
  text-align:right;
}
html[dir="rtl"] .user-box, html[dir="rtl"] .brand, html[dir="rtl"] .nav{
  flex-direction:row-reverse;
}

/* HDAMS Arabic professional layout fix */
html[dir="rtl"] body{
  direction:rtl;
  font-family:"Segoe UI",Tahoma,Arial,sans-serif;
}
html[dir="rtl"] .sidebar{
  left:auto!important;
  right:18px!important;
}
html[dir="rtl"] .main{
  margin-left:18px!important;
  margin-right:328px!important;
  padding:18px 0 18px 18px!important;
}
html[dir="rtl"] .brand{
  flex-direction:row-reverse;
  text-align:right;
}
html[dir="rtl"] .nav{
  flex-direction:row-reverse;
  justify-content:flex-start;
  text-align:right;
}
html[dir="rtl"] .nav-section{
  text-align:right;
}
html[dir="rtl"] .topbar,
html[dir="rtl"] .hero,
html[dir="rtl"] .card-head,
html[dir="rtl"] .page-title{
  flex-direction:row-reverse;
}
html[dir="rtl"] .user-box{
  flex-direction:row-reverse;
}
html[dir="rtl"] .content,
html[dir="rtl"] .card,
html[dir="rtl"] .login-card{
  text-align:right;
}
html[dir="rtl"] th,
html[dir="rtl"] td{
  text-align:right!important;
}
html[dir="rtl"] input,
html[dir="rtl"] textarea,
html[dir="rtl"] select{
  direction:rtl;
  text-align:right;
}
html[dir="rtl"] .search{
  flex-direction:row-reverse;
}
html[dir="rtl"] .stats,
html[dir="rtl"] .form-grid,
html[dir="rtl"] .grid-2,
html[dir="rtl"] .grid-map{
  direction:rtl;
}
html[dir="rtl"] .leaflet-container{
  direction:ltr;
}
html[dir="rtl"] .map-popup{
  direction:rtl;
  text-align:right;
}
html[dir="rtl"] .popup-kpis{
  direction:rtl;
}
html[dir="rtl"] .powered{
  direction:rtl;
}
.language-selector{
  direction:ltr!important;
  text-align:left!important;
}
html[dir="rtl"] .login-card form{
  text-align:right;
}
html[dir="rtl"] .login-logo-img{
  display:block;
  margin-left:auto;
  margin-right:auto;
}

/* HDAMS final Arabic refinements */
html[dir="rtl"] .brand-sub,
html[dir="rtl"] .top-title,
html[dir="rtl"] .top-sub{
  letter-spacing:0;
}
html[dir="rtl"] table td,
html[dir="rtl"] table th{
  white-space:normal;
}
html[dir="rtl"] .popup-asset small,
html[dir="rtl"] .popup-asset span{
  text-align:right;
}
html[dir="rtl"] .map-note{
  flex-direction:row-reverse;
  justify-content:flex-start;
}

/* FINAL KPI CLEANUP
   Remove the top KPI label line completely to avoid clipping in Arabic/RTL.
   Keep only the main number and the explanatory text below. */
.stats .stat span{
  display:none !important;
}
.stats .stat{
  min-height:150px !important;
  padding:26px 20px 22px 20px !important;
  display:flex;
  flex-direction:column;
  justify-content:center;
}
.stats .stat b{
  margin:0 0 10px 0 !important;
  line-height:1.1 !important;
}
.stats .stat small{
  display:block !important;
  line-height:1.45 !important;
  white-space:normal !important;
  overflow:visible !important;
}
html[dir="rtl"] .stats .stat{
  text-align:right !important;
  align-items:flex-start;
}
html[dir="rtl"] .stats .stat small{
  text-align:right !important;
}
.stats .stat:after{
  width:70px !important;
  height:70px !important;
  top:-20px !important;
  right:-20px !important;
}
html[dir="rtl"] .stats .stat:after{
  right:auto !important;
  left:-20px !important;
}

/* HDAMS Enterprise V2 Clean Sidebar Fix */
.sidebar{
  overflow-y:auto !important;
  overflow-x:hidden !important;
  padding-bottom:24px !important;
}
.powered{
  display:none !important;
}
.app-footer{
  margin:22px 4px 4px;
  padding:14px 18px;
  border:1px solid var(--border);
  background:rgba(255,255,255,.78);
  border-radius:18px;
  color:var(--muted);
  display:flex;
  justify-content:center;
  align-items:center;
  gap:18px;
  font-size:13px;
  box-shadow:var(--shadow2);
}
.app-footer b{
  color:#0b7a45;
}
.nav{
  min-height:46px;
  line-height:1.2;
}
.nav span{
  white-space:normal;
}
.nav-section{
  margin-top:16px !important;
}
html[dir="rtl"] .app-footer{
  direction:rtl;
}
html[dir="rtl"] .sidebar{
  padding-bottom:24px !important;
}
html[dir="rtl"] .nav span{
  text-align:right;
}

/* HDAMS V4 Asset profile and QR label */
.asset-profile-grid{
  display:grid;
  grid-template-columns:minmax(0,1fr) 280px;
  gap:18px;
  margin-bottom:18px;
}
.asset-main-card{
  min-height:250px;
}
.asset-title-row{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:16px;
  margin-bottom:20px;
}
.asset-model{
  font-size:30px;
  font-weight:950;
  color:var(--navy);
}
.asset-sub{
  color:var(--muted);
  font-weight:750;
  margin-top:5px;
}
.asset-kpi-grid{
  display:grid;
  grid-template-columns:repeat(3,1fr);
  gap:12px;
}
.asset-kpi-grid div{
  border:1px solid var(--border);
  background:#f8fbff;
  border-radius:16px;
  padding:14px;
}
.asset-kpi-grid span{
  display:block;
  color:var(--muted);
  font-size:12px;
  font-weight:850;
  margin-bottom:7px;
}
.asset-kpi-grid b{
  font-size:15px;
  color:#061b33;
  word-break:break-word;
}
.qr-card{
  text-align:center;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
}
#assetQRCode{
  background:white;
  padding:12px;
  border-radius:18px;
  border:1px solid var(--border);
  margin:10px 0;
}
.qr-id{
  font-weight:950;
  color:var(--navy);
  margin:8px 0 14px;
}
.timeline{
  position:relative;
  padding-left:18px;
}
.timeline:before{
  content:"";
  position:absolute;
  left:5px;
  top:4px;
  bottom:4px;
  width:2px;
  background:#d9e3ef;
}
.timeline-item{
  position:relative;
  padding:0 0 16px 18px;
}
.timeline-item:before{
  content:"";
  position:absolute;
  left:-18px;
  top:4px;
  width:12px;
  height:12px;
  background:var(--blue);
  border:3px solid white;
  border-radius:50%;
  box-shadow:0 0 0 2px #d9e3ef;
}
.timeline-item b{
  display:block;
  color:#061b33;
}
.timeline-item span{
  display:block;
  color:var(--muted);
  font-size:12px;
  margin:3px 0;
}
.timeline-item p{
  margin:0;
  color:#475467;
}
html[dir="rtl"] .timeline{
  padding-left:0;
  padding-right:18px;
}
html[dir="rtl"] .timeline:before{
  left:auto;
  right:5px;
}
html[dir="rtl"] .timeline-item{
  padding-left:0;
  padding-right:18px;
}
html[dir="rtl"] .timeline-item:before{
  left:auto;
  right:-18px;
}
@media(max-width:1100px){
  .asset-profile-grid{grid-template-columns:1fr}
  .asset-kpi-grid{grid-template-columns:1fr 1fr}
}
@media print{
  body *{visibility:hidden!important}
  .qr-card,.qr-card *{visibility:visible!important}
  .qr-card{position:absolute;left:0;top:0;width:320px!important;box-shadow:none!important;border:0!important}
}

.btn.small{padding:7px 10px;font-size:12px;border-radius:10px}.danger-btn{background:linear-gradient(135deg,#d92d20,#f04438)!important;color:white!important;border:0!important}.actions-cell{white-space:nowrap}pre{background:#f3f7fd;border:1px solid var(--border);border-radius:14px;padding:14px;white-space:pre-wrap}
