:root {
  --yellow: #ffed00;
  --navy: #242c79;
  --red: #ed1c24;
  --green: #35b85a;
  --green-dark: #087438;
  --ink: #10131d;
  --muted: #64748b;
  --surface: #ffffff;
  --line: #dbe2ea;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: #f5f7fa;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
a { color: var(--navy); font-weight: 700; text-decoration: none; }
a:hover { text-decoration: underline; }
button, input { font: inherit; }

.admin-header {
  min-height: 72px;
  padding: 12px clamp(20px, 4vw, 56px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  background: var(--navy);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 10;
}
.admin-brand { color: #fff; display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 12px; background: var(--yellow); color: var(--navy); font-weight: 950; }
.admin-header nav { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.admin-header nav a, .link-button { color: #fff; font-size: 14px; font-weight: 750; }
.admin-header nav form { margin: 0; }
.link-button { border: 0; background: transparent; cursor: pointer; padding: 0; }

.admin-page { background: #f5f7fa; }
.admin-main { max-width: 1280px; margin: 0 auto; padding: 44px clamp(20px, 4vw, 56px) 72px; }
.admin-main.narrow { max-width: 980px; }
.page-heading, .panel-heading { display: flex; align-items: end; justify-content: space-between; gap: 24px; }
.page-heading { margin-bottom: 30px; }
.page-heading h1 { margin: 2px 0 8px; color: var(--navy); font-size: clamp(32px, 5vw, 52px); letter-spacing: -0.04em; }
.eyebrow { color: var(--red); font-size: 12px; font-weight: 900; letter-spacing: .16em; margin: 0 0 8px; }
.muted { color: var(--muted); margin: 0; line-height: 1.6; }

.button { border: 0; border-radius: 12px; padding: 12px 18px; font-weight: 850; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.button:hover { text-decoration: none; transform: translateY(-1px); }
.button-primary { background: var(--navy); color: #fff; box-shadow: 0 8px 20px rgba(36,44,121,.18); }
.button-secondary { background: #edf0f7; color: var(--navy); border: 1px solid #cfd6e7; }
.button-row { display: flex; gap: 12px; flex-wrap: wrap; }

.metric-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 14px; margin-bottom: 26px; }
.metric-grid article { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 20px; box-shadow: 0 6px 24px rgba(15,23,42,.04); }
.metric-grid span { color: var(--muted); font-size: 13px; }
.metric-grid strong { display: block; color: var(--navy); font-size: 28px; margin-top: 8px; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 24px; box-shadow: 0 10px 32px rgba(15,23,42,.05); margin-bottom: 24px; }
.panel-heading { margin-bottom: 18px; align-items: center; }
.panel-heading h2 { margin: 0; color: var(--navy); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { color: var(--muted); text-transform: uppercase; letter-spacing: .08em; font-size: 11px; text-align: left; padding: 12px; border-bottom: 1px solid var(--line); }
td { padding: 14px 12px; border-bottom: 1px solid #edf0f4; }
tbody tr:hover { background: #fbfcfe; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }
.status { display: inline-flex; border-radius: 999px; padding: 5px 9px; background: #edf0f7; color: var(--navy); font-size: 11px; font-weight: 850; }
.status-ok { background: #e8f8ee; color: #087438; }
.empty-state { text-align: center; padding: 46px 20px; color: var(--muted); }
.empty-state strong { color: var(--navy); display: block; font-size: 18px; }

.alert { border-radius: 16px; padding: 16px 18px; margin: 0 0 20px; line-height: 1.55; }
.alert ul { margin-bottom: 0; }
.alert-error { background: #fff0f0; color: #9f1d25; border: 1px solid #ffc9cc; }
.alert-success { background: #eaf9ef; color: #086a36; border: 1px solid #bce8ca; }
.alert-info { background: #eef2ff; color: var(--navy); border: 1px solid #cbd3ff; }

.form-stack { display: grid; gap: 16px; }
.form-stack label, .batch-actions label { display: grid; gap: 7px; font-size: 13px; font-weight: 750; color: #334155; }
input { width: 100%; border: 1px solid #cfd8e4; border-radius: 11px; padding: 12px 13px; background: #fff; }
input:focus { outline: 3px solid rgba(36,44,121,.14); border-color: var(--navy); }
.import-panel { display: grid; grid-template-columns: 1.4fr .8fr; gap: 26px; }
.file-drop { min-height: 190px; border: 2px dashed #bbc5d4; border-radius: 16px; display: grid !important; place-items: center; align-content: center; text-align: center; padding: 24px; background: #fbfcfe; }
.file-drop input { max-width: 360px; border: 0; padding: 8px; }
.file-icon { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 14px; background: var(--yellow); color: var(--navy); font-weight: 950; }
.csv-guide { padding: 20px; background: #f4f6fa; border-radius: 16px; }
.csv-guide h2 { color: var(--navy); margin-top: 0; }
.csv-guide code { word-break: break-word; }
.table-note { color: var(--muted); font-size: 13px; }
.search-form { display: flex; gap: 10px; margin-bottom: 18px; }
.search-form input { flex: 1; }
.pagination { display: flex; justify-content: center; align-items: center; gap: 24px; padding: 20px 0 0; color: var(--muted); }

.batch-grid { display: grid; gap: 18px; }
.batch-card { background: #fff; border: 1px solid var(--line); border-radius: 20px; padding: 22px; box-shadow: 0 8px 28px rgba(15,23,42,.05); }
.batch-card h2 { color: var(--navy); margin: 8px 0 4px; }
.batch-card p { color: var(--muted); margin: 0 0 18px; }
.batch-actions { display: grid; grid-template-columns: 1fr 1fr auto auto; gap: 12px; align-items: end; padding-top: 16px; border-top: 1px solid var(--line); }
.batch-actions.compact { grid-template-columns: 120px 120px auto; margin-top: 12px; padding-top: 12px; }

.print-preview-main { max-width: 1180px; }
.preview-toolbar { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.preview-toolbar h1 { margin: 2px 0 8px; color: var(--navy); font-size: clamp(32px, 5vw, 48px); letter-spacing: -.04em; }
.print-bridge-status { display: flex; align-items: center; gap: 10px; min-height: 48px; margin: -4px 0 20px; padding: 12px 16px; border: 1px solid #cbd5e1; border-radius: 14px; background: #fff; color: #475569; font-weight: 750; }
.print-status-dot { width: 11px; height: 11px; flex: 0 0 auto; border-radius: 50%; background: #94a3b8; box-shadow: 0 0 0 4px rgba(148,163,184,.18); }
.print-bridge-status[data-state="ready"] { color: #087438; border-color: #a7dfba; background: #effaf3; }
.print-bridge-status[data-state="ready"] .print-status-dot,
.print-bridge-status[data-state="success"] .print-status-dot { background: #22a653; box-shadow: 0 0 0 4px rgba(34,166,83,.16); }
.print-bridge-status[data-state="printing"] .print-status-dot,
.print-bridge-status[data-state="checking"] .print-status-dot { background: #eab308; box-shadow: 0 0 0 4px rgba(234,179,8,.16); }
.print-bridge-status[data-state="offline"] { color: #9f1d25; border-color: #ffc9cc; background: #fff0f0; }
.print-bridge-status[data-state="offline"] .print-status-dot { background: #dc2626; box-shadow: 0 0 0 4px rgba(220,38,38,.14); }
.button:disabled { cursor: not-allowed; opacity: .55; transform: none; }
.label-preview-grid { display: grid; grid-template-columns: repeat(2, 100mm); justify-content: center; gap: 28px; }
.label-page { position: relative; width: 100mm; height: 100mm; overflow: hidden; background: transparent; box-shadow: 0 14px 40px rgba(15,23,42,.18); }
.label-guide { position: absolute; inset: 0; overflow: hidden; border: .6mm solid var(--red); border-radius: 50%; background: var(--yellow); color: var(--navy); text-align: center; }
.label-guide::after { content: ""; position: absolute; inset: 2.2mm; border: .25mm solid var(--red); border-radius: 50%; }
.guide-hashtag { position: absolute; left: 29mm; top: 41mm; padding: 1.3mm 2.4mm; color: var(--yellow); background: var(--red); font-size: 4.5mm; font-weight: 950; transform: rotate(-2deg); }
.guide-campaign { position: absolute; left: 35mm; top: 55mm; font-size: 9mm; line-height: .9; font-weight: 950; }
.guide-number { position: absolute; left: 33mm; top: 66mm; font-size: 14mm; line-height: .9; font-weight: 950; }
.guide-office { position: absolute; left: 39mm; top: 80mm; font-size: 3mm; font-weight: 900; }
.label-variable { position: absolute; z-index: 2; overflow: hidden; color: #000; font-family: Arial, Helvetica, sans-serif; font-weight: 900; line-height: 1; text-align: center; white-space: nowrap; }
.label-name { display: flex; align-items: flex-start; justify-content: center; letter-spacing: -.02em; }
.label-name span { display: inline-block; flex: 0 0 auto; white-space: nowrap; transform-origin: center top; }
.label-primary-line { position: absolute; height: .38mm; background: #000; z-index: 3; }
.label-qr { position: absolute; z-index: 2; display: block; image-rendering: pixelated; }
.preview-reference { position: absolute; z-index: 3; right: 4mm; bottom: 3mm; padding: 1mm 2mm; border-radius: 999px; background: rgba(255,255,255,.88); color: var(--navy); font-size: 2.4mm; font-weight: 850; }

.admin-login-page { background: linear-gradient(145deg, var(--yellow), #ffe000); display: grid; place-items: center; padding: 24px; }
.login-shell { width: min(100%, 440px); }
.login-card { background: #fff; border: 2px solid var(--navy); border-radius: 26px; padding: 34px; box-shadow: 12px 12px 0 var(--navy); }
.login-card h1 { color: var(--navy); margin: 0 0 8px; font-size: 34px; }
.login-emblem { width: 58px; height: 58px; border-radius: 17px; background: var(--navy); color: var(--yellow); display: grid; place-items: center; font-weight: 950; font-size: 22px; margin-bottom: 24px; }
.login-card .form-stack { margin-top: 24px; }

.public-page {
  background-color: #fff;
  background-image: url("/static/puzzle-background-4k-v2.png");
  background-position: center top;
  background-repeat: no-repeat;
  background-size: cover;
  background-attachment: fixed;
}
.public-shell { min-height: 100vh; width: min(100%, 680px); margin: 0 auto; padding: 18px 14px 54px; overflow: hidden; position: relative; }
.public-shell::before, .public-shell::after { display: none; }
.confirm-form { position: relative; z-index: 1; margin: 0; }
.confirm-machine { position: relative; display: block; width: 100%; margin-top: 0; padding: 12px 20px 10px; border: 3px solid #146d3b; border-radius: 22px; appearance: none; font: inherit; text-align: center; color: #050505; background-color: var(--green); background-image: radial-gradient(rgba(255,255,255,.26) .8px, transparent .8px); background-size: 4px 4px; box-shadow: 0 8px 0 var(--green-dark), 0 14px 26px rgba(0,0,0,.22); cursor: pointer; }
.confirm-machine:active { transform: translateY(5px); box-shadow: 0 3px 0 var(--green-dark), 0 8px 18px rgba(0,0,0,.2); }
.confirm-machine.is-confirming { transform: translateY(5px); box-shadow: 0 3px 0 var(--green-dark), 0 8px 18px rgba(0,0,0,.2); filter: brightness(1.08); cursor: wait; }
.machine-top { display: block; }
.confirm-title { display: block; margin: 0; font-size: clamp(38px, 9vw, 56px); line-height: .95; letter-spacing: -.05em; font-weight: 950; }
.personal-greeting { position: relative; z-index: 1; margin: 22px auto 14px; text-align: center; color: #050505; }
.person-first-name { display: block; width: min(68%, 300px); margin: 0 auto 12px; padding: 6px 18px 8px; border: 3px solid #111; border-radius: 20px; background: #ffed00; box-shadow: 0 2px 0 rgba(0,0,0,.12); font-size: clamp(28px, 8vw, 42px); line-height: 1; font-weight: 950; text-transform: none; }
.personal-greeting p { margin: 0 0 9px; font-size: clamp(17px, 4.7vw, 22px); line-height: 1.2; font-weight: 500; }
.braille { display: grid; grid-template-columns: repeat(6, 7px); gap: 3px; justify-content: center; margin: 8px auto 0; }
.braille i { width: 7px; height: 7px; display: block; border-radius: 50%; background: #44c865; box-shadow: inset 1px 1px 1px rgba(255,255,255,.7), 1px 1px 1px rgba(0,0,0,.25); }
.braille i:nth-child(4), .braille i:nth-child(7) { grid-column-start: 3; }
.personal-message { margin: 0 auto 18px; max-width: 540px; font-size: clamp(17px, 4.5vw, 21px); line-height: 1.42; font-weight: 720; }
.personal-message strong { color: #d71129; font-weight: 950; text-transform: none; }
.physical-confirm { border: 2px solid rgba(0,0,0,.48); border-radius: 999px; padding: 10px 20px; font-weight: 950; letter-spacing: .08em; color: #020202; background: rgba(40,184,81,.5); box-shadow: inset 0 2px 2px rgba(255,255,255,.45), 0 3px 0 rgba(0,0,0,.2); cursor: pointer; }
.physical-confirm:active { transform: translateY(3px); box-shadow: inset 0 2px 3px rgba(0,0,0,.25); }
.campaign-composite { position: relative; z-index: 0; display: block; width: calc(100% + 28px); height: auto; margin: 8px -14px -54px; user-select: none; pointer-events: none; }
.campaign-art { position: relative; z-index: 1; width: min(78%, 490px); margin: 38px auto 24px; border: 2px solid var(--navy); border-radius: 26px; overflow: hidden; box-shadow: 14px 14px 0 var(--navy); background: white; }
.campaign-art img { width: 100%; display: block; }
.identity-card { position: relative; z-index: 1; width: min(100%, 540px); margin: 34px auto 0; background: rgba(255,255,255,.86); border: 2px solid var(--navy); border-radius: 22px; padding: 22px 16px; text-align: center; box-shadow: 8px 8px 0 var(--red); }
.identity-card span { display: block; font-size: 11px; font-weight: 900; letter-spacing: .17em; }
.identity-card strong { display: block; font-size: clamp(28px, 8vw, 45px); line-height: 1; margin: 9px 0 12px; }
.identity-card small { color: var(--navy); font-weight: 950; }

@media (max-width: 980px) {
  .metric-grid { grid-template-columns: repeat(3, 1fr); }
  .admin-header { align-items: flex-start; }
  .admin-header nav { gap: 12px; }
  .label-preview-grid { grid-template-columns: 100mm; }
}
@media (max-width: 720px) {
  .admin-header { position: static; display: block; }
  .admin-header nav { margin-top: 14px; }
  .page-heading, .panel-heading { align-items: flex-start; flex-direction: column; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .import-panel { grid-template-columns: 1fr; }
  .search-form { flex-direction: column; }
  .batch-actions, .batch-actions.compact { grid-template-columns: 1fr; }
  .preview-toolbar { align-items: flex-start; flex-direction: column; }
  .print-preview-main { padding-left: 8px; padding-right: 8px; overflow-x: auto; }
}
@media (max-width: 440px) {
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .metric-grid article { padding: 15px; }
  .metric-grid strong { font-size: 24px; }
  .admin-main { padding-top: 28px; }
  .campaign-art { width: 80%; }
}

@page { size: 100mm 100mm; margin: 0; }
@media print {
  :root, body, .admin-page { background: #fff !important; }
  .admin-header, .screen-only { display: none !important; }
  .admin-main, .print-preview-main { width: auto; max-width: none; margin: 0; padding: 0; overflow: visible; }
  .label-preview-grid { display: block; margin: 0; }
  .label-page { width: 100mm; height: 100mm; margin: 0; box-shadow: none; break-after: page; page-break-after: always; }
  .label-page:last-child { break-after: auto; page-break-after: auto; }
  .label-guide { display: none !important; }
}
