/* =========================================================
   KÝ ỨC TUỔI THƠ — Photo Contest Styles
   ========================================================= */
:root {
  --bg: #fff8f0;
  --card: #ffffff;
  --primary: #ff7a59;
  --primary-dark: #e85a3b;
  --accent: #ffc857;
  --pink: #ff9eb5;
  --ink: #2d2a26;
  --muted: #7a7470;
  --line: #f0e4d6;
  --gold: #f5b50a;
  --gold-soft: #fff4cc;
  --green: #5cb85c;
  --red: #d33;
  --shadow: 0 6px 24px rgba(232, 90, 59, 0.10);
}
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  font-family: 'Segoe UI', 'Helvetica Neue', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
}

/* ---------- LOGIN ---------- */
#login {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(circle at 20% 20%, #ffd9c2 0%, transparent 40%),
    radial-gradient(circle at 80% 80%, #ffe5a3 0%, transparent 40%),
    radial-gradient(circle at 50% 50%, #ffc4d6 0%, transparent 50%),
    var(--bg);
  padding: 24px;
}
.login-card {
  background: white; border-radius: 24px;
  padding: 40px 36px; width: 100%; max-width: 440px;
  box-shadow: var(--shadow); text-align: center;
}
.login-card .logo { font-size: 56px; margin-bottom: 8px; }
.login-card h1 { font-size: 26px; margin: 4px 0; color: var(--primary-dark); letter-spacing: 0.5px; }
.login-card .sub { color: var(--muted); font-size: 14px; margin-bottom: 28px; }
.field { text-align: left; margin-bottom: 16px; }
.field label {
  display: block; font-size: 13px; color: var(--muted);
  margin-bottom: 6px; font-weight: 500;
}
.field input {
  width: 100%; padding: 12px 14px;
  border: 1.5px solid var(--line); border-radius: 12px;
  font-size: 15px; color: var(--ink); background: #fffdf9;
  transition: border-color .2s;
}
.field input:focus { outline: none; border-color: var(--primary); }
.btn {
  background: var(--primary); color: white; border: none;
  padding: 13px 22px; border-radius: 12px;
  font-size: 15px; font-weight: 600; cursor: pointer;
  transition: all .15s; width: 100%;
}
.btn:hover { background: var(--primary-dark); transform: translateY(-1px); }
.btn:disabled { background: #d9d3cc; cursor: not-allowed; transform: none; }
.login-hint { margin-top: 18px; font-size: 12px; color: var(--muted); }
.err { color: var(--red); font-size: 13px; margin-top: 8px; min-height: 18px; }

/* ---------- APP ---------- */
#app { display: none; }
#app.active { display: block; }
header.top {
  background: linear-gradient(135deg, #ff7a59 0%, #ff9eb5 50%, #ffc857 100%);
  color: white; padding: 22px 24px; box-shadow: var(--shadow);
}
.top-inner {
  max-width: 1200px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-emoji { font-size: 34px; }
.brand h1 { margin: 0; font-size: 22px; letter-spacing: 0.5px; }
.brand .tagline { font-size: 12px; opacity: 0.9; }
.user-pill {
  display: flex; align-items: center; gap: 10px;
  background: rgba(255,255,255,0.2); backdrop-filter: blur(6px);
  padding: 8px 14px; border-radius: 999px; font-size: 13px;
}
.user-pill .avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: white; color: var(--primary); font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
}
.logout {
  background: rgba(255,255,255,0.25); color: white; border: none;
  padding: 6px 10px; border-radius: 8px; font-size: 11px; cursor: pointer;
}
.logout:hover { background: rgba(255,255,255,0.4); }
.role-badge {
  background: var(--gold); color: var(--ink); font-weight: 700;
  font-size: 10px; padding: 3px 7px; border-radius: 6px;
  letter-spacing: 0.5px; margin-left: 4px;
}

/* tabs */
nav.tabs {
  background: white; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.tabs-inner {
  max-width: 1200px; margin: 0 auto; padding: 0 16px;
  display: flex; gap: 4px; overflow-x: auto;
}
.tab {
  background: none; border: none; padding: 16px 18px;
  font-size: 14px; font-weight: 600; color: var(--muted);
  cursor: pointer; border-bottom: 3px solid transparent;
  white-space: nowrap; transition: all .15s;
}
.tab:hover { color: var(--primary); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab .ico { margin-right: 4px; }

main { max-width: 1200px; margin: 0 auto; padding: 24px 16px 60px; }

/* category header */
.cat-header {
  background: white; border-radius: 18px;
  padding: 22px 24px; margin-bottom: 22px;
  box-shadow: var(--shadow); border-left: 6px solid var(--primary);
}
.cat-header h2 { margin: 0 0 6px; font-size: 20px; color: var(--primary-dark); }
.cat-header p { margin: 0; font-size: 14px; color: var(--muted); }
.vote-meter {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--gold-soft); color: #8a6d00;
  padding: 8px 14px; border-radius: 999px; font-size: 13px;
  font-weight: 600; margin-top: 10px;
}

/* photo grid */
.grid {
  display: grid; gap: 18px;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}
.card {
  background: white; border-radius: 16px; overflow: hidden;
  box-shadow: var(--shadow); transition: all .2s;
  border: 2px solid transparent; display: flex; flex-direction: column;
}
.card:hover { transform: translateY(-3px); box-shadow: 0 10px 32px rgba(232,90,59,0.15); }
.card.voted { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-soft), var(--shadow); }
.card .photo {
  aspect-ratio: 1 / 1; position: relative; overflow: hidden;
  background: #f5ede0;
}
.card .photo img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.card .badge {
  position: absolute; top: 10px; right: 10px;
  background: rgba(255,255,255,0.95); color: var(--primary-dark);
  font-weight: 700; font-size: 12px; padding: 5px 10px;
  border-radius: 999px;
}
.card .gold-mark {
  position: absolute; top: 10px; left: 10px;
  background: var(--gold); color: white;
  font-weight: 700; font-size: 12px; padding: 5px 10px;
  border-radius: 999px; display: none;
}
.card.voted .gold-mark { display: block; }
/* Glow Up tab */
.card.glow-card.picked { border-color: var(--gold); box-shadow: 0 0 0 4px var(--gold-soft), var(--shadow); }
.card.glow-card .crown {
  position: absolute; top: 10px; left: 10px;
  background: var(--gold); color: white;
  font-weight: 700; font-size: 12px; padding: 5px 10px;
  border-radius: 999px; display: none;
}
.card.glow-card.picked .crown { display: block; }
.glow-real { font-size: 12px; color: var(--gold); font-weight: 600; margin-bottom: 6px; }
.card .body { padding: 14px 16px 16px; flex: 1; display: flex; flex-direction: column; }
.card h3 { margin: 0 0 4px; font-size: 16px; color: var(--ink); }
.card .meta { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.card .story {
  font-size: 13px; color: var(--muted); flex: 1; margin-bottom: 12px;
  white-space: pre-wrap; word-wrap: break-word;
}
.card .actions { display: flex; align-items: center; justify-content: space-between; }
.vote-btn {
  background: var(--primary); color: white; border: none;
  padding: 8px 14px; border-radius: 10px; font-size: 13px;
  font-weight: 600; cursor: pointer; transition: all .15s;
}
.vote-btn:hover { background: var(--primary-dark); }
.vote-btn.voted { background: var(--gold); }
.vote-btn:disabled { background: #e5dfd8; color: #998f86; cursor: not-allowed; }
.vote-count { font-size: 13px; color: var(--muted); font-weight: 600; }

.loading {
  grid-column: 1 / -1; text-align: center; padding: 40px;
  color: var(--muted); font-size: 14px;
}
.empty {
  grid-column: 1 / -1; text-align: center; padding: 60px 20px;
  color: var(--muted); font-size: 14px;
}
.note {
  background: #fff4ea; border-left: 4px solid var(--accent);
  padding: 12px 16px; border-radius: 8px; font-size: 13px;
  color: #6a5a30; margin-bottom: 18px;
}

/* minigame */
.minigame-wrap {
  background: white; border-radius: 18px; padding: 28px;
  box-shadow: var(--shadow); max-width: 640px; margin: 0 auto;
}
.mg-progress {
  display: flex; align-items: center; justify-content: space-between;
  color: var(--muted); font-size: 13px; margin-bottom: 16px;
}
.mg-score { color: var(--gold); font-weight: 700; }
.mg-photo {
  width: 240px; height: 240px; margin: 0 auto 18px;
  border-radius: 16px; overflow: hidden; background: #f5ede0;
  box-shadow: 0 8px 24px rgba(0,0,0,0.08);
}
.mg-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mg-question { text-align: center; font-size: 18px; font-weight: 600; margin-bottom: 18px; }
.mg-options { display: grid; gap: 10px; }
.mg-opt {
  background: #fff8ef; border: 2px solid var(--line); border-radius: 12px;
  padding: 14px 16px; font-size: 15px; cursor: pointer; text-align: left;
  transition: all .15s; color: var(--ink); font-weight: 500;
}
.mg-opt:hover { border-color: var(--primary); background: #fff4ea; }
.mg-opt.correct { background: #e8f7e8; border-color: var(--green); color: #2c6e2c; }
.mg-opt.wrong { background: #fde7e7; border-color: var(--red); color: #a02828; }
.mg-opt:disabled { cursor: default; }
.mg-next { margin-top: 18px; display: flex; gap: 10px; justify-content: center; }
.mg-feedback { text-align: center; padding: 14px; border-radius: 12px; margin-top: 14px; font-weight: 600; }
.mg-feedback.right { background: #e8f7e8; color: #2c6e2c; }
.mg-feedback.wrong { background: #fde7e7; color: #a02828; }

/* results */
.results-wrap { display: grid; gap: 22px; }
.res-section { background: white; border-radius: 18px; padding: 22px 24px; box-shadow: var(--shadow); }
.res-section h3 { margin-top: 0; color: var(--primary-dark); }
.leaderboard { display: flex; flex-direction: column; gap: 10px; }
.row {
  display: flex; align-items: center; gap: 14px;
  padding: 10px; border-radius: 12px; background: #fffaf3;
}
.row .rank {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--line); color: var(--ink);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; flex-shrink: 0;
}
.row.r1 .rank { background: var(--gold); color: white; }
.row.r2 .rank { background: #c0c0c0; color: white; }
.row.r3 .rank { background: #cd7f32; color: white; }
.row .mini-photo {
  width: 44px; height: 44px; border-radius: 10px; overflow: hidden; flex-shrink: 0;
  background: linear-gradient(135deg, var(--accent), var(--primary));
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 700; font-size: 16px;
}
.row .mini-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.row .info { flex: 1; min-width: 0; }
.row .info .name { font-weight: 600; font-size: 14px; }
.row .info .bar-wrap { background: #f4ebde; height: 6px; border-radius: 3px; margin-top: 4px; overflow: hidden; }
.row .info .bar { background: linear-gradient(90deg, var(--primary), var(--accent)); height: 100%; }
.row .count { font-weight: 700; color: var(--primary-dark); font-size: 14px; }

/* ---------- BTC ---------- */
.btc-subnav {
  display: flex; gap: 6px; margin-bottom: 18px;
  background: white; padding: 6px; border-radius: 14px;
  box-shadow: var(--shadow); overflow-x: auto;
}
.btc-subtab {
  background: none; border: none; padding: 10px 16px;
  font-size: 14px; font-weight: 600; color: var(--muted);
  cursor: pointer; border-radius: 10px; white-space: nowrap;
  transition: all .15s;
}
.btc-subtab:hover { background: #fff4ea; color: var(--primary); }
.btc-subtab.active { background: var(--primary); color: white; }

.stat-grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin-bottom: 22px;
}
.stat-card {
  background: white; border-radius: 16px; padding: 18px 20px;
  box-shadow: var(--shadow); border-top: 4px solid var(--primary);
}
.stat-card .label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; }
.stat-card .value { font-size: 30px; font-weight: 700; color: var(--primary-dark); margin: 4px 0; }
.stat-card .delta { font-size: 12px; color: var(--green); font-weight: 600; }
.stat-card.c2 { border-top-color: var(--pink); } .stat-card.c2 .value { color: #c94565; }
.stat-card.c3 { border-top-color: var(--accent); } .stat-card.c3 .value { color: #b88200; }
.stat-card.c4 { border-top-color: var(--green); } .stat-card.c4 .value { color: #3d8c3d; }

.panel { background: white; border-radius: 18px; padding: 24px; box-shadow: var(--shadow); margin-bottom: 18px; }
.panel h3 { margin-top: 0; color: var(--primary-dark); }
.panel .hint { font-size: 13px; color: var(--muted); margin-top: 0; }
.muted { color: var(--muted); font-size: 12px; }

.timeline { display: grid; gap: 10px; margin-top: 12px; }
.timeline-item {
  display: flex; gap: 14px; align-items: center;
  padding: 10px; background: #fffaf3; border-radius: 10px;
}
.timeline-item.current { background: #fff4ea; border-left: 3px solid var(--primary); }
.timeline-item .ico { font-size: 22px; }
.timeline-item .info b { display: block; }
.timeline-item .info span { font-size: 12px; color: var(--muted); }

.form-row { display: grid; gap: 14px; grid-template-columns: 1fr 1fr; margin-top: 8px; }
@media (max-width: 600px) { .form-row { grid-template-columns: 1fr; } }
.form-side { display: flex; flex-direction: column; gap: 12px; }
.form-field { display: flex; flex-direction: column; margin-bottom: 14px; }
.form-field label { font-size: 13px; color: var(--muted); margin-bottom: 6px; font-weight: 500; }
.form-field input, .form-field textarea, .form-field select {
  padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 10px;
  font-size: 14px; font-family: inherit; background: #fffdf9; resize: vertical;
}
.form-field input:focus, .form-field textarea:focus, .form-field select:focus {
  outline: none; border-color: var(--primary);
}

.radio-group { display: flex; gap: 10px; }
.radio-card {
  flex: 1; padding: 14px; border: 2px solid var(--line); border-radius: 12px;
  cursor: pointer; text-align: center; transition: all .15s; background: #fffdf9;
}
.radio-card:hover { border-color: var(--primary); }
.radio-card.checked { border-color: var(--primary); background: #fff4ea; }
.radio-card .icon { font-size: 22px; display: block; margin-bottom: 4px; }
.radio-card .name { font-size: 13px; font-weight: 600; }
.radio-card .desc { font-size: 11px; color: var(--muted); margin-top: 2px; }

.upload-zone {
  border: 2.5px dashed var(--line); border-radius: 14px;
  padding: 28px; text-align: center; cursor: pointer;
  transition: all .15s; background: #fffdf9;
  min-height: 200px; display: flex; align-items: center; justify-content: center;
}
.upload-zone:hover { border-color: var(--primary); background: #fff4ea; }
.upload-zone .ico { font-size: 36px; margin-bottom: 6px; }
.upload-zone .text { font-weight: 600; color: var(--ink); }
.upload-zone .sub { font-size: 12px; color: var(--muted); margin-top: 4px; }
.upload-status { font-size: 12px; color: var(--muted); margin-top: 6px; min-height: 16px; }
.upload-status.success { color: var(--green); }
.upload-status.error { color: var(--red); }

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.btn-row .btn { max-width: 200px; }
.btn-secondary {
  background: #f5ede0; color: var(--ink); border: none;
  padding: 11px 18px; border-radius: 10px; font-size: 14px;
  font-weight: 600; cursor: pointer; transition: all .15s;
}
.btn-secondary:hover { background: #ebdfca; }
.btn-danger {
  background: #fde7e7; color: #a02828; border: none;
  padding: 6px 12px; border-radius: 8px; font-size: 12px;
  font-weight: 600; cursor: pointer;
}
.btn-danger:hover { background: #f9d4d4; }
.btn-small {
  background: #fff4ea; color: var(--primary-dark); border: none;
  padding: 6px 12px; border-radius: 8px; font-size: 12px;
  font-weight: 600; cursor: pointer; margin-right: 4px;
}
.btn-small:hover { background: #ffe5cc; }

table.admin-table { width: 100%; border-collapse: collapse; }
table.admin-table th {
  text-align: left; padding: 10px 12px; font-size: 12px;
  color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px;
  border-bottom: 2px solid var(--line);
}
table.admin-table td {
  padding: 12px; border-bottom: 1px solid var(--line); font-size: 14px;
  vertical-align: middle;
}
table.admin-table tr:hover td { background: #fffaf3; }
.tbl-thumb {
  width: 44px; height: 44px; border-radius: 8px; overflow: hidden;
  background: #f5ede0;
}
.tbl-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.status-pill {
  display: inline-block; padding: 3px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 600;
}
.status-pill.active { background: #e8f7e8; color: #2c6e2c; }
.status-pill.hidden { background: #f0e4d6; color: #998f86; }

.reveal-toggle {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px; background: #fff4ea;
  border-radius: 12px; border-left: 4px solid var(--accent);
  margin-top: 12px;
}
.switch-info b { display: block; }
.switch {
  position: relative; width: 46px; height: 26px;
  background: #d9d3cc; border-radius: 999px; cursor: pointer;
  transition: background .2s; flex-shrink: 0;
}
.switch.on { background: var(--green); }
.switch::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 20px; height: 20px; background: white; border-radius: 50%;
  transition: left .2s; box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
.switch.on::after { left: 23px; }

.org-list { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.org-list .org-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 12px; background: #fffaf3; border-radius: 8px; font-size: 14px;
}
.add-row { display: flex; gap: 8px; margin-top: 12px; }
.add-row input {
  flex: 1; padding: 10px 12px; border: 1.5px solid var(--line);
  border-radius: 8px; font-size: 14px; background: #fffdf9;
}
.add-row input:focus { outline: none; border-color: var(--primary); }

.scroll-x { overflow-x: auto; }

/* toast */
#toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: white; padding: 12px 20px;
  border-radius: 10px; font-size: 14px; font-weight: 500;
  box-shadow: 0 6px 24px rgba(0,0,0,0.2);
  opacity: 0; pointer-events: none; transition: opacity .3s, transform .3s;
  z-index: 100; max-width: 90vw; text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(-6px); }
#toast.error { background: var(--red); }
#toast.success { background: var(--green); }

@media (max-width: 540px) {
  .brand h1 { font-size: 17px; }
  .brand-emoji { font-size: 26px; }
  .top-inner { gap: 8px; }
  main { padding: 16px 12px 40px; }
  .login-card { padding: 30px 22px; }
}
