:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #edf2f7;
  --text: #18202a;
  --muted: #647080;
  --line: #d8dee8;
  --accent: #146c5c;
  --accent-strong: #0e5b4d;
  --blue: #2359a7;
  --red: #b2333a;
  --amber: #9a6400;
  --green: #13724d;
  --shadow: 0 8px 22px rgba(24, 32, 42, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

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

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.app-shell {
  width: min(100%, 560px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 14px 14px 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 2px 12px;
}

.top-actions {
  display: flex;
  gap: 8px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 26px;
  line-height: 1.15;
  letter-spacing: 0;
}

h2 {
  font-size: 17px;
  letter-spacing: 0;
}

.icon-button {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
  font-size: 20px;
}

.login-shell {
  width: min(100%, 420px);
  min-height: 100vh;
  display: grid;
  place-items: center;
  margin: 0 auto;
  padding: 18px;
}

.login-panel {
  width: 100%;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-form {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.login-form label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

#pinInput {
  height: 56px;
  padding: 0 14px;
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 0;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin: 4px 0 12px;
}

.tab {
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-weight: 700;
}

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

.stats-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 12px;
}

.stats-strip div {
  min-width: 0;
  padding: 10px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  text-align: center;
}

.stats-strip span {
  display: block;
  font-weight: 800;
  font-size: 18px;
}

.stats-strip small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.field,
.quantity-panel,
.product-panel,
.upload-panel,
.compare-toolbar,
.list-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.field {
  margin-bottom: 10px;
  padding: 10px;
}

.field label,
.quantity-panel label {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  outline: 0;
}

input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(20, 108, 92, 0.14);
}

#staffInput {
  height: 44px;
  padding: 0 12px;
}

#barcodeInput {
  height: 58px;
  padding: 0 14px;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0;
}

#manualSearchInput {
  height: 48px;
  padding: 0 12px;
  font-size: 16px;
  font-weight: 700;
}

.scan-field {
  border-color: rgba(20, 108, 92, 0.45);
}

.manual-search-field {
  position: relative;
}

.manual-results,
.candidate-list {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}

.manual-result,
.candidate-option {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 58px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  text-align: left;
}

.manual-result span,
.candidate-option span {
  min-width: 0;
}

.manual-result strong,
.manual-result small,
.candidate-option strong,
.candidate-option small {
  display: block;
  overflow-wrap: anywhere;
}

.manual-result strong,
.candidate-option strong {
  font-size: 14px;
  line-height: 1.25;
}

.manual-result small,
.candidate-option small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.manual-result em,
.candidate-option em {
  flex: 0 0 auto;
  padding: 5px 7px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--blue);
  font-size: 12px;
  font-style: normal;
  font-weight: 900;
}

.manual-empty {
  margin: 8px 2px 0;
  color: var(--muted);
  font-size: 13px;
}

.product-panel {
  min-height: 118px;
  margin-bottom: 10px;
  padding: 14px;
}

.muted-panel {
  display: grid;
  place-items: center;
  color: var(--muted);
  background: var(--surface-2);
}

.product-code {
  display: inline-block;
  margin-bottom: 8px;
  padding: 4px 7px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--blue);
  font-size: 13px;
  font-weight: 800;
}

.product-code-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}

.product-code-line .product-code {
  margin-bottom: 0;
}

.ecount-code {
  display: inline-block;
  padding: 4px 7px;
  border-radius: 6px;
  background: rgba(20, 108, 92, 0.1);
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
}

.product-name {
  display: block;
  margin-bottom: 10px;
  font-size: 21px;
  font-weight: 900;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.stock-line {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 14px;
}

.stock-line strong {
  color: var(--text);
}

.stock-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

.stock-metric {
  min-width: 0;
  padding: 8px 6px;
  border-radius: 8px;
  background: var(--surface-2);
  text-align: center;
}

.stock-metric small {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 11px;
}

.stock-metric strong {
  font-size: 16px;
}

.stock-metric.focus {
  background: rgba(20, 108, 92, 0.12);
  color: var(--accent);
}

.stock-metric.warn {
  background: rgba(178, 51, 58, 0.12);
  color: var(--red);
}

.quantity-panel {
  padding: 12px;
}

.qty-control {
  display: grid;
  grid-template-columns: 58px 1fr 58px;
  gap: 8px;
  margin-bottom: 10px;
}

.qty-control button {
  height: 54px;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 24px;
  font-weight: 900;
}

#qtyInput {
  height: 54px;
  text-align: center;
  font-size: 22px;
  font-weight: 900;
}

