:root {
  --bg: #f6f7fb;
  --panel: #ffffff;
  --panel-soft: #f2f3f8;
  --line: #e5e6ef;
  --line-strong: #d9dbe7;
  --text: #171724;
  --muted: #72758a;
  --accent: #7c3aed;
  --accent-strong: #6d28d9;
  --accent-soft: #f0eaff;
  --green: #16a34a;
  --green-soft: #e9f8ee;
  --red: #dc2626;
  --red-soft: #fdf0f0;
  --shadow: 0 14px 40px rgba(29, 26, 61, .065);
  --card-gap: 16px;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #101219;
  --panel: #191c26;
  --panel-soft: #222632;
  --line: #2b3040;
  --line-strong: #373d50;
  --text: #f4f5fb;
  --muted: #a3a8bb;
  --accent: #9061f9;
  --accent-strong: #a77cfb;
  --accent-soft: #30264b;
  --green: #4ade80;
  --green-soft: #173725;
  --red: #f87171;
  --red-soft: #421f25;
  --shadow: 0 16px 44px rgba(0, 0, 0, .28);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html {
  min-width: 0;
  overflow-y: scroll;
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Apple SD Gothic Neo", "Pretendard", "Malgun Gothic", sans-serif;
  font-size: 14px;
  line-height: 1.55;
  transition: background .18s ease, color .18s ease;
}

button,
input,
select { font: inherit; }

button { cursor: pointer; }

a { color: inherit; text-decoration: none; }

svg {
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.visually-hidden {
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  height: 1px;
  overflow: hidden;
  position: absolute;
  white-space: nowrap;
  width: 1px;
}

[hidden] { display: none !important; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 74px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .86);
  backdrop-filter: blur(18px);
}

:root[data-theme="dark"] .topbar { background: rgba(16, 18, 25, .9); }

.topbar-inner {
  display: grid;
  grid-template-columns: 240px minmax(220px, 1fr) 42px;
  gap: 16px;
  align-items: center;
  width: min(1060px, calc(100% - 48px));
  height: 100%;
  margin: 0 auto;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  min-width: 0;
  font-size: 18px;
}

.brand strong {
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-mark {
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  overflow: visible;
}

.brand-mark img { display: block; width: 44px; height: 44px; object-fit: contain; }

.status-pill {
  display: flex;
  gap: 10px;
  align-items: center;
  min-width: 0;
  height: 44px;
  padding: 0 18px;
  overflow: hidden;
  border-radius: 18px;
  background: var(--panel-soft);
  color: var(--muted);
  white-space: nowrap;
}

.status-pill span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.status-pill strong {
  overflow: hidden;
  color: #343447;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

:root[data-theme="dark"] .status-pill strong { color: var(--text); }

.status-pill i,
.status-tag i {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 14%, transparent);
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 0;
  border-radius: 15px;
  background: var(--panel-soft);
  color: var(--text);
  transition: transform .15s ease, background .15s ease;
}

.icon-btn:hover { transform: translateY(-1px); background: var(--line); }
.icon-btn svg { width: 19px; height: 19px; }
.theme-toggle { position: relative; }
.theme-toggle .moon-icon { display: none; }
:root[data-theme="dark"] .theme-toggle .sun-icon { display: none; }
:root[data-theme="dark"] .theme-toggle .moon-icon { display: block; }

.tab-nav {
  position: sticky;
  top: 74px;
  z-index: 15;
  height: 52px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .88);
  backdrop-filter: blur(18px);
}

:root[data-theme="dark"] .tab-nav { background: rgba(16, 18, 25, .92); }

.tab-nav-inner {
  display: flex;
  gap: 6px;
  align-items: center;
  width: min(1060px, calc(100% - 48px));
  height: 100%;
  margin: 0 auto;
}

.tab-btn {
  min-height: 38px;
  padding: 0 17px;
  border: 0;
  border-radius: 15px;
  background: transparent;
  color: var(--muted);
  font-size: 16px;
  font-weight: 800;
  transition: color .15s ease, background .15s ease, transform .15s ease;
}

.tab-btn:hover { color: var(--text); transform: translateY(-1px); }
.tab-btn.active { background: var(--accent-soft); color: var(--accent-strong); }

.main-wrap {
  width: min(1060px, calc(100% - 48px));
  margin: 0 auto;
  padding: 22px 0 64px;
}

.tab-pane { display: none; }
.tab-pane.active { display: block; }

.page-heading {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-end;
  min-height: 82px;
  padding: 4px 2px 20px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent-strong);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .12em;
}

