/* =========================================================
   GIAO DIỆN TRANG
   ========================================================= */
:root {
  --teal: #1f8a80;
  --teal-d: #136a62;
  --ink: #18272a;
  --muted: #6b7b7d;
  --line: #dfe8e7;
  --bg: #f3f7f6;
  --radius: 14px;
  --sans: 'Be Vietnam Pro', system-ui, sans-serif;
  --serif: 'Noto Serif', Georgia, serif;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: var(--sans); color: var(--ink); background: var(--bg); }
a { color: var(--teal-d); }

.topnav {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px clamp(16px, 4vw, 40px); background: #fff; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.topnav .brand { font-weight: 700; text-decoration: none; color: var(--ink); font-size: 17px; }
.topnav .links { display: flex; gap: 4px; }
.topnav .links a { text-decoration: none; color: var(--muted); padding: 8px 14px; border-radius: 999px; font-weight: 500; font-size: 14px; }
.topnav .links a.on, .topnav .links a:hover { background: #e4f2f0; color: var(--teal-d); }

.wrap { max-width: 1240px; margin: 0 auto; padding: 28px clamp(16px, 4vw, 40px) 60px; }
.page-title { font-size: clamp(22px, 3vw, 30px); margin: 0 0 6px; }
.lead { color: var(--muted); margin: 0 0 22px; max-width: 680px; line-height: 1.55; }
.section-title { margin: 34px 0 14px; }
.hint { color: var(--muted); font-size: 13px; text-align: center; }
.muted { color: var(--muted); }
.center { text-align: center; }

.panel { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }

.create-grid { display: grid; grid-template-columns: minmax(300px, 400px) 1fr; gap: 28px; align-items: start; }
.preview-sticky { position: sticky; top: 84px; display: grid; gap: 12px; justify-items: center; }
@media (max-width: 900px) {
  .create-grid { grid-template-columns: 1fr; }
  .preview-col { order: -1; }
  .preview-sticky { position: static; }
}

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.fld { display: grid; gap: 6px; }
.fld.full, .full { grid-column: 1 / -1; }
.fld > span { font-size: 13px; font-weight: 600; color: #3b4b4d; }
.fld small { font-weight: 400; color: var(--muted); }
input, select {
  width: 100%; font: inherit; font-size: 15px; padding: 10px 12px; border: 1px solid #cfdcda;
  border-radius: 10px; background: #fff; color: var(--ink);
}
input:focus, select:focus { outline: 2px solid #9fd6cf; border-color: var(--teal); }
input[type=file] { padding: 8px; background: #f7faf9; }
.check { display: flex; gap: 8px; align-items: center; font-size: 14px; }
.check input { width: auto; }

fieldset { border: 0; padding: 0; margin: 0 0 22px; }
legend { font-weight: 700; color: var(--teal-d); margin-bottom: 10px; font-size: 15px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 600; font-size: 14px; padding: 11px 18px; border-radius: 10px;
  border: 1px solid #cfdcda; background: #fff; color: var(--ink); cursor: pointer; text-decoration: none;
}
.btn:hover { border-color: var(--teal); }
.btn.primary { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn.primary:hover { background: var(--teal-d); }
.btn.ghost { background: transparent; }
.btn.danger { color: #b42318; border-color: #f1c4bf; }
.btn.small { padding: 7px 12px; font-size: 13px; }
.btn:disabled { opacity: .6; cursor: wait; }

.alert { padding: 14px 16px; border-radius: 12px; margin-bottom: 18px; line-height: 1.6; }
.alert.ok { background: #e6f6f1; border: 1px solid #b5e3d5; }
.alert.err { background: #fdecea; border: 1px solid #f5c2bc; color: #8a1f14; }
.code-big {
  font-family: ui-monospace, Menlo, monospace; font-size: 1.1em; font-weight: 700; letter-spacing: .06em;
  background: #e4f2f0; color: var(--teal-d); padding: 3px 10px; border-radius: 8px; display: inline-block;
}

.card-page { display: grid; justify-items: center; gap: 18px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.actions form { margin: 0; }

.search { display: flex; gap: 10px; margin-bottom: 22px; padding: 14px; }
.search input { flex: 1; font-size: 16px; text-transform: uppercase; }
.search input::placeholder { text-transform: none; }

.profile { display: grid; grid-template-columns: 280px 1fr; gap: 28px; }
.profile-photo img { width: 100%; aspect-ratio: 3/4; object-fit: cover; border-radius: 14px; display: block; }
.profile-info h2 { font-size: 32px; margin: 6px 0 10px; font-family: var(--serif); }
.verified { color: #12805c; font-weight: 600; font-size: 14px; }
.profile dl { display: grid; grid-template-columns: max-content 1fr; gap: 10px 22px; margin: 22px 0 0; }
.profile dt { color: var(--muted); font-size: 14px; }
.profile dt small { display: block; font-style: italic; font-size: 12px; }
.profile dd { margin: 0; font-weight: 600; }
@media (max-width: 700px) { .profile { grid-template-columns: 1fr; } .profile-photo { max-width: 260px; } }

.login { max-width: 420px; margin: 40px auto; display: grid; gap: 14px; }
.admin-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; margin-bottom: 18px; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tabs a { padding: 8px 14px; border-radius: 999px; text-decoration: none; color: var(--muted); font-weight: 500; font-size: 14px; background: #fff; border: 1px solid var(--line); }
.tabs a.on { background: var(--teal); color: #fff; border-color: var(--teal); }
.table-wrap { overflow-x: auto; padding: 0; }
.list { width: 100%; border-collapse: collapse; font-size: 14px; }
.list th, .list td { padding: 10px 14px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.list th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.thumb { width: 40px; height: 52px; object-fit: cover; border-radius: 6px; display: block; }

/* =========================================================
   THẺ CĂN CƯỚC — mọi kích thước tính theo chiều rộng thẻ (cqw)
   nên thẻ co giãn đúng tỉ lệ ở mọi màn hình.
   ========================================================= */
.card-holder { width: 100%; max-width: 860px; container-type: inline-size; }

.pet-card {
  --c-head1: #cdebe8;
  --c-head2: #93d2cc;
  --c-ink: #141c1d;
  --c-label: #4a5556;
  --c-accent: #2a8c83;
  position: relative; width: 100%; aspect-ratio: 85.6 / 54; overflow: hidden;
  border-radius: 4.2cqw; color: var(--c-ink);
  background:
    radial-gradient(60% 80% at 90% 85%, rgba(170, 222, 196, .55), transparent 70%),
    radial-gradient(50% 60% at 8% 70%, rgba(190, 228, 220, .5), transparent 70%),
    linear-gradient(160deg, #f4faf8 0%, #e6f3ef 55%, #d7eee4 100%);
  box-shadow: 0 1.5cqw 4cqw rgba(20, 70, 65, .18), 0 0 0 .12cqw rgba(30, 110, 100, .15);
  font-family: var(--sans);
}
/* hoa văn guilloche chống giả */
.pc-guilloche {
  position: absolute; inset: 0; pointer-events: none; opacity: .55;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='44'%3E%3Cg fill='none' stroke-width='.7'%3E%3Cpath d='M0 22C20 0 60 0 80 22S140 44 160 22' stroke='%2389c2cf'/%3E%3Cpath d='M0 22C20 44 60 44 80 22S140 0 160 22' stroke='%23b2acdc'/%3E%3Cpath d='M0 0C20 22 60 22 80 0M80 44C100 22 140 22 160 44' stroke='%2389c2cf' opacity='.6'/%3E%3Cpath d='M0 44C20 22 60 22 80 44M80 0C100 22 140 22 160 0' stroke='%23b2acdc' opacity='.6'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 19cqw 5.2cqw;
  -webkit-mask-image: linear-gradient(90deg, #000 0%, rgba(0,0,0,.55) 45%, #000 100%);
          mask-image: linear-gradient(90deg, #000 0%, rgba(0,0,0,.55) 45%, #000 100%);
}

/* đầu thẻ */
.pc-head {
  position: relative; height: 15.5cqw; display: grid; grid-template-columns: 27cqw 1fr; align-items: center;
  padding: 0 3cqw 0 3.6cqw;
  background:
    radial-gradient(70% 140% at 15% 0%, rgba(255,255,255,.55), transparent 60%),
    linear-gradient(180deg, var(--c-head1), var(--c-head2));
}
.pc-logo { display: flex; align-items: center; height: 100%; }
.pc-logo img { max-width: 100%; max-height: 11.5cqw; object-fit: contain; }
.pc-logo-text {
  font-family: var(--sans); font-weight: 700; font-size: 5.2cqw; letter-spacing: -.05em; line-height: 1;
  color: #1f8a76; text-shadow: 0 .15cqw 0 rgba(255,255,255,.6);
}
.pc-org { text-align: center; display: grid; gap: .55cqw; }
.pc-org strong { font-family: var(--serif); font-weight: 800; font-size: 2.7cqw; line-height: 1.15; }
.pc-org span { font-size: 1.95cqw; line-height: 1.15; }
.pc-org i { font-size: 1.95cqw; line-height: 1.15; font-weight: 500; }

/* dải viền hoa văn */
.pc-band {
  position: relative; height: 1.3cqw;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M6 1 10 4 6 7 2 4Z' fill='%23fff' fill-opacity='.85'/%3E%3C/svg%3E") 0 50% / 1.3cqw .9cqw repeat-x,
    linear-gradient(90deg, #8f8fd0, #6fc2c8 30%, #9fd8d2 50%, #6fc2c8 70%, #8f8fd0);
  box-shadow: 0 .3cqw .6cqw rgba(60, 100, 130, .2);
}

/* thân thẻ */
.pc-body {
  position: relative; display: grid; grid-template-columns: 25cqw 1fr; gap: 3.2cqw;
  padding: 2.2cqw 3.4cqw 0 4cqw; height: calc(100% - 16.8cqw);
}
.pc-left { display: flex; flex-direction: column; gap: 1.2cqw; }
.pc-id { font-family: var(--serif); font-weight: 800; font-size: 3.2cqw; line-height: 1; white-space: nowrap; }
.pc-id b { font-family: ui-monospace, 'SFMono-Regular', Menlo, monospace; font-size: 2.15cqw; letter-spacing: .04em; color: var(--c-accent); font-weight: 700; vertical-align: .25cqw; }
.pc-photo {
  width: 100%; aspect-ratio: 3 / 4; border-radius: 2.4cqw; overflow: hidden; background: #fff;
  display: grid; place-items: center;
  box-shadow: 0 0 0 .8cqw rgba(255,255,255,.55), 0 .5cqw 1.6cqw rgba(30, 80, 75, .15);
}
.pc-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pc-photo-ph { color: #7d8a8c; font-size: 1.9cqw; }
.pc-issue { font-family: var(--serif); color: var(--c-label); margin-top: auto; padding-bottom: 2.4cqw; line-height: 1.1; }
.pc-issue > div { font-size: 2.15cqw; font-weight: 700; white-space: nowrap; }
.pc-issue b { color: var(--c-ink); }
.pc-issue em { font-size: 1.5cqw; font-weight: 600; }

.pc-main { min-width: 0; }
.pc-main h2 {
  margin: 0; text-align: center; font-family: var(--serif); font-weight: 800; font-size: 4.7cqw;
  letter-spacing: .02em; line-height: 1.05; white-space: nowrap;
}
.pc-main h3 {
  margin: .4cqw 0 1.6cqw; text-align: center; font-weight: 500; font-size: 2.55cqw; letter-spacing: .14em; color: #555f61; line-height: 1.1;
}
.pc-fields { display: grid; gap: .55cqw; }
.pc-fields > .pc-f { max-width: 50cqw; }
.pc-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5cqw; }
.pc-f { display: grid; grid-template-columns: 3.6cqw 1fr; align-items: center; gap: .9cqw; min-width: 0; }
.pc-paw { width: 3.4cqw; height: 3.4cqw; color: var(--c-accent); opacity: .85; }
.pc-lbl { min-width: 0; line-height: 1.05; }
.pc-lbl .vi {
  font-family: var(--serif); font-size: 2.3cqw; color: var(--c-label); font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pc-lbl em { display: block; font-family: var(--serif); font-size: 1.45cqw; font-weight: 600; color: #5c6769; }
.pc-val { font-family: var(--sans); font-weight: 700; font-size: 2.15cqw; color: var(--c-ink); margin-left: .4cqw; }

/* mã QR */
.pc-qr {
  position: absolute; right: 3.2cqw; bottom: 3cqw; width: 10cqw; text-align: center;
  display: grid; gap: .4cqw; justify-items: center;
}
.pc-qr-box { width: 10cqw; height: 10cqw; background: #fff; padding: .6cqw; border-radius: 1cqw; box-shadow: 0 .3cqw 1cqw rgba(30,80,75,.15); }
.pc-qr-box svg { width: 100%; height: 100%; display: block; }
.pc-qr small { font-size: 1.1cqw; color: #4b5759; font-weight: 600; white-space: nowrap; }

/* =========================================================
   IN THẺ: đúng khổ 85.6 × 54 mm
   ========================================================= */
@media print {
  @page { size: auto; margin: 10mm; }
  body { background: #fff; }
  .topnav, .actions, .alert, .search, .profile, .section-title, .page-title, .hint { display: none !important; }
  .wrap { padding: 0; }
  .card-holder { width: 85.6mm; max-width: none; }
  .pet-card { box-shadow: none; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
