:root {
  --bg-app: #f4f6fb;
  --bg-sidebar: #0f172a;
  --bg-sidebar-hover: #1e293b;
  --accent: #2563eb;
  --accent-soft: #dbeafe;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --card-shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 8px 24px rgba(15, 23, 42, 0.06);
  --radius: 12px;
  --font: "DM Sans", system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  font-size: 15px;
}

body {
  font-family: var(--font);
  color: var(--text-main);
  background: var(--bg-app);
  margin: 0;
}

/* App shell */
.app-body {
  min-height: 100vh;
}

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 260px;
  flex-shrink: 0;
  background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
  padding: 1.25rem 0;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 1.25rem 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 1rem;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  letter-spacing: 0.02em;
}

.sidebar-brand strong {
  display: block;
  font-size: 1rem;
  color: #fff;
}

.sidebar-brand small {
  color: #94a3b8;
  font-size: 0.75rem;
}

.sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0 0.75rem;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  color: #cbd5e1;
  text-decoration: none;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}

.sidebar-link:hover {
  background: var(--bg-sidebar-hover);
  color: #fff;
}

.sidebar-link.active {
  background: rgba(37, 99, 235, 0.25);
  color: #fff;
}

.sidebar-icon {
  opacity: 0.85;
  font-size: 0.9rem;
  width: 1.25rem;
  text-align: center;
}

.sidebar-footer {
  padding: 1rem 1.25rem 0;
}

.role-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
}

.role-admin {
  background: rgba(34, 197, 94, 0.2);
  color: #86efac;
}

.role-dev {
  background: rgba(59, 130, 246, 0.25);
  color: #93c5fd;
}

.main-column {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1rem;
  background: #fff;
  border-bottom: 1px solid var(--border);
}

.compact-row {
  font-size: 0.875rem;
}

.table-compact-wrap {
  overflow-x: auto;
}

.table-compact td,
.table-compact th {
  padding: 0.35rem 0.5rem !important;
  font-size: 0.85rem;
}

.page-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.user-name {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.content-area {
  flex: 1;
  padding: 0.75rem 1rem 1rem;
  max-width: 100%;
}

.app-footer {
  padding: 0.75rem 2rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  background: #fff;
}

/* Page blocks */
.page-header {
  margin-bottom: 1.5rem;
}

.page-header h1 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.page-header p {
  margin: 0;
  color: var(--text-muted);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 1.35rem 1.5rem;
  box-shadow: var(--card-shadow);
  border: 1px solid var(--border);
}

.stat-card h5 {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.stat-card .stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.1;
}

.panel {
  background: #fff;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--card-shadow);
  overflow: hidden;
}

.panel-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}

.panel-body {
  padding: 0;
}

.table-modern {
  margin: 0;
}

.table-modern thead th {
  background: #f8fafc;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  padding: 0.85rem 1.25rem;
}

.table-modern tbody td {
  padding: 0.85rem 1.25rem;
  vertical-align: middle;
  border-bottom: 1px solid #f1f5f9;
}

.table-modern tbody tr:last-child td {
  border-bottom: none;
}

.table-modern tbody tr:hover {
  background: #f8fafc;
}

code {
  font-size: 0.85em;
  background: #f1f5f9;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  color: #be185d;
}

.form-panel {
  background: #fff;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--card-shadow);
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
}

.btn-primary:hover {
  background: #1d4ed8;
  border-color: #1d4ed8;
}

.alert {
  border-radius: 8px;
}

/* Login */
.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 50%, #2563eb 100%);
  padding: 2rem;
}

.login-shell-inner {
  width: 100%;
  max-width: 420px;
}

.login-card {
  background: #fff;
  border-radius: 16px;
  padding: 2.25rem 2rem;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
}

.login-brand {
  text-align: center;
  margin-bottom: 2rem;
}

.login-logo {
  display: inline-flex;
  width: 56px;
  height: 56px;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  border-radius: 14px;
  margin-bottom: 1rem;
}

.login-brand h1 {
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
}

@media (max-width: 991px) {
  .app-shell {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
  }

  .sidebar-nav {
    flex-direction: row;
    flex-wrap: wrap;
    flex: unset;
  }

  .sidebar-footer {
    display: none;
  }

  .content-area {
    padding: 1rem;
  }
}
