:root {
    --bg: #0a0d12;
    --bg-soft: #10151d;
    --panel: #141a23;
    --panel-strong: #19212c;
    --text: #edf2f7;
    --muted: #94a3b8;
    --line: #2b3544;
    --line-soft: #202938;
    --accent: #22c7a9;
    --accent-dark: #7dd3c7;
    --warn: #f6c177;
    --danger: #fb7185;
    --shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background:
        radial-gradient(circle at 20% -10%, rgba(34, 199, 169, 0.12), transparent 32rem),
        linear-gradient(180deg, #0d1118 0%, var(--bg) 34rem);
    color: var(--text);
    font: 15px/1.5 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
    color: var(--accent-dark);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 62px;
    padding: 0 32px;
    background: rgba(10, 13, 18, 0.84);
    border-bottom: 1px solid var(--line-soft);
    color: white;
    backdrop-filter: blur(16px);
}

.brand {
    color: white;
    letter-spacing: 0;
    font-weight: 700;
}

.nav a {
    color: #cbd5e1;
    margin-left: 20px;
}

.page {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    max-width: 1620px;
    margin: 0 auto;
    padding: 34px 32px 48px;
}

.page > * {
    grid-column: 1 / -1;
}

.page-head {
    display: flex;
    gap: 24px;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 20px;
}

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

h1 {
    margin-bottom: 6px;
    font-size: 32px;
    line-height: 1.15;
}

h2 {
    font-size: 19px;
}

h3 {
    font-size: 16px;
}

.new-estimate {
    display: flex;
    gap: 10px;
    min-width: 420px;
}

.head-actions {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.head-actions.compact {
    min-width: 0;
}

input[type="text"],
input[type="number"],
input[type="file"] {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 12px 14px;
    background: #0c1118;
    color: var(--text);
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.catalog-search-panel {
    display: grid;
    gap: 14px;
}

.catalog-search-head h2,
.catalog-search-head p {
    margin-bottom: 0;
}

.catalog-search-form {
    display: flex;
    gap: 8px;
    align-items: center;
}

.catalog-search-input {
    position: relative;
    flex: 1 1 420px;
}

.catalog-search-input > i {
    position: absolute;
    top: 50%;
    left: 14px;
    color: var(--muted);
    transform: translateY(-50%);
    pointer-events: none;
}

.catalog-search-input input {
    padding-left: 40px;
}

.search-note {
    margin: 0;
    color: var(--muted);
    font-size: 14px;
}

.catalog-search-results {
    margin-top: 2px;
}

.catalog-search-results td.catalog-product-name {
    white-space: normal;
    min-width: 260px;
}

.etm-search-panel {
    display: grid;
    gap: 14px;
}

.etm-search-form {
    display: flex;
    gap: 8px;
    align-items: center;
}

.etm-search-input {
    position: relative;
    flex: 1 1 420px;
}

.etm-search-input > i {
    position: absolute;
    top: 50%;
    left: 14px;
    color: var(--muted);
    transform: translateY(-50%);
    pointer-events: none;
}

.etm-search-input input {
    padding-left: 40px;
}

.etm-search-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 18px;
    color: var(--muted);
    font-size: 14px;
}

.etm-search-meta strong {
    color: var(--text);
    font-weight: 500;
}

.etm-response {
    max-height: 620px;
    margin: 0;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 18px;
    background: #0c1118;
    color: #c4f5e9;
    font: 13px/1.55 ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
    white-space: pre;
}

.catalog-import-panel {
    display: grid;
    gap: 14px;
}

.catalog-import-panel.is-processing {
    border-color: rgba(34, 199, 169, 0.52);
}

.catalog-import-head,
.catalog-progress-meta,
.catalog-import-form {
    display: flex;
    align-items: center;
    gap: 10px;
}

.catalog-import-head {
    justify-content: space-between;
}

.catalog-import-head h2,
.catalog-import-head p {
    margin-bottom: 0;
}

.catalog-progress {
    height: 10px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 2px;
    background: #0c1118;
}

.catalog-progress > span {
    display: block;
    width: var(--catalog-progress, 0%);
    height: 100%;
    background: linear-gradient(90deg, #159b85, #6ee7d2);
    transition: width 340ms ease;
}

.catalog-progress > span.is-indeterminate {
    width: 42%;
    background: linear-gradient(90deg, transparent, #22c7a9, #99f6e4, transparent);
    background-size: 200% 100%;
    animation: catalog-progress-shift 1.45s linear infinite;
}

.catalog-progress-meta {
    justify-content: space-between;
    color: var(--muted);
    font-size: 14px;
}

.catalog-progress-meta strong {
    color: var(--text);
    font-weight: 500;
}

.catalog-batch-control {
    display: grid;
    gap: 4px;
    color: var(--muted);
    font-size: 14px;
    white-space: nowrap;
}

.catalog-batch-input {
    display: flex;
    align-items: center;
    width: 176px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: #0c1118;
    transition: border-color 180ms ease, box-shadow 180ms ease;
}

.catalog-batch-input:focus-within {
    border-color: rgba(34, 199, 169, 0.72);
    box-shadow: 0 0 0 3px rgba(34, 199, 169, 0.12);
}

.catalog-batch-input input[type="number"] {
    min-width: 0;
    border: 0;
    border-radius: 0;
    padding: 8px 8px 8px 10px;
    background: transparent;
    box-shadow: none;
}

.catalog-batch-input small {
    padding: 0 10px 0 8px;
    border-left: 1px solid var(--line-soft);
    color: var(--muted);
    font-size: 12px;
    line-height: 24px;
}

.catalog-auto-note {
    color: var(--accent-dark);
    font-size: 14px;
    white-space: nowrap;
}

input[type="checkbox"] {
    accent-color: var(--accent);
}

button,
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    border: 0;
    border-radius: 4px;
    padding: 0 14px;
    background: var(--accent);
    color: #04100d;
    font-weight: 500;
    font-size: 14px;
    cursor: pointer;
    transition: transform 180ms ease, background 180ms ease, opacity 180ms ease;
}

button.small,
.button.small {
    min-height: 30px;
    padding: 0 9px;
    font-size: 13px;
}

button.tool-button,
.button.tool-button {
    gap: 6px;
    white-space: nowrap;
}

.tool-button .button-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 13px;
    min-width: 13px;
    font-size: 15px;
    font-weight: 400;
    line-height: 1;
}

.tool-button[data-toggle-collapse] .button-icon {
    transition: transform 180ms ease;
}

.tool-button[data-toggle-collapse].is-expanded .button-icon {
    transform: rotate(180deg);
}

button.secondary.match-batch-button:not(:disabled) {
    border: 1px solid transparent;
    background:
        linear-gradient(#263241, #263241) padding-box,
        linear-gradient(105deg, transparent 24%, rgba(153, 246, 228, 0.2) 39%, #99f6e4 50%, rgba(153, 246, 228, 0.2) 61%, transparent 76%) border-box;
    background-size: 100% 100%, 230% 100%;
    background-position: 0 0, 145% 0;
    box-shadow: 0 0 0 1px rgba(34, 199, 169, 0.16), 0 0 18px rgba(34, 199, 169, 0.12);
    animation: match-batch-border 2.8s ease-in-out infinite;
}

button.icon-button,
.button.icon-button {
    position: relative;
    width: 28px;
    min-width: 28px;
    min-height: 28px;
    padding: 0;
    font-size: 17px;
    line-height: 1;
}

button.icon-button.is-button-busy > * {
    opacity: 0;
}

button.icon-button.is-button-busy::after {
    content: "";
    position: absolute;
    width: 14px;
    height: 14px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: button-spin 720ms linear infinite;
}

button.icon-button.wide,
.button.icon-button.wide {
    width: 32px;
    min-width: 32px;
}

button.danger,
.button.danger {
    background: rgba(251, 113, 133, 0.18);
    color: #fecdd3;
}

button:hover,
.button:hover {
    transform: translateY(-1px);
    text-decoration: none;
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
    cursor: not-allowed;
    opacity: 0.65;
    transform: none;
}

.button.secondary,
button.secondary {
    background: #263241;
    color: var(--text);
}

.panel,
.table-wrap,
.step-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 5px;
    box-shadow: var(--shadow);
    padding: 26px;
}

.table-wrap.flat {
    border: 0;
    box-shadow: none;
    padding: 0;
    overflow-x: auto;
}

.action-panel,
.section-head,
.stage-head {
    display: flex;
    gap: 22px;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 16px;
}

.stage-head {
    margin-bottom: 0;
}

.stage-head h2 {
    margin-bottom: 5px;
}

.stage-head p {
    margin-bottom: 0;
}

.grid.two,
.workflow-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

.workflow-grid {
    display: contents;
}

.workflow-stage {
    grid-column: span 1;
    order: 10;
    margin-bottom: 0;
}

.utility-stage {
    grid-column: span 1;
    order: 11;
}

.workflow-stage:not(.is-complete):not(.utility-stage) {
    grid-column: span 2;
}

.result-panel,
.steps,
.page > section.panel:not(.workflow-stage):not(.result-panel) {
    order: 20;
    grid-column: 1 / -1;
}

.workflow-stage.is-complete {
    padding: 18px 20px;
    box-shadow: none;
}

.workflow-stage.is-complete .stage-head p,
.workflow-stage.is-complete .stage-head form {
    display: none;
}

.workflow-stage.is-complete .stage-head form.stage-recalculate {
    display: block;
}

.workflow-stage.is-complete .stage-head .head-actions {
    gap: 6px;
}

.workflow-stage.is-complete .stage-head .stage-toggle {
    display: inline-flex;
}

.workflow-stage.is-next {
    border-color: rgba(34, 199, 169, 0.72);
    background:
        linear-gradient(135deg, rgba(34, 199, 169, 0.11), transparent 46%),
        var(--panel);
    box-shadow: 0 18px 58px rgba(34, 199, 169, 0.12), var(--shadow);
}

.workflow-stage.is-next h2::after {
    content: "Следующий этап";
    display: inline-flex;
    margin-left: 10px;
    border: 1px solid rgba(34, 199, 169, 0.42);
    border-radius: 4px;
    padding: 3px 7px;
    background: rgba(34, 199, 169, 0.12);
    color: #99f6e4;
    font-size: 12px;
    font-weight: 650;
    vertical-align: middle;
}

.stage-body {
    margin-top: 16px;
}

.stage-body.is-collapsed {
    display: none;
}

.steps {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

.step-card span {
    display: block;
    margin-bottom: 8px;
    color: var(--accent-dark);
    font-size: 13px;
    text-transform: uppercase;
}

.status {
    display: inline-flex;
    border: 1px solid rgba(34, 199, 169, 0.35);
    border-radius: 4px;
    padding: 4px 9px;
    background: rgba(34, 199, 169, 0.1);
    color: #99f6e4;
    font-size: 13px;
}

.status.score-status.is-high {
    border-color: rgba(52, 211, 153, 0.5);
    background: rgba(52, 211, 153, 0.12);
    color: #a7f3d0;
}

.status.score-status.is-good {
    border-color: rgba(56, 189, 248, 0.5);
    background: rgba(56, 189, 248, 0.12);
    color: #bae6fd;
}

.status.score-status.is-medium {
    border-color: rgba(251, 191, 36, 0.5);
    background: rgba(251, 191, 36, 0.12);
    color: #fde68a;
}

.status.score-status.is-low {
    border-color: rgba(251, 113, 133, 0.5);
    background: rgba(251, 113, 133, 0.12);
    color: #fecdd3;
}

.verification-switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    cursor: pointer;
    color: var(--muted);
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
}

.verification-switch input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.verification-switch-track {
    position: relative;
    display: inline-block;
    width: 28px;
    height: 16px;
    border: 1px solid #475569;
    border-radius: 999px;
    background: #111827;
    transition: background 160ms ease, border-color 160ms ease;
}

.verification-switch-track::after {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #94a3b8;
    content: '';
    transition: transform 160ms ease, background 160ms ease;
}

.verification-switch input:checked + .verification-switch-track {
    border-color: #34d399;
    background: rgba(52, 211, 153, 0.16);
}

.verification-switch input:checked + .verification-switch-track::after {
    transform: translateX(12px);
    background: #6ee7b7;
}

.verification-switch input:focus-visible + .verification-switch-track {
    outline: 2px solid #7dd3fc;
    outline-offset: 2px;
}

.verify-cell {
    width: 1%;
    min-width: 48px;
    text-align: center;
}

.candidate-item [hidden] {
    display: none !important;
}

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

.flash {
    margin-bottom: 18px;
    border: 1px solid rgba(246, 193, 119, 0.38);
    border-radius: 5px;
    padding: 18px 22px;
    background: rgba(246, 193, 119, 0.08);
    color: var(--warn);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

th,
td {
    border-bottom: 1px solid var(--line);
    border-right: 1px solid rgba(148, 163, 184, 0.16);
    padding: 8px 9px;
    text-align: left;
    vertical-align: top;
}

th:last-child,
td:last-child {
    border-right: 0;
}

th:nth-child(n+3),
td:nth-child(n+3) {
    white-space: nowrap;
}

#match-items-table table {
    min-width: 1480px;
    table-layout: fixed;
}

#match-items-table th:nth-child(1),
#match-items-table td:nth-child(1) {
    width: 190px;
    white-space: normal;
    overflow-wrap: anywhere;
}

#match-items-table th:nth-child(2),
#match-items-table td:nth-child(2) {
    width: 120px;
}

#match-items-table th:nth-child(3),
#match-items-table td:nth-child(3) {
    width: 190px;
}

