:root {
  --red: #c8202a;
  --red-dark: #8e1219;
  --gold: #d9a91c;
  --ink: #141414;
  --muted: #6b6b6b;
  --line: #e4e0d8;
  --bg: #f6f4ef;
  --ok: #1f7a3a;
  --warn: #b26a00;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
}
button, input, select { font: inherit; }
.hidden { display: none !important; }

/* ---------- header ---------- */
.top {
  background: var(--ink);
  color: #fff;
  border-bottom: 4px solid var(--gold);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.top img { width: 52px; height: 52px; border-radius: 50%; background: #fff; }
.top .t1 { font-weight: 800; letter-spacing: .5px; text-transform: uppercase; }
.top .t2 { color: var(--gold); font-size: 13px; letter-spacing: 1px; text-transform: uppercase; }
.top .spacer { flex: 1; }

/* ---------- verify page ---------- */
.wrap { max-width: 460px; margin: 18px auto; padding: 0 14px 30px; }
.panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}
.banner {
  padding: 14px;
  text-align: center;
  color: #fff;
  font-weight: 800;
  letter-spacing: 2px;
  font-size: 20px;
}
.banner small { display: block; font-weight: 400; letter-spacing: 0; font-size: 13px; opacity: .9; }
.banner.active { background: var(--ok); }
.banner.suspended { background: var(--warn); }
.banner.expired, .banner.invalid { background: var(--red-dark); }
.profile { padding: 18px; text-align: center; }
.photo {
  width: 150px; height: 188px; object-fit: cover;
  border-radius: 8px; border: 3px solid var(--gold); background: #eee;
}
.name { font-size: 22px; font-weight: 800; margin: 10px 0 2px; }
.rank { color: var(--red); font-weight: 700; text-transform: uppercase; letter-spacing: 1px; font-size: 14px; }
.fields { margin: 0; padding: 0 18px 8px; }
.fields div {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 10px 0; border-top: 1px solid var(--line);
}
.fields dt { color: var(--muted); font-size: 14px; }
.fields dd { margin: 0; font-weight: 600; text-align: right; }
.fields a { color: var(--red); }
.foot { color: var(--muted); font-size: 12px; text-align: center; padding: 12px 18px 16px; }
.msg { padding: 30px 18px; text-align: center; color: var(--muted); }

/* ---------- admin ---------- */
.container { max-width: 1050px; margin: 20px auto; padding: 0 16px 40px; }
.card-box {
  background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 18px; margin-bottom: 16px;
}
.login { max-width: 360px; margin: 50px auto; }
label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=search], select {
  width: 100%; padding: 9px 10px; border: 1px solid #cfcac0; border-radius: 8px; background: #fff;
}
.btn {
  text-decoration: none; display: inline-block;
  border: 0; border-radius: 8px; padding: 9px 14px; cursor: pointer;
  background: var(--red); color: #fff; font-weight: 600;
}
.btn:hover { background: var(--red-dark); }
.btn.ghost { background: #fff; color: var(--ink); border: 1px solid #cfcac0; }
.btn.ghost:hover { background: #f1eee8; }
.btn.small { padding: 5px 9px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar input { max-width: 280px; }
.error { color: var(--red); font-size: 14px; min-height: 18px; margin-top: 8px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; }
td img { width: 36px; height: 45px; object-fit: cover; border-radius: 4px; background: #eee; }
.pill { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 99px; color: #fff; }
.pill.active { background: var(--ok); }
.pill.suspended { background: var(--warn); }
.pill.expired { background: var(--red-dark); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
@media (max-width: 640px) { .grid2 { grid-template-columns: 1fr; } .hide-sm { display: none; } }
.photo-edit { display: flex; gap: 14px; align-items: center; margin-top: 10px; }
.photo-edit img { width: 90px; height: 112px; object-fit: cover; border-radius: 6px; background: #eee; border: 2px solid var(--gold); }
.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: flex; align-items: flex-start; justify-content: center; overflow: auto; padding: 30px 12px; z-index: 10;
}
.overlay .card-box { width: 100%; max-width: 620px; }
.tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.tab {
  border: 1px solid #cfcac0; background: #fff; border-radius: 8px;
  padding: 8px 16px; cursor: pointer; font-weight: 600;
}
.tab.on { background: var(--ink); color: var(--gold); border-color: var(--ink); }
.notice {
  background: #eef7f0; border: 1px solid #b9dcc3; color: #174d27;
  border-radius: 8px; padding: 10px 12px; margin-top: 8px; font-size: 14px;
}
.notice code { background: #fff; padding: 1px 6px; border-radius: 4px; font-size: 15px; }
.linkline { font-size: 12px; color: var(--muted); word-break: break-all; margin-top: 10px; }

/* ---------- printable ID card, Classic QR (CR80: 85.6 x 54 mm) ---------- */
.id-card {
  width: 85.6mm; height: 54mm;
  border-radius: 3mm;
  overflow: hidden;
  position: relative;
  background: #fff;
  border: 0.2mm solid #bbb;
  display: flex;
  font-family: "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--ink);
  -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
.id-card .left { flex: 1; padding: 4mm 2mm 0 4mm; display: flex; flex-direction: column; }
.id-card .crest-row { display: flex; gap: 2.2mm; align-items: center; }
.id-card .crest-row img { width: 15mm; height: 15mm; }
.id-card .sch { font-size: 3.5mm; font-weight: 800; line-height: 1.05; text-transform: uppercase; }
.id-card .unit { font-size: 2.6mm; font-weight: 700; color: var(--red); letter-spacing: .3mm; text-transform: uppercase; margin-top: .5mm; }
.id-card .tag {
  margin-top: 2.4mm; align-self: flex-start;
  background: var(--ink); color: var(--gold);
  font-size: 2.1mm; font-weight: 800; letter-spacing: .45mm;
  padding: .7mm 1.8mm; border-radius: 1mm;
}
.id-card .det { font-size: 1.9mm; color: #444; line-height: 1.35; margin-top: 2mm; }
.id-card .motto { font-size: 1.85mm; font-style: italic; color: var(--red-dark); margin-top: auto; margin-bottom: 4mm; line-height: 1.3; }
.id-card .right {
  width: 29mm; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding-bottom: 3mm; border-left: .3mm dashed #ddd;
}
.id-card .qr { width: 23mm; height: 23mm; }
.id-card .qr svg { display: block; width: 100%; height: 100%; }
.id-card .scan { font-size: 1.9mm; font-weight: 800; letter-spacing: .3mm; margin-top: 1.2mm; }
.id-card .code { font-size: 2mm; font-family: Consolas, monospace; font-weight: 700; letter-spacing: .4mm; margin-top: .4mm; color: #333; }
.id-card .stripe {
  position: absolute; left: 0; right: 0; bottom: 0; height: 2.6mm;
  background: linear-gradient(90deg, var(--red) 0 60%, var(--gold) 60% 80%, var(--ink) 80%);
}

/* ---------- scanner page ---------- */
.viewer { position: relative; background: #000; }
.viewer video { display: block; width: 100%; max-height: 60vh; object-fit: cover; }
.viewer .aim {
  position: absolute; left: 6%; right: 6%; top: 30%; bottom: 30%;
  border: 3px solid var(--gold); border-radius: 8px;
  box-shadow: 0 0 0 9999px rgba(0,0,0,.35);
}
.scan-help { padding: 14px 18px; color: var(--muted); font-size: 14px; text-align: center; }
.manual { display: flex; gap: 8px; padding: 0 18px 18px; }
.manual input::placeholder { text-transform: none; letter-spacing: 0; }
.manual input { text-transform: uppercase; letter-spacing: 2px; font-family: Consolas, monospace; }
.navlink { display: block; text-align: center; margin-top: 14px; color: var(--red); font-weight: 600; }

#printArea { display: none; }
@media print {
  @page { size: A4; margin: 10mm; }
  body { background: #fff; }
  body.printing > *:not(#printArea) { display: none !important; }
  body.printing #printArea {
    display: grid !important;
    grid-template-columns: repeat(2, 85.6mm);
    gap: 4mm 6mm;
    justify-content: center;
  }
  .id-card { break-inside: avoid; }
}

/* ---------- home page ---------- */
.home { padding: 26px 20px; text-align: center; }
.home-crest { width: 130px; height: 130px; }
.home h1 { font-size: 20px; margin: 12px 0 20px; }
.btn.big { display: block; padding: 14px; font-size: 17px; margin-top: 10px; text-align: center; }

/* ---------- menu ---------- */
.menu-btn {
  margin-left: auto; flex: none;
  width: 44px; height: 44px; border-radius: 10px;
  border: 1px solid rgba(255,255,255,.25); background: transparent; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
}
.menu-btn span { display: block; width: 20px; height: 2px; background: #fff; border-radius: 2px; transition: .2s; }
.menu-btn.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.menu-btn.open span:nth-child(2) { opacity: 0; }
.menu-btn.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
.menu {
  position: fixed; top: 70px; right: 12px; z-index: 20;
  width: min(260px, calc(100vw - 24px));
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,.18); padding: 6px; 
}
.menu a, .menu button {
  display: block; width: 100%; text-align: left; padding: 11px 12px; border-radius: 8px;
  color: var(--ink); text-decoration: none; font-weight: 600; background: none; border: 0; cursor: pointer;
}
.menu a:hover, .menu button:hover { background: #f1eee8; }
.menu a.current { color: var(--red); }
.menu .danger { color: var(--red); }
.menu-extra:not(:empty) { border-top: 1px solid var(--line); margin-top: 4px; padding-top: 4px; }
.menu-who { font-size: 12px; color: var(--muted); padding: 8px 12px 6px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.table-wrap { overflow-x: auto; }
.actions { white-space: nowrap; }
.with-btn { display: flex; gap: 6px; align-items: center; }
.with-btn input { flex: 1; min-width: 0; }
.with-btn .btn { flex: none; }

/* ---------- phones ---------- */
@media (max-width: 640px) {
  .top { padding: 10px 12px; gap: 10px; }
  .top img { width: 42px; height: 42px; }
  .top .t1 { font-size: 14px; }
  .top .t2 { font-size: 11px; }
  .menu { top: 62px; }
  .container { padding: 0 10px 30px; margin-top: 12px; }
  .card-box { padding: 14px; }
  .toolbar input { max-width: none; flex: 1 1 100%; order: 3; }
  th, td { padding: 8px 6px; }
  .overlay { padding: 10px 8px; }
  .actions .btn { display: block; width: 100%; margin: 3px 0 !important; text-align: center; }
}
