:root{--sidebar:#111827;--bg:#f4f7fb;--primary:#2563eb;--sidebar-width:272px}
*{box-sizing:border-box} body{margin:0;background:var(--bg);font-family:Inter,system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif;color:#1f2937}
.app-shell{display:block;min-height:100vh}
.sidebar{width:var(--sidebar-width);background:var(--sidebar);color:#fff;padding:18px 12px;position:fixed;top:0;left:0;bottom:0;overflow-y:auto;overflow-x:hidden}
.brand{display:flex;gap:10px;align-items:center;font-size:20px;font-weight:800;padding:8px 10px 18px}
.sidebar a{display:flex;gap:10px;align-items:center;justify-content:flex-start;padding:9px 12px;margin:2px 0;color:#cbd5e1;text-decoration:none;border-radius:8px;font-size:14px;line-height:1.35;white-space:normal}
.sidebar a:hover{background:#1f2937;color:#fff}.nav-title{font-size:11px;text-transform:uppercase;letter-spacing:.08em;color:#64748b;padding:16px 12px 5px}
.content{margin-left:var(--sidebar-width);width:calc(100% - var(--sidebar-width));min-width:0}.topbar{height:64px;background:#fff;border-bottom:1px solid #e5e7eb;display:flex;align-items:center;justify-content:space-between;padding:0 24px;position:sticky;top:0;z-index:10}
.kpi-card,.panel{background:#fff;border:1px solid #e8edf5;border-radius:14px;box-shadow:0 6px 20px rgba(15,23,42,.04)}
.kpi-card{padding:18px;display:flex;gap:14px;align-items:center;height:100%}.kpi-icon{width:42px;height:42px;border-radius:12px;background:#eff6ff;color:#2563eb;display:grid;place-items:center;font-size:20px}
.kpi-value{font-size:24px;font-weight:800}.kpi-label{font-size:12px;color:#64748b}.panel{padding:20px}.panel-title{font-weight:800;margin-bottom:12px}.money{font-size:30px;font-weight:800;color:#0f766e}
.login-page{min-height:100vh;display:grid;place-items:center;background:linear-gradient(135deg,#e0ecff,#f8fafc)}.login-card{width:min(420px,92vw);background:#fff;padding:34px;border-radius:20px;box-shadow:0 20px 60px rgba(15,23,42,.14)}


/* Relational autocomplete */
.lookup-wrap .lookup-menu{
  top:calc(100% + 4px);
  left:0;
  background:#fff;
  border:1px solid #dbe3ee;
  border-radius:10px;
  overflow:hidden;
}
.lookup-wrap .lookup-menu .list-group-item{
  border-left:0;
  border-right:0;
  font-size:14px;
  padding:10px 12px;
}
.lookup-wrap .lookup-menu .list-group-item:first-child{border-top:0}
.lookup-wrap .lookup-menu .list-group-item:last-child{border-bottom:0}
.lookup-input:focus{
  position:relative;
  z-index:1081;
}



/* V6.3 date + hour/minute selector */
input[type="date"],
input[type="month"]{
  cursor:pointer;
}
.form-select{
  min-height:38px;
}

/* V8 inspection photo */
.photo-upload-box{
  border:1px dashed #cbd5e1;
  border-radius:12px;
  padding:16px;
  background:#f8fafc;
}
.inspection-photo-preview{
  width:100%;
  max-width:520px;
  max-height:340px;
  object-fit:contain;
  border:1px solid #dbe3ee;
  border-radius:12px;
  background:#fff;
}


/* ==========================================================
   V9 MOBILE / TABLET
   ========================================================== */

.sidebar{
  z-index:1045;
  transition:transform .22s ease;
}

.sidebar .brand{
  justify-content:space-between;
}

.sidebar-close{
  width:40px;
  height:40px;
  border:0;
  border-radius:10px;
  display:grid;
  place-items:center;
  background:rgba(255,255,255,.08);
  color:#fff;
}

.sidebar-backdrop{
  display:none;
}

.topbar-left{
  min-width:0;
  display:flex;
  align-items:center;
  gap:10px;
}

.topbar-title{
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}

.mobile-menu-btn{
  width:42px;
  height:42px;
  flex:0 0 42px;
  border:1px solid #dbe3ee;
  border-radius:11px;
  background:#fff;
  color:#1f2937;
  display:grid;
  place-items:center;
  font-size:24px;
}

.touch-btn{
  min-height:44px;
}

.mobile-record-card{
  border:1px solid #e5e7eb;
  border-radius:14px;
  padding:14px;
  background:#fff;
  margin-bottom:12px;
}

body.mobile-menu-open{
  overflow:hidden;
}


@media(max-width:991.98px){

  .sidebar{
    width:min(84vw,320px);
    transform:translateX(-105%);
    box-shadow:0 12px 40px rgba(0,0,0,.24);
  }

  .sidebar.is-open{
    transform:translateX(0);
  }

  .sidebar-backdrop{
    display:block;
    position:fixed;
    inset:0;
    background:rgba(15,23,42,.50);
    opacity:0;
    visibility:hidden;
    transition:opacity .2s ease,visibility .2s ease;
    z-index:1040;
  }

  .sidebar-backdrop.is-open{
    opacity:1;
    visibility:visible;
  }

  .content{
    width:100%;
    margin-left:0;
  }

  .topbar{
    height:62px;
    padding:0 12px;
    gap:10px;
  }

  .topbar-title{
    font-size:16px;
  }

  .site-badge{
    max-width:145px;
    overflow:hidden;
    text-overflow:ellipsis;
  }

  .app-content{
    padding-left:12px !important;
    padding-right:12px !important;
  }

  .panel{
    padding:16px;
  }

  .kpi-card{
    padding:14px;
  }

  .kpi-value{
    font-size:21px;
  }

  .money{
    font-size:26px;
  }

  .sidebar a{
    min-height:42px;
    font-size:14px;
  }

  .sidebar .nav-title{
    font-size:11px;
  }

  .sidebar .user-name{
    display:block;
  }
}


@media(max-width:767.98px){

  .modal-dialog{
    margin:0;
    width:100%;
    max-width:none;
    min-height:100%;
  }

  .modal-content{
    min-height:100vh;
    border:0;
    border-radius:0;
  }

  .modal-header,
  .modal-footer{
    position:sticky;
    z-index:4;
    background:#fff;
  }

  .modal-header{
    top:0;
  }

  .modal-footer{
    bottom:0;
  }

  .modal-footer .btn{
    min-height:44px;
  }

  .photo-upload-box{
    padding:12px;
  }

  .inspection-photo-preview{
    max-height:280px;
  }
}


@media(max-width:420px){

  .site-badge{
    max-width:125px;
  }

  .topbar-title{
    font-size:15px;
  }

  .kpi-card{
    gap:10px;
  }

  .kpi-icon{
    width:38px;
    height:38px;
  }

  .kpi-label{
    font-size:11px;
  }
}


/* ==========================================================
   V9.1 MOBILE MENU VISIBILITY FIX
   ========================================================== */
.mobile-menu-toggle{
  display:none;
}

@media(max-width:991.98px){

  .mobile-menu-toggle{
    display:grid !important;
    place-items:center;
    position:fixed;
    top:calc(env(safe-area-inset-top, 0px) + 10px);
    left:10px;
    width:48px;
    height:48px;
    border:1px solid #dbe3ee;
    border-radius:12px;
    background:#fff;
    color:#111827;
    font-size:28px;
    line-height:1;
    box-shadow:0 6px 18px rgba(15,23,42,.16);
    z-index:1090;
    cursor:pointer;
    -webkit-tap-highlight-color:transparent;
  }

  .topbar{
    padding-left:70px !important;
    min-height:68px;
  }

  .sidebar{
    display:block !important;
    visibility:visible !important;
    position:fixed !important;
    left:0;
    top:0;
    bottom:0;
    width:min(84vw,320px) !important;
    height:100dvh;
    max-height:100dvh;
    overflow-y:auto;
    overflow-x:hidden;
    transform:translateX(-105%);
    z-index:1085;
    background:#0f1724;
    transition:transform .22s ease;
  }

  .sidebar.is-open{
    transform:translateX(0) !important;
  }

  .sidebar-backdrop{
    z-index:1080;
  }

  body.mobile-menu-open .mobile-menu-toggle{
    opacity:0;
    pointer-events:none;
  }

  .sidebar .brand{
    position:sticky;
    top:0;
    z-index:3;
    background:#0f1724;
  }

  .sidebar-nav{
    padding-bottom:calc(24px + env(safe-area-inset-bottom,0px));
  }
}

@media(min-width:992px){
  .mobile-menu-toggle{
    display:none !important;
  }
}

/* V10 workflow / reports */
.approval-row{display:flex;justify-content:space-between;align-items:center;gap:16px;padding:13px 0;border-bottom:1px solid #e5e7eb}.approval-row:last-child{border-bottom:0}
.report-nav{display:flex;gap:8px;overflow-x:auto;padding-bottom:6px}.report-nav .btn{white-space:nowrap}.report-kpi{border:1px solid #e5e7eb;border-radius:14px;background:#fff;padding:16px;height:100%}.report-kpi .value{font-size:25px;font-weight:800}.status-dot{width:9px;height:9px;border-radius:50%;display:inline-block;margin-right:5px}
@media(max-width:767.98px){.approval-row{align-items:flex-start;flex-direction:column}.approval-row .btn{min-height:42px}.report-table-mobile td,.report-table-mobile th{min-width:120px}}


/* ==========================================================
   V10.1 DESKTOP + MOBILE LAYOUT FIX
   ========================================================== */
.sidebar-nav{padding-bottom:28px}
.sidebar::-webkit-scrollbar{width:7px}
.sidebar::-webkit-scrollbar-thumb{background:rgba(148,163,184,.28);border-radius:10px}
.sidebar a i{width:20px;min-width:20px;text-align:center}
.content,.app-content,.panel,.table-responsive{min-width:0}
.app-content{overflow-x:hidden}
.panel .table-responsive{width:100%}

@media(min-width:992px){
  .sidebar{
    width:var(--sidebar-width)!important;
    transform:none!important;
    visibility:visible!important;
  }
  .content{
    margin-left:var(--sidebar-width)!important;
    width:calc(100% - var(--sidebar-width))!important;
  }
  .sidebar a{
    justify-content:flex-start!important;
    font-size:14px!important;
  }
  .sidebar .nav-title{
    display:block!important;
  }
  .topbar{
    padding-left:24px!important;
  }
}

@media(max-width:991.98px){
  .content{
    margin-left:0!important;
    width:100%!important;
  }
  .sidebar a{
    justify-content:flex-start!important;
  }
}
