*{
  margin:0;
  padding:0;
  box-sizing:border-box;
}

:root{
  --bg:#f4f6fb;
  --card:#fff;
  --text:#172033;
  --muted:#718096;
  --primary:#635bff;
  --border:#e8ebf2;
  --green:#16a36a;
  --red:#e5484d;
  --orange:#ed9b24;
}

body.dark{
  --bg:#111827;
  --card:#1f2937;
  --text:#f3f4f6;
  --muted:#9ca3af;
  --border:#374151;
}

body{
  font-family:Arial,sans-serif;
  background:var(--bg);
  color:var(--text);
  transition:.2s;
  overflow-x:hidden;
}

button,input,select{
  font:inherit;
}

button{
  cursor:pointer;
  border:0;
}

.app{
  display:flex;
  min-height:100vh;
  width:100%;
}

/* SIDEBAR */

.sidebar{
  width:235px;
  min-width:235px;
  background:var(--card);
  padding:25px 18px;
  border-right:1px solid var(--border);
  flex-shrink:0;
}

.logo{
  font-size:24px;
  font-weight:bold;
  color:var(--primary);
  margin-bottom:38px;
}

.logo span{
  color:var(--text);
}

.nav-title{
  font-size:11px;
  color:var(--muted);
  margin:20px 10px 12px;
}

.nav-btn{
  width:100%;
  padding:13px 12px;
  text-align:left;
  background:transparent;
  color:var(--muted);
  border-radius:8px;
  margin-bottom:6px;
  font-size:14px;
}

.nav-btn.active,
.nav-btn:hover{
  background:#eeedff;
  color:var(--primary);
}

/* MAIN */

.main{
  flex:1;
  min-width:0;
  width:calc(100% - 235px);
  padding:28px;
}

.topbar{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:15px;
  margin-bottom:28px;
}

.topbar h1{
  font-size:25px;
}

.top-actions{
  display:flex;
  gap:10px;
  align-items:center;
}

.btn{
  padding:11px 16px;
  border-radius:8px;
  background:var(--primary);
  color:white;
  font-weight:600;
}

.btn.secondary{
  background:var(--card);
  color:var(--text);
  border:1px solid var(--border);
}

/* STATS */

.stats{
  display:grid;
  grid-template-columns:repeat(4,minmax(0,1fr));
  gap:16px;
  margin-bottom:25px;
}

.card{
  background:var(--card);
  border:1px solid var(--border);
  border-radius:12px;
  padding:20px;
  min-width:0;
}

.stat-label{
  color:var(--muted);
  font-size:13px;
}

.stat-value{
  font-size:27px;
  font-weight:bold;
  margin:13px 0 7px;
  overflow-wrap:anywhere;
}

.stat-note{
  font-size:12px;
  color:var(--muted);
}

.green{color:var(--green)}
.red{color:var(--red)}
.orange{color:var(--orange)}

/* CONTENT */

.content-card{
  margin-bottom:22px;
}

.section-head{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:12px;
  margin-bottom:18px;
}

.section-head h2{
  font-size:18px;
}

/* FILTERS */

.filters{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  margin-bottom:17px;
}

.filters input,
.filters select,
.field input,
.field select{
  padding:11px 12px;
  border:1px solid var(--border);
  border-radius:7px;
  background:var(--bg);
  color:var(--text);
  outline:none;
}

.filters input{
  flex:1;
  min-width:170px;
}

/* TABLES */

.table-wrap{
  width:100%;
  max-width:100%;
  overflow-x:auto;
  overflow-y:hidden;
  -webkit-overflow-scrolling:touch;
  scrollbar-width:thin;
}

table{
  width:100%;
  border-collapse:collapse;
  white-space:nowrap;
}

th,td{
  text-align:left;
  padding:14px 12px;
  border-bottom:1px solid var(--border);
  font-size:13px;
}

th{
  color:var(--muted);
  font-weight:600;
}

.status{
  padding:6px 9px;
  border-radius:20px;
  font-size:11px;
  background:#e6f7ef;
  color:#138653;
}

.status.low{
  background:#fff1dc;
  color:#b46b08;
}

.status.out{
  background:#ffe8e8;
  color:#d33636;
}

/* ACTIONS */

.actions{
  display:flex;
  gap:6px;
}

.small-btn{
  padding:7px 9px;
  border-radius:6px;
  background:var(--bg);
  color:var(--text);
}

.small-btn:hover{
  color:var(--primary);
}

/* PAGINATION */

.pagination{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:10px;
  margin-top:18px;
  color:var(--muted);
  font-size:13px;
}

.page-buttons{
  display:flex;
  gap:7px;
  flex-wrap:wrap;
}

