:root {
    --sidebar: #122033;
    --sidebar-2: #1b2d44;
    --accent: #2f9e8f;
    --accent-soft: #e7f6f3;
    --ink: #152033;
    --muted: #6b7a8d;
    --line: #dbe3ec;
    --bg: #f4f7fa;
    --card: #ffffff;
    --danger: #c0392b;
    --warn: #b7791f;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    margin: 0;
    display: flex;
    height: 100vh;
    background: var(--bg);
    color: var(--ink);
    font-family: "Segoe UI", Tahoma, sans-serif;
}

.app-sidebar {
    width: 260px;
    flex-shrink: 0;
    height: 100vh;
    background: linear-gradient(180deg, var(--sidebar), var(--sidebar-2));
    color: #e8eef5;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    overflow: auto;
}

.brand {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 24px 20px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand-mark {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--accent);
    display: grid;
    place-items: center;
    font-weight: 700;
}

.brand small {
    display: block;
    color: #9fb0c3;
}

.app-sidebar nav {
    display: flex;
    flex-direction: column;
    padding: 16px 12px;
    gap: 4px;
}

.nav-section {
    margin: 16px 12px 2px;
    color: #8ea0b3;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    line-height: 1.3;
}

.nav-section:first-child {
    margin-top: 0;
}

.app-sidebar nav a {
    color: #c9d6e5;
    text-decoration: none;
    padding: 10px 12px;
    border-radius: 8px;
}

.app-sidebar nav a.active,
.app-sidebar nav a:hover {
    background: rgba(47, 158, 143, 0.18);
    color: #fff;
}

.sidebar-foot {
    margin-top: auto;
    padding: 16px 20px;
    color: #8ea0b3;
    font-size: 12px;
}

.app-main {
    flex: 1;
    min-width: 0;
    min-height: 0;
    height: 100vh;
    overflow: auto;
    padding: 28px 32px 48px;
}

.page-host {
    max-width: 1180px;
}

body.rules-wide .page-host {
    max-width: none;
    width: 100%;
}

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

.page-title h1 {
    font-size: 28px;
    margin: 0 0 6px;
}

.page-title p {
    margin: 0;
    color: var(--muted);
}

.panel {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 20px;
    box-shadow: 0 8px 24px rgba(18, 32, 51, 0.04);
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.stat {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 16px 18px;
}

.stat span {
    color: var(--muted);
    font-size: 13px;
}

.stat strong {
    display: block;
    font-size: 28px;
    margin-top: 4px;
}

.stat-click {
    cursor: pointer;
    text-align: left;
    width: 100%;
    transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}

.stat-click:hover {
    border-color: #9bb6d4;
    box-shadow: 0 0 0 3px rgba(59, 110, 165, 0.12);
}

.stat-click.active {
    border-color: #3b6ea5;
    background: #f0f6fc;
    box-shadow: 0 0 0 3px rgba(59, 110, 165, 0.16);
}

.match-list-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 16px;
    flex-wrap: wrap;
}

.match-list-search {
    min-width: min(280px, 100%);
    flex: 0 1 280px;
}

.report-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 14px;
}

.report-filter-chip {
    border: 1px solid var(--line);
    background: #fff;
    color: #334155;
    border-radius: 999px;
    padding: 6px 12px;
}

.report-filter-chip:hover:not(:disabled) {
    border-color: #9bb6d4;
    background: #f8fafc;
}

.report-filter-chip.active {
    border-color: #3b6ea5;
    background: #eef5fb;
    color: #1f466e;
    font-weight: 600;
}

.select2-container .select2-selection--single {
    height: 38px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 4px 8px;
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: 28px;
    color: #1f2937;
    padding-left: 2px;
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 36px;
}

.select2-dropdown {
    border-color: var(--line);
    border-radius: 8px;
}

.match-save-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    padding-top: 14px;
    padding-bottom: 14px;
}

.match-save-info {
    display: flex;
    align-items: center;
    gap: 10px 14px;
    flex-wrap: wrap;
    min-width: 0;
}

.match-save-info strong {
    font-size: 15px;
}

.table {
    margin-bottom: 0;
}

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

.badge-soft {
    background: var(--accent-soft);
    color: #1d6f65;
    border-radius: 999px;
    padding: 3px 10px;
    font-size: 12px;
}

.badge-off {
    background: #f3e8e8;
    color: #8a3a32;
    border-radius: 999px;
    padding: 3px 10px;
    font-size: 12px;
}

.source-tools {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    flex-shrink: 0;
}

.source-tool-btns {
    display: flex;
    gap: 8px;
}

.source-tool-btns .btn {
    white-space: nowrap;
}

.source-search {
    min-width: 280px;
}

.source-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.source-tab {
    border: 1px solid var(--line);
    background: #fff;
    color: var(--muted);
    border-radius: 999px;
    padding: 8px 14px;
    font-size: 13px;
    cursor: pointer;
}

.source-tab span {
    margin-left: 6px;
    color: var(--ink);
    font-weight: 600;
}

.source-tab.on {
    background: var(--accent-soft);
    border-color: #b7e0d9;
    color: #1d6f65;
}

.sources-panel {
    padding: 12px 16px 8px;
}

.sources-panel.is-firm-pinned {
    position: sticky;
    top: 0;
    z-index: 25;
    background: var(--card);
    box-shadow: 0 10px 24px rgba(18, 32, 51, 0.12);
}

.source-bulk-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 2px 0 4px;
}

.source-bulk-all {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    font-size: 13px;
    font-weight: 700;
    color: #2c3e52;
    cursor: pointer;
    user-select: none;
}

.source-bulk-all input,
.source-select-cell input,
.sources-table th.source-select-th input {
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: #1a7d70;
    cursor: pointer;
}

.source-bulk-all input:disabled,
.source-select-cell input:disabled,
.sources-table th.source-select-th input:disabled {
    cursor: not-allowed;
}

.sources-table th.source-select-th,
.sources-table td.source-select-cell {
    width: 44px;
    text-align: center;
    padding-left: 14px;
    padding-right: 6px;
}

.sources-table tbody tr.source-row-selected {
    box-shadow:
        inset 4px 0 0 #1a7d70,
        0 0 0 2px #7eb8af,
        0 2px 6px rgba(18, 32, 51, 0.08);
}

.table-wrap {
    overflow: auto;
}

.sources-panel .table-wrap {
    padding-bottom: 4px;
}

.sources-table {
    --source-row-gap: 14px;
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 var(--source-row-gap);
    margin: calc(var(--source-row-gap) * -1) 0 0;
}

