* {
  box-sizing: border-box;
}

:root {
  --bg: #f3f6fb;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --sidebar: #0f172a;
  --sidebar-hover: #1e293b;
  --sidebar-active: #2563eb;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
  --radius: 16px;
}

html, body {
  margin: 0;
  padding: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: var(--bg);
  color: var(--text);
}

body.sidebar-open {
  overflow: hidden;
}

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

/* Sidebar */
.sidebar {
  width: 260px;
  background: var(--sidebar);
  color: #fff;
  padding: 20px 16px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  transition: transform 0.28s ease, box-shadow 0.28s ease;
  z-index: 1001;
}

.brand {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 6px;
}

.brand-sub {
  color: #94a3b8;
  font-size: 13px;
  margin-bottom: 22px;
}

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

.nav-link {
  display: block;
  padding: 12px 14px;
  border-radius: 12px;
  text-decoration: none;
  color: #cbd5e1;
  font-weight: 600;
  transition: background 0.2s ease, transform 0.2s ease, color 0.2s ease;
}

.nav-link:hover {
  background: var(--sidebar-hover);
  color: #fff;
  transform: translateX(2px);
}

.nav-link.active {
  background: var(--sidebar-active);
  color: #fff;
}

/* Main */
.main {
  flex: 1;
  min-width: 0;
  padding: 24px;
}

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.menu-btn {
  display: none;
  border: none;
  background: #fff;
  color: var(--text);
  padding: 10px 12px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  width: auto;
}

.menu-btn:hover {
  transform: translateY(-1px);
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.page-title {
  margin: 0;
  font-size: 28px;
  line-height: 1.2;
}

.page-subtitle {
  color: var(--muted);
  margin-top: 6px;
}

/* Cards */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 20px;
  border: 1px solid rgba(226, 232, 240, 0.8);
}

.section-title {
  margin: 0 0 14px 0;
  font-size: 20px;
}

/* Forms */
.filter-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 12px;
}

label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 6px;
  color: #334155;
}

input,
select,
button {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  font-size: 14px;
}

input,
select {
  background: #fff;
}

input:focus,
select:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

button {
  background: #0f172a;
  color: white;
  border: none;
  cursor: pointer;
  margin-top: 22px;
  transition: transform 0.2s ease, opacity 0.2s ease, background 0.2s ease;
}

button:hover {
  opacity: 0.96;
  transform: translateY(-1px);
}

/* KPI */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(150px, 1fr));
  gap: 16px;
}

.kpi {
  background: linear-gradient(180deg, #ffffff, #f8fbff);
  border: 1px solid #e5edf7;
  border-radius: 16px;
  padding: 18px;
}

.kpi-label {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 8px;
}

.kpi-value {
  font-size: 28px;
  font-weight: 700;
  word-break: break-word;
}

/* Grids */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 20px;
}

/* Charts */
.chart-box {
  position: relative;
  height: 320px;
  width: 100%;
}

/* Tables */
.table-wrap {
  overflow-x: auto;
  border-radius: 12px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid #e5e7eb;
  text-align: left;
  font-size: 14px;
  vertical-align: top;
}

th {
  background: #f8fafc;
  position: sticky;
  top: 0;
  z-index: 1;
}

tbody tr:hover {
  background: #f8fbff;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 700;
  border-radius: 999px;
  white-space: nowrap;
}

.badge-green { background: #dcfce7; color: #166534; }
.badge-yellow { background: #fef3c7; color: #92400e; }
.badge-red { background: #fee2e2; color: #991b1b; }
.badge-blue { background: #dbeafe; color: #1d4ed8; }

.small-note {
  font-size: 13px;
  color: var(--muted);
}

/* Overlay */
.sidebar-overlay {
  display: none;
}

/* Tablet */
@media (max-width: 1100px) {
  .kpi-grid {
    grid-template-columns: repeat(3, minmax(160px, 1fr));
  }

  .grid-3 {
    grid-template-columns: 1fr;
  }

  .filter-grid {
    grid-template-columns: repeat(2, minmax(160px, 1fr));
  }
}

/* Mobile / drawer */
@media (max-width: 900px) {
  .menu-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    transform: translateX(-100%);
    width: 260px;
    max-width: 84vw;
    box-shadow: none;
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.28);
  }

  .sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
    z-index: 1000;
  }

  .sidebar-overlay.show {
    opacity: 1;
    pointer-events: auto;
  }

  .main {
    width: 100%;
    padding: 16px;
  }

  .page-title {
    font-size: 24px;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, minmax(130px, 1fr));
  }

  .grid-2,
  .filter-grid {
    grid-template-columns: 1fr;
  }

  .chart-box {
    height: 280px;
  }
}

/* Small phones */
@media (max-width: 560px) {
  .kpi-grid {
    grid-template-columns: 1fr;
  }

  .card {
    padding: 14px;
  }

  .page-title {
    font-size: 22px;
  }

  th,
  td {
    font-size: 13px;
    padding: 9px 10px;
  }
}