:root {
  color-scheme: light;
  --ink: #15202b;
  --muted: #657181;
  --subtle: #8a96a5;
  --line: #d9e0e7;
  --line-strong: #c2ccd6;
  --panel: #ffffff;
  --page: #f3f5f7;
  --rail: #111827;
  --rail-soft: #1f2937;
  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --accent-soft: #e6f4f1;
  --blue: #1d4ed8;
  --blue-soft: #e9f0ff;
  --amber: #a16207;
  --amber-soft: #fff7df;
  --danger: #b42318;
  --danger-soft: #fff1f0;
  --shadow: 0 18px 50px rgba(17, 24, 39, 0.10);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--page);
}

button,
input,
textarea {
  font: inherit;
}

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  color: #fff;
  background: var(--accent);
  padding: 0 18px;
  font-weight: 700;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

button:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(15, 118, 110, 0.22);
  outline-offset: 2px;
}

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

button.secondary {
  color: var(--ink);
  background: #fff;
  border-color: var(--line);
}

button.secondary:hover {
  color: var(--accent-strong);
  background: var(--accent-soft);
  border-color: #9bcac4;
}

h1,
h2,
h3,
p {
  margin: 0;
}

a {
  color: var(--accent-strong);
  font-weight: 700;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

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

.workspace {
  display: grid;
  grid-template-columns: 286px minmax(0, 1fr);
  max-width: 1240px;
  min-height: calc(100vh - 48px);
  margin: 0 auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.sidebar {
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  gap: 22px;
  background: var(--rail);
  color: #f9fafb;
  padding: 24px;
}

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

.mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 8px;
  color: #fff;
  background: var(--accent);
  font-weight: 900;
}

.brand h1 {
  font-size: 21px;
  line-height: 1.2;
}

.brand p {
  margin-top: 3px;
  color: #aeb8c5;
  font-size: 13px;
}

.steps {
  display: grid;
  align-content: start;
  gap: 10px;
  list-style: none;
  padding: 8px 0 0;
  margin: 0;
}

.step {
  position: relative;
  display: grid;
  grid-template-columns: 30px 1fr;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  padding: 9px 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: #b8c3d1;
}

.step::before {
  content: attr(data-step-label);
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid #526071;
  color: #d8dee7;
  font-size: 13px;
  font-weight: 800;
}

.step.is-active {
  color: #ffffff;
  background: var(--rail-soft);
  border-color: #334155;
  font-weight: 800;
}

.step.is-active::before {
  color: #ffffff;
  background: var(--accent);
  border-color: var(--accent);
}

.step.is-done {
  color: #e5e7eb;
}

.step.is-done::before {
  content: "";
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: inset 0 0 0 8px var(--accent), inset 0 0 0 10px #fff;
}

.lookup-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid #334155;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.lookup-card button {
  width: 100%;
  color: #f9fafb;
  background: #202b3a;
  border-color: #3a4656;
}

.lookup-card button:hover {
  background: #2a3748;
  border-color: #617084;
}

.admin-entry {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  color: #d9f4ef;
  font-size: 14px;
}

.panel {
  min-width: 0;
  background: #f8fafb;
  padding: 26px;
}

form {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

.wizard-page {
  display: none;
}

.wizard-page.is-active {
  display: block;
}

.panel-header {
  display: grid;
  gap: 7px;
  margin-bottom: 22px;
}

.panel-header span,
.review-grid span,
.drop-meta {
  color: var(--muted);
}

.panel-header span {
  font-size: 13px;
  font-weight: 800;
}

.panel-header h2 {
  color: var(--ink);
  font-size: 30px;
  line-height: 1.18;
}

.row-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
}

.drop-zone {
  position: relative;
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 224px;
  border: 1px dashed #9aa8b6;
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  cursor: pointer;
  padding: 26px;
  text-align: center;
  transition: border-color 160ms ease, background 160ms ease;
}

.drop-zone:hover {
  border-color: var(--accent);
  background: #fbfefd;
}

.drop-zone.compact {
  min-height: 138px;
}

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

.drop-title {
  display: block;
  font-size: 24px;
  font-weight: 900;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: #fff;
  padding: 10px 12px;
  font-weight: 500;
}

input:focus,
textarea:focus {
  border-color: var(--accent);
}

textarea {
  line-height: 1.55;
}

.mode-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  max-width: 920px;
  margin: 18px 0 0;
  padding: 0;
  border: 0;
}

