:root {
    --pv-blue: #2a46ff;
    --pv-navy: #0f1629;
    --pv-white: #ffffff;

    --bs-primary: #2a46ff;
    --bs-primary-rgb: 42, 70, 255;
    --bs-link-color: #2a46ff;
    --bs-link-color-rgb: 42, 70, 255;
    --bs-link-hover-color: #0f1629;
    --bs-link-hover-color-rgb: 15, 22, 41;
    --bs-body-color: #0f1629;
    --bs-body-color-rgb: 15, 22, 41;
    --bs-body-bg: #ffffff;
    --bs-border-color: #e3e6ee;
    --bs-border-radius: 10px;
}

body {
    background: #f7f8fb;
}

.btn-primary {
    --bs-btn-bg: var(--pv-blue);
    --bs-btn-border-color: var(--pv-blue);
    --bs-btn-hover-bg: var(--pv-navy);
    --bs-btn-hover-border-color: var(--pv-navy);
    --bs-btn-active-bg: var(--pv-navy);
    --bs-btn-active-border-color: var(--pv-navy);
    --bs-btn-disabled-bg: var(--pv-blue);
    --bs-btn-disabled-border-color: var(--pv-blue);
    --bs-btn-focus-shadow-rgb: 42, 70, 255;
}

.btn-outline-secondary {
    --bs-btn-color: #4a5266;
    --bs-btn-border-color: #d3d8e4;
    --bs-btn-hover-bg: var(--pv-navy);
    --bs-btn-hover-border-color: var(--pv-navy);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--pv-blue);
    box-shadow: 0 0 0 0.2rem rgba(42, 70, 255, 0.15);
}

a {
    text-decoration: none;
}

code {
    color: var(--pv-blue);
}

/* ---- каркас ---- */

.app {
    display: flex;
    min-height: 100vh;
}

.app-sidebar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    flex: 0 0 240px;
    flex-direction: column;
    width: 240px;
    height: 100vh;
    padding: 22px 14px;
    background: var(--pv-white);
    border-right: 1px solid var(--bs-border-color);
}

.app-logo {
    padding: 0 10px 22px;
    font-size: 20px;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--pv-navy);
}

.app-logo span {
    color: var(--pv-blue);
}

.app-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.app-nav-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    color: #4a5266;
}

.app-nav-link:hover {
    background: #f4f5f9;
    color: var(--pv-navy);
}

.app-nav-link.active {
    background: rgba(42, 70, 255, 0.1);
    color: var(--pv-blue);
}

.app-nav-link.disabled {
    color: #9aa2b5;
    cursor: default;
}

.app-nav-link.disabled:hover {
    background: transparent;
    color: #9aa2b5;
}

.app-soon {
    padding: 2px 7px;
    border-radius: 20px;
    background: #eef0f5;
    color: #7b8399;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.app-sidebar-foot {
    margin-top: auto;
    padding: 12px 10px 0;
    border-top: 1px solid var(--bs-border-color);
}

.app-env {
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: 11px;
    color: #9aa2b5;
}

.app-main {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-width: 0;
}

.app-topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 16px;
    height: 64px;
    padding: 0 24px;
    background: var(--pv-white);
    border-bottom: 1px solid var(--bs-border-color);
}

.app-topbar-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--pv-navy);
}

.app-user {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-left: auto;
}

.app-user-email {
    font-size: 13px;
    color: #5c657a;
}

.app-user-link {
    font-size: 13px;
    font-weight: 600;
}

.app-burger {
    display: none;
    padding: 4px 10px;
    border: 1px solid var(--bs-border-color);
    border-radius: 8px;
    background: var(--pv-white);
    font-size: 18px;
    line-height: 1.2;
}

.app-content {
    width: 100%;
    max-width: 1180px;
    padding: 32px 24px 64px;
}

/* ---- страницы ---- */

.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 28px;
}

.page-title {
    margin: 0;
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--pv-navy);
}