#match-items-table th:nth-child(4),
#match-items-table td:nth-child(4) {
    width: 110px;
}

#match-items-table th:nth-child(5),
#match-items-table td:nth-child(5) {
    width: 100px;
}

#match-items-table th:nth-child(6),
#match-items-table td:nth-child(6) {
    width: 135px;
}

#match-items-table th:nth-child(7),
#match-items-table td:nth-child(7) {
    white-space: normal;
    overflow-wrap: anywhere;
}

#match-items-table th:nth-child(8),
#match-items-table td:nth-child(8) {
    width: 120px;
}

#match-items-table th:nth-child(9),
#match-items-table td:nth-child(9) {
    width: 90px;
}

#match-items-table th:nth-child(10),
#match-items-table td:nth-child(10) {
    width: 60px;
}

#match-items-table th:nth-child(11),
#match-items-table td:nth-child(11) {
    width: 150px;
}

.etm-lookup-cell {
    min-width: 0;
}

.etm-lookup-form {
    display: flex;
    align-items: center;
    gap: 5px;
}

.etm-lookup-form .etm-lookup-input {
    width: auto;
    min-width: 0;
    flex: 1 1 auto;
    padding: 6px 8px;
}

.etm-lookup-form .etm-lookup-input[readonly] {
    cursor: not-allowed;
    border-color: rgba(148, 163, 184, 0.28);
    color: var(--muted);
}

