:root {
  --bg: #fff6f1;
  --surface: #ffffff;
  --text: #2a1210;
  --muted: #8a4f42;
  --line: #f0d0c2;
  --primary: #c02026;
  --accent: #f26522;
  --accent-soft: #ffe8d8;
  --gold: #ffc20e;
  --warn: #c2410c;
  --danger: #b91c1c;
  --ok: #166534;
  --shadow: 0 8px 24px rgba(192, 32, 38, 0.08);
  --radius: 14px;
  --sidebar: 250px;
  --font: "Be Vietnam Pro", "Segoe UI", sans-serif;
  --fire-1: #c02026;
  --fire-2: #f26522;
  --fire-3: #ffc20e;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background:
    radial-gradient(ellipse at 0% 0%, rgba(255, 194, 14, 0.22), transparent 42%),
    radial-gradient(ellipse at 100% 10%, rgba(242, 101, 34, 0.16), transparent 45%),
    radial-gradient(ellipse at 50% 100%, rgba(192, 32, 38, 0.10), transparent 50%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar);
  background: linear-gradient(180deg, #9e151a 0%, #c02026 40%, #d94720 100%);
  color: #fff;
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  flex-shrink: 0;
  box-shadow: 4px 0 24px rgba(192, 32, 38, 0.2);
}
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px 18px;
  border-bottom: 1px solid rgba(255,255,255,.18);
  margin-bottom: 14px;
}
.brand strong { font-size: 17px; letter-spacing: .2px; display: block; }
.brand span { font-size: 11px; opacity: .8; display: block; line-height: 1.3; }
.brand-logo {
  width: 48px; height: 48px; object-fit: contain;
  background: #fff; border-radius: 12px; padding: 4px;
  flex-shrink: 0;
}
.brand-logo--lg { width: 96px; height: 96px; border-radius: 18px; padding: 6px; display: block; }
.brand-logo--tv { width: 72px; height: 72px; border-radius: 16px; }

