/* Дашборд «Дополнительные объекты» (php/add_obj_dash/add_obj_dash_container.php, js/modules/add_obj_dash.js).
   Все правила ограничены .aod — контейнер можно встраивать на любую страницу. */

.aod {
    --aod-inv: #3b7ddd;
    --aod-des: #20a4a4;
    --aod-paid: #2e9e5b;
    --aod-unpaid: #b8bec6;
    --aod-border: #e3e6ea;
    --aod-muted: #8a939d;
    --aod-bg: #ffffff;
    --aod-soft: #f4f6f9;
    position: relative;
    font-size: 14px;
    color: #212529;
    text-align: left;
}

.aod-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}
.aod-title {
    font-size: 20px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}
.aod-title > i { color: var(--aod-inv); }
.aod-badge {
    font-size: 12px;
    font-weight: 600;
    background: var(--aod-soft);
    border: 1px solid var(--aod-border);
    border-radius: 999px;
    padding: 1px 9px;
    color: #495057;
}
.aod-header-actions { display: flex; gap: 6px; }

/* ---- фильтры ---- */
.aod-filters {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 8px 10px;
    background: var(--aod-bg);
    border: 1px solid var(--aod-border);
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 12px;
}
.aod-field { display: flex; flex-direction: column; min-width: 0; }
.aod-field label {
    font-size: 11px;
    color: var(--aod-muted);
    margin-bottom: 2px;
    text-transform: uppercase;
    letter-spacing: .02em;
}
.aod-field-search { grid-column: span 2; }
.aod-field-actions { justify-content: flex-end; align-items: flex-start; }
.aod-field-actions .btn { padding-left: 0; }