.page-buttons button{
  padding:8px 11px;
  border-radius:6px;
  background:var(--bg);
  color:var(--text);
}

.page-buttons button.active{
  background:var(--primary);
  color:white;
}

/* CHART */

.chart-bars{
  display:flex;
  align-items:end;
  gap:12px;
  height:145px;
  margin-top:20px;
  width:100%;
  min-width:0;
}

.bar-item{
  flex:1;
  min-width:0;
  height:100%;
  display:flex;
  flex-direction:column;
  justify-content:end;
  align-items:center;
  gap:8px;
}

.bar{
  width:100%;
  max-width:45px;
  background:var(--primary);
  border-radius:6px 6px 0 0;
  min-height:5px;
}

.bar-label{
  font-size:11px;
  color:var(--muted);
  text-align:center;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  max-width:100%;
}

.chart-legend{
  font-size:12px;
  color:var(--muted);
  margin-top:15px;
}

/* MODAL */

.overlay{
  position:fixed;
  inset:0;
  background:#0008;
  display:none;
  align-items:center;
  justify-content:center;
  padding:15px;
  z-index:10;
}

.modal{
  background:var(--card);
  width:100%;
  max-width:440px;
  padding:25px;
  border-radius:13px;
  max-height:90vh;
  overflow-y:auto;
}

.modal h2{
  margin-bottom:20px;
}

.field{
  margin-bottom:15px;
}

.field label{
  display:block;
  font-size:13px;
  margin-bottom:7px;
}

.field input,
.field select{
  width:100%;
}

.modal-actions{
  display:flex;
  justify-content:flex-end;
  gap:10px;
  margin-top:20px;
}

.empty{
  text-align:center;
  color:var(--muted);
  padding:30px;
}

.menu-btn{
  display:none;
}

/* TABLET */

@media(max-width:1000px){

  .stats{
    grid-template-columns:repeat(2,minmax(0,1fr));
  }

  .main{
    padding:22px 16px;
  }

}

/* MOBILE */

@media(max-width:700px){

  .sidebar{
    width:65px;
    min-width:65px;
    padding:20px 8px;
  }

  .logo{
    font-size:0;
    margin-bottom:30px;
    text-align:center;
  }

  .logo:after{
    content:"S";
    font-size:24px;
  }

  .nav-title{
    display:none;
  }

  .nav-btn{
    font-size:0;
    text-align:center;
    padding:13px 2px;
  }

  .nav-btn span{
    font-size:18px;
  }

  .main{
    width:calc(100% - 65px);
    min-width:0;
    padding:16px 10px;
  }

  .topbar{
    align-items:flex-start;
    flex-wrap:wrap;
    gap:12px;
  }

  .topbar h1{
    font-size:19px;
  }

  .top-actions{
    width:100%;
    flex-wrap:wrap;
    justify-content:flex-start;
  }

  .top-actions .btn{
    flex:1;
    min-width:0;
    padding:10px 6px;
    font-size:12px;
    white-space:nowrap;
  }

  .stats{
    grid-template-columns:repeat(2,minmax(0,1fr));
    gap:9px;
  }

  .card{
    padding:13px;
  }

  .stat-value{
    font-size:20px;
  }

  .section-head h2{
    font-size:16px;
  }

  .table-wrap table{
    min-width:620px;
  }

  #products .table-wrap table{
    min-width:760px;
  }

  .filters{
    flex-direction:column;
  }

  .filters input,
  .filters select{
    width:100%;
    min-width:0;
  }

  .pagination{
    flex-wrap:wrap;
  }

  .chart-bars{
    gap:6px;
    height:135px;
  }

  .bar{
    max-width:35px;
  }

  .bar-label{
    font-size:9px;
  }

  .modal{
    padding:18px;
  }

}

/* SMALL MOBILE */

@media(max-width:390px){

  .main{
    padding:13px 8px;
  }

  .topbar h1{
    font-size:17px;
  }

  .stats{
    gap:7px;
  }

  .card{
    padding:10px;
  }

  .stat-value{
    font-size:18px;
  }

  .chart-bars{
    gap:4px;
    height:125px;
  }

  .bar-label{
    font-size:8px;
  }

  .top-actions .btn{
    font-size:11px;
    padding:9px 4px;
  }

}

/* VERY SMALL MOBILE */

@media(max-width:340px){

  .sidebar{
    width:55px;
    min-width:55px;
    padding:15px 5px;
  }

  .main{
    width:calc(100% - 55px);
    padding:12px 7px;
  }

  .stats{
    grid-template-columns:1fr;
  }

  .top-actions{
    flex-direction:column;
  }

  .top-actions .btn{
    width:100%;
  }

}
