:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --border: #e2e4e9;
  --text: #1f2430;
  --muted: #6b7280;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #dc2626;
  --success: #16a34a;
  --radius: 10px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e293b, #334155);
}
.login-card {
  background: var(--panel);
  padding: 36px 32px;
  border-radius: var(--radius);
  width: 340px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.25);
}
.login-card h1 { font-size: 20px; margin: 0 0 4px; }
.login-card p.subtitle { color: var(--muted); margin: 0 0 20px; font-size: 13px; }

.admin-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px;
  background: #111827;
  color: #d1d5db;
  padding: 20px 0;
  flex-shrink: 0;
}
.sidebar .brand {
  font-weight: 700;
  color: #fff;
  padding: 0 20px 18px;
  font-size: 15px;
  border-bottom: 1px solid #1f2937;
  margin-bottom: 8px;
}
.sidebar a {
  display: block;
  padding: 10px 20px;
  color: #d1d5db;
  font-size: 14px;
}
.sidebar a:hover { background: #1f2937; text-decoration: none; }
.sidebar a.active { background: #2563eb; color: #fff; }
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 56px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
}
.topbar form { margin: 0; }
.content { padding: 24px; flex: 1; }

.flash {
  padding: 10px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 14px;
}
.flash.success { background: #ecfdf5; color: var(--success); border: 1px solid #bbf7d0; }
.flash.error { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.grid-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.stat-card .num { font-size: 28px; font-weight: 700; }
.stat-card .label { color: var(--muted); font-size: 13px; margin-top: 4px; }

.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.page-head h1 { font-size: 20px; margin: 0; }

.btn {
  display: inline-block;
  padding: 8px 16px;
  border-radius: 8px;
  border: none;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  font-size: 14px;
}
.btn:hover { background: var(--primary-dark); text-decoration: none; }
.btn.secondary { background: #e5e7eb; color: var(--text); }
.btn.secondary:hover { background: #d1d5db; }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #b91c1c; }
.btn.small { padding: 5px 10px; font-size: 12px; }

table { width: 100%; border-collapse: collapse; background: var(--panel); }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 14px; vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; }
tr:last-child td { border-bottom: none; }
.table-wrap { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); background: #f3f4f6; }

.form-row { margin-bottom: 16px; }
.form-row label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 600; color: #374151; }
.form-row .hint { color: var(--muted); font-size: 12px; margin-top: 4px; }
input[type=text], input[type=password], input[type=number], input[type=file], select, textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
}
textarea { min-height: 90px; resize: vertical; }
.form-actions { display: flex; gap: 10px; margin-top: 20px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.tree ul { list-style: none; margin: 0; padding-left: 22px; }
.tree > ul { padding-left: 0; }
.tree li { margin: 4px 0; }
.tree .row { display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-radius: 8px; }
.tree .row:hover { background: #f3f4f6; }
.tree .name { font-size: 14px; }
.tree .actions a, .tree .actions button { font-size: 12px; }
.badge { display: inline-block; background: #eef2ff; color: #4338ca; border-radius: 6px; padding: 2px 8px; font-size: 12px; }
.empty { color: var(--muted); padding: 30px; text-align: center; }