.primary-button,
.secondary-button,
.danger-ghost {
  height: 48px;
  border-radius: 8px;
  font-weight: 800;
}

.primary-button {
  width: 100%;
  background: var(--accent);
  color: #fff;
}

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

.secondary-button {
  min-width: 72px;
  padding: 0 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
}

.danger-ghost {
  height: 36px;
  padding: 0 10px;
  border: 1px solid rgba(178, 51, 58, 0.28);
  background: #fff;
  color: var(--red);
  font-size: 13px;
}

.message {
  min-height: 22px;
  margin: 10px 2px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.4;
}

.message.ok {
  color: var(--green);
  font-weight: 800;
}

.message.error {
  color: var(--red);
  font-weight: 800;
}

.list-section {
  margin-top: 12px;
  padding: 12px;
}

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

.recent-list,
.compare-list,
.warning-list {
  display: grid;
  gap: 8px;
}

.empty-text {
  color: var(--muted);
  text-align: center;
}

.recent-item,
.compare-item,
.warning-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.recent-item {
  padding: 10px;
}

.recent-top,
.compare-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.recent-name,
.compare-name {
  font-weight: 800;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.recent-meta,
.compare-code {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.qty-badge {
  flex: 0 0 auto;
  min-width: 48px;
  padding: 6px 8px;
  border-radius: 8px;
  background: var(--surface-2);
  text-align: center;
  font-weight: 900;
}

.recent-actions {
  flex: 0 0 auto;
  display: grid;
  gap: 6px;
  justify-items: end;
}

.edit-count-btn {
  min-width: 48px;
  height: 30px;
  padding: 0 9px;
  border: 1px solid rgba(35, 89, 167, 0.28);
  border-radius: 8px;
  background: #fff;
  color: var(--blue);
  font-size: 12px;
  font-weight: 900;
}

.upload-panel {
  padding: 14px;
}

.helper-text {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.file-row {
  margin: 14px 0 10px;
}

#fileInput {
  height: auto;
  padding: 12px;
}

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

.warning-item {
  padding: 10px;
  color: var(--amber);
  font-size: 13px;
  line-height: 1.45;
}

.compare-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  padding: 10px;
}

.compare-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-weight: 800;
}

.toggle-row input {
  width: 20px;
  height: 20px;
}

.toolbar-actions {
  display: flex;
  gap: 8px;
}

.toolbar-actions .primary-button {
  width: auto;
  min-width: 72px;
  padding: 0 14px;
}

.compare-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(78px, 1fr));
  gap: 6px;
  margin-bottom: 10px;
}

.compare-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 14px 2px 8px;
}

.compare-section-title span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.summary-chip {
  padding: 9px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  text-align: center;
}

.summary-chip strong {
  display: block;
  font-size: 18px;
}

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

.compare-item {
  padding: 11px;
}

.compare-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-top: 10px;
}

.metric {
  padding: 8px 6px;
  border-radius: 8px;
  background: var(--surface-2);
  text-align: center;
}

.metric small {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 11px;
}

.metric strong {
  font-size: 16px;
}

.status {
  flex: 0 0 auto;
  padding: 5px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
}

.status.ok {
  background: rgba(19, 114, 77, 0.12);
  color: var(--green);
}

.status.short {
  background: rgba(178, 51, 58, 0.12);
  color: var(--red);
}

.status.over {
  background: rgba(154, 100, 0, 0.14);
  color: var(--amber);
}

.status.miss {
  background: rgba(100, 112, 128, 0.14);
  color: var(--muted);
}

.status.unmatched {
  background: rgba(35, 89, 167, 0.12);
  color: var(--blue);
}

@media (min-width: 720px) {
  .app-shell {
    padding-top: 24px;
  }
}
