:root {
    --bg:          #f4f4f5;
    --card:        #ffffff;
    --text:        #18181b;
    --text-muted:  #71717a;
    --primary:     #e85d04;
    --primary-h:   #c44d00;
    --border:      #e4e4e7;
    --success:     #16a34a;
    --success-bg:  #f0fdf4;
    --success-br:  #bbf7d0;
    --error:       #dc2626;
    --error-bg:    #fef2f2;
    --error-br:    #fecaca;
    --radius:      10px;
}

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

body {
    background:  var(--bg);
    color:       var(--text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size:   16px;
    line-height: 1.5;
    min-height:  100vh;
    display:     flex;
    align-items: center;
    justify-content: center;
    padding:     16px;
}

.card {
    background:    var(--card);
    border-radius: var(--radius);
    padding:       36px 28px;
    width:         100%;
    max-width:     420px;
    box-shadow:    0 1px 3px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.06);
}

.logo { font-size: 48px; text-align: center; margin-bottom: 8px; }

h1 { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.card-header { margin-bottom: 24px; }
.subtitle     { color: var(--text-muted); font-size: 15px; margin-bottom: 24px; }

.form-group  { margin-bottom: 18px; }
label        { display: block; font-size: 14px; font-weight: 500; margin-bottom: 6px; }

input[type="password"],
input[type="number"] {
    width:         100%;
    padding:       12px 14px;
    border:        1px solid var(--border);
    border-radius: var(--radius);
    font-size:     16px;
    outline:       none;
    transition:    border-color .15s;
    appearance:    none;
    -webkit-appearance: none;
}
input:focus { border-color: var(--primary); }

.count-input {
    font-size:   52px;
    font-weight: 700;
    text-align:  center;
    padding:     16px;
    border:      2px solid var(--border);
}
.count-input:focus { border-color: var(--primary); }

.btn {
    display:       block;
    width:         100%;
    padding:       14px;
    background:    var(--primary);
    color:         #fff;
    border:        none;
    border-radius: var(--radius);
    font-size:     16px;
    font-weight:   600;
    cursor:        pointer;
    line-height:   1;
    transition:    background .15s;
}
.btn:hover    { background: var(--primary-h); }
.btn-outline  {
    background: transparent;
    color:      var(--primary);
    border:     2px solid var(--primary);
}
.btn-outline:hover { background: var(--primary); color: #fff; }

.alert {
    padding:       11px 14px;
    border-radius: var(--radius);
    font-size:     14px;
    margin-bottom: 18px;
    border:        1px solid transparent;
}
.alert-error   { background: var(--error-bg);   color: var(--error);   border-color: var(--error-br); }
.alert-success { background: var(--success-bg); color: var(--success); border-color: var(--success-br); }

.text-center  { text-align: center; }
.text-muted   { color: var(--text-muted); font-size: 14px; }

.success-icon {
    font-size:     56px;
    color:         var(--success);
    text-align:    center;
    margin-bottom: 12px;
}

.footer-links {
    text-align:  center;
    margin-top:  20px;
    font-size:   14px;
    color:       var(--text-muted);
}
.footer-links a { color: var(--primary); text-decoration: none; }
.footer-links a:hover { text-decoration: underline; }

.history-list   { display: flex; flex-direction: column; gap: 10px; margin-bottom: 8px; }
.history-item   { padding: 14px; border: 1px solid var(--border); border-radius: var(--radius); }
.history-main   { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.history-count  { font-weight: 600; }
.history-meta   { font-size: 13px; color: var(--text-muted); }

.status-badge {
    display:       inline-block;
    padding:       2px 9px;
    border-radius: 99px;
    font-size:     12px;
    font-weight:   500;
}
.status-pending   { background: #fef3c7; color: #92400e; }
.status-completed { background: #d1fae5; color: #065f46; }
.status-failed    { background: var(--error-bg); color: var(--error); }

/* ── Label preview ─────────────────────────────────────────────────────── */
.preview-heading {
    font-size:     13px;
    font-weight:   600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color:         var(--text-muted);
    margin-bottom: 10px;
    text-align:    center;
}

/* Outer wrapper clips the scaled inner div to the correct visual size */
.label-scale-wrap {
    width:    253px;   /* 290 * 0.87 */
    height:   420px;   /* 483 * 0.87 */
    overflow: hidden;
    margin:   0 auto;
}

/* Inner div is sized to 3×5 inches at 96dpi (288×480), then scaled down */
.label-preview {
    width:            290px;
    height:           483px;
    transform:        scale(0.87);
    transform-origin: top left;
    border:           1.5px solid #000;
    padding:          13px;
    font-family:      Arial, Helvetica, sans-serif;
    font-size:        12px;
    line-height:      1.3;
    display:          flex;
    flex-direction:   column;
}
.lp-org-name {
    font-size:    14px;
    font-weight:  bold;
    text-align:   center;
    margin-bottom: 2px;
}
.lp-org-address {
    font-size:     10px;
    text-align:    center;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid #000;
}
.lp-table { width: 100%; margin-bottom: 10px; border-collapse: collapse; }
.lp-table td { font-size: 12px; padding: 1px 0; vertical-align: top; }
.lp-field-label {
    font-size:      9px;
    font-weight:    bold;
    text-transform: uppercase;
    color:          #444;
    width:          90px;
}
.lp-date { font-size: 17px; font-weight: bold; }
.lp-spacer { flex: 1; }
.lp-allergy-box {
    border:  1.5px solid #000;
    padding: 6px 8px;
}
.lp-allergy-title {
    font-size:    13px;
    font-weight:  bold;
    text-align:   center;
    display:      block;
    margin-bottom: 3px;
}
.lp-allergy-sub {
    font-size:    10px;
    font-weight:  bold;
    display:      block;
    margin-bottom: 2px;
}
.lp-allergens   { font-size: 10px; font-weight: bold; margin-bottom: 3px; }
.lp-allergy-note { font-size: 9.5px; }