.sources-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #e4ecf3;
    color: #2c3e52;
    border: none !important;
    border-bottom: 2px solid #b8c7d6 !important;
    box-shadow: 0 1px 0 #b8c7d6;
    padding: 11px 12px;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.sources-table tbody tr {
    background: #fff;
    box-shadow:
        inset 4px 0 0 var(--accent),
        0 0 0 2px #aebfd0,
        0 2px 6px rgba(18, 32, 51, 0.08);
    transition: background-color 0.12s ease, box-shadow 0.12s ease;
}

.sources-table tbody tr:nth-child(even) {
    background: #f3f7fa;
    box-shadow:
        inset 4px 0 0 #5fa89e,
        0 0 0 2px #aebfd0,
        0 2px 5px rgba(18, 32, 51, 0.06);
}

.sources-table tbody tr:hover {
    background: #e9f6f3;
    box-shadow:
        inset 4px 0 0 #1a7d70,
        0 0 0 2.5px #7eb8af,
        0 4px 12px rgba(18, 32, 51, 0.11);
}

.sources-table tbody td {
    border: none !important;
    vertical-align: middle;
    padding: 16px 12px;
}

.sources-table tbody td:first-child {
    border-radius: 12px 0 0 12px;
}

.sources-table tbody td:last-child {
    border-radius: 0 12px 12px 0;
}

.sources-table th {
    white-space: nowrap;
}

.sources-table th.source-th-pair {
    white-space: normal;
    line-height: 1.25;
    font-weight: 800;
}

.sources-table th.source-th-code,
.sources-table td.source-code-cell {
    min-width: 220px;
}

.sources-table th.source-th-name-currency {
    min-width: 260px;
    width: 22%;
}

.sources-table td.source-name-currency-cell {
    min-width: 260px;
    width: 22%;
}

.sources-table td.source-name-currency-cell .source-stack,
.sources-table td.source-name-currency-cell .form-select,
.sources-table td.source-name-currency-cell .stock-chosen {
    max-width: none;
    width: 100%;
    min-width: 0;
}

.source-currency-groups {
    margin-top: 5px;
    padding: 4px 7px;
    font-size: 11px;
    line-height: 1.35;
    color: #3d5a54;
    background: #eef7f5;
    border: 1px solid #c5ddd7;
    border-radius: 6px;
    word-break: break-word;
}

.sources-table .form-select,
.sources-table .form-control,
.sources-table input.form-control-sm {
    background: #fff !important;
    border: 1.5px solid #b4c3d2 !important;
    border-radius: 8px !important;
    box-shadow: 0 1px 0 rgba(18, 32, 51, 0.04);
    color: var(--ink);
    font-weight: 600;
}

.sources-table .form-select:focus,
.sources-table .form-control:focus,
.sources-table input.form-control-sm:focus {
    border-color: #2f9e8f !important;
    box-shadow: 0 0 0 3px rgba(47, 158, 143, 0.18);
}

.sources-table .form-select {
    min-width: 128px;
    max-width: 220px;
}

.sources-table input.form-control-sm {
    min-width: 88px;
    max-width: 160px;
}

.sources-table input.form-control-sm.discount-locked,
.sources-table input.form-control-sm.discount-locked:disabled {
    background: #e6ebf1 !important;
    color: #8b97a6 !important;
    border-color: #c5ced8 !important;
    box-shadow: inset 0 0 0 1px #d5dde6;
    cursor: not-allowed;
    opacity: 1;
}

.source-firm-cell {
    position: relative;
    overflow: hidden;
    min-width: 188px;
    padding-top: 12px !important;
    padding-right: 56px !important;
    vertical-align: middle;
}

.source-firm-cell > strong {
    display: block;
    font-size: 15px;
    font-weight: 800;
    letter-spacing: 0.01em;
    color: #122033;
}

.source-firm-cell > .help.mono {
    display: inline-block;
    margin-top: 3px;
    padding: 2px 7px;
    border-radius: 999px;
    background: #e8eef5;
    color: #44586c;
    border: 1px solid #cfd9e4;
    font-size: 11px;
}

.source-depot-input {
    margin-top: 8px;
    max-width: 148px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
    background: #fff8e8 !important;
    border-color: #e0c47a !important;
}

.source-depot-input::placeholder {
    color: #9a7d3a;
    font-weight: 600;
}

.source-cargo-flag {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    font-size: 12px;
    font-weight: 600;
    color: #3d4a3a;
    cursor: pointer;
    user-select: none;
}

.source-cargo-flag input {
    margin: 0;
}

.source-pin-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    z-index: 2;
    width: 28px;
    height: 28px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1.5px solid #b4c3d2;
    background: #fff;
    border-radius: 8px;
    color: #5d7084;
    box-shadow: 0 1px 2px rgba(18, 32, 51, 0.08);
}

.source-pin-btn svg {
    width: 16px;
    height: 16px;
}

.source-pin-btn:hover {
    color: #17685d;
    border-color: #2f9e8f;
    background: #e7f6f3;
}

.source-pin-btn.on {
    color: #fff;
    background: #1d6f65;
    border-color: #17685d;
}

.source-detail-overlay.is-pinned {
    position: static;
    z-index: auto;
    background: transparent;
    display: block;
    padding: 14px 0 0;
}

.source-detail-overlay.is-pinned .source-detail {
    width: 100%;
    max-height: none;
    box-shadow: none;
    border: 1px solid #c9d6e3;
}

