/* Department dashboard layout system (used by Components/Shared/DepartmentDashboard/*) */
.ddash {
    --ddash-bg: linear-gradient(145deg, #1d2733, #243447);
    --ddash-border: #37506b;
    --ddash-accent: #d18836;
    --ddash-accent-soft: rgba(209, 136, 54, 0.16);
    --ddash-text: #ecf0f1;
    --ddash-muted: #9fb0c0;
    --ddash-ok: #5fd68a;
    --ddash-warn: #f3c37f;
    --ddash-danger: #ff8f8f;
    width: 100%;
    margin-bottom: 1.5rem;
    color: var(--ddash-text);
    font-size: 0.78rem;
}

.ddash-grid {
    display: grid;
    grid-template-columns: minmax(0, 3.4fr) minmax(0, 1fr);
    gap: 0.75rem;
    align-items: stretch;
}

.ddash-kpis { grid-area: 1 / 1; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0.75rem; }
.ddash-alerts { grid-area: 1 / 2; }
.ddash-row-charts { grid-area: 2 / 1; }
.ddash-needs { grid-area: 2 / 2; }
.ddash-row-goals { grid-area: 3 / 1; }
.ddash-tasks { grid-area: 3 / 2 / span 2 / span 1; }
.ddash-row-inventory { grid-area: 4 / 1; }
.ddash-attention { grid-area: 5 / 1 / span 1 / span 2; }

.ddash-row { display: grid; gap: 0.75rem; align-items: stretch; }
.ddash-row-charts { grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr) minmax(0, 1fr); }
.ddash-row-goals { grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); }
.ddash-row-inventory { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr) minmax(0, 1fr); }

/* Cards */
.ddash-card {
    position: relative;
    min-width: 0;
    padding: 0.7rem 0.8rem;
    background: var(--ddash-bg);
    border: 1px solid var(--ddash-border);
    border-radius: 0.75rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.18);
    overflow: hidden;
}

.ddash-blur {
    filter: blur(4px);
    pointer-events: none;
    user-select: none;
}

.ddash-badge {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 0.2rem 0.6rem;
    background: rgba(18, 26, 36, 0.8);
    border: 1px solid var(--ddash-accent);
    border-radius: 999px;
    color: var(--ddash-warn);
    font-size: 0.66rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    white-space: nowrap;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.45);
}

/* Card internals */
.ddash-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.ddash-card-title { font-size: 0.78rem; font-weight: 600; color: #ffffff; }
.ddash-card-title .oi { margin-right: 0.3rem; }

.ddash-view-all { font-size: 0.66rem; color: var(--ddash-accent); white-space: nowrap; }

.ddash-sub-title {
    margin: 0.6rem 0 0.3rem;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--ddash-muted);
}

.ddash-legend { display: flex; align-items: center; gap: 0.35rem; font-size: 0.66rem; color: var(--ddash-muted); }

.ddash-dot {
    display: inline-block;
    width: 0.45rem;
    height: 0.45rem;
    border-radius: 50%;
    background: currentColor;
}

