:root {
  color-scheme: light;
  --blue: #004aad;
  --blue-soft: #e8f1ff;
  --yellow: #fbbf24;
  --yellow-dark: #b87900;
  --text: #162033;
  --muted: #5c6c82;
  --line: #d7e2f1;
  --bg: #f6f8fb;
  --card: #ffffff;
  --danger: #c82127;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); }
body.task-active { background: var(--card); }
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .45; }
.stockroom-app { min-height: 100vh; padding: calc(14px + env(safe-area-inset-top, 0px)) 14px 32px; display: grid; align-content: start; gap: 14px; }
body.task-active .stockroom-app { padding: env(safe-area-inset-top, 0px) 0 0; gap: 0; }
body.capacitor-android .stockroom-app { padding-top: max(34px, calc(14px + env(safe-area-inset-top, 0px))); }
body.capacitor-android.task-active .stockroom-app { padding-top: max(24px, env(safe-area-inset-top, 0px)); }
body.task-active .app-header,
body.task-active .summary-grid,
body.history-active .summary-grid,
body.inventory-active .summary-grid { display: none; }
.app-header { display: flex; gap: 14px; align-items: center; padding: 16px; border-radius: 22px; background: var(--blue); color: #fff; box-shadow: 0 14px 34px rgba(0, 74, 173, .22); }
.app-header img { width: 124px; height: auto; }
.app-header h1 { margin: 0; font-size: clamp(22px, 7vw, 32px); line-height: 1; }
.app-header p { margin: 6px 0 0; color: rgba(255, 255, 255, .8); font-weight: 800; }
.summary-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.summary-grid article, .scan-card, .list-card, .task-home { background: var(--card); border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 12px 32px rgba(15, 23, 42, .07); }
.summary-grid article { padding: 12px; }
.summary-grid span { display: block; color: var(--muted); font-weight: 900; font-size: 12px; text-transform: uppercase; }
.summary-grid strong { display: block; margin-top: 4px; color: var(--blue); font-size: 28px; line-height: 1; }
.scan-card, .list-card, .task-home { padding: 14px; }
body.task-active .scan-card { min-height: calc(100vh - env(safe-area-inset-top, 0px)); border: 0; border-radius: 0; box-shadow: none; padding: 18px 16px 16px; }
.task-home { display: grid; gap: 10px; }
.section-title { display: flex; justify-content: space-between; gap: 12px; align-items: end; }
.section-title h2 { margin: 0; color: var(--blue); font-size: 20px; }
.section-title span { color: var(--muted); font-weight: 850; font-size: 13px; }
.task-button { display: grid; gap: 4px; width: 100%; min-height: 78px; padding: 16px; border: 1px solid #b9d3f7; border-radius: 18px; background: #f4f8ff; color: var(--text); text-align: left; box-shadow: 0 8px 18px rgba(0, 74, 173, .08); }
.task-button strong { color: var(--blue); font-size: 22px; line-height: 1; }
.task-button span { color: var(--muted); font-weight: 850; }
.task-button.danger { border-color: #fecaca; background: #fff7f7; }
.task-button.danger strong { color: var(--danger); }
.task-button.neutral { border-color: #d6dde8; background: #fbfcff; }
.task-head { display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: start; margin-bottom: 14px; }
.task-head h2 { margin: 0; color: var(--blue); font-size: 22px; line-height: 1.1; }
.task-head p { margin: 4px 0 0; color: var(--muted); font-weight: 800; }
.back-button, .cancel-button { min-height: 42px; border: 0; border-radius: 999px; padding: 0 14px; font-weight: 950; }
.back-button { background: var(--blue-soft); color: var(--blue); }
.cancel-button { background: #fee2e2; color: var(--danger); }
.mode-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.mode-tabs button, .primary-button, .warning-button, .action-row button { border: 0; border-radius: 16px; min-height: 52px; font-weight: 950; }
.mode-tabs button { background: var(--blue-soft); color: var(--blue); }
.mode-tabs button.active { background: var(--yellow); color: #073b82; }
.mode-panel { display: grid; gap: 4px; margin: 0 0 14px; padding: 12px 14px; border-radius: 16px; border: 1px solid #b9d3f7; background: #f3f8ff; }
.mode-panel.stock-out { border-color: #fecaca; background: #fff5f5; }
.mode-panel strong { color: var(--blue); font-size: 22px; line-height: 1.1; }
.mode-panel.stock-out strong { color: var(--danger); }
.mode-panel span { color: var(--muted); font-weight: 800; }
form { display: grid; gap: 12px; }
label { display: grid; gap: 7px; color: var(--muted); font-weight: 900; }
input { width: 100%; min-height: 52px; border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; background: #fff; color: var(--text); font-size: 18px; }
input:focus { outline: 3px solid rgba(0, 74, 173, .16); border-color: var(--blue); }
.scan-row { display: grid; grid-template-columns: 1fr 56px; gap: 8px; }
.icon-button { border: 1px solid var(--line); border-radius: 14px; background: var(--blue); color: #fff; font-size: 24px; font-weight: 900; }
.camera-panel { display: grid; gap: 10px; }
.camera-panel.hidden { display: none; }
video { width: 100%; max-height: 270px; object-fit: cover; border-radius: 18px; background: #0f172a; }
.camera-panel button { border: 0; border-radius: 14px; min-height: 44px; background: #e8eef7; color: var(--blue); font-weight: 900; }
.product-preview { min-height: 62px; padding: 12px; border-radius: 14px; background: #f8fbff; border: 1px dashed #b8c9df; color: var(--muted); font-weight: 800; }
.product-preview strong { display: block; color: var(--text); margin-bottom: 4px; }
.product-preview b { display: block; margin-top: 6px; color: var(--blue); font-size: 18px; }
.product-results { display: grid; gap: 7px; margin-top: -6px; }
.product-results[hidden] { display: none; }
.product-result-button { width: 100%; min-height: 58px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 14px; background: #fff; color: var(--text); text-align: left; font-weight: 850; }
.product-result-button strong { display: block; line-height: 1.2; }
.product-result-button small { display: block; margin-top: 4px; color: var(--muted); font-weight: 750; }
.form-grid { display: grid; grid-template-columns: minmax(120px, 240px); gap: 10px; }
.primary-button { background: var(--blue); color: #fff; font-size: 18px; }
.warning-button { background: var(--yellow); color: #073b82; font-size: 18px; }
.task-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.task-actions .primary-button:only-child { grid-column: 1 / -1; }
.complete-button { width: 100%; margin-top: 10px; background: var(--yellow); color: #073b82; }
.embedded { box-shadow: none; background: #f8fbff; }
body.task-active .embedded { margin-top: 4px; }
.action-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.action-row button { background: var(--yellow); color: #073b82; }
.section-head { display: flex; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.section-head h2 { margin: 0; color: var(--blue); font-size: 18px; }
.section-head button { border: 0; border-radius: 999px; background: #fee2e2; color: var(--danger); font-weight: 950; padding: 9px 14px; }
.section-head input { min-height: 42px; max-width: 190px; font-size: 14px; }
.stock-list, .movement-list { display: grid; gap: 8px; }
.empty { padding: 12px; border-radius: 14px; background: #f8fbff; color: var(--muted); font-weight: 800; }
.stock-item, .movement-item { display: grid; gap: 6px; padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: #fff; }
.stock-item strong, .movement-item strong { line-height: 1.2; }
.stock-item small, .movement-item small { color: var(--muted); font-weight: 750; }
.stock-item .qty { color: var(--blue); font-size: 24px; font-weight: 950; }
.movement-item.in { border-left: 6px solid #15803d; }
.movement-item.out { border-left: 6px solid var(--danger); }
.movement-item.check { border-left: 6px solid var(--blue); }
.movement-item.adjust { border-left: 6px solid var(--yellow-dark); }
.movement-meta { display: flex; justify-content: space-between; gap: 10px; }
.remove-line-button { width: max-content; min-height: 38px; border: 1px solid #fecaca; border-radius: 999px; padding: 0 14px; background: #fee2e2; color: var(--danger); font-weight: 950; }
.pill { display: inline-flex; width: max-content; padding: 5px 9px; border-radius: 999px; font-size: 12px; font-weight: 950; background: var(--blue-soft); color: var(--blue); }
.pill.out { background: #fee2e2; color: var(--danger); }
.pill.check { background: var(--blue-soft); color: var(--blue); }
.pill.adjust { background: #fff1c2; color: #8a5c00; }
.web-stockroom { display: none; }
.web-toolbar { display: flex; gap: 16px; align-items: center; justify-content: space-between; }
.web-toolbar h2 { margin: 0; color: var(--blue); font-size: 24px; }
.web-toolbar p { margin: 4px 0 0; color: var(--muted); font-weight: 800; }
.web-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.web-actions button { min-width: 128px; padding: 0 18px; }
.web-search { width: min(420px, 100%); }
.stock-table { width: 100%; border-collapse: collapse; background: #fff; table-layout: fixed; }
.stock-table th, .stock-table td { padding: 14px 16px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.stock-table th { background: #eef4fd; color: #334b6b; font-size: 12px; font-weight: 950; text-transform: uppercase; }
.stock-table td:first-child { width: 190px; }
.stock-table td:last-child { width: 150px; }
.stock-table strong { color: var(--text); }
.stock-table small { display: block; margin-top: 3px; color: var(--muted); font-weight: 750; }
.stock-table .clickable-row { cursor: pointer; }
.stock-table .clickable-row:hover { background: #f3f8ff; }
.stock-table .clickable-row:focus-visible { outline: 3px solid rgba(0, 74, 173, .18); outline-offset: -3px; }
.stock-table.compact th, .stock-table.compact td { padding: 10px 12px; }
.stock-table.compact td:first-child { width: 160px; }
.stock-table.compact td:nth-child(3) { width: 120px; }
.stock-table.compact td:last-child { width: 116px; }
.line-qty-input { width: 96px; min-height: 42px; border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; font: inherit; font-weight: 950; color: var(--text); background: #fff; }
.line-qty-input:focus { outline: 3px solid rgba(0, 74, 173, .18); border-color: var(--blue); }
.line-qty-input:invalid { border-color: #fca5a5; background: #fff7f7; }
.empty-cell { color: var(--muted); font-weight: 800; }
.web-dialog { width: min(960px, calc(100vw - 40px)); max-height: min(760px, calc(100vh - 40px)); border: 0; border-radius: 20px; padding: 0; background: #fff; color: var(--text); box-shadow: 0 28px 80px rgba(15, 23, 42, .32); }
.web-dialog::backdrop { background: rgba(15, 23, 42, .48); }
.web-dialog form { padding: 20px; gap: 14px; }
.web-dialog-head { display: flex; gap: 16px; align-items: start; justify-content: space-between; }
.web-dialog-head h2 { margin: 0; color: var(--blue); font-size: 24px; }
.web-dialog-head p { margin: 4px 0 0; color: var(--muted); font-weight: 800; }
.web-movement-fields { display: grid; grid-template-columns: minmax(280px, 1fr) 180px; gap: 12px; align-items: end; }
.web-dialog-actions { display: flex; justify-content: flex-end; }
.web-dialog-actions button { min-width: 190px; padding: 0 18px; }
.dialog-status { min-height: 20px; color: var(--muted); font-weight: 850; }

@media (min-width: 720px) {
  .stockroom-app { width: min(760px, 100%); margin: 0 auto; }
}

@media (min-width: 900px) {
  body:not(.capacitor-android) .stockroom-app { width: min(1320px, 100%); margin: 0 auto; padding: 14px 24px 18px; gap: 10px; }
  body:not(.capacitor-android) .app-header { min-height: 92px; padding: 12px 18px; border-radius: 16px; }
  body:not(.capacitor-android) .app-header img { width: 98px; }
  body:not(.capacitor-android) .summary-grid { grid-template-columns: repeat(3, minmax(0, 190px)); gap: 8px; }
  body:not(.capacitor-android) .summary-grid article { padding: 9px 12px; }
  body:not(.capacitor-android) .summary-grid strong { font-size: 24px; }
  body:not(.capacitor-android) #taskHome,
  body:not(.capacitor-android) #taskPanel,
  body:not(.capacitor-android) #inventoryPanel,
  body:not(.capacitor-android) #historyPanel,
  body:not(.capacitor-android) #queuePanel { display: none !important; }
  body:not(.capacitor-android) .web-stockroom {
    display: grid;
    gap: 10px;
    padding: 14px 18px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: #fff;
    box-shadow: 0 12px 32px rgba(15, 23, 42, .07);
  }
  body:not(.capacitor-android) .web-toolbar { align-items: start; gap: 12px; }
  body:not(.capacitor-android) .web-toolbar h2 { font-size: 22px; }
  body:not(.capacitor-android) .web-toolbar p { max-width: 340px; margin-top: 2px; line-height: 1.15; }
  body:not(.capacitor-android) .web-actions { gap: 8px; }
  body:not(.capacitor-android) .web-actions button { min-height: 42px; min-width: 126px; border-radius: 14px; }
  body:not(.capacitor-android) .web-search { min-height: 42px; padding: 9px 14px; }
  body:not(.capacitor-android) .stock-table th,
  body:not(.capacitor-android) .stock-table td { padding: 8px 16px; }
  body:not(.capacitor-android) .stock-table th { height: 34px; }
}
