:root{
  --bg:#f4f6f8;
  --panel:#ffffff;
  --text:#111827;
  --muted:#6b7280;
  --line:#e5e7eb;
  --dark:#0f172a;
  --blue:#2563eb;
  --green:#16a34a;
  --red:#dc2626;
  --shadow:0 20px 60px rgba(15,23,42,.08);
  --radius:22px;
}

*{box-sizing:border-box}

body{
  margin:0;
  font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Arial,sans-serif;
  background:linear-gradient(135deg,#f8fafc,#eef2f7);
  color:var(--text);
}

.app{display:flex;min-height:100vh}

.sidebar{
  width:280px;
  background:rgba(255,255,255,.78);
  backdrop-filter:blur(22px);
  border-right:1px solid rgba(229,231,235,.8);
  padding:22px;
  position:fixed;
  top:0;
  bottom:0;
  left:0;
  display:flex;
  flex-direction:column;
  gap:22px;
}

.brand{
  display:flex;
  align-items:center;
  gap:14px;
  padding:10px 6px 18px;
}

.brand-icon{
  width:48px;
  height:48px;
  border-radius:16px;
  display:flex;
  align-items:center;
  justify-content:center;
  background:var(--dark);
  color:white;
  font-size:24px;
  box-shadow:var(--shadow);
}

.brand-title{
  font-size:24px;
  font-weight:900;
  letter-spacing:-.04em;
}

.brand-sub{
  color:var(--muted);
  font-size:12px;
  font-weight:700;
  margin-top:3px;
}

.live-dot{
  display:inline-block;
  width:9px;
  height:9px;
  background:var(--green);
  border-radius:50%;
  margin-right:6px;
  box-shadow:0 0 0 6px rgba(22,163,74,.12);
}

.nav{
  display:flex;
  flex-direction:column;
  gap:7px;
}

.nav a,.logout{
  text-decoration:none;
  color:#1f2937;
  padding:13px 15px;
  border-radius:16px;
  font-weight:700;
  transition:.18s;
}

.nav a:hover,.logout:hover{
  background:#111827;
  color:white;
  transform:translateX(3px);
}

.userbox{
  margin-top:auto;
  background:#f9fafb;
  border:1px solid var(--line);
  border-radius:20px;
  padding:14px;
  display:flex;
  align-items:center;
  gap:12px;
}

.avatar{
  width:42px;
  height:42px;
  border-radius:50%;
  background:var(--blue);
  color:white;
  display:flex;
  align-items:center;
  justify-content:center;
  font-weight:900;
}

.username{font-weight:900}
.userrole{font-size:12px;color:var(--muted);margin-top:3px}

.logout{
  display:block;
  background:#fee2e2;
  color:#991b1b;
  text-align:center;
}

.content{
  margin-left:280px;
  padding:32px;
  width:calc(100% - 280px);
}

h1{
  font-size:34px;
  letter-spacing:-.05em;
  margin:0 0 22px;
}

h2{
  margin:0 0 16px;
  letter-spacing:-.03em;
}

.grid{
  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:18px;
  margin-bottom:20px;
}

.two{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:20px;
  margin-bottom:20px;
}

.card{
  background:rgba(255,255,255,.9);
  border:1px solid rgba(229,231,235,.9);
  border-radius:var(--radius);
  padding:20px;
  box-shadow:var(--shadow);
  overflow:auto;
}

.num{
  font-size:38px;
  line-height:1;
  font-weight:950;
  margin-top:10px;
  letter-spacing:-.06em;
}

.small{font-size:22px}

table{
  width:100%;
  border-collapse:separate;
  border-spacing:0;
  overflow:hidden;
}

th{
  text-align:left;
  color:#64748b;
  font-size:13px;
  text-transform:uppercase;
  letter-spacing:.04em;
  padding:12px;
  border-bottom:1px solid var(--line);
}

td{
  padding:13px 12px;
  border-bottom:1px solid #f1f5f9;
}

tr:hover td{background:#f8fafc}

a{color:var(--blue);font-weight:800}

.btn,button{
  display:inline-block;
  border:0;
  background:#111827;
  color:white;
  padding:11px 16px;
  border-radius:14px;
  font-weight:900;
  text-decoration:none;
  cursor:pointer;
  transition:.18s;
  margin:4px;
}

.btn:hover,button:hover{
  transform:translateY(-1px);
  box-shadow:0 12px 30px rgba(15,23,42,.15);
}

.search,input,select{
  border:1px solid var(--line);
  background:white;
  border-radius:14px;
  padding:12px 14px;
  font-size:15px;
  outline:none;
  margin:4px;
}

.search:focus,input:focus,select:focus{
  border-color:var(--blue);
  box-shadow:0 0 0 4px rgba(37,99,235,.12);
}

.toolbar,.rolebar{
  margin-bottom:18px;
}

.rolebar a{
  display:inline-block;
  background:white;
  border:1px solid var(--line);
  border-radius:14px;
  padding:10px 13px;
  margin:4px;
  text-decoration:none;
  color:#111827;
}

.rolebar a:hover{
  background:#111827;
  color:white;
}

.pill{
  display:inline-block;
  padding:6px 10px;
  border-radius:999px;
  background:#dcfce7;
  color:#166534;
  font-weight:900;
  font-size:13px;
}

.bad{color:var(--red);font-weight:900}

.photo{
  max-width:100%;
  border-radius:18px;
  margin-top:10px;
  box-shadow:var(--shadow);
}

hr{
  border:0;
  border-top:1px solid var(--line);
  margin:24px 0;
}

@media(max-width:1000px){
  .sidebar{
    position:relative;
    width:100%;
    height:auto;
  }
  .app{display:block}
  .content{
    margin-left:0;
    width:100%;
    padding:18px;
  }
  .grid,.two{
    grid-template-columns:1fr;
  }
}

/* ===== PrepFlow V13 Premium Components ===== */

.topbar{
  height:68px;
  background:rgba(255,255,255,.75);
  backdrop-filter:blur(22px);
  border:1px solid rgba(229,231,235,.9);
  border-radius:24px;
  box-shadow:var(--shadow);
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:12px 18px;
  margin-bottom:26px;
}

.global-search{
  display:flex;
  align-items:center;
  gap:10px;
  width:min(520px,100%);
  background:#f8fafc;
  border:1px solid var(--line);
  border-radius:18px;
  padding:0 14px;
}

.global-search input{
  width:100%;
  border:0;
  background:transparent;
  box-shadow:none;
}

.top-actions{
  display:flex;
  align-items:center;
  gap:14px;
  font-weight:900;
}

.server-ok{
  color:#166534;
  background:#dcfce7;
  padding:9px 12px;
  border-radius:999px;
}

.notify{
  background:#111827;
  color:white;
  padding:10px 13px;
  border-radius:999px;
}

.badge{
  display:inline-block;
  padding:6px 10px;
  border-radius:999px;
  font-size:12px;
  font-weight:900;
  margin-top:5px;
}

.role-admin{background:#fee2e2;color:#991b1b}
.role-accountant{background:#dcfce7;color:#166534}
.role-manager{background:#dbeafe;color:#1d4ed8}
.role-qc{background:#ede9fe;color:#6d28d9}
.role-driver{background:#ffedd5;color:#c2410c}
.role-polisher{background:#e5e7eb;color:#111827}
.role-worker{background:#e5e7eb;color:#111827}
.role-washer{background:#e0f2fe;color:#0369a1}
.role-ppf{background:#ccfbf1;color:#0f766e}
.role-pdr{background:#fef3c7;color:#92400e}

.status-done{background:#dcfce7!important;color:#166534!important}
.status-assigned{background:#fef9c3!important;color:#854d0e!important}
.status-returned{background:#fee2e2!important;color:#991b1b!important}
.status-in_trip{background:#dbeafe!important;color:#1d4ed8!important}
.status-completed{background:#dcfce7!important;color:#166534!important}
.status-draft{background:#f1f5f9!important;color:#475569!important}

.stat-card{
  position:relative;
  overflow:hidden;
}

.stat-card:after{
  content:"";
  position:absolute;
  right:-40px;
  top:-40px;
  width:120px;
  height:120px;
  background:linear-gradient(135deg,rgba(37,99,235,.15),rgba(15,23,42,.03));
  border-radius:50%;
}

.card:hover{
  transform:translateY(-2px);
  transition:.18s;
}

@media(max-width:1000px){
  .topbar{display:block;height:auto}
  .top-actions{margin-top:12px}
}









/* ===== PrepFlow Stable App Layout ===== */
html, body {
  margin: 0;
  width: 100%;
  min-width: 0;
  overflow-x: hidden;
}

.app-layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  width: 100%;
  min-height: 100vh;
}

.sidebar {
  grid-column: 1;
  width: 260px;
  min-width: 260px;
  height: 100vh;
  position: sticky;
  top: 0;
  overflow-y: auto;
  box-sizing: border-box;
  z-index: 20;
}

.main-area {
  grid-column: 2;
  min-width: 0;
  box-sizing: border-box;
}

.page-content {
  padding: 24px;
  box-sizing: border-box;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.side-nav a {
  display: block;
}

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

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

.card {
  overflow-x: auto;
}

table {
  width: 100%;
}

.mobile-menu-toggle,
.mobile-menu-btn,
.mobile-menu-overlay,
.mobile-close {
  display: none;
}

/* ===== PrepFlow Mobile App Layout ===== */
@media (max-width: 900px) {
  html, body {
    width: 100% !important;
    min-width: 0 !important;
    overflow-x: hidden !important;
    background: #f3f6fb;
  }

  .app-layout {
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
  }

  .mobile-menu-btn {
    display: flex !important;
    position: fixed;
    top: 14px;
    left: 14px;
    z-index: 1001;
    width: 46px;
    height: 46px;
    border-radius: 14px;
    background: #0f172a;
    color: white;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    box-shadow: 0 12px 30px rgba(15,23,42,.25);
  }

  .mobile-close {
    display: block !important;
    margin-left: auto;
    font-size: 28px;
    cursor: pointer;
  }

  .mobile-menu-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,.45);
    z-index: 998;
  }

  .mobile-menu-toggle:checked ~ .mobile-menu-overlay {
    display: block;
  }

  .sidebar.mobile-drawer {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 290px !important;
    min-width: 290px !important;
    max-width: 86vw !important;
    height: 100vh !important;
    z-index: 999 !important;
    transform: translateX(-105%);
    transition: transform .25s ease;
    overflow-y: auto !important;
    box-shadow: 20px 0 60px rgba(15,23,42,.25);
  }

  .mobile-menu-toggle:checked ~ .app-layout .sidebar.mobile-drawer {
    transform: translateX(0);
  }

  .main-area {
    width: 100% !important;
    min-width: 0 !important;
  }

  .topbar {
    display: flex !important;
    position: sticky;
    top: 0;
    z-index: 50;
    min-height: 70px;
    padding: 12px 14px 12px 74px !important;
    box-sizing: border-box;
    background: rgba(255,255,255,.92);
    backdrop-filter: blur(14px);
  }

  .global-search {
    flex: 1;
    min-width: 0;
  }

  .global-search input {
    width: 100% !important;
    max-width: 100% !important;
  }

  .top-actions {
    display: none !important;
  }

  .page-content {
    padding: 14px !important;
    width: 100% !important;
    box-sizing: border-box;
  }

  h1 {
    font-size: 25px !important;
    line-height: 1.2 !important;
    margin: 14px 0 12px !important;
  }

  h2 {
    font-size: 19px !important;
  }

  .grid,
  .two,
  .salary-hero,
  .trip-header,
  .log-grid {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  .card,
  .big-card,
  .profile-card,
  .trip-card {
    padding: 15px !important;
    border-radius: 18px !important;
    overflow-x: auto !important;
  }

  .num {
    font-size: 34px !important;
  }

  .num.small {
    font-size: 24px !important;
  }

  form,
  .formgrid,
  .inline-form {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }

  input,
  select,
  button,
  .btn {
    width: 100% !important;
    max-width: 100% !important;
    min-height: 46px !important;
    font-size: 16px !important;
    box-sizing: border-box !important;
  }

  .btn {
    display: block !important;
    text-align: center !important;
  }

  table {
    min-width: 720px !important;
    font-size: 14px !important;
  }

  th,
  td {
    padding: 9px !important;
    white-space: nowrap !important;
  }

  .side-nav a {
    font-size: 16px !important;
    padding: 12px 14px !important;
  }

  .userbox {
    margin-top: 14px !important;
  }
}

@media (max-width: 420px) {
  .page-content {
    padding: 10px !important;
  }

  h1 {
    font-size: 22px !important;
  }

  .card {
    margin-bottom: 12px !important;
  }
}
