/* =========================================================
   Design tokens
   ========================================================= */
:root {
  --bg: #f6f7fb;
  --bg-grad-1: #eef2ff;
  --bg-grad-2: #faf5ff;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e8f0;
  --border-soft: #eef2f7;

  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --primary-soft: #eef2ff;
  --emerald: #10b981;
  --emerald-soft: #ecfdf5;
  --amber: #f59e0b;
  --rose: #f43f5e;
  --rose-soft: #fff1f2;

  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;
  --muted-2: #94a3b8;

  --radius: 16px;
  --radius-sm: 10px;
  --radius-lg: 22px;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .04), 0 1px 3px rgba(15, 23, 42, .04);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, .06), 0 2px 4px rgba(15, 23, 42, .04);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, .10), 0 4px 8px rgba(15, 23, 42, .04);
  --shadow-pop: 0 24px 60px rgba(15, 23, 42, .18);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: 'Inter', 'Segoe UI', -apple-system, Roboto, sans-serif;
  font-size: 14px;
  color: var(--text);
  background:
    radial-gradient(1200px 800px at 0% 0%, var(--bg-grad-1), transparent 60%),
    radial-gradient(900px 600px at 100% 0%, var(--bg-grad-2), transparent 60%),
    var(--bg);
  min-height: 100vh;
  padding: 22px;
  -webkit-font-smoothing: antialiased;
}

/* =========================================================
   App shell
   ========================================================= */
.app { max-width: 1500px; margin: 0 auto; }

.topbar {
  display: flex; justify-content: space-between; align-items: center;
  gap: 24px; flex-wrap: wrap;
  background: rgba(255, 255, 255, .85);
  backdrop-filter: saturate(180%) blur(12px);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 16px 22px;
  margin-bottom: 22px;
  box-shadow: var(--shadow-md);
}

.brand { display: flex; align-items: center; gap: 14px; }
.brand-icon {
  width: 44px; height: 44px; border-radius: 14px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6 60%, #ec4899);
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 1.1rem;
  box-shadow: 0 8px 20px rgba(99, 102, 241, .35);
}
.brand-title { font-size: 1.15rem; font-weight: 700; letter-spacing: -.01em; }
.brand-sub { font-size: .75rem; color: var(--muted); margin-top: 1px; }

.tabs {
  display: flex; gap: 4px;
  background: var(--surface-2);
  padding: 4px; border-radius: 999px;
  border: 1px solid var(--border-soft);
}
.tab {
  border: none; background: transparent; cursor: pointer;
  font-family: inherit; font-size: .85rem; font-weight: 600;
  color: var(--muted); padding: 9px 18px; border-radius: 999px;
  transition: all .18s ease;
  display: inline-flex; align-items: center; gap: 8px;
}
.tab:hover { color: var(--text); }
.tab.active {
  background: white; color: var(--primary-dark);
  box-shadow: var(--shadow-sm);
}

/* =========================================================
   Layout
   ========================================================= */
.panel { display: none; }
.panel.active { display: block; animation: fadeIn .22s ease; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 22px;
  align-items: start;
}
@media (max-width: 1000px) { .layout { grid-template-columns: 1fr; } }

.sidebar {
  display: flex; flex-direction: column; gap: 14px;
  max-height: calc(100vh - 130px);
  overflow-y: auto;
  padding-right: 4px;
}
.sidebar::-webkit-scrollbar { width: 8px; }
.sidebar::-webkit-scrollbar-thumb { background: #dbe2ea; border-radius: 20px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }

/* =========================================================
   Cards
   ========================================================= */
.card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 16px 16px 14px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .2s ease, border-color .2s ease;
}
.card:hover { box-shadow: var(--shadow-md); }

.card-head {
  display: flex; align-items: center; gap: 9px;
  font-size: .82rem; font-weight: 700;
  color: var(--text-2); text-transform: uppercase; letter-spacing: .04em;
  margin-bottom: 12px;
}
.card-head i { color: var(--primary); font-size: .9rem; }
.card-head .badge { margin-left: auto; }