.page-lead {
    margin: 8px 0 0;
    font-size: 14px;
    color: #5c657a;
}

.card {
    border-color: var(--bs-border-color);
}

.app-stat-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #7b8399;
}

.app-stat-value {
    margin: 10px 0 6px;
    font-size: 34px;
    font-weight: 800;
    line-height: 1;
    color: var(--pv-navy);
}

.app-stat-hint {
    font-size: 12px;
    color: #9aa2b5;
}

.app-empty {
    border-style: dashed;
    background: transparent;
}

.app-empty-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--pv-navy);
}

/* ---- вход ---- */

.auth-body {
    background: var(--pv-white);
}

.auth-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 32px 20px;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    box-shadow: 0 18px 48px rgba(15, 22, 41, 0.08);
}

.auth-logo {
    display: inline-block;
    margin-bottom: 22px;
    font-size: 20px;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--pv-navy);
}

.auth-logo span {
    color: var(--pv-blue);
}

.auth-title {
    margin: 0 0 6px;
    font-size: 24px;
    font-weight: 800;
    color: var(--pv-navy);
}

.auth-lead {
    margin: 0 0 24px;
    font-size: 14px;
    color: #5c657a;
}

.auth-foot {
    margin: 24px 0 0;
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: 11px;
    color: #9aa2b5;
}

/* ---- мобильный ---- */

@media (max-width: 991.98px) {
    .app-sidebar {
        position: fixed;
        left: 0;
        transform: translateX(-100%);
        transition: transform 0.2s ease;
        box-shadow: 0 0 40px rgba(15, 22, 41, 0.16);
    }

    .app-sidebar.open {
        transform: translateX(0);
    }

    .app-burger {
        display: inline-block;
    }

    .app-content {
        padding: 24px 16px 48px;
    }

    .page-title {
        font-size: 24px;
    }
}

@media (max-width: 575.98px) {
    .app-user-email {
        display: none;
    }
}

/* ---- таблицы и карточки контента ---- */

.app-card-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 6px;
    font-size: 17px;
    font-weight: 700;
    color: var(--pv-navy);
}

.app-card-lead {
    margin: 0 0 16px;
    font-size: 13px;
    color: #5c657a;
}

.app-count {
    padding: 2px 8px;
    border-radius: 20px;
    background: rgba(42, 70, 255, 0.1);
    color: var(--pv-blue);
    font-size: 12px;
    font-weight: 700;
}

.app-table > :not(caption) > * > * {
    padding: 12px 16px;
    border-bottom-color: var(--bs-border-color);
}

.app-table thead th {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #7b8399;
    background: #fafbfd;
}

.app-table-title {
    font-weight: 600;
    color: var(--pv-navy);
}

.app-table-title:hover {
    color: var(--pv-blue);
}

.app-table-sub {
    font-size: 12px;
    color: #7b8399;
    overflow-wrap: anywhere;
}

.app-breadcrumbs {
    display: flex;
    gap: 6px;
    margin-bottom: 8px;
    font-size: 12px;
    color: #7b8399;
}

.app-breadcrumbs a:hover {
    color: var(--pv-blue);
}

.app-run-form {
    display: flex;
    align-items: center;
    gap: 10px;
}

.app-run-form .form-select {
    width: auto;
    min-width: 150px;
}

.app-alert {
    font-size: 13px;
    color: #4a5266;
}

.app-keywords {
    display: grid;
    gap: 1px;
    max-height: 320px;
    overflow-y: auto;
    margin: 0;
    padding: 0;
    list-style: none;
}

.app-keywords li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 7px 0;
    border-bottom: 1px solid var(--bs-border-color);
    font-size: 13.5px;
}

.app-keywords li.is-off span {
    color: #9aa2b5;
    text-decoration: line-through;
}

.app-keyword-toggle {
    border: 0;
    border-radius: 6px;
    padding: 2px 7px;
    background: none;
    color: #7b8399;
    font-size: 11px;
    line-height: 1.6;
}