#supplier-items-table .supplier-store-cell {
    width: 190px;
    min-width: 150px;
    max-width: 240px;
    white-space: normal;
    overflow-wrap: anywhere;
}

.score-indicator {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.score-indicator::before {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #64748b;
    content: '';
}

.score-indicator.is-high::before {
    background: #34d399;
}

.score-indicator.is-good::before {
    background: #38bdf8;
}

.score-indicator.is-medium::before {
    background: #fbbf24;
}

.score-indicator.is-low::before {
    background: #fb7185;
}

.supplier-total-row td {
    border-top: 1px solid rgba(100, 211, 188, 0.46);
    border-bottom: 0;
    background: rgba(100, 211, 188, 0.07);
    color: var(--text);
    font-weight: 600;
}

.supplier-total-row td span,
.supplier-total-row td strong {
    display: block;
}

.supplier-total-row td span {
    margin-bottom: 2px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 500;
}

.select-cell {
    width: 30px;
    min-width: 30px;
    padding-left: 6px;
    padding-right: 6px;
    text-align: center;
}

.select-cell input {
    width: 14px;
    height: 14px;
    margin: 2px 0 0;
}

.row-actions {
    width: 1%;
    min-width: 62px;
    white-space: nowrap;
}

.row-actions button,
.row-actions .button {
    margin: 0 2px 0 0;
    vertical-align: top;
}

.edit-control,
tr.is-editing [data-view-value],
tr.is-editing .view-action {
    display: none;
}

tr.is-reordered {
    animation: row-reordered 360ms ease;
}

@keyframes row-reordered {
    0% { background-color: rgba(100, 211, 188, 0.22); }
    100% { background-color: transparent; }
}

tr.is-editing .edit-control,
tr.is-editing .edit-action {
    display: inline-flex;
}

.edit-action {
    display: none;
}

.table-input {
    width: 100%;
    min-width: 110px;
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 8px 10px;
    background: #0c1118;
    color: var(--text);
    font: inherit;
}

.table-input.short {
    max-width: 110px;
}

tr.is-saving {
    opacity: 0.72;
}

tr.is-saving td,
.panel.is-saving {
    background-image: linear-gradient(90deg, transparent, rgba(34, 199, 169, 0.08), transparent);
    background-size: 220% 100%;
    animation: ajax-saving 1.15s ease-in-out infinite;
}

tr.is-removing,
.panel.is-removing {
    opacity: 0;
    transform: translateX(10px);
    transition: opacity 220ms ease, transform 220ms ease;
}

.toast-stack {
    position: fixed;
    right: 24px;
    top: 82px;
    z-index: 50;
    display: grid;
    width: min(380px, calc(100vw - 32px));
    gap: 10px;
}

.toast {
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(34, 199, 169, 0.42);
    border-radius: 5px;
    padding: 13px 15px 16px;
    background: rgba(15, 23, 32, 0.96);
    box-shadow: 0 18px 52px rgba(0, 0, 0, 0.42);
    color: var(--text);
    animation: toast-in 180ms ease-out;
}

.toast.toast-error {
    border-color: rgba(251, 113, 133, 0.48);
}

.toast span {
    display: block;
    padding-right: 8px;
    font-weight: 650;
}

.toast b {
    position: absolute;
    left: 0;
    bottom: 0;
    display: block;
    width: 100%;
    height: 3px;
    background: var(--accent);
    transform-origin: left center;
    animation: toast-progress 4.2s linear forwards;
}

.toast.toast-error b {
    background: var(--danger);
}

.toast.is-closing {
    opacity: 0;
    transform: translateY(-6px);
    transition: opacity 240ms ease, transform 240ms ease;
}

.candidate-row td {
    padding: 0 12px 10px;
    background: rgba(255, 255, 255, 0.015);
}

.candidate-list {
    display: grid;
    gap: 6px;
}

.candidate-list.is-collapsed {
    display: none;
}

.candidate-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 8px 10px;
    background: rgba(255, 255, 255, 0.025);
}