.aod-status {
    font-size: 13px;
    color: #495057;
    margin-bottom: 8px;
}
.aod-status-error { color: #c0392b; }
.aod.aod-loading .aod-kpis,
.aod.aod-loading .aod-stats,
.aod.aod-loading .aod-table-card { opacity: .5; transition: opacity .15s; }

/* ---- KPI ---- */
.aod-kpis {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 10px;
    margin-bottom: 12px;
}
.aod-kpi {
    background: var(--aod-bg);
    border: 1px solid var(--aod-border);
    border-radius: 10px;
    padding: 10px 12px;
}
.aod-kpi-label { font-size: 12px; color: var(--aod-muted); }
.aod-kpi-value { font-size: 24px; font-weight: 600; line-height: 1.25; font-variant-numeric: tabular-nums; }
.aod-kpi-sub { font-size: 12px; color: #6c757d; }
.aod-kpi-good .aod-kpi-value { color: var(--aod-paid); }
.aod-kpi-accent .aod-kpi-value { color: var(--aod-inv); }

/* ---- карточки статистики ---- */
.aod-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 10px;
    margin-bottom: 12px;
}
.aod-card {
    background: var(--aod-bg);
    border: 1px solid var(--aod-border);
    border-radius: 10px;
    padding: 10px 12px;
    min-width: 0;
}
.aod-stats .aod-card { max-height: 300px; overflow-y: auto; }
.aod-card-title {
    font-weight: 600;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.aod-card-title > i { color: var(--aod-muted); }
.aod-muted { color: var(--aod-muted); }
.aod-nowrap { white-space: nowrap; }

/* столбики по месяцам */
.aod-chart {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    height: 180px;
    overflow-x: auto;
    padding-top: 4px;
}
.aod-chart-col {
    flex: 1 0 22px;
    max-width: 48px;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: stretch;
    text-align: center;
}
.aod-chart-val { font-size: 11px; color: #495057; font-variant-numeric: tabular-nums; }
.aod-chart-bar {
    position: relative;
    background: var(--aod-inv);
    border-radius: 3px 3px 0 0;
    overflow: hidden;
}
.aod-chart-des { position: absolute; left: 0; right: 0; top: 0; background: var(--aod-des); }
.aod-chart-paid {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    background: repeating-linear-gradient(135deg, rgba(255,255,255,.55) 0 3px, transparent 3px 6px);
    border-top: 2px solid #fff;
}
.aod-chart-label { font-size: 10px; color: var(--aod-muted); line-height: 1.15; margin-top: 3px; }
.aod-legend { font-size: 11px; color: var(--aod-muted); margin-top: 6px; }
.aod-legend span {
    display: inline-block;
    width: 10px; height: 10px;
    border-radius: 2px;
    margin: 0 3px -1px 8px;
}
.aod-legend span:first-child { margin-left: 0; }
.aod-lg-inv { background: var(--aod-inv); }
.aod-lg-des { background: var(--aod-des); }
.aod-lg-paid { background: repeating-linear-gradient(135deg, #adb5bd 0 2px, #fff 2px 4px); border: 1px solid #adb5bd; }

/* разбивка по исполнителям / МОП */
.aod-breakdown { width: 100%; font-size: 13px; font-variant-numeric: tabular-nums; }
.aod-breakdown th { font-size: 11px; font-weight: 500; color: var(--aod-muted); padding: 0 4px 4px; }
.aod-breakdown td { padding: 3px 4px; border-top: 1px solid var(--aod-soft); vertical-align: middle; }
.aod-breakdown tr[data-aod-expert],
.aod-breakdown tr[data-aod-mop] { cursor: pointer; }
.aod-breakdown tbody tr:hover td { background: var(--aod-soft); }
.aod-bd-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px; }
.aod-bd-bar { position: relative; height: 4px; background: var(--aod-soft); border-radius: 2px; margin-top: 2px; }
.aod-bd-bar span, .aod-bd-bar i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 2px; }
.aod-bd-bar span { background: #b9cff2; }
.aod-bd-bar i { background: var(--aod-paid); }

/* ---- таблица объектов ---- */
.aod-table-card { padding: 0; }
.aod-table { margin: 0; font-size: 13px; }
.aod-table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--aod-soft);
    font-size: 12px;
    font-weight: 600;
    color: #495057;
    white-space: nowrap;
    border-bottom: 1px solid var(--aod-border);
}
.aod-table th[data-aod-sort] { cursor: pointer; user-select: none; }
.aod-table th[data-aod-sort]:hover { color: var(--aod-inv); }
.aod-table th.aod-sorted-asc::after { content: ' ▲'; font-size: 9px; }
.aod-table th.aod-sorted-desc::after { content: ' ▼'; font-size: 9px; }
.aod-table td { vertical-align: top; }
.aod-deal { min-width: 240px; }
.aod-deal a, .aod-child a { text-decoration: none; }
.aod-deal a:hover, .aod-child a:hover { text-decoration: underline; }
.aod-tags { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 3px; }
.aod-tag {
    font-size: 11px;
    line-height: 1.5;
    padding: 0 6px;
    border-radius: 4px;
    background: #e7f0fd;
    color: #2459a8;
    white-space: nowrap;
}
.aod-tag-muted { background: var(--aod-soft); color: #6c757d; }
.aod-tag-ea { background: #fff3cd; color: #8a6d00; }
.aod-tag-frozen { background: #e6f6fb; color: #1b7f9c; }

.aod-pair { display: inline-flex; align-items: baseline; gap: 4px; font-variant-numeric: tabular-nums; }
.aod-pair > span { font-size: 11px; padding: 0 5px; border-radius: 8px; }
.aod-paid { background: #e3f4ea; color: var(--aod-paid); font-weight: 600; }
.aod-unpaid { background: var(--aod-soft); color: var(--aod-muted); }

.aod-children { min-width: 220px; }
.aod-child { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px; margin-bottom: 2px; }
.aod-child-meta { font-size: 11px; color: var(--aod-muted); }

.aod-last-comment {
    font-size: 12px;
    color: #5c636a;
    margin-top: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 380px;
}
.aod-last-comment > i { color: var(--aod-muted); }

.aod-comment-btn {
    position: relative;
    border: 1px solid var(--aod-border);
    background: #fff;
    border-radius: 6px;
    padding: 2px 7px;
    color: var(--aod-muted);
    line-height: 1.4;
}
.aod-comment-btn:hover { color: var(--aod-inv); border-color: var(--aod-inv); }
.aod-comment-btn.aod-has { color: var(--aod-inv); border-color: #b9cff2; background: #f2f7ff; }
.aod-comment-btn > span { font-size: 11px; font-weight: 600; margin-left: 3px; }
.aod-row.aod-open > td { background: #f7faff; border-bottom-color: transparent; }

.aod-empty { padding: 24px; text-align: center; color: var(--aod-muted); }

/* ---- комментарии (раскрывающаяся строка) ---- */
.aod-comments-row > td { background: #f7faff; padding: 0 12px 12px !important; }
.aod-comments {
    background: #fff;
    border: 1px solid #dbe6f7;
    border-radius: 8px;
    padding: 10px 12px;
    max-width: 820px;
}
.aod-comments-list { max-height: 260px; overflow-y: auto; margin-bottom: 8px; }
.aod-comment { padding: 6px 0; border-bottom: 1px solid var(--aod-soft); }
.aod-comment:last-child { border-bottom: 0; }
.aod-comment-head { display: flex; align-items: baseline; gap: 8px; font-size: 12px; }
.aod-comment-head > span { color: var(--aod-muted); }
.aod-comment-text { white-space: pre-wrap; word-break: break-word; }
.aod-comment-del {
    margin-left: auto;
    border: 0;
    background: none;
    color: var(--aod-muted);
    padding: 0 2px;
}
.aod-comment-del:hover { color: #c0392b; }
.aod-comment-form { display: flex; flex-direction: column; gap: 6px; }
.aod-comment-form-row { display: flex; gap: 6px; }
.aod-comment-form-row .aod-author { max-width: 320px; }
.aod-comment-form-row .btn { white-space: nowrap; }
.aod-comment-error { font-size: 12px; color: #c0392b; }

.aod-toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%);
    z-index: 2000;
    background: #212529;
    color: #fff;
    font-size: 13px;
    padding: 8px 14px;
    border-radius: 8px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, .2);
}

@media (max-width: 576px) {
    .aod-title { font-size: 17px; }
    .aod-filters { grid-template-columns: repeat(2, 1fr); }
    .aod-kpis { grid-template-columns: repeat(2, 1fr); }
    .aod-kpi-value { font-size: 20px; }
    .aod-comment-form-row { flex-direction: column; }
    .aod-comment-form-row .aod-author { max-width: none; }
}

/* ---- встраивание в окно из формы «Отчеты» (adaptive_form) ---- */
#adaptive_form .aod { padding-bottom: 8px; }
#adaptive_form .aod .aod-header { justify-content: flex-end; margin-top: -8px; }
#adaptive_form .aod .aod-title { display: none; } /* заголовок показывает само окно */
