:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --sidebar: #14203b;
  --sidebar-active: #1e2f57;
  --text: #1a2138;
  --text-muted: #6b7488;
  --border: #e5e8f0;
  --accent: #3b5bfd;
  --accent-soft: #eef1ff;
  --ok: #17a673;
  --ok-soft: #e8f9f2;
  --warn: #d98a1c;
  --warn-soft: #fdf3e3;
  --bad: #e04b4b;
  --bad-soft: #fdeaea;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 32, 59, .04), 0 8px 24px rgba(20, 32, 59, .06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--sidebar);
  color: #cdd5ec;
  display: flex;
  flex-direction: column;
  padding: 20px 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 22px 22px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  margin-bottom: 14px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: linear-gradient(135deg, #3b5bfd, #7c3bfd);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: white;
  font-size: 15px;
}

.brand-text { line-height: 1.2; }
.brand-text strong { display: block; color: #fff; font-size: 15px; }
.brand-text span { font-size: 12px; color: #8b93b3; }

.nav { list-style: none; margin: 0; padding: 0 12px; flex: 1; }
.nav li { margin-bottom: 2px; }

.nav button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  background: transparent;
  border: none;
  color: #b6bedb;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  transition: background .15s, color .15s;
}

.nav button:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav li.active button { background: var(--sidebar-active); color: #fff; }
.nav .icon { width: 18px; text-align: center; opacity: .9; }

.sidebar-footer {
  padding: 14px 22px 4px;
  border-top: 1px solid rgba(255,255,255,.08);
  font-size: 12px;
  color: #7a83a3;
}

/* Main */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 32px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar h1 { font-size: 20px; margin: 0; }
.topbar .sub { color: var(--text-muted); font-size: 13px; margin-top: 2px; }

.topbar-right { display: flex; align-items: center; gap: 14px; }

.search {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--text-muted);
  width: 220px;
}

.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px;
}

.content { padding: 28px 32px; flex: 1; }

.view { display: none; }
.view.active { display: block; animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

/* KPI cards */
.kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
  margin-bottom: 26px;
}

.kpi {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
}

.kpi .label { font-size: 12.5px; color: var(--text-muted); margin-bottom: 8px; }
.kpi .value { font-size: 24px; font-weight: 700; }
.kpi .delta { font-size: 12px; margin-top: 6px; display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 20px; }
.kpi .delta.up { color: var(--ok); background: var(--ok-soft); }
.kpi .delta.down { color: var(--bad); background: var(--bad-soft); }

/* Panels */
.panel {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}

.panel-header h2 { font-size: 15px; margin: 0; }

.btn {
  background: var(--accent);
  color: white;
  border: none;
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.btn.secondary { background: var(--accent-soft); color: var(--accent); }

.grid-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
  text-align: left;
  padding: 10px 22px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
tbody td { padding: 13px 22px; border-bottom: 1px solid var(--border); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafbff; }

.badge { padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; display: inline-block; }
.badge.ok { color: var(--ok); background: var(--ok-soft); }
.badge.warn { color: var(--warn); background: var(--warn-soft); }
.badge.bad { color: var(--bad); background: var(--bad-soft); }

.mono { font-variant-numeric: tabular-nums; }
.text-muted { color: var(--text-muted); }
.right { text-align: right; }

.toolbar { display: flex; gap: 10px; padding: 16px 22px; border-bottom: 1px solid var(--border); }
.toolbar input, .toolbar select {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  background: var(--bg);
}
.toolbar input { flex: 1; }

.cust-card {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 22px; border-bottom: 1px solid var(--border);
}
.cust-card:last-child { border-bottom: none; }
.cust-avatar {
  width: 38px; height: 38px; border-radius: 10px;
  background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; flex-shrink: 0;
}
.cust-name { font-weight: 600; font-size: 13.5px; }
.cust-meta { font-size: 12px; color: var(--text-muted); }
.cust-amount { margin-left: auto; font-weight: 700; font-size: 13.5px; }

footer.note {
  padding: 14px 32px;
  color: var(--text-muted);
  font-size: 12px;
  border-top: 1px solid var(--border);
}

@media (max-width: 980px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
}