.danger-card { border-color: #ffe4e6; }

/* =========================================================
   Buttons
   ========================================================= */
.btn {
  border: none; cursor: pointer;
  font-family: inherit; font-weight: 600; font-size: .85rem;
  padding: 11px 18px; border-radius: var(--radius-sm);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; transition: all .15s ease;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  box-shadow: 0 6px 16px rgba(99, 102, 241, .30);
}
.btn-primary:not(:disabled):hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(99, 102, 241, .40);
}

.btn-soft {
  background: var(--surface-2); color: var(--text-2);
  border: 1px solid var(--border);
}
.btn-soft:not(:disabled):hover { background: #eef2f7; }

.btn-ghost {
  background: transparent; color: var(--muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text-2); }

.btn-danger {
  background: var(--rose-soft); color: #be123c;
  border: 1px solid #fecdd3;
}
.btn-danger:hover { background: #ffe4e6; border-color: #fda4af; }

.btn-sm { padding: 8px 12px; font-size: .78rem; width: auto; }

.btn-row { display: flex; gap: 6px; }
.btn-row .btn { flex: 1; }

/* =========================================================
   Inputs / file buttons
   ========================================================= */
.input {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-family: inherit; font-size: .87rem; color: var(--text);
  background: white; transition: all .15s ease;
}
.input:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, .14);
}
.input:disabled { background: var(--surface-2); cursor: not-allowed; opacity: .8; }

.file-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 12px 14px; cursor: pointer;
  border: 1.5px dashed #cbd5e1; border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-size: .85rem; font-weight: 600; color: var(--text-2);
  transition: all .15s ease;
  margin-bottom: 10px;
}
.file-btn:hover {
  border-color: var(--primary); background: var(--primary-soft); color: var(--primary-dark);
}
.file-btn i { color: var(--primary); }
input[type="file"] { display: none; }

/* =========================================================
   Status
   ========================================================= */
