:root {
  --primary: #6D28D9;
  --primary-dark: #5B21B6;
  --primary-light: #EDE9FE;
  --ink: #1F2333;
  --ink-soft: #5B5F70;
  --border: #E6E5EC;
  --bg: #F7F7FB;
  --white: #FFFFFF;
  --success: #16A34A;
  --danger: #DC2626;
  --warning: #D97706;
  --radius: 10px;
  --radius-lg: 16px;
  --shadow: 0 1px 2px rgba(20,20,43,0.04), 0 1px 12px rgba(20,20,43,0.04);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

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

.sidebar {
  width: 248px;
  background: var(--white);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 20;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 22px;
  border-bottom: 1px solid var(--border);
}

.sidebar-brand img {
  height: 32px;
  width: 32px;
  object-fit: contain;
  border-radius: 8px;
}

.sidebar-brand .brand-fallback {
  height: 32px;
  width: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--primary), #A78BFA);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
}

.sidebar-brand span {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.01em;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  overflow-y: auto;
}

.nav-section-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #9A9DAE;
  font-weight: 600;
  padding: 12px 10px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--ink-soft);
  font-weight: 500;
  font-size: 13.5px;
  margin-bottom: 2px;
  transition: background .15s, color .15s;
}

.nav-item svg { flex-shrink: 0; width: 18px; height: 18px; }

.nav-item:hover {
  background: var(--bg);
  color: var(--ink);
}

.nav-item.active {
  background: var(--primary-light);
  color: var(--primary-dark);
  font-weight: 600;
}

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding: 14px;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 8px;
}

.sidebar-user:hover { background: var(--bg); }

.avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #A78BFA);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}

.sidebar-user-info { overflow: hidden; }
.sidebar-user-info .name { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-info .email { font-size: 11.5px; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Main content ---------- */
.main {
  margin-left: 248px;
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 64px;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.breadcrumb {
  font-size: 13px;
  color: var(--ink-soft);
  display: flex;
  align-items: center;
  gap: 6px;
}

.breadcrumb .current { color: var(--ink); font-weight: 600; }

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

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 12px;
  color: var(--ink-soft);
  font-size: 13px;
  width: 220px;
}
.search-box input {
  border: none;
  background: transparent;
  outline: none;
  width: 100%;
  font-size: 13px;
  color: var(--ink);
}

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

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

.page-header h1 {
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 4px;
  letter-spacing: -0.01em;
}

.page-header p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 13.5px;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 600;
  border: 1px solid transparent;
  transition: background .15s, border-color .15s, opacity .15s;
  white-space: nowrap;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }

.btn-secondary { background: var(--white); color: var(--ink); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg); }

.btn-ghost { background: transparent; color: var(--ink-soft); }
.btn-ghost:hover { background: var(--bg); color: var(--ink); }

.btn-danger { background: #FEF2F2; color: var(--danger); }
.btn-danger:hover { background: #FEE2E2; }

.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-block { width: 100%; justify-content: center; }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }

/* ---------- Cards / Tabs ---------- */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.card-body { padding: 22px; }

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

.tab {
  padding: 10px 16px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink-soft);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.tab.active { color: var(--primary); border-color: var(--primary); }

/* ---------- Forms ---------- */
.form-group { margin-bottom: 16px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

label.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--ink);
}
label.form-label .req { color: var(--danger); }

.form-hint { font-size: 12px; color: var(--ink-soft); margin-top: 4px; }

.form-control {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13.5px;
  color: var(--ink);
  background: var(--white);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

textarea.form-control { resize: vertical; min-height: 100px; }

.upload-box {
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  color: var(--ink-soft);
  font-size: 12.5px;
  background: var(--bg);
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.upload-box:hover { border-color: var(--primary); background: var(--primary-light); }
.upload-box svg { margin-bottom: 8px; }
.upload-box .link { color: var(--primary); font-weight: 600; }

/* ---------- Empty state ---------- */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--ink-soft);
}
.empty-state svg { margin-bottom: 14px; opacity: .6; }
.empty-state h3 { color: var(--ink); font-size: 16px; margin: 0 0 6px; }
.empty-state p { margin: 0 0 18px; font-size: 13.5px; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
}
.badge-success { background: #ECFDF3; color: var(--success); }
.badge-warning { background: #FFFBEB; color: var(--warning); }
.badge-danger { background: #FEF2F2; color: var(--danger); }
.badge-muted { background: var(--bg); color: var(--ink-soft); }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  background: var(--ink);
  color: #fff;
  padding: 12px 18px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  z-index: 100;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
}

/* ---------- Login page ---------- */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #F7F7FB 0%, #EDE9FE 100%);
  padding: 20px;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 24px rgba(30,20,60,0.08);
  padding: 32px;
}

.auth-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
  text-align: center;
}

.auth-logo img { height: 44px; }

.auth-logo h1 { font-size: 17px; margin: 0; font-weight: 700; }
.auth-logo p { font-size: 12.5px; color: var(--ink-soft); margin: 0; }

.error-box {
  background: #FEF2F2;
  color: var(--danger);
  border: 1px solid #FECACA;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .form-row { grid-template-columns: 1fr; }
}
