:root {
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --secondary: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --bg: #f3f4f6;
  --card: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --shadow: 0 1px 3px rgba(0,0,0,0.1);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

a { color: var(--primary); text-decoration: none; }

/* Login */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
}

.login-card {
  background: var(--card);
  padding: 40px;
  border-radius: 16px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.2);
  width: 360px;
}

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

.login-card p {
  margin: 0 0 24px;
  color: var(--muted);
  text-align: center;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-weight: 500;
}

.form-control {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  transition: border .2s;
}

.form-control:focus {
  border-color: var(--primary);
}

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

select.form-control { height: 38px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  transition: opacity .2s, transform .1s;
}

.btn:active { transform: translateY(1px); }

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

.btn-secondary { background: #f3f4f6; color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: #e5e7eb; }

.btn-success { background: var(--secondary); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }

.btn-sm { padding: 5px 10px; font-size: 12px; }

.btn-block { width: 100%; }

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

.sidebar {
  width: 220px;
  background: #1f2937;
  color: #fff;
  display: flex;
  flex-direction: column;
}

.brand {
  padding: 20px;
  font-size: 18px;
  font-weight: 700;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.nav {
  flex: 1;
  padding: 12px 0;
}

.nav a {
  display: block;
  padding: 12px 20px;
  color: #d1d5db;
  border-left: 3px solid transparent;
}

.nav a:hover, .nav a.active {
  background: rgba(255,255,255,0.05);
  color: #fff;
  border-left-color: var(--primary);
}

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

.topbar {
  height: 60px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  box-shadow: var(--shadow);
}

.topbar h2 { margin: 0; font-size: 18px; }

.content {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
}

/* Cards / Stats */
.card {
  background: var(--card);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 20px;
}

.card-title {
  margin: 0 0 16px;
  font-size: 16px;
  font-weight: 600;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--card);
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--shadow);
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--primary);
}

.stat-label {
  color: var(--muted);
  margin-top: 4px;
}

/* Tables */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

th, td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  background: #f9fafb;
  font-weight: 600;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

tr:hover { background: #f9fafb; }

/* Tags */
.tag {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}

.tag-draft { background: #e5e7eb; color: #374151; }
.tag-reviewing { background: #dbeafe; color: #1e40af; }
.tag-published { background: #d1fae5; color: #065f46; }
.tag-rejected { background: #fee2e2; color: #991b1b; }

.tag-practice { background: #eff6ff; color: #1e40af; }
.tag-exam { background: #fff7ed; color: #9a3412; }
.tag-survey { background: #f5f3ff; color: #5b21b6; }
.tag-psychology { background: #ecfdf5; color: #065f46; }

/* Toolbar */
.toolbar {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  align-items: center;
}

.toolbar .form-control { width: auto; min-width: 140px; }

/* Forms */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.form-actions {
  margin-top: 20px;
  display: flex;
  gap: 12px;
}

/* Options editor */
.option-row {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}

.option-row .form-control { flex: 1; margin-bottom: 0; }

/* Toast */
.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 12px 18px;
  border-radius: 8px;
  color: #fff;
  font-weight: 500;
  box-shadow: 0 10px 25px rgba(0,0,0,0.15);
  z-index: 1000;
  transform: translateX(120%);
  transition: transform .3s;
}

.toast.show { transform: translateX(0); }
.toast.success { background: var(--secondary); }
.toast.error { background: var(--danger); }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
}

.modal {
  background: var(--card);
  border-radius: 12px;
  width: 90%;
  max-width: 700px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 50px rgba(0,0,0,0.2);
}

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

.modal-body { padding: 20px; }

.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.close-btn {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--muted);
}

/* Charts */
.bar-chart { margin-top: 10px; }
.bar-row {
  display: flex;
  align-items: center;
  margin-bottom: 10px;
}
.bar-label {
  width: 140px;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bar-track {
  flex: 1;
  height: 20px;
  background: #e5e7eb;
  border-radius: 10px;
  overflow: hidden;
  margin: 0 10px;
}
.bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 10px;
}
.bar-value { width: 60px; font-size: 13px; color: var(--muted); text-align: right; }

.empty-state {
  padding: 40px;
  text-align: center;
  color: var(--muted);
}
