/* Production Intelligence Dashboard — Linear / Notion style */
.dash-canvas {
    --dash-bg: #f7f8fa;
    --dash-surface: #ffffff;
    --dash-surface-2: #f1f2f5;
    --dash-border: transparent;
    --dash-muted: #9ca3af;
    --dash-ink: #111827;
    --dash-accent: #111827;
    --dash-green: #059669;
    --dash-yellow: #d97706;
    --dash-red: #dc2626;
    background: var(--dash-bg);
    font-feature-settings: "tnum" 1, "ss01" 1;
}
html[data-theme="dark"] .dash-canvas {
    --dash-bg: #0f1115;
    --dash-surface: #181b22;
    --dash-surface-2: #1e2129;
    --dash-border: transparent;
    --dash-muted: #6b7280;
    --dash-ink: #f3f4f6;
    color-scheme: dark;
}

/* Hero — light floating metrics strip */
.pi-hero {
    background: #ffffff;
    border-radius: 1.25rem;
    padding: 1.75rem 2rem;
    color: var(--dash-ink);
    box-shadow: 0 4px 24px rgb(15 23 42 / 0.04);
    position: relative;
    overflow: hidden;
    border: none;
}
.pi-hero::before { display: none; }
.pi-hero-inner { position: relative; z-index: 1; }

.header-user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 9999px;
    overflow: hidden;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: #e8eaed;
    color: #374151;
    font-size: 11px;
    font-weight: 700;
    border: none;
    box-shadow: none;
}
.header-user-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.header-user-avatar-fallback {
    width: 100%;
    height: 100%;
    align-items: center;
    justify-content: center;
}

.owner-filter-select {
    font-size: 12px;
    font-weight: 600;
    color: #374151;
    background: #f1f2f5;
    border: none;
    border-radius: 9999px;
    padding: 0.5rem 2rem 0.5rem 0.9rem;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%239ca3af' d='M3 4.5L6 7.5L9 4.5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.65rem center;
    cursor: pointer;
    min-width: 132px;
}
.pi-hero-eyebrow {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #9ca3af;
}
.pi-hero-title {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    margin-top: 0.25rem;
    color: var(--dash-ink);
}
.pi-hero-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.5rem 2.5rem;
    margin-top: 1.75rem;
}
@media (min-width: 768px) {
    .pi-hero-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}
.pi-hero-stat-label {
    font-size: 10px;
    font-weight: 600;
    color: #9ca3af;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}
.pi-hero-stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.04em;
    line-height: 1.05;
    margin-top: 0.35rem;
    font-variant-numeric: tabular-nums;
    color: var(--dash-ink);
}
.pi-hero-stat-sub {
    font-size: 11px;
    color: #9ca3af;
    margin-top: 0.35rem;
    font-weight: 500;
}
.pi-traffic-green,
.pi-traffic-yellow,
.pi-traffic-red { color: var(--dash-ink) !important; }
.pi-traffic-yellow.ph-warn-only { color: #b45309 !important; }
.pi-traffic-red.ph-danger-only { color: #dc2626 !important; }

.pi-risk-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 11px;
    font-weight: 600;
    padding: 0.25rem 0.6rem;
    border-radius: 999px;
    background: #f1f2f5;
    border: none;
    color: #6b7280;
}
.pi-risk-pill.green,
.pi-risk-pill.yellow,
.pi-risk-pill.red { background: #f1f2f5; color: #374151; border: none; }

/* Trend strip */
.pi-trend-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    margin-top: 1.25rem;
    padding-top: 1.25rem;
    border-top: none;
}
.pi-trend-line {
    font-size: 11px;
    font-weight: 500;
    color: #9ca3af;
}
.pi-trend-line.positive,
.pi-trend-line.negative { color: #6b7280; }

/* Alert cards */
.pi-alerts { display: flex; flex-direction: column; gap: 0.65rem; }
.pi-alert {
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
    padding: 0.85rem 1.1rem;
    border-radius: 1rem;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.45;
    border: none;
    box-shadow: 0 2px 12px rgb(15 23 42 / 0.04);
}
.pi-alert.critical {
    background: #ffffff;
    color: #991b1b;
}
.pi-alert.warning {
    background: #ffffff;
    color: #92400e;
}
html[data-theme="dark"] .pi-alert.critical,
html[data-theme="dark"] .pi-alert.warning {
    background: var(--dash-surface);
}

/* Surface cards */
.dash-surface {
    background: var(--dash-surface);
    border: none;
    border-radius: 1.25rem;
    padding: 1.5rem 1.65rem;
    box-shadow: 0 4px 24px rgb(15 23 42 / 0.04);
}
.dash-surface-soft {
    background: var(--dash-surface-2);
    border-radius: 1rem;
}
.dash-section-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--dash-ink);
    letter-spacing: -0.02em;
}
.dash-section-sub {
    font-size: 12px;
    color: var(--dash-muted);
    font-weight: 500;
    margin-top: 0.2rem;
}

