:root {
  --bg: #edf2f7;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #d8e2ed;
  --sidebar: #0b1220;
  --sidebar-soft: #121b2d;
  --accent: #0ea5e9;
  --accent-dark: #0369a1;
  --green: #16a34a;
  --red: #dc2626;
  --amber: #d97706;
  --purple: #7c3aed;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 13px;
  letter-spacing: 0;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(15, 23, 42, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(15, 23, 42, 0.045) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: linear-gradient(to bottom, rgba(0,0,0,.6), transparent 70%);
}

button, input, select, textarea {
  font: inherit;
  letter-spacing: 0;
}

button {
  cursor: pointer;
}

input, select, textarea {
  width: 100%;
  min-height: 34px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;
  padding: 7px 10px;
  color: var(--ink);
}

input:disabled, select:disabled, textarea:disabled {
  color: #475569;
  background: #f1f5f9;
  cursor: not-allowed;
}

textarea {
  resize: vertical;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(14, 165, 233, .16);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 8px 10px;
  font-size: 12px;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid #edf2f7;
}

th {
  color: #475569;
  background: #f8fafc;
  font-weight: 800;
  white-space: nowrap;
}

td {
  background: #fff;
}

tr:hover td {
  background: #f8fbff;
}

.login-page {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background-color: #07111f;
  background-image:
    linear-gradient(135deg, rgba(14, 165, 233, .22), rgba(34, 197, 94, .12)),
    linear-gradient(rgba(255,255,255,.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.07) 1px, transparent 1px);
  background-size: auto, 36px 36px, 36px 36px;
}

.login-card {
  width: min(380px, calc(100vw - 32px));
  padding: 32px;
  border: 1px solid rgba(255,255,255,.28);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(0,0,0,.28);
}

.brand-mark {
  width: 44px;
  height: 44px;
  margin: 0 auto 12px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  font-weight: 900;
  background: linear-gradient(135deg, var(--accent), #22c55e);
}

.login-card h1 {
  margin: 0;
  text-align: center;
  font-size: 24px;
}

.login-card p {
  margin: 4px 0 24px;
  text-align: center;
  color: #94a3b8;
}

.error {
  margin-top: 12px;
  color: var(--red);
  text-align: center;
  font-size: 12px;
}

.app-shell {
  position: relative;
  z-index: 1;
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 216px;
  flex: 0 0 216px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px;
  color: #cbd5e1;
  background: var(--sidebar);
  border-right: 1px solid #1e293b;
  box-shadow: 12px 0 28px rgba(15, 23, 42, .12);
}

.sidebar h1 {
  margin: 0;
  color: #fff;
  font-size: 22px;
}

.user-badge {
  padding: 10px 12px;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 8px;
  background: rgba(255,255,255,.06);
  color: #dbeafe;
  line-height: 1.45;
}

.nav {
  display: grid;
  gap: 6px;
}

.nav-btn, .logout-btn {
  min-height: 36px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #cbd5e1;
  text-align: left;
  padding: 8px 10px;
}

.nav-btn:hover, .logout-btn:hover {
  background: rgba(148, 163, 184, .12);
  color: #fff;
}

.nav-btn.active {
  background: rgba(14, 165, 233, .18);
  color: #f8fafc;
  border-color: rgba(14, 165, 233, .34);
}

.logout-btn {
  color: #fb7185;
  margin-top: auto;
}

.version {
  color: #475569;
  text-align: center;
  font-size: 11px;
}

.main {
  flex: 1;
  min-width: 0;
  padding: 20px;
  overflow: auto;
}

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

.page-header h2 {
  margin: 0;
  font-size: 22px;
}

.page-header p {
  margin: 4px 0 0;
  color: #64748b;
  font-size: 12px;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(15, 23, 42, .05);
}

.table-wrap {
  overflow: auto;
}

.btn {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(15, 23, 42, .08);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: .55;
  transform: none;
  box-shadow: none;
}

.btn-primary { color: #fff; background: #2563eb; }
.btn-dark { color: #fff; background: #0f172a; }
.btn-green { color: #fff; background: #16a34a; }
.btn-red { color: #fff; background: #dc2626; }
.btn-purple { color: #fff; background: #7c3aed; }
.btn-blue-soft { color: #2563eb; background: #eff6ff; }
.btn-green-soft { color: #16a34a; background: #f0fdf4; }
.btn-red-soft { color: #dc2626; background: #fef2f2; }
.btn-amber-soft { color: #d97706; background: #fffbeb; }
.btn-muted { color: #475569; background: #f1f5f9; border-color: #e2e8f0; }

.field-sm {
  width: auto;
  min-width: 120px;
  max-width: 220px;
}

.filter-panel {
  padding: 12px;
  margin-bottom: 12px;
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.filter-group label {
  color: #64748b;
  font-size: 11px;
  white-space: nowrap;
}

.summary {
  color: #64748b;
  font-size: 12px;
}

.tag {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.tag-blue { color: #1d4ed8; background: #dbeafe; }
.tag-green { color: #047857; background: #d1fae5; }
.tag-amber { color: #b45309; background: #fef3c7; }
.tag-red { color: #b91c1c; background: #fee2e2; }
.tag-gray { color: #64748b; background: #f1f5f9; }
.tag-teal { color: #0f766e; background: #ccfbf1; }
.tag-orange { color: #c2410c; background: #ffedd5; }
.tag-purple { color: #6d28d9; background: #ede9fe; }
.tag-slate { color: #475569; background: #e2e8f0; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.metric {
  padding: 16px;
}

.metric-label {
  color: #64748b;
  margin-bottom: 8px;
}

.metric-value {
  font-size: 24px;
  line-height: 1.1;
  font-weight: 900;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 14px;
}

.panel {
  padding: 16px;
}

.panel-title {
  margin-bottom: 14px;
  font-size: 14px;
  font-weight: 900;
}

.progress-row {
  margin-bottom: 12px;
}

.rank-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.rank-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #334155;
}

.progress-track {
  height: 8px;
  margin-top: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: #e2e8f0;
}

.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
}

.trend-grid {
  min-height: 190px;
  display: grid;
  grid-template-columns: repeat(14, minmax(24px, 1fr));
  align-items: end;
  gap: 8px;
}

.trend-item {
  color: #94a3b8;
  text-align: center;
  font-size: 10px;
}

.trend-bar {
  width: 100%;
  min-height: 4px;
  border-radius: 8px 8px 2px 2px;
  background: linear-gradient(180deg, var(--accent), #2563eb);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(15, 23, 42, .55);
}

.modal {
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 42px);
  overflow: auto;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 28px 80px rgba(0,0,0,.24);
  padding: 22px;
}

.modal.wide {
  width: min(760px, calc(100vw - 32px));
}

.modal h3 {
  margin: 0 0 14px;
  font-size: 18px;
}

.form-grid {
  display: grid;
  gap: 12px;
}

.field-block {
  display: grid;
  gap: 6px;
}

.field-block label {
  color: #475569;
  font-size: 12px;
  font-weight: 800;
}

.form-grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.form-actions .btn {
  flex: 1;
}

.inline-note {
  color: #64748b;
  font-size: 12px;
  line-height: 1.5;
}

.check-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.check-item {
  padding: 8px 10px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #f8fafc;
}

.check-item strong {
  display: block;
  margin-top: 4px;
}

.check-pass { color: #047857; }
.check-fail { color: #b91c1c; }

.user-cards {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.user-card {
  padding: 12px;
  border-left: 4px solid var(--accent);
}

.text-muted { color: #64748b; }
.text-danger { color: #dc2626; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace; }
.nowrap { white-space: nowrap; }
.clickable { cursor: pointer; }
.empty { padding: 28px; color: #94a3b8; text-align: center; }

@media (max-width: 980px) {
  .app-shell { flex-direction: column; }
  .sidebar {
    width: 100%;
    flex: none;
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
  }
  .nav { display: flex; }
  .main { padding: 12px; }
  .stats-grid, .dashboard-grid, .user-cards, .check-grid { grid-template-columns: 1fr; }
  .page-header { align-items: flex-start; flex-direction: column; }
  .form-grid.two { grid-template-columns: 1fr; }
}
