/* EWER CMS — ATI data integrity and responsive presentation v9 */
#atiView {
    --ati-indigo: #5b55e8;
    --ati-slate: #1e293b;
    --ati-muted: #64748b;
    --ati-border: rgba(148, 163, 184, .28);
}

#atiView .ati-content-grid {
    align-items: start;
}

#atiView .ati-table-card,
#atiView .ati-charts-column .card {
    border: 1px solid var(--ati-border);
    box-shadow: 0 14px 34px rgba(30, 41, 59, .06);
}

#atiView .ati-table-card .card-header {
    gap: 1rem;
    flex-wrap: wrap;
}

#atiView .ati-table-card .card-header > .flex {
    margin-left: auto;
    flex-wrap: wrap;
}

#atiView .ati-table-card .table-container {
    width: 100%;
    overflow-x: auto !important;
    overflow-y: visible !important;
    scrollbar-width: thin;
    scrollbar-color: #b8c2d6 transparent;
}

#atiView .ati-table-card .table-container::-webkit-scrollbar {
    height: 9px;
}

#atiView .ati-table-card .table-container::-webkit-scrollbar-thumb {
    background: #b8c2d6;
    border-radius: 999px;
}

@media (min-width: 901px) {
    #atiView #atiTable {
        width: 100% !important;
        min-width: 980px !important;
        table-layout: fixed !important;
    }

    #atiView #atiTable th,
    #atiView #atiTable td {
        overflow: visible !important;
        text-overflow: clip !important;
        white-space: normal !important;
        overflow-wrap: break-word !important;
        word-break: normal !important;
        vertical-align: middle;
        line-height: 1.45;
    }

    #atiView #atiTable th {
        font-size: .72rem !important;
        letter-spacing: .035em !important;
        word-break: keep-all !important;
    }

    #atiView #atiTable th:nth-child(1), #atiView #atiTable td:nth-child(1) { width: 13% !important; }
    #atiView #atiTable th:nth-child(2), #atiView #atiTable td:nth-child(2) { width: 15% !important; }
    #atiView #atiTable th:nth-child(3), #atiView #atiTable td:nth-child(3) { width: 14% !important; }
    #atiView #atiTable th:nth-child(4), #atiView #atiTable td:nth-child(4) { width: 10% !important; }
    #atiView #atiTable th:nth-child(5), #atiView #atiTable td:nth-child(5) { width: 11% !important; }
    #atiView #atiTable th:nth-child(6), #atiView #atiTable td:nth-child(6) { width: 12% !important; }
    #atiView #atiTable th:nth-child(7), #atiView #atiTable td:nth-child(7) { width: 10% !important; }
    #atiView #atiTable th:nth-child(8), #atiView #atiTable td:nth-child(8) { width: 15% !important; }

    #atiView #atiTable .record-id-cell,
    #atiView #atiTable .record-id-cell strong {
        overflow-wrap: normal !important;
        word-break: normal !important;
        hyphens: none !important;
    }

    #atiView #atiTable .table-actions {
        display: flex !important;
        flex-direction: column;
        gap: .45rem !important;
        align-items: stretch;
    }

    #atiView #atiTable .table-actions .btn {
        width: 100%;
        min-width: 0 !important;
        white-space: nowrap !important;
    }
}

#atiView .ati-cell-primary {
    display: block;
    color: var(--ati-slate);
    font-weight: 650;
}

#atiView .ati-cell-wrap {
    display: block;
    color: var(--ati-slate);
}

#atiView .ati-province-chip {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: .28rem .55rem;
    border: 1px solid rgba(99, 102, 241, .18);
    border-radius: 999px;
    background: rgba(99, 102, 241, .08);
    color: #4f46e5;
    font-size: .76rem;
    font-weight: 700;
}

#atiView .ati-date-stack {
    display: flex;
    flex-direction: column;
    gap: .3rem;
}

#atiView .ati-deadline {
    display: inline-flex;
    width: fit-content;
    padding: .22rem .42rem;
    border-radius: 999px;
    font-size: .65rem;
    font-weight: 750;
    line-height: 1.15;
    white-space: nowrap;
}

#atiView .ati-deadline-overdue {
    color: #b91c1c;
    background: #fee2e2;
}

#atiView .ati-deadline-today {
    color: #b45309;
    background: #fef3c7;
}

#atiView .ati-deadline-soon {
    color: #1d4ed8;
    background: #dbeafe;
}

#atiView .ati-loading-row,
#atiView .ati-empty-row,
#atiView .ati-error-row {
    min-height: 180px;
    padding: 2.4rem 1rem !important;
    text-align: center;
    color: var(--ati-muted);
}

#atiView .ati-loading-row {
    display: table-cell;
}

#atiView .ati-empty-row strong,
#atiView .ati-error-row strong {
    display: block;
    margin-top: .5rem;
    color: var(--ati-slate);
}

#atiView .ati-empty-row span,
#atiView .ati-error-row span {
    display: block;
    margin-top: .3rem;
}

#atiView .ati-inline-loader {
    display: inline-block;
    width: 22px;
    height: 22px;
    margin-right: .55rem;
    border: 3px solid rgba(99, 102, 241, .18);
    border-top-color: var(--ati-indigo);
    border-radius: 50%;
    vertical-align: middle;
    animation: ati-spin .8s linear infinite;
}

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

#atiView .ati-detail-comment {
    padding: .7rem 0;
    border-bottom: 1px solid var(--ati-border);
}

#atiView .ati-detail-comment > div {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    font-size: .78rem;
}

#atiView .ati-detail-comment > div span {
    color: var(--ati-muted);
}

#atiView .ati-detail-comment p {
    margin: .35rem 0 0;
    font-size: .86rem;
}

#atiView .ati-detail-attachment {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .65rem;
    margin-bottom: .55rem;
    border: 1px solid var(--ati-border);
    border-radius: 10px;
    background: var(--bg-main);
}

#atiView .ati-detail-attachment > div {
    display: flex;
    align-items: center;
    gap: .55rem;
    min-width: 0;
}

@media (max-width: 1350px) {
    #atiView .ati-content-grid {
        grid-template-columns: minmax(0, 1fr) !important;
    }

    #atiView .ati-charts-column {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 1rem !important;
    }

    #atiView .ati-table-card {
        width: 100%;
    }
}

@media (max-width: 900px) {
    #atiView .ati-charts-column {
        grid-template-columns: minmax(0, 1fr);
    }

    #atiView #atiTable td {
        overflow: visible !important;
        text-overflow: clip !important;
    }

    #atiView #atiTable .table-actions {
        display: flex !important;
        flex-wrap: wrap !important;
    }
}

@media (max-width: 620px) {
    #atiView .ati-table-card .card-header > .flex,
    #atiView #atiSearch,
    #atiView #filterAtiStatus {
        width: 100% !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    #atiView .ati-inline-loader { animation: none; }
}