.source-firm-ribbon {
    position: absolute;
    top: 16px;
    right: -28px;
    width: 118px;
    padding: 4px 0;
    text-align: center;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #fff;
    background: linear-gradient(180deg, #2f9e8f, #217a6f);
    transform: rotate(45deg);
    box-shadow: 0 2px 5px rgba(18, 32, 51, 0.25);
    pointer-events: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.source-firm-ribbon.excel {
    background: linear-gradient(180deg, #7a8ca3, #5d6d82);
}

.source-stack {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 132px;
    padding: 8px;
    background: rgba(255, 255, 255, 0.82);
    border: 1px solid #d5e0ea;
    border-radius: 10px;
}

.sources-table tbody tr:nth-child(even) .source-stack {
    background: rgba(255, 255, 255, 0.92);
    border-color: #c8d5e2;
}

.source-stack .form-select,
.source-stack .form-control {
    width: 100%;
    max-width: 180px;
}

.source-code-row {
    display: flex;
    align-items: center;
    gap: 6px;
    max-width: 180px;
    overflow: visible;
}

.source-code-row .form-select {
    flex: 1;
    min-width: 0;
    max-width: none;
}

.source-rule-btn {
    position: relative;
    flex: 0 0 28px;
    width: 28px;
    height: 28px;
    overflow: visible;
}

.source-rule-mark {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #1d6f65;
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px rgba(29, 111, 101, 0.28);
    pointer-events: none;
    z-index: 1;
}

.code-split-hint {
    margin: 0;
    line-height: 1.2;
}

.code-split-samples {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    max-width: 180px;
}

.code-split-samples span {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 999px;
    background: #e7f4f1;
    color: #1d6f65;
    font-size: 11px;
    line-height: 1.4;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.source-code-rule {
    width: min(640px, 100%);
}

.code-rule-current {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin: 0 0 14px;
    padding: 10px 12px;
    border-radius: 10px;
    background: #e7f4f1;
    color: #1d6f65;
}

.code-rule-current span {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    opacity: 0.8;
}

.code-rule-current strong {
    font-size: 14px;
    font-weight: 700;
}

.code-rule-kinds {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 8px;
}

.code-rule-kind {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    text-align: left;
    padding: 12px 14px;
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 12px;
    color: inherit;
}

.code-rule-kind:hover:not(:disabled) {
    background: var(--accent-soft);
    border-color: #b7e0d9;
}

.code-rule-kind.on {
    background: var(--accent-soft);
    border-color: #b7e0d9;
}

.code-rule-kind-num {
    flex: 0 0 28px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #e7f4f1;
    color: #1d6f65;
    font-weight: 700;
    font-size: 13px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.code-rule-kind strong {
    display: block;
    font-size: 15px;
}

.code-rule-kind small {
    display: block;
    color: #6b7c93;
    font-size: 12px;
}

.code-split-preview td,
.code-split-preview th {
    font-size: 13px;
}

.source-raw-table th.is-code-col,
.source-raw-table td.is-code-col {
    color: #1d6f65;
    font-weight: 600;
    background: #f3faf8;
}

.stock-cell .source-stack .form-select,
.stock-cell .stock-chosen .form-select {
    max-width: none;
    width: 100%;
}

.source-info-cell {
    position: relative;
    min-width: 156px;
    padding: 10px 14px 10px 12px !important;
    vertical-align: middle;
}

.source-info-cell::before {
    content: "";
    position: absolute;
    inset: 8px 8px 8px 0;
    border-radius: 10px;
    background: #eef3f8;
    border: 1px solid #c9d6e3;
    z-index: 0;
}

.source-info-cell > * {
    position: relative;
    z-index: 1;
}

.source-info-dot {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 2;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: #9aa7b5;
    box-shadow: 0 0 0 3px rgba(154, 167, 181, 0.22);
}

.source-info-cell.ok {
    color: #1d6f65;
}

.source-info-cell.ok::before {
    background: #e7f6f3;
    border-color: #b7e0d9;
}

.source-info-cell.ok .source-info-dot {
    background: #1d6f65;
    box-shadow: 0 0 0 3px rgba(29, 111, 101, 0.2);
}

.source-info-cell.err {
    color: #c0453c;
}

.source-info-cell.err::before {
    background: #fbeeed;
    border-color: #ebc4c0;
}

.source-info-cell.err .source-info-dot {
    background: #c0453c;
    box-shadow: 0 0 0 3px rgba(192, 69, 60, 0.2);
}

.source-info-cell.run {
    color: #b58112;
}

.source-info-cell.run::before {
    background: #fff6e5;
    border-color: #ebd29a;
}

.source-info-cell.run .source-info-dot {
    background: #d4a017;
    box-shadow: 0 0 0 3px rgba(212, 160, 23, 0.24);
    animation: source-dot-pulse 1.2s ease-in-out infinite;
}

.source-info-time {
    font-size: 12px;
    font-weight: 700;
    line-height: 1.3;
    padding-right: 14px;
}

.source-info-count {
    font-size: 12px;
    font-weight: 600;
    margin-top: 3px;
}

.source-info-count.muted {
    color: var(--muted);
    font-weight: 400;
}

@keyframes source-dot-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.35; }
}

.stock-cell {
    min-width: 148px;
    width: 12%;
}

.stock-cell .source-stack {
    min-width: 0;
}

.stock-chosen {
    position: relative;
    width: 100%;
    min-width: 0;
    overflow: hidden;
}

.stock-chosen.has-value > select {
    color: transparent;
    -webkit-text-fill-color: transparent;
    overflow: hidden;
    padding-right: 2.75rem;
}

.stock-chosen > select option {
    color: var(--ink);
    -webkit-text-fill-color: var(--ink);
}

.stock-chosen-values {
    position: absolute;
    left: 6px;
    right: 40px;
    top: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    gap: 4px;
    overflow: hidden;
    pointer-events: none;
}

.stock-chosen-clear {
    position: absolute;
    right: 1.35rem;
    top: 0;
    bottom: 0;
    z-index: 2;
    width: 22px;
    border: 0;
    background: transparent;
    color: var(--muted);
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
}

.stock-chosen-clear:hover {
    color: var(--ink);
}

.stock-chip {
    display: inline-flex;
    align-items: center;
    flex: 0 1 auto;
    max-width: 100%;
    height: 22px;
    background: #e4edf7;
    border: 1px solid #b7c9db;
    border-radius: 999px;
    padding: 0 9px;
    font-size: 11px;
    font-weight: 700;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    line-height: 1;
    color: #2a4660;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stock-chip.always {
    background: #d9f3ed;
    border-color: #8fcfc4;
    color: #17685d;
}

.stock-cell .form-select {
    min-width: 0;
    max-width: none;
    width: 100%;
}

.source-detail-overlay {
    position: fixed;
    inset: 0;
    z-index: 40;
    background: rgba(18, 32, 51, 0.46);
    display: flex;
    align-items: stretch;
    justify-content: center;
    padding: 20px 24px;
}

.source-detail {
    width: min(1680px, calc(100vw - 32px));
    max-height: 100%;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 24px 60px rgba(18, 32, 51, 0.22);
    padding: 20px 22px 16px;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.source-detail-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 16px;
}

.source-detail-head h2 {
    margin: 0 0 4px;
    font-size: 22px;
}

.source-detail-kpis {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 14px;
}

.source-detail-kpis .stat {
    margin: 0;
}

.source-detail-kpis .stat-in strong {
    color: #1d6f65;
}

.source-detail-kpis .stat-out strong {
    color: #8a3a32;
}

.source-detail-filters {
    display: grid;
    grid-template-columns: 1.2fr 1fr 150px 1fr;
    gap: 12px;
    margin-bottom: 12px;
}

.source-detail-groupbar {
    margin: 0 0 12px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #f8fafc;
}

.source-detail-groupline {
    margin: 0;
    line-height: 1.45;
    word-break: break-word;
}

.source-detail-groupline strong {
    font-weight: 700;
    margin-right: 4px;
}

.source-detail-table {
    flex: 1;
    min-height: 220px;
}

.source-raw-table {
    font-size: 12px;
    white-space: nowrap;
}

.source-raw-table th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #f6f8fb;
    font-weight: 700;
}

.source-raw-table td {
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.badge-provider {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    background: #e7eef8;
    color: #245a8c;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.source-icon-btn {
    width: 32px;
    height: 30px;
    padding: 0;
    margin: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1.5px solid #b4c3d2;
    background: #fff;
    border-radius: 9px;
    color: #1d6f65;
    box-shadow: 0 1px 2px rgba(18, 32, 51, 0.06);
}

.source-actions-cell {
    position: relative;
    width: 84px;
    padding-left: 8px !important;
    padding-right: 12px !important;
    vertical-align: middle;
}

.source-actions {
    display: grid;
    grid-template-columns: 32px 32px;
    grid-template-rows: 30px 30px;
    grid-auto-flow: column;
    gap: 6px;
    justify-content: end;
    padding: 8px;
    background: #eef3f8;
    border: 1px solid #c9d6e3;
    border-radius: 12px;
}

.source-icon-btn.on {
    background: var(--accent-soft);
    border-color: #8fcfc4;
}

.source-icon-btn:hover:not(:disabled) {
    background: var(--accent-soft);
    border-color: #2f9e8f;
    color: #17685d;
}

.source-icon-btn:disabled {
    opacity: 0.45;
}

.source-icon-btn.busy {
    color: #b8860b;
}

.source-icon-btn svg {
    width: 16px;
    height: 16px;
}

.source-icon-spin {
    width: 14px;
    height: 14px;
    border: 2px solid #e6d39a;
    border-top-color: #b8860b;
    border-radius: 50%;
    animation: source-spin 0.7s linear infinite;
}

@keyframes source-spin {
    to { transform: rotate(360deg); }
}

.source-history {
    width: min(860px, 100%);
    max-height: min(80vh, 720px);
}

.source-live-create {
    width: min(760px, 100%);
    max-height: min(90vh, 820px);
    align-self: center;
    overflow: auto;
}

.live-status {
    font-weight: 600;
}

.live-status.ok {
    color: #1d6f65;
}

.live-status.err {
    color: #8a3a32;
}

.live-status.run {
    color: #b8860b;
}

@media (max-width: 900px) {
    .source-detail-kpis,
    .source-detail-filters {
        grid-template-columns: 1fr 1fr;
    }
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 12px;
}

.form-wide {
    grid-column: 1 / -1;
}

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

.btn-accent {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.btn-accent:hover {
    background: #25877a;
    border-color: #25877a;
    color: #fff;
}

.alert-box {
    margin-bottom: 14px;
}

.mono {
    font-family: Consolas, "Courier New", monospace;
}

.product-search-panel .match-toolbar {
    align-items: end;
}

.product-search-table th {
    white-space: nowrap;
}

.product-search-table td {
    vertical-align: middle;
}

.stock-pill {
    display: inline-block;
    min-width: 42px;
    text-align: center;
    border-radius: 999px;
    padding: 2px 8px;
    font-size: 12px;
    font-weight: 700;
}

.stock-pill.var {
    background: #e7f6f3;
    color: #1d6f65;
}

.stock-pill.yok {
    background: #f3e8e8;
    color: #8a3a32;
}

.preview-result {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
}

.preview-card {
    background: #f8fbfb;
    border: 1px dashed var(--line);
    border-radius: 12px;
    padding: 14px;
}

.preview-card .label {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.preview-card .value {
    font-size: 20px;
    margin-top: 6px;
    word-break: break-all;
}

.help {
    color: var(--muted);
    font-size: 13px;
}

.sample-box {
    background: #f8fbfb;
    border: 1px dashed var(--line);
    border-radius: 12px;
    padding: 12px 14px;
}

.sample-box-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.sample-code {
    white-space: nowrap;
}

.sample-code-hit {
    background: #ffe566;
    box-shadow: inset 0 -1px 0 #e6c200;
    border-radius: 2px;
    padding: 0 1px;
}

.match-toolbar {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
}

.match-toolbar-field {
    max-width: 360px;
    flex: 1;
}

.match-toolbar-field.grow {
    max-width: none;
    flex: 1.4;
}

.report-toolbar {
    flex-wrap: wrap;
}

.report-wrap-grid,
.owner-wrap-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 14px 18px;
    align-items: start;
}

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

.owner-wrap-row .form-control {
    flex: 1;
    min-width: 0;
}

.owner-wrap-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.owner-wrap-chips .stock-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.chip-x {
    border: 0;
    background: transparent;
    color: inherit;
    font-size: 14px;
    line-height: 1;
    padding: 0;
    cursor: pointer;
    opacity: 0.7;
}

.chip-x:hover {
    opacity: 1;
}

.name-preview-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.name-preview-row .form-control {
    flex: 1;
    min-width: 0;
}

.name-preview-overlay {
    z-index: 45;
    align-items: center;
}

.match-more-codes {
    font-size: 12px;
    line-height: 1.3;
    text-decoration: underline;
    color: #3b6ea5;
    vertical-align: baseline;
}

.match-more-codes:hover {
    color: #1f466e;
}

.match-hits-overlay {
    z-index: 46;
    align-items: center;
}

.match-hits-panel {
    width: min(760px, calc(100vw - 32px));
    max-height: min(820px, calc(100vh - 40px));
}

.match-hits-list {
    overflow: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 0;
    padding-right: 4px;
}

.match-hits-row {
    display: grid;
    grid-template-columns: minmax(120px, 1.1fr) minmax(100px, 0.9fr) minmax(120px, 1fr) auto;
    gap: 8px 12px;
    align-items: baseline;
    padding: 8px 10px;
    border: 1px solid #e4ebf3;
    border-radius: 8px;
    background: #f8fafc;
}

.match-hits-row .mono {
    word-break: break-all;
}

.unique-firm-row {
    width: 100%;
    grid-template-columns: 1fr auto;
    text-align: left;
    cursor: pointer;
    font: inherit;
    color: inherit;
}

.unique-firm-row:hover {
    border-color: #9bb6d4;
    background: #f0f6fc;
}

.unique-firm-count {
    font-size: 18px;
    font-weight: 700;
}

@media (max-width: 720px) {
    .match-hits-row {
        grid-template-columns: 1fr;
        gap: 2px;
    }
}

.name-preview-panel {
    width: min(1480px, calc(100vw - 24px));
    max-height: min(900px, calc(100vh - 32px));
}

.name-preview-filter {
    margin: 0 0 14px;
}

.name-preview-list {
    overflow: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-right: 4px;
    min-height: 0;
    flex: 1;
}

.name-preview-firm {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 10px 12px;
    background: #fbfcfe;
}

.rule-propagation-firm {
    display: block;
    cursor: pointer;
}

.rule-propagation-firm .name-preview-firm-head {
    display: flex;
    align-items: center;
    gap: 8px;
}

.name-preview-firm.selected {
    border-color: #1f6feb;
    background: #f3f8ff;
}

.name-preview-firm.empty {
    opacity: 0.72;
}

.name-preview-firm-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.name-preview-sample {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    text-align: left;
    border: 1px solid transparent;
    border-radius: 10px;
    background: #fff;
    padding: 10px 12px;
    margin: 0 0 6px;
    cursor: pointer;
}

.name-preview-sample:last-child {
    margin-bottom: 0;
}

.name-preview-sample:hover:not(:disabled) {
    border-color: #1f6feb;
    background: #f8fbff;
}

.name-preview-sample:disabled {
    opacity: 0.6;
    cursor: wait;
}

.name-preview-sample-name {
    font-weight: 600;
    color: #152338;
    line-height: 1.35;
}

.scan-sticky {
    position: sticky;
    top: 0;
    z-index: 30;
    margin: 0 0 16px;
}

.scan-sticky-inner {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 14px 16px;
    box-shadow: 0 10px 28px rgba(18, 32, 51, 0.08);
}

.scan-progress-track {
    height: 10px;
    background: #e6edf3;
    border-radius: 999px;
    overflow: hidden;
}

.pager {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px 12px;
    margin: 8px 0 12px;
    background: #f4f7fa;
    border: 1px solid var(--line);
    border-radius: 10px;
}

.pager-num {
    min-width: 36px;
}

.pager-gap {
    color: var(--muted);
    padding: 0 4px;
    line-height: 31px;
}

.pager-jump {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: 8px;
}

.pager-jump input {
    width: 72px;
}

.match-unique-tag {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 7px;
    border-radius: 999px;
    background: #eef6ff;
    color: #3a6ea5;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.02em;
    vertical-align: middle;
}

.scan-progress-bar {
    height: 100%;
    background: var(--accent);
    border-radius: 999px;
    transition: width 0.25s ease;
}

.firm-scan-done {
    background: #e7f6f3;
}

.firm-scan-run {
    background: #eef6ff;
}

.firm-check {
    display: inline-grid;
    place-items: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
}

.firm-spin {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #c5d4e2;
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: firm-spin 0.7s linear infinite;
}

@keyframes firm-spin {
    to { transform: rotate(360deg); }
}

.firm-acc {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: 0 8px 24px rgba(18, 32, 51, 0.04);
    overflow: hidden;
}

.firm-acc-bar {
    display: flex;
    align-items: stretch;
}

.desc-pick {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 8px 10px 8px 0;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #fff;
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
}

.desc-pick:hover:not(:disabled) {
    border-color: var(--accent);
    color: var(--text);
}

.desc-pick.on {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: #1d6f65;
}

.desc-pick:disabled {
    opacity: 0.65;
}

.desc-pick-mark {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid currentColor;
    box-shadow: inset 0 0 0 2px #fff;
}

.desc-pick.on .desc-pick-mark {
    background: var(--accent);
    border-color: var(--accent);
    box-shadow: none;
}

.firm-acc-head {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    text-align: left;
    background: transparent;
    border: 0;
    padding: 14px 16px;
    color: inherit;
}

.firm-acc-head:hover {
    background: #f7fafc;
}

.firm-acc-head strong {
    display: block;
    font-size: 16px;
}

.firm-acc-chevron {
    width: 8px;
    height: 8px;
    border-right: 2px solid var(--muted);
    border-bottom: 2px solid var(--muted);
    transform: rotate(-45deg);
    margin: 0 4px 0 2px;
    flex-shrink: 0;
}

.firm-acc.open .firm-acc-chevron {
    transform: rotate(45deg);
    margin-top: -4px;
}

.firm-acc-body {
    padding: 0 16px 16px;
    border-top: 1px solid var(--line);
}

[ng-cloak] {
    display: none !important;
}

html:has(body.matrix-mode),
body.matrix-mode {
    height: 100vh;
    overflow: hidden;
}

body.matrix-mode .app-sidebar {
    width: 200px;
    min-height: 100vh;
    flex-shrink: 0;
}

body.matrix-mode .app-main {
    flex: 1;
    min-width: 0;
    height: 100vh;
    padding: 8px;
    display: flex;
    flex-direction: column;
}

body.matrix-mode .page-host {
    max-width: none;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.matrix-screen {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    gap: 6px;
}

.matrix-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: nowrap;
    flex-shrink: 0;
}

.matrix-toolbar strong {
    white-space: nowrap;
    font-size: 15px;
}

.matrix-toolbar .form-control,
.matrix-toolbar .form-select,
.matrix-toolbar .btn {
    width: auto;
    max-width: 220px;
}

.matrix-toolbar .help {
    white-space: nowrap;
    margin-left: auto;
}

.matrix-wrap {
    flex: 1;
    min-height: 0;
    width: 100%;
    overflow: auto;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.matrix-table {
    width: max-content;
    min-width: 100%;
    margin: 0;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 12px;
}

.matrix-table th,
.matrix-table td {
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    padding: 4px 6px;
    vertical-align: middle;
}

.matrix-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #eef3f7;
    font-weight: 600;
    color: var(--ink);
    overflow: hidden;
    border-bottom: 1px solid #c5d0da;
}

.matrix-table thead th.matrix-col {
    height: 108px;
    min-width: 124px;
    width: 124px;
    padding: 0 4px 6px;
    vertical-align: bottom;
    overflow: hidden;
}

.matrix-table thead th.matrix-col .hdr {
    display: flex;
    align-items: flex-end;
    height: 100%;
}

.matrix-table thead th.matrix-col .hdr span {
    display: inline-block;
    transform: rotate(-48deg);
    transform-origin: left bottom;
    white-space: nowrap;
    font-size: 11px;
    line-height: 1;
    padding-left: 2px;
}

.matrix-table th.sticky,
.matrix-table td.sticky {
    position: sticky;
    left: 0;
    z-index: 3;
    width: 140px;
    min-width: 140px;
    background: #fff;
    box-shadow: 2px 0 0 var(--line);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.matrix-table thead th.sticky {
    z-index: 4;
    background: #eef3f7;
}

.matrix-table tbody tr.selected td {
    background: #b7ebe2 !important;
}

.matrix-table tbody tr.selected td.sticky {
    background: #6fd4c4 !important;
    box-shadow: inset 4px 0 0 #14665c, 2px 0 0 var(--line);
    color: #0d3d38;
}

.matrix-table tbody tr {
    cursor: pointer;
}

.matrix-col {
    min-width: 124px;
    width: 124px;
    position: relative;
}

.matrix-cell {
    display: block;
    width: 100%;
    min-height: 28px;
    line-height: 1.25;
    padding: 4px 2px;
    color: var(--muted);
    cursor: pointer;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.matrix-cell.filled {
    color: var(--ink);
    font-weight: 600;
}

.matrix-cell.hit {
    background: #ffe566;
    color: #3a2f00;
    font-weight: 700;
}

.report-table .matrix-cell {
    cursor: default;
    white-space: normal;
}

.report-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.report-item {
    display: grid;
    grid-template-columns: minmax(220px, 300px) 1fr;
    gap: 20px;
    align-items: start;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 16px 18px;
}

.report-owner-code {
    display: block;
    font-size: 22px;
    line-height: 1.2;
    word-break: break-all;
}

.report-owner-desc {
    margin: 10px 0 0;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.35;
    color: var(--text);
}

.report-desc-src {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 8px;
    border-radius: 999px;
    background: #eef6ff;
    color: #3a6ea5;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.report-firms {
    display: flex;
    flex-direction: column;
    gap: 0;
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: 10px;
    overflow: hidden;
}

.report-table-head,
.report-firm-line {
    display: grid;
    grid-template-columns: minmax(140px, 1.2fr) minmax(140px, 1.4fr) 72px 120px 120px 90px;
    column-gap: 10px;
    align-items: center;
    padding: 10px 12px;
}

.report-table-head {
    background: #eef2f6;
    border-bottom: 1px solid var(--line);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: #5a6b7d;
}

.report-firm-line {
    border-bottom: 1px solid var(--line);
    font-size: 15px;
    font-weight: 600;
}

.report-firm-line:last-child {
    border-bottom: 0;
}

.report-firm-line.is-in {
    background: #eefaf4;
}

.report-firm-line.is-out {
    background: #fbf0f0;
    opacity: 0.92;
}

.report-firm-line.is-cheap {
    box-shadow: inset 3px 0 0 #1d6f65;
}

.report-firm-name {
    font-weight: 800;
    letter-spacing: 0.01em;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.report-cheap-tag {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 999px;
    background: #1d6f65;
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.report-firm-code {
    font-family: Consolas, "Courier New", monospace;
    font-weight: 700;
    font-size: 14px;
    word-break: break-all;
}

.report-num {
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    white-space: nowrap;
}

.report-curr {
    font-weight: 600;
    opacity: 0.65;
    font-size: 0.85em;
}

.report-stock {
    font-weight: 800;
    letter-spacing: 0.02em;
}

.report-stock.on {
    color: #1d6f65;
}

.report-stock.off {
    color: #8a3a32;
}

.report-firm-line.report-firm-desc .report-firm-name {
    color: #1d6f65;
}

.report-firm-line.report-firm-hit {
    background: #ffe566;
    color: #3a2f00;
}

.report-firm-line.report-firm-hit .report-stock.on,
.report-firm-line.report-firm-hit .report-stock.off {
    color: inherit;
}

.matrix-editor {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 8;
    width: 240px;
    background: #fff;
    border: 1px solid #9bb0c3;
    border-radius: 8px;
    box-shadow: 0 10px 24px rgba(18, 32, 51, 0.16);
    padding: 6px;
}

.matrix-editor-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
    font-size: 12px;
    font-weight: 600;
}

.matrix-editor-close {
    border: 0;
    background: #eef3f7;
    color: var(--ink);
    border-radius: 6px;
    padding: 2px 8px;
    font-size: 12px;
    cursor: pointer;
}

.matrix-editor-close:hover {
    background: #dbe3ec;
}

.matrix-editor input,
.matrix-editor select {
    width: 100%;
    font-size: 13px;
}

.matrix-editor input {
    margin-bottom: 6px;
}

.matrix-editor select {
    min-height: 220px;
}

.matrix-picked {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 6px;
    min-height: 24px;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--accent-soft);
    color: #1d6f65;
    border-radius: 999px;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 600;
}

.chip button {
    border: 0;
    background: transparent;
    color: inherit;
    line-height: 1;
    padding: 0;
    cursor: pointer;
    font-size: 14px;
}

.ai-boot {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at center, #16324a 0%, #071018 62%, #04070c 100%);
    color: #e8f6ff;
    text-align: center;
    overflow: hidden;
}

.ai-boot-glow {
    position: absolute;
    width: 520px;
    height: 520px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(47, 214, 196, 0.22), transparent 68%);
    animation: ai-pulse 2.4s ease-in-out infinite;
}

.ai-core {
    position: relative;
    width: 180px;
    height: 180px;
    margin-bottom: 28px;
}

.ai-ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 1px dashed rgba(140, 230, 220, 0.35);
}

.ai-ring-a { animation: ai-spin 8s linear infinite; }
.ai-ring-b {
    inset: 14px;
    border-style: solid;
    border-color: transparent rgba(47, 214, 196, 0.55) transparent rgba(47, 214, 196, 0.15);
    animation: ai-spin 4.5s linear infinite reverse;
}
.ai-ring-c {
    inset: 28px;
    border-style: dotted;
    animation: ai-spin 11s linear infinite;
}

.ai-orb {
    position: absolute;
    inset: 44px;
    border-radius: 50%;
    background: linear-gradient(160deg, #7ef0de, #2f9e8f 55%, #145e56);
    box-shadow: 0 0 32px rgba(47, 214, 196, 0.55), inset 0 0 18px rgba(255, 255, 255, 0.25);
    display: grid;
    place-items: center;
    animation: ai-breathe 1.6s ease-in-out infinite;
}

.ai-orb strong {
    font-size: 28px;
    letter-spacing: 0.08em;
    text-shadow: 0 0 12px rgba(255, 255, 255, 0.45);
}

.ai-orb-eye {
    position: absolute;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    top: 18px;
    right: 22px;
    box-shadow: 0 0 10px #fff;
    animation: ai-blink 2.8s ease-in-out infinite;
}

.ai-dot {
    position: absolute;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #8ef0e2;
    top: 50%;
    left: 50%;
    animation: ai-orbit 3.6s linear infinite;
}

.ai-dot:nth-child(5) { animation-delay: -0.4s; }
.ai-dot:nth-child(6) { animation-delay: -0.8s; }
.ai-dot:nth-child(7) { animation-delay: -1.2s; }
.ai-dot:nth-child(8) { animation-delay: -1.6s; }
.ai-dot:nth-child(9) { animation-delay: -2s; }
.ai-dot:nth-child(10) { animation-delay: -2.4s; }
.ai-dot:nth-child(11) { animation-delay: -2.8s; }
.ai-dot:nth-child(12) { animation-delay: -3.2s; }

.ai-boot-name {
    font-size: 13px;
    letter-spacing: 0.28em;
    text-transform: uppercase;
    color: #8ef0e2;
    margin-bottom: 8px;
}

.ai-boot-title {
    font-size: 32px;
    margin: 0 0 8px;
    font-weight: 700;
}

.ai-boot-sub {
    max-width: 460px;
    color: #9fb8c8;
    margin: 0 0 28px;
}

.ai-boot-steps {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 320px;
    text-align: left;
}

.ai-boot-steps li {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #6d8494;
    font-size: 14px;
}

.ai-boot-steps li.done { color: #8ef0e2; }
.ai-boot-steps li.on {
    color: #fff;
    font-weight: 700;
}

.ai-step-mark {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 1px solid #6d8494;
    flex-shrink: 0;
}

.ai-boot-steps li.done .ai-step-mark {
    background: #2f9e8f;
    border-color: #2f9e8f;
}

.ai-boot-steps li.on .ai-step-mark {
    background: #8ef0e2;
    border-color: #8ef0e2;
    box-shadow: 0 0 10px #8ef0e2;
    animation: ai-pulse 1s ease-in-out infinite;
}

@keyframes ai-spin { to { transform: rotate(360deg); } }
@keyframes ai-pulse {
    0%, 100% { opacity: 0.55; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.06); }
}
@keyframes ai-breathe {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.06); }
}
@keyframes ai-blink {
    0%, 80%, 100% { transform: scaleY(1); opacity: 1; }
    88% { transform: scaleY(0.15); opacity: 0.4; }
}
@keyframes ai-orbit {
    from { transform: rotate(0deg) translateX(78px) rotate(0deg); }
    to { transform: rotate(360deg) translateX(78px) rotate(-360deg); }
}
.app-main.login-main { margin-left: 0; width: 100%; padding: 0; }
.login-main .page-host { max-width: none; }
.login-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background: #f1f5f9; }
.login-card { width: 100%; max-width: 420px; padding: 36px; background: #fff; border: 1px solid #e2e8f0; border-radius: 16px; box-shadow: 0 16px 48px rgba(15, 23, 42, .08); }
.login-card .brand-mark { display: inline-flex; margin-bottom: 20px; }
.login-card h1 { font-size: 24px; color: #0f172a; margin-bottom: 10px; }
.login-card p { color: #64748b; }
.login-card label { display: block; margin: 18px 0 8px; color: #334155; font-weight: 600; }
.login-card input { min-height: 44px; }
.login-card button { width: 100%; margin-top: 24px; min-height: 44px; }
.login-card .login-error { color: #b91c1c; margin: 16px 0 0; }
.sidebar-foot button { margin-top: 10px; }

.brand-board {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    gap: 16px;
    align-items: stretch;
    min-height: calc(100vh - 190px);
}

.brand-firms,
.brand-main {
    margin: 0;
    min-height: 0;
    max-height: calc(100vh - 190px);
    overflow: auto;
}

.brand-firm {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    border: 0;
    background: transparent;
    color: var(--ink);
    text-align: left;
    border-radius: 8px;
    padding: 8px 10px;
}

.brand-firm:hover,
.brand-firm.on {
    background: var(--accent-soft);
}

.brand-firm em {
    font-style: normal;
    min-width: 22px;
    padding: 1px 7px;
    border-radius: 999px;
    background: #f3d6d2;
    color: var(--danger);
    font-size: 12px;
    text-align: center;
}

.brand-toolbar,
.brand-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.brand-toolbar h2 {
    margin: 0 0 4px;
    font-size: 22px;
}

.brand-search {
    width: 260px;
}

.brand-actions {
    justify-content: flex-start;
    margin: 14px 0;
}

.brand-actions-gap {
    flex: 1;
}

.brand-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.brand-row {
    display: grid;
    grid-template-columns: 32px minmax(160px, 1.4fr) 90px minmax(120px, 1fr) 110px;
    gap: 10px;
    align-items: center;
    padding: 8px 10px;
    border-radius: 8px;
}

.brand-row-head {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .03em;
    position: sticky;
    top: 0;
    background: var(--card);
}

.brand-row.off {
    background: #fbf6f5;
}

.brand-row strong {
    font-weight: 650;
}

.brand-switch {
    border: 1px solid var(--line);
    background: #fff;
    color: var(--muted);
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 12px;
}

.brand-switch.on {
    border-color: #b7e4dc;
    background: var(--accent-soft);
    color: #0f6f62;
}

.cheap-kpis {
    grid-template-columns: repeat(6, minmax(0, 1fr));
}

.cheap-kpis .stat strong {
    font-size: 18px;
}

.cheap-dash {
    width: min(1680px, calc(100vw - 32px));
}

.cheap-dash-body {
    display: grid;
    grid-template-columns: 420px minmax(0, 1fr);
    gap: 16px;
    min-height: 0;
    flex: 1;
}

.cheap-firms,
.cheap-products {
    min-height: 0;
    overflow: auto;
}

.table-scroll {
    overflow: auto;
}

.cheap-firms tr {
    cursor: pointer;
}

.cheap-firms tr.active {
    background: #e7f6f3;
}

.cheap-product-tools {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}

@media (max-width: 1100px) {
    .cheap-dash-body,
    .cheap-kpis {
        grid-template-columns: 1fr;
    }
}

.tecdoc-detail {
    width: min(1100px, calc(100vw - 32px));
}

.tecdoc-body {
    display: grid;
    grid-template-columns: minmax(280px, 420px) minmax(0, 1fr);
    gap: 20px;
    min-height: 0;
    overflow: auto;
}

.tecdoc-main {
    display: block;
    width: 100%;
    padding: 0;
    border: 1px solid #d5dde6;
    border-radius: 12px;
    background: #f4f7fa;
    cursor: zoom-in;
}

.tecdoc-main img,
.tecdoc-thumbs img {
    display: block;
    width: 100%;
    height: 280px;
    object-fit: contain;
}

.tecdoc-thumbs {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    overflow: auto;
}

.tecdoc-thumbs button {
    width: 72px;
    padding: 0;
    border: 1px solid #d5dde6;
    border-radius: 8px;
    background: #fff;
}

.tecdoc-thumbs button.active {
    border-color: #2f9e8f;
}

.tecdoc-thumbs img {
    height: 56px;
}

.tecdoc-facts {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.tecdoc-facts span {
    display: block;
    color: #6b7c93;
    font-size: 12px;
}

.tecdoc-lightbox {
    position: fixed;
    inset: 0;
    z-index: 80;
    background: rgba(10, 16, 28, 0.88);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px;
}

.tecdoc-lightbox img {
    max-width: min(1200px, 100%);
    max-height: 100%;
    object-fit: contain;
}

.tecdoc-lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    height: 48px;
    border: 0;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
    font-size: 32px;
    line-height: 1;
}

.tecdoc-lightbox-nav.prev { left: 16px; }
.tecdoc-lightbox-nav.next { right: 16px; }

@media (max-width: 900px) {
    .tecdoc-body {
        grid-template-columns: 1fr;
    }
}

.bm-panel {
    padding-bottom: 12px;
}

.bm-row {
    grid-template-columns: 32px minmax(180px, 1.3fr) 90px minmax(160px, 1.2fr) minmax(200px, 1.2fr);
}

.bm-firms {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bm-firm-link {
    border: 0;
    background: none;
    padding: 0;
    color: #1d6f65;
    font: inherit;
    cursor: pointer;
}

.bm-firm-link:hover,
.bm-firm-link:focus-visible {
    text-decoration: underline;
}

.bm-raw-firms {
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.bm-raw-filters {
    grid-template-columns: minmax(240px, 420px);
}

.bm-cell {
    width: 100%;
    text-align: left;
    border: 1px dashed transparent;
    background: transparent;
    color: var(--ink);
    font-weight: 600;
    border-radius: 6px;
    padding: 4px 8px;
}

.bm-cell:hover:not(:disabled) {
    border-color: var(--line);
    background: #f8fafc;
}

.bm-cell.empty {
    color: var(--muted);
    font-weight: 400;
    font-style: italic;
}

.bm-row-error {
    color: var(--danger);
    font-size: 12px;
}

.bm-bulk {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.bm-bulk input {
    width: 240px;
}

.bm-excel-panel {
    width: min(760px, calc(100vw - 32px));
    max-height: min(820px, calc(100vh - 32px));
}

.bm-excel-body {
    overflow-y: auto;
    min-height: 0;
    flex: 1 1 auto;
}

.bm-excel-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
    margin-bottom: 12px;
}

.bm-excel-stat {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
}

.bm-excel-stat strong {
    font-size: 22px;
    color: var(--ink);
}

.bm-excel-stat span {
    color: var(--muted);
    font-size: 13px;
}

.bm-excel-stat.warn {
    border-color: #f0c36d;
    background: #fff8e6;
}

.bm-excel-list {
    border-top: 1px solid var(--line);
    padding-top: 10px;
    margin-top: 10px;
}

.bm-excel-names {
    font-size: 13px;
    word-break: break-word;
}

.bm-excel-foot {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
    margin-top: 12px;
}

.bm-excel-foot .help {
    margin-right: auto;
}

.td-row {
    grid-template-columns: 32px minmax(180px, 1.2fr) 110px 90px minmax(300px, 1.8fr);
    align-items: start;
    border-bottom: 1px solid #eef2f6;
}

.td-row.brand-row-head {
    align-items: center;
    border-bottom: 0;
}

.td-row.confirmed {
    background: #f6fbfa;
}

.td-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 4px 0 2px;
}

.td-badge-changed {
    background: #fff8e6;
    color: var(--warn);
    border: 1px solid #f0c36d;
    border-radius: 999px;
    padding: 2px 9px;
    font-size: 12px;
}

.td-choice {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.td-option {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    padding: 3px 6px;
    border-radius: 6px;
    cursor: pointer;
}

.td-option:hover {
    background: #f8fafc;
}

.td-option-name {
    font-weight: 600;
    color: var(--ink);
}

.td-option-name.td-none {
    font-weight: 400;
    color: var(--muted);
    font-style: italic;
}

.td-tag {
    background: var(--accent-soft);
    color: #1d6f65;
    border-radius: 999px;
    padding: 1px 8px;
    font-size: 11px;
    white-space: nowrap;
}

.td-search-line {
    display: flex;
    gap: 8px;
    margin-top: 4px;
}

.td-search-line input {
    flex: 1 1 auto;
    min-width: 0;
}

@media (max-width: 900px) {
    .td-row {
        grid-template-columns: 32px 1fr;
    }

    .td-row > span {
        display: none;
    }

    .td-row .td-choice {
        grid-column: 2;
    }
}

.full-sync-steps {
    display: grid;
    gap: 6px;
}

.full-sync-step {
    display: flex;
    align-items: baseline;
    gap: 10px;
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fbfcfe;
}

.full-sync-badge {
    min-width: 84px;
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
}

.full-sync-step.is-running {
    border-color: #b7e0d9;
    background: var(--accent-soft);
}

.full-sync-step.is-running .full-sync-badge,
.full-sync-step.is-done .full-sync-badge {
    color: #1d6f65;
}

.full-sync-step.is-failed {
    border-color: #f1b8b8;
    background: #fdf2f2;
}

.full-sync-step.is-failed .full-sync-badge {
    color: #b42318;
}

.full-sync-step.is-skipped {
    opacity: 0.6;
}

.solr-status {
    border-top: 1px solid var(--line);
    padding-top: 12px;
}

.solr-badge {
    font-size: 12px;
    font-weight: 600;
    padding: 2px 10px;
    border-radius: 999px;
    background: #eef2f6;
    color: var(--muted);
}

.solr-badge.busy {
    background: var(--accent-soft);
    color: #1d6f65;
}

.solr-badge.failed {
    background: #fdf2f2;
    color: #b42318;
}

.solr-grid {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 4px 12px;
    font-size: 13px;
}

.solr-grid span:nth-child(odd) {
    color: var(--muted);
}

.merkez-sync {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
}

.merkez-sync-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.merkez-row {
    grid-template-columns: minmax(180px, 1fr) minmax(200px, .8fr) minmax(280px, 1.5fr);
    align-items: start;
}

.merkez-count {
    margin-top: 2px;
}

.merkez-hits {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}

.merkez-brand {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
}

.merkez-tecdoc-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.merkez-tecdoc-body {
    display: grid;
    grid-template-columns: minmax(280px, 0.9fr) minmax(340px, 1.2fr);
    gap: 18px;
    min-height: 0;
    flex: 1;
    overflow: hidden;
}

.merkez-tecdoc-list,
.merkez-tecdoc-detail {
    min-height: 0;
    overflow: auto;
}

.merkez-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 10px;
}

.merkez-tabs button {
    border: 1px solid var(--line, #d7dee7);
    background: #fff;
    border-radius: 999px;
    padding: 4px 12px;
    font-size: 13px;
}

.merkez-tabs button.is-on {
    background: #1d6f65;
    border-color: #1d6f65;
    color: #fff;
}

.merkez-tecdoc-table tr {
    cursor: default;
}

.merkez-tecdoc-table.can-open tr {
    cursor: pointer;
}

.merkez-tecdoc-table tr.is-on {
    background: #e7f3f1;
}

.merkez-tecdoc-detail h3 {
    margin: 0 0 4px;
    font-size: 18px;
}

.merkez-tecdoc-pager {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
}

@media (max-width: 900px) {
    .merkez-tecdoc-body {
        grid-template-columns: 1fr;
        overflow: auto;
    }
}
