:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --accent: #1d4ed8;
  --accent-hover: #1e40af;
  --accent-soft: #e0e7ff;
  --focus: #2563eb;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --red: #b91c1c;    --red-bg: #fee2e2;
  --orange: #c2410c; --orange-bg: #ffedd5;
  --amber: #a16207;  --amber-bg: #fef9c3;
  --green: #15803d;  --green-bg: #dcfce7;
  --grey: #475569;   --grey-bg: #e2e8f0;
  --violet: #6d28d9; --violet-bg: #ede9fe;
  --shadow: 0 1px 2px rgb(15 23 42 / 6%), 0 4px 16px rgb(15 23 42 / 6%);
  --radius: 12px;
  color-scheme: light;
}

/* Dark palette: used when chosen in the app, or when the system is dark and "Világos" wasn't chosen. */
:root[data-theme="dark"] {
    --bg: #0b1120;
    --surface: #111827;
    --surface-2: #0f172a;
    --border: #1f2a3d;
    --text: #e5e7eb;
    --muted: #94a3b8;
    --accent: #3b82f6;
    --accent-hover: #60a5fa;
    --accent-soft: #1e293b;
    --focus: #60a5fa;
    --danger: #f87171;
    --danger-soft: #3f1d1d;
    --red: #fca5a5;    --red-bg: #3f1d1d;
    --orange: #fdba74; --orange-bg: #3d2410;
    --amber: #fde047;  --amber-bg: #34300f;
    --green: #86efac;  --green-bg: #12301f;
    --grey: #cbd5e1;   --grey-bg: #1f2937;
    --violet: #c4b5fd; --violet-bg: #2a2150;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 4px 16px rgb(0 0 0 / 25%);
    color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1120;
    --surface: #111827;
    --surface-2: #0f172a;
    --border: #1f2a3d;
    --text: #e5e7eb;
    --muted: #94a3b8;
    --accent: #3b82f6;
    --accent-hover: #60a5fa;
    --accent-soft: #1e293b;
    --focus: #60a5fa;
    --danger: #f87171;
    --danger-soft: #3f1d1d;
    --red: #fca5a5;    --red-bg: #3f1d1d;
    --orange: #fdba74; --orange-bg: #3d2410;
    --amber: #fde047;  --amber-bg: #34300f;
    --green: #86efac;  --green-bg: #12301f;
    --grey: #cbd5e1;   --grey-bg: #1f2937;
    --violet: #c4b5fd; --violet-bg: #2a2150;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 4px 16px rgb(0 0 0 / 25%);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2 { margin: 0; line-height: 1.25; }
h1 { font-size: 1.5rem; letter-spacing: -0.01em; }
h2 { font-size: 1.15rem; }
p { margin: 0; }

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.9em; }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.boot, .loading { padding: 64px 16px; text-align: center; color: var(--muted); }

/* ---------- brand ---------- */

.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.brand-mark {
  display: inline-grid; place-items: center;
  height: 34px; padding: 0 8px; border-radius: 9px;
  background: var(--accent); color: #fff; font-size: 0.95rem; letter-spacing: 0.02em;
}
.brand-name { font-size: 1.05rem; }

/* ---------- buttons & inputs ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 38px; padding: 0 14px;
  border: 1px solid var(--border); border-radius: 9px;
  background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.btn:hover { background: var(--surface-2); border-color: var(--muted); }
.btn:disabled { opacity: 0.6; cursor: progress; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.block { width: 100%; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 36px; height: 36px; padding: 0;
  border: 1px solid transparent; border-radius: 8px;
  background: transparent; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); border-color: var(--border); color: var(--text); }
.icon-btn.danger:hover { color: var(--danger); background: var(--danger-soft); }

input, select, textarea {
  width: 100%; min-height: 40px; padding: 8px 12px;
  border: 1px solid var(--border); border-radius: 9px;
  background: var(--surface); color: var(--text); font: inherit;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 25%, transparent); }
input:disabled, select:disabled { opacity: 0.65; }
input[type="checkbox"] { width: 18px; height: 18px; min-height: 0; accent-color: var(--accent); flex: none; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 0.85rem; font-weight: 600; }
.hint { font-size: 0.8rem; color: var(--muted); }
.check { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.form-error {
  padding: 10px 12px; border-radius: 9px;
  background: var(--danger-soft); color: var(--danger); font-weight: 500;
}
.notice {
  padding: 10px 12px; border-radius: 9px;
  background: var(--accent-soft); color: var(--text); font-size: 0.9rem;
}

/* ---------- auth ---------- */

