/**
 * Общий каркас внутренних страниц (как главная): контрастные карточки,
 * чёткая типографика, те же акценты teal / indigo.
 * Подключать после corp-theme.css. На <body> добавьте class="page-app".
 */

body.page-app {
    font-size: 1.06rem;
    line-height: 1.58;
    background: linear-gradient(
            165deg,
            var(--corp-page-from, #9fb0c4) 0%,
            var(--corp-page-mid, #b4c2d4) 50%,
            var(--corp-page-to, #cad6e4) 100%
        )
        !important;
    background-color: var(--corp-bg, #b4c2d4) !important;
    color: var(--corp-text, #0f172a) !important;
}

body.page-app .container {
    max-width: 1400px;
    margin: 0 auto;
}

/* Шапка */
body.page-app .header {
    background: var(--corp-surface, #ffffff);
    border: 1px solid var(--corp-border, #6b7c90);
    border-top: 4px solid var(--corp-teal, #0d9488);
    border-radius: var(--corp-radius, 14px);
    box-shadow: var(--corp-shadow, 0 14px 44px rgba(15, 23, 42, 0.16));
    color: var(--corp-text, #0f172a);
}

body.page-app .header h1 {
    color: var(--corp-text, #0f172a);
    font-size: clamp(1.4rem, 2.2vw, 1.9rem);
    font-weight: 700;
    letter-spacing: -0.02em;
}

/* Назад */
body.page-app a.back-btn,
body.page-app .back-btn {
    background: var(--corp-surface-2, #e8eef5);
    border: 1px solid var(--corp-border, #6b7c90);
    color: var(--corp-text, #0f172a);
    font-weight: 600;
    font-size: 0.95rem;
}

body.page-app a.back-btn:hover,
body.page-app .back-btn:hover {
    background: var(--corp-teal-soft, #ccfbf1);
    border-color: var(--corp-teal, #0d9488);
    color: var(--corp-teal-dark, #0f766e);
}

/* Вкладки (график, MAX-стат, LDAP nav) */
body.page-app .tabs,
body.page-app .period-tabs,
body.page-app .sub-tabs {
    background: var(--corp-surface-muted, #d8e2ed);
    border: 1px solid var(--corp-border-strong, #556575);
    border-radius: 14px;
}

body.page-app .tab-btn,
body.page-app .period-tab,
body.page-app .sub-tab-btn,
body.page-app .nav-links a {
    color: var(--corp-text-muted, #475569);
    font-weight: 600;
    font-size: 0.95rem;
}

body.page-app .tab-btn:hover,
body.page-app .period-tab:hover,
body.page-app .sub-tab-btn:hover {
    background: rgba(255, 255, 255, 0.75);
    color: var(--corp-text, #0f172a);
}

body.page-app .tab-btn.active,
body.page-app .period-tab.active,
body.page-app .sub-tab-btn.active {
    background: var(--corp-teal-dark, #0f766e) !important;
    color: #ffffff !important;
    border-color: transparent;
    box-shadow: 0 2px 10px rgba(15, 118, 110, 0.35);
}

body.page-app .tab-panel,
body.page-app .tab-panel.active {
    background: var(--corp-surface, #ffffff);
    border: 1px solid var(--corp-border, #6b7c90);
    border-radius: var(--corp-radius, 14px);
    box-shadow: var(--corp-shadow, 0 14px 44px rgba(15, 23, 42, 0.12));
}

body.page-app .tab-content.active {
    background: var(--corp-surface, #ffffff);
    border: 1px solid var(--corp-border, #6b7c90);
    border-radius: 18px;
    box-shadow: var(--corp-shadow, 0 14px 44px rgba(15, 23, 42, 0.12));
}

body.page-app .placeholder {
    color: var(--corp-text-muted, #475569);
    font-size: 1rem;
    line-height: 1.55;
}

/* LDAP nav */
body.page-app .nav-links a:hover {
    background: var(--corp-teal-soft, #ccfbf1);
    color: var(--corp-teal-dark, #0f766e);
}

/* Таблицы по умолчанию */
body.page-app table {
    border: 1px solid var(--corp-border, #6b7c90);
    background: var(--corp-surface, #ffffff);
}

body.page-app th {
    background: var(--corp-surface-muted, #d8e2ed);
    color: var(--corp-text-secondary, #1e293b);
    font-weight: 700;
    font-size: 0.82rem;
}

body.page-app td {
    color: var(--corp-text, #0f172a);
    border-color: var(--corp-border, #6b7c90);
}

/* Вход: только типографика контейнера (фон задаётся в login.html) */
body.page-app-login {
    font-size: 1.05rem;
    line-height: 1.58;
}

/* ——— Мобильная адаптация внутренних страниц (десктоп не трогаем) ——— */
@media (max-width: 900px) {
    body.page-app {
        padding: 12px;
        overflow-x: hidden;
    }

    body.page-app .container {
        max-width: 100%;
    }

    body.page-app .header {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    body.page-app .header h1 {
        font-size: clamp(1.2rem, 4.5vw, 1.55rem);
        line-height: 1.25;
    }

    body.page-app .nav-links {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }

    body.page-app .nav-links a {
        flex: 1 1 auto;
        text-align: center;
        padding: 10px 12px;
    }

    body.page-app .tabs,
    body.page-app .period-tabs,
    body.page-app .sub-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
    }

    body.page-app .tab-btn,
    body.page-app .period-tab,
    body.page-app .sub-tab-btn {
        flex: 0 0 auto;
        white-space: nowrap;
        padding: 8px 12px;
        font-size: 0.82rem;
    }

    body.page-app .tab-panel,
    body.page-app .tab-content.active {
        padding: 14px;
        overflow-x: auto;
    }

    body.page-app table {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* Поле пароля с кнопкой «показать» */
.pwd-field-wrap {
    position: relative;
    display: block;
    width: 100%;
}

.pwd-field-wrap input {
    width: 100%;
    padding-right: 2.75rem !important;
    box-sizing: border-box;
}

.pwd-field-eye {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--corp-text-muted, #64748b);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 0;
}

.pwd-field-eye:hover {
    background: var(--corp-surface-muted, #e2e8f0);
    color: var(--corp-teal-dark, #0f766e);
}

.pwd-field-eye.is-visible {
    color: var(--corp-teal-dark, #0f766e);
}

body.page-app-login .form-group .pwd-field-wrap input,
.login-form .pwd-field-wrap input {
    padding-right: 2.75rem !important;
}

@media (max-width: 540px) {
    body.page-app {
        padding: 10px;
    }

    body.page-app a.back-btn,
    body.page-app .back-btn {
        width: 100%;
        justify-content: center;
        box-sizing: border-box;
    }

    body.page-app .header h1 {
        font-size: 1.2rem;
    }
}

.org-unit-switcher {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 140px;
}
.org-unit-switcher__label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--corp-text-muted, #475569);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.org-unit-switcher__select {
    padding: 8px 10px;
    border-radius: 10px;
    border: 1px solid var(--corp-border, #6b7c90);
    font-size: 0.9rem;
    font-weight: 600;
    background: var(--corp-surface, #fff);
}
.org-page-subtitle {
    font-size: 0.85rem;
    color: var(--corp-text-muted, #475569);
    font-weight: 600;
    margin-top: 4px;
}

.responsible-exclude-modal {
    position: fixed;
    inset: 0;
    z-index: 12000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.responsible-exclude-modal[hidden] {
    display: none !important;
}
.responsible-exclude-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
}
.responsible-exclude-modal__panel {
    position: relative;
    z-index: 1;
    width: min(520px, 100%);
    max-height: 90vh;
    overflow: auto;
    background: #fff;
    border-radius: 12px;
    padding: 18px 20px;
    box-shadow: 0 12px 40px rgba(15, 23, 42, 0.2);
}

.cc-admin-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 12000;
    align-items: flex-start;
    justify-content: center;
    padding: 24px 16px;
    overflow-y: auto;
}
.cc-admin-modal__backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 40, 60, 0.45);
}
.cc-admin-modal-box {
    position: relative;
    z-index: 1;
    background: #f7fcfe;
    border: 1px solid #bdd7eb;
    border-radius: 16px;
    padding: 20px 24px;
    max-width: 760px;
    width: 100%;
    margin: auto;
}
.cc-admin-modal-box h2 {
    margin: 0 0 12px;
    color: #286090;
    font-size: 1.15rem;
}
.cc-admin-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 14px;
    justify-content: flex-end;
}

/* Очередь парсеров (админ) */
.pq-modal {
    display: flex;
    position: fixed;
    inset: 0;
    z-index: 12050;
    align-items: flex-start;
    justify-content: center;
    padding: 20px 12px;
    overflow-y: auto;
}
.pq-modal[hidden] {
    display: none !important;
}
.pq-modal__backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 40, 60, 0.45);
}
.pq-modal__panel {
    position: relative;
    z-index: 1;
    background: #f7fcfe;
    border: 1px solid #bdd7eb;
    border-radius: 16px;
    padding: 18px 20px 14px;
    max-width: 960px;
    width: 100%;
    margin: auto;
    max-height: calc(100vh - 40px);
    overflow: auto;
}
.pq-modal__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}
.pq-modal__head h2 {
    margin: 0;
    color: #286090;
    font-size: 1.15rem;
}
.pq-modal__close {
    border: none;
    background: transparent;
    font-size: 1.2rem;
    cursor: pointer;
    color: #475569;
    padding: 4px 8px;
}
.pq-summary {
    font-size: 0.88rem;
    line-height: 1.45;
    margin: 0 0 12px;
}
.pq-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    border-bottom: 1px solid #d5e5f0;
    padding-bottom: 8px;
}
.pq-tab {
    border: 1px solid #bdd7eb;
    background: #fff;
    color: #334155;
    border-radius: 8px;
    padding: 8px 14px;
    cursor: pointer;
    font: inherit;
}
.pq-tab--active {
    background: #286090;
    border-color: #286090;
    color: #fff;
}
.pq-pane {
    display: none;
}
.pq-pane--active {
    display: block;
}
.pq-org {
    border: 1px solid #d5e5f0;
    border-radius: 12px;
    padding: 12px 14px;
    margin-bottom: 12px;
    background: #fff;
}
.pq-org--alert {
    border-color: #f5a623;
    box-shadow: 0 0 0 1px rgba(245, 166, 35, 0.25);
}
.pq-org__head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 10px;
}
.pq-org__head h3 {
    margin: 0;
    font-size: 1rem;
    color: #0f172a;
}
.pq-org__badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.pq-badge {
    display: inline-block;
    font-size: 0.75rem;
    padding: 3px 8px;
    border-radius: 999px;
    font-weight: 600;
}
.pq-badge--ok {
    background: #dcfce7;
    color: #166534;
}
.pq-badge--warn {
    background: #fef3c7;
    color: #92400e;
}
.pq-badge--danger {
    background: #fee2e2;
    color: #991b1b;
}
.pq-badge--info {
    background: #e0f2fe;
    color: #075985;
}
.pq-metrics {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 8px 12px;
    margin-bottom: 10px;
}
.pq-metrics__k {
    display: block;
    font-size: 0.72rem;
    color: #64748b;
}
.pq-metrics__v {
    font-size: 0.92rem;
    font-weight: 600;
    color: #0f172a;
}
.pq-table-wrap {
    overflow-x: auto;
    margin-top: 8px;
}
.pq-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}
.pq-table th,
.pq-table td {
    border-bottom: 1px solid #e2e8f0;
    padding: 6px 8px;
    text-align: left;
    vertical-align: top;
}
.pq-table th {
    color: #475569;
    font-weight: 600;
    background: #f8fafc;
}
.pq-row--error td {
    background: #fff7ed;
}
.pq-error {
    color: #b42318;
    font-size: 0.85rem;
    margin: 6px 0;
}
.pq-empty,
.pq-hint {
    font-size: 0.85rem;
    margin: 6px 0 0;
}
.pq-modal__foot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid #d5e5f0;
}
.pq-org-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 10px;
}
.pq-org-tab {
    border: 1px solid #94a3b8;
    background: #fff;
    color: #334155;
    border-radius: 999px;
    padding: 6px 12px;
    cursor: pointer;
    font: inherit;
    font-size: 0.85rem;
}
.pq-org-tab--active {
    background: #0f766e;
    border-color: #0f766e;
    color: #fff;
}
.pq-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-bottom: 12px;
    padding: 10px 12px;
    background: #f1f5f9;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
}
.pq-actions-hint {
    font-size: 0.78rem;
    flex: 1 1 200px;
}
.pq-row-retry {
    font-size: 0.75rem;
    padding: 3px 8px;
}
#btnClientChartAdmin {
    display: none;
}

.ai-report-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}
.ai-report-filter-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.ai-report-filter {
    border: 1px solid #cbd5e1;
    background: #fff;
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 0.85rem;
    cursor: pointer;
}
.ai-report-filter.active {
    background: #0f766e;
    border-color: #0f766e;
    color: #fff;
}
.ai-report-layout {
    display: grid;
    grid-template-columns: minmax(220px, 320px) 1fr;
    gap: 16px;
    align-items: start;
}
@media (max-width: 900px) {
    .ai-report-layout {
        grid-template-columns: 1fr;
    }
}
.ai-report-col-list,
.ai-report-col-detail {
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    background: #fff;
    padding: 12px;
    max-height: 72vh;
    overflow: auto;
}
.ai-report-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.ai-report-list-item {
    text-align: left;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: #f8fafc;
    padding: 10px 12px;
    cursor: pointer;
}
.ai-report-list-item--active {
    border-color: #0f766e;
    background: #ecfdf5;
}
.ai-report-list-title {
    display: block;
    font-size: 0.88rem;
    font-weight: 600;
    margin-bottom: 4px;
}
.ai-report-list-meta {
    display: block;
    font-size: 0.75rem;
    color: #64748b;
}
.ai-report-detail h2,
.ai-report-detail h3,
.ai-report-detail h4 {
    margin: 0.6em 0 0.35em;
}
.ai-report-body {
    font-size: 0.92rem;
    line-height: 1.55;
}
.ai-report-md-list {
    margin: 0.4em 0 0.8em 1.2em;
}

.daily-ai-embed {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 2px solid rgba(15, 118, 110, 0.25);
}
.daily-ai-embed-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
}
.daily-ai-embed-head h3 {
    margin: 0;
    font-size: 1.1rem;
}
.ai-report-charts-host {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px dashed #cbd5e1;
    width: 100%;
}
.ai-charts-wrap {
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 100%;
}
.ai-chart-block {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 14px;
    width: 100%;
    box-sizing: border-box;
}
.ai-chart-block--daily {
    max-width: none;
}
.ai-chart-block h4 {
    margin: 0 0 8px;
    font-size: 0.95rem;
}
.ai-chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin: 8px 0 12px;
    font-size: 0.78rem;
    color: #64748b;
}
.ai-chart-legend-item i {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 2px;
    margin-right: 4px;
    vertical-align: middle;
}
.ai-daily-bars {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    min-height: 160px;
    overflow-x: auto;
    padding-bottom: 4px;
}
.ai-daily-bar-group {
    position: relative;
    flex: 0 0 28px;
    height: 140px;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.ai-daily-bar-group.ai-bar-peak {
    outline: 2px solid #f59e0b;
    border-radius: 4px;
}
.ai-daily-bar-group.ai-bar-dip {
    outline: 2px solid #ef4444;
    border-radius: 4px;
}
.ai-daily-bar-pair {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 120px;
    width: 100%;
    justify-content: center;
}
.ai-daily-bar {
    width: 10px;
    border-radius: 3px 3px 0 0;
    min-height: 2px;
}
.ai-daily-bar--new { background: #6366f1; }
.ai-daily-bar--done { background: #10b981; }
.ai-daily-avg-lines {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 20px;
    height: 120px;
    pointer-events: none;
}
.ai-daily-avg {
    position: absolute;
    left: 2px;
    right: 2px;
    height: 0;
    border-top: 1px dashed #94a3b8;
}
.ai-daily-bar-label {
    font-size: 0.65rem;
    color: #64748b;
    margin-top: 4px;
    white-space: nowrap;
}
.ai-sla-chart {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.ai-sla-row {
    display: grid;
    grid-template-columns: minmax(120px, 180px) 1fr auto;
    gap: 8px;
    align-items: center;
    font-size: 0.82rem;
}
.ai-sla-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ai-sla-track {
    position: relative;
    height: 14px;
    background: #e2e8f0;
    border-radius: 7px;
    overflow: visible;
}
.ai-sla-fill {
    height: 100%;
    border-radius: 7px;
    min-width: 2px;
}
.ai-sla-marker {
    position: absolute;
    top: -3px;
    width: 2px;
    height: 20px;
    transform: translateX(-1px);
}
.ai-sla-marker--team { background: #f59e0b; }
.ai-sla-marker--norm { background: #ef4444; }
.ai-sla-val {
    font-size: 0.75rem;
    color: #64748b;
    white-space: nowrap;
}
.ai-charts-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
@media (max-width: 768px) {
    .ai-charts-row { grid-template-columns: 1fr; }
    .ai-sla-row { grid-template-columns: 1fr; }
}
.ai-hour-bars {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    min-height: 100px;
    overflow-x: auto;
}
.ai-hour-bar {
    position: relative;
    flex: 0 0 14px;
    height: 90px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
}
.ai-hour-fill {
    width: 10px;
    border-radius: 2px 2px 0 0;
    min-height: 2px;
}
.ai-hour-baseline {
    position: absolute;
    left: 1px;
    right: 1px;
    height: 0;
    border-top: 1px dashed #94a3b8;
}
.ai-hour-label {
    font-size: 0.6rem;
    color: #94a3b8;
    margin-top: 2px;
}
.ai-daily-bar-values {
    display: flex;
    justify-content: center;
    gap: 4px;
    font-size: 0.68rem;
    font-weight: 700;
    margin-bottom: 2px;
    min-height: 1.1rem;
}
.ai-daily-val--new { color: #6366f1; }
.ai-daily-val--done { color: #10b981; }
.ai-daily-bar-pcts {
    display: flex;
    justify-content: center;
    gap: 4px;
    font-size: 0.58rem;
    color: #64748b;
    margin-top: 2px;
}
.ai-hour-val {
    font-size: 0.62rem;
    font-weight: 700;
    color: #334155;
    min-height: 0.9rem;
}
.ai-hour-pct {
    font-size: 0.55rem;
    color: #64748b;
}
.ai-chart-table-wrap {
    width: 100%;
    overflow-x: auto;
    margin-top: 12px;
}
.ai-chart-table {
    width: 100%;
    min-width: 720px;
    border-collapse: collapse;
    font-size: 0.78rem;
    table-layout: auto;
}
.ai-chart-table th,
.ai-chart-table td {
    border: 1px solid #e2e8f0;
    padding: 6px 8px;
    text-align: left;
}
.ai-chart-table th {
    background: #f1f5f9;
    font-weight: 600;
}
.ai-chart-flag {
    color: #b45309;
    font-size: 0.72rem;
}
.ai-emp-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 4px;
}
.ai-report-summary {
    background: #ecfdf5;
    border-left: 3px solid #0f766e;
    padding: 8px 12px;
    margin: 0.5em 0;
    border-radius: 0 8px 8px 0;
    font-size: 0.9rem;
}