.page-heading h1,
.card-heading h2,
.vendor-details h3,
.batch-dropzone h3,
.empty-state p { margin: 0; }

.page-heading h1 {
  font-size: 27px;
  line-height: 1.2;
  letter-spacing: -.035em;
}

.page-heading > div > p:last-child {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.page-note {
  flex: 0 0 auto;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  white-space: nowrap;
}

.workspace-grid {
  display: grid;
  grid-template-columns: 390px minmax(0, 1fr);
  gap: var(--card-gap);
  align-items: start;
}

.image-workspace { grid-template-columns: 390px minmax(0, 1fr); }

.work-card {
  min-width: 0;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.card-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  min-height: 52px;
  margin-bottom: 16px;
}

.card-heading h2 { font-size: 18px; line-height: 1.25; letter-spacing: -.02em; }

.badge {
  flex: 0 0 auto;
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 900;
  line-height: 1.2;
}

.badge-success { background: var(--green-soft); color: var(--green); }
.badge-neutral { background: var(--panel-soft); color: var(--muted); }

.config-card form { display: flex; flex-direction: column; gap: 14px; }
.image-settings-stack { display: flex; flex-direction: column; gap: 14px; }

.toggle-row {
  position: relative;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  min-height: 60px;
  padding: 10px 12px 10px 14px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--panel-soft);
  cursor: pointer;
}

.toggle-row > span { display: flex; flex-direction: column; min-width: 0; }
.toggle-row strong { font-size: 13px; }
.toggle-row small { margin-top: 2px; color: var(--muted); font-size: 11px; }
.toggle-row input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-row i {
  position: relative;
  flex: 0 0 38px;
  width: 38px;
  height: 22px;
  border-radius: 999px;
  background: var(--line-strong);
  transition: background .16s ease;
}

.toggle-row i::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .18);
  transition: transform .16s ease;
}

.toggle-row input:checked + i { background: var(--accent); }
.toggle-row input:checked + i::after { transform: translateX(16px); }

.form-group { display: flex; flex: 1; flex-direction: column; gap: 6px; min-width: 0; }
.form-row { display: flex; gap: 12px; }
.form-compact { flex: 0 0 112px; }
.form-grow { flex: 1 1 auto; }
.form-group label { font-size: 12px; font-weight: 850; }

.form-group input[type="text"],
.form-group select {
  width: 100%;
  height: 43px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  outline: none;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  font-weight: 650;
  transition: border-color .15s ease, box-shadow .15s ease;
}

.form-group input[type="text"]:focus,
.form-group select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 17%, transparent);
}

.hint-text { color: var(--muted); font-size: 10.5px; line-height: 1.45; }

.save-location {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--panel-soft);
}

.save-location-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  font-size: 12px;
}

.save-location-status {
  max-width: 180px;
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.save-location.ready .save-location-status { color: var(--green); }

.segmented-control {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  border-radius: 11px;
  background: var(--line);
}

.segmented-control button {
  min-height: 34px;
  padding: 0 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
}

.segmented-control button.active {
  background: var(--panel);
  color: var(--accent-strong);
  box-shadow: 0 2px 8px rgba(27, 24, 58, .08);
}

.save-location .save-folder-btn { width: 100%; background: var(--panel); }
.save-location .save-location-hint { margin-top: -1px; }

.merge-order {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 13px;
}

.merge-order-head {
  display: flex;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-soft);
  font-size: 11px;
}

.merge-order-head span { color: var(--muted); }
.summary-order-list { display: grid; grid-template-columns: 1fr 1fr; gap: 0; margin: 0; padding: 7px 10px 9px 34px; }
.summary-order-list li { padding: 3px 7px 3px 0; color: var(--text); font-size: 11px; }
.summary-order-list li::marker { color: var(--muted); font-weight: 800; }
.summary-order-list li span { color: var(--muted); font-size: 9px; font-weight: 800; }
.summary-order-list .auto-li { color: var(--green); font-weight: 750; }

