:root {
  --app-width: 520px;
  --bg: #070b08;
  --surface: #0d120f;
  --panel: #141b16;
  --panel-soft: #1d261f;
  --line: #2a352c;
  --line-strong: #3d4a40;
  --text: #f4f1e8;
  --muted: #a5afa7;
  --soft-text: #7f8a82;
  --accent: #79d7a2;
  --accent-strong: #b7f0cd;
  --accent-soft: #183225;
  --blue: #9bbcff;
  --blue-soft: #17243b;
  --danger: #ff8a7d;
  --danger-soft: #351b19;
  --warn: #e5bd66;
  --warn-soft: #352a14;
  --review: #b9abff;
  --review-soft: #2b2542;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.56);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100dvh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.35;
  overscroll-behavior-y: none;
  -webkit-tap-highlight-color: transparent;
}

body.detail-open {
  overflow: hidden;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease, transform 140ms ease, box-shadow 140ms ease;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
  transform: none;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid rgba(121, 215, 162, 0.9);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

.hidden {
  display: none !important;
}

.app-shell {
  position: relative;
  width: min(100%, var(--app-width));
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: clip;
}

body.am-mode .app-shell {
  width: min(100%, 1720px);
  border: 1px solid rgba(61, 74, 64, 0.72);
  background: linear-gradient(135deg, #090d0b 0%, #0d120f 46%, #101513 100%);
}

body.am-mode {
  overflow-y: auto;
  background: #050806;
}

.workspace {
  min-height: 100dvh;
  padding: max(12px, env(safe-area-inset-top)) 12px calc(86px + env(safe-area-inset-bottom));
}

.auth-panel,
.store-panel,
.products-layout {
  min-height: calc(100dvh - 96px);
}

.auth-panel {
  display: grid;
  align-items: center;
}

.auth-card,
.store-card,
.products-table-card,
.detail-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.auth-card {
  display: grid;
  gap: 18px;
  padding: 18px;
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.app-brand img {
  width: 44px;
  height: 44px;
  border-radius: 8px;
}

.app-brand strong,
.app-brand span {
  display: block;
}

.app-brand strong {
  font-size: 18px;
  letter-spacing: 0;
}

.app-brand span {
  color: var(--muted);
  font-size: 13px;
}

.auth-copy {
  display: grid;
  gap: 3px;
}

.eyebrow {
  color: var(--accent-strong);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 27px;
  line-height: 1.05;
  letter-spacing: 0;
}

p {
  color: var(--muted);
}

.auth-form,
.store-card,
.detail-card,
.expiry-form,
.photo-form,
.am-account-form {
  display: grid;
  gap: 12px;
}

label span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

input,
select {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--text);
  padding: 10px 12px;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(121, 215, 162, 0.16);
}

.primary-button,
.ghost-button,
.danger-button,
.icon-button,
.link-button {
  min-height: 44px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 10px 12px;
  font-weight: 800;
}

.primary-button {
  background: var(--accent);
  color: #07100b;
}

.primary-button:hover {
  background: var(--accent-strong);
}

.ghost-button,
.icon-button {
  background: var(--panel);
  color: var(--text);
  border-color: var(--line);
}

.danger-button {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: rgba(255, 138, 125, 0.36);
}

.link-button {
  min-height: 32px;
  background: transparent;
  color: var(--muted);
  border: 0;
  padding: 4px 0;
}

.form-message {
  min-height: 18px;
  margin: 0;
  color: var(--danger);
  font-size: 12px;
}

.screen-head,
.topbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.screen-head {
  align-items: center;
  padding: 4px 0 14px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 18;
  align-items: flex-start;
  margin: calc(-1 * max(12px, env(safe-area-inset-top))) -12px 12px;
  padding: max(12px, env(safe-area-inset-top)) 12px 10px;
  background: rgba(13, 18, 15, 0.95);
  border-bottom: 1px solid rgba(61, 74, 64, 0.78);
  backdrop-filter: blur(16px);
}

.topbar-title {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.topbar-title h1 {
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.connection-line {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
}

.status-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--danger);
}

.status-dot.online {
  background: var(--accent);
}

.topbar-actions {
  display: flex;
  gap: 5px;
  flex: 0 0 auto;
}

.scan-fab {
  position: fixed;
  right: max(16px, calc((100vw - var(--app-width)) / 2 + 16px));
  bottom: calc(82px + env(safe-area-inset-bottom));
  z-index: 36;
  width: 66px;
  height: 66px;
  min-height: 66px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(183, 240, 205, 0.42);
  border-radius: 50%;
  background: linear-gradient(160deg, var(--accent-strong), var(--accent));
  color: #07100b;
  padding: 0;
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.52), 0 0 0 6px rgba(121, 215, 162, 0.1);
}

.scan-fab svg {
  width: 31px;
  height: 31px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.scan-fab:active {
  transform: translateY(1px) scale(0.98);
}

.icon-button {
  width: 38px;
  min-width: 38px;
  min-height: 38px;
  display: grid;
  place-items: center;
  padding: 0;
}

.icon-button svg,
.bulk-buttons svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-button.active,
.icon-button[aria-pressed="true"] {
  background: var(--accent-soft);
  color: var(--accent-strong);
  border-color: rgba(121, 215, 162, 0.42);
}

.products-notice {
  position: sticky;
  top: 78px;
  z-index: 17;
  display: none;
  margin: 0 0 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  font-weight: 800;
}

.products-notice.visible {
  display: block;
}

.products-notice[data-kind="success"] {
  border-color: rgba(121, 215, 162, 0.42);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.products-notice[data-kind="error"] {
  border-color: rgba(255, 138, 125, 0.36);
  background: var(--danger-soft);
  color: var(--danger);
}

.store-grid {
  display: grid;
  gap: 10px;
}

.store-card {
  padding: 14px;
}

.store-card strong {
  display: block;
  font-size: 16px;
}

.store-meta {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.metric-grid {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(72px, 1fr);
  gap: 6px;
  margin-bottom: 8px;
  overflow-x: auto;
  scrollbar-width: none;
}

.metric-grid::-webkit-scrollbar,
.segmented::-webkit-scrollbar {
  display: none;
}

.metric-card {
  min-height: 46px;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.metric-card span {
  display: block;
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
}

.metric-card strong {
  display: block;
  margin-top: 2px;
  font-size: 17px;
  line-height: 1;
}

.control-panel {
  display: grid;
  gap: 8px;
  margin: 0 0 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(20, 27, 22, 0.96);
  backdrop-filter: blur(14px);
}

.search-box input {
  min-height: 48px;
}

.control-panel[aria-label="Экспорт товаров"] {
  grid-template-columns: 1fr 1fr;
}

.segmented {
  display: flex;
  gap: 6px;
  margin: 0;
  padding: 0 0 2px;
  overflow-x: auto;
}

.segment {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  padding: 7px 12px;
  white-space: nowrap;
  font-weight: 850;
}

.segment.active {
  background: var(--accent-soft);
  border-color: rgba(121, 215, 162, 0.42);
  color: var(--accent-strong);
}

.bulk-actions {
  position: fixed;
  left: 50%;
  bottom: calc(66px + env(safe-area-inset-bottom));
  z-index: 34;
  display: none;
  width: min(calc(100% - 20px), calc(var(--app-width) - 20px));
  grid-template-columns: minmax(74px, auto) 1fr;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(20, 27, 22, 0.96);
  backdrop-filter: blur(16px);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.5);
  transform: translateX(-50%);
}

.bulk-actions[data-visible="true"] {
  display: grid;
}

.bulk-actions[data-active="true"] {
  border-color: rgba(121, 215, 162, 0.42);
  background: rgba(24, 50, 37, 0.96);
}

.bulk-summary {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.bulk-summary strong,
.bulk-summary span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bulk-summary span {
  color: var(--muted);
  font-size: 12px;
}

.bulk-summary strong {
  font-size: 12px;
}

.bulk-buttons {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.bulk-buttons button {
  min-width: 0;
  min-height: 40px;
  display: grid;
  place-items: center;
  padding: 0;
}

.content-grid {
  display: grid;
  gap: 12px;
}

.products-table-card {
  overflow: hidden;
}

.table-head {
  min-height: 40px;
  padding: 9px 12px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.products-table {
  display: grid;
  gap: 8px;
  padding: 8px;
}

.products-table[data-bulk-mode="false"] .bulk-check {
  display: none;
}

.products-table[data-bulk-mode="false"] .product-row {
  grid-template-columns: 66px minmax(0, 1fr) 62px;
}

.product-row {
  position: relative;
  display: grid;
  grid-template-columns: 28px 66px minmax(0, 1fr) 62px;
  gap: 8px;
  align-items: center;
  min-height: 112px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.product-row.active,
.product-row:hover {
  border-color: rgba(121, 215, 162, 0.34);
  background: #18211b;
}

.product-row.bulk-selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.bulk-check {
  display: grid;
  place-items: center;
  min-height: 54px;
}

.bulk-check input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.check-box {
  width: 24px;
  height: 24px;
  border: 2px solid var(--line-strong);
  border-radius: 7px;
  background: var(--panel);
}

.bulk-check input:checked + .check-box {
  border-color: var(--accent);
  background: var(--accent);
  box-shadow: inset 0 0 0 5px var(--panel);
}

.bulk-check input:disabled + .check-box {
  opacity: 0.45;
}

.product-thumb {
  width: 66px;
  height: 88px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  object-fit: contain;
  object-position: center;
}

.product-main,
.product-compact-meta {
  min-width: 0;
}

.product-main {
  display: grid;
  gap: 4px;
}

.product-name {
  display: -webkit-box;
  color: var(--text);
  font-weight: 850;
  font-size: 14px;
  line-height: 1.16;
  overflow: hidden;
  text-overflow: ellipsis;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.product-sub {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.product-compact-meta {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
}

.product-compact-meta span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.product-compact-meta span:last-child {
  color: var(--text);
}

.term-card {
  align-self: stretch;
  display: grid;
  align-content: center;
  justify-items: center;
  min-height: 88px;
  border-radius: 8px;
  padding: 6px;
  text-align: center;
}

.term-card strong {
  font-size: 26px;
  line-height: 1;
  letter-spacing: 0;
}

.term-card strong.term-card-word {
  font-size: 11px;
  line-height: 1.08;
  overflow-wrap: anywhere;
}

.term-card span {
  margin-top: 3px;
  font-size: 10px;
  font-weight: 850;
  text-transform: uppercase;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.status-ok {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.status-warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.status-danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.status-review {
  background: var(--review-soft);
  color: var(--review);
}

.detail-panel,
.scanner-panel {
  position: fixed;
  inset: 0;
  z-index: 40;
  width: min(100%, var(--app-width));
  margin: 0 auto;
  background: rgba(0, 0, 0, 0.58);
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.scanner-panel {
  z-index: 45;
}

.detail-panel.open,
.scanner-panel.open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.empty-detail {
  display: none;
}

.detail-card,
.scanner-card {
  min-height: 100dvh;
  max-height: 100dvh;
  overflow: auto;
  border-radius: 0;
  border-left: 0;
  border-right: 0;
  padding: max(12px, env(safe-area-inset-top)) 12px calc(22px + env(safe-area-inset-bottom));
}

.scanner-card {
  display: grid;
  align-content: start;
  gap: 10px;
  background: var(--panel);
}

.scanner-camera {
  position: relative;
  overflow: hidden;
  min-height: 188px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #050806;
}

.scanner-camera video {
  width: 100%;
  height: 100%;
  min-height: 188px;
  object-fit: cover;
  display: block;
}

.scanner-frame {
  position: absolute;
  inset: 28px 42px;
  border: 2px solid rgba(121, 215, 162, 0.82);
  border-radius: 8px;
  box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.28);
}

.scanner-message {
  min-height: 18px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.scanner-message[data-kind="success"] {
  color: var(--accent-strong);
}

.scanner-message[data-kind="error"] {
  color: var(--danger);
}

.scan-code-form {
  display: grid;
  gap: 8px;
}

.scan-code-actions {
  display: grid;
  grid-template-columns: 0.86fr 1fr;
  gap: 8px;
}

.scanner-result {
  display: grid;
  gap: 10px;
}

.am-row.editing {
  align-items: stretch;
}

.am-user-edit-form {
  grid-column: 1 / -1;
  margin-top: 4px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.am-store-editor {
  display: grid;
  gap: 10px;
}

.am-store-editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.am-store-editor-head strong {
  font-size: 14px;
}

.am-store-editor-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.am-store-chip-list,
.am-store-pick-list {
  display: grid;
  gap: 6px;
}

.am-store-chip {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
}

.am-store-chip span {
  overflow-wrap: anywhere;
}

.am-store-pick {
  min-height: 42px;
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--text);
  padding: 8px 10px;
  text-align: left;
}

.am-store-pick strong {
  color: var(--accent-strong);
}

.am-store-pick span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.empty-state.compact {
  padding: 12px;
  text-align: left;
}

.scanner-product {
  display: grid;
  grid-template-columns: 74px 1fr;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.scanner-product img {
  width: 74px;
  height: 74px;
  border-radius: 7px;
  border: 1px solid var(--line);
  object-fit: contain;
  object-position: center;
  background: rgba(255, 255, 255, 0.03);
}

.scanner-product div {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.scanner-product strong,
.scanner-product span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.scanner-product strong {
  color: var(--text);
  font-size: 14px;
  line-height: 1.22;
}

.scanner-product span {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.3;
}

.scan-expiry-form {
  display: grid;
  gap: 10px;
}

.detail-sheet-head {
  position: sticky;
  top: calc(-1 * max(12px, env(safe-area-inset-top)));
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: calc(-1 * max(12px, env(safe-area-inset-top))) -12px 12px;
  padding: max(12px, env(safe-area-inset-top)) 12px 10px;
  border-bottom: 1px solid var(--line);
  background: rgba(20, 27, 22, 0.96);
  backdrop-filter: blur(16px);
}

.sheet-close {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  padding: 8px 10px;
  font-weight: 850;
}

.detail-hero {
  display: grid;
  gap: 10px;
}

.detail-image {
  width: 100%;
  aspect-ratio: 16 / 10;
  border: 1px solid var(--line);
  border-radius: 8px;
  object-fit: contain;
  object-position: center;
  background: var(--panel-soft);
}

.detail-title {
  display: grid;
  gap: 6px;
}

.detail-title strong {
  font-size: 20px;
  line-height: 1.16;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.detail-fact {
  min-width: 0;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.detail-fact span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.detail-fact strong {
  display: block;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.detail-actions [data-history] {
  grid-column: 1 / -1;
}

.expiry-form,
.photo-form {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.form-section-title {
  display: grid;
  gap: 2px;
}

.form-section-title span {
  color: var(--muted);
  font-size: 12px;
}

.expiry-fields,
.photo-fields {
  display: grid;
  gap: 8px;
}

.photo-fields input[type="file"] {
  min-width: 0;
  width: 100%;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
}

.history-list {
  display: grid;
  gap: 8px;
}

.history-item {
  padding: 9px;
  border-left: 3px solid var(--line-strong);
  border-radius: 7px;
  background: var(--panel-soft);
}

.history-item strong,
.history-item span {
  display: block;
}

.history-item span {
  color: var(--muted);
  font-size: 12px;
}

.loading-state,
.empty-state {
  padding: 26px 14px;
  color: var(--muted);
  text-align: center;
}

.empty-state.compact {
  padding: 10px;
  font-size: 12px;
}

.am-layout {
  display: grid;
  gap: 12px;
}

.am-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 8px;
}

.am-tab {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--muted);
  padding: 8px 14px;
  font-weight: 850;
}

.am-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #07100b;
}

.am-filters .ghost-button.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.am-section,
.am-table-card {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 12px;
}

.am-report-workspace-section {
  gap: 9px;
  padding: 10px;
  background:
    linear-gradient(180deg, rgba(20, 27, 22, 0.96), rgba(13, 18, 15, 0.96)),
    var(--panel);
}

.am-report-workspace-section .am-section-head {
  align-items: end;
}

.am-report-workspace-section .metric-grid {
  grid-auto-flow: row;
  grid-template-columns: repeat(auto-fit, minmax(108px, 1fr));
  gap: 7px;
  margin-bottom: 0;
  overflow: visible;
}

.am-report-workspace-section .metric-card {
  min-height: 44px;
  padding: 7px 9px;
  border-color: rgba(89, 107, 93, 0.7);
  background: linear-gradient(180deg, rgba(29, 38, 31, 0.9), rgba(18, 25, 21, 0.92));
}

.am-section h2,
.am-table-card h3 {
  margin: 0;
  font-size: 16px;
  letter-spacing: 0;
}

.am-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.am-filters,
.am-upload-form,
.am-account-form {
  display: grid;
  gap: 8px;
}

@media (min-width: 860px) {
  body.am-mode .workspace {
    padding: 14px 18px 28px;
  }

  body.am-mode .rail {
    display: none;
  }

  .am-layout {
    gap: 16px;
  }

  .am-upload-form,
  .am-account-form,
  .am-filters {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    align-items: end;
  }

  .am-rule-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .am-table {
    gap: 8px;
  }
}

@media (max-width: 859px) {
  .am-price-tags-workspace,
  .am-actions-workspace {
    grid-template-columns: 1fr;
  }

  .am-price-tag-summary-grid {
    grid-template-columns: 1fr;
  }

  .am-price-tag-batch-row {
    grid-template-columns: 1fr 1fr;
  }

  .am-report-summary,
  .am-category-chip-grid {
    grid-template-columns: 1fr 1fr;
  }

  .am-rule-row {
    grid-template-columns: 1fr;
  }

  .am-rule-actions {
    justify-content: start;
  }
}

@media (max-width: 520px) {
  .am-report-summary,
  .am-category-chip-grid {
    grid-template-columns: 1fr;
  }
}

.am-wide-field {
  grid-column: 1 / -1;
}

.am-upload-form input[type="file"] {
  padding: 9px;
}

.am-import-form textarea {
  min-height: 140px;
  resize: vertical;
  font-family: inherit;
  line-height: 1.35;
}

.am-actions-workspace {
  display: grid;
  grid-template-columns: minmax(360px, 520px) minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.am-rule-form,
.am-rule-list-panel {
  min-width: 0;
  border: 1px solid rgba(89, 107, 93, 0.72);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(22, 31, 25, 0.96), rgba(15, 21, 17, 0.96)),
    var(--panel);
  padding: 12px;
}

.am-rule-form textarea {
  min-height: 150px;
  resize: vertical;
  font-family: inherit;
  line-height: 1.35;
}

.am-rule-options {
  display: grid;
  gap: 10px;
  min-height: 80px;
  padding: 10px;
  border: 1px solid rgba(89, 107, 93, 0.72);
  border-radius: 8px;
  background: rgba(11, 17, 13, 0.72);
}

.am-rule-options-head {
  display: grid;
  gap: 3px;
}

.am-rule-options-head strong,
.am-rule-option-section h4 {
  margin: 0;
  color: var(--text);
  font-size: 12px;
  font-weight: 900;
}

.am-rule-options-head span {
  color: var(--muted);
  font-size: 11px;
}

.am-rule-option-section {
  display: grid;
  gap: 7px;
}

.am-rule-option-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 132px;
  overflow: auto;
}

.am-rule-option-chip {
  max-width: 260px;
  min-height: 30px;
  overflow: hidden;
  padding: 6px 9px;
  border: 1px solid rgba(121, 215, 162, 0.38);
  border-radius: 999px;
  color: var(--text);
  background: rgba(24, 50, 37, 0.42);
  font: inherit;
  font-size: 11px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}

.am-rule-option-chip:hover {
  border-color: rgba(121, 215, 162, 0.72);
  background: rgba(35, 70, 52, 0.72);
}

.am-rule-list {
  display: grid;
  gap: 8px;
}

.am-rule-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, 260px) auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(19, 27, 22, 0.92);
}

.am-rule-row.active {
  border-color: rgba(121, 215, 162, 0.5);
}

.am-rule-row.inactive {
  opacity: 0.68;
}

.am-rule-main,
.am-rule-meta,
.am-rule-actions {
  min-width: 0;
}

.am-rule-main {
  display: grid;
  gap: 3px;
}

.am-rule-main strong {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.am-rule-main span,
.am-rule-meta span {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.am-rule-meta {
  display: grid;
  gap: 3px;
}

.am-rule-actions {
  display: flex;
  gap: 6px;
  justify-content: end;
  flex-wrap: wrap;
}

.am-rule-actions .ghost-button,
.am-rule-actions .danger-button {
  min-height: 34px;
  padding: 7px 9px;
  font-size: 11px;
}

.am-price-tags-workspace {
  display: grid;
  grid-template-columns: minmax(340px, 460px) minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.am-price-tag-form,
.am-price-tag-summary-panel {
  min-width: 0;
  border: 1px solid rgba(89, 107, 93, 0.72);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(22, 31, 25, 0.96), rgba(15, 21, 17, 0.96)),
    var(--panel);
  padding: 12px;
}

.am-price-tag-form {
  grid-template-columns: 1fr;
}

.am-price-tag-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.am-price-tag-type-card {
  display: grid;
  gap: 5px;
  min-width: 0;
  padding: 10px;
  border: 1px solid rgba(121, 215, 162, 0.28);
  border-radius: 8px;
  background: rgba(17, 27, 22, 0.94);
}

.am-price-tag-type-card span,
.am-price-tag-type-card small {
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.am-price-tag-type-card strong {
  color: var(--text);
  font-size: 24px;
  line-height: 1;
}

.am-price-tag-batches {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.am-price-tag-batches h4 {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.am-price-tag-batch-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) repeat(3, minmax(80px, auto));
  gap: 8px;
  align-items: center;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(19, 27, 22, 0.92);
}

.am-price-tag-batch-row div {
  min-width: 0;
}

.am-price-tag-batch-row strong,
.am-price-tag-batch-row span {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.am-price-tag-batch-row strong {
  color: var(--text);
  font-size: 12px;
}

.am-price-tag-batch-row span {
  color: var(--muted);
  font-size: 11px;
}

.am-checkbox {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.am-checkbox input {
  width: 18px;
  min-height: 18px;
}

.am-report-grid {
  display: grid;
  grid-template-columns: minmax(880px, 1fr) minmax(320px, 380px);
  align-items: start;
  gap: 10px;
}

.am-table {
  display: grid;
  gap: 8px;
}

.am-report-main-card {
  min-width: 0;
}

.am-report-insights-card {
  position: sticky;
  top: 12px;
  max-height: calc(100dvh - 130px);
  overflow: auto;
  scrollbar-width: thin;
}

.am-report-body {
  display: grid;
  min-width: 0;
  gap: 8px;
}

.am-report-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.am-report-summary > div {
  min-width: 0;
  padding: 7px 9px;
  border: 1px solid rgba(61, 74, 64, 0.7);
  border-radius: 8px;
  background: rgba(18, 25, 21, 0.86);
}

.am-report-summary span,
.am-report-cardlet h4 {
  display: block;
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}

.am-report-summary strong {
  display: block;
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.am-column-settings {
  border: 1px solid rgba(89, 107, 93, 0.72);
  border-radius: 8px;
  background: rgba(12, 18, 14, 0.72);
}

.am-column-settings summary {
  min-height: 34px;
  padding: 9px 11px;
  color: var(--text);
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
}

.am-column-toggle-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 0 10px 10px;
}

.am-column-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 5px 8px;
  border: 1px solid rgba(121, 215, 162, 0.32);
  border-radius: 999px;
  color: var(--text);
  background: rgba(24, 50, 37, 0.34);
  font-size: 11px;
  font-weight: 850;
}

.am-column-toggle.locked {
  opacity: 0.72;
}

.am-report-scroll {
  overflow: auto;
  min-height: 520px;
  max-height: calc(100dvh - 260px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(246, 250, 246, 0.035);
  scrollbar-width: thin;
}

.am-report-mobile-list {
  display: none;
}

.am-report-mobile-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(121, 215, 162, 0.2);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(24, 40, 30, 0.94), rgba(15, 22, 18, 0.96));
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.2);
}

.am-report-mobile-card.is-empty {
  opacity: 0.68;
}

.am-report-mobile-card header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
}

.am-report-mobile-card header strong,
.am-report-mobile-card header span,
.am-report-mobile-card header em {
  display: block;
  min-width: 0;
}

.am-report-mobile-card header strong {
  color: var(--text);
  font-size: 17px;
  font-weight: 950;
}

.am-report-mobile-card header span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.25;
}

.am-report-mobile-card header em {
  color: #d6f2c0;
  font-size: 16px;
  font-style: normal;
  font-weight: 950;
  text-align: right;
  white-space: nowrap;
}

.am-mobile-report-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.am-mobile-report-kpis span,
.am-mobile-report-categories span {
  display: grid;
  min-width: 0;
  gap: 2px;
  padding: 7px;
  border: 1px solid rgba(121, 215, 162, 0.18);
  border-radius: 8px;
  background: rgba(8, 14, 11, 0.44);
}

.am-mobile-report-kpis b,
.am-mobile-report-categories b {
  overflow: hidden;
  color: var(--text);
  font-size: 12px;
  font-weight: 950;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.am-mobile-report-kpis small,
.am-mobile-report-categories small,
.am-mobile-report-time {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

.am-mobile-report-time {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
}

.am-mobile-report-categories {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.am-report-table {
  width: 100%;
  min-width: 1240px;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 11px;
  line-height: 1.12;
}

.am-report-table th,
.am-report-table td {
  padding: 5px 7px;
  border-right: 1px solid rgba(128, 143, 132, 0.34);
  border-bottom: 1px solid rgba(128, 143, 132, 0.34);
  text-align: center;
  white-space: nowrap;
  background: rgba(18, 24, 21, 0.98);
}

.am-report-table th {
  position: sticky;
  top: 0;
  z-index: 3;
  color: #162018;
  background: #b8d4ea;
  font-weight: 900;
}

.am-report-table tbody tr:nth-child(even) td {
  background: rgba(27, 34, 30, 0.98);
}

.am-report-table tbody tr.am-report-empty-row td {
  color: var(--soft-text);
}

.am-report-table tfoot td {
  position: sticky;
  bottom: 0;
  z-index: 2;
  color: #172018;
  background: #d6e9bb;
  font-weight: 950;
}

.am-report-table .am-sticky-time,
.am-report-table .am-sticky-store {
  position: sticky;
  z-index: 4;
}

.am-report-table .am-sticky-time {
  left: 0;
  width: 64px;
  min-width: 64px;
}

.am-report-table .am-sticky-store {
  left: 64px;
  width: 286px;
  min-width: 286px;
  text-align: left;
  box-shadow: 1px 0 0 rgba(128, 143, 132, 0.5);
}

.am-report-table td.am-sticky-time,
.am-report-table td.am-sticky-store {
  background: rgba(18, 24, 21, 0.99);
}

.am-report-table tbody tr:nth-child(even) td.am-sticky-time,
.am-report-table tbody tr:nth-child(even) td.am-sticky-store {
  background: rgba(27, 34, 30, 0.99);
}

.am-report-table th.am-sticky-time,
.am-report-table th.am-sticky-store {
  background: #b8d4ea;
}

.am-report-table tfoot .am-sticky-time,
.am-report-table tfoot .am-sticky-store {
  background: #d6e9bb;
}

.am-report-table td.am-sticky-store strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
}

.am-report-table td.am-sticky-store span {
  display: block;
  margin-top: 2px;
  overflow: hidden;
  color: var(--muted);
  font-size: 9px;
  text-overflow: ellipsis;
}

.am-report-table .am-heat-good {
  color: #142015;
  background: #96d58d !important;
  font-weight: 900;
}

.am-report-table .am-heat-mid {
  color: #251f0d;
  background: #f3d36c !important;
  font-weight: 900;
}

.am-report-table .am-heat-low {
  color: #2d1212;
  background: #ef8b7f !important;
  font-weight: 900;
}

.am-report-table .am-category-cell {
  min-width: 72px;
}

.am-report-side {
  display: grid;
  gap: 10px;
}

.am-report-cardlet {
  display: grid;
  gap: 8px;
  padding-top: 2px;
}

.am-report-cardlet + .am-report-cardlet {
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.am-category-chip-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.am-category-chip {
  display: grid;
  gap: 2px;
  min-width: 0;
  padding: 7px;
  border: 1px dashed rgba(121, 215, 162, 0.38);
  border-radius: 8px;
  background: rgba(24, 50, 37, 0.36);
}

.am-category-chip.active {
  border-style: solid;
  border-color: rgba(121, 215, 162, 0.72);
  background: rgba(24, 50, 37, 0.62);
}

.am-category-chip strong,
.am-category-chip small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.am-category-chip strong {
  color: var(--text);
  font-size: 12px;
}

.am-category-chip small {
  color: var(--muted);
  font-size: 10px;
}

.am-diagnostic-list {
  display: grid;
  gap: 7px;
}

.am-diagnostic-list div {
  display: grid;
  gap: 2px;
  padding: 7px 0;
  border-bottom: 1px solid rgba(61, 74, 64, 0.6);
}

.am-diagnostic-list div:last-child {
  border-bottom: 0;
}

.am-diagnostic-list strong {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.am-diagnostic-list span {
  color: var(--muted);
  font-size: 11px;
}

.am-products-compact .am-row {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  padding: 8px;
}

@media (max-width: 1280px) {
  .am-report-grid {
    grid-template-columns: 1fr;
  }

  .am-actions-workspace {
    grid-template-columns: 1fr;
  }

  .am-report-insights-card {
    position: static;
    max-height: none;
  }

  .am-report-scroll {
    max-height: 68vh;
  }
}

@media (max-width: 760px) {
  .am-report-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .am-column-settings summary {
    min-height: 40px;
  }

  .am-column-toggle-grid {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 12px;
  }

  .am-column-toggle {
    flex: 0 0 auto;
  }

  .am-report-mobile-list {
    display: grid;
    gap: 8px;
  }

  .am-report-scroll {
    display: none;
  }

  .am-mobile-report-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .am-mobile-report-categories {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 1400px) {
  .am-report-table {
    font-size: 11.5px;
  }
}

.am-row,
.am-cash-row {
  display: grid;
  gap: 6px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.am-row strong,
.am-cash-row strong {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
}

.am-row span,
.am-cash-row span,
.am-result {
  color: var(--muted);
  font-size: 12px;
}

.am-cash-row select {
  min-height: 40px;
}

.rail {
  position: fixed;
  left: 50%;
  right: auto;
  bottom: 0;
  z-index: 30;
  width: min(100%, var(--app-width));
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 5px;
  padding: 8px max(10px, env(safe-area-inset-left)) calc(8px + env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-right));
  border-top: 1px solid rgba(61, 74, 64, 0.78);
  background: rgba(13, 18, 15, 0.94);
  backdrop-filter: blur(18px);
}

.rail-item {
  min-height: 48px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  padding: 7px 4px;
  text-align: center;
  font-size: 11px;
  font-weight: 850;
}

.rail-item.active {
  background: var(--accent-soft);
  color: var(--accent-strong);
  border-color: rgba(121, 215, 162, 0.42);
}

.rail-item.muted {
  opacity: 0.55;
}

@media (min-width: 720px) {
  .app-shell {
    min-height: calc(100dvh - 28px);
    margin-top: 14px;
    margin-bottom: 14px;
    border-radius: 18px;
  }

  .workspace {
    min-height: calc(100dvh - 28px);
  }

  .detail-panel,
  .scanner-panel {
    left: 50%;
    right: auto;
    transform: translate(-50%, 12px);
  }

  .detail-panel.open,
  .scanner-panel.open {
    transform: translate(-50%, 0);
  }

  .detail-card,
  .scanner-card {
    min-height: calc(100dvh - 28px);
    max-height: calc(100dvh - 28px);
    border-radius: 18px 18px 0 0;
  }

  .scan-fab {
    right: calc((100vw - var(--app-width)) / 2 + 18px);
  }
}

@media (max-width: 390px) {
  .workspace {
    padding-left: 10px;
    padding-right: 10px;
  }

  .topbar,
  .detail-sheet-head {
    margin-left: -10px;
    margin-right: -10px;
    padding-left: 10px;
    padding-right: 10px;
  }

  .bulk-buttons,
  .detail-grid,
  .detail-actions {
    grid-template-columns: 1fr;
  }

  .product-row {
    grid-template-columns: 26px 58px minmax(0, 1fr) 54px;
  }

  .products-table[data-bulk-mode="false"] .product-row {
    grid-template-columns: 58px minmax(0, 1fr) 54px;
  }

  .product-thumb {
    width: 58px;
    height: 78px;
  }

  .term-card {
    min-height: 78px;
  }

  .term-card strong {
    font-size: 23px;
  }

  .term-card strong.term-card-word {
    font-size: 10px;
  }

  .product-compact-meta {
    grid-template-columns: 1fr;
    gap: 1px;
  }

  .scan-fab {
    right: 14px;
    bottom: calc(78px + env(safe-area-inset-bottom));
    width: 62px;
    height: 62px;
    min-height: 62px;
  }
}