.ddash-legend .ddash-dot { margin-left: 0.35rem; }
.ddash-dot-actual { color: var(--ddash-accent); }
.ddash-dot-goal { color: #8fa4bd; }
.ddash-dot-last { color: #cfd9e4; }

/* KPI tiles */
.ddash-kpi-value { font-size: 1.4rem; font-weight: 600; line-height: 1.2; font-variant-numeric: tabular-nums; }
.ddash-kpi-sub { font-size: 0.68rem; color: var(--ddash-muted); }
.ddash-delta { display: flex; flex-direction: column; gap: 0.1rem; margin-top: 0.35rem; font-size: 0.66rem; color: var(--ddash-warn); }

.ddash-meter {
    height: 5px;
    margin: 0.35rem 0;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 999px;
    overflow: hidden;
}

.ddash-meter > span { display: block; height: 100%; background: var(--ddash-accent); }

/* Active alerts */
.ddash-alert-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.2rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.ddash-alert-row:last-child { border-bottom: none; }

.ddash-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.1rem;
    padding: 0.05rem 0.3rem;
    border-radius: 0.35rem;
    background: var(--ddash-accent-soft);
    color: var(--ddash-warn);
    font-weight: 600;
}

/* Bar chart */
.ddash-bars {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.5rem;
    padding-top: 0.25rem;
}

.ddash-bar-group { text-align: center; }

.ddash-bar-stack {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 3px;
    height: 86px;
}

.ddash-bar { flex: 1; max-width: 16px; border-radius: 3px 3px 0 0; }
.ddash-bar-actual { background: var(--ddash-accent); }
.ddash-bar-goal { background: #8fa4bd; opacity: 0.75; }
.ddash-bar-last { background: #cfd9e4; opacity: 0.65; }

.ddash-bar-name,
.ddash-bar-sub { font-size: 0.66rem; color: var(--ddash-muted); }

.ddash-bar-value { font-size: 0.72rem; font-weight: 600; font-variant-numeric: tabular-nums; }

/* Line chart */
.ddash-chart-layout { display: flex; align-items: flex-start; gap: 0.5rem; }
.ddash-svg { flex: 1 1 auto; min-width: 0; width: 100%; height: auto; }
.ddash-chart-stats { display: flex; flex-direction: column; gap: 0.35rem; min-width: 5.5rem; }

.ddash-grid-line { stroke: rgba(255, 255, 255, 0.09); stroke-width: 1; }
.ddash-target-line { stroke: #8fa4bd; stroke-width: 1.2; stroke-dasharray: 4 3; }
.ddash-actual-line { fill: none; stroke: var(--ddash-accent); stroke-width: 2; }
.ddash-forecast-line { fill: none; stroke: var(--ddash-accent); stroke-width: 2; stroke-dasharray: 4 3; }
.ddash-legend-line { stroke-width: 2; }
.ddash-axis { fill: var(--ddash-muted); font-size: 7px; }

/* Stat strips and simple lines */
.ddash-stat-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.4rem; }

.ddash-stat { padding: 0.35rem 0.45rem; background: rgba(255, 255, 255, 0.04); border-radius: 0.5rem; }

.ddash-stat-highlight { background: var(--ddash-accent-soft); }
.ddash-stat-label { font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ddash-muted); }
.ddash-stat-value { font-size: 0.95rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.ddash-stat-sub { font-size: 0.62rem; color: var(--ddash-muted); }

/* Split metric: one value per production stream instead of a single summed figure */
.ddash-split { display: flex; flex-direction: column; gap: 0.05rem; margin-top: 0.15rem; }

.ddash-split-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.4rem;
}

.ddash-split-key { font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ddash-muted); }
.ddash-split-value { font-size: 0.85rem; font-weight: 600; font-variant-numeric: tabular-nums; }

/* Forecast completion bars */
.ddash-progress-list { display: flex; flex-direction: column; gap: 0.3rem; }

.ddash-progress-row { display: flex; align-items: center; gap: 0.5rem; }

.ddash-progress-label {
    flex: 0 0 3.2rem;
    font-size: 0.62rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--ddash-muted);
}

.ddash-progress-track {
    flex: 1 1 auto;
    height: 8px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    overflow: hidden;
}

