:root{
  --bg:#f6f8fc;
  --panel:#ffffff;
  --card:#ffffff;
  --text:#0f172a;
  --muted:#64748b;
  --line:#e6eaf2;
  --shadow: 0 10px 25px rgba(15, 23, 42, .08);
  --radius:16px;
  --brand:#2563eb;
  --brand2:#22c55e;
  --danger:#ef4444;
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font-family:ui-sans-serif,system-ui,-apple-system,Segoe UI,Roboto,Arial;
  background:linear-gradient(180deg,#ffffff 0%,var(--bg) 100%);
  color:var(--text);
}
a{color:inherit;text-decoration:none}

/* Layout */
.wrap{
  display:flex;
  min-height:100vh;
}

/* Sidebar */
.sidebar{
  width:280px;
  background:var(--panel);
  border-right:1px solid var(--line);
  padding:18px;
  position:sticky;
  top:0;
  height:100vh;
  overflow:auto;
}

/* Brand */
.brand{
  display:flex;
  gap:12px;
  align-items:center;
  padding:12px;
  border-radius:var(--radius);
  background:linear-gradient(135deg,rgba(37,99,235,.08),rgba(34,197,94,.06));
  border:1px solid var(--line);
  box-shadow:var(--shadow);
}
.brand .logo{
  width:42px;height:42px;border-radius:14px;
  background:linear-gradient(135deg,var(--brand),#60a5fa);
  display:flex;align-items:center;justify-content:center;
  font-weight:800;color:white
}
.brand .title b{display:block}
.brand .title small{color:var(--muted)}

/* Nav */
.nav{margin-top:18px;display:flex;flex-direction:column;gap:8px}
.nav a{
  padding:12px;
  border-radius:14px;
  color:var(--muted);
  display:flex;
  align-items:center;
  justify-content:space-between;
  border:1px solid transparent;
}
.nav a:hover{
  background:rgba(37,99,235,.06);
  color:var(--text);
  border-color:rgba(37,99,235,.12);
}
.nav a.active{
  background:rgba(37,99,235,.10);
  border-color:rgba(37,99,235,.22);
  color:var(--text);
}

/* Main */
.main{
  flex:1;
  padding:22px;
  min-width:0; /* IMPORTANT: allows tables to scroll */
}

/* Topbar */
.topbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:14px;
  margin-bottom:18px;
}

/* Search bar */
.search{
  flex:1;
  display:flex;
  gap:10px;
  align-items:center;
  padding:12px 14px;
  border-radius:16px;
  background:var(--panel);
  border:1px solid var(--line);
  box-shadow:0 6px 16px rgba(15,23,42,.05);
}
.search input{
  width:100%;
  background:transparent;
  border:0;
  outline:none;
  color:var(--text);
}

/* User chip */
.userchip{
  display:flex;
  gap:10px;
  align-items:center;
  padding:10px 12px;
  border-radius:16px;
  background:var(--panel);
  border:1px solid var(--line);
  box-shadow:0 6px 16px rgba(15,23,42,.05);
}
.avatar{
  width:36px;height:36px;border-radius:14px;
  background:rgba(37,99,235,.12);
  color:var(--brand);
  display:flex;
  align-items:center;
  justify-content:center;
  font-weight:800;
}

/* Cards */
.card{
  background:var(--card);
  border:1px solid var(--line);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
  padding:18px;
  min-width:0;
}
.muted{color:var(--muted)}
.pill{
  font-size:12px;
  padding:4px 8px;
  border-radius:999px;
  background:rgba(15,23,42,.06);
  color:var(--muted);
  white-space:nowrap;
}

/* Buttons */
.btnrow{display:flex;gap:10px;flex-wrap:wrap}
.btn{
  padding:10px 14px;
  border-radius:14px;
  border:1px solid var(--line);
  background:white;
  color:var(--text);
  cursor:pointer;
  box-shadow:0 6px 16px rgba(15,23,42,.06);
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
}
.btn.primary{background:var(--brand);border-color:rgba(37,99,235,.2);color:white}
.btn.good{background:var(--brand2);color:white;border-color:rgba(34,197,94,.2)}
.btn.bad{background:var(--danger);color:white;border-color:rgba(239,68,68,.2)}
.btn:disabled, .btn.disabled{
  opacity:.6;
  cursor:not-allowed;
}

/* Forms */
.field{
  width:100%;
  padding:12px;
  border-radius:14px;
  border:1px solid var(--line);
  background:white;
  color:var(--text);
  outline:none;
}
.field:focus{
  border-color:rgba(37,99,235,.45);
  box-shadow:0 0 0 4px rgba(37,99,235,.10);
}
label{display:block;font-size:13px;color:var(--muted);margin:10px 0 6px}
textarea.field{resize:vertical}

/* Grid */
.grid{
  display:grid;
  grid-template-columns:1.2fr .8fr;
  gap:16px;
}
.row{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:12px;
}

/* Tables (RESPONSIVE) */
.table-wrap{
  width:100%;
  overflow:auto;
  border-radius:16px;
  border:1px solid var(--line);
}
.table{
  width:100%;
  border-collapse:collapse;
  min-width:900px;  /* forces horizontal scroll on mobile */
}
.table th,.table td{
  padding:12px;
  border-bottom:1px solid var(--line);
  text-align:left;
  vertical-align:top;
}
.table th{
  color:var(--muted);
  font-size:13px;
  background:rgba(15,23,42,.02);
  position:sticky;
  top:0;
}

/* Toast */
.toast{
  padding:12px 14px;
  border-radius:16px;
  border:1px solid var(--line);
  background:white;
  margin-bottom:12px;
}
.toast.ok{border-color:rgba(34,197,94,.35);background:rgba(34,197,94,.08)}
.toast.err{border-color:rgba(239,68,68,.35);background:rgba(239,68,68,.08)}

/* KPI cards */
.kpis{display:grid;grid-template-columns:repeat(3,1fr);gap:12px}
.kpi{
  padding:14px;
  border-radius:16px;
  border:1px solid var(--line);
  background:linear-gradient(180deg,rgba(37,99,235,.05),rgba(34,197,94,.03));
}
.kpi b{font-size:18px}
.kpi small{color:var(--muted)}

/* -----------------------------
   MOBILE RESPONSIVE
--------------------------------*/
.mobile-only{display:none}
.desktop-only{display:flex}

@media (max-width: 1000px){
  .grid{grid-template-columns:1fr}
}

@media (max-width: 900px){
  .sidebar{
    position:fixed;
    left:-320px;
    top:0;
    height:100vh;
    z-index:100;
    transition: left .25s ease;
    box-shadow: 0 20px 60px rgba(0,0,0,.25);
  }
  .sidebar.open{left:0}

  .main{padding:16px}

  .topbar{gap:10px}
  .search{display:none}

  .mobile-only{display:flex}
  .desktop-only{display:none}
}

@media (max-width: 600px){
  .btn{width:100%}
  .btnrow{flex-direction:column}
  .row{grid-template-columns:1fr}
  .kpis{grid-template-columns:1fr}
}