.file-status {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-radius: var(--radius-sm);
  font-size: .8rem; background: var(--surface-2); color: var(--muted);
  border: 1px solid var(--border-soft);
  word-break: break-word;
}
.file-status i { color: var(--muted-2); }
.file-status.ok { background: var(--emerald-soft); color: #065f46; border-color: #a7f3d0; }
.file-status.ok i { color: var(--emerald); }
.file-status.err { background: var(--rose-soft); color: #991b1b; border-color: #fecdd3; }
.file-status.err i { color: var(--rose); }

.status {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; border-radius: var(--radius-sm);
  font-size: .82rem; background: var(--emerald-soft); color: #065f46;
  border: 1px solid #a7f3d0;
}
.status i { color: var(--emerald); }
.status.err { background: var(--rose-soft); color: #991b1b; border-color: #fecdd3; }
.status.err i { color: var(--rose); }
.status.info { background: var(--primary-soft); color: #3730a3; border-color: #c7d2fe; }
.status.info i { color: var(--primary); }

.hint {
  font-size: .78rem; color: var(--muted); line-height: 1.55;
}
.hint b { color: var(--text-2); font-weight: 600; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 999px;
  font-size: .72rem; font-weight: 700;
  background: var(--primary-soft); color: var(--primary-dark);
}
.badge-soft {
  background: var(--surface-2); color: var(--muted);
  border: 1px solid var(--border-soft);
  padding: 6px 12px; font-weight: 600;
}
.badge-soft b { color: var(--text-2); }

/* =========================================================
   Shortcuts list
   ========================================================= */
.kbd-list {
  list-style: none; display: flex; flex-direction: column; gap: 7px;
  font-size: .78rem; color: var(--muted); margin-bottom: 10px;
}
.kbd {
  display: inline-block;
  padding: 1px 7px; border-radius: 5px;
  background: var(--surface-2); border: 1px solid var(--border);
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: .72rem; color: var(--text-2); font-weight: 600;
}

/* =========================================================
   Main area
   ========================================================= */
.main {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  min-height: 500px;
  display: flex; flex-direction: column;
  overflow: hidden;
}

.main-toolbar {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-soft);
  background: linear-gradient(180deg, #fbfcff, #f6f8fd);
  flex-wrap: wrap;
}
.headline {
  display: flex; align-items: center; gap: 8px;
  font-weight: 600; font-size: .88rem; color: var(--text-2);
  flex: 1;
}

.pill-group {
  display: inline-flex; align-items: center; gap: 4px;
  background: white; border: 1px solid var(--border);
  border-radius: 999px; padding: 3px 5px;
  box-shadow: var(--shadow-sm);
}
.pill-icon {
  width: 30px; height: 30px; border-radius: 999px;
  border: none; background: transparent;
  cursor: pointer; color: var(--text-2);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: .78rem; transition: all .15s ease;
}
.pill-icon:not(:disabled):hover { background: var(--primary-soft); color: var(--primary-dark); }
.pill-icon:disabled { opacity: .35; cursor: not-allowed; }
.pill-icon-soft { color: var(--muted-2); font-size: .8rem; padding-left: 8px; }
.pill-label {
  padding: 0 10px; font-size: .78rem; color: var(--muted);
  font-weight: 500;
}
.pill-label b { color: var(--text); }
.pill-label.mono { font-variant-numeric: tabular-nums; }
.pill-select {
  border: none; background: transparent; font-family: inherit;
  font-size: .78rem; color: var(--text-2); font-weight: 600;
  padding: 6px 6px; outline: none; cursor: pointer; max-width: 180px;
}

.canvas-stage {
  flex: 1; padding: 22px;
  background: repeating-conic-gradient(#f1f5f9 0 25%, #f8fafc 0 50%) 0 0/24px 24px;
  display: flex; align-items: flex-start; justify-content: center;
  overflow: auto;
  min-height: 460px;
}

/* Empty state */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; gap: 12px;
  padding: 60px 20px; color: var(--muted);
  max-width: 460px;
}
.empty-icon {
  width: 68px; height: 68px; border-radius: 22px;
  background: linear-gradient(135deg, #eef2ff, #f5f3ff);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem; color: var(--primary);
  box-shadow: 0 8px 20px rgba(99, 102, 241, .18);
}
.empty-icon.accent {
  background: linear-gradient(135deg, #ecfdf5, #f0fdfa);
  color: var(--emerald);
  box-shadow: 0 8px 20px rgba(16, 185, 129, .20);
}
.empty-title { font-size: 1rem; font-weight: 700; color: var(--text-2); }
.empty-sub { font-size: .85rem; line-height: 1.6; }

/* =========================================================
   PDF canvas + fields
   ========================================================= */
.canvas-container {
  position: relative; display: inline-block;
  background: white;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  cursor: crosshair; user-select: none;
}
.canvas-container canvas { display: block; max-width: 100%; height: auto; }

.fields-overlay {
  position: absolute; inset: 0;
  pointer-events: none;
}

.field-box {
  position: absolute;
  border: 1.5px solid var(--primary);
  background: rgba(99, 102, 241, .14);
  color: var(--primary-dark);
  font-size: 11px; font-weight: 600;
  padding: 2px 4px;
  border-radius: 4px;
  pointer-events: auto;
  cursor: move;
  overflow: hidden; white-space: nowrap;
  transition: box-shadow .15s ease;
}
.field-box:hover { box-shadow: 0 0 0 2px rgba(99, 102, 241, .25); }
.field-box.selected {
  border-color: var(--amber);
  background: rgba(245, 158, 11, .18);
  color: #92400e;
  box-shadow: 0 0 0 2px rgba(245, 158, 11, .35);
}
.field-box .resize-handle {
  position: absolute; right: -5px; bottom: -5px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--primary); border: 2px solid white;
  cursor: se-resize; pointer-events: auto;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.field-box.selected .resize-handle { background: var(--amber); }

.field-box.field-white-mask {
  border-color: #64748b; background: rgba(100,116,139,.22); color: #334155;
}
.field-box.field-created-date {
  border-color: var(--emerald); background: rgba(16,185,129,.18); color: #065f46;
}
.field-box.field-derived {
  border-color: #8b5cf6; background: rgba(139,92,246,.18); color: #4c1d95;
}
.field-box.field-conditional {
  border-color: var(--rose); background: rgba(244,63,94,.15); color: #9f1239;
}
.field-box.field-image {
  border-color: #14b8a6; background: rgba(20, 184, 166, .18); color: #115e59;
}
.field-box.field-barcode {
  border-color: #0ea5e9; background: rgba(14,165,233,.18); color: #075985;
}
.field-box.field-qr {
  border-color: #8b5cf6; background: rgba(139,92,246,.18); color: #4c1d95;
}
.field-box.field-pdf417 {
  border-color: #ec4899; background: rgba(236, 72, 153, .18); color: #831843;
}

/* =========================================================
   Sidebar field list
   ========================================================= */
.field-list {
  display: flex; flex-direction: column; gap: 7px;
  max-height: 260px; overflow-y: auto;
}
.field-item {
  padding: 9px 11px;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  cursor: pointer; transition: all .15s ease;
}
.field-item:hover { background: #eef2f7; }
.field-item.selected {
  border-color: var(--amber);
  background: #fffbeb;
  box-shadow: 0 0 0 2px rgba(245, 158, 11, .15);
}
.field-item-head {
  display: flex; align-items: center; gap: 6px;
}
.field-item-label {
  flex: 1; font-weight: 700; font-size: .82rem; color: var(--text-2);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.field-item-sub {
  font-size: .72rem; color: var(--muted-2); margin-top: 3px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.field-item .icon-btn {
  background: transparent; border: none; cursor: pointer;
  color: var(--muted-2); padding: 4px 6px; border-radius: 6px;
  font-size: .75rem; transition: all .15s ease;
}
.field-item .icon-btn:hover { background: white; color: var(--text-2); }
.field-item .icon-btn.del:hover { color: var(--rose); background: var(--rose-soft); }

/* =========================================================
   Fill stage
   ========================================================= */
.row-input {
  display: flex; align-items: center; gap: 8px;
  margin-top: 12px; padding-top: 12px;
  border-top: 1px dashed var(--border);
}
.row-input label { font-size: .78rem; color: var(--muted); font-weight: 600; }
.row-input input {
  width: 68px; padding: 7px 9px;
  border: 1px solid var(--border); border-radius: 8px;
  font-family: inherit; font-size: .82rem; text-align: center;
}
.row-input input:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, .14);
}
.row-input .btn { width: auto; margin-left: auto; }

.excel-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.excel-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 11px;
  background: var(--emerald-soft);
  border: 1px solid #a7f3d0;
  border-radius: 8px;
  font-size: .8rem; color: #065f46;
}
.excel-item .rm {
  background: transparent; border: none; cursor: pointer;
  color: #34d399; padding: 2px 6px; border-radius: 4px;
  transition: all .15s ease;
}
.excel-item .rm:hover { color: var(--rose); background: white; }

/* =========================================================
   Tracking pool
   ========================================================= */
.tracking-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 10px;
}
.tracking-stats .stat {
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  padding: 10px 6px;
  text-align: center;
  transition: all .15s ease;
}
.tracking-stats .stat.used {
  background: #fff7ed;
  border-color: #fed7aa;
}
.tracking-stats .stat.available {
  background: var(--emerald-soft);
  border-color: #a7f3d0;
}
.tracking-stats .stat-value {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.tracking-stats .stat.used .stat-value { color: #c2410c; }
.tracking-stats .stat.available .stat-value { color: #047857; }
.tracking-stats .stat-label {
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  font-weight: 700;
  margin-top: 3px;
}

/* =========================================================
   Progress bars
   ========================================================= */
.progress-bar {
  height: 8px; border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
  border: 1px solid var(--border-soft);
}
#shipProgressFill {
  height: 100%;
  background: linear-gradient(90deg, #6366f1, #10b981);
  width: 0%;
  transition: width .2s ease;
  border-radius: 999px;
}
#trackingPoolProgress {
  height: 100%;
  background: linear-gradient(90deg, #f59e0b, #ef4444);
  width: 0%;
  transition: width .25s ease;
  border-radius: 999px;
}
#trackingPoolProgress.full {
  background: linear-gradient(90deg, #ef4444, #b91c1c);
}

/* =========================================================
   Ship log
   ========================================================= */
.ship-log {
  max-height: 160px; overflow-y: auto;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-family: ui-monospace, monospace;
  font-size: .72rem; color: var(--text-2);
  line-height: 1.5;
  margin-top: 10px;
}
.ship-log .err { color: #e11d48; }
.ship-log .ok { color: #059669; }

/* =========================================================
   Modal
   ========================================================= */
.modal {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center;
}
.modal.hidden { display: none; }
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(15, 23, 42, .45);
  backdrop-filter: blur(4px);
}
.modal-panel {
  position: relative;
  background: white;
  border-radius: 20px;
  width: min(720px, 92vw);
  max-height: 90vh;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-pop);
  overflow: hidden;
  animation: popIn .18s ease-out;
}
@keyframes popIn {
  from { opacity: 0; transform: translateY(12px) scale(.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border-soft);
  background: linear-gradient(180deg, #fbfcff, white);
}
.modal-header h2 { font-size: 1.05rem; font-weight: 700; color: var(--text); }
.modal-header .icon-btn {
  background: transparent; border: none; cursor: pointer;
  color: var(--muted); padding: 7px 10px; border-radius: 8px;
  transition: all .15s ease;
}
.modal-header .icon-btn:hover { background: var(--surface-2); color: var(--text-2); }

.modal-body { padding: 20px 22px; overflow-y: auto; flex: 1; }
.modal-footer {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 14px 22px;
  border-top: 1px solid var(--border-soft);
  background: var(--surface-2);
}
.modal-footer .btn { width: auto; padding: 10px 22px; }

.fm-section { margin-bottom: 18px; }
.fm-section:last-child { margin-bottom: 0; }
.fm-section.hidden { display: none; }

.fm-label {
  display: block; font-size: .74rem; font-weight: 700;
  color: var(--muted); text-transform: uppercase; letter-spacing: .05em;
  margin-bottom: 7px;
}
.fm-input {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-family: inherit; font-size: .87rem; color: var(--text);
  background: white;
}
.fm-input:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, .14);
}
.fm-row { display: flex; gap: 12px; margin-bottom: 12px; }
.fm-row:last-child { margin-bottom: 0; }
.fm-col { flex: 1; min-width: 0; }
.fm-hint {
  font-size: .76rem; color: var(--muted); margin-top: 6px; line-height: 1.55;
}
.fm-hint b { color: var(--primary-dark); }

.fm-checkbox {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: .85rem;
  color: var(--text-2);
  transition: all .15s ease;
  user-select: none;
}
.fm-checkbox:hover { background: #eef2f7; }
.fm-checkbox input[type="checkbox"] {
  accent-color: var(--primary);
  cursor: pointer;
  width: 16px; height: 16px;
}
.fm-checkbox i { color: var(--muted); margin-right: 2px; }
.fm-checkbox:has(input:checked) {
  background: var(--primary-soft);
  border-color: #c7d2fe;
  color: var(--primary-dark);
}
.fm-checkbox:has(input:checked) i { color: var(--primary); }

/* =========================================================
   Column picker row
   ========================================================= */
.fm-column-picker-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.fm-column-picker-row .input { flex: 1; min-width: 0; }
.fm-column-picker-row .fm-col-picker {
  max-width: 180px;
  flex-shrink: 0;
  cursor: pointer;
  background: var(--surface-2);
  font-weight: 600;
  color: var(--primary-dark);
}
.fm-column-picker-row .fm-col-picker:focus { background: white; }

/* =========================================================
   Font size slider
   ========================================================= */
.font-size-control {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.font-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary-soft), var(--primary));
  outline: none;
  cursor: pointer;
}
.font-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: white;
  border: 3px solid var(--primary);
  box-shadow: 0 2px 6px rgba(99, 102, 241, .35);
  cursor: grab;
  transition: transform .12s ease;
}
.font-slider::-webkit-slider-thumb:active {
  cursor: grabbing;
  transform: scale(1.15);
}
.font-slider::-moz-range-thumb {
  width: 20px; height: 20px; border-radius: 50%;
  background: white; border: 3px solid var(--primary);
  cursor: grab;
}
.font-number {
  width: 70px;
  text-align: center;
  font-weight: 700;
  padding: 8px 6px;
  font-variant-numeric: tabular-nums;
}
.font-presets {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.font-presets button {
  border: 1px solid var(--border);
  background: white;
  border-radius: 8px;
  padding: 5px 10px;
  font-size: .75rem;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  font-family: inherit;
  transition: all .12s ease;
  min-width: 32px;
}
.font-presets button:hover {
  border-color: var(--primary);
  color: var(--primary-dark);
  background: var(--primary-soft);
}
.font-presets button:active { transform: scale(.95); }

/* =========================================================
   Image preview
   ========================================================= */
.image-preview-wrap {
  display: flex; gap: 14px; align-items: flex-start;
  padding: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
}
.image-preview {
  max-width: 140px; max-height: 140px;
  border-radius: 8px;
  background:
    linear-gradient(45deg, #f1f5f9 25%, transparent 25%),
    linear-gradient(-45deg, #f1f5f9 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #f1f5f9 75%),
    linear-gradient(-45deg, transparent 75%, #f1f5f9 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  border: 1px solid var(--border);
  object-fit: contain;
}
.image-preview-meta {
  display: flex; flex-direction: column; gap: 8px;
  justify-content: space-between; flex: 1; min-width: 0;
}
.image-preview-meta .btn { width: auto; }

/* =========================================================
   Code
   ========================================================= */
code {
  background: var(--surface-2);
  padding: 1px 6px; border-radius: 5px;
  font-size: .82em;
  font-family: ui-monospace, Menlo, Consolas, monospace;
}

/* =========================================================
   PDF417 routing
   ========================================================= */
#fmSectionRouting .fm-row { margin-bottom: 0; }

/* =========================================================
   Tracking Manager Modal
   ========================================================= */
.tracking-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 0; border-bottom: 1px solid var(--border-soft);
}
.tracking-row:last-child { border-bottom: none; }
.tracking-num {
  font-family: ui-monospace, monospace; font-size: .85rem; color: var(--text-2);
}
.tracking-status {
  font-size: .72rem; padding: 3px 8px; border-radius: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
}
.tracking-status.used { background: var(--rose-soft); color: var(--rose); }
.tracking-status.avail { background: var(--emerald-soft); color: var(--emerald); }

/* =========================================================
   Responsive
   ========================================================= */
@media (max-width: 700px) {
  body { padding: 12px; }
  .topbar { padding: 12px 16px; }
  .brand-title { font-size: 1rem; }
  .tab { padding: 8px 12px; font-size: .78rem; }
  .modal-panel { width: 95vw; }
}