:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --text: #1c2333;
  --muted: #667085;
  --border: #e4e7ec;
  --primary: #4f46e5;
  --primary-soft: #eef2ff;
  --success: #12b76a;
  --success-soft: #ecfdf3;
  --danger: #f04438;
  --danger-soft: #fef3f2;
  --warn: #f79009;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 16px rgba(16, 24, 40, .06);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}
a { color: var(--primary); }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.25; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ---------- Layout ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 24px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; }
.brand .logo {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  background: var(--primary); color: #fff; font-size: 18px;
}
.user-box { display: flex; align-items: center; gap: 12px; }
.container { max-width: 1180px; margin: 0 auto; padding: 24px 16px 60px; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px;
}
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 900px) { .grid-2, .grid-4 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 600px) { .grid-2, .grid-4 { grid-template-columns: 1fr; } .topbar { padding: 10px 16px; } }

/* ---------- Form ---------- */
label { display: block; font-weight: 600; font-size: 13px; margin: 12px 0 6px; }
input, select, textarea {
  width: 100%; padding: 10px 12px; font: inherit; color: inherit;
  border: 1px solid var(--border); border-radius: 10px; background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
textarea { resize: vertical; min-height: 70px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 16px; border-radius: 10px; border: 1px solid transparent;
  font: inherit; font-weight: 600; cursor: pointer; background: var(--primary); color: #fff;
  text-decoration: none; transition: filter .15s, transform .05s;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.ghost { background: #fff; color: var(--text); border-color: var(--border); }
.btn.danger { background: var(--danger); }
.btn.sm { padding: 6px 10px; font-size: 13px; }
.btn.block { width: 100%; }

.alert { padding: 10px 12px; border-radius: 10px; font-size: 14px; margin-top: 12px; }
.alert.error { background: var(--danger-soft); color: #b42318; }
.alert.success { background: var(--success-soft); color: #027a48; }
.alert.info { background: var(--primary-soft); color: #3730a3; }
.hidden { display: none !important; }

/* ---------- Login ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 420px; }
.tabs { display: flex; gap: 4px; background: var(--bg); padding: 4px; border-radius: 12px; margin: 16px 0 4px; }
.tabs button {
  flex: 1; padding: 8px; border: 0; border-radius: 9px; background: transparent;
  font: inherit; font-weight: 600; color: var(--muted); cursor: pointer;
}
.tabs button.active { background: #fff; color: var(--text); box-shadow: var(--shadow); }

/* ---------- Vote ---------- */
.vote-header { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.slots { display: flex; gap: 8px; }
.slot {
  width: 44px; height: 44px; border-radius: 50%; border: 2px dashed var(--border);
  display: grid; place-items: center; font-weight: 700; color: var(--muted); background: #fff;
}
.slot.filled { border: 2px solid var(--primary); background: var(--primary); color: #fff; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar input, .toolbar select { max-width: 280px; }

.lect-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.lect {
  position: relative; cursor: pointer; text-align: left; font: inherit; color: inherit;
  background: var(--surface); border: 2px solid var(--border); border-radius: var(--radius);
  padding: 16px; display: flex; gap: 12px; align-items: flex-start; transition: border-color .15s, box-shadow .15s;
}
.lect:hover { border-color: #c7d2fe; box-shadow: var(--shadow); }
.lect.selected { border-color: var(--primary); background: var(--primary-soft); }
.lect.disabled { opacity: .45; cursor: not-allowed; }
.lect .check {
  position: absolute; top: 10px; right: 10px; width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center; background: var(--primary); color: #fff; font-size: 13px; font-weight: 700;
}
.avatar {
  flex: none; width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center;
  color: #fff; font-weight: 700; font-size: 16px;
}
.lect .name { font-weight: 700; }
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--bg); color: var(--muted);
}
.badge.green { background: var(--success-soft); color: #027a48; }
.badge.red { background: var(--danger-soft); color: #b42318; }
.badge.blue { background: var(--primary-soft); color: #3730a3; }

.submit-bar {
  position: sticky; bottom: 0; margin-top: 20px; padding: 14px 16px;
  background: rgba(255,255,255,.95); backdrop-filter: blur(6px);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}

/* ---------- Admin ---------- */
.nav { display: flex; gap: 6px; margin-bottom: 20px; flex-wrap: wrap; }
.nav button {
  padding: 9px 16px; border-radius: 10px; border: 1px solid var(--border); background: #fff;
  font: inherit; font-weight: 600; cursor: pointer; color: var(--muted);
}
.nav button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.kpi .label { color: var(--muted); font-size: 13px; font-weight: 600; }
.kpi .value { font-size: 30px; font-weight: 800; margin-top: 4px; }
.kpi .sub { font-size: 13px; color: var(--muted); }
.progress { height: 8px; background: var(--bg); border-radius: 99px; overflow: hidden; margin-top: 8px; }
.progress > span { display: block; height: 100%; background: var(--primary); border-radius: 99px; }
.chart-box { position: relative; height: 300px; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 8px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.table-wrap { overflow-x: auto; }
.rank { font-weight: 800; width: 36px; }
.medal { font-size: 18px; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 600; }
.switch input { display: none; }
.switch .track { width: 42px; height: 24px; border-radius: 99px; background: #d0d5dd; position: relative; transition: background .2s; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: left .2s; }
.switch input:checked + .track { background: var(--success); }
.switch input:checked + .track::after { left: 21px; }

dialog { border: 0; border-radius: var(--radius); padding: 0; width: min(520px, calc(100vw - 32px)); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(16, 24, 40, .45); }
dialog form { padding: 22px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
