/* Receive Deliveries: goods-in counted on a phone in the stockroom. One-thumb use, large targets, no animation loops,
   safe-area padding. Uses the app tokens so light/dark both work. */

.rcv-topbar-logo { height: 34px; width: 34px; display: block; }

.rcv-body {
    position: relative;
    flex: 1;
    overflow-y: auto;
    padding: var(--space-4) var(--space-4) calc(var(--space-8) + env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.rcv-wrap { width: 100%; max-width: 720px; margin: 0 auto; display: flex; flex-direction: column; gap: var(--space-4); }

.rcv-title { font-size: var(--text-xl); font-weight: 700; line-height: 1.2; margin: 0; }
.rcv-sub { color: var(--text-muted); font-size: var(--text-sm); }

/* Delivery list */
.rcv-card {
    display: flex; flex-direction: column; gap: var(--space-2);
    padding: var(--space-4); border-radius: var(--radius-lg);
    background: var(--bg-surface); border: 1px solid var(--border);
    color: inherit; text-decoration: none;
}
.rcv-card:active { background: var(--bg-hover); }
.rcv-card-top { display: flex; justify-content: space-between; gap: var(--space-3); align-items: baseline; }
.rcv-card-name { font-weight: 700; font-size: var(--text-lg); }

.rcv-progress { height: 8px; border-radius: 999px; background: var(--bg-surface-2); overflow: hidden; }
.rcv-progress-fill { height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent), var(--lime)); }
.rcv-progress-row { display: flex; justify-content: space-between; font-size: var(--text-sm); color: var(--text-secondary); font-variant-numeric: tabular-nums; }

/* Counting page: sticky tools */
.rcv-tools {
    position: sticky; top: calc(-1 * var(--space-4)); z-index: 5;
    margin: calc(-1 * var(--space-4)) calc(-1 * var(--space-4)) 0;
    padding: var(--space-3) var(--space-4);
    background: var(--bg-canvas); border-bottom: 1px solid var(--border);
    display: flex; flex-direction: column; gap: var(--space-3);
}
.rcv-search { display: flex; gap: var(--space-2); }
.rcv-search .search-input { flex: 1; }
.rcv-search input { font-size: 16px; min-height: 46px; }
.rcv-icon-btn {
    flex-shrink: 0; width: 48px; height: 48px; border-radius: var(--radius-md);
    display: inline-grid; place-items: center; border: 1px solid var(--border);
    background: var(--bg-surface-2); color: var(--text-primary); cursor: pointer;
}
.rcv-icon-btn.accent { background: var(--accent); color: var(--text-on-accent); border-color: var(--accent); }

.rcv-filter { display: flex; gap: 4px; padding: 3px; border-radius: var(--radius-md); background: var(--bg-surface-2); border: 1px solid var(--border); }
.rcv-filter button {
    flex: 1; min-height: 40px; border: 0; background: none; border-radius: 8px; cursor: pointer;
    font: inherit; font-size: var(--text-sm); font-weight: 600; color: var(--text-secondary);
}
.rcv-filter button.on { background: var(--bg-surface); color: var(--text-primary); box-shadow: var(--shadow-sm); }