.btn {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 42px;
  padding: 0 16px;
  border: 0;
  border-radius: 13px;
  font-size: 13px;
  font-weight: 850;
  white-space: nowrap;
  transition: transform .15s ease, background .15s ease, box-shadow .15s ease;
}

.btn:hover:not(:disabled) { transform: translateY(-1px); }
.btn-primary { background: linear-gradient(135deg, var(--accent), #5f3cdb); color: #fff; box-shadow: 0 7px 17px rgba(124, 58, 237, .2); }
.btn-secondary { background: var(--panel-soft); color: var(--text); }
.btn-block { width: 100%; }
.btn-sm { min-height: 36px; padding: 0 13px; border-radius: 11px; font-size: 12px; }
.btn:disabled { cursor: not-allowed; opacity: .48; box-shadow: none; }

.batch-dropzone {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  min-height: 104px;
  padding: 16px;
  border: 1.5px dashed color-mix(in srgb, var(--accent) 45%, var(--line));
  border-radius: 15px;
  background: var(--bg);
  transition: background .16s ease, border-color .16s ease, transform .16s ease;
}

.batch-dropzone:hover,
.batch-dropzone.dragover { border-color: var(--accent); background: var(--accent-soft); transform: translateY(-1px); }

.drop-icon,
.empty-illustration {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.drop-icon svg { width: 25px; height: 25px; }
.drop-copy { min-width: 0; }
.drop-copy h3 { font-size: 14px; line-height: 1.35; }
.drop-copy p { margin: 4px 0 0; color: var(--muted); font-size: 11px; line-height: 1.45; }

.doc-slots {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  margin-top: 12px;
}

.slot-item {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  min-height: 62px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  transition: border-color .15s ease, background .15s ease, transform .15s ease;
}

.slot-item:nth-child(5) { grid-column: 1 / -1; }
.slot-item[role="button"] { cursor: pointer; }
.slot-item[role="button"]:hover { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); transform: translateY(-1px); }
.slot-item.filled { border-color: color-mix(in srgb, var(--green) 55%, var(--line)); background: var(--green-soft); }
.slot-header { display: flex; gap: 7px; align-items: center; min-width: 0; }
.slot-num { display: grid; place-items: center; flex: 0 0 21px; width: 21px; height: 21px; border-radius: 7px; background: var(--line); font-size: 10px; font-weight: 900; }
.slot-header strong { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.slot-tag { flex: 0 0 auto; padding: 2px 6px; border-radius: 6px; font-size: 9px; font-weight: 900; }
.slot-tag.required { background: var(--red-soft); color: var(--red); }
.slot-tag.optional { background: var(--panel-soft); color: var(--muted); }
.slot-tag.auto { background: var(--green-soft); color: var(--green); }
.slot-file-info { min-width: 0; margin-top: 4px; padding-left: 28px; overflow: hidden; color: var(--muted); font-size: 10.5px; text-overflow: ellipsis; white-space: nowrap; }
.slot-item.filled .slot-file-info { color: var(--text); font-weight: 750; }
.db-slot { background: color-mix(in srgb, var(--green-soft) 45%, var(--bg)); }

.section-divider { height: 1px; margin: 3px 0; background: var(--line); }
.action-buttons-box { display: flex; flex-direction: column; gap: 9px; margin-top: 4px; }
.img-results-list { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 230px;
  padding: 30px 16px;
  color: var(--muted);
  text-align: center;
}

.empty-state .empty-illustration { width: 52px; height: 52px; margin-bottom: 13px; }
.empty-state svg { width: 25px; height: 25px; }
.empty-state strong { color: var(--text); font-size: 13px; }
.empty-state p { margin-top: 5px; font-size: 11px; }

.img-card {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  min-width: 0;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--bg);
}

.img-thumb-wrap { display: flex; justify-content: center; align-items: center; width: 112px; height: 78px; overflow: hidden; border-radius: 9px; background: #090a0e; }
.img-thumb-wrap img { max-width: 100%; max-height: 100%; object-fit: contain; }
.img-meta-info { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.img-meta-info strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.img-meta-info span { color: var(--muted); font-size: 10.5px; }
.img-applied-badge { width: fit-content; padding: 3px 7px; border-radius: 6px; background: var(--accent-soft); color: var(--accent-strong) !important; font-weight: 800; }
.img-actions { display: flex; gap: 6px; }

.vendor-section { padding: 22px; }
.vendor-heading { align-items: center; }
.section-desc { margin: 5px 0 0; color: var(--muted); font-size: 11px; font-weight: 500; }
.vendor-cards-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.vendor-item-card { display: flex; gap: 14px; min-width: 0; padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--bg); }
.vendor-avatar { display: grid; place-items: center; flex: 0 0 42px; width: 42px; height: 42px; border-radius: 13px; background: var(--accent-soft); color: var(--accent-strong); font-size: 15px; font-weight: 900; }
.vendor-details { flex: 1; min-width: 0; }
.vendor-details h3 { font-size: 15px; }
.doc-status-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.status-tag { display: inline-flex; gap: 6px; align-items: center; padding: 4px 7px; border-radius: 7px; font-size: 10px; font-weight: 850; }
.status-tag i { width: 5px; height: 5px; box-shadow: none; }
.status-tag.tag-ok { background: var(--green-soft); color: var(--green); }
.status-tag.tag-warn { background: var(--red-soft); color: var(--red); }
.status-tag.tag-warn i { background: var(--red); }
.vendor-files { display: grid; gap: 4px; margin: 11px 0 0; font-size: 10.5px; }
.vendor-files div { display: grid; grid-template-columns: 42px minmax(0, 1fr); gap: 7px; }
.vendor-files dt { color: var(--muted); }
.vendor-files dd { min-width: 0; margin: 0; overflow: hidden; color: var(--text); text-overflow: ellipsis; white-space: nowrap; }
.vendor-empty { grid-column: 1 / -1; }

button:focus-visible,
input:focus-visible,
select:focus-visible,
[role="button"]:focus-visible,
a:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 38%, transparent);
  outline-offset: 2px;
}

@media (max-width: 920px) {
  .topbar-inner { grid-template-columns: minmax(220px, 1fr) 42px; }
  .status-pill { display: none; }
  .workspace-grid,
  .image-workspace { grid-template-columns: 1fr; }
  .config-card { order: 1; }
  .upload-card { order: 0; }
}

@media (max-width: 680px) {
  .topbar { height: 62px; }
  .topbar-inner { grid-template-columns: minmax(0, 1fr) 42px; width: min(100% - 24px, 1060px); gap: 8px; }
  .brand { font-size: 16px; }
  .brand-mark { flex-basis: 38px; width: 38px; height: 38px; border-radius: 12px; }
  .brand-mark img { width: 38px; height: 38px; }
  .tab-nav { top: 62px; height: 50px; }
  .tab-nav-inner,
  .main-wrap { width: min(100% - 24px, 1060px); }
  .tab-nav-inner { overflow-x: auto; }
  .tab-btn { min-height: 36px; padding: 0 15px; font-size: 14px; white-space: nowrap; }
  .main-wrap { padding-top: 16px; }
  .page-heading { align-items: flex-start; min-height: 0; padding-bottom: 15px; }
  .page-heading h1 { font-size: 23px; }
  .page-heading > div > p:last-child { font-size: 12px; }
  .page-note { display: none; }
  .work-card { padding: 17px; border-radius: 16px; }
  .batch-dropzone { grid-template-columns: 42px minmax(0, 1fr); min-height: 0; padding: 13px; }
  .batch-dropzone .btn { grid-column: 1 / -1; }
  .drop-icon { width: 42px; height: 42px; border-radius: 12px; }
  .doc-slots { grid-template-columns: 1fr; }
  .slot-item:nth-child(5) { grid-column: auto; }
  .vendor-cards-grid { grid-template-columns: 1fr; }
  .img-card { grid-template-columns: 88px minmax(0, 1fr); }
  .img-thumb-wrap { width: 88px; height: 68px; }
  .img-actions { grid-column: 1 / -1; }
  .img-actions .btn { flex: 1; }
}

@media (max-width: 420px) {
  .form-row { flex-direction: column; }
  .form-compact { flex-basis: auto; }
  .summary-order-list { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
