:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --border: #e2e5eb;
  --text: #1f2430;
  --muted: #6b7280;
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #d97706;
  --radius: 8px;
}

* { box-sizing: border-box; }

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

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

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

.sidebar {
  width: 220px;
  background: #171923;
  color: #d1d5db;
  flex-shrink: 0;
  padding: 20px 0;
}
.sidebar .brand {
  color: #fff;
  font-weight: 700;
  font-size: 18px;
  padding: 0 20px 20px;
  border-bottom: 1px solid #2d2f3a;
  margin-bottom: 10px;
}
.sidebar a {
  display: block;
  padding: 10px 20px;
  color: #d1d5db;
}
.sidebar a:hover { background: #232634; text-decoration: none; }
.sidebar a.active { background: var(--primary); color: #fff; }

.main { flex: 1; padding: 24px 32px; max-width: 1200px; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.topbar h1 { font-size: 20px; margin: 0; }
.topbar .user { color: var(--muted); font-size: 13px; }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}

.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 900px) { .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr 1fr; } }

.stat-card { text-align: center; }
.stat-card .value { font-size: 28px; font-weight: 700; }
.stat-card .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 13px; }
th { color: var(--muted); font-weight: 600; text-transform: uppercase; font-size: 11px; letter-spacing: .03em; }
tr:last-child td { border-bottom: none; }

.btn {
  display: inline-block;
  padding: 8px 16px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}
.btn:hover { background: var(--primary-dark); text-decoration: none; color: #fff; }
.btn.secondary { background: #fff; border-color: var(--border); color: var(--text); }
.btn.secondary:hover { background: #f3f4f6; }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #b91c1c; }
.btn.small { padding: 5px 10px; font-size: 12px; }

.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; font-weight: 600; font-size: 13px; }
.form-group .hint { color: var(--muted); font-size: 12px; margin-top: 4px; }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=datetime-local], select, textarea {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
}
textarea { resize: vertical; }
.radio-group label { display: inline-flex; align-items: center; gap: 6px; margin-right: 20px; font-weight: normal; }

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .02em;
}
.badge.gray { background: #e5e7eb; color: #374151; }
.badge.green { background: #dcfce7; color: #166534; }
.badge.red { background: #fee2e2; color: #991b1b; }
.badge.blue { background: #dbeafe; color: #1e40af; }
.badge.yellow { background: #fef3c7; color: #92400e; }

.flash { padding: 10px 14px; border-radius: 6px; margin-bottom: 16px; font-size: 13px; }
.flash.success { background: #dcfce7; color: #166534; }
.flash.error { background: #fee2e2; color: #991b1b; }

.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; gap: 12px; flex-wrap: wrap; }
.toolbar-actions { display: flex; gap: 8px; }

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #4f46e5, #171923);
}
.login-box {
  background: #fff;
  padding: 36px;
  border-radius: 10px;
  width: 340px;
  box-shadow: 0 20px 40px rgba(0,0,0,.2);
}
.login-box h1 { margin: 0 0 4px; font-size: 20px; }
.login-box p.sub { color: var(--muted); margin: 0 0 20px; font-size: 13px; }

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

.ql-editor { min-height: 260px; background: #fff; }
#html-editor-wrap { border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }

.placeholder-btns { margin: 8px 0; }
.placeholder-btns button { margin-right: 6px; margin-bottom: 6px; }

.progress-bar { background: #e5e7eb; border-radius: 100px; height: 8px; overflow: hidden; }
.progress-bar span { display: block; height: 100%; background: var(--success); }

.help-box { background: #eef2ff; border: 1px solid #c7d2fe; padding: 12px 16px; border-radius: 6px; font-size: 13px; color: #3730a3; margin-bottom: 16px; }
