:root {
  --ink: #10183d;
  --muted: #5b607e;
  --surface: #ffffff;
  --canvas: #f4f6fb;
  --line: #dfe3ef;
  --accent: #001d7e;
  --accent-dark: #00145a;
  --accent-soft: #e8ecf8;
  --magenta: #ba007c;
  --magenta-dark: #87005a;
  --magenta-soft: #f8e6f2;
  --cyan: #38daff;
  --cyan-soft: #e6faff;
  --lavender: #8882a9;
  --warm: #38daff;
  --danger: #9d174d;
  --shadow: 0 18px 50px rgba(0, 29, 126, .14);
  --radius: 12px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--canvas); }
body { margin: 0; min-height: 100vh; color: var(--ink); background: var(--canvas); font-family: "Trebuchet MS", "Segoe UI", sans-serif; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .45; }
:focus-visible { outline: 3px solid rgba(56, 218, 255, .65); outline-offset: 2px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.topbar { height: 72px; padding: 0 clamp(20px, 4vw, 64px); display: flex; align-items: center; justify-content: space-between; background: var(--accent); color: white; }
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.brand-logo { width: auto; height: 48px; display: block; object-fit: contain; flex: 0 0 auto; }
.brand strong { color: white; font-size: 20px; white-space: nowrap; }
.header-actions { display: flex; align-items: center; gap: 10px; }
.save-status { font-size: 12px; color: #dfe3ef; }
.layout { width: min(1480px, 100%); margin: 0 auto; }
.workbench { padding: clamp(28px, 5vw, 58px) clamp(20px, 4vw, 64px) 0; background: #f9faff; border-bottom: 1px solid var(--line); }
.section-heading, .inventory-toolbar { display: flex; justify-content: space-between; align-items: end; gap: 24px; }
.eyebrow { margin: 0 0 6px; color: var(--magenta); font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
h1, h2, h3, p { text-wrap: pretty; }
h1 { margin: 0; font-size: clamp(30px, 5vw, 48px); letter-spacing: -.045em; }
h2 { margin: 0; font-size: 28px; letter-spacing: -.035em; }
h3 { margin: 0; }
.keyboard-hint { color: var(--muted); font-size: 13px; }
.scan-panel { margin-top: 28px; }
.scan-form label, .form-grid label > span { display: block; margin-bottom: 7px; font-size: 12px; font-weight: 800; color: #28345f; }
.scan-input-row { display: grid; grid-template-columns: minmax(220px, 1fr) auto auto minmax(230px, auto); gap: 9px; }
input, select { width: 100%; min-height: 46px; border: 1px solid #bfc7df; border-radius: 9px; background: white; color: var(--ink); padding: 10px 12px; }
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(56, 218, 255, .25); outline: 0; }
#barcode-input { min-height: 58px; border: 2px solid var(--accent); padding-inline: 18px; font-size: 20px; letter-spacing: .025em; }
.field-help { margin: 8px 0 0; color: var(--muted); font-size: 12px; }
.btn { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid transparent; border-radius: 9px; padding: 10px 16px; font-weight: 800; text-decoration: none; transition: transform .15s ease, background .15s ease, border-color .15s ease; }
.btn:hover:not(:disabled) { transform: translateY(-1px); }
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-export { background: var(--magenta); color: white; }
.btn-export:hover { background: var(--magenta-dark); }
.btn-camera { color: var(--accent); background: var(--cyan-soft); border-color: var(--cyan); }
.btn-secondary { background: white; color: var(--ink); border-color: var(--line); }
.btn-ghost { background: transparent; color: inherit; border-color: currentColor; }
.inventory .btn-ghost, .dialog .btn-ghost { color: var(--accent); border-color: #bfc7df; background: white; }
.btn-danger { color: var(--danger); background: #fcecf3; border-color: #e6a8c9; }
.last-action { min-width: 230px; min-height: 46px; display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-left: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.pulse-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 0 5px var(--cyan-soft); }
.last-action.success { color: var(--accent); font-weight: 800; }
.last-action.error { color: var(--danger); }
.last-action.error .pulse-dot { background: var(--magenta); box-shadow: 0 0 0 5px var(--magenta-soft); }
.summary-strip { display: grid; grid-template-columns: 150px 150px 160px 1fr; gap: 0; align-items: stretch; margin-top: 36px; border-top: 1px solid var(--line); }
.summary-strip > div:not(.summary-actions) { padding: 20px 24px 20px 0; }
.summary-strip span, .summary-strip strong { display: block; }
.summary-strip span { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
.summary-strip strong { margin-top: 4px; color: var(--accent); font-size: 22px; font-variant-numeric: tabular-nums; }
.summary-actions { display: flex; justify-content: end; align-items: center; gap: 9px; }
.inventory { padding: clamp(28px, 4vw, 48px) clamp(20px, 4vw, 64px) 60px; }
.toolbar-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: end; }
.search-box input { min-width: 280px; }
.empty-state { padding: 70px 20px; display: grid; place-items: center; text-align: center; color: var(--muted); }
.empty-state h3 { margin: 20px 0 6px; color: var(--ink); }
.empty-state p { margin: 0; max-width: 440px; }
.empty-illustration { width: 82px; height: 64px; display: flex; align-items: end; gap: 5px; padding: 10px; border: 2px solid var(--lavender); border-radius: 8px 8px 18px 18px; }
.empty-illustration span { flex: 1; background: var(--cyan); border: 1px solid var(--accent); }
.empty-illustration span:nth-child(2) { background: var(--magenta); }
.empty-illustration span:nth-child(3) { background: var(--lavender); }
.empty-illustration span:nth-child(1) { height: 75%; } .empty-illustration span:nth-child(2) { height: 100%; } .empty-illustration span:nth-child(3) { height: 58%; }
.table-wrap { margin-top: 22px; border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; background: white; box-shadow: 0 6px 20px rgba(0, 29, 126, .06); }
table { width: 100%; min-width: 860px; border-collapse: collapse; }
th, td { padding: 14px 16px; border-bottom: 1px solid #eef0f7; text-align: left; vertical-align: middle; }
th { position: sticky; top: 0; background: #eef1f8; color: #48516f; font-size: 11px; text-transform: uppercase; letter-spacing: .065em; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #f8f9fd; }
.product-name strong, .product-name small { display: block; }
.product-name small { margin-top: 3px; color: var(--muted); }
.mono { font-family: "Courier New", monospace; font-variant-numeric: tabular-nums; }
.number { text-align: right; font-variant-numeric: tabular-nums; }
.stock-control { display: inline-grid; grid-template-columns: 36px minmax(50px, auto) 36px; align-items: center; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; background: white; }
.stock-control button { width: 36px; height: 36px; border: 0; background: var(--accent-soft); color: var(--accent); font-size: 20px; }
.stock-control strong { min-width: 54px; text-align: center; }
.row-actions { display: flex; justify-content: end; gap: 6px; }
.row-button { min-height: 36px; border: 1px solid var(--line); border-radius: 7px; background: white; color: var(--accent); padding: 6px 10px; }
.dialog { width: min(760px, calc(100% - 24px)); max-height: calc(100vh - 32px); border: 0; border-radius: 16px; padding: 0; color: var(--ink); background: white; box-shadow: var(--shadow); }
.dialog::backdrop { background: rgba(0, 12, 55, .66); backdrop-filter: blur(2px); }
.dialog form, .dialog > :not(form) { margin: 0; }
.dialog-header { display: flex; align-items: start; justify-content: space-between; gap: 20px; padding: 24px 26px 18px; border-bottom: 1px solid var(--line); }
.dialog-header h2 { font-size: 25px; }
.icon-button { width: 42px; height: 42px; border: 0; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-size: 25px; line-height: 1; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; padding: 22px 26px; overflow: auto; }
.form-grid .span-2 { grid-column: span 2; }
.form-grid.single-column { grid-template-columns: 1fr; }
.form-grid small, .data-danger-zone small { display: block; margin-top: 5px; color: var(--muted); }
.checkbox-label { display: flex !important; align-items: center; gap: 10px; }
.checkbox-label input { width: 20px; min-height: 20px; }
.checkbox-label span { margin: 0 !important; }
.form-error { min-height: 18px; margin: -6px 26px 0; color: var(--danger); font-size: 13px; }
.dialog-footer { display: flex; gap: 8px; align-items: center; padding: 16px 26px 22px; border-top: 1px solid var(--line); }
.spacer { flex: 1; }
.camera-dialog { width: min(620px, calc(100% - 24px)); }
.camera-frame { position: relative; aspect-ratio: 4/3; margin: 20px; overflow: hidden; border-radius: 12px; background: #05091d; }
.camera-frame video { width: 100%; height: 100%; object-fit: cover; }
.camera-target { position: absolute; inset: 30% 12%; border: 2px solid var(--warm); border-radius: 8px; box-shadow: 0 0 0 999px rgba(0,0,0,.18); }
.camera-status { margin: 0 20px 22px; color: var(--muted); text-align: center; }
.settings-dialog { width: min(600px, calc(100% - 24px)); }
.data-danger-zone { display: flex; align-items: center; gap: 20px; margin: 0 26px 20px; padding: 16px; border: 1px solid #e6a8c9; border-radius: 10px; background: #fdf5fa; }
.data-danger-zone div { flex: 1; }
.export-dialog { width: min(760px, calc(100% - 24px)); padding-bottom: 32px; }
.export-dialog > p { margin: 24px 32px 0; color: var(--muted); line-height: 1.55; }
.export-dialog > .export-options { display: grid; gap: 14px; margin: 22px 32px 0; }
.export-card { display: grid; grid-template-columns: minmax(170px, .8fr) minmax(0, 1.2fr); align-items: center; gap: 24px; min-height: 84px; padding: 18px 20px; border: 1px solid var(--line); border-radius: 10px; background: white; text-align: left; color: var(--ink); }
.export-card strong { font-size: 16px; }
.export-card span { color: var(--muted); font-size: 13px; line-height: 1.45; }
.export-card.featured { margin-top: 4px; color: white; background: var(--magenta); border-color: var(--magenta); }
.export-card.featured span { color: var(--magenta-soft); }
.export-dialog > .import-note { margin: 20px 32px 0; padding: 18px 20px; border: 1px solid #b7efff; border-radius: 9px; background: var(--cyan-soft); color: var(--accent); font-size: 13px; line-height: 1.55; }
.toast-region { position: fixed; right: 20px; bottom: 20px; z-index: 10; display: grid; gap: 8px; }
.toast { max-width: 380px; padding: 13px 16px; border-radius: 9px; background: var(--accent); color: white; box-shadow: var(--shadow); animation: toast-in .2s ease both; }
.toast.error { background: var(--danger); }
@keyframes toast-in { from { transform: translateY(10px); opacity: 0; } }
@media (max-width: 820px) {
  .save-status, .keyboard-hint { display: none; }
  .scan-input-row { grid-template-columns: minmax(220px, 1fr) auto auto; }
  .last-action { grid-column: 1 / -1; min-width: 0; border-left: 0; padding-left: 0; }
  .summary-strip { grid-template-columns: repeat(3, 1fr); }
  .summary-actions { grid-column: 1 / -1; justify-content: stretch; padding: 14px 0 20px; }
  .summary-actions .btn { flex: 1; }
  .inventory-toolbar { align-items: stretch; flex-direction: column; }
  .toolbar-actions { justify-content: stretch; }
  .toolbar-actions > * { flex: 1 1 auto; }
  .search-box { flex-basis: 100%; }
  .search-box input { min-width: 0; }
}
@media (max-width: 600px) {
  .topbar { height: 64px; padding-inline: 16px; }
  .brand { gap: 8px; }
  .brand-logo { height: 38px; }
  .brand strong { font-size: 17px; }
  .header-actions .btn { padding-inline: 10px; }
  .workbench, .inventory { padding-inline: 16px; }
  .scan-input-row { grid-template-columns: 1fr auto; }
  #barcode-input { grid-column: 1 / -1; }
  .btn-camera { grid-column: 1; grid-row: 2; }
  .scan-input-row .btn-primary { grid-column: 2; grid-row: 2; }
  .summary-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .summary-strip > div:not(.summary-actions) { padding-right: 8px; }
  .summary-strip strong { font-size: 18px; }
  .summary-actions { flex-direction: column; }
  .summary-actions .btn { width: 100%; }
  .form-grid { grid-template-columns: 1fr; padding: 18px; }
  .form-grid .span-2 { grid-column: auto; }
  .dialog-header { padding-inline: 18px; }
  .dialog-footer { padding-inline: 18px; flex-wrap: wrap; }
  .dialog-footer .spacer { display: none; }
  .dialog-footer .btn { flex: 1; }
  .data-danger-zone { margin-inline: 18px; align-items: stretch; flex-direction: column; }
  .export-dialog { padding-bottom: 24px; }
  .export-dialog > p { margin: 20px 18px 0; }
  .export-dialog > .export-options { margin: 18px 18px 0; }
  .export-card { grid-template-columns: 1fr; align-items: start; gap: 6px; min-height: 0; padding: 16px; }
  .export-dialog > .import-note { margin: 18px 18px 0; padding: 16px; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; animation: none !important; } }