.mode-options legend {
  grid-column: 1 / -1;
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.mode-option {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: flex-start;
  gap: 12px;
  min-height: 132px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  cursor: pointer;
}

.mode-option:hover {
  border-color: var(--line-strong);
}

.mode-option:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px rgba(15, 118, 110, 0.12);
}

.mode-option input {
  width: 18px;
  height: 18px;
  margin-top: 3px;
  accent-color: var(--accent);
}

.mode-option span {
  display: grid;
  gap: 5px;
}

.mode-option strong {
  font-size: 16px;
}

.mode-option small,
.default-watermark span,
.settings-grid span {
  color: var(--muted);
  font-weight: 500;
  line-height: 1.45;
}

.quantity-row {
  display: grid;
  grid-template-columns: 44px minmax(180px, 280px) 44px;
  align-items: end;
  gap: 12px;
}

.icon-button {
  width: 44px;
  min-height: 52px;
  padding: 0;
  font-size: 24px;
  line-height: 1;
}

.count-box input {
  height: 52px;
  font-size: 28px;
  font-weight: 900;
}

.quick-counts {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.quick-counts button {
  min-width: 56px;
  color: var(--ink);
  background: #fff;
  border-color: var(--line);
}

.quick-counts button:hover {
  color: var(--accent-strong);
  background: var(--accent-soft);
  border-color: #9bcac4;
}

.default-watermark {
  max-width: 650px;
  margin-top: 24px;
}

.default-watermark textarea {
  min-height: 88px;
  resize: vertical;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 210px));
  gap: 14px;
  margin-top: 18px;
}

.settings-grid input {
  height: 48px;
  font-size: 18px;
  font-weight: 800;
}

#blindSettings {
  grid-template-columns: minmax(280px, 480px);
}

.table-wrap {
  overflow: auto;
  max-height: 56vh;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

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

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: var(--muted);
  background: #f2f5f7;
  font-size: 13px;
  font-weight: 900;
}

td:first-child {
  width: 70px;
  color: var(--muted);
  text-align: center;
  font-weight: 800;
}

td input {
  min-width: 180px;
}

.confirm-note {
  max-width: 780px;
  margin: -8px 0 18px;
  color: var(--muted);
  line-height: 1.65;
}