.candidate-select-form {
    display: flex;
    justify-content: flex-end;
}

.candidate-select-form button {
    white-space: nowrap;
}

.candidate-item strong,
.candidate-item span,
.candidate-item small {
    margin-right: 8px;
}

.candidate-line {
    display: flex;
    align-items: center;
    gap: 9px;
    min-width: 0;
    font-size: 13px;
    line-height: 1.25;
    white-space: nowrap;
}

.candidate-line > * {
    flex: 0 0 auto;
}

.candidate-line .candidate-name {
    flex: 1 1 auto;
    min-width: 140px;
    overflow: hidden;
    color: var(--text);
    text-overflow: ellipsis;
}

.candidate-etm-code {
    position: relative;
    display: inline-flex;
    padding-top: 4px;
}

.candidate-etm-code strong {
    margin-right: 0;
}

.candidate-selected-dot {
    position: absolute;
    top: -1px;
    left: 50%;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #34d399;
    box-shadow: 0 0 0 2px rgba(15, 23, 32, 0.9);
    transform: translateX(-50%);
}

.candidate-line small {
    color: var(--muted);
}

th {
    color: var(--muted);
    font-size: 13px;
    font-weight: 650;
}

th.group-head {
    text-align: center;
    color: var(--accent-dark);
}

.file-list {
    margin: 18px 0 0;
    padding: 0;
    list-style: none;
}

