:root {
  --ink: #15213b;
  --muted: #657089;
  --line: #dfe4ed;
  --soft: #f4f7fb;
  --navy: #192a56;
  --blue: #3157d5;
  --green: #07875f;
  --green-soft: #e8f7f1;
  --amber: #a65d00;
  --amber-soft: #fff4df;
  --red: #b3293a;
  --red-soft: #fdecef;
  --white: #ffffff;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: #eef2f7;
  font-synthesis: none;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: linear-gradient(180deg, #f7f9fc 0, #eef2f7 420px); }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }

.topbar {
  min-height: 92px;
  padding: 20px clamp(20px, 4vw, 64px);
  background: var(--navy);
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  box-shadow: 0 6px 24px rgba(18, 32, 70, .18);
}

.topbar h1 { margin: 2px 0 0; font-size: clamp(1.35rem, 2.7vw, 2rem); letter-spacing: -.03em; }
.topbar h1 span { color: #8fe0c3; }
.eyebrow, .step { margin: 0; text-transform: uppercase; letter-spacing: .11em; font-size: .72rem; font-weight: 800; }
.eyebrow { color: #bfc9df; }
.step { color: var(--blue); }
.privacy-note { display: flex; gap: 9px; align-items: center; color: #dfe6f5; font-size: .88rem; }
.lock { color: #65ddb2; font-size: .7rem; }

main { width: min(1480px, calc(100% - 32px)); margin: 28px auto 110px; }
.workspace { display: grid; grid-template-columns: minmax(0, 1.8fr) minmax(290px, .8fr); gap: 20px; }
.workflow-column { min-width: 0; }
.mode-menu { display: inline-flex; gap: 6px; margin-bottom: 12px; padding: 5px; border: 1px solid #d6deea; border-radius: 13px; background: #e8edf5; }
.mode-button { background: transparent; color: #526078; box-shadow: none; }
.mode-button.is-active { background: var(--navy); color: white; box-shadow: 0 5px 14px rgba(25, 42, 86, .18); }
.panel { background: var(--white); border: 1px solid rgba(213, 220, 232, .9); border-radius: 18px; box-shadow: 0 14px 40px rgba(32, 48, 82, .07); }
.paste-panel, .source-panel, .settings { padding: 24px; }
.section-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.section-heading.compact { margin-bottom: 16px; }
h2 { margin: 5px 0 0; font-size: 1.25rem; letter-spacing: -.02em; }
.helper, .review-header p { margin: 8px 0 16px; color: var(--muted); font-size: .92rem; }

textarea {
  width: 100%; min-height: 260px; resize: vertical; border: 1px solid #cbd3e1; border-radius: 12px;
  padding: 16px; background: #fbfcfe; color: var(--ink); line-height: 1.5; font-size: .95rem;
}
textarea:focus, input:focus, select:focus { outline: 3px solid rgba(49, 87, 213, .14); border-color: var(--blue); }
.paste-actions { display: flex; align-items: center; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
button { border: 0; border-radius: 10px; padding: 11px 16px; font-weight: 750; transition: transform .15s ease, box-shadow .15s ease, background .15s ease; }
button:hover:not(:disabled) { transform: translateY(-1px); }
.primary, .approve { background: var(--blue); color: white; box-shadow: 0 7px 16px rgba(49, 87, 213, .2); }
.secondary { background: #edf1f7; color: var(--ink); }
.text-button { padding: 6px 3px; background: transparent; color: var(--blue); }
.danger { background: var(--red-soft); color: var(--red); }
.catalog-status { margin-left: auto; color: var(--muted); font-size: .82rem; }
.catalog-status.ready { color: var(--green); }
.save-status { min-height: 24px; margin-top: 12px; color: var(--muted); font-size: .86rem; font-weight: 700; }
.save-status.ok { color: var(--green); }
.save-status.error { color: var(--red); }

.source-search > label { display: block; margin-bottom: 7px; color: #4c5870; font-size: .82rem; font-weight: 800; }
.source-search > div { display: grid; grid-template-columns: auto minmax(150px, 1fr) auto; align-items: center; gap: 10px; }
.source-search > div > span { color: var(--navy); font-size: 1.35rem; font-weight: 900; }
.source-search input { min-height: 46px; font-size: 1.05rem; font-weight: 800; }
.source-results { display: grid; gap: 10px; margin-top: 8px; }
.source-result { display: flex; align-items: center; gap: 12px; padding: 14px; border: 2px solid #d9e0eb; border-radius: 13px; background: #fbfcfe; cursor: pointer; transition: border-color .15s ease, background .15s ease; }
.source-result:has(input:checked) { border-color: var(--green); background: var(--green-soft); }
.source-result > input { position: absolute; width: 1px; height: 1px; min-height: 0; opacity: 0; }
.source-check { width: 32px; height: 32px; flex: 0 0 32px; display: grid; place-items: center; border: 2px solid #93a0b3; border-radius: 8px; background: white; color: transparent; font-weight: 950; }
.source-result input:checked + .source-check { border-color: var(--green); background: var(--green); color: white; }
.source-result input:focus-visible + .source-check { outline: 3px solid rgba(49, 87, 213, .22); outline-offset: 2px; }
.source-result-copy { display: grid; min-width: 0; gap: 4px; color: var(--muted); font-size: .84rem; }
.source-result-top { display: flex; align-items: center; gap: 9px; }
.source-result-top strong { color: var(--navy); font-size: 1rem; }
.source-result-top em { padding: 4px 8px; border-radius: 999px; background: #e6ecf8; color: var(--blue); font-size: .72rem; font-style: normal; font-weight: 850; }
.source-selection-bar { display: flex; justify-content: space-between; align-items: center; gap: 14px; margin-top: 16px; padding-top: 15px; border-top: 1px solid var(--line); }
.source-selection-bar span { color: var(--muted); font-size: .86rem; }
.source-selection-bar strong { color: var(--navy); }

.settings label, .field label { display: grid; gap: 6px; color: #4c5870; font-size: .78rem; font-weight: 750; }
input, select { width: 100%; min-height: 40px; padding: 8px 10px; border: 1px solid #cbd3e1; border-radius: 9px; color: var(--ink); background: white; }
.settings > label { margin-bottom: 12px; }
.settings-helper { margin: -6px 0 12px; color: var(--muted); font-size: .75rem; }
.next-cod-toggle { display: flex !important; grid-template-columns: none !important; align-items: center; gap: 11px !important; padding: 13px; border: 2px solid #9aa7ba; border-radius: 12px; background: #f7f9fc; color: var(--ink) !important; cursor: pointer; }
.next-cod-toggle.is-active { border-color: var(--green); background: var(--green-soft); }
.next-cod-toggle > input { position: absolute; width: 1px; height: 1px; min-height: 0; opacity: 0; }
.next-cod-box { width: 36px; height: 36px; flex: 0 0 36px; display: grid; place-items: center; border: 3px solid #8793a8; border-radius: 8px; background: white; color: transparent; font-size: 1.35rem; }
.next-cod-toggle input:checked + .next-cod-box { border-color: var(--green); background: var(--green); color: white; }
.next-cod-toggle input:focus-visible + .next-cod-box { outline: 3px solid rgba(49, 87, 213, .22); outline-offset: 2px; }
.next-cod-copy { display: grid; line-height: 1.1; }
.next-cod-copy strong { font-size: .95rem; color: var(--navy); }
.next-cod-copy small { margin-top: 4px; color: var(--muted); font-size: .72rem; }
.fixed-setting { display: grid; gap: 5px; margin-top: 4px; padding: 12px; border: 1px solid #cbd3e1; border-radius: 10px; background: #f7f9fc; }
.fixed-setting span { color: #4c5870; font-size: .78rem; font-weight: 750; }
.fixed-setting strong { color: var(--navy); font-size: .92rem; }
.two-fields { display: grid; grid-template-columns: .7fr 1.3fr; gap: 10px; margin-bottom: 12px; }
.history-line { border-top: 1px solid var(--line); padding-top: 15px; margin-top: 18px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.history-line div { display: grid; }
.history-line strong { font-size: 1.35rem; }
.history-line span { color: var(--muted); font-size: .76rem; }
.queue-card { display: grid; gap: 2px; margin-top: 18px; padding: 15px; border: 1px solid #bfe7d8; border-radius: 12px; background: var(--green-soft); }
.queue-card strong { color: var(--green); font-size: 1.65rem; }
.queue-card span { color: #42665a; font-size: .8rem; font-weight: 700; }
.history-note { color: var(--muted); font-size: .8rem; }
button.is-busy { cursor: wait; opacity: .7; }

.review { margin-top: 24px; }
.hidden { display: none !important; }
.review-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 15px; }
.stats { display: flex; gap: 8px; flex-wrap: wrap; }
.stats > div { min-width: 82px; padding: 10px 12px; border-radius: 12px; background: white; border: 1px solid var(--line); display: grid; }
.stats strong { font-size: 1.3rem; }
.stats span { font-size: .73rem; color: var(--muted); }
.stats .ok { background: var(--green-soft); border-color: #bfe7d8; }
.stats .warn { background: var(--amber-soft); border-color: #efd6a7; }
.stats .bad { background: var(--red-soft); border-color: #f2c8cf; }

.orders { display: grid; gap: 14px; }
.order-card { background: white; border: 1px solid var(--line); border-radius: 16px; overflow: hidden; box-shadow: 0 9px 26px rgba(32, 48, 82, .05); }
.order-card.has-error { border-left: 5px solid var(--red); }
.order-card.has-warning { border-left: 5px solid #d88917; }
.order-card.is-ready { border-left: 5px solid var(--green); }
.order-summary { padding: 15px 18px; display: flex; align-items: center; gap: 14px; justify-content: space-between; }
.order-main { display: flex; align-items: center; gap: 12px; min-width: 0; }
.order-index { width: 35px; height: 35px; flex: 0 0 35px; display: grid; place-items: center; border-radius: 10px; background: var(--soft); font-weight: 850; color: var(--navy); }
.order-name { min-width: 0; }
.order-name strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.order-name span { color: var(--muted); font-size: .78rem; }
.order-actions { display: flex; gap: 8px; align-items: center; }
.status-pill { border-radius: 999px; padding: 6px 10px; font-size: .73rem; font-weight: 800; white-space: nowrap; }
.status-pill.ready { background: var(--green-soft); color: var(--green); }
.status-pill.warning { background: var(--amber-soft); color: var(--amber); }
.status-pill.error { background: var(--red-soft); color: var(--red); }
.icon-button { width: 36px; height: 36px; padding: 0; border-radius: 50%; background: var(--soft); color: var(--muted); font-size: 1.25rem; }
.toggle-details { background: #edf1f7; color: var(--ink); padding: 8px 11px; }

.order-details { border-top: 1px solid var(--line); padding: 18px; background: #fbfcfe; }
.order-save-row { display: flex; align-items: center; gap: 12px; margin-top: 16px; }
.order-save-row span { color: var(--muted); font-size: .88rem; }
.guide-cod-toggle { display: flex !important; grid-template-columns: none !important; align-items: center; gap: 12px !important; padding: 13px 14px; border: 2px solid #9aa7ba; border-radius: 12px; background: #f7f9fc; color: var(--ink) !important; cursor: pointer; }
.guide-cod-toggle.is-active { border-color: var(--green); background: var(--green-soft); }
.guide-cod-toggle > input { position: absolute; width: 1px; height: 1px; min-height: 0; opacity: 0; }
.guide-cod-box { width: 34px; height: 34px; flex: 0 0 34px; display: grid; place-items: center; border: 3px solid #8793a8; border-radius: 8px; background: white; color: transparent; font-size: 1.25rem; }
.guide-cod-toggle input:checked + .guide-cod-box { border-color: var(--green); background: var(--green); color: white; }
.guide-cod-toggle input:focus-visible + .guide-cod-box { outline: 3px solid rgba(49, 87, 213, .22); outline-offset: 2px; }
.guide-cod-copy { display: grid; line-height: 1.15; }
.guide-cod-copy strong { color: var(--navy); font-size: .92rem; }
.guide-cod-copy small { margin-top: 4px; color: var(--muted); font-size: .75rem; }
.issues { display: flex; gap: 7px; flex-wrap: wrap; margin-bottom: 16px; }
.issue { padding: 7px 9px; border-radius: 8px; font-size: .76rem; font-weight: 700; }
.issue.error { background: var(--red-soft); color: var(--red); }
.issue.warning { background: var(--amber-soft); color: var(--amber); }
.warning-review { margin: 0 0 16px; padding: 15px 17px; border: 2px solid #e6a817; border-radius: 12px; background: #fff7da; color: #684500; box-shadow: 0 8px 20px rgba(148, 98, 0, .1); }
.warning-review strong { display: block; margin-bottom: 7px; font-size: .95rem; }
.warning-review ul { margin: 0 0 7px; padding-left: 22px; }
.warning-review li { margin: 4px 0; font-weight: 750; }
.warning-review span { display: block; color: #765718; font-size: .8rem; }
.warning-confirm { padding: 11px 13px; border: 1px solid #e6a817; border-radius: 10px; background: #fff7da; color: #684500; }
.form-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 12px; }
.field { grid-column: span 3; }
.field.wide { grid-column: span 6; }
.field.full { grid-column: 1 / -1; }
.field.city { grid-column: span 5; }
.field.code { grid-column: span 2; }
.readonly { background: #eef2f7; color: #58647b; }
.checks { margin-top: 15px; padding-top: 14px; border-top: 1px dashed #ccd4e1; display: flex; flex-wrap: wrap; gap: 18px; }
.check { display: flex; align-items: center; gap: 8px; font-size: .83rem; font-weight: 700; color: #465168; }
.check input { width: 18px; height: 18px; min-height: 0; }

.excel-preview { margin-top: 18px; padding: 18px; border: 1px solid #cbd3e1; border-radius: 16px; background: white; box-shadow: 0 10px 28px rgba(32, 48, 82, .06); }
.excel-preview-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 18px; margin-bottom: 13px; }
.excel-preview-heading > span { color: var(--muted); font-size: .78rem; }
.excel-scroll { max-height: 430px; overflow: auto; border: 1px solid #aeb8c8; border-radius: 9px; background: white; }
#excel-preview-table { width: max-content; min-width: 100%; border-collapse: separate; border-spacing: 0; font-size: .76rem; }
#excel-preview-table th, #excel-preview-table td { min-width: 130px; max-width: 300px; padding: 8px 10px; border-right: 1px solid #d8dee8; border-bottom: 1px solid #d8dee8; text-align: left; vertical-align: top; white-space: normal; overflow-wrap: anywhere; }
#excel-preview-table td { white-space: pre-wrap; }
#excel-preview-table thead th { position: sticky; top: 0; z-index: 2; background: #dce7fb; color: #20365f; font-weight: 850; }
#excel-preview-table tbody tr:nth-child(even) td { background: #f7f9fc; }
#excel-preview-table .row-number { position: sticky; left: 0; z-index: 3; min-width: 46px; width: 46px; background: #e9edf4; text-align: center; color: #4d5a71; }
#excel-preview-table thead .row-number { z-index: 4; background: #cdd9ee; }

.approval-bar { position: sticky; bottom: 14px; margin-top: 18px; background: rgba(25, 42, 86, .97); color: white; border-radius: 15px; padding: 15px 18px; display: flex; align-items: center; justify-content: space-between; gap: 18px; box-shadow: 0 16px 40px rgba(17, 30, 64, .28); backdrop-filter: blur(12px); }
.approval-bar div { display: grid; gap: 2px; }
.approval-bar span { color: #c9d2e5; font-size: .8rem; }
.approve { background: #52d2a6; color: #10243f; min-width: 230px; }
.approve:disabled { cursor: not-allowed; opacity: .45; box-shadow: none; }

dialog { width: min(720px, calc(100% - 28px)); max-height: 80vh; border: 0; border-radius: 18px; padding: 0; color: var(--ink); box-shadow: 0 30px 90px rgba(14, 25, 54, .35); }
dialog::backdrop { background: rgba(12, 21, 43, .58); backdrop-filter: blur(3px); }
.dialog-header, .dialog-actions { padding: 18px 20px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.dialog-header { border-bottom: 1px solid var(--line); }
.dialog-actions { border-top: 1px solid var(--line); }
.history-content { padding: 10px 20px 20px; overflow: auto; max-height: 55vh; }
.history-entry { padding: 12px 0; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 18px; }
.history-entry span { color: var(--muted); font-size: .8rem; }
.attention-dialog { width: min(680px, calc(100% - 24px)); border: 4px solid #c91d31; }
.attention-band { padding: 12px 20px; background: #c91d31; color: white; text-align: center; font-size: 1.1rem; font-weight: 950; letter-spacing: .14em; }
.attention-body { padding: 24px; }
.attention-body h2 { margin: 0 0 14px; color: #971426; font-size: 1.45rem; }
.attention-content { max-height: 48vh; overflow: auto; border: 1px solid #f1bac2; border-radius: 11px; background: #fff5f6; color: #801422; }
.attention-content ul { margin: 0; padding: 14px 18px 14px 38px; }
.attention-content li { margin: 7px 0; line-height: 1.4; font-weight: 750; }
.attention-button { width: 100%; margin-top: 18px; background: #c91d31; color: white; font-size: .95rem; }
.empty { padding: 30px 0; text-align: center; color: var(--muted); }
.toast { position: fixed; right: 22px; bottom: 22px; max-width: 390px; transform: translateY(140%); background: #15213b; color: white; padding: 13px 16px; border-radius: 11px; box-shadow: 0 14px 36px rgba(10, 18, 38, .28); transition: transform .25s ease; z-index: 10; }
.toast.show { transform: translateY(0); }

@media (max-width: 950px) {
  .workspace { grid-template-columns: 1fr; }
  .settings { order: -1; }
  .field, .field.city, .field.code { grid-column: span 6; }
  .field.wide { grid-column: 1 / -1; }
}

@media (max-width: 640px) {
  .topbar { align-items: flex-start; flex-direction: column; padding: 18px 20px; }
  .privacy-note { font-size: .78rem; }
  main { width: min(100% - 20px, 1480px); margin-top: 16px; }
  .mode-menu { display: grid; width: 100%; grid-template-columns: 1fr 1fr; }
  .mode-button { padding-inline: 9px; font-size: .82rem; }
  .paste-panel, .source-panel, .settings { padding: 18px; border-radius: 14px; }
  .source-search > div { grid-template-columns: auto 1fr; }
  .source-search button { grid-column: 1 / -1; }
  .source-selection-bar { align-items: stretch; flex-direction: column; }
  .source-selection-bar button { width: 100%; }
  textarea { min-height: 220px; }
  .catalog-status { width: 100%; margin-left: 0; }
  .review-header { align-items: flex-start; flex-direction: column; }
  .stats { width: 100%; }
  .stats > div { flex: 1; min-width: 70px; }
  .order-summary { align-items: flex-start; }
  .order-actions { align-items: flex-end; flex-direction: column; }
  .order-save-row { align-items: stretch; flex-direction: column; }
  .order-save-row button { width: 100%; }
  .field, .field.city, .field.code, .field.wide { grid-column: 1 / -1; }
  .approval-bar { align-items: stretch; flex-direction: column; bottom: 8px; }
  .approve { width: 100%; }
  .excel-preview-heading { align-items: flex-start; flex-direction: column; }
}
