:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --text: #17202a;
  --muted: #6c7683;
  --line: #dce2e8;
  --blue: #255fbb;
  --blue-dark: #173e7c;
  --green: #0b7a3b;
  --green-soft: #e7f7ee;
  --red: #b42318;
  --red-soft: #fdecea;
  --yellow: #946200;
  --yellow-soft: #fff6db;
  --shadow: 0 18px 40px rgba(23, 32, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px clamp(14px, 3vw, 28px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(10px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 8px;
  background: var(--blue);
  color: #ffffff;
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
}

.brand small,
.role-badge,
.eyebrow,
.panel-label,
.mode-help,
.last-scan span,
.metric span {
  color: var(--muted);
}

.session {
  display: flex;
  align-items: center;
  gap: 8px;
}

.session select,
#actionPeriod {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 0 10px;
}

.role-badge {
  min-width: 78px;
  padding: 7px 9px;
  border-radius: 999px;
  background: #eef2f7;
  text-align: center;
  font-size: 13px;
}

main {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: clamp(16px, 4vw, 32px);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.home-hero {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 20px;
  align-items: end;
  padding: clamp(18px, 4vw, 34px) 0 26px;
}

.eyebrow,
.panel-label {
  margin: 0 0 8px;
  text-transform: uppercase;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  max-width: 820px;
  margin-bottom: 0;
  font-size: clamp(30px, 5vw, 58px);
  line-height: 1.02;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(22px, 3vw, 34px);
  letter-spacing: 0;
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
}

.status-strip div,
.metric {
  background: var(--panel);
  padding: 18px;
}

.status-strip span,
.metric strong {
  display: block;
  font-size: 30px;
  font-weight: 800;
}

.status-strip small,
.metric span {
  display: block;
  margin-top: 4px;
}

.module-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.module-tile {
  min-height: 168px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  color: var(--text);
  text-align: left;
}

.module-tile.primary {
  background: var(--blue);
  color: #ffffff;
}

.module-tile span,
.module-tile strong,
.module-tile small {
  display: block;
}

.module-tile span {
  margin-bottom: 34px;
  color: inherit;
  opacity: 0.78;
}

.module-tile strong {
  margin-bottom: 8px;
  font-size: 23px;
}

.module-tile small {
  line-height: 1.35;
  color: inherit;
  opacity: 0.78;
}

.scanner-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 16px;
}

.mode-panel,
.scan-panel,
.table-section,
.notice,
.bind-panel,
.stock-table-wrap {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.mode-panel {
  padding: 18px;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.mode-button {
  min-height: 58px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  font-weight: 800;
}

.mode-button.put.active {
  border-color: var(--green);
  background: var(--green-soft);
  color: var(--green);
}

.mode-button.view-mode.active {
  border-color: var(--blue);
  background: var(--blue);
  color: #ffffff;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.22);
}

.mode-help {
  margin: 14px 0 0;
  line-height: 1.45;
}

.scan-panel {
  overflow: hidden;
}

.shelf-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: clamp(16px, 4vw, 26px);
  border-bottom: 1px solid var(--line);
}

.shelf-header.put-state {
  background: var(--green-soft);
}

.shelf-header.view-state {
  background: #eaf0ff;
}

.shelf-header .label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
}

.shelf-header strong {
  display: block;
  font-size: clamp(36px, 8vw, 76px);
  line-height: 0.95;
  letter-spacing: 0;
}

.mode-badge {
  flex: 0 0 auto;
  max-width: 240px;
  padding: 12px 14px;
  border-radius: 8px;
  color: #ffffff;
  text-align: center;
  font-weight: 800;
  line-height: 1.15;
}

.mode-badge.put-state {
  background: var(--green);
}

.mode-badge.view-state {
  background: var(--blue);
}

.scan-fields {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  padding: clamp(16px, 4vw, 26px);
}

label span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

input {
  width: 100%;
  min-height: 54px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 0 14px;
}

input:focus,
select:focus {
  outline: 3px solid rgba(37, 95, 187, 0.2);
  border-color: var(--blue);
}

input:disabled {
  background: #eef2f7;
  color: var(--muted);
}

.mode-button:disabled,
.ghost-button:disabled,
.session select:disabled {
  cursor: wait;
  opacity: 0.58;
}

.scan-message {
  margin: 0 clamp(16px, 4vw, 26px) clamp(16px, 4vw, 26px);
  padding: 14px;
  border-radius: 8px;
  font-weight: 700;
}

.scan-message.neutral {
  background: #eef2f7;
  color: #445160;
}

.scan-message.success {
  background: var(--green-soft);
  color: var(--green);
}

.scan-message.error {
  background: var(--red-soft);
  color: var(--red);
}

.scan-message.warn {
  background: var(--yellow-soft);
  color: var(--yellow);
}

.last-scan {
  display: grid;
  grid-template-columns: 1fr 180px;
  gap: 1px;
  background: var(--line);
  border-top: 1px solid var(--line);
}

.last-scan div {
  background: #ffffff;
  padding: 16px clamp(16px, 4vw, 26px);
}

.last-scan strong {
  display: block;
  margin-top: 5px;
  font-size: 20px;
}

.table-section {
  margin-top: 16px;
  padding: 18px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.ghost-button,
.danger-button {
  min-height: 40px;
  border-radius: 8px;
  padding: 0 14px;
  font-weight: 700;
}

.ghost-button {
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--text);
}

.danger-button {
  border: 1px solid var(--red);
  background: var(--red);
  color: #ffffff;
}

.movement-list {
  display: grid;
  gap: 10px;
}

.movement-row {
  display: grid;
  grid-template-columns: 86px 90px 1fr 110px 130px;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.shelf-content-row {
  display: grid;
  grid-template-columns: 1fr 110px;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.shelf-content-row strong,
.shelf-content-row small,
.shelf-content-row span {
  display: block;
}

.shelf-content-row small {
  margin-top: 4px;
  color: var(--muted);
}

.shelf-content-row span {
  padding: 7px 8px;
  border-radius: 8px;
  background: #eef2f7;
  text-align: center;
  font-weight: 800;
}

.movement-row.cancelled {
  opacity: 0.68;
}

.movement-row strong,
.movement-row span {
  display: block;
}

.movement-row small {
  color: var(--muted);
}

.op-pill {
  padding: 7px 8px;
  border-radius: 8px;
  text-align: center;
  font-size: 13px;
  font-weight: 800;
}

.op-pill.put,
.op-pill.cancel_pick {
  background: var(--green-soft);
  color: var(--green);
}

.op-pill.pick,
.op-pill.cancel_put {
  background: var(--red-soft);
  color: var(--red);
}

.op-pill.adjust {
  background: #eaf0ff;
  color: var(--blue-dark);
}

.filters {
  display: grid;
  grid-template-columns: 1.1fr 0.7fr 260px;
  gap: 14px;
  align-items: end;
  margin-bottom: 14px;
}

.checkbox-line {
  display: flex;
  align-items: center;
  min-height: 54px;
  gap: 9px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

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

.checkbox-line span {
  margin: 0;
  color: var(--text);
}

.stock-table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
}

th,
td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  background: #eef2f7;
  color: #445160;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0;
}

.polka-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.polka-list span {
  padding: 5px 7px;
  border-radius: 8px;
  background: #eef2f7;
  font-weight: 700;
}

.notice {
  margin-bottom: 14px;
  padding: 14px;
  background: var(--yellow-soft);
  color: var(--yellow);
  font-weight: 700;
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 14px;
}

.bind-panel {
  display: grid;
  gap: 14px;
  margin-bottom: 14px;
  padding: 18px;
}

.bind-fields {
  display: grid;
  grid-template-columns: 1fr 1fr 160px;
  gap: 14px;
  align-items: end;
}

.label-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.label-chip {
  padding: 7px 9px;
  border-radius: 8px;
  background: #eef2f7;
  color: #445160;
  font-weight: 700;
}

#cancelDialog,
#repeatResetDialog {
  width: min(460px, calc(100% - 28px));
  border: 0;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

#cancelDialog::backdrop,
#repeatResetDialog::backdrop {
  background: rgba(23, 32, 42, 0.42);
}

.dialog-body {
  display: grid;
  gap: 14px;
  padding: 12px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.hidden {
  display: none !important;
}

@media (max-width: 900px) {
  .home-hero,
  .scanner-layout,
  .scan-fields,
  .bind-fields,
  .filters {
    grid-template-columns: 1fr;
  }

  .module-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .movement-row {
    grid-template-columns: 78px 82px 1fr;
  }

  .movement-row .row-action {
    grid-column: 1 / -1;
  }
}

@media (max-width: 620px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .session,
  .session select {
    width: 100%;
  }

  .role-badge {
    flex: 0 0 88px;
  }

  main {
    padding: 12px;
  }

  .module-grid,
  .status-strip,
  .admin-grid,
  .last-scan {
    grid-template-columns: 1fr;
  }

  .module-tile {
    min-height: 138px;
  }

  .shelf-header {
    align-items: stretch;
    flex-direction: column;
  }

  .mode-badge {
    max-width: none;
  }

  .section-head {
    align-items: stretch;
    flex-direction: column;
  }

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