.file-list li {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    border-top: 1px solid var(--line);
    padding: 14px 0;
}

.db-browser {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    gap: 16px;
}

.db-sidebar {
    align-self: start;
    position: sticky;
    top: 82px;
}

.db-table-list {
    display: grid;
    gap: 6px;
}

.db-table-list a {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 9px 10px;
    color: var(--text);
}

.db-table-list a.is-active {
    border-color: rgba(34, 199, 169, 0.5);
    background: rgba(34, 199, 169, 0.08);
}

.db-table-wrap {
    overflow: auto;
    max-height: 72vh;
}

.db-table-wrap table {
    min-width: 980px;
}

.db-table-wrap th small {
    display: block;
    margin-top: 3px;
    color: var(--muted);
    font-weight: 400;
}

.json-cell summary {
    cursor: pointer;
    color: var(--accent-dark);
}

.json-cell pre {
    max-width: 760px;
    max-height: 360px;
    overflow: auto;
    margin: 8px 0 0;
    white-space: pre-wrap;
}

.pager {
    display: flex;
    gap: 10px;
    margin-top: 16px;
}

label {
    display: block;
    margin-bottom: 10px;
}

pre {
    overflow: auto;
    max-height: 460px;
    border-radius: 5px;
    padding: 14px;
    background: #101828;
    color: #f2f4f7;
}

