:root {
    --bg: #f5f7fb;
    --card: #ffffff;
    --text: #1f2937;
    --muted: #6b7280;
    --line: #d7dde8;
    --primary: #1d4ed8;
    --primary-dark: #1e40af;
    --success-bg: #ecfdf5;
    --success: #047857;
    --error-bg: #fef2f2;
    --error: #b91c1c;
    --danger: #dc2626;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    background: var(--bg);
    color: var(--text);
}
.container {
    width: min(1280px, calc(100% - 24px));
    margin: 0 auto;
}
.topbar {
    background: #0f172a;
    color: white;
    padding: 16px 0;
    box-shadow: 0 4px 24px rgba(0,0,0,.08);
}
.nav-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: center;
    justify-content: space-between;
}
.brand {
    margin: 0;
    font-size: 1.5rem;
}
.subtitle {
    margin: 4px 0 0;
    color: #cbd5e1;
    font-size: .95rem;
}
.nav {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    flex: 1 1 480px;
}
.nav a {
    color: white;
    text-decoration: none;
    padding: 10px 12px;
    border-radius: 10px;
}
.nav a:hover { background: rgba(255,255,255,.12); }
.user-box {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #e2e8f0;
}
.main-content { padding: 24px 0 40px; }
.grid {
    display: grid;
    gap: 16px;
}
.grid.two { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 18px;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.05);
}
.narrow-card { max-width: 760px; }
.auth-shell {
    min-height: calc(100vh - 180px);
    display: grid;
    place-items: center;
}
.auth-card {
    width: min(460px, 100%);
}
.stat-card { text-align: center; }
.stat-label { color: var(--muted); margin-bottom: 8px; }
.stat-value { font-size: 2rem; font-weight: 700; }
.button-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}
.compact-row { gap: 6px; }
.button {
    display: inline-block;
    background: var(--primary);
    color: white;
    border: 0;
    border-radius: 12px;
    padding: 10px 14px;
    cursor: pointer;
    text-decoration: none;
    font-size: .95rem;
}
.button:hover { background: var(--primary-dark); }
.button.secondary {
    background: #e5e7eb;
    color: #111827;
}
.button.danger {
    background: var(--danger);
}
.button-small {
    padding: 7px 10px;
    font-size: 0.85rem;
}
.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 14px;
}
.table-wrap form { margin: 0; }
table {
    width: 100%;
    border-collapse: collapse;
    min-width: 980px;
    background: white;
}
th, td {
    padding: 12px 10px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}
th {
    background: #eef2ff;
    white-space: nowrap;
}
.empty { text-align: center; color: var(--muted); }
label {
    font-weight: 600;
    margin-bottom: 6px;
    display: block;
}
input, textarea, select {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 12px;
    font-size: 1rem;
    background: white;
}
textarea { resize: vertical; }
.form-grid > * + * { margin-top: 12px; }
.inline-form > * + * { margin-top: 12px; }
.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 12px;
    align-items: end;
}
.single-line-form { align-items: end; }
.filter-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: end;
}
.flash-stack { margin-bottom: 16px; }
.flash {
    padding: 12px 14px;
    border-radius: 12px;
    margin-bottom: 10px;
    border: 1px solid transparent;
}
.flash.success {
    background: var(--success-bg);
    color: var(--success);
    border-color: #a7f3d0;
}
.flash.error {
    background: var(--error-bg);
    color: var(--error);
    border-color: #fecaca;
}
.info-box {
    padding: 14px;
    border-radius: 14px;
    background: #f8fafc;
    border: 1px solid var(--line);
    line-height: 1.7;
}
.success-box {
    background: #f0fdf4;
    border-color: #bbf7d0;
}
.scanner-box {
    width: 100%;
    min-height: 280px;
    border: 2px dashed #94a3b8;
    border-radius: 14px;
    overflow: hidden;
    background: #f8fafc;
}
.labels-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}
.label-card {
    background: white;
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 16px;
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 16px;
    align-items: center;
}
.label-card img {
    width: 120px;
    height: 120px;
    object-fit: contain;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 8px;
    background: white;
}
.label-text {
    line-height: 1.5;
}
.summary-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 18px;
    color: var(--muted);
}
.muted-text { color: var(--muted); }
.hint, .top-gap { margin-top: 14px; }
.bottom-gap { margin-bottom: 14px; }
@media (max-width: 720px) {
    .nav-wrap { align-items: flex-start; }
    .nav { width: 100%; }
    .user-box { width: 100%; justify-content: space-between; }
    table { min-width: 780px; }
    .label-card { grid-template-columns: 1fr; text-align: center; }
    .label-card img { margin: 0 auto; }
}
@media print {
    body { background: white; }
    .topbar, .flash-stack, .print-hidden { display: none !important; }
    .main-content { padding: 0; }
    .label-card { break-inside: avoid; box-shadow: none; }
}
