:root {
  --bg: #f3f0e8;
  --panel: #fffdf8;
  --ink: #1f1a14;
  --muted: #6b6258;
  --line: #ddd4c6;
  --accent: #2f6f4e;
  --accent-soft: #e4f0e8;
  --danger: #a33b2b;
  --warn: #9a6b1a;
  --shadow: 0 10px 30px rgba(40, 30, 10, 0.08);
  --radius: 14px;
  --font: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 0%, #efe6d4 0%, transparent 40%),
    radial-gradient(circle at 90% 10%, #dceade 0%, transparent 35%),
    var(--bg);
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  max-width: 980px;
  margin: 0 auto;
  padding: 24px 16px 80px;
}

.brand {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 18px;
}

.brand h1 {
  margin: 0;
  font-size: 28px;
  letter-spacing: 0.02em;
}

.brand-side {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand .date {
  color: var(--muted);
  font-size: 15px;
}

.brand-side .btn {
  padding: 6px 14px;
  font-size: 14px;
}

.back-link {
  justify-self: start;
  border: none;
  background: transparent;
  padding: 0;
  color: var(--accent);
  font-size: 15px;
  font-weight: 700;
}

.work-restart {
  display: flex;
  justify-content: flex-end;
}

.work-restart:has(.hidden) {
  display: none;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.temp-customer {
  justify-self: start;
}

.text-action {
  border: none;
  background: transparent;
  padding: 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.temp-customer-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.temp-customer-form .btn {
  padding: 8px 14px;
  font-size: 14px;
}

.hidden {
  display: none !important;
}

.stack {
  display: grid;
  gap: 14px;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

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

.hint {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.5;
}

label.field {
  display: grid;
  gap: 6px;
  font-weight: 600;
}

input[type='password'],
input[type='text'],
input[type='number'],
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  background: #fff;
  color: var(--ink);
}

textarea {
  min-height: 140px;
  resize: vertical;
  line-height: 1.5;
}

.temp-customer-form input[type='text'] {
  width: 220px;
  flex: 0 0 220px;
}

.factory-row input[type='text'] {
  width: 220px;
  flex: 0 1 220px;
}

.btn {
  border: none;
  border-radius: 999px;
  padding: 12px 18px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 16px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn.secondary {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
}

.btn.danger {
  background: var(--danger);
}

.btn.ghost {
  background: transparent;
  color: var(--accent);
  border: 1px dashed var(--accent);
}

.btn.block {
  width: 100%;
}

.progress {
  font-size: 15px;
  color: var(--muted);
}

.chip-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}

.chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  font-size: 16px;
  user-select: none;
}

.chip input {
  width: 18px;
  height: 18px;
}

.item-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  background: #fff;
  display: grid;
  gap: 8px;
}

.catalog-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.catalog-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.catalog-row span {
  flex: 1;
  min-width: 0;
}

.catalog-row select {
  width: 148px;
  flex: 0 0 148px;
  padding: 8px 10px;
}

.catalog-row .btn {
  padding: 6px 14px;
  font-size: 14px;
}

.item-card.needs-confirm {
  background: #fff4cc;
  border-color: #e0b84a;
}

.item-card .grid-3 {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 8px;
}

.item-card .note {
  font-size: 13px;
  color: var(--warn);
}

.entry-switch {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.dropzone {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 28px 16px;
  border: 1.5px dashed var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}

.dropzone span {
  color: var(--muted);
  font-size: 14px;
}

.dropzone.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.file-input {
  display: none;
}

.thumb {
  width: 96px;
  height: 96px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--line);
  cursor: zoom-in;
  background: #fff;
}

.source-text {
  white-space: pre-wrap;
  background: #f7f4ee;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  max-height: 200px;
  overflow: auto;
  line-height: 1.5;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(20, 16, 10, 0.86);
  cursor: zoom-out;
}

.lightbox img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  background: #fff;
  border-radius: 8px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
}

.nav-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.nav-tabs button {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 8px 14px;
}

.nav-tabs button.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 700;
}

.steps {
  display: flex;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.steps li {
  flex: 1;
  text-align: center;
  padding: 10px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  font-weight: 700;
  cursor: pointer;
}

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

.alias-table {
  width: 100%;
  border-collapse: collapse;
}

.alias-table th,
.alias-table td {
  border-bottom: 1px solid var(--line);
  text-align: left;
  padding: 10px 6px;
  vertical-align: top;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: #1f1a14;
  color: #fff;
  padding: 12px 18px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 50;
}

.toast.show {
  opacity: 1;
}

@media (max-width: 640px) {
  .brand h1 {
    font-size: 22px;
  }

  .item-card .grid-3 {
    grid-template-columns: 1fr;
  }
}