.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card {
  width: 100%; max-width: 400px;
  display: flex; flex-direction: column; gap: 16px;
  padding: 32px 28px; border-radius: 16px;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
}
.auth-card h1 { margin-top: 8px; }

.auth-theme { position: fixed; top: max(12px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right)); }

/* ---------- shell ---------- */

.topbar {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1280px; margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; gap: 24px;
}
.tabs { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.tab {
  padding: 8px 14px; border: 0; border-radius: 8px;
  background: transparent; color: var(--muted); font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.tab:hover { color: var(--text); background: var(--surface-2); }
.tab.active { color: var(--accent); background: var(--accent-soft); }
.user-menu { display: flex; align-items: center; gap: 4px; }
.user-name { display: inline-flex; align-items: center; gap: 6px; margin-right: 6px; color: var(--muted); font-size: 0.9rem; white-space: nowrap; }

.container { max-width: 1280px; margin: 0 auto; padding: 24px 16px 64px; display: flex; flex-direction: column; gap: 18px; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head > div:first-child { display: flex; flex-direction: column; gap: 2px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- stats ---------- */

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.stat {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  padding: 14px 16px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
  color: var(--text); font: inherit; text-align: left; cursor: pointer;
  border-left: 4px solid var(--c, var(--accent));
  transition: transform 0.12s, border-color 0.12s;
}
.stat:hover { transform: translateY(-1px); }
.stat.selected { outline: 2px solid var(--c, var(--accent)); outline-offset: -1px; }
.stat-value { font-size: 1.75rem; font-weight: 700; line-height: 1.1; color: var(--c, var(--text)); font-variant-numeric: tabular-nums; }
.stat-label { font-size: 0.85rem; color: var(--muted); }
.stat-expired { --c: var(--red); }
.stat-soon { --c: var(--orange); }
.stat-month { --c: var(--amber); }
.stat-active { --c: var(--accent); }

/* ---------- toolbar ---------- */

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.search { position: relative; flex: 1 1 260px; }
.search .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search input { padding-left: 38px; }
.toolbar select { width: auto; min-width: 200px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); color: var(--muted);
  font: inherit; font-size: 0.85rem; font-weight: 600; cursor: pointer;
}
.chip:hover { color: var(--text); }
.chip.active { background: var(--text); border-color: var(--text); color: var(--surface); }

/* ---------- tables ---------- */

.table-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 0.78rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--muted); background: var(--surface-2); padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table .note { color: var(--muted); max-width: 280px; overflow-wrap: anywhere; }
.col-actions { width: 1%; text-align: right; }
.row-actions { display: flex; gap: 2px; justify-content: flex-end; }
.sort {
  display: inline-flex; align-items: center; gap: 4px; padding: 0; border: 0; background: none;
  color: inherit; font: inherit; text-transform: inherit; letter-spacing: inherit; cursor: pointer;
}
.sort:hover, .sort.active { color: var(--text); }
.sort-arrow { font-size: 0.65rem; min-width: 8px; }

.items-table tr.row-expired td:first-child { box-shadow: inset 4px 0 0 var(--red); }
.items-table tr.row-soon td:first-child { box-shadow: inset 4px 0 0 var(--orange); }
.items-table tr.row-month td:first-child { box-shadow: inset 4px 0 0 var(--amber); }
.items-table tr.row-handled td { opacity: 0.6; }
.items-table tr.row-handled td.col-actions { opacity: 1; }
.row-inactive td { opacity: 0.55; }
.row-inactive td.col-actions { opacity: 1; }
.row-warn td { background: color-mix(in srgb, var(--orange-bg) 50%, transparent); }

.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 0.8rem; font-weight: 600; white-space: nowrap; }
.pill-expired { color: var(--red); background: var(--red-bg); }
.pill-soon { color: var(--orange); background: var(--orange-bg); }
.pill-month { color: var(--amber); background: var(--amber-bg); }
.pill-ok { color: var(--green); background: var(--green-bg); }
.pill-handled { color: var(--grey); background: var(--grey-bg); }
.pill-admin { color: var(--violet); background: var(--violet-bg); }

.empty { padding: 48px 16px; display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.empty-title { font-weight: 700; font-size: 1.05rem; }

/* ---------- modal ---------- */

.modal {
  width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 32px);
  padding: 0; border: 1px solid var(--border); border-radius: 16px;
  background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgb(0 0 0 / 30%);
}
.modal::backdrop { background: rgb(15 23 42 / 45%); backdrop-filter: blur(2px); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal > :not(.modal-head) { padding: 20px; }
.modal-actions { display: flex; justify-content: flex-end; align-items: center; gap: 8px; flex-wrap: wrap; padding-top: 4px; }
.modal-actions .grow { margin-right: auto; font-size: 0.9rem; }
.modal p + .modal-actions { margin-top: 18px; }

.secret { display: flex; gap: 8px; align-items: center; }
.secret code {
  flex: 1; padding: 10px 12px; border-radius: 9px; background: var(--surface-2); border: 1px dashed var(--border);
  font: 600 1.1rem ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: 0.04em; user-select: all;
}

/* ---------- toasts ---------- */

#toasts { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow);
  background: var(--text); color: var(--surface); font-weight: 500; max-width: calc(100vw - 32px);
  transition: opacity 0.3s, transform 0.3s;
}
.toast.error { background: var(--danger); color: #fff; }
.toast.hide { opacity: 0; transform: translateY(8px); }

/* ---------- notifications ---------- */

h3 { margin: 0; font-size: 0.95rem; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.stack-sm { display: flex; flex-direction: column; gap: 10px; }
.inline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.num-input { width: 110px; }
.time-input { max-width: 160px; }
.error-text { color: var(--danger); overflow-wrap: anywhere; }
.notice.warn { background: var(--amber-bg); }
.ok-line { display: flex; align-items: center; gap: 8px; color: var(--green); font-weight: 600; }

.bell { position: relative; }
.badge {
  position: absolute; top: 2px; right: 0;
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  background: var(--danger); color: #fff; font-size: 0.7rem; font-weight: 700; line-height: 18px; text-align: center;
}

.notif-layout { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 18px; align-items: start; }
.notif-layout > .card { position: sticky; top: 76px; }

.channel { border: 1px solid var(--border); border-radius: 10px; padding: 14px; display: flex; flex-direction: column; gap: 10px; background: var(--surface-2); }
.channel-head { display: flex; align-items: center; gap: 8px; }
.push-toggle { margin-left: auto; font-size: 0.9rem; }

.devices { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.devices li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; background: var(--surface); border: 1px solid var(--border); }

.inbox { padding: 0; overflow: hidden; }
.inbox-item { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.inbox-item:last-child { border-bottom: 0; }
.inbox-item.unread { box-shadow: inset 4px 0 0 var(--accent); background: color-mix(in srgb, var(--accent-soft) 40%, transparent); }
.inbox-head { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.inbox-body { font-size: 0.9rem; color: var(--muted); }
.deliveries { display: flex; flex-direction: column; gap: 6px; }
.delivery { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 0.85rem; }

.health { display: flex; flex-direction: column; gap: 4px; border-left: 4px solid var(--green); }
.health-warn { border-left-color: var(--orange); }

/* phones with a notch / home indicator */
.topbar-inner { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
.container { padding-bottom: max(64px, env(safe-area-inset-bottom)); }
@supports (padding-top: env(safe-area-inset-top)) { .topbar { padding-top: env(safe-area-inset-top); } }

/* ---------- categories ---------- */

.cat { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; font-size: 0.8rem; font-weight: 600; white-space: nowrap; color: var(--c-fg); background: var(--c-bg); }
.cat::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c-dot); }
.cat-blue   { --c-fg: #1d4ed8; --c-bg: #dbeafe; --c-dot: #3b82f6; }
.cat-green  { --c-fg: #15803d; --c-bg: #dcfce7; --c-dot: #22c55e; }
.cat-amber  { --c-fg: #a16207; --c-bg: #fef9c3; --c-dot: #eab308; }
.cat-orange { --c-fg: #c2410c; --c-bg: #ffedd5; --c-dot: #f97316; }
.cat-red    { --c-fg: #b91c1c; --c-bg: #fee2e2; --c-dot: #ef4444; }
.cat-violet { --c-fg: #6d28d9; --c-bg: #ede9fe; --c-dot: #8b5cf6; }
.cat-pink   { --c-fg: #be185d; --c-bg: #fce7f3; --c-dot: #ec4899; }
.cat-teal   { --c-fg: #0f766e; --c-bg: #ccfbf1; --c-dot: #14b8a6; }
.cat-grey   { --c-fg: #475569; --c-bg: #e2e8f0; --c-dot: #94a3b8; }
:root[data-theme="dark"] .cat-blue   { --c-fg: #93c5fd; --c-bg: #1e2a4a; }
:root[data-theme="dark"] .cat-green  { --c-fg: #86efac; --c-bg: #12301f; }
:root[data-theme="dark"] .cat-amber  { --c-fg: #fde047; --c-bg: #34300f; }
:root[data-theme="dark"] .cat-orange { --c-fg: #fdba74; --c-bg: #3d2410; }
:root[data-theme="dark"] .cat-red    { --c-fg: #fca5a5; --c-bg: #3f1d1d; }
:root[data-theme="dark"] .cat-violet { --c-fg: #c4b5fd; --c-bg: #2a2150; }
:root[data-theme="dark"] .cat-pink   { --c-fg: #f9a8d4; --c-bg: #3d1730; }
:root[data-theme="dark"] .cat-teal   { --c-fg: #5eead4; --c-bg: #0f2f2c; }
:root[data-theme="dark"] .cat-grey   { --c-fg: #cbd5e1; --c-bg: #1f2937; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .cat-blue   { --c-fg: #93c5fd; --c-bg: #1e2a4a; }
  :root:not([data-theme="light"]) .cat-green  { --c-fg: #86efac; --c-bg: #12301f; }
  :root:not([data-theme="light"]) .cat-amber  { --c-fg: #fde047; --c-bg: #34300f; }
  :root:not([data-theme="light"]) .cat-orange { --c-fg: #fdba74; --c-bg: #3d2410; }
  :root:not([data-theme="light"]) .cat-red    { --c-fg: #fca5a5; --c-bg: #3f1d1d; }
  :root:not([data-theme="light"]) .cat-violet { --c-fg: #c4b5fd; --c-bg: #2a2150; }
  :root:not([data-theme="light"]) .cat-pink   { --c-fg: #f9a8d4; --c-bg: #3d1730; }
  :root:not([data-theme="light"]) .cat-teal   { --c-fg: #5eead4; --c-bg: #0f2f2c; }
  :root:not([data-theme="light"]) .cat-grey   { --c-fg: #cbd5e1; --c-bg: #1f2937; }
}

.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch { width: 30px; height: 30px; border-radius: 50%; border: 2px solid transparent; background: var(--c-dot); cursor: pointer; padding: 0; }
.swatch.selected { border-color: var(--text); box-shadow: 0 0 0 2px var(--surface) inset; }

.person-list { display: flex; flex-direction: column; gap: 2px; max-height: 240px; overflow-y: auto; border: 1px solid var(--border); border-radius: 9px; padding: 6px; }
.person-row { padding: 6px 8px; border-radius: 6px; }
.person-row:hover { background: var(--surface-2); }
.people { display: flex; gap: 6px; flex-wrap: wrap; }
.person { padding: 2px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); font-size: 0.85rem; }
.person.inactive { opacity: 0.6; text-decoration: line-through; }

.radio-group { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.radio-card { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; background: var(--surface-2); }
.radio-card.selected { border-color: var(--accent); background: var(--accent-soft); }
.radio-card input { width: 18px; height: 18px; min-height: 0; margin-top: 2px; accent-color: var(--accent); flex: none; }

.tag { margin-left: 6px; padding: 1px 8px; border-radius: 999px; background: var(--green-bg); color: var(--green); font-size: 0.72rem; font-weight: 700; }

/* ---------- barcode ---------- */

.barcode { font-size: 0.78rem; color: var(--muted); letter-spacing: 0.02em; margin-top: 2px; }
.input-row { display: flex; gap: 8px; }
.input-row input { flex: 1; min-width: 0; }
.search .scan-btn { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 34px; height: 34px; }
.search .scan-btn .icon { position: static; transform: none; color: currentColor; }
.search:has(.scan-btn) input { padding-right: 44px; }
.scanner { position: relative; border-radius: 12px; overflow: hidden; background: #000; aspect-ratio: 4 / 3; }
.scanner video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scanner-frame { position: absolute; inset: 22% 10%; border: 3px solid rgb(255 255 255 / 85%); border-radius: 12px; box-shadow: 0 0 0 9999px rgb(0 0 0 / 35%); }
.scanner-frame::after { content: ""; position: absolute; left: 6%; right: 6%; top: 50%; height: 2px; background: #ef4444; box-shadow: 0 0 8px #ef4444; animation: scanline 1.6s ease-in-out infinite alternate; }
@keyframes scanline { from { transform: translateY(-40px); } to { transform: translateY(40px); } }
@media (prefers-reduced-motion: reduce) { .scanner-frame::after { animation: none; } }

/* ---------- mobile ---------- */

@media (max-width: 820px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .topbar-inner { flex-wrap: wrap; gap: 8px 16px; }
  .tabs { order: 3; flex-basis: 100%; }
  .user-menu { margin-left: auto; }
  .user-name { display: none; }
  .toolbar select { flex: 1 1 100%; }
  .grid-2 { grid-template-columns: 1fr; }
  .notif-layout { grid-template-columns: 1fr; }
  .radio-group { grid-template-columns: 1fr; }
  .notif-layout > .card { position: static; }
  .page-head .actions { width: 100%; }
  .page-head .actions .btn { flex: 1; }

  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { padding: 10px 14px; border-bottom: 1px solid var(--border); position: relative; }
  .table tbody tr:last-child { border-bottom: 0; }
  .table td { padding: 3px 0; border: 0; display: flex; gap: 12px; }
  .table td[data-label]::before { content: attr(data-label); flex: 0 0 120px; color: var(--muted); font-size: 0.82rem; }
  .table td:empty { display: none; }
  .table .note { max-width: none; }
  .col-actions { text-align: left; }
  .row-actions { justify-content: flex-start; margin-top: 4px; }
  .items-table tr.row-expired { box-shadow: inset 4px 0 0 var(--red); }
  .items-table tr.row-soon { box-shadow: inset 4px 0 0 var(--orange); }
  .items-table tr.row-month { box-shadow: inset 4px 0 0 var(--amber); }
  .items-table tr td:first-child { box-shadow: none !important; }
}

/* ---------- print: black & white A4 portrait log ---------- */

#print-area { display: none; }

@page { size: A4 portrait; margin: 12mm 12mm 10mm; }

@media print {
  body { background: #fff; color: #000; font: 9pt/1.25 Helvetica, Arial, sans-serif; }
  #app, #toasts, dialog { display: none !important; }
  #print-area { display: block; }
  .print-page { break-after: page; }
  .print-page:last-child { break-after: auto; }
  .print-page h1 { font-size: 15pt; text-align: center; margin: 0 0 4mm; color: #000; }
  .print-meta { display: flex; gap: 6mm; margin-bottom: 4mm; font-size: 9.5pt; }
  .print-meta > div { display: flex; flex: 1; align-items: flex-end; white-space: nowrap; }
  .print-meta .line { flex: 1; min-width: 20mm; border-bottom: 0.6pt solid #000; padding: 0 1mm; font-weight: 600; white-space: normal; }
  .print-table { width: 100%; border-collapse: collapse; table-layout: fixed; border: 1.5pt solid #000; }
  .print-table th, .print-table td { border: 0.5pt solid #000; padding: 0 1.5mm; height: 7.4mm; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #000; background: #fff; }
  .print-table th { font-weight: 700; text-align: center; border-bottom: 1.5pt solid #000; height: 8mm; }
  .print-table .c-no { text-align: center; }
  .print-table .c-date { text-align: center; }
  .date-guide { letter-spacing: 0.08em; }
  .print-foot { display: flex; justify-content: space-between; margin-top: 2mm; font-size: 8pt; }
}
