/**
 * KPI widget layout composition (feature 017).
 * Layout only: colours, badges and controls come from the design-system kit.
 */

[x-cloak] {
    display: none !important;
}

.t2-kpi-widget__groups {
    display: flex;
    flex-direction: column;
    gap: var(--td-space-4);
    padding: var(--td-space-3);
}

.t2-kpi-group__title {
    margin: 0 0 var(--td-space-2);
    color: var(--td-color-fg-muted);
    font-family: var(--td-font-heading);
    font-size: var(--td-text-sm);
    font-weight: var(--td-weight-semibold);
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.t2-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
    gap: var(--td-space-2);
}

.t2-kpi-card {
    display: flex;
    flex-direction: column;
    gap: var(--td-space-1);
    min-width: 0;
    padding: var(--td-space-3);
    border: 1px solid var(--td-color-border);
    border-radius: var(--td-radius-md);
    background-color: var(--td-color-surface);
    color: var(--td-color-fg);
    text-align: left;
}

.t2-kpi-card--interactive {
    cursor: pointer;
}

.t2-kpi-card--interactive:hover,
.t2-kpi-card--interactive:focus-visible {
    border-color: var(--td-color-border-strong);
    background-color: var(--td-color-surface-hover);
    outline: none;
}

.t2-kpi-card__label {
    color: var(--td-color-fg-muted);
    font-size: var(--td-text-xs);
    line-height: var(--td-leading-tight);
    overflow-wrap: anywhere;
}

.t2-kpi-card__channel {
    color: var(--td-color-primary-fg);
    font-weight: var(--td-weight-medium);
}

.t2-kpi-card__value {
    color: var(--td-color-fg);
    font-size: var(--td-text-lg);
    font-weight: var(--td-weight-semibold);
    line-height: var(--td-leading-tight);
    overflow-wrap: anywhere;
}

.t2-kpi-card__meta {
    color: var(--td-color-fg-dim);
    font-size: var(--td-text-xs);
}

.t2-kpi-history__chart {
    width: 100%;
    min-height: 14rem;
    margin: var(--td-space-3) 0;
}

.t2-kpi-history__chart svg {
    display: block;
    width: 100%;
    height: auto;
}

.t2-kpi-history__chart .t2-kpi-line {
    fill: none;
    stroke: var(--td-color-primary);
    stroke-width: 2;
}

.t2-kpi-history__chart .t2-kpi-state--success {
    fill: var(--td-color-success);
}

.t2-kpi-history__chart .t2-kpi-state--danger {
    fill: var(--td-color-error);
}

.t2-kpi-history__chart .t2-kpi-state--info {
    fill: var(--td-color-info);
}

.t2-kpi-history__chart .t2-kpi-state--warning {
    fill: var(--td-color-warning);
}

.t2-kpi-history__chart .t2-kpi-state--neutral {
    fill: var(--td-color-fg-muted);
}

.t2-kpi-history__chart .t2-kpi-axis text {
    fill: var(--td-color-fg-muted);
    font-family: var(--td-font-body);
    font-size: var(--td-text-xs);
}

.t2-kpi-history__chart .t2-kpi-axis .domain,
.t2-kpi-history__chart .t2-kpi-axis .tick line {
    stroke: var(--td-color-border);
}

.t2-kpi-history__table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--td-text-sm);
}

.t2-kpi-history__table th,
.t2-kpi-history__table td {
    padding: var(--td-space-1) var(--td-space-2);
    border-bottom: 1px solid var(--td-color-border);
    text-align: left;
}

.t2-kpi-history__table th {
    color: var(--td-color-fg-muted);
    font-weight: var(--td-weight-medium);
}