.ocr-text {
    white-space: pre-wrap;
    max-height: 520px;
    border: 1px solid var(--line);
}

.ocr-text.is-collapsed {
    max-height: 132px;
    overflow: hidden;
    position: relative;
}

.ocr-text.is-collapsed::after,
.collapsible-block.is-collapsed::after {
    content: "";
    position: sticky;
    display: block;
    height: 56px;
    bottom: 0;
    margin-top: -56px;
    background: linear-gradient(180deg, rgba(16, 24, 40, 0), #101828 88%);
}

.collapsible-block.is-collapsed {
    max-height: 260px;
    overflow: hidden;
    position: relative;
}

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

.upload-form {
    display: grid;
    gap: 16px;
}

.dropzone {
    position: relative;
    display: grid;
    min-height: 238px;
    place-items: center;
    overflow: hidden;
    border: 1px solid #273241;
    border-radius: 5px;
    background:
        radial-gradient(ellipse at 50% 40%, rgba(248, 113, 113, 0.14), transparent 34%),
        radial-gradient(ellipse at 50% 50%, rgba(2, 6, 10, 0.96) 0 24%, rgba(12, 17, 24, 0.96) 56%, rgba(20, 26, 35, 0.9) 100%),
        linear-gradient(145deg, #101720, #070a0f);
    cursor: pointer;
    isolation: isolate;
    transition: border-color 240ms ease, box-shadow 240ms ease, transform 240ms ease;
}

.dropzone::before,
.dropzone::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 40%;
    z-index: -1;
    pointer-events: none;
}

.dropzone::before {
    width: min(78%, 720px);
    height: 72px;
    background:
        linear-gradient(90deg, transparent, rgba(127, 29, 29, 0.12) 17%, rgba(251, 146, 60, 0.22) 42%, rgba(255, 237, 213, 0.46) 50%, rgba(251, 146, 60, 0.22) 58%, rgba(127, 29, 29, 0.12) 83%, transparent),
        radial-gradient(ellipse at 50% 50%, rgba(251, 191, 36, 0.34), transparent 64%);
    border-radius: 50%;
    filter: blur(12px);
    transform: translate(-50%, -50%);
    animation: eye-glow 4.8s ease-in-out infinite;
}

.dropzone::after {
    width: 380px;
    height: 150px;
    background:
        radial-gradient(ellipse at 50% 50%, rgba(255, 237, 213, 0.5) 0 8%, rgba(251, 146, 60, 0.34) 20%, rgba(127, 29, 29, 0.18) 42%, transparent 64%);
    border-radius: 50%;
    filter: blur(18px);
    opacity: 0.66;
    transform: translate(-50%, -50%);
    animation: eye-halo 6s ease-in-out infinite;
    transition: opacity 260ms ease;
}

.dropzone.is-dragover,
.dropzone:focus-within {
    border-color: rgba(34, 199, 169, 0.78);
    box-shadow: 0 0 0 1px rgba(34, 199, 169, 0.22), 0 0 70px rgba(34, 199, 169, 0.18);
    transform: translateY(-1px);
}

.dropzone.is-dragover::after,
.dropzone:focus-within::after {
    opacity: 0.92;
}

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

.void {
    position: absolute;
    width: min(64%, 520px);
    height: 142px;
    border-radius: 52% 48% 52% 48% / 48% 48% 52% 52%;
    overflow: hidden;
    background:
        radial-gradient(ellipse at 50% 50%, rgba(255, 247, 237, 0.98) 0 6%, rgba(251, 191, 36, 0.9) 10%, rgba(249, 115, 22, 0.74) 20%, rgba(127, 29, 29, 0.48) 40%, rgba(3, 7, 18, 0.96) 72%),
        linear-gradient(90deg, rgba(0, 0, 0, 0.92) 0 8%, rgba(127, 29, 29, 0.45) 24%, rgba(255, 237, 213, 0.28) 50%, rgba(127, 29, 29, 0.45) 76%, rgba(0, 0, 0, 0.92) 92% 100%);
    clip-path: polygon(0 50%, 9% 35%, 22% 22%, 38% 13%, 50% 10%, 62% 13%, 78% 22%, 91% 35%, 100% 50%, 91% 65%, 78% 78%, 62% 87%, 50% 90%, 38% 87%, 22% 78%, 9% 65%);
    box-shadow:
        inset 0 0 38px rgba(0, 0, 0, 0.9),
        inset 0 0 6px rgba(255, 237, 213, 0.4),
        0 0 44px rgba(0, 0, 0, 0.95),
        0 0 46px rgba(249, 115, 22, 0.18);
    animation: eye-core 5.2s ease-in-out infinite;
    transition: box-shadow 260ms ease, transform 260ms ease;
}

.void::before,
.void::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    pointer-events: none;
}