.app-keyword-toggle:hover {
    background: #f1f3f9;
    color: var(--pv-blue);
}

.app-keywords li:last-child {
    border-bottom: 0;
}

.app-status {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.app-status-lg {
    padding: 6px 14px;
    font-size: 12px;
}

.app-status-queued {
    background: #f1f3f8;
    color: #5c657a;
}

.app-status-running {
    background: rgba(42, 70, 255, 0.1);
    color: var(--pv-blue);
}

.app-status-done {
    background: #e9f6ef;
    color: #1d7a4c;
}

.app-status-failed {
    background: #fdeceb;
    color: #b42318;
}

.app-pos {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.app-pos-top {
    display: inline-block;
    min-width: 28px;
    padding: 2px 7px;
    border-radius: 6px;
    background: var(--pv-blue);
    color: var(--pv-white);
}

.app-stat-value-sm {
    font-size: 22px;
}

@media (max-width: 767.98px) {
    .page-head {
        flex-wrap: wrap;
        align-items: flex-start;
    }

    .app-run-form {
        width: 100%;
        flex-wrap: wrap;
    }

    .app-run-form .form-select {
        flex: 1;
    }

    .app-run-form .btn {
        flex: 1 0 auto;
    }
}

.app-inline-form {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.app-inline-form .form-control {
    flex: 1;
    min-width: 160px;
    max-width: 240px;
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}

.app-input-narrow {
    flex: 0 0 120px;
    max-width: 120px;
}

/* ---- отчёт проекта ---- */

.app-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.app-stat-foot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.app-delta {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 11.5px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.app-delta-up {
    background: #e9f6ef;
    color: #1d7a4c;
}

.app-delta-down {
    background: #fdeceb;
    color: #b42318;
}

.app-charts {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 24px;
    margin-top: 4px;
}

.app-chart {
    margin: 0;
}

.app-chart figcaption {
    margin-bottom: 8px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #7b8399;
}

.app-chart-svg {
    display: block;
    width: 100%;
    height: auto;
}

.app-chart-grid {
    stroke: #eceef4;
    stroke-width: 1;
}

.app-chart-baseline {
    stroke: #dfe3ec;
    stroke-width: 1;
}

.app-chart-tick {
    fill: #9aa2b5;
    font-size: 10px;
    font-variant-numeric: tabular-nums;
}

.app-chart-area {
    fill: rgba(42, 70, 255, 0.08);
}

.app-chart-line {
    fill: none;
    stroke: var(--pv-blue);
    stroke-width: 2.2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.app-chart-dot {
    fill: var(--pv-white);
    stroke: var(--pv-blue);
    stroke-width: 2;
}

.app-chart-dot:hover {
    fill: var(--pv-blue);
}

.app-chart-bar {
    fill: rgba(42, 70, 255, 0.72);
}

.app-chart-bar:hover {
    fill: var(--pv-navy);
}

.app-matrix-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 14px;
}

.app-matrix-controls {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
}

.app-matrix-legend {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    font-size: 11px;
    color: #7b8399;
}

.app-legend-chip {
    display: inline-block;
    width: 12px;
    height: 12px;
    margin-right: 4px;
    border-radius: 3px;
    vertical-align: -1px;
}

.app-matrix-search {
    width: 260px;
}

.app-matrix-wrap {
    max-height: 580px;
    overflow: auto;
    border: 1px solid var(--bs-border-color);
    border-radius: 10px;
}

.app-matrix {
    width: 100%;
    margin: 0;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 12.5px;
}

.app-matrix th,
.app-matrix td {
    padding: 7px 8px;
    border-bottom: 1px solid #f0f2f7;
    white-space: nowrap;
}

.app-matrix thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #fafbfd;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #7b8399;
    text-align: center;
    border-bottom: 1px solid var(--bs-border-color);
}

.app-matrix thead th.app-matrix-phrase,
.app-matrix td.app-matrix-phrase {
    position: sticky;
    left: 0;
    z-index: 1;
    min-width: 220px;
    max-width: 320px;
    overflow: hidden;
    background: var(--pv-white);
    text-align: left;
    text-overflow: ellipsis;
}

.app-matrix thead th.app-matrix-phrase {
    z-index: 3;
}

.app-matrix td.app-matrix-phrase {
    font-weight: 600;
    color: var(--pv-navy);
    box-shadow: 1px 0 0 var(--bs-border-color);
}

.app-matrix thead th.app-matrix-phrase {
    box-shadow: 1px 0 0 var(--bs-border-color);
}

.app-matrix tbody tr:hover td.app-matrix-phrase {
    background: #f6f8ff;
}

.app-matrix-delta {
    text-align: center !important;
    font-variant-numeric: tabular-nums;
}

.app-delta-value {
    font-weight: 700;
    font-size: 12px;
}

.app-delta-value.is-up {
    color: #1d7a4c;
}

.app-delta-value.is-down {
    color: #b42318;
}

.app-matrix-cell {
    min-width: 42px;
    text-align: center;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.app-matrix .app-tone-top3 {
    background: var(--pv-blue);
    color: var(--pv-white);
}

.app-matrix .app-tone-top10 {
    background: #e6ecff;
    color: #1b2fa8;
}

.app-matrix .app-tone-top30 {
    background: #eaf6e6;
    color: #2f6b1f;
}

.app-matrix .app-tone-top50 {
    background: #fdf4e3;
    color: #8a5a12;
}

.app-matrix .app-tone-out {
    background: #f7f8fb;
    color: #7b8399;
}

.app-matrix .app-tone-none {
    background: var(--pv-white);
    color: #c3c9d6;
}

.app-matrix-none {
    color: #c3c9d6;
}

.app-matrix-empty {
    margin: 14px 0 0;
    font-size: 13px;
    color: #7b8399;
}

@media (max-width: 991.98px) {
    .app-charts {
        grid-template-columns: minmax(0, 1fr);
        gap: 20px;
    }

    .app-matrix-controls {
        width: 100%;
        align-items: flex-start;
    }

    .app-matrix-search {
        width: 100%;
    }
}

.app-legend-chip.app-tone-top3 {
    background: var(--pv-blue);
}

.app-legend-chip.app-tone-top10 {
    background: #e6ecff;
}

.app-legend-chip.app-tone-top30 {
    background: #eaf6e6;
}

.app-legend-chip.app-tone-top50 {
    background: #fdf4e3;
}

.app-legend-chip.app-tone-none {
    background: var(--pv-white);
    border: 1px solid #dfe3ec;
}

.app-inline-form .app-input-wide {
    flex: 0 0 130px;
    max-width: 130px;
}

.app-competitor-actions {
    display: flex;
    align-items: center;
    gap: 2px;
}

.app-competitor-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 14px;
}

.app-competitor-chip {
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding: 6px 10px;
    border: 1px solid var(--bs-border-color);
    border-radius: 8px;
    background: #fafbfd;
}

.app-competitor-name {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--pv-navy);
}

.app-competitor-meta {
    font-size: 11px;
    color: #7b8399;
}

.app-matrix-wrap-compact {
    max-height: 420px;
}

.app-head-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 8px;
}

.app-share {
    position: relative;
}

.app-share > summary {
    list-style: none;
    cursor: pointer;
}

.app-share > summary::-webkit-details-marker {
    display: none;
}

.app-share-panel {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    z-index: 20;
    width: 320px;
    padding: 12px;
    background: var(--pv-white);
    border: 1px solid var(--bs-border-color);
    border-radius: 10px;
    box-shadow: 0 12px 24px rgba(22, 33, 74, 0.12);
}

.app-copy-row {
    display: flex;
    gap: 6px;
}

@media (max-width: 767.98px) {
    .app-head-actions {
        width: 100%;
    }

    .app-share-panel {
        left: 0;
        right: auto;
        width: min(320px, calc(100vw - 40px));
    }
}
