/* Partner insights — the Results tab's alerts, health cards, chart, funnel,
   rescans and email settings (partner-insights.js). Layered on portal.css and
   built from the same tokens (--primary-color, --border, --text-light) so it
   reads as the same product. Status colours (warn / danger) are reserved for
   coupon budgets and always come with an icon and words, never colour alone. */

/* ── Low-coupon alerts ─────────────────────────────────────────────── */

#partner-alerts:empty,
#results-alerts:empty { display: none; }

#partner-alerts,
#results-alerts { margin-bottom: 1.25rem; }

.coupon-alert {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem 1rem;
    padding: 0.9rem 1.1rem;
    border-radius: 10px;
    border: 1px solid #fcd34d;
    border-left: 5px solid #d97706;
    background: #fffbeb;
    margin-bottom: 0.6rem;
}

.coupon-alert.is-out {
    border-color: #fca5a5;
    border-left-color: #dc2626;
    background: #fef2f2;
}

.coupon-alert-icon { font-size: 1.3rem; line-height: 1; }

.coupon-alert-body {
    flex: 1 1 260px;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    font-size: 0.9rem;
}

.coupon-alert-body strong { font-size: 0.98rem; }

.coupon-alert-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.coupon-alert-actions a.btn-sm,
.health-card a.btn-sm { text-decoration: none; display: inline-block; }

/* ── At a glance ───────────────────────────────────────────────────── */

.insights-box {
    border: 1px solid var(--border);
    border-left: 4px solid var(--primary-color);
    border-radius: 10px;
    background: var(--background-alt, #f9fafb);
    padding: 0.9rem 1.1rem 0.6rem;
    margin-bottom: 1.5rem;
}

.insights-list {
    margin: 0;
    padding-left: 1.1rem;
    font-size: 0.92rem;
}

.insights-list li { margin-bottom: 0.35rem; }

.insights-list.compact { font-size: 0.85rem; margin-top: 0.6rem; }

/* Trend arrows ride beside a number. Words-plus-arrow, so the direction is
   never carried by colour alone. */
.trend {
    display: inline-block;
    margin-left: 0.4rem;
    font-size: 0.75rem;
    font-weight: 700;
    vertical-align: middle;
    font-variant-numeric: tabular-nums;
}
.trend-up { color: #047857; }
.trend-down { color: #b91c1c; }
.trend-flat { color: var(--text-light); }

.stat .trend { display: block; margin: 0.15rem 0 0; }

/* ── Campaign health ───────────────────────────────────────────────── */

.health-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1rem;
    margin-bottom: 1.75rem;
}

.health-card {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem 1.1rem;
    background: var(--background);
    min-width: 0;
}

.health-card.is-low { border-color: #fcd34d; }
.health-card.is-out { border-color: #fca5a5; }

.health-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.health-head h4 {
    margin: 0;
    font-size: 1rem;
    overflow-wrap: anywhere;
}

.budget { margin-bottom: 0.85rem; }

.budget-head {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0.25rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.3rem;
}

.budget-sub {
    font-weight: 400;
    color: var(--text-light);
    font-size: 0.8rem;
    font-variant-numeric: tabular-nums;
}

.budget-track {
    height: 10px;
    border-radius: 5px;
    background: var(--background-alt, #eef2f7);
    border: 1px solid var(--border);
    overflow: hidden;
}

.budget-fill {
    height: 100%;
    border-radius: 5px;
    background: var(--primary-color);
}
.budget-fill.budget-low { background: #d97706; }
.budget-fill.budget-exhausted { background: #dc2626; }

.budget-line {
    font-size: 0.85rem;
    color: var(--text-light);
    margin: 0 0 0.85rem;
}

.mini-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 0.5rem 0.75rem;
}

.mini-stat {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.mini-value {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-dark);
    font-variant-numeric: tabular-nums;
    line-height: 1.25;
}

.mini-label {
    font-size: 0.72rem;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.funnel-lifetime { margin: 0.9rem 0 0.4rem; }

/* ── Daily chart ───────────────────────────────────────────────────── */

.insights-section { margin-bottom: 1.75rem; }

.insights-section-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem 1rem;
}

.chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 1rem;
    font-size: 0.8rem;
    color: var(--text-dark);
    margin-bottom: 0.6rem;
}

.legend-item { display: inline-flex; align-items: center; gap: 0.4rem; }

.legend-key {
    display: inline-block;
    width: 16px;
    height: 0;
    border-top: 2px solid;
}
.legend-key.legend-scans { height: 10px; width: 10px; border: 0; border-radius: 2px; }
.legend-key.legend-redeemed { border-top-style: dashed; }

.trend-chart {
    position: relative;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.5rem 0.25rem 0.25rem;
    background: var(--background);
}

.trend-chart svg { display: block; overflow: visible; }

.chart-grid { stroke: #eef0f3; stroke-width: 1; }
.chart-axis { stroke: #d1d5db; stroke-width: 1; }
.chart-label { fill: var(--text-light); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart-crosshair { stroke: #9ca3af; stroke-width: 1; }
.chart-hit { cursor: crosshair; outline: none; }
.chart-hit:focus-visible { stroke: var(--primary-color); stroke-width: 2; }

.chart-tip {
    position: absolute;
    top: 0.5rem;
    min-width: 150px;
    padding: 0.5rem 0.65rem;
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
    font-size: 0.8rem;
    pointer-events: none;
}

.chart-tip-date { color: var(--text-light); margin-bottom: 0.25rem; }

.chart-tip-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-variant-numeric: tabular-nums;
}

.chart-tip-row strong { min-width: 1.75rem; }
.chart-tip-row span { white-space: nowrap; }
.chart-tip-row span:last-child { color: var(--text-light); }

.chart-tip-key {
    display: inline-block;
    width: 12px;
    border-top: 2px solid;
}

.chart-table-toggle { margin-top: 0.5rem; font-size: 0.85rem; }
.chart-table-toggle summary { cursor: pointer; color: var(--text-light); }
.chart-table-toggle .table-scroll { max-height: 320px; overflow-y: auto; margin-top: 0.5rem; }

/* ── Activity feed and ducks ───────────────────────────────────────── */

.activity-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 0.5rem;
    background: #2563eb;
    vertical-align: middle;
}
.activity-claim .activity-dot { background: #d97706; }
.activity-redeemed .activity-dot { background: #1baf7a; border-radius: 1px; }

.duck-tools {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 0.75rem;
    margin-bottom: 0.6rem;
}

.check-inline {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    cursor: pointer;
}

.check-inline input { width: auto; margin: 0; }

.duck-row .duck-meta {
    flex-shrink: 1;
    text-align: right;
}

.duck-dormant {
    margin-left: 0.4rem;
    padding: 0 0.4rem;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-radius: 999px;
    background: #fef3c7;
    color: #92400e;
}

/* ── Email settings ────────────────────────────────────────────────── */

.notify-box {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem 1.1rem;
    margin-top: 1.75rem;
    background: var(--background-alt, #f9fafb);
}

.notify-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem 0.75rem;
    margin-bottom: 0.6rem;
    font-size: 0.9rem;
}

.notify-row select { max-width: 100%; }

.notify-box .row-actions { margin-top: 0.75rem; }

@media (max-width: 600px) {
    .duck-row { flex-direction: column; align-items: flex-start; }
    .duck-row .duck-meta { text-align: left; }
    .health-list { grid-template-columns: 1fr; }
    .coupon-alert-actions { width: 100%; }
}