.dash-metric {
    background: var(--dash-surface);
    border: none;
    border-radius: 1.25rem;
    padding: 1.15rem 1.25rem;
    box-shadow: 0 4px 24px rgb(15 23 42 / 0.04);
}
.dash-pct-bar {
    height: 3px;
    border-radius: 999px;
    background: #f1f2f5;
    overflow: hidden;
}
html[data-theme="dark"] .dash-pct-bar { background: #2d323c; }
.dash-pct-fill {
    height: 100%;
    border-radius: 999px;
    transition: width 0.5s ease;
    background: #111827;
}
.dash-health-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}
.dash-health-dot.ok { background: #111827; }
.dash-health-dot.warn { background: #d97706; }
.dash-health-dot.danger { background: #dc2626; }
.dash-health-dot.active { background: #111827; }
.dash-health-dot.idle { background: #d1d5db; }

.dash-chart-card {
    background: var(--dash-surface);
    border: none;
    border-radius: 1.25rem;
    padding: 1.5rem 1.65rem;
    box-shadow: 0 4px 24px rgb(15 23 42 / 0.04);
}
.dash-chart-wrap {
    position: relative;
    height: 200px;
    max-width: 100%;
}

/* Buffer panel */
.pi-buffer-panel {
    padding: 1.15rem 1.25rem;
    border-radius: 1rem;
    background: var(--dash-surface-2);
    border: none;
}
.pi-buffer-panel.green,
.pi-buffer-panel.yellow,
.pi-buffer-panel.red { background: var(--dash-surface-2); }

/* Pipeline intelligence rows */
.pi-pipe-list { display: flex; flex-direction: column; gap: 0.25rem; }
.pi-pipe-row-wrap {
    position: relative;
    border-radius: 0.75rem;
    transition: background 0.12s ease;
}
.pi-pipe-row-wrap.collapsed .pi-pipe-row {
    padding: 0.35rem 0.5rem;
    opacity: 0.72;
}
.pi-pipe-row-wrap.expanded {
    background: var(--dash-surface-2);
    box-shadow: none;
}
.pi-pipe-row-wrap.expanded.critical,
.pi-pipe-row-wrap.expanded.warning {
    background: var(--dash-surface-2);
    box-shadow: none;
}
.pi-pipe-row {
    display: grid;
    grid-template-columns: minmax(5.5rem, 7rem) minmax(72px, 96px) minmax(4.5rem, 1fr) auto;
    align-items: center;
    gap: 0.65rem 0.75rem;
    padding: 0.6rem 0.65rem;
}
@media (max-width: 520px) {
    .pi-pipe-row {
        grid-template-columns: 1fr auto;
        grid-template-rows: auto auto auto;
    }
    .pi-pipe-row-name { grid-column: 1; }
    .pi-pipe-row-counts { grid-column: 1; }
    .pi-pipe-row-bar { grid-column: 1 / -1; }
    .pi-pipe-row-badge-wrap { grid-column: 2; grid-row: 1; justify-self: end; }
}
.pi-pipe-row-name {
    font-size: 12px;
    font-weight: 700;
    color: var(--dash-ink);
    letter-spacing: -0.01em;
    line-height: 1.2;
}
.pi-pipe-row-name .en {
    display: block;
    font-size: 10px;
    font-weight: 500;
    color: var(--dash-muted);
    margin-top: 0.1rem;
}
.pi-pipe-row-bar {
    height: 3px;
    max-width: 96px;
}
.pi-pipe-row-counts {
    font-size: 11px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--dash-muted);
    white-space: nowrap;
}
.pi-pipe-row-counts strong { color: var(--dash-ink); font-weight: 700; }
.pi-pipe-badge {
    font-size: 10px;
    font-weight: 600;
    padding: 0.2rem 0.5rem;
    border-radius: 999px;
    white-space: nowrap;
    background: #f1f2f5;
    color: #6b7280;
    border: none;
}
.pi-pipe-badge.green,
.pi-pipe-badge.yellow,
.pi-pipe-badge.red { background: #f1f2f5; color: #374151; }

.pi-pipe-fill-green,
.pi-pipe-fill-yellow,
.pi-pipe-fill-red,
.pi-pipe-fill-indigo { background: #111827; }

.pi-pipe-popover {
    position: absolute;
    left: 0.5rem;
    right: 0.5rem;
    top: calc(100% + 2px);
    z-index: 30;
    padding: 0.45rem 0.5rem;
    border-radius: 0.85rem;
    background: var(--dash-surface);
    box-shadow: 0 8px 32px rgb(15 23 42 / 0.08);
    border: none;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(2px);
    transition: opacity 0.14s ease, transform 0.14s ease, visibility 0.14s ease;
}
.pi-pipe-row-wrap:hover .pi-pipe-popover,
.pi-pipe-row-wrap:focus-within .pi-pipe-popover {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
}
.pi-pipe-popover-title {
    font-size: 10px;
    font-weight: 600;
    color: var(--dash-muted);
    padding: 0.2rem 0.4rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.pi-pipe-popover-list { max-height: 180px; overflow-y: auto; }
.pi-pipe-popover-item {
    display: block;
    padding: 0.35rem 0.45rem;
    border-radius: 0.5rem;
    text-decoration: none;
    color: inherit;
    font-size: 11px;
    font-weight: 500;
}
.pi-pipe-popover-item:hover { background: #f1f2f5; }

.dash-today-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    border-radius: 0.85rem;
    background: var(--dash-surface-2);
    transition: background 0.15s ease;
    border: none;
}
.dash-today-item:hover { background: #eceef2; }
html[data-theme="dark"] .dash-today-item:hover { background: #252932; }