.void::before {
    width: 30px;
    height: 112px;
    border-radius: 50%;
    background: #000;
    box-shadow:
        0 0 0 8px rgba(0, 0, 0, 0.16),
        0 0 30px rgba(0, 0, 0, 0.95);
    transform: translate(-50%, -50%);
    animation: eye-slit 5.2s ease-in-out infinite;
}

.void::after {
    width: 92%;
    height: 68%;
    border-radius: 50%;
    background:
        linear-gradient(90deg, transparent 0 26%, rgba(255, 237, 213, 0.22) 48%, transparent 54% 100%),
        repeating-linear-gradient(102deg, transparent 0 12px, rgba(251, 191, 36, 0.12) 13px 15px, transparent 16px 32px);
    mix-blend-mode: screen;
    opacity: 0.64;
    transform: translate(-50%, -50%);
}

.dropzone.is-dragover .void {
    box-shadow:
        inset 0 0 38px #000,
        0 0 76px rgba(0, 0, 0, 1),
        0 0 72px rgba(251, 146, 60, 0.42);
    transform: scale(1.04, 1.08);
}

.dropzone-copy {
    position: relative;
    z-index: 1;
    display: grid;
    gap: 7px;
    padding-top: 168px;
    text-align: center;
}

.dropzone-copy strong {
    font-size: 18px;
}