.ddash-progress-fill { display: block; height: 100%; border-radius: 999px; transition: width 0.3s ease; }
.ddash-progress-resin { background: var(--ddash-accent); }
.ddash-progress-rosin { background: #8ecbff; }

.ddash-progress-value {
    flex: 0 0 auto;
    min-width: 8.5rem;
    text-align: right;
    font-size: 0.68rem;
    font-variant-numeric: tabular-nums;
    color: #ffffff;
}

.ddash-lines { margin-top: 0.6rem; }

.ddash-line {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.25rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.ddash-line:last-child { border-bottom: none; }
.ddash-strong { font-weight: 600; font-variant-numeric: tabular-nums; }

/* Needs attention / tasks */
.ddash-need {
    display: flex;
    align-items: flex-start;
    gap: 0.4rem;
    padding: 0.3rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.ddash-need:last-child { border-bottom: none; }
.ddash-need-icon { color: var(--ddash-warn); margin-top: 0.15rem; }
.ddash-need-title { font-weight: 600; }
.ddash-need-detail { font-size: 0.66rem; color: var(--ddash-muted); }

.ddash-task {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.4rem;
    padding: 0.35rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.ddash-task:last-child { border-bottom: none; }
.ddash-task-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.ddash-chip {
    padding: 0.1rem 0.4rem;
    border: 1px solid currentColor;
    border-radius: 999px;
    font-size: 0.62rem;
    white-space: nowrap;
}

/* Tables */
.ddash-table { display: flex; flex-direction: column; }

.ddash-tr {
    display: grid;
    gap: 0.4rem;
    align-items: center;
    padding: 0.28rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.ddash-tr > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.ddash-th { font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ddash-muted); }

.ddash-table-material .ddash-tr { grid-template-columns: 0.6fr 1.3fr 0.5fr 0.8fr 1fr 0.6fr; }
.ddash-table-goals .ddash-tr { grid-template-columns: 1.4fr 0.9fr 0.9fr 1fr 0.8fr 1fr; }
.ddash-table-menu .ddash-tr { grid-template-columns: 1.4fr 1fr 0.8fr 0.9fr 1.1fr; }
.ddash-table-packaging .ddash-tr { grid-template-columns: 1.5fr 1fr 1fr 0.9fr; }
.ddash-table-departments .ddash-tr { grid-template-columns: 1.2fr 0.9fr 0.7fr 1fr; }
.ddash-table-attention .ddash-tr { grid-template-columns: 0.8fr 2.2fr 1.4fr 1.6fr 1fr 0.6fr; }

.ddash-progress-cell { display: flex; align-items: center; gap: 0.3rem; }

.ddash-mini-bar {
    flex: 1;
    height: 5px;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 999px;
    overflow: hidden;
}

.ddash-mini-bar > span { display: block; height: 100%; background: var(--ddash-ok); }

/* Carousel (used by the workforce module's today/weekly slides) */
.ddash-carousel-head { display: flex; align-items: center; gap: 0.35rem; }

.ddash-carousel-nav {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.25rem;
    height: 1.25rem;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--ddash-accent);
    font-size: 0.7rem;
    line-height: 1;
    cursor: pointer;
    pointer-events: auto;
}

.ddash-carousel-nav:disabled { color: var(--ddash-muted); opacity: 0.4; cursor: default; }

.ddash-carousel { overflow: hidden; }
.ddash-carousel-track { display: flex; transition: transform 0.3s ease; }
.ddash-carousel-slide { flex: 0 0 100%; min-width: 0; }

.ddash-carousel-dots { display: flex; justify-content: center; gap: 0.3rem; margin-top: 0.5rem; }

.ddash-carousel-dot {
    width: 0.4rem;
    height: 0.4rem;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.25);
    cursor: pointer;
    pointer-events: auto;
}

.ddash-carousel-dot.active { background: var(--ddash-accent); }

.ddash-table-weekly .ddash-tr { grid-template-columns: 0.8fr 1fr 1fr 1fr 1fr; }
.ddash-row-today { color: #ffffff; font-weight: 600; }

/* Drill-down: metric values that open the employee modal */
.ddash-drill {
    padding: 0;
    border: none;
    background: none;
    font: inherit;
    color: inherit;
    text-align: left;
    cursor: pointer;
    pointer-events: auto;
}

.ddash-drill:hover { text-decoration: underline; }

/* Employee drill-down modal (rendered outside the card so it is never clipped) */
.ddash-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(8, 12, 20, 0.65);
}

.ddash-modal {
    width: min(32rem, 100%);
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    background: #1d2733;
    border: 1px solid var(--ddash-border, #37506b);
    border-radius: 0.75rem;
    box-shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.85);
}

.ddash-modal-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.8rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.ddash-modal-title { font-size: 0.95rem; font-weight: 600; color: #ffffff; }
.ddash-modal-sub { font-size: 0.68rem; color: var(--ddash-muted, #9fb0c0); }

.ddash-modal-close {
    padding: 0;
    border: none;
    background: none;
    color: var(--ddash-muted, #9fb0c0);
    font-size: 0.8rem;
    cursor: pointer;
}

.ddash-modal-close:hover { color: #ffffff; }

.ddash-modal-body { padding: 0.35rem 1rem 0.85rem; overflow-y: auto; }

.ddash-person {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    padding: 0.55rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.ddash-person:last-child { border-bottom: none; }

.ddash-avatar {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.2rem;
    height: 2.2rem;
    overflow: hidden;
    border: 1px solid var(--ddash-border, #37506b);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
}

.ddash-avatar img { width: 100%; height: 100%; object-fit: cover; }
.ddash-avatar-initials { font-size: 0.72rem; font-weight: 600; color: #ffffff; }
/* Batch/vat rows inside the detail modal */
.ddash-batch {
    padding: 0.55rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.ddash-batch:last-child { border-bottom: none; }

.ddash-batch-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem;
}

.ddash-batch-label { font-weight: 600; color: #ffffff; }

.ddash-person-name { font-weight: 600; color: #ffffff; }
.ddash-person-line { font-size: 0.68rem; color: var(--ddash-muted, #9fb0c0); }

/* Status tokens */
.ddash-status { display: inline-flex; align-items: center; gap: 0.25rem; white-space: nowrap; }

.ddash-tone-ok { color: var(--ddash-ok); }
.ddash-tone-warn { color: var(--ddash-warn); }
.ddash-tone-danger { color: var(--ddash-danger); }
.ddash-tone-info { color: #8ecbff; }
.ddash-tone-muted { color: var(--ddash-muted); }

/* Attention center */
.ddash-attention-counters { display: flex; align-items: center; gap: 1rem; }
.ddash-counter { text-align: center; }
.ddash-counter .ddash-stat-value { display: block; font-size: 1.1rem; }

.ddash-select {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.5rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--ddash-border);
    border-radius: 0.4rem;
    font-size: 0.68rem;
    color: var(--ddash-muted);
    white-space: nowrap;
}

.ddash-severity { display: inline-flex; align-items: center; gap: 0.3rem; font-weight: 600; white-space: nowrap; }
.ddash-attention-dept { display: inline-block; min-width: 4.5rem; color: var(--ddash-muted); }
.ddash-attention-title { display: block; font-weight: 600; }

@media (max-width: 1200px) {
    .ddash-grid { grid-template-columns: minmax(0, 1fr); }
    .ddash-kpis { grid-area: auto; grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .ddash-alerts,
    .ddash-row-charts,
    .ddash-needs,
    .ddash-row-goals,
    .ddash-tasks,
    .ddash-row-inventory,
    .ddash-attention { grid-area: auto; }
    .ddash-row-charts,
    .ddash-row-inventory { grid-template-columns: minmax(0, 1fr); }
}
