/* HPI Invoice System — Frontend CSS */
.hpi-app { max-width: 900px; margin: 0 auto; padding: 1rem; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; color: #1a1a1a; }
.hpi-public { max-width: 800px; margin: 0 auto; padding: 1.5rem; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; }

/* Header */
.hpi-header { display: flex; align-items: center; justify-content: space-between; padding-bottom: 1rem; margin-bottom: 1.25rem; border-bottom: 1px solid #e5e5e5; }
.hpi-logo-area strong { display: block; font-size: 16px; font-weight: 700; letter-spacing: -0.3px; }
.hpi-logo-area span  { font-size: 12px; color: #666; }

/* Steps */
.hpi-step-bar, .hpi-packing-steps { display: flex; border: 1px solid #e5e5e5; border-radius: 8px; overflow: hidden; margin-bottom: 1.25rem; }
.hpi-step, .hpi-pk-step { flex: 1; padding: 8px 12px; font-size: 12px; text-align: center; color: #888; background: #f7f7f7; border-right: 1px solid #e5e5e5; }
.hpi-step:last-child, .hpi-pk-step:last-child { border-right: none; }
.hpi-step.active, .hpi-pk-step.active { background: #fff; color: #1a1a1a; font-weight: 600; }
.hpi-step.done { background: #f0fdf4; color: #16a34a; }

/* Card */
.hpi-card { background: #fff; border: 1px solid #e5e5e5; border-radius: 10px; padding: 1rem 1.25rem; margin-bottom: 1rem; }
.hpi-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.75rem; }
.hpi-card-title { font-size: 11px; font-weight: 600; color: #888; text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 0.75rem; }

/* Form */
.hpi-form-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.hpi-field label { display: block; font-size: 11px; color: #666; margin-bottom: 4px; }
.hpi-field input, .hpi-field select { width: 100%; padding: 7px 10px; font-size: 13px; border: 1px solid #ddd; border-radius: 6px; background: #fafafa; color: #1a1a1a; font-family: inherit; }
.hpi-field input:focus, .hpi-field select:focus { outline: none; border-color: #999; background: #fff; }

/* Buttons */
.hpi-btn { display: inline-flex; align-items: center; gap: 5px; padding: 8px 14px; border-radius: 6px; border: 1px solid #ddd; background: transparent; font-size: 13px; cursor: pointer; font-family: inherit; color: #1a1a1a; text-decoration: none; transition: background 0.12s; }
.hpi-btn:hover { background: #f3f3f3; }
.hpi-btn-primary { background: #1a1a1a; color: #fff; border-color: #1a1a1a; }
.hpi-btn-primary:hover { background: #333; color: #fff; }
.hpi-btn-sm { padding: 4px 9px; font-size: 12px; }
.hpi-btn-outline { background: transparent; }

/* Upload zone */
.hpi-upload-zone { border: 2px dashed #ddd; border-radius: 10px; padding: 2.5rem; text-align: center; cursor: pointer; transition: border-color 0.15s, background 0.15s; }
.hpi-upload-zone:hover, .hpi-upload-zone.hpi-drag-over { border-color: #999; background: #f9f9f9; }
.hpi-upload-icon { font-size: 32px; display: block; margin-bottom: 0.75rem; }
.hpi-upload-zone h3 { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.hpi-upload-zone p { font-size: 13px; color: #666; }
.hpi-upload-actions { display: flex; justify-content: center; gap: 8px; margin-top: 1rem; }
.hpi-sub { font-size: 12px; color: #999; margin-top: 4px !important; }

/* Processing */
.hpi-processing { text-align: center; padding: 3rem; }
.hpi-spinner { display: inline-block; width: 30px; height: 30px; border: 2px solid #eee; border-top-color: #1a1a1a; border-radius: 50%; animation: hpi-spin 0.8s linear infinite; margin-bottom: 1rem; }
@keyframes hpi-spin { to { transform: rotate(360deg); } }
#hpi-process-msg { font-size: 14px; font-weight: 500; }

/* Table */
.hpi-table-wrap, .hpi-table-scroll { overflow-x: auto; }
.hpi-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.hpi-table th { text-align: left; padding: 7px 8px; font-size: 11px; font-weight: 600; color: #666; border-bottom: 1px solid #e5e5e5; white-space: nowrap; }
.hpi-table td { padding: 6px 8px; border-bottom: 1px solid #f0f0f0; vertical-align: middle; }
.hpi-table tbody tr:last-child td { border-bottom: none; }
.hpi-editable-table td input { width: 100%; padding: 3px 5px; font-size: 12px; border: 1px solid transparent; border-radius: 4px; background: transparent; color: #1a1a1a; font-family: inherit; }
.hpi-editable-table td input:focus { border-color: #ddd; background: #fafafa; outline: none; }

/* Summary bar */
.hpi-summary-bar { display: flex; gap: 10px; margin-bottom: 1rem; flex-wrap: wrap; }
.hpi-sum-card { flex: 1; min-width: 80px; background: #f7f7f7; border-radius: 6px; padding: 10px 12px; }
.hpi-sum-label { font-size: 11px; color: #888; margin-bottom: 3px; }
.hpi-sum-val { font-size: 20px; font-weight: 600; }
.hpi-sum-ok .hpi-sum-val { color: #16a34a; }
.hpi-sum-danger .hpi-sum-val { color: #dc2626; }

/* Actions */
.hpi-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 1rem; padding-top: 1rem; border-top: 1px solid #f0f0f0; flex-wrap: wrap; }
.hpi-actions-cell { display: flex; gap: 4px; }

/* Notice */
.hpi-notice { padding: 10px 14px; border-radius: 6px; font-size: 13px; margin-bottom: 1rem; display: flex; align-items: center; gap: 8px; }
.hpi-notice-success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.hpi-notice-warning { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }

/* Badges */
.hpi-badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.hpi-badge-received  { background: #dbeafe; color: #1e40af; }
.hpi-badge-production{ background: #fef9c3; color: #854d0e; }
.hpi-badge-shipped   { background: #dcfce7; color: #166534; }
.hpi-pill { display: inline-block; border: 1px solid #e5e5e5; border-radius: 4px; padding: 1px 6px; font-size: 11px; margin: 1px; }
.hpi-box-badge { font-size: 13px; font-weight: 700; background: #1a1a1a; color: #fff; padding: 4px 10px; border-radius: 6px; }

/* Meta grid */
.hpi-meta-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 1.25rem; }
.hpi-meta-item label { display: block; font-size: 11px; color: #888; margin-bottom: 2px; }
.hpi-meta-item span  { font-size: 14px; font-weight: 500; }
.hpi-section-title { font-size: 13px; font-weight: 600; color: #666; text-transform: uppercase; letter-spacing: 0.05em; margin: 1.25rem 0 0.5rem; }

/* Boxes grid */
.hpi-boxes-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.hpi-box-card { background: #fff; border: 1px solid #e5e5e5; border-radius: 8px; padding: 12px; }
.hpi-box-header { font-size: 13px; font-weight: 600; margin-bottom: 8px; }
.hpi-checkpoints { margin-bottom: 8px; }
.hpi-cp { display: flex; align-items: center; gap: 6px; font-size: 12px; color: #888; margin-bottom: 3px; }
.hpi-cp.hpi-cp-done { color: #16a34a; }
.hpi-cp-icon { width: 14px; height: 14px; border: 1px solid #ccc; border-radius: 3px; display: inline-flex; align-items: center; justify-content: center; font-size: 10px; flex-shrink: 0; }
.hpi-cp.hpi-cp-done .hpi-cp-icon { background: #16a34a; border-color: #16a34a; color: #fff; }
.hpi-box-contents { list-style: none; font-size: 11px; color: #666; padding: 0; margin: 0; }
.hpi-box-contents li { padding: 2px 0; border-bottom: 1px solid #f5f5f5; }

/* QR */
.hpi-qr-wrap { text-align: center; margin-top: 1.5rem; padding-top: 1.5rem; border-top: 1px solid #e5e5e5; }
.hpi-qr-wrap p { font-size: 12px; color: #888; margin-top: 6px; }

/* Timeline */
.hpi-timeline { margin: 0; padding: 0; }
.hpi-timeline-item { display: flex; align-items: flex-start; gap: 12px; padding: 10px 0; border-bottom: 1px solid #f0f0f0; }
.hpi-timeline-item:last-child { border-bottom: none; }
.hpi-tl-dot { width: 14px; height: 14px; border: 2px solid #ddd; border-radius: 50%; flex-shrink: 0; margin-top: 3px; }
.hpi-timeline-item.done .hpi-tl-dot { background: #16a34a; border-color: #16a34a; }
.hpi-tl-body strong { display: block; font-size: 13px; font-weight: 600; }
.hpi-tl-body span { font-size: 12px; color: #666; }
.hpi-pending { color: #999; font-style: italic; }

/* Dymo label preview */
.hpi-label-wrap { margin-bottom: 1rem; }
.hpi-label-hint { font-size: 11px; color: #888; margin-bottom: 6px; }
.hpi-dymo-label { background: #fff; border: 1px solid #ccc; border-radius: 4px; width: 384px; min-height: 226px; padding: 10px 12px; font-family: Arial, sans-serif; color: #111; font-size: 11px; }
.hpi-lbl-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 5px; }
.hpi-lbl-brand { font-size: 13px; font-weight: 700; letter-spacing: -0.3px; }
.hpi-lbl-sub { font-size: 9px; color: #666; }
.hpi-lbl-inv { font-size: 12px; font-weight: 700; }
.hpi-lbl-meta { margin: 3px 0; font-size: 9px; }
.hpi-lbl-pills { margin: 3px 0; }
.hpi-lbl-footer { display: flex; align-items: flex-end; margin-top: 6px; border-top: 1px solid #eee; padding-top: 5px; }
.hpi-lbl-checks { flex: 1; }
.hpi-lbl-check { display: flex; align-items: center; gap: 5px; margin-bottom: 4px; font-size: 9px; }
.hpi-chk-box { width: 12px; height: 12px; border: 1px solid #333; border-radius: 2px; flex-shrink: 0; }
.hpi-lbl-qr { width: 56px; height: 56px; flex-shrink: 0; }

/* Packing slip */
.hpi-packing-slip { background: #fff; border: 1px solid #ddd; border-radius: 6px; padding: 1.5rem; margin-bottom: 1.5rem; max-width: 680px; }
.hpi-ps-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 1rem; padding-bottom: 0.75rem; border-bottom: 1px solid #eee; }
.hpi-ps-brand { font-size: 18px; font-weight: 700; }
.hpi-ps-sub { font-size: 11px; color: #888; }
.hpi-ps-box-badge { font-size: 18px; font-weight: 700; background: #1a1a1a; color: #fff; padding: 6px 14px; border-radius: 6px; }
.hpi-ps-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 16px; font-size: 13px; margin-bottom: 1rem; }
.hpi-ps-table { width: 100%; border-collapse: collapse; font-size: 13px; margin-bottom: 1rem; }
.hpi-ps-table th { text-align: left; padding: 6px 8px; border-bottom: 2px solid #333; font-weight: 600; }
.hpi-ps-table td { padding: 6px 8px; border-bottom: 1px solid #eee; }
.hpi-ps-footer { display: flex; align-items: flex-end; gap: 1rem; padding-top: 0.75rem; border-top: 1px solid #eee; }
.hpi-ps-checks { flex: 1; }
.hpi-ps-check { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 12px; }
.hpi-ps-qr { flex-shrink: 0; }
.hpi-print-break { page-break-after: always; height: 1px; }

/* Tabs */
.hpi-tab-bar { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 0.75rem; }
.hpi-tab { padding: 6px 12px; font-size: 12px; cursor: pointer; background: #f7f7f7; border: 1px solid #ddd; border-radius: 6px; font-family: inherit; color: #666; transition: background 0.12s; }
.hpi-tab.active { background: #1a1a1a; color: #fff; border-color: #1a1a1a; }

/* List page */
.hpi-list-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.25rem; }
.hpi-list-header h2 { font-size: 18px; font-weight: 600; }
.hpi-empty-state { padding: 2rem; text-align: center; color: #888; }
.hpi-empty { color: #aaa; font-size: 13px; padding: 0.5rem 0; }

/* Responsive */
@media (max-width: 600px) {
  .hpi-form-grid, .hpi-meta-grid { grid-template-columns: 1fr 1fr; }
  .hpi-dymo-label { width: 100%; }
}

/* Print styles */
@media print {
  .hpi-actions, .hpi-step-bar, .hpi-packing-steps, .hpi-notice, .hpi-card:not(.hpi-packing-slip) { display: none !important; }
  .hpi-packing-slip { border: none; padding: 0; }
  .hpi-print-page { page-break-after: always; }
}
