:root {
  color-scheme: light;
  --ink: #172033;
  --muted: #667085;
  --line: #dfe3ea;
  --panel: rgba(255, 255, 255, 0.94);
  --primary: #185adb;
  --primary-dark: #1049b8;
  --danger: #b42318;
  --success: #087443;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: Inter, Pretendard, "Malgun Gothic", Arial, sans-serif;
  background:
    radial-gradient(circle at 15% 0%, rgba(62, 123, 250, 0.14), transparent 34rem),
    linear-gradient(145deg, #f8faff 0%, #eef2f8 100%);
}

button, input { font: inherit; }

.hidden { display: none !important; }
.label-print-frame { position: fixed; top: 0; left: -10000px; width: 152.4mm; height: 101.6mm; border: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.app-shell { width: min(1120px, calc(100% - 32px)); margin: 0 auto; padding: 32px 0 64px; }
.app-header { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 22px; }
.eyebrow { margin: 0 0 4px; color: var(--primary); font-size: 12px; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; }
h1 { margin: 0; font-size: clamp(28px, 4vw, 42px); letter-spacing: -0.04em; }
h2 { margin: 0; font-size: 19px; }
.panel-heading p { margin: 5px 0 0; color: var(--muted); font-size: 14px; }

.session-panel { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 14px; }
.panel { margin-bottom: 16px; padding: 22px; border: 1px solid rgba(210, 216, 227, 0.9); border-radius: 18px; background: var(--panel); box-shadow: 0 16px 40px rgba(33, 43, 68, 0.08); backdrop-filter: blur(12px); }
.panel-heading { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 18px; }
.panel-heading.compact { margin-bottom: 12px; }
.step { display: grid; flex: 0 0 30px; width: 30px; height: 30px; place-items: center; border-radius: 9px; color: #fff; background: var(--primary); font-weight: 800; }

#login-form { display: grid; grid-template-columns: 1fr 1fr auto; align-items: end; gap: 12px; }
#login-form label { display: grid; gap: 7px; color: var(--muted); font-size: 13px; font-weight: 700; }
input { width: 100%; height: 44px; padding: 0 13px; border: 1px solid #cbd2df; border-radius: 10px; color: var(--ink); background: #fff; outline: none; }
input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(24, 90, 219, 0.14); }

#lookup-form { display: grid; grid-template-columns: minmax(220px, 1fr) auto; gap: 10px; }
.lookup-field input { height: 52px; font-size: 19px; font-weight: 750; letter-spacing: 0.03em; }
.auto-print-option { display: inline-flex; align-items: center; gap: 8px; margin-top: 12px; color: var(--muted); font-size: 13px; }
.auto-print-option input { width: 16px; height: 16px; margin: 0; }

.button { min-height: 42px; padding: 0 18px; border: 0; border-radius: 10px; cursor: pointer; font-weight: 800; transition: 120ms ease; }
.button:disabled { cursor: wait; opacity: 0.58; }
.button-primary { color: #fff; background: var(--primary); box-shadow: 0 8px 18px rgba(24, 90, 219, 0.2); }
.button-primary:hover:not(:disabled) { background: var(--primary-dark); transform: translateY(-1px); }
.button-quiet { color: var(--ink); background: #e9edf4; }

.status { min-height: 24px; margin: 4px 4px 14px; color: var(--muted); font-size: 14px; font-weight: 700; }
.status.error { color: var(--danger); }
.status.success { color: var(--success); }

.candidate-list { display: grid; gap: 8px; }
.candidate-button { display: grid; grid-template-columns: 1fr auto; gap: 8px 20px; width: 100%; padding: 14px; border: 1px solid var(--line); border-radius: 12px; text-align: left; color: var(--ink); background: #fff; cursor: pointer; }
.candidate-button:hover { border-color: var(--primary); background: #f5f8ff; }
.candidate-address { font-weight: 800; }
.candidate-code { grid-row: span 2; align-self: center; color: var(--primary); font-weight: 900; }
.candidate-detail { color: var(--muted); font-size: 13px; }

.preview-wrap { margin-top: 20px; }
.preview-toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; padding: 12px 15px; border-radius: 12px; background: #fff; box-shadow: 0 8px 26px rgba(33, 43, 68, 0.09); }
.preview-toolbar strong { display: block; }
.preview-toolbar span { color: var(--muted); font-size: 12px; }

.shipping-label {
  width: 152.4mm;
  height: 101.6mm;
  margin: 0 auto;
  padding: 0 2mm 0 5mm;
  overflow: hidden;
  color: #000;
  background: #fff;
  font-family: Arial, "Malgun Gothic", sans-serif;
  font-weight: 700;
  box-shadow: 0 3px 18px rgba(0, 0, 0, 0.25);
}

.route-row { display: grid; grid-template-columns: 43% 57%; height: 16mm; }
.route-grid { width: 78mm; height: 16mm; justify-self: center; }
.route-main { display: grid; grid-template-columns: 13mm 10mm 19mm 10mm 13mm 13mm; align-items: end; height: 11mm; white-space: nowrap; text-align: center; }
.route-main > * { min-width: 0; }
.route-code { padding: 0.4mm; font-size: 24pt; line-height: 1; }
.delivery-code { padding: 0 0.5mm; font-size: 28pt; line-height: 1; }
.route-name { overflow: hidden; padding-bottom: 1mm; font-size: 8pt; line-height: 1; letter-spacing: -0.15mm; }
.course-number { padding: 0.5mm 2mm 0 0; text-align: right; font-size: 12pt; line-height: 1; }

.identity-row { display: grid; grid-template-columns: 49% 51%; height: 24mm; }
.brand-name { align-self: center; font-size: 18pt; }
.sender-info { display: flex; flex-direction: column; padding-top: 3mm; font-size: 9.5pt; line-height: 1.15; }
.sender-info strong { font-size: 11pt; }

.label-body { display: grid; grid-template-columns: 49% 51%; height: 34mm; }
.tracking-block { padding: 1mm; font-size: 11pt; }
.hawb-title { display: block; margin-bottom: 1.5mm; }
.tracking-barcode { width: 54mm; height: 23mm; }
.barcode-number { width: 54mm; text-align: center; font-size: 11pt; letter-spacing: 1px; line-height: 1; }
.barcode img { display: block; width: 100%; height: 100%; image-rendering: pixelated; }

.recipient-block { padding-top: 1mm; font-size: 11pt; line-height: 1.12; overflow: hidden; }
.recipient-name { display: block; font-size: 12pt; }
.recipient-address { max-height: 14mm; overflow: hidden; }
.postcode-row { display: flex; align-items: center; gap: 1mm; width: 40mm; height: 7mm; margin-top: 1mm; }
.postcode-barcode { width: 28mm; height: 7mm; }
.postcode-row strong { font-size: 10pt; letter-spacing: 1px; }
.recipient-phone { margin-top: 1mm; font-size: 10.5pt; }

.message-row { height: 8mm; padding-left: 1mm; font-size: 10pt; }
.label-footer { display: grid; grid-template-columns: 69% 31%; height: 10mm; padding-left: 1mm; font-size: 9pt; }
.label-footer div { font-size: 7.5pt; }

@media (max-width: 720px) {
  .app-shell { width: min(100% - 20px, 1120px); padding-top: 20px; }
  .app-header { align-items: flex-start; }
  #login-form { grid-template-columns: 1fr; }
  #lookup-form { grid-template-columns: 1fr; }
  .preview-wrap { overflow-x: auto; padding-bottom: 10px; }
  .shipping-label { margin-left: 0; transform-origin: top left; }
}

@page { margin: 0; }

@media print {
  html, body {
    width: 152.4mm;
    height: 101.6mm;
    min-height: 0 !important;
    max-height: 101.6mm;
    margin: 0;
    padding: 0;
    overflow: hidden;
    background: #fff;
  }
  .no-print { display: none !important; }
  .app-shell, .preview-wrap { width: 0; height: 0; margin: 0; padding: 0; overflow: visible; }
  .preview-wrap.hidden { display: none !important; }
  .shipping-label {
    position: absolute;
    top: 0;
    left: 0;
    width: 152.4mm;
    height: 101.6mm;
    margin: 0;
    box-shadow: none;
    transform: none;
    zoom: 1;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
    break-after: avoid;
    break-inside: avoid;
  }
}