.review-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.review-grid div {
  display: grid;
  gap: 6px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.review-grid strong {
  overflow-wrap: anywhere;
}

.preview-list {
  display: grid;
  gap: 0;
  max-height: 286px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.preview-item {
  display: grid;
  grid-template-columns: 62px minmax(120px, 0.7fr) minmax(0, 1.3fr);
  gap: 12px;
  align-items: center;
  min-height: 52px;
  padding: 10px 14px;
  border-bottom: 1px solid #edf1f3;
}

.preview-item:last-child {
  border-bottom: 0;
}

.preview-item strong {
  color: var(--accent-strong);
}

.preview-item span {
  overflow-wrap: anywhere;
}

.progress {
  height: 10px;
  margin-top: 18px;
  background: #e4e9ee;
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar {
  width: 0;
  height: 100%;
  background: var(--accent);
  transition: width 220ms ease;
}

.result {
  display: grid;
  gap: 10px;
  margin-top: 18px;
  padding: 14px;
  border: 1px solid #b9ded8;
  border-radius: 8px;
  background: var(--accent-soft);
}

.lookup-result {
  display: grid;
  gap: 8px;
  max-height: 300px;
  overflow: auto;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  color: var(--ink);
  font-size: 14px;
}

.lookup-result .download-list {
  max-height: 150px;
}

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

.status-note {
  color: var(--accent-strong);
  line-height: 1.5;
}

code {
  color: var(--ink);
  background: #eef4f3;
  border: 1px solid #d4e3df;
  border-radius: 4px;
  padding: 1px 5px;
  overflow-wrap: anywhere;
}

.download-list {
  display: grid;
  gap: 0;
  max-height: 230px;
  overflow: auto;
  border-top: 1px solid #cfe5e1;
  border-bottom: 1px solid #cfe5e1;
}

.download-row {
  display: grid;
  grid-template-columns: minmax(90px, 180px) minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 7px 0;
  border-bottom: 1px solid rgba(207, 229, 225, 0.65);
}

.download-row:last-child {
  border-bottom: 0;
}

.download-row span,
.download-row a {
  overflow-wrap: anywhere;
}

.error {
  color: var(--danger);
}

.actions {
  position: sticky;
  bottom: 0;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: auto -26px -26px;
  padding: 16px 26px;
  border-top: 1px solid var(--line);
  background: rgba(248, 250, 251, 0.96);
  backdrop-filter: blur(10px);
}

.actions button {
  min-width: 110px;
}

dialog {
  width: min(720px, calc(100vw - 28px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 24px 80px rgba(17, 24, 39, 0.26);
}

dialog::backdrop {
  background: rgba(17, 24, 39, 0.42);
}

.dialog-card {
  min-height: auto;
  padding: 20px;
  background: #fff;
}

.dialog-card header,
.dialog-card menu {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0;
  padding: 0;
}

.dialog-card header {
  margin-bottom: 14px;
}

.dialog-card h3 {
  font-size: 20px;
}

.dialog-card label {
  margin-top: 12px;
}

.dialog-card textarea {
  min-height: 220px;
  resize: vertical;
}

.dialog-card menu {
  margin-top: 16px;
}

#closeDialog,
#closeLookupDialog,
#closeDetectDialog {
  width: 36px;
  min-height: 36px;
  padding: 0;
  color: var(--ink);
  background: #fff;
  border-color: var(--line);
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  color: var(--ink);
}

.check-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.admin-shell {
  max-width: 1140px;
  margin: 0 auto;
  padding: 32px;
}

.admin-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
}

.admin-header h1 {
  font-size: 30px;
}

.admin-header p {
  color: var(--muted);
  margin-top: 6px;
}

.admin-login {
  display: grid;
  grid-template-columns: minmax(220px, 360px) auto;
  gap: 12px;
  align-items: end;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  margin-bottom: 18px;
}

.admin-result {
  display: grid;
  gap: 14px;
}

.admin-task {
  display: grid;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.admin-task header {
  display: flex;
  justify-content: space-between;
  gap: 14px;
}

.admin-task h2 {
  font-size: 20px;
}

.admin-task p {
  color: var(--muted);
  margin-top: 4px;
}

.admin-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.admin-meta span {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 3px 9px;
  border-radius: 999px;
  color: var(--muted);
  background: #f1f4f6;
  font-size: 13px;
}

.admin-links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

@media (max-width: 980px) {
  .app-shell {
    padding: 0;
  }

  .workspace {
    grid-template-columns: 1fr;
    min-height: 100vh;
    border: 0;
    border-radius: 0;
  }

  .sidebar {
    grid-template-rows: auto auto auto;
    gap: 16px;
    padding: 18px;
  }

  .steps {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    padding-top: 0;
  }

  .step {
    grid-template-columns: 1fr;
    justify-items: center;
    gap: 6px;
    min-height: 72px;
    padding: 8px 6px;
    text-align: center;
    font-size: 13px;
  }

  .lookup-card {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .admin-entry {
    min-height: 28px;
  }

  .panel {
    padding: 22px 18px;
  }

  .actions {
    margin: auto -18px -22px;
    padding: 14px 18px;
  }

  .mode-options,
  .review-grid,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .mode-option {
    min-height: auto;
  }

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

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

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

  .panel-header h2 {
    font-size: 24px;
  }

  .drop-zone {
    min-height: 170px;
    padding: 20px;
  }

  .drop-title {
    font-size: 21px;
  }

  .quantity-row {
    grid-template-columns: 44px minmax(0, 1fr) 44px;
  }

  .table-wrap {
    max-height: none;
    overflow: visible;
    border: 0;
    background: transparent;
  }

  table {
    min-width: 0;
  }

  table,
  thead,
  tbody,
  tr,
  td {
    display: block;
    width: 100%;
  }

  thead {
    display: none;
  }

  tbody {
    display: grid;
    gap: 12px;
  }

  tr {
    display: grid;
    gap: 10px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
  }

  td {
    display: grid;
    gap: 6px;
    border-bottom: 0;
    padding: 0;
  }

  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
  }

  td:first-child {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--accent-strong);
    text-align: left;
  }

  td:first-child::before {
    content: attr(data-label);
    color: var(--muted);
  }

  td input {
    min-width: 0;
    height: 44px;
  }

  .preview-item {
    grid-template-columns: 48px 1fr;
  }

  .preview-item span:last-child {
    grid-column: 2;
  }

  .download-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .actions {
    position: static;
    flex-wrap: wrap;
  }

  .actions button {
    flex: 1 1 130px;
  }

  dialog {
    width: min(100vw - 16px, 720px);
  }

  .dialog-card menu {
    flex-wrap: wrap;
  }

  .dialog-card menu button {
    flex: 1 1 130px;
  }

  .admin-shell {
    padding: 18px;
  }

  .admin-header,
  .admin-task header {
    align-items: flex-start;
    flex-direction: column;
  }

  .admin-login {
    grid-template-columns: 1fr;
  }
}
