:root {
  color-scheme: light;
  --ink: #102a43;
  --muted: #627d98;
  --line: #d9e2ec;
  --paper: #ffffff;
  --canvas: #f2f6fa;
  --brand: #0f6b54;
  --brand-dark: #0a4d3d;
  --accent: #f2b134;
  --danger: #b42318;
  --shadow: 0 12px 32px rgba(16, 42, 67, .10);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; color: var(--ink); background: var(--canvas); }
button, input, select { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.eyebrow { margin: 0 0 .3rem; color: var(--brand); font-size: .73rem; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: .55rem; font-size: clamp(1.6rem, 3vw, 2.4rem); line-height: 1.12; }
h2 { margin-bottom: .3rem; }
.login-view { min-height: 100vh; display: grid; place-items: center; padding: 1rem; background: linear-gradient(135deg, rgba(8,37,27,.76), rgba(18,61,43,.48)), url('/poultry-house.png') center / cover fixed; }
.login-card { width: min(420px, 100%); padding: 2.2rem; background: var(--paper); border: 1px solid rgba(255,255,255,.8); border-radius: 24px; box-shadow: var(--shadow); }
.login-card h1 { font-size: 1.8rem; margin-bottom: 1.5rem; }
.project-credit { margin: -1rem 0 1.4rem; color: var(--muted); font-size: .82rem; font-weight: 750; letter-spacing: .04em; }
.brand-mark { display: grid; place-items: center; width: 64px; height: 64px; margin-bottom: 1.2rem; color: white; background: var(--brand); border-radius: 18px; font-weight: 900; letter-spacing: .04em; box-shadow: 0 8px 20px rgba(15,107,84,.25); }
.brand-mark.small { width: 44px; height: 44px; margin: 0; border-radius: 13px; font-size: .8rem; }
label { display: grid; gap: .4rem; margin-bottom: 1rem; color: #334e68; font-size: .86rem; font-weight: 700; }
input, select { min-width: 0; height: 46px; padding: 0 .85rem; color: var(--ink); background: white; border: 1px solid #bcccdc; border-radius: 11px; outline: none; }
input:focus, select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(15,107,84,.12); }
.primary, .ghost, .scan-button, .danger-button { min-height: 44px; padding: .7rem 1rem; border-radius: 11px; font-weight: 800; border: 1px solid transparent; }
.primary { color: white; background: var(--brand); }
.primary:hover { background: var(--brand-dark); }
.primary:disabled { opacity: .45; cursor: not-allowed; }
.ghost { color: var(--ink); background: white; border-color: var(--line); }
.danger-button { color: var(--danger); background: #fff4f2; border-color: #fecdca; }
.compact { min-height: 38px; padding: .45rem .75rem; }
.wide { width: 100%; }
.error { min-height: 1.2rem; margin: .3rem 0 .8rem; color: var(--danger); font-size: .86rem; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 1rem; height: 72px; padding: 0 max(1rem, calc((100vw - 1240px)/2)); background: rgba(255,255,255,.94); border-bottom: 1px solid var(--line); backdrop-filter: blur(12px); }
.brand { display: flex; align-items: center; gap: .7rem; }
.brand strong, .brand span { display: block; }
.brand span { color: var(--muted); font-size: .76rem; }
.topbar-actions { display: flex; align-items: center; gap: .7rem; }
.current-user { padding: .35rem .6rem; color: var(--ink); background: #eef3f7; border-radius: 999px; font-size: .78rem; font-weight: 850; }
.online-state { color: var(--brand); font-size: .8rem; font-weight: 800; }
.tabs { display: flex; gap: .35rem; padding: .75rem max(1rem, calc((100vw - 1240px)/2)); background: var(--paper); border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab { padding: .65rem 1rem; color: var(--muted); background: transparent; border: 0; border-radius: 10px; font-weight: 800; white-space: nowrap; }
.tab.active { color: var(--brand-dark); background: #e5f4ef; }
main { width: min(1240px, calc(100% - 2rem)); margin: 0 auto; padding: 1.4rem 0 4rem; }
.hero { display: flex; justify-content: space-between; align-items: center; gap: 1rem; min-height: 230px; padding: clamp(1.3rem, 3vw, 2.2rem); color: white; background: linear-gradient(90deg, rgba(8,35,25,.9), rgba(20,73,50,.48)), url('/poultry-house.png') center 47% / cover; border-radius: 22px; box-shadow: var(--shadow); }
.hero h1, .hero p { text-shadow: 0 2px 14px rgba(0,0,0,.55); }
.hero p:not(.eyebrow) { margin-bottom: 0; color: #d9e8ef; }
.hero .eyebrow { color: #91e5c9; }
.scan-button { display: flex; gap: .55rem; align-items: center; color: var(--ink); background: var(--accent); white-space: nowrap; }
.scan-button span { font-size: 1.5rem; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: .8rem; margin: 1rem 0; }
.stat { padding: 1rem 1.1rem; background: var(--paper); border: 1px solid var(--line); border-radius: 15px; }
.stat strong { display: block; font-size: 1.55rem; }
.stat span { color: var(--muted); font-size: .78rem; }
.search-panel, .scanner-card { margin-top: 1rem; padding: 1rem; background: var(--paper); border: 1px solid var(--line); border-radius: 17px; }
.search-line { display: flex; gap: .6rem; }
.search-field { flex: 1; margin: 0; }
.search-line input { width: 100%; }
.filters { display: grid; grid-template-columns: repeat(3, 1fr); gap: .7rem; margin-top: .8rem; }
.filters label { margin: 0; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 1rem; margin: 1.8rem 0 .8rem; }
.section-heading h1, .section-heading h2 { margin: 0; }
.count-badge { min-width: 36px; padding: .35rem .65rem; text-align: center; color: var(--brand-dark); background: #dff3ec; border-radius: 999px; font-weight: 900; }
.results { overflow: hidden; background: var(--paper); border: 1px solid var(--line); border-radius: 17px; }
.result-head, .result-row { display: grid; grid-template-columns: 130px minmax(260px, 1.8fr) 80px 145px 130px 120px 135px; gap: .7rem; align-items: center; padding: .8rem 1rem; }
.result-head { color: var(--muted); background: #f7f9fb; border-bottom: 1px solid var(--line); font-size: .7rem; font-weight: 900; text-transform: uppercase; }
.result-row { border-bottom: 1px solid #e8eef3; }
.result-row:last-child { border-bottom: 0; }
.result-row:hover { background: #f8fcfa; }
.article { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-weight: 900; }
.item-name { font-weight: 750; line-height: 1.35; }
.meta-mobile { display: none; }
.badge { display: inline-flex; width: fit-content; padding: .3rem .55rem; border-radius: 999px; font-size: .72rem; font-weight: 850; }
.badge.direction { color: #175cd3; background: #eff8ff; }
.badge.origin { color: #6941c6; background: #f4f3ff; }
.badge.location { color: #067647; background: #ecfdf3; }
.link-button { padding: .2rem 0; color: var(--brand); background: none; border: 0; font-weight: 900; text-align: left; }
.empty { padding: 2.5rem 1rem; color: var(--muted); text-align: center; }
.scanner-card { max-width: 760px; margin-inline: auto; }
.camera-shell { position: relative; display: grid; place-items: center; min-height: 320px; overflow: hidden; color: white; background: #0b1f30; border-radius: 16px; }
.camera-shell video { position: absolute; width: 100%; height: 100%; object-fit: cover; }
.scan-frame { position: absolute; z-index: 2; width: min(68vw, 300px); aspect-ratio: 1; border: 3px solid var(--accent); border-radius: 18px; box-shadow: 0 0 0 999px rgba(0,0,0,.34); }
.camera-shell p { z-index: 3; padding: .7rem; background: rgba(0,0,0,.45); border-radius: 9px; }
.scanner-actions { display: flex; gap: .6rem; margin: 1rem 0; }
.manual-scan { padding-top: 1rem; border-top: 1px solid var(--line); }
.hint { color: var(--muted); font-size: .82rem; }
.history { display: grid; gap: .7rem; }
.history-card { display: grid; grid-template-columns: 80px 1fr auto; gap: 1rem; align-items: center; padding: 1rem; background: white; border: 1px solid var(--line); border-radius: 14px; }
.history-card strong, .history-card span { display: block; }
.history-card time, .history-card small { color: var(--muted); }
.users-layout { display: grid; grid-template-columns: minmax(280px, 380px) 1fr; gap: 1rem; align-items: start; }
.user-form, .users-list { padding: 1.1rem; background: white; border: 1px solid var(--line); border-radius: 16px; }
.user-card { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: .7rem; padding: .85rem 0; border-bottom: 1px solid var(--line); }
.user-card:last-child { border-bottom: 0; }
.user-card strong, .user-card small { display: block; }
.user-card small { margin-top: .2rem; color: var(--muted); }
.back { margin-bottom: 1rem; padding: .4rem 0; color: var(--brand); background: transparent; border: 0; font-weight: 900; }
.package-header { display: flex; justify-content: space-between; gap: 1rem; padding: 1.4rem; color: white; background: linear-gradient(120deg, #102a43, #174d56); border-radius: 18px 18px 0 0; }
.package-header h1 { margin: 0; }
.package-status { align-self: start; padding: .45rem .7rem; color: var(--ink); background: var(--accent); border-radius: 999px; font-size: .75rem; font-weight: 900; }
.package-body { padding: 1.2rem; background: white; border: 1px solid var(--line); border-top: 0; border-radius: 0 0 18px 18px; }
.package-meta { display: grid; grid-template-columns: repeat(4, 1fr); gap: .7rem; margin-bottom: 1.2rem; }
.package-meta div { padding: .8rem; background: #f5f8fa; border-radius: 11px; }
.package-meta span, .package-meta strong { display: block; }
.package-meta span { margin-bottom: .25rem; color: var(--muted); font-size: .72rem; }
.package-items { width: 100%; border-collapse: collapse; }
.package-items th, .package-items td { padding: .75rem .55rem; text-align: left; border-bottom: 1px solid var(--line); }
.package-items th { color: var(--muted); font-size: .72rem; text-transform: uppercase; }
.package-items input { width: 20px; height: 20px; }
.package-actions { position: sticky; bottom: .7rem; display: flex; justify-content: flex-end; gap: .7rem; margin-top: 1rem; padding: .8rem; background: rgba(255,255,255,.94); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); backdrop-filter: blur(8px); }
dialog { width: min(560px, calc(100% - 1.4rem)); padding: 0; border: 0; border-radius: 19px; box-shadow: 0 28px 70px rgba(16,42,67,.3); }
dialog::backdrop { background: rgba(7,26,41,.62); backdrop-filter: blur(3px); }
dialog form { padding: 1.3rem; }
.dialog-heading { display: flex; justify-content: space-between; gap: 1rem; }
.icon-button { width: 40px; height: 40px; color: var(--muted); background: #f3f6f8; border: 0; border-radius: 50%; font-size: 1.5rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: .7rem; margin-top: 1rem; }
.toast { position: fixed; right: 1rem; bottom: 1rem; z-index: 50; max-width: 420px; padding: .9rem 1rem; color: white; background: var(--brand-dark); border-radius: 12px; box-shadow: var(--shadow); font-weight: 800; }
@media (max-width: 980px) {
  .result-head { display: none; }
  .result-row { grid-template-columns: 110px 1fr auto 145px; align-items: start; }
  .result-row > :nth-child(n+5) { display: none; }
  .meta-mobile { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .55rem; }
  .package-meta { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 680px) {
  .current-user { display: none; }
  .online-state { display: none; }
  main { width: min(100% - 1rem, 1240px); padding-top: .7rem; }
  .hero { align-items: stretch; flex-direction: column; border-radius: 17px; }
  .scan-button { justify-content: center; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .filters { grid-template-columns: 1fr; }
  .search-line { align-items: stretch; }
  .result-row { grid-template-columns: 1fr auto; gap: .4rem; padding: 1rem; }
  .result-row .article { grid-column: 1; }
  .result-row .item-cell { grid-column: 1 / -1; }
  .result-row .quantity { grid-column: 2; grid-row: 1; }
  .result-row .package-link { grid-column: 1 / -1; }
  .package-header { flex-direction: column; }
  .package-meta { grid-template-columns: 1fr 1fr; }
  .package-items thead { display: none; }
  .package-items tr { display: grid; grid-template-columns: 36px 1fr auto; padding: .7rem 0; border-bottom: 1px solid var(--line); }
  .package-items td { padding: .25rem; border: 0; }
  .package-items td:nth-child(2) { font-weight: 900; }
  .package-items td:nth-child(3) { grid-column: 2 / -1; }
  .package-actions { flex-direction: column; }
  .history-card { grid-template-columns: 55px 1fr; }
  .history-card time { grid-column: 2; }
  .users-layout { grid-template-columns: 1fr; }
  .login-card { padding: 1.4rem; }
}
