@import url("https://fonts.googleapis.com/css2?family=Be+Vietnam+Pro:wght@400;500;600;700;800&family=Barlow+Condensed:wght@600;700;800&display=swap");

:root {
  --navy: #0d2f5e;
  --navy-dark: #081d3d;
  --gold: #e8a33d;
  --gold-light: #fbe3b8;
  --bg: #f2f4f8;
  --paper: #ffffff;
  --ink: #182338;
  --ink-soft: #5b6779;
  --line: #dfe4ec;
  --ok: #1f8a52;
  --warn: #c0392b;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Be Vietnam Pro", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

h1, h2, h3 { font-family: "Be Vietnam Pro", sans-serif; margin: 0; }

.numeric { font-family: "Barlow Condensed", sans-serif; font-weight: 800; letter-spacing: 1px; }

/* ---------- Thanh trên cùng dùng chung ---------- */
.topbar {
  background: linear-gradient(120deg, var(--navy-dark), var(--navy));
  color: #fff;
  padding: 18px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 10px rgba(0,0,0,.15);
}
.topbar .title { font-weight: 800; font-size: 1.25rem; letter-spacing: .5px; }
.topbar .title small { display:block; font-weight:500; font-size:.7rem; opacity:.75; letter-spacing:2px; }
.topbar .actions { display: flex; gap: 10px; align-items: center; }
.topbar .who { font-size:.85rem; opacity:.85; }

/* ---------- Nút bấm ---------- */
.btn {
  border: none;
  border-radius: 10px;
  padding: 12px 20px;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease, opacity .12s;
  font-family: inherit;
}
.btn:active { transform: translateY(1px) scale(.98); }
.btn-primary { background: var(--gold); color: var(--navy-dark); }
.btn-primary:hover { box-shadow: 0 4px 14px rgba(232,163,61,.5); }
.btn-outline { background: transparent; border: 1px solid rgba(255,255,255,.5); color: #fff; }
.btn-outline:hover { background: rgba(255,255,255,.12); }
.btn-danger { background: var(--warn); color: #fff; }
.btn-ghost { background: var(--line); color: var(--ink); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-lg { padding: 18px 26px; font-size: 1.1rem; border-radius: 14px; }
.btn-block { width: 100%; }

/* ---------- Form / thẻ ---------- */
.card {
  background: var(--paper);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  padding: 24px;
  box-shadow: 0 1px 3px rgba(20,30,50,.05);
}
.field { margin-bottom: 16px; }
.field label { display:block; font-weight:600; font-size:.85rem; margin-bottom:6px; color: var(--ink-soft); }
.field input, .field select {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  font-size: 1rem;
  font-family: inherit;
  background: #fbfcfe;
}
.field input:focus, .field select:focus { outline: 2px solid var(--gold); border-color: var(--gold); }

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at top, var(--navy), var(--navy-dark));
  padding: 20px;
}
.login-card { width: 100%; max-width: 380px; }
.login-card .brand { text-align:center; color:#fff; margin-bottom: 22px; }
.login-card .brand .badge {
  width: 56px; height:56px; border-radius: 50%; background: var(--gold);
  display:flex; align-items:center; justify-content:center; margin: 0 auto 12px;
  font-weight:800; color: var(--navy-dark); font-size:1.7rem;
}
.login-card .brand .org-name {
  font-family: "Times New Roman", Times, serif;
  font-weight:700; letter-spacing: .5px; font-size:1.1rem; color: #d32f2f;
  margin-bottom: 8px; text-transform: uppercase; line-height:1.3;
}
.login-card .brand h1 { font-size: 1.05rem; line-height:1.4; }

/* ---------- Toast ---------- */
.htxh-toast {
  position: fixed; left: 50%; bottom: 30px; transform: translate(-50%, 20px);
  background: var(--navy-dark); color:#fff; padding: 12px 22px; border-radius: 10px;
  opacity: 0; pointer-events: none; transition: all .25s ease; z-index: 999;
  font-weight: 600; box-shadow: 0 6px 20px rgba(0,0,0,.25);
}
.htxh-toast.show { opacity: 1; transform: translate(-50%, 0); }
.htxh-toast.error { background: var(--warn); }

/* ---------- Trang hiển thị (TV) ---------- */
html, body { height: 100%; }
.hienthi-wrap { height: 100vh; height: 100dvh; display:flex; flex-direction:column; background: var(--navy-dark); overflow:hidden; }
.hienthi-header {
  text-align:center; padding: 2vh 10px 1.5vh; color:#fff; flex-shrink:0;
  background: linear-gradient(180deg, var(--navy), var(--navy-dark));
  border-bottom: 3px solid var(--gold);
}
.hienthi-header h1 { font-size: clamp(1.8rem, 3.6vw, 3.2rem); letter-spacing: 1px; }
.hienthi-grid {
  flex: 1; display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(2, 1fr);
  gap: 1.6vh 1.4vw; padding: 1.8vh 1.4vw; min-height: 0;
}
.counter-box {
  background: var(--paper); border-radius: 18px; padding: 1.6vh 1vw;
  display:flex; flex-direction:column; align-items:center; justify-content:space-between;
  text-align:center;
  border: 2px solid var(--line); position: relative; overflow:hidden;
}
.counter-box.flash { animation: flash 1.2s ease; }
@keyframes flash { 0%,100% { box-shadow:none; } 30% { box-shadow: 0 0 0 8px var(--gold-light); } }
.counter-box .cb-name {
  font-weight: 800; color: var(--navy); text-transform: uppercase;
  font-size: clamp(1.6rem, 3.4vw, 2.6rem); letter-spacing: .5px;
}
.counter-box .cb-field {
  color: var(--ink-soft); font-weight:600;
  font-size: clamp(1rem, 1.9vw, 1.45rem); line-height:1.3; margin-top: .6vh;
}
.counter-box .cb-number {
  font-size: clamp(4.2rem, 9vw, 7.5rem);
  color: var(--navy-dark); text-align:center; line-height:1;
  margin-top: auto;
}
.hienthi-marquee {
  background: var(--gold); color: var(--navy-dark); font-weight: 700; flex-shrink:0;
  padding: 1.2vh 0; overflow: hidden; white-space: nowrap;
  font-size: clamp(1rem, 1.6vw, 1.3rem);
}
.hienthi-marquee span { display: inline-block; padding-left: 100%; animation: marquee 22s linear infinite; }
@keyframes marquee { from { transform: translateX(0); } to { transform: translateX(-100%); } }

/* ---------- Trang Kiosk (tự co giãn lấp đầy màn hình, tối ưu cho màn hình dọc) ---------- */
html, body { height: 100%; }
.kiosk-wrap {
  height: 100vh; height: 100dvh;
  background: linear-gradient(180deg, var(--navy), var(--navy-dark));
  display:flex; flex-direction:column;
  padding: 2.5vh 2.5vw;
  box-sizing: border-box;
  overflow: hidden;
}
.kiosk-title { color:#fff; text-align:center; font-size: clamp(1.1rem, 3.4vh, 2.1rem); line-height:1.25; flex-shrink:0; }
.kiosk-sub { color: var(--gold-light); text-align:center; margin-top: .6vh; font-size: clamp(.85rem, 1.9vh, 1.15rem); flex-shrink:0; }

/* Mặc định (màn hình dọc / hẹp): xếp thành danh sách dọc, mỗi quầy chia đều chiều cao còn lại */
.kiosk-grid {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1.6vh;
  margin-top: 2vh;
  min-height: 0;
}
.kiosk-btn {
  flex: 1;
  min-height: 0;
  background: var(--paper); border-radius: 16px; border: none;
  display:flex; flex-direction:column; align-items:center; justify-content:center;
  text-align:center; cursor:pointer; box-shadow: 0 6px 18px rgba(0,0,0,.2);
  transition: transform .12s;
  padding: 1vh 3vw;
}
.kiosk-btn:active { transform: scale(.97); }
.kiosk-btn .kb-name {
  font-weight:800; color: var(--navy-dark);
  font-size: clamp(1.1rem, 3.4vh, 2rem);
  text-transform: uppercase; letter-spacing: .5px;
}
.kiosk-btn .kb-field {
  color: var(--ink-soft); font-weight:600;
  font-size: clamp(.9rem, 2.1vh, 1.3rem);
  margin-top: .8vh; line-height:1.3;
}

/* Màn hình ngang / rộng (ví dụ máy tính bàn): chuyển sang lưới 2 cột cho gọn */
@media (min-aspect-ratio: 1/1) and (min-width: 720px) {
  .kiosk-wrap { align-items:center; }
  .kiosk-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-auto-rows: 1fr;
    width:100%; max-width: 900px;
    margin: 2vh auto 0;
  }
}
/* Phiếu in 58mm */
#printArea { display:none; }
@media print {
  body * { visibility: hidden; }
  #printArea, #printArea * { visibility: visible; }
  #printArea { position: fixed; top:0; left:0; display:block; }
  @page { size: 58mm auto; margin: 2mm; }
}
.ticket-slip { width: 54mm; font-family: "Be Vietnam Pro", sans-serif; text-align:center; }
.ticket-slip h3 { font-size: 11px; line-height:1.3; }
.ticket-slip .big { font-size: 34px; font-weight: 800; margin: 6px 0; }
.ticket-slip .row { font-size: 11px; margin: 2px 0; }
.ticket-slip hr { border: none; border-top: 1px dashed #000; margin: 6px 0; }

/* ---------- Trang quầy cán bộ ---------- */
.quay-wrap { max-width: 640px; margin: 24px auto; padding: 0 16px 60px; }
.quay-current { text-align:center; padding: 30px 16px; }
.quay-current .label { color: var(--ink-soft); font-weight:600; }
.quay-current .number { font-size: 5rem; color: var(--navy); line-height:1; margin: 10px 0; }
.quay-actions { display:grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 18px; }
.quay-info { margin-top: 10px; font-size:.95rem; color: var(--ink-soft); }
.waiting-list { margin-top: 22px; }
.waiting-item { display:flex; justify-content:space-between; padding: 10px 14px; border-bottom:1px solid var(--line); }
.pill { display:inline-block; padding: 2px 10px; border-radius: 20px; font-size:.75rem; font-weight:700; }
.pill-kiosk { background:#e6f0ff; color:#1d4fa3; }
.pill-mobile { background:#eaf7ee; color: var(--ok); }

/* ---------- Trang admin ---------- */
.admin-wrap { max-width: 1080px; margin: 24px auto; padding: 0 16px 60px; }
.tabs { display:flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }
.tab-btn { background: var(--paper); border:1px solid var(--line); border-radius: 10px; padding: 10px 16px; cursor:pointer; font-weight:700; color: var(--ink-soft); }
.tab-btn.active { background: var(--navy); color:#fff; border-color: var(--navy); }
.tab-panel { display:none; }
.tab-panel.active { display:block; }
.grid-2 { display:grid; grid-template-columns: 1fr 1fr; gap: 16px; }
table { width:100%; border-collapse: collapse; margin-top: 12px; }
th, td { text-align:left; padding: 10px 12px; border-bottom:1px solid var(--line); font-size:.92rem; }
th { color: var(--ink-soft); font-size:.78rem; text-transform: uppercase; letter-spacing:.5px; }
.stat-row { display:flex; gap: 14px; flex-wrap: wrap; margin: 14px 0; }
.stat-card { flex:1; min-width: 140px; background: var(--paper); border:1px solid var(--line); border-radius: 12px; padding: 16px; }
.stat-card .num { font-size: 1.8rem; font-weight:800; color: var(--navy); }
.stat-card .lbl { font-size:.8rem; color: var(--ink-soft); font-weight:600; }
.list-row { display:flex; align-items:center; justify-content:space-between; padding: 10px 0; border-bottom: 1px solid var(--line); }
.small-note { font-size: .8rem; color: var(--ink-soft); margin-top: 6px; }

/* ---------- Trang mobile (dân) ---------- */
.mobile-wrap { min-height: 100vh; background: var(--bg); display:flex; align-items:flex-start; justify-content:center; padding: 30px 16px; }
.mobile-card { width:100%; max-width: 420px; }
.mobile-result { text-align:center; }
.mobile-result .number { font-size: 4rem; color: var(--navy); margin: 10px 0; }

@media (max-width: 720px) {
  .hienthi-grid { grid-template-columns: 1fr; grid-template-rows: repeat(6,1fr); }
  .quay-actions { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
}