.dropzone-copy span {
    color: var(--muted);
}

@keyframes slow-spin {
    to {
        transform: rotate(1turn);
    }
}

@keyframes hypnotic-spin {
    to {
        transform: rotate(1turn) scale(1.04);
    }
}

@keyframes eye-glow {
    0%,
    100% {
        opacity: 0.72;
        opacity: 0.55;
        transform: translate(-50%, -50%) scaleX(0.94);
    }
    50% {
        opacity: 0.95;
        transform: translate(-50%, -50%) scaleX(1.04);
    }
}

@keyframes eye-halo {
    0%,
    100% {
        transform: translate(-50%, -50%) scale(0.96);
    }
    50% {
        transform: translate(-50%, -50%) scale(1.06);
    }
}

@keyframes eye-core {
    0%,
    100% {
        transform: scale(1, 1);
    }
    50% {
        transform: scale(1.06, 1.12);
    }
}

@keyframes eye-slit {
    0%,
    100% {
        transform: translate(-50%, -50%) scaleX(0.82);
    }
    50% {
        transform: translate(-50%, -50%) scaleX(1.1);
    }
}

@keyframes ajax-saving {
    0% {
        background-position: 120% 0;
    }
    100% {
        background-position: -120% 0;
    }
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
}

@keyframes toast-progress {
    to {
        transform: scaleX(0);
    }
}

@keyframes button-spin {
    to {
        transform: rotate(1turn);
    }
}

@keyframes match-batch-border {
    0%,
    100% {
        background-position: 0 0, 145% 0;
        box-shadow: 0 0 0 1px rgba(34, 199, 169, 0.12), 0 0 14px rgba(34, 199, 169, 0.08);
    }
    50% {
        background-position: 0 0, -45% 0;
        box-shadow: 0 0 0 1px rgba(153, 246, 228, 0.46), 0 0 24px rgba(34, 199, 169, 0.18);
    }
}

@keyframes catalog-progress-shift {
    to {
        background-position: -200% 0;
    }
}

@media (max-width: 820px) {
    .page,
    .topbar {
        padding-left: 16px;
        padding-right: 16px;
    }

    .page {
        grid-template-columns: 1fr;
    }

    .page-head,
    .new-estimate,
    .head-actions,
    .action-panel,
    .section-head,
    .stage-head,
    .catalog-search-form,
    .etm-search-form {
        display: block;
        min-width: 0;
    }

    .catalog-import-head,
    .catalog-progress-meta,
    .catalog-import-form {
        align-items: flex-start;
        flex-direction: column;
    }

    .catalog-batch-input {
        width: 100%;
    }

    .new-estimate input,
    .new-estimate button,
    .head-actions .button,
    .head-actions form,
    .stage-head button,
    .stage-head form,
    .catalog-search-form .catalog-search-input,
    .catalog-search-form button,
    .catalog-search-form .button {
        margin-bottom: 10px;
    }

    .etm-search-form .etm-search-input,
    .etm-search-form button {
        margin-bottom: 10px;
    }

    .grid.two,
    .workflow-grid,
    .steps {
        grid-template-columns: 1fr;
    }

    .workflow-stage.is-complete {
        grid-column: 1 / -1;
        padding: 16px;
    }

    .workflow-stage,
    .workflow-stage:not(.is-complete):not(.utility-stage),
    .utility-stage {
        grid-column: 1 / -1;
    }

    .workflow-stage.is-next h2::after {
        display: flex;
        width: max-content;
        margin: 8px 0 0;
    }

    .row-actions {
        width: 1%;
        min-width: 62px;
    }

    .dropzone {
        min-height: 214px;
    }

    .toast-stack {
        right: 16px;
        top: 72px;
    }
}