.nav a {
  display: flex; align-items: center; gap: 10px;
  color: rgba(255,255,255,.86);
  padding: 10px 12px;
  border-radius: 10px;
  margin-bottom: 4px;
  text-decoration: none;
  font-size: 14px;
}
.nav a:hover, .nav a.active {
  background: rgba(255,255,255,.12);
  color: #fff;
  text-decoration: none;
}
.nav .nav-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: .08em;
  opacity: .55; padding: 12px 12px 6px; font-weight: 600;
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 14px 22px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 18px; margin: 0; font-weight: 700; }
.user-chip {
  display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted);
}
.user-chip b { color: var(--text); }
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--accent-soft); color: var(--accent);
}
.badge.danger { background: #fee2e2; color: var(--danger); }
.badge.warn { background: #ffedd5; color: var(--warn); }
.badge.ok { background: #dcfce7; color: var(--ok); }
.badge.muted { background: #eef2f6; color: var(--muted); }

.content { padding: 22px; }

.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.card-header h2, .card-header h3 { margin: 0; font-size: 15px; }
.card-body { padding: 16px; }

.stat {
  padding: 16px;
}
.stat .label { color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.stat .value { font-size: 24px; font-weight: 700; color: var(--primary); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid transparent; border-radius: 10px;
  padding: 9px 14px; font-size: 13px; font-weight: 600; cursor: pointer;
  font-family: inherit; text-decoration: none; background: var(--line); color: var(--text);
}
.btn:hover { text-decoration: none; filter: brightness(.98); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-dark { background: var(--primary); color: #fff; }
.btn-outline { background: #fff; border-color: var(--line); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn-block { width: 100%; }

.form-row { display: grid; gap: 12px; margin-bottom: 12px; }
.form-row.cols-2 { grid-template-columns: 1fr 1fr; }
.form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-row.cols-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
input, select, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; font: inherit; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(242,101,34,.18);
}
textarea { min-height: 90px; resize: vertical; }

.table-wrap { overflow: auto; }
table.data {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
table.data th, table.data td {
  padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top;
}
table.data th {
  font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); background: #fff8f4; position: sticky; top: 0;
}
table.data tr:hover td { background: #fff5ef; }

.alert {
  padding: 12px 14px; border-radius: 10px; margin-bottom: 14px; font-size: 14px;
  border: 1px solid var(--line); background: #fff;
}
.alert-success { background: #ecfdf5; border-color: #a7f3d0; color: var(--ok); }
.alert-error { background: #fef2f2; border-color: #fecaca; color: var(--danger); }
.alert-info { background: var(--accent-soft); border-color: #fdba8c; color: var(--primary); }

.login-page {
  min-height: 100vh; display: grid; place-items: center;
  background:
    radial-gradient(circle at 12% 18%, rgba(255,194,14,.35), transparent 38%),
    radial-gradient(circle at 88% 12%, rgba(242,101,34,.28), transparent 40%),
    radial-gradient(circle at 50% 100%, rgba(192,32,38,.22), transparent 45%),
    linear-gradient(160deg, #fff3ea, #ffe0cc 55%, #ffd2b8);
  padding: 20px;
}
.login-card {
  width: min(420px, 100%);
  background: #fff; border: 1px solid var(--line); border-radius: 18px;
  padding: 28px; box-shadow: var(--shadow);
}
.login-brand { text-align: center; margin-bottom: 10px; }
.login-card h1 { margin: 10px 0 4px; font-size: 24px; color: var(--primary); }
.login-tagline {
  margin: 0 0 10px !important;
  color: var(--accent) !important;
  font-size: 11px !important;
  font-weight: 700;
  letter-spacing: .06em;
}
.login-card p { margin: 0 0 18px; color: var(--muted); font-size: 14px; }

.scan-hero {
  background: linear-gradient(135deg, #c02026, #f26522 60%, #ff9f1c);
  color: #fff; border-radius: var(--radius); padding: 18px;
  margin-bottom: 14px;
  box-shadow: 0 10px 24px rgba(192,32,38,.22);
}
.scan-hero h2 { margin: 0 0 6px; font-size: 18px; }
.scan-hero p { margin: 0; opacity: .92; font-size: 13px; }

.btn-lg { padding: 14px 18px; font-size: 15px; border-radius: 12px; }
.scan-input {
  font-size: 18px !important; letter-spacing: 1px; font-weight: 700;
}
.scan-actions {
  display: flex; flex-wrap: wrap; gap: 10px;
}
.scan-actions .btn { flex: 1; min-width: 180px; }
.camera-box {
  border-radius: 14px; overflow: hidden; background: #0b1220;
  min-height: 240px; border: 1px solid var(--line);
  width: 100%;
}
.camera-box video,
.login-camera-overlay__view video {
  width: 100% !important;
  max-width: 100% !important;
  height: auto !important;
  min-height: 220px;
  object-fit: cover;
  display: block !important;
  background: #000;
}
.login-camera-overlay {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 9999;
  background: #0b1220;
  color: #fff;
  padding: 0 0 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,.35);
  max-height: 85vh;
  overflow: auto;
}
.login-camera-overlay[hidden] { display: none !important; }
.login-camera-overlay__bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 12px 14px;
  background: linear-gradient(90deg, #c02026, #f26522);
}
.login-camera-overlay__view {
  width: 100%;
  min-height: 280px;
  background: #000;
}
.login-camera-overlay__view img {
  display: none !important; /* tránh qrbox che video trên một số máy */
}
.login-camera-overlay__hint {
  margin: 0 12px; font-size: 13px; opacity: .9; line-height: 1.4;
}
.login-camera-panel {
  position: sticky;
  top: 0;
  z-index: 30;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  margin: 0 0 16px;
}
.scan-ways { display: grid; gap: 10px; }
.scan-way {
  background: #f8fafc; border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 14px;
}
.scan-way b { display: block; margin-bottom: 4px; font-size: 13px; }
.scan-way p { margin: 0; font-size: 13px; }
@media (max-width: 960px) {
  .scan-actions { flex-direction: column; }
  .scan-actions .btn { width: 100%; }
}
.result-flash {
  padding: 14px; border-radius: 12px; background: var(--accent-soft);
  border: 1px solid #fdba8c; margin-top: 12px; display: none;
}
.result-flash.show { display: block; }
.result-flash.error { background: #fef2f2; border-color: #fecaca; color: var(--danger); }

.pill-row { display: flex; flex-wrap: wrap; gap: 8px; }
.muted { color: var(--muted); }
.flex { display: flex; gap: 10px; align-items: center; }
.flex-between { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-0 { margin-bottom: 0; }
.text-right { text-align: right; }
.w-100 { width: 100%; }

.qr-box {
  display: grid; place-items: center; padding: 20px;
  background: #fff; border: 1px dashed var(--line); border-radius: 14px;
}

.student-avatar {
  width: 44px;
  height: 44px;
  display: block;
  flex: 0 0 auto;
  object-fit: cover;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--accent-soft);
  box-shadow: 0 2px 8px rgba(122,26,18,.16);
}
.student-avatar--sm { width: 34px; height: 34px; }
.student-avatar--lg { width: 58px; height: 58px; }
.student-avatar--xl { width: 112px; height: 112px; }
.student-profile-heading {
  display: flex;
  align-items: center;
  gap: 12px;
}
.student-profile-heading h2 { margin: 0; }
.student-avatar-editor {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff8f4;
}
.student-self-avatar {
  display: grid;
  grid-template-columns: minmax(130px, auto) minmax(180px, 1fr) auto;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff8f4;
}
.subject-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.subject-checkboxes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fffaf7;
}
.subject-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  font-weight: 500;
  cursor: pointer;
}
.subject-check input {
  width: auto;
  margin: 0;
}
.student-subject-row {
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}
.student-detail-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}
.document-description {
  max-width: 520px;
  margin-top: 6px;
  font-size: 12px;
  line-height: 1.5;
}
.document-file-meta {
  margin-top: 7px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
  word-break: break-word;
}
.multi-file {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.multi-file-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.multi-file-list__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffaf7;
  font-size: 13px;
}
.multi-file-existing {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.multi-file-existing__item {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-weight: 500;
}
.multi-file-existing__item input {
  width: auto;
  margin: 0;
}
.fees-quick-scroll {
  max-height: 70vh;
  overflow: auto;
}
.fees-quick-table th.fees-quick-sticky,
.fees-quick-table td.fees-quick-sticky {
  position: sticky;
  left: 0;
  background: #fff;
  z-index: 2;
  min-width: 140px;
  box-shadow: 2px 0 4px rgba(0,0,0,.04);
}
.fees-quick-col {
  min-width: 88px;
  text-align: center;
  font-size: 12px;
}
.fees-quick-cell {
  text-align: center;
}
.fee-tick {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  margin: 0;
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
}
.fee-tick input {
  width: 18px;
  height: 18px;
  margin: 0;
  cursor: pointer;
}
.fee-tick--paid .fee-tick-label {
  color: var(--ok);
}
.fee-tick--all .fee-tick-label {
  color: var(--accent);
}
.fees-quick-status {
  font-size: 12px;
  font-weight: 600;
}
.homework-previews {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 8px;
}
.homework-preview-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: #fffaf7;
}
.homework-preview-img {
  max-width: 100%;
  max-height: 480px;
  display: block;
  border-radius: 8px;
  object-fit: contain;
}
.homework-preview-pdf {
  width: 100%;
  min-height: 420px;
  border: 0;
  border-radius: 8px;
  background: #f3f3f3;
}

.lookup-card {
  max-width: 560px;
  margin: 24px auto;
  text-align: center;
}
.lookup-card__body {
  padding: 28px 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.lookup-card__body h2 { margin: 12px 0 8px; }
.lookup-card__body .muted { margin: 0 0 22px; }
.lookup-url-hint {
  margin-top: 18px !important;
  font-size: 11px;
  word-break: break-all;
  max-width: 100%;
  line-height: 1.5;
}
.lookup-app-btn {
  display: flex; align-items: center; gap: 16px; text-align: left;
  padding: 18px 20px; border-radius: 16px;
  background: linear-gradient(135deg, #c02026, #f26522);
  color: #fff !important; text-decoration: none !important;
  box-shadow: 0 12px 28px rgba(192,32,38,.28);
  transition: transform .2s ease, box-shadow .2s ease;
  width: 100%;
  max-width: 420px;
  cursor: pointer;
  border: 0;
}
.lookup-app-btn:hover { transform: translateY(-2px); box-shadow: 0 16px 32px rgba(192,32,38,.35); text-decoration: none !important; }
.lookup-app-btn__icon {
  width: 64px; height: 64px; border-radius: 16px;
  background: rgba(255,255,255,.18); display: grid; place-items: center;
  color: #fff; flex-shrink: 0;
}
.lookup-app-btn__text { display: flex; flex-direction: column; gap: 4px; }
.lookup-app-btn__text b { font-size: 16px; }
.lookup-app-btn__text small { opacity: .85; font-size: 12px; }

.dialog-open { overflow: hidden !important; }
.lookup-dialog {
  position: fixed;
  inset: 0;
  z-index: 12000;
  display: grid;
  place-items: center;
  padding: 2vh 2vw;
}
.lookup-dialog[hidden] { display: none !important; }
.lookup-dialog__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(32, 6, 7, .72);
  backdrop-filter: blur(4px);
}
.lookup-dialog__window {
  position: relative;
  z-index: 1;
  width: min(1500px, 96vw);
  height: 94vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #fff;
  border: 1px solid rgba(255,255,255,.35);
  border-radius: 18px;
  box-shadow: 0 24px 80px rgba(0,0,0,.45);
}
.lookup-dialog__header {
  min-height: 62px;
  padding: 10px 14px 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #fff;
  background: linear-gradient(90deg, var(--primary), var(--accent));
}
.lookup-dialog__header h2 { margin: 0; font-size: 19px; }
.lookup-dialog__tools {
  display: flex;
  align-items: center;
  gap: 10px;
}
.lookup-dialog__close {
  width: 42px;
  height: 42px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255,255,255,.55);
  border-radius: 50%;
  background: rgba(0,0,0,.18);
  color: #fff;
  font: 700 30px/1 Arial, sans-serif;
  cursor: pointer;
}
.lookup-dialog__close:hover { background: rgba(0,0,0,.35); }
.lookup-dialog__body { flex: 1; min-height: 0; background: #fff; }
.lookup-dialog__body iframe {
  width: 100%;
  height: 100%;
  display: block;
  border: 0;
  background: #fff;
}

.tv-gift-body {
  min-height: 100vh;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 20% 20%, rgba(255,194,14,.35), transparent 40%),
    radial-gradient(circle at 80% 0%, rgba(242,101,34,.3), transparent 42%),
    linear-gradient(160deg, #2a0a0c, #5c1014 40%, #a31c20);
  color: #fff;
}
.tv-gift {
  width: min(920px, 100%);
  margin: 0 auto;
  padding: 28px 20px 40px;
  text-align: center;
}
.tv-gift__header {
  display: flex; align-items: center; justify-content: center; gap: 16px;
  margin-bottom: 28px; text-align: left;
}
.tv-gift__header h1 { margin: 0; font-size: 34px; font-weight: 800; }
.tv-gift__header p {
  margin: 4px 0 0; letter-spacing: .08em; font-size: 12px;
  color: var(--gold); font-weight: 700;
}
.tv-gift__panel {
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 22px; padding: 36px 28px;
  backdrop-filter: blur(6px);
}
.tv-gift__panel--center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 280px;
}
.tv-gift__hint { font-size: 20px; margin: 0 0 28px; opacity: .92; max-width: 640px; }
.tv-gift__cta {
  font-size: 22px !important; padding: 18px 48px !important;
  min-width: 280px; border-radius: 16px !important;
  margin: 0 auto;
}
.tv-gift__status {
  font-size: 22px; font-weight: 700; margin-bottom: 14px;
  color: var(--gold);
}
.tv-gift__gift {
  background: #fff; color: var(--text); border-radius: 16px;
  padding: 18px 20px; margin: 0 auto 16px;
  width: min(520px, 100%);
  text-align: center;
}
.tv-gift__gift h2 { margin: 0 0 6px; color: var(--primary); font-size: 28px; }
.tv-gift__cam {
  min-height: 320px; border: 0;
  width: min(640px, 100%);
  margin: 0 auto;
}
.tv-gift__actions { margin-top: 18px; display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; }
.tv-gift .result-flash {
  width: min(640px, 100%);
  margin-left: auto;
  margin-right: auto;
  background: #fff7e6;
  border: 2px solid #ffc20e;
  color: #7a1a12;
  font-weight: 700;
  font-size: 18px;
  text-align: center;
  box-shadow: 0 8px 20px rgba(0,0,0,.25);
}
.tv-gift .result-flash.error {
  background: #fff1f1;
  border-color: #f87171;
  color: #991b1b;
}
/* Ô nhận mã máy quét: giữ focus nhưng không hiển thị mã lên màn hình */
.tv-gift__hidden-input {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  border: 0 !important;
  opacity: 0 !important;
  pointer-events: none;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  color: transparent !important;
  background: transparent !important;
  caret-color: transparent !important;
}

@media (max-width: 960px) {
  .app { flex-direction: column; }
  .sidebar {
    width: 100%; height: auto; position: relative;
    display: flex; flex-wrap: wrap; gap: 4px; align-items: center;
  }
  .brand { width: 100%; border: 0; margin: 0; padding-bottom: 8px; }
  .nav { display: flex; flex-wrap: wrap; gap: 4px; width: 100%; }
  .nav .nav-label { display: none; }
  .nav a { margin: 0; padding: 8px 10px; font-size: 12px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .form-row.cols-2, .form-row.cols-3, .form-row.cols-4 { grid-template-columns: 1fr; }
  .content { padding: 14px; }
  .student-avatar-editor { align-items: flex-start; flex-direction: column; }
  .student-self-avatar { grid-template-columns: 1fr; }
  .lookup-dialog { padding: 0; }
  .lookup-dialog__window {
    width: 100vw;
    height: 100vh;
    border-radius: 0;
  }
  .lookup-dialog__header { min-height: 56px; padding-left: 14px; }
  .lookup-dialog__tools .btn { display: none; }
  .tv-gift__header { flex-direction: column; text-align: center; }
  .tv-gift__header h1 { font-size: 24px; }
}
