/* Insights (reports, builder, exports, approvals), admin settings, dashboard extras and top-bar widgets. */

/* ---- KPI tiles ---- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); gap: 0.75rem; }
.kpi-grid .tile { padding: 0.8rem 1rem; }
.kpi-grid .tile-value { font-size: 1.35rem; }
.kpi-grid .tile-good .tile-value { color: #15803d; }
.kpi-grid .tile-bad .tile-value { color: #b91c1c; }

/* ---- Filter bar / cards ---- */
.adm-filters { display: flex; flex-wrap: wrap; gap: 0.6rem 0.9rem; align-items: flex-end; background: #fff; border: 1px solid #e3e6ea; border-radius: 8px; padding: 0.75rem 1rem; }
.adm-filters .form-label { font-size: 0.78rem; color: #6c757d; margin-bottom: 0.15rem; }
.adm-filters .adm-field { width: 165px; }
.adm-filters .adm-field-wide { width: 240px; }
.adm-card { background: #fff; border: 1px solid #e3e6ea; border-radius: 8px; padding: 1rem 1.25rem; }
.adm-card h2 { font-size: 1rem; font-weight: 600; color: var(--tp-navy, #0B1A3A); margin-bottom: 0.6rem; }
.adm-tabs .dxbl-tabs-content, .adm-tabs > .dxbl-tabs-content-panel { padding-top: 0.75rem; }
.adm-section-head { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; justify-content: space-between; margin: 0.75rem 0; }
.adm-section-head h2 { font-size: 1rem; font-weight: 600; color: var(--tp-navy, #0B1A3A); margin: 0; }
.adm-grid { background: #fff; }
.adm-hint { background: #eef3fd; border: 1px solid #c9d8f8; border-radius: 6px; padding: 0.55rem 0.75rem; font-size: 0.85rem; color: #1e3a6e; }
.adm-noperm { display: flex; gap: 0.9rem; align-items: center; background: #fff; border: 1px solid #e3e6ea; border-left: 4px solid #f59e0b; border-radius: 8px; padding: 1rem 1.25rem; }
.adm-noperm-icon { font-size: 1.6rem; line-height: 1; }

/* ---- Funnel ---- */
.funnel { display: flex; flex-direction: column; gap: 0.35rem; align-items: center; }
.funnel-stage { color: #fff; border-radius: 6px; padding: 0.45rem 0.75rem; display: flex; justify-content: space-between; gap: 0.75rem; min-width: 220px; font-size: 0.88rem; transition: width .3s; }
.funnel-stage .fs-name { font-weight: 600; }
.funnel-stage .fs-val { white-space: nowrap; opacity: 0.92; }

/* ---- AR aging ---- */
.aging-bucket { font-weight: 600; color: var(--tp-navy, #0B1A3A); }

/* ---- Report builder ---- */
.rb-layout { display: grid; grid-template-columns: minmax(300px, 380px) 1fr; gap: 1rem; align-items: start; }
.rb-panel { background: #fff; border: 1px solid #e3e6ea; border-radius: 8px; padding: 0.9rem 1rem; }
.rb-panel + .rb-panel { margin-top: 0.75rem; }
.rb-panel h2 { font-size: 0.82rem; font-weight: 700; color: #6c757d; text-transform: uppercase; letter-spacing: .03em; margin-bottom: 0.5rem; }
.rb-row { display: flex; gap: 0.35rem; align-items: center; margin-bottom: 0.35rem; }
.rb-row > .rb-grow { flex: 1 1 auto; min-width: 0; }
.rb-row .form-select, .rb-row .form-control { font-size: 0.85rem; }
.rb-saved { max-height: 260px; overflow-y: auto; }
.rb-saved .list-group-item { font-size: 0.88rem; padding: 0.4rem 0.6rem; }
.rb-saved .active-report { background: #eef3fd; }
.rb-totals td { font-weight: 700; background: #f8f9fb; }

/* ---- Permissions matrix ---- */
.perm-wrap { overflow-x: auto; background: #fff; border: 1px solid #e3e6ea; border-radius: 8px; }
.perm-table { margin: 0; min-width: 640px; }
.perm-table th { font-size: 0.8rem; color: #6c757d; font-weight: 600; white-space: nowrap; text-align: center; background: #f8f9fb; position: sticky; top: 0; }
.perm-table th:first-child { text-align: left; }
.perm-table td { vertical-align: middle; }
.perm-table td.perm-cell { text-align: center; width: 120px; }
.perm-table .perm-group td { background: #eef3fd; font-weight: 600; color: var(--tp-navy, #0B1A3A); font-size: 0.85rem; }
.perm-table input[type=checkbox] { width: 1.1rem; height: 1.1rem; cursor: pointer; }
.perm-table input[type=checkbox]:disabled { cursor: not-allowed; }
.perm-key { font-size: 0.72rem; color: #8a939c; font-family: ui-monospace, Consolas, monospace; }
.perm-dirty { color: #b45309; font-size: 0.72rem; display: block; }

/* ---- Audit ---- */
.audit-changes { font-size: 0.85rem; margin: 0; }
.audit-changes th { font-size: 0.75rem; color: #6c757d; }
.audit-old { color: #b91c1c; text-decoration: line-through; word-break: break-word; }
.audit-new { color: #15803d; word-break: break-word; }
.audit-action { font-size: 0.75rem; }

/* ---- Exports ---- */
.export-targets { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 0.6rem; }
.export-target { border: 1px solid #dfe3e8; border-radius: 8px; padding: 0.7rem 0.85rem; background: #fff; cursor: pointer; text-align: left; font: inherit; width: 100%; }
.export-target:hover { border-color: var(--tp-blue, #1A5CE6); }
.export-target.selected { border-color: var(--tp-blue, #1A5CE6); box-shadow: inset 0 0 0 1px var(--tp-blue, #1A5CE6); background: #f5f8ff; }
.export-target .et-name { font-weight: 600; color: var(--tp-navy, #0B1A3A); }
.howto ol { padding-left: 1.2rem; margin-bottom: 0; }
.howto li { margin-bottom: 0.25rem; font-size: 0.88rem; }

/* ---- Approvals ---- */
.approval-card { background: #fff; border: 1px solid #e3e6ea; border-left: 4px solid #f59e0b; border-radius: 8px; padding: 0.8rem 1rem; }
.approval-card.decided { border-left-color: #adb5bd; }
.approval-card + .approval-card { margin-top: 0.6rem; }
.approval-amount { font-size: 1.15rem; font-weight: 700; color: var(--tp-navy, #0B1A3A); }

/* ---- Companies ---- */
.company-item { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; padding: 0.5rem 0; border-bottom: 1px solid #eef0f2; }
.company-item:last-child { border-bottom: 0; }

/* ---- Top bar: company switcher + approvals bell ---- */
.tb-company { max-width: 230px; }
.tb-company select { font-size: 0.85rem; padding-top: 0.2rem; padding-bottom: 0.2rem; }
.tb-bell { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 50%; color: var(--tp-navy, #0B1A3A); text-decoration: none; }
.tb-bell:hover { background: #eef3fd; color: var(--tp-blue, #1A5CE6); }
.tb-bell svg { width: 19px; height: 19px; }
.tb-bell-count { position: absolute; top: -2px; right: -4px; background: #dc3545; color: #fff; border-radius: 999px; font-size: 0.66rem; font-weight: 700; min-width: 17px; height: 17px; line-height: 17px; text-align: center; padding: 0 4px; }

/* ---- Dashboard extras ---- */
.dash-wo-list { list-style: none; padding: 0; margin: 0; }
.dash-wo-list li { padding: 0.4rem 0; border-bottom: 1px solid #eef0f2; font-size: 0.88rem; }
.dash-wo-list li:last-child { border-bottom: 0; }

@media (max-width: 991.98px) {
    .rb-layout { grid-template-columns: 1fr; }
}

@media (max-width: 576px) {
    .adm-filters .adm-field, .adm-filters .adm-field-wide { width: 100%; }
    .funnel-stage { min-width: 0; width: 100% !important; }
    .tb-company { max-width: 140px; }
}
