:root {
  --amt-navy: #071a2d;
  --amt-blue: #0b6f9c;
  --amt-blue-soft: #eaf5fa;
  --amt-border: #d8e2ed;
  --amt-text: #0b1f35;
  --amt-muted: #667991;
  --amt-bg: #f4f7fb;
  --amt-success: #138a5b;
  --amt-error: #c63737;
}

.amt-modal-open { overflow: hidden !important; }

.amt-icon { display: inline-flex; width: 17px; height: 17px; flex: 0 0 auto; }
.amt-icon svg,
.amt-close svg,
.amt-camera-placeholder__icon svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.amt-toolbar-button,
.amt-card-code-button,
.amt-button,
.amt-tab,
.amt-mode-tab,
.amt-close { font: inherit; }

.amt-toolbar-button {
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 0 16px;
  border: 1px solid #bcd0df;
  border-radius: 7px;
  background: #fff;
  color: var(--amt-navy);
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background .16s, border-color .16s, transform .16s;
}
.amt-toolbar-button:hover { background: var(--amt-blue-soft); border-color: #74adc6; }
.amt-toolbar-button:active { transform: translateY(1px); }

.amt-card-code-button {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 11px;
  margin-left: auto;
  border: 1px solid #cfdcea;
  border-radius: 7px;
  background: #fff;
  color: #536d8b;
  cursor: pointer;
  transition: color .16s, border-color .16s, background .16s;
}
.amt-card-code-button + button { margin-left: 0 !important; }
.amt-card-code-button:hover { color: var(--amt-blue); border-color: #8dbbd0; background: #f4fafc; }

.amt-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(3, 16, 31, .60);
  backdrop-filter: blur(3px);
  opacity: 0;
  transition: opacity .18s ease;
}
.amt-overlay.is-open { opacity: 1; }

.amt-dialog {
  width: min(860px, 100%);
  max-height: min(90vh, 820px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(216, 226, 237, .85);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 28px 80px rgba(0, 19, 41, .28);
  color: var(--amt-text);
  transform: translateY(9px) scale(.99);
  transition: transform .18s ease;
}
.amt-overlay.is-open .amt-dialog { transform: translateY(0) scale(1); }
.amt-dialog__header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding: 22px 24px 18px; border-bottom: 1px solid #e4ebf2; }
.amt-dialog__title { margin: 0; font-size: 22px; line-height: 1.25; font-weight: 750; color: var(--amt-navy); }
.amt-dialog__subtitle { margin: 5px 0 0; font-size: 14px; color: var(--amt-muted); }
.amt-dialog__body { padding: 22px 24px 24px; overflow: auto; }
.amt-close { width: 36px; height: 36px; display: grid; place-items: center; flex: 0 0 auto; padding: 9px; border: 1px solid #d9e3ed; border-radius: 8px; color: #53687f; background: #fff; cursor: pointer; }
.amt-close:hover { background: #f1f5f9; color: var(--amt-navy); }

.amt-code-meta { display: grid; grid-template-columns: 1.5fr .9fr 1fr; gap: 10px; margin-bottom: 18px; }
.amt-detail { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.amt-detail__label { font-size: 11px; font-weight: 700; letter-spacing: .045em; text-transform: uppercase; color: #7b8da3; }
.amt-detail__value { overflow: hidden; font-size: 14px; color: var(--amt-text); text-overflow: ellipsis; white-space: nowrap; }

.amt-tabs { display: flex; gap: 5px; padding: 4px; border-radius: 9px; background: #eef3f8; }
.amt-tab { flex: 1; padding: 10px 14px; border: 0; border-radius: 7px; background: transparent; color: #60738b; font-weight: 650; cursor: pointer; }
.amt-tab.is-active { background: #fff; color: var(--amt-navy); box-shadow: 0 1px 4px rgba(4, 25, 47, .10); }
.amt-code-stage { min-height: 330px; display: grid; place-items: center; margin-top: 14px; padding: 26px; border: 1px dashed #cbd9e6; border-radius: 12px; background: #f8fafc; }
.amt-code-panel { display: none; width: 100%; text-align: center; }
.amt-code-panel.is-active { display: block; }
.amt-barcode-canvas { display: block; width: min(100%, 620px); height: auto; max-height: 180px; margin: 0 auto; }
.amt-qr-canvas { display: block; width: min(280px, 75vw); height: auto; margin: 0 auto; }
.amt-qr-hint { margin: 13px 0 0; color: var(--amt-muted); font-size: 13px; text-align: center; }
.amt-dialog__actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

.amt-button { min-height: 40px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 15px; border: 1px solid transparent; border-radius: 8px; font-weight: 650; cursor: pointer; transition: background .16s, border-color .16s, opacity .16s; }
.amt-button:disabled { opacity: .58; cursor: wait; }
.amt-button--primary { background: var(--amt-navy); color: #fff; border-color: var(--amt-navy); }
.amt-button--primary:hover:not(:disabled) { background: #123553; }
.amt-button--secondary { background: #fff; color: var(--amt-navy); border-color: #cdd9e5; }
.amt-button--secondary:hover { background: #f3f7fa; }
.amt-button--camera { position: absolute; z-index: 3; left: 50%; bottom: 14px; transform: translateX(-50%); min-width: 170px; background: rgba(255,255,255,.96); color: var(--amt-navy); border-color: rgba(255,255,255,.85); box-shadow: 0 5px 18px rgba(2,17,32,.22); }

.amt-mode-tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; margin-bottom: 18px; }
.amt-mode-tab { min-height: 42px; padding: 9px 10px; border: 1px solid #d4e0eb; border-radius: 8px; background: #fff; color: #5b6f86; font-weight: 650; cursor: pointer; }
.amt-mode-tab:hover { border-color: #9cbdd0; }
.amt-mode-tab.is-active { border-color: var(--amt-blue); background: var(--amt-blue-soft); color: #075f89; box-shadow: inset 0 0 0 1px rgba(11,111,156,.12); }

.amt-scanner-grid { display: grid; grid-template-columns: 1.08fr .92fr; gap: 16px; }
.amt-camera-box { position: relative; min-height: 230px; overflow: hidden; border-radius: 12px; background: #0b2035; }
.amt-camera-video { position: absolute; z-index: 1; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #071a2d; }
.amt-camera-placeholder { position: absolute; z-index: 2; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding-bottom: 42px; color: #d9e6f2; text-align: center; background: radial-gradient(circle at 50% 35%, #183b58, #091b2e 72%); }
.amt-camera-placeholder[hidden] { display: none !important; }
.amt-camera-placeholder::after { content: ''; width: 52%; height: 40%; position: absolute; top: 23%; border: 2px solid rgba(255,255,255,.58); border-radius: 8px; box-shadow: 0 0 0 999px rgba(0,0,0,.08); }
.amt-camera-placeholder__icon { width: 27px; height: 27px; margin-bottom: 5px; }
.amt-camera-placeholder strong { font-size: 15px; }
.amt-camera-placeholder span:last-child { font-size: 12px; color: #9db3c8; }
.amt-manual-box { display: flex; flex-direction: column; justify-content: center; padding: 24px; border: 1px solid #dbe5ee; border-radius: 12px; background: #f8fafc; }
.amt-manual-box h3 { margin: 0; font-size: 17px; color: var(--amt-navy); }
.amt-manual-box p { margin: 7px 0 16px; font-size: 13px; line-height: 1.45; color: var(--amt-muted); }
.amt-photo-button { width: 100%; margin-top: 14px; }
.amt-photo-input { display: none !important; }
.amt-manual-divider { display: flex; align-items: center; gap: 9px; margin: 15px 0 4px; color: #7b8da3; font-size: 11px; font-weight: 700; letter-spacing: .035em; text-transform: uppercase; }
.amt-manual-divider::before,
.amt-manual-divider::after { content: ''; height: 1px; flex: 1; background: #dbe4ed; }
.amt-search-row { display: flex; gap: 8px; }
.amt-search-row .amt-input { flex: 1; min-width: 0; }

.amt-input { width: 100%; min-height: 42px; padding: 9px 11px; border: 1px solid #cbd8e5; border-radius: 8px; outline: 0; background: #fff; color: var(--amt-text); font: inherit; font-size: 14px; }
.amt-input:focus { border-color: #328cb3; box-shadow: 0 0 0 3px rgba(50,140,179,.13); }
.amt-textarea { resize: vertical; }

.amt-result-area { margin-top: 16px; }
.amt-empty-result,
.amt-not-found { min-height: 66px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 15px; border: 1px dashed #cddae6; border-radius: 10px; color: #718399; font-size: 13px; text-align: center; }
.amt-not-found { border-color: #e7bcbc; background: #fff8f8; color: #9c4141; }
.amt-item-summary { padding: 16px; border: 1px solid #b9d8c9; border-radius: 11px; background: #f3fbf7; }
.amt-item-summary__top { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.amt-item-summary__top > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.amt-item-summary__eyebrow { font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--amt-success); }
.amt-item-summary__name { overflow: hidden; color: #0c3c2b; text-overflow: ellipsis; white-space: nowrap; }
.amt-stock-badge { flex: 0 0 auto; padding: 6px 10px; border-radius: 999px; background: #dcefe5; color: #126c49; font-size: 13px; font-weight: 750; }
.amt-item-summary__details { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-top: 13px; padding-top: 12px; border-top: 1px solid #cfe5da; }

.amt-operation { margin-top: 16px; padding: 17px; border: 1px solid #d7e2ed; border-radius: 11px; background: #f8fafc; }
.amt-operation__title { margin: 0 0 13px; font-size: 16px; color: var(--amt-navy); }
.amt-operation__grid { display: grid; grid-template-columns: .58fr 1.25fr 1.5fr; gap: 12px; align-items: end; }
.amt-field { display: flex; flex-direction: column; gap: 5px; }
.amt-field__label { font-size: 12px; font-weight: 650; color: #53677e; }
.amt-operation__submit { display: flex; justify-content: flex-end; margin-top: 14px; }

.amt-location-dialog { width: min(980px, 100%); }
.amt-location-loading { min-height: 180px; display: grid; place-items: center; color: var(--amt-muted); }
.amt-location-controls { display: grid; grid-template-columns: minmax(260px, 1fr) minmax(190px, auto) auto; gap: 14px; align-items: end; padding: 16px; border: 1px solid #d9e3ed; border-radius: 11px; background: #f7f9fc; }
.amt-location-summary { min-height: 42px; display: flex; flex-direction: column; justify-content: center; gap: 2px; }
.amt-location-summary span { color: #708198; font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.amt-location-summary strong { color: var(--amt-text); font-size: 14px; }
.amt-location-print-button { min-width: 142px; }
.amt-location-preview-area { display: grid; place-items: center; gap: 12px; margin-top: 17px; padding: 24px; border-radius: 11px; background: #dfe6ee; }
.amt-location-sheet { width: min(100%, 590px); min-height: 795px; display: flex; flex-direction: column; padding: 30px; color: #101820; background: #fff; box-shadow: 0 16px 36px rgba(19, 38, 58, .22); }
.amt-location-preview-loading { min-height: 380px; display: grid; place-items: center; color: #617287; }
.amt-location-sheet__header { display: flex; align-items: flex-start; justify-content: space-between; gap: 22px; padding-bottom: 15px; border-bottom: 2px solid #15263c; }
.amt-location-sheet__logo { display: block; width: 128px; height: auto; }
.amt-location-sheet__header-meta { display: grid; justify-items: end; gap: 5px; padding-top: 6px; color: #536273; font-size: 12px; }
.amt-location-sheet__header-meta strong { color: #15263c; letter-spacing: .05em; }
.amt-location-sheet__location { display: grid; place-content: center; justify-items: center; gap: 4px; min-height: 112px; text-align: center; }
.amt-location-sheet__location > span { font-size: 11px; font-weight: 700; letter-spacing: .15em; }
.amt-location-sheet__location > strong { font-size: 48px; line-height: 1; color: #101820; }
.amt-location-sheet__location > small { color: #536273; font-size: 13px; }
.amt-location-sheet__items { display: grid; gap: 10px; }
.amt-location-sheet__item { min-height: 125px; display: grid; grid-template-columns: 92px minmax(0, 1fr); align-items: center; gap: 17px; padding: 12px; border: 1px solid #aeb9c5; }
.amt-location-sheet__qr { display: block; width: 88px; height: 88px; object-fit: contain; }
.amt-location-sheet__item-info { min-width: 0; display: grid; justify-items: start; gap: 5px; }
.amt-location-sheet__item-info h3 { margin: 0; color: #101820; font-size: 16px; line-height: 1.25; }
.amt-location-sheet__item-info code { display: inline-block; padding: 3px 7px; border: 1px solid #aeb9c5; color: #101820; background: #fff; font-size: 12px; font-weight: 700; }
.amt-location-sheet__item-info span { color: #4f5d6b; font-size: 12px; }
.amt-location-sheet__footer { display: flex; justify-content: space-between; gap: 16px; margin-top: auto; padding-top: 15px; border-top: 1px solid #aeb9c5; color: #586778; font-size: 11px; }
.amt-location-more-pages { width: min(100%, 590px); padding: 10px 12px; border-radius: 8px; color: #455970; background: rgba(255,255,255,.82); font-size: 13px; text-align: center; }
.amt-location-more-pages[hidden] { display: none; }

.amt-toast-region { position: fixed; z-index: 11000; right: 20px; bottom: 20px; width: min(420px, calc(100vw - 40px)); display: flex; flex-direction: column; gap: 9px; pointer-events: none; }
.amt-toast { padding: 13px 15px; border-radius: 9px; color: #fff; font-size: 14px; line-height: 1.4; box-shadow: 0 12px 35px rgba(0,0,0,.2); opacity: 0; transform: translateY(8px); transition: opacity .2s, transform .2s; }
.amt-toast.is-visible { opacity: 1; transform: translateY(0); }
.amt-toast--success { background: #126c49; }
.amt-toast--error { background: #9f3030; }

@media (max-width: 760px) {
  .amt-overlay { padding: 10px; align-items: end; }
  .amt-dialog { max-height: 94vh; border-radius: 15px 15px 8px 8px; }
  .amt-dialog__header { padding: 18px 17px 14px; }
  .amt-dialog__body { padding: 16px 17px 20px; }
  .amt-dialog__title { font-size: 19px; }
  .amt-dialog__subtitle { font-size: 12px; }
  .amt-mode-tabs { grid-template-columns: repeat(2, 1fr); }
  .amt-scanner-grid { grid-template-columns: 1fr; }
  .amt-camera-box { min-height: 210px; }
  .amt-manual-box { padding: 17px; }
  .amt-item-summary__details { grid-template-columns: repeat(2, 1fr); }
  .amt-operation__grid { grid-template-columns: 1fr; }
  .amt-code-meta { grid-template-columns: 1fr 1fr; }
  .amt-code-meta .amt-detail:first-child { grid-column: 1 / -1; }
  .amt-code-stage { min-height: 270px; padding: 15px; }
  .amt-dialog__actions { flex-direction: column-reverse; }
  .amt-dialog__actions .amt-button { width: 100%; }
  .amt-toolbar-button { padding: 0 12px; }
  .amt-location-controls { grid-template-columns: 1fr; align-items: stretch; padding: 13px; }
  .amt-location-print-button { width: 100%; }
  .amt-location-preview-area { padding: 12px; }
  .amt-location-sheet { min-height: 650px; padding: 18px; }
  .amt-location-sheet__logo { width: 105px; }
  .amt-location-sheet__location { min-height: 92px; }
  .amt-location-sheet__location > strong { font-size: 40px; }
  .amt-location-sheet__item { min-height: 108px; grid-template-columns: 76px minmax(0, 1fr); gap: 12px; padding: 10px; }
  .amt-location-sheet__qr { width: 72px; height: 72px; }
  .amt-location-sheet__item-info h3 { font-size: 14px; }
}

@media (max-width: 480px) {
  .amt-search-row { flex-direction: column; }
  .amt-item-summary__details { grid-template-columns: 1fr; }
  .amt-toolbar-button { width: 42px; padding: 0; font-size: 0; }
  .amt-toolbar-button .amt-icon { width: 19px; height: 19px; }
  .amt-card-code-button { padding-inline: 9px; }
  .amt-location-preview-area { padding: 8px; }
  .amt-location-sheet { min-height: 560px; padding: 13px; }
  .amt-location-sheet__header { gap: 10px; padding-bottom: 10px; }
  .amt-location-sheet__logo { width: 88px; }
  .amt-location-sheet__header-meta { font-size: 10px; }
  .amt-location-sheet__location { min-height: 82px; }
  .amt-location-sheet__location > strong { font-size: 35px; }
  .amt-location-sheet__item { min-height: 92px; grid-template-columns: 59px minmax(0, 1fr); gap: 9px; padding: 8px; }
  .amt-location-sheet__qr { width: 56px; height: 56px; }
  .amt-location-sheet__item-info { gap: 3px; }
  .amt-location-sheet__item-info h3 { font-size: 12px; }
  .amt-location-sheet__item-info code,
  .amt-location-sheet__item-info span { font-size: 10px; }
  .amt-location-sheet__footer { font-size: 9px; }
}