/* Item rows */
.rcv-list { display: flex; flex-direction: column; gap: var(--space-2); }
.rcv-item {
    display: grid; grid-template-columns: 1fr auto; gap: 4px var(--space-3); align-items: center;
    width: 100%; text-align: left; cursor: pointer; font: inherit; color: inherit;
    padding: var(--space-3) var(--space-4); border-radius: var(--radius-lg);
    background: var(--bg-surface); border: 1px solid var(--border); border-left: 4px solid var(--border-strong);
}
.rcv-item.done { border-left-color: var(--success); }
.rcv-item.started { border-left-color: var(--warning); }
.rcv-item-name { font-weight: 700; line-height: 1.25; }
.rcv-item-sub { font-size: var(--text-sm); color: var(--text-muted); line-height: 1.3; }
.rcv-item-qty { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.rcv-tags { display: flex; flex-wrap: wrap; gap: 4px; grid-column: 1 / -1; }

/* Item editor: full screen on a phone, centred column on bigger screens */
.rcv-sheet {
    position: fixed; inset: 0; z-index: 50; background: var(--bg-canvas);
    display: flex; flex-direction: column;
}
.rcv-sheet-head {
    display: flex; align-items: center; gap: var(--space-3);
    padding: calc(var(--space-3) + env(safe-area-inset-top)) var(--space-4) var(--space-3);
    background: var(--bg-surface); border-bottom: 1px solid var(--border);
}
.rcv-sheet-title { flex: 1; min-width: 0; font-weight: 700; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.rcv-sheet-body { flex: 1; overflow-y: auto; padding: var(--space-4) var(--space-4) calc(var(--space-6) + env(safe-area-inset-bottom)); }
.rcv-sheet-inner { max-width: 640px; margin: 0 auto; display: flex; flex-direction: column; gap: var(--space-5); }
.rcv-sheet-foot {
    display: flex; gap: var(--space-2); padding: var(--space-3) var(--space-4) calc(var(--space-3) + env(safe-area-inset-bottom));
    background: var(--bg-surface); border-top: 1px solid var(--border);
}
.rcv-sheet-foot .btn { flex: 1; min-height: 48px; }

.rcv-block { display: flex; flex-direction: column; gap: var(--space-2); }
.rcv-label { font-size: var(--text-sm); font-weight: 700; color: var(--text-secondary); display: flex; justify-content: space-between; gap: var(--space-2); }
.rcv-info { padding: var(--space-3); border-radius: var(--radius-md); background: var(--bg-surface); border: 1px solid var(--border); font-size: var(--text-sm); color: var(--text-secondary); display: grid; gap: 4px; }
.rcv-info b { color: var(--text-primary); }

/* Big +/- quantity control */
.rcv-qty { display: grid; grid-template-columns: 64px 1fr 64px; gap: var(--space-2); }
.rcv-qty button {
    height: 60px; border-radius: var(--radius-md); border: 1px solid var(--border);
    background: var(--bg-surface-2); color: var(--text-primary); font-size: 30px; font-weight: 700; line-height: 1; cursor: pointer;
    touch-action: manipulation;
}
.rcv-qty button:active { background: var(--accent); color: var(--text-on-accent); }
.rcv-qty input { height: 60px; text-align: center; font-size: 26px !important; font-weight: 700; font-variant-numeric: tabular-nums; }
.rcv-qty.small { grid-template-columns: 52px 1fr 52px; }
.rcv-qty.small button { height: 48px; font-size: 24px; }
.rcv-qty.small input { height: 48px; font-size: 20px !important; }
.rcv-quick { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.rcv-quick .btn { min-height: 44px; }

/* Date: a big button showing dd.MM.yyyy with the real date input laid invisibly on top (tap = phone calendar) */
.rcv-date { position: relative; flex: 1; min-width: 0; }
.rcv-date-face {
    display: flex; align-items: center; justify-content: space-between; gap: var(--space-2);
    min-height: 52px; padding: 0 var(--space-4); border-radius: var(--radius-md);
    border: 1px solid var(--border-strong); background: var(--bg-surface); font-size: 20px; font-weight: 700;
    font-variant-numeric: tabular-nums; pointer-events: none;
}
.rcv-date-face.empty { color: var(--text-muted); font-weight: 600; font-size: var(--text-md); }
.rcv-date input[type="date"] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.rcv-row { display: flex; gap: var(--space-2); align-items: center; }
.rcv-check { display: flex; gap: var(--space-3); align-items: center; min-height: 44px; font-weight: 600; }
.rcv-check input { width: 22px; height: 22px; }

.rcv-lot { display: grid; grid-template-columns: 1fr 1.2fr 44px; gap: var(--space-2); align-items: center; }
.rcv-lot .rcv-date-face { min-height: 48px; font-size: 17px; }
.rcv-lot input.rcv-lot-qty { height: 48px; text-align: center; font-size: 18px; font-weight: 700; }

.rcv-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.rcv-chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 999px; font-size: var(--text-sm); font-family: var(--font-mono); background: var(--bg-surface-2); border: 1px solid var(--border); }
.rcv-chip.new { border-color: var(--lime); }
.rcv-chip button { border: 0; background: none; color: var(--text-muted); cursor: pointer; padding: 0 2px; font-size: 16px; line-height: 1; }

.rcv-photo { max-width: 100%; max-height: 220px; border-radius: var(--radius-md); border: 1px solid var(--border); display: block; }
.rcv-file { position: relative; overflow: hidden; display: inline-flex; }
.rcv-file input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; font-size: 0; }

.rcv-status { font-size: var(--text-sm); color: var(--text-muted); display: flex; align-items: center; gap: 6px; }
.rcv-status.ok { color: var(--success); }
.rcv-status.bad { color: var(--danger); }

/* Camera overlay */
.rcv-scanner { position: fixed; inset: 0; z-index: 70; background: #000; display: flex; flex-direction: column; }
.rcv-scanner video { flex: 1; width: 100%; height: 100%; object-fit: cover; }
.rcv-scanner-bar {
    position: absolute; left: 0; right: 0; top: 0; display: flex; justify-content: space-between; align-items: center;
    padding: calc(var(--space-3) + env(safe-area-inset-top)) var(--space-4) var(--space-3); color: #fff;
    background: linear-gradient(rgba(0, 0, 0, .65), transparent); font-weight: 600;
}
.rcv-scanner-bar button { width: 46px; height: 46px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, .18); color: #fff; display: grid; place-items: center; cursor: pointer; }
.rcv-scanner-frame { position: absolute; left: 12%; right: 12%; top: 34%; height: 22%; border: 3px solid rgba(166, 206, 57, .9); border-radius: 16px; pointer-events: none; }
.rcv-scanner-hint { position: absolute; left: 0; right: 0; bottom: calc(var(--space-8) + env(safe-area-inset-bottom)); text-align: center; color: #fff; text-shadow: 0 1px 3px #000; padding: 0 var(--space-4); }

@media (min-width: 900px) {
    .rcv-sheet { left: 50%; transform: translateX(-50%); width: 720px; border-left: 1px solid var(--border); border-right: 1px solid var(--border); }
}

/* Invoice page, Goods-in on phones: count statistics */
.gi-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: var(--space-2); margin-bottom: var(--space-4); }
.gi-stat { display: flex; flex-direction: column; gap: 2px; padding: var(--space-2) var(--space-3); border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--bg-surface-2); }
.gi-stat-value { font-size: var(--text-xl); font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; color: var(--text-primary); }
.gi-stat-label { font-size: var(--text-xs); color: var(--text-muted); }
.gi-stat.warn .gi-stat-value { color: var(--warning); }
.gi-stat.bad { border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); }
.gi-stat.bad .gi-stat-value { color: var(--danger); }
