:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --border: #d8dde7;
  --text: #1b2030;
  --muted: #6b7180;
  --accent: #2a5fdb;
  --accent-hover: #1e4cb6;
  --success: #1f8a4c;
  --warn: #c4621a;
  --error: #b8252e;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg); color: var(--text); line-height: 1.45;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

nav.topnav {
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 8px 16px; display: flex; gap: 16px; align-items: center;
  position: sticky; top: 0; z-index: 10;
}
nav.topnav .brand { font-weight: 700; font-size: 18px; margin-right: 12px; }
nav.topnav a { padding: 6px 10px; border-radius: 6px; color: var(--text); }
nav.topnav a:hover { background: var(--bg); text-decoration: none; }
nav.topnav .spacer { flex: 1; }
nav.topnav .user { color: var(--muted); font-size: 14px; }

main { max-width: 1100px; margin: 0 auto; padding: 16px; }
.scan-main { max-width: 720px; }

h1 { font-size: 22px; margin: 6px 0 14px; }
h2 { font-size: 18px; margin: 14px 0 8px; }

.flash { padding: 10px 14px; border-radius: 6px; margin: 10px 0; }
.flash.error { background: #fce8ea; color: var(--error); border: 1px solid #f4b8be; }
.flash.info  { background: #e8f3ff; color: var(--accent); border: 1px solid #b6d4ff; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
        padding: 14px; margin-bottom: 12px; }
.card.tight { padding: 10px 14px; }

button, input[type=submit], .btn {
  background: var(--accent); color: #fff; border: 0; padding: 9px 14px; border-radius: 6px;
  font-size: 14px; font-weight: 600; cursor: pointer;
}
button:hover, .btn:hover { background: var(--accent-hover); }
button.secondary, .btn.secondary {
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
}
button.secondary:hover { background: var(--bg); }
button.danger { background: var(--error); }

input[type=text], input[type=password], input[type=number], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 6px;
  font-size: 14px; font-family: inherit; background: var(--surface);
}
input.big { font-size: 22px; padding: 14px 14px; }

label { display: block; font-weight: 600; font-size: 13px; margin: 8px 0 4px; }
.row { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 100px; }

table { width: 100%; border-collapse: collapse; background: var(--surface); }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); font-size: 14px; }
th { background: #eef1f7; font-weight: 600; }
tbody tr:hover { background: #fafbfd; }

.muted { color: var(--muted); font-size: 13px; }
.tag { display: inline-block; padding: 2px 7px; border-radius: 999px; background: #eef1f7;
       font-size: 12px; color: var(--muted); }
.tag.identified { background: #e2f5e9; color: var(--success); }
.tag.unidentified { background: #fdecdc; color: var(--warn); }

.scan-header { display: grid; grid-template-columns: 1fr 1fr 110px; gap: 10px; }
@media (max-width: 600px) { .scan-header { grid-template-columns: 1fr 1fr; }
  .scan-header .qty-cell { grid-column: 1 / -1; } }

.last-scans li { padding: 6px 8px; border-bottom: 1px dashed var(--border);
                 list-style: none; font-size: 13px; }
.last-scans { padding: 0; margin: 0; }
.candidate { border: 1px solid var(--border); border-radius: 6px; padding: 10px; margin-bottom: 8px; }
.candidate img { max-width: 80px; max-height: 80px; float: right; }

form.inline { display: inline; }
