/* ===============================================================================
   PROJECT MANAGER MODULE STYLES
   ===============================================================================
   Module-specific styling for Project Manager, Fortschrittsplanung, and Settings pages.
   Uses design tokens from site.css.
   =============================================================================== */

/* ===============================================================================
   INDICATOR CARDS (Fortschrittsplanung)
   =============================================================================== */

.pm-indicator-card {
    /* Fix 1 (Planner-Fix.txt) — centred 2-line layout matching RDS cards. */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: var(--space-12) var(--space-8);
    border-radius: var(--radius-medium);
    border: 1px solid var(--color-border-subtle);
    background: var(--color-grey-50);
    min-height: 84px;
}

.pm-indicator-card--neutral {
    background: var(--color-grey-50);
    border-color: var(--color-border-subtle);
}

.pm-indicator-card--warning {
    background: var(--color-warning-light);
    border-color: var(--color-warning);
}

.pm-indicator-card--danger {
    background: var(--color-error-light);
    border-color: var(--color-error);
}

/* BCF Overdue card — saturated red, distinct from Waiting orange */
.pm-indicator-card--overdue {
    background: rgba(214, 69, 69, 0.12);
    border-color: #D64545;
}

/* BCF Waiting card — orange, distinct from yellow InProgress and red Overdue */
.pm-indicator-card--waiting-orange {
    background: rgba(230, 95, 56, 0.12);
    border-color: #e65f38;
}

/* Fix 1 — info (blue) variant for Active state. */
.pm-indicator-card--info {
    background: rgba(0, 95, 158, 0.10);
    border-color: #005f9e;
}

/* Fix 1 — success (green) variant for Approved states. */
.pm-indicator-card--success {
    background: rgba(46, 133, 64, 0.12);
    border-color: #2E8540;
}

/* Session 4 V2 — Completed uses light gray (§6.8) to visually de-emphasise
   finished work, distinct from the green Approved state. */
.pm-indicator-card--completed {
    background-color: var(--mud-palette-action-disabled-background, var(--color-grey-100));
    border-color: var(--color-border-subtle);
}

/* Active toggle state for the interactive indicator cards (Session 7).
   Cards are <button> elements; reset native button chrome and highlight when
   selected as a state filter. */
button.pm-indicator-card {
    cursor: pointer;
    font: inherit;
    color: inherit;
    width: 100%;
}

button.pm-indicator-card:hover {
    box-shadow: 0 0 0 1px var(--color-primary);
}

.pm-indicator-card--active {
    box-shadow: 0 0 0 2px var(--color-primary);
    border-color: var(--color-primary);
}

/* Session 3 — Total card active highlight (States is null/empty = "all visible"). */
.pm-indicator-card--total-active {
    box-shadow: 0 0 0 2px var(--color-primary);
    border-color: var(--color-primary);
}

.pm-indicator-card__label {
    /* Smaller label that wraps to 2 lines instead of clipping (Fix 1). */
    font-size: 0.875rem;
    line-height: 1.2;
    color: var(--color-text-secondary);
    margin-bottom: var(--space-4);
    /* Allow up to two lines of wrap. */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
}

.pm-indicator-card__value {
    /* Match Room Data Sheet KPI typography. */
    font-size: 1.75rem;
    font-weight: 600;
    line-height: 1;
    margin-top: var(--space-4);
}

.pm-indicator-card__value--warning {
    color: #856404;
}

.pm-indicator-card__value--danger {
    color: #721c24;
}

/* ===============================================================================
   TIMELINE CONTAINER
   =============================================================================== */

.pm-timeline-container {
    margin-top: var(--space-24);
    margin-bottom: var(--space-24);
    min-height: 400px;
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-medium);
    position: relative;
    background: var(--color-white);
}

/* ===============================================================================
   TIMELINE LEGEND  (Fix 2 — Planner-Fix.txt)
   =============================================================================== */

.pm-timeline-legend {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-16);
    align-items: center;
    padding: var(--space-8) var(--space-12);
    margin-bottom: var(--space-8);
    font-size: 0.8125rem;
    color: var(--color-text-secondary);
    background: var(--color-grey-50);
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-medium);
}

.pm-timeline-legend__item {
    display: inline-flex;
    align-items: center;
    gap: var(--space-8);
    white-space: nowrap;
}

.pm-timeline-legend__line {
    display: inline-block;
    width: 28px;
    height: 4px;
    border-radius: 2px;
    background: #005f9e;
}

.pm-timeline-legend__line--solid    { background: #005f9e; }
.pm-timeline-legend__line--dashed   {
    background: repeating-linear-gradient(to right,
        #2E8540 0, #2E8540 6px, transparent 6px, transparent 10px);
}
.pm-timeline-legend__line--overdue  { background: #D64545; }
.pm-timeline-legend__line--rejected {
    background: repeating-linear-gradient(to right,
        #D64545 0, #D64545 6px, transparent 6px, transparent 10px);
}
.pm-timeline-legend__line--today    { background: #D64545; }

.pm-timeline-legend__symbol {
    display: inline-block;
    width: 14px;
    height: 14px;
}

.pm-timeline-legend__symbol--diamond {
    background: #9c27b0;
    transform: rotate(45deg);
}

.pm-timeline-legend__symbol--milestone {
    background: #f2b705;
    transform: rotate(45deg);
}

.pm-timeline-legend__symbol--circle {
    border: 2px solid #005f9e;
    border-radius: 50%;
    background: transparent;
}

.pm-timeline-legend__symbol--circle-filled {
    border-radius: 50%;
    background: #005f9e;
}

.pm-timeline-legend__symbol--check {
    width: 14px;
    height: 14px;
    background: transparent;
    /* simple checkmark via inline SVG mask */
    -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><path d='M3 8l3 3 7-7' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/></svg>") center / contain no-repeat;
            mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><path d='M3 8l3 3 7-7' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/></svg>") center / contain no-repeat;
    background-color: #2E8540;
}

/* ===============================================================================
   TASK TABLE (fallback view)
   =============================================================================== */

.pm-task-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9em;
}

.pm-task-table thead {
    background: var(--color-table-header-bg);
    position: sticky;
    top: 0;
    z-index: 10;
}

.pm-task-table th {
    padding: var(--space-12) var(--space-16);
    text-align: left;
    font-weight: 600;
    border: 1px solid var(--color-border-subtle);
}

.pm-task-table td {
    padding: var(--space-12) var(--space-16);
    border: 1px solid var(--color-border-subtle);
}

.pm-task-table tbody tr:hover {
    background: var(--color-table-row-hover-bg);
}

/* ===============================================================================
   BADGES / STATUS INDICATORS
   =============================================================================== */

.pm-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-4);
    padding: 2px var(--space-8);
    border-radius: var(--radius-full, 999px);
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    background: var(--color-primary, #005f9e);
    color: #fff;
}

/* X remove button inside a badge */
.pm-badge__x {
    background: transparent;
    border: none;
    padding: 0;
    margin: 0;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.8);
    font-size: 11px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    border-radius: 50%;
    transition: color 0.1s, background 0.1s;
}

.pm-badge__x:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.2);
}

/* Non-removable badge (analysis mode label) */
.pm-badge--readonly {
    background: var(--color-grey-200);
    color: var(--color-text-secondary);
}

.pm-badge--success {
    background: var(--color-success-light);
    color: var(--color-success);
}

.pm-badge--info {
    background: #cfe2ff;
    color: #084298;
}

.pm-badge--danger {
    background: var(--color-error-light);
    color: var(--color-error);
}

.pm-badge--warning {
    background: var(--color-warning-light);
    color: #856404;
}

/* ===============================================================================
   CHECKBOXES / CONTROLS
   =============================================================================== */

.pm-control-group {
    margin-bottom: var(--space-16);
}

.pm-checkbox-label {
    display: flex;
    align-items: center;
    gap: var(--space-8);
    cursor: pointer;
    user-select: none;
}

.pm-checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* ===============================================================================
   EMPTY STATE
   =============================================================================== */

.pm-empty-state {
    text-align: center;
    padding: var(--space-48);
    color: var(--color-text-secondary);
}

.pm-empty-state p {
    margin: 0;
}

/* ===============================================================================
   LOADING STATE
   =============================================================================== */

.pm-loading-state {
    text-align: center;
    padding: var(--space-48);
}

.pm-loading-state p {
    margin-top: var(--space-16);
}

/* ===============================================================================
   PAGE HEADER
   =============================================================================== */

.pm-page-header {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: var(--space-16);
    color: var(--color-text-primary);
}

/* ===============================================================================
   CARD CONTENT
   =============================================================================== */

.pm-card-text-secondary {
    color: var(--color-text-secondary);
}

/* ===============================================================================
   GRID LAYOUT (for indicator cards)
   =============================================================================== */

.pm-indicator-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    width: 100%;
    gap: var(--space-16);
    margin-bottom: var(--space-24);
}

/* ===============================================================================
   DRAWER (for WorkPackage creation/editing)
   =============================================================================== */

.drawer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: flex;
}

.drawer {
    background: var(--color-white);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    max-width: 600px;
    width: 100%;
}

.drawer-right {
    margin-left: auto;
}

.drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-20);
    border-bottom: 1px solid var(--color-border-subtle);
}

.drawer-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--color-text-primary);
}

.btn-close {
    background: transparent;
    border: none;
    font-size: 24px;
    color: var(--color-text-muted);
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-small);
}

.btn-close:hover {
    background: var(--color-grey-100);
    color: var(--color-text-primary);
}

.drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-20);
}

.drawer-actions {
    display: flex;
    gap: var(--space-12);
    margin-top: var(--space-20);
    padding-top: var(--space-16);
    border-top: 1px solid var(--color-border-subtle);
}

/* ===============================================================================
   RESPONSIVE
   =============================================================================== */

@media (max-width: 768px) {
    .pm-indicator-grid {
        grid-template-columns: 1fr;
    }
    
    .pm-page-header {
        font-size: 20px;
    }

    .pm-filter-row {
        flex-direction: column;
        align-items: stretch;
    }
}

/* ===============================================================================
   APP-BTN — shared button primitives (no Bootstrap, no MudBlazor dependency)
   =============================================================================== */

.app-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-4);
    padding: 5px var(--space-12);
    border-radius: var(--radius-medium);
    font-size: 13px;
    font-weight: 500;
    line-height: 1.5;
    border: 1px solid transparent;
    cursor: pointer;
    white-space: nowrap;
    text-decoration: none;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.app-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.app-btn-primary {
    background: var(--color-button-primary, #005f9e);
    border-color: var(--color-button-primary, #005f9e);
    color: #fff;
}

.app-btn-primary:hover:not(:disabled) {
    background: var(--color-button-primary-hover, #00437b);
    border-color: var(--color-button-primary-hover, #00437b);
    color: #fff;
}

.app-btn-secondary {
    background: transparent;
    border-color: var(--color-border, #d1d5db);
    color: var(--color-text-primary, #1a202c);
}

.app-btn-secondary:hover:not(:disabled) {
    background: var(--color-grey-100, #f3f4f6);
}

.app-btn-default {
    background: var(--color-grey-100, #f3f4f6);
    border-color: var(--color-border, #d1d5db);
    color: var(--color-text-primary, #1a202c);
}

.app-btn-default:hover:not(:disabled) {
    background: var(--color-grey-200, #e5e7eb);
}

/* ===============================================================================
   FILTER BAR (Session 7)
   =============================================================================== */

.pm-filter-bar {
    display: flex;
    flex-direction: column;
    gap: var(--space-12);
    padding: var(--space-16);
    background: var(--color-grey-50);
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-medium);
    margin-bottom: var(--space-16);
}

.pm-filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-8);
    /* Section 2 (Planner_UI_Fix): align filter inputs on same baseline as buttons */
    align-items: flex-end;
}

.pm-filter-row--toggles {
    align-items: center;
}

/* Section 2 — Ensure dropdowns, date inputs, and tag-dropdown buttons share the same height as .app-btn (~30px) */
.pm-filter-row select.app-input,
.pm-filter-row input[type="date"].app-input,
.pm-filter-row button.app-input {
    height: 30px;
    padding-top: 3px;
    padding-bottom: 3px;
    box-sizing: border-box;
    line-height: 1.4;
}

/* Buttons in filter rows keep the same 30px height */
.pm-filter-row .app-btn {
    height: 30px;
    padding-top: 0;
    padding-bottom: 0;
}

.pm-filter-field {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    flex: 1 1 180px;
    min-width: 160px;
}

.pm-filter-label {
    font-size: 12px;
    color: var(--color-text-secondary);
    font-weight: 500;
}

.pm-filter-reset {
    margin-left: auto;
}

/* ── Tag dropdown multi-select ──────────────────────────────────────────── */
.pm-tag-dropdown {
    position: relative;
}

.pm-tag-dropdown__btn {
    width: 100%;
    text-align: left;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.pm-tag-dropdown__panel {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 200;
    background: var(--color-surface, #fff);
    border: 1px solid var(--color-border, #e2e8f0);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.10);
    padding: 8px 12px;
    min-width: 180px;
    max-height: 240px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* ===============================================================================
   TASK GRID (Session 8)
   =============================================================================== */

.pm-task-grid {
    margin-top: var(--space-12);
}

.pm-task-grid .mud-table-row {
    cursor: pointer;
}

/* Toolbar above the task grid (Session 4 - PM Drawers) */
.pm-table-toolbar {
    display: flex;
    gap: var(--space-8);
    padding: var(--space-8) 0;
}

/* State pill — small colored badge in the State column */
.pm-state-pill {
    display: inline-block;
    padding: 2px var(--space-8);
    border-radius: var(--radius-small);
    font-size: 12px;
    font-weight: 500;
    background: var(--color-grey-100);
    color: var(--color-text-primary);
    white-space: nowrap;
}

.pm-state-pill--plannedoverdue,
.pm-state-pill--rejected {
    background: var(--color-error-light);
    color: #721c24;
}

.pm-state-pill--incontrol {
    background: var(--color-warning-light);
    color: #856404;
}

.pm-state-pill--approved,
.pm-state-pill--completed {
    background: var(--color-success-light, #d4edda);
    color: var(--color-success-dark, #155724);
}

.pm-state-pill--active {
    background: var(--color-info-light, #d1ecf1);
    color: var(--color-info-dark, #0c5460);
}

.pm-state-pill--future {
    background: var(--color-grey-100);
    color: var(--color-text-secondary);
}

/* Tag chip cluster in the Tags column */
.pm-tag-chip-list {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-4);
}

.pm-tag-chip {
    display: inline-block;
    padding: 1px var(--space-8);
    border-radius: var(--radius-small);
    background: var(--color-grey-100);
    color: var(--color-text-secondary);
    font-size: 11px;
}

/* ===============================================================================
   COLLAPSIBLE SECTION (Session 9)
   =============================================================================== */

.pm-collapsible-section {
    margin-bottom: var(--space-16);
}

/* Section 5 (Planner_UI_Fix): removed border from card title header */
.pm-collapsible-section__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: var(--space-8) var(--space-4);
    background: transparent;
    border: none;
    border-radius: var(--radius-default);
    cursor: pointer;
    user-select: none;
    font-weight: 600;
    font-size: 14px;
    color: var(--color-text-primary);
    transition: background 0.15s;
}

.pm-collapsible-section__header:hover {
    background: var(--color-grey-50, #f8f9fa);
}

.pm-collapsible-section--collapsed .pm-collapsible-section__header {
    border-radius: var(--radius-default);
}

.pm-collapsible-section__title {
    flex: 1;
    text-align: left;
}

/* Section 5 — dynamic count shown after section title */
.pm-collapsible-section__count {
    margin-left: var(--space-4);
    font-weight: 400;
    color: var(--color-text-muted);
    font-size: 13px;
}

.pm-collapsible-section__chevron {
    flex-shrink: 0;
    color: var(--color-text-secondary);
}

.pm-collapsible-section__body {
    padding: var(--space-12) 0;
}

/* ===============================================================================
   PAGE LAYOUT (Session 9, updated Session 4/V2)
   =============================================================================== */

.projectmanager-layout {
    height: 100vh;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.projectmanager-content {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.pm-page {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: var(--space-20);
}

.pm-page__error-banner {
    padding: var(--space-8) var(--space-12);
    background: var(--color-error-light);
    border: 1px solid var(--color-error, #D64545);
    border-radius: var(--radius-default);
    color: #721c24;
    font-size: 13px;
    margin-bottom: var(--space-8);
}

/* ===============================================================================
   CHARTS (Session 10)
   =============================================================================== */

.pm-charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: var(--space-16);
}

.pm-chart-card {
    background: var(--color-surface, #fff);
    border: 1px solid var(--color-border, #E2E8F0);
    border-radius: var(--radius-medium);
    padding: var(--space-16);
    overflow: hidden;
}

.pm-chart-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-primary, #1a202c);
    margin-bottom: var(--space-12);
}

/* Bar chart title row with chart-type radio toggles on the same line. */
.pm-chart-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-12);
    margin-bottom: var(--space-12);
}

.pm-chart-title-row .pm-chart-title {
    margin-bottom: 0;
}

.pm-bar-type-toggles {
    display: flex;
    gap: var(--space-12);
    flex-shrink: 0;
}

/* Session 8 — Increase MudChart SVG text to improve legibility (§5.1). */
.pm-chart svg text {
    font-size: 0.85rem;
}

/* ===============================================================================
   CARD (Session 4/V2 — canonical definition)
   Mirrors the checklist.css settings card pattern.
   =============================================================================== */

.pm-card {
    background: var(--color-white);
    border-radius: var(--radius-medium);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border-subtle);
    padding: var(--space-20);
    margin-bottom: var(--space-20);
    min-width: 0;
}

/* Header bar inside a pm-card (bold title row with bottom separator) */
.pm-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: var(--space-12);
    margin-bottom: var(--space-12);
    border-bottom: 1px solid var(--color-border-subtle);
    font-size: 15px;
    font-weight: 600;
    color: var(--color-text-primary);
}

/* Body area inside a pm-card (optional extra top spacing) */
.pm-card-body {
    padding-top: var(--space-4);
}

.pm-card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--color-text-primary, #1a202c);
    margin: 0 0 var(--space-16);
    padding-bottom: var(--space-8);
    border-bottom: 1px solid var(--color-border, #E2E8F0);
}

.pm-settings-row {
    display: flex;
    align-items: center;
    gap: var(--space-12);
    padding: var(--space-6) 0;
}

.pm-settings-label {
    min-width: 180px;
    font-size: 13px;
    color: var(--color-text-secondary, #4A5568);
    flex-shrink: 0;
}

.pm-settings-slider {
    flex: 1;
}

.pm-settings-value {
    min-width: 36px;
    text-align: right;
    font-size: 13px;
    font-variant-numeric: tabular-nums;
    color: var(--color-text-primary, #1a202c);
}

/* ===============================================================================
   TASK CREATION DRAWER (Session 3)
   =============================================================================== */

.pm-drawer-section-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-text-secondary, #4a5568);
    margin: var(--space-16) 0 var(--space-8);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.pm-drawer-reviewer-mode {
    margin-top: var(--space-8);
}

/* BCF table: inactive rows */
.bcf-row--inactive td {
    font-style: italic;
    opacity: 0.5;
}

/* BCF drawer: 3-column metadata grid */
.bcf-drawer-meta-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: var(--space-8) var(--space-16);
    margin-bottom: var(--space-16);
}

@media (max-width: 480px) {
    .bcf-drawer-meta-grid {
        grid-template-columns: 1fr 1fr;
    }
}

/* ===============================================================================
   SETTINGS — ADMIN TABLES (Phases / Disciplines / TaskTypes / Copy Config)
   =============================================================================== */

.pm-admin-table-toolbar {
    display: flex;
    gap: var(--space-8);
    padding: var(--space-8) 0;
}

.pm-admin-inline-form {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-8);
    padding: var(--space-8) 0 var(--space-12);
}

.pm-admin-form {
    display: flex;
    flex-direction: column;
    gap: var(--space-12);
}

.pm-admin-copyconfig-options {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.pm-settings-empty {
    font-size: 13px;
    color: var(--color-text-secondary, #4a5568);
    margin: var(--space-8) 0;
}

/* ── Inline delete-confirmation modal ── */
.pm-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pm-modal-dialog {
    background: var(--color-white, #fff);
    border-radius: var(--radius-medium);
    box-shadow: var(--shadow-lg);
    padding: var(--space-24);
    min-width: 320px;
    max-width: 480px;
}

.pm-modal-dialog h3 {
    margin: 0 0 var(--space-8);
    font-size: 16px;
    font-weight: 600;
}

.pm-modal-dialog p {
    margin: 0 0 var(--space-20);
    font-size: 14px;
    color: var(--color-text-secondary, #4a5568);
}

.pm-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-8);
}

/* ===============================================================================
   3-ZONE LAYOUT (Session 6; Planner_UI_Fix sticky toggle)
   =============================================================================== */

/* Top card — default is NOT sticky; add .pm-top-card--sticky to enable */
.pm-top-card {
    background: var(--color-white, #fff);
    border-radius: var(--radius-medium);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border-subtle);
    padding: var(--space-12) var(--space-20);
    margin-bottom: var(--space-16);
}

/* When user opts in to sticky header */
.pm-top-card--sticky {
    position: sticky;
    top: 0;
    z-index: 10;
}

.pm-top-card__row1 {
    display: flex;
    align-items: center;
    gap: var(--space-8);
    /* Reduced spacing (Planner_UI_Fix §1.3) */
    margin-bottom: var(--space-4);
}

.pm-top-card__row2 {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-8);
}

.pm-top-card__row3 {
    overflow: hidden;
    max-height: 0;
    transition: max-height 0.25s ease, padding-top 0.25s ease;
    padding-top: 0;
}

.pm-top-card--expanded .pm-top-card__row3 {
    max-height: 240px;
    padding-top: var(--space-8);
}

.pm-top-card__badges {
    display: flex;
    flex-wrap: nowrap;
    gap: var(--space-6, 6px);
    overflow: hidden; /* badges that don't fit disappear to the right */
}

/* Bottom row: badges on the left, sticky checkbox + chevron on the right — always one line */
.pm-top-card__bottom-row {
    display: flex;
    align-items: center;
    gap: var(--space-8);
    margin-top: var(--space-6);
    padding-top: var(--space-4);
    border-top: 1px solid var(--color-border-subtle);
}

.pm-top-card__bottom-row .pm-top-card__badges {
    flex: 1 1 0;
    min-width: 0;
}

/* Controls row (sticky checkbox + chevron) — pinned to right of bottom row */
.pm-top-card__header-controls {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: var(--space-8);
    flex-shrink: 0;
}

.pm-top-card__header-controls .pm-checkbox-label {
    font-size: 12px;
    color: var(--color-text-muted);
    gap: var(--space-4);
}

.pm-top-card__header-controls .pm-checkbox-label input[type="checkbox"] {
    width: 14px;
    height: 14px;
}

/* Icon-only button used for the collapse chevron in the header */
.pm-btn-icon {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 2px var(--space-4);
    border-radius: var(--radius-small);
    color: var(--color-text-muted);
    font-size: 14px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
}

.pm-btn-icon:hover {
    background: var(--color-grey-100);
    color: var(--color-text-primary);
}

/* (pm-badge defined above in BADGES section) */

/* 3-column layout (Status page) */
.pm-layout {
    display: flex;
    gap: var(--space-16);
    align-items: flex-start;
}

/* Status page 2-column grid:
   - Left:   fixed 160–260px for pie charts
   - Main:   1fr for charts + attention board / table
*/
.pm-layout--status {
    display: grid;
    grid-template-columns: minmax(160px, 220px) minmax(0, 1fr);
    gap: var(--space-12);
    align-items: stretch;
    min-width: 0;
    /* overflow: clip does not create a scroll container, so position:sticky works */
    overflow: clip;
}

/* Prevent direct children from overflowing their grid cell */
.pm-layout--status > * {
    min-width: 0;
    overflow: clip;
}

/* Section 3 (Planner_UI_Fix) — left charts sticky on Status page.
   align-self:start prevents grid stretch which breaks position:sticky. */
.pm-layout--status .pm-layout__left {
    align-self: start;
    position: sticky;
    top: 0;
}

/* height: auto (was 100%) so that sticky works correctly in grid */
.pm-layout--status .pm-left-charts {
    height: auto;
}

/* ── Status page layout (Planning_Fix.txt) ──────────────────────────────────
   The page scrolls normally (no inner-scroll model).  Charts have a fixed
   height that never shrinks with the viewport.  When the viewport is short
   the page scrolls vertically; charts are never crushed.                  */

/* CSS variables – single source of truth for chart dimensions. */
.pm-page--status {
    --pm-left-chart-height: 230px;
    --pm-chart-gap: 12px;
    --pm-top-chart-height: calc((var(--pm-left-chart-height) * 2) + var(--pm-chart-gap));

    /* Normal page flow – scrolls when content exceeds viewport */
    padding-bottom: var(--space-16);
}

/* Prevent grid stretch from adding height pressure to the layout column */
.pm-page--status .pm-layout--status {
    align-items: start;
}

/* Left column: sticky, never stretches, never scrolls internally */
.pm-page--status .pm-layout__left {
    align-self: start;
    position: sticky;
    top: 0;
    overflow-y: visible;
}

/* Upper row inside .pm-layout__main: bar chart (left) + rose/radar (right)
   Height is content-driven: the bar chart's natural height sets the row. */
/* 3-column horizontal row: Weekly Overview (50%) | Rose (25%) | Radar (25%) */
.pm-status-upper-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: var(--pm-chart-gap);
    margin-bottom: var(--space-8);
    align-items: stretch;
    height: 470px;
}

/* Cards in the upper row fill the row height exactly */
.pm-status-upper-row .pm-card {
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* The bar-chart area fills the card below the title row */
.pm-status-upper-row .pm-chart {
    flex: 1 1 0;
    min-height: 0;
    overflow: hidden;
}

/* Rose/Radar chart-cards (no outer pm-card wrapper) fill the grid cell */
.pm-status-upper-row .pm-chart-card {
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.pm-status-upper-row .pm-chart-card .pm-chart {
    flex: 1 1 0;
    min-height: 0;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

@media (max-width: 1100px) {
    .pm-status-upper-row {
        grid-template-columns: 1fr;
    }
}

.pm-layout__left {
    position: sticky;
    top: 0;
    width: 220px;
    flex-shrink: 0;
    overflow-y: visible;   /* no internal scroll — page scroll only */
    height: auto;
    align-self: flex-start; /* don't stretch to grid row height */
}

.pm-layout__center {
    flex: 2;
    min-width: 0;
}

.pm-layout__right {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: var(--space-12);
}

/* Main scrollable column (Planning page) */
.pm-layout__main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.pm-scroll-main {
    overflow-y: auto;
}

/* Left sidebar chart cards */
.pm-left-charts {
    display: flex;
    flex-direction: column;
    gap: var(--space-8);
    overflow-y: visible;
    height: auto;
}

/* Section 6 (Planner_UI_Fix): reduced padding so pies fill more of the card width.
   Planning_Fix.txt: fixed height prevents left charts from shrinking.      */
.pm-left-chart-card {
    background: var(--color-surface, #fff);
    border: 1px solid var(--color-border, #E2E8F0);
    border-radius: var(--radius-default);
    padding: var(--space-8) var(--space-8) var(--space-4);
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    overflow: visible;
    min-width: 0;
    height: var(--pm-left-chart-height, 230px);
    min-height: var(--pm-left-chart-height, 230px);
}

.pm-left-chart-card:hover {
    border-color: var(--color-primary, #0064b4);
}

.pm-left-chart-card--active {
    background: var(--color-primary, #0064b4);
    border-color: var(--color-primary, #0064b4);
    color: #fff;
}

.pm-left-chart-card--active .pm-chart-title {
    color: #fff;
}

.pm-left-chart-card:not(.pm-left-chart-card--active) {
    border-color: var(--color-primary, #0064b4);
    color: var(--color-primary, #0064b4);
}

.pm-left-chart-pie {
    width: 100%;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: visible;
}

.pm-left-chart-nodata {
    min-height: 160px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    opacity: 0.6;
    text-align: center;
    padding: var(--space-8);
}

/* ── Chart legend ─────────────────────────────────────────────────────── */

.pm-chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-4) var(--space-8);
    margin-top: var(--space-4);
    font-size: 0.75rem;
    color: var(--color-text-secondary, #64748b);
}

.pm-chart-legend-item {
    display: inline-flex;
    align-items: center;
    gap: var(--space-4);
}

.pm-chart-legend-swatch {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 2px;
    flex-shrink: 0;
}

/* ── Chart title as button (AnalysisMode selector) ───────────────────── */

.pm-chart-title--btn {
    background: none;
    border: none;
    padding: 0;
    margin: 0 0 var(--space-4) 0;
    font-size: inherit;
    font-weight: 600;
    color: inherit;
    cursor: pointer;
    text-align: left;
    width: 100%;
}

.pm-chart-title--btn:hover {
    text-decoration: underline;
}

.pm-pie-title--active {
    font-weight: 800;
    text-decoration: underline;
}

/* ── MudBlazor chart legend font size ─────────────────────────────────── */

.pm-chart .mud-charts-legend text {
    font-size: 12px;
}

/* ── Bar chart in status page ─────────────────────────────────────────── */

.pm-bar-chart {
    overflow-x: hidden;
    width: 100%;
}


/* ── Import page ──────────────────────────────────────────────────────── */

.pm-import-drop-zone {
    border: 2px dashed var(--color-border, #ced4da);
    border-radius: 8px;
    padding: 24px 16px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background-color 0.2s;
    background-color: var(--color-surface, #fafafa);
    user-select: none;
}

.pm-import-drop-zone:hover,
.pm-import-drop-zone.has-file {
    border-color: var(--mud-palette-primary, #594ae2);
    background-color: var(--color-surface-hover, #f0f0ff);
}

.pm-import-drop-zone.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pm-import-drop-zone .drop-icon {
    font-size: 2rem;
    display: block;
    margin-bottom: 8px;
}

.pm-import-drop-zone p {
    margin: 4px 0;
}

.pm-import-drop-zone .drop-hint {
    font-size: 0.8rem;
    color: var(--color-text-muted, #6c757d);
}

.pm-import-section {
    margin-bottom: 1.25rem;
}

/* Import preview action badges */
.pm-import-action-insert {
    color: var(--color-success, #198754);
    font-weight: bold;
}

.pm-import-action-update {
    color: var(--mud-palette-primary, #594ae2);
}

.pm-import-action-skip {
    color: var(--color-text-muted, #6c757d);
}

/* Blocking error list inside MudAlert */
.pm-import-error-list {
    margin: 8px 0 0 0;
    padding-left: 20px;
    list-style-type: disc;
}

.pm-import-error-list li {
    margin-bottom: 4px;
    line-height: 1.5;
}

/* Import preview tables */
.pm-import-preview-section {
    margin-top: 1rem;
}

.pm-import-preview-section summary {
    cursor: pointer;
    font-weight: 600;
    padding: 6px 0;
    user-select: none;
}

.pm-import-preview-section summary:hover {
    color: var(--mud-palette-primary, #594ae2);
}

/* ── Bar chart axis font size ─────────────────────────────────────────── */
/* MudBlazor sets font-size inline on SVG text elements; !important is
   required to override inline styles.  Target is 12 px to match legend. */
.pm-bar-chart svg text {
    font-size: 12px !important;
}

.pm-bar-chart .mud-charts-legend text {
    font-size: 12px !important;
}

/* ===============================================================================
   ATTENTION BOARD (Status page — PlannerOverview Session 3)
   =============================================================================== */

/* ── Legend ─────────────────────────────────────────────────────────── */

.pm-attention-legend {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-8);
    font-size: var(--font-size-xs, 0.75rem);
    color: var(--color-text-secondary, #6b7280);
    margin-bottom: var(--space-8);
}

.pm-attention-legend__item {
    display: flex;
    align-items: center;
    gap: var(--space-4);
}

.pm-attention-legend__dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* ── Board ──────────────────────────────────────────────────────────── */

.pm-attention-board {
    display: flex;
    gap: var(--space-12);
    overflow-x: auto;
    min-height: 320px;
    align-items: flex-start;
}

.pm-attention-col {
    flex: 1 1 200px;
    min-width: 180px;
    display: flex;
    flex-direction: column;
    gap: var(--space-8);
}

.pm-attention-col__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-8) var(--space-10);
    background: var(--color-grey-100, #f3f4f6);
    border-radius: var(--radius-medium);
    font-weight: 600;
    font-size: var(--font-size-sm, 0.8125rem);
}

.pm-attention-col__badge {
    background: var(--color-grey-300, #d1d5db);
    color: var(--color-text-secondary, #6b7280);
    border-radius: var(--radius-full, 9999px);
    font-size: var(--font-size-xs, 0.75rem);
    font-weight: 600;
    min-width: 20px;
    text-align: center;
    padding: 1px 6px;
}

.pm-attention-col__body {
    display: flex;
    flex-direction: column;
    gap: var(--space-6);
    overflow-y: auto;
    /* Max-cards limit: set via --pm-col-max-cards on the element (≈76px per card + 6px gap) */
    max-height: calc(var(--pm-col-max-cards, 10) * 82px);
}

.pm-attention-col__empty {
    font-size: var(--font-size-sm, 0.8125rem);
    color: var(--color-text-secondary, #6b7280);
    text-align: center;
    padding: var(--space-10) 0;
    font-style: italic;
}

/* ── Card ───────────────────────────────────────────────────────────── */

.pm-attention-card {
    padding: var(--space-8) var(--space-10);
    border-radius: var(--radius-medium);
    border: 1px solid var(--color-border-subtle);
    background-color: color-mix(in srgb, var(--card-accent, transparent) 15%, var(--color-surface-1, #fff));
    cursor: pointer;
    transition: box-shadow 0.15s;
    outline: none;
}

.pm-attention-card:hover,
.pm-attention-card:focus-visible {
    box-shadow: var(--shadow-sm, 0 1px 3px rgba(0,0,0,.12));
    border-color: var(--color-border);
}

.pm-attention-card--overdue {
    border-left: 3px solid var(--color-error, #ef4444);
}

.pm-attention-card__row1 {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-6);
    margin-bottom: var(--space-4);
}

.pm-attention-card__name {
    font-weight: 500;
    font-size: var(--font-size-sm, 0.8125rem);
    /* Clamp to 2 lines */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    flex: 1 1 0;
    word-break: break-word;
}

.pm-attention-card__kind-badge {
    font-size: var(--font-size-xs, 0.75rem);
    padding: 1px 6px;
    border-radius: var(--radius-full, 9999px);
    background: color-mix(in srgb, var(--card-taskkind) 20%, transparent);
    color: var(--card-taskkind);
    white-space: nowrap;
    flex-shrink: 0;
    line-height: 1.5;
}

.pm-attention-card__row2 {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-6);
    font-size: var(--font-size-xs, 0.75rem);
    color: var(--color-text-secondary, #6b7280);
}

.pm-attention-card__date {
    white-space: nowrap;
    flex-shrink: 0;
}

/* ── Responsive ─────────────────────────────────────────────────────── */

@media (max-width: 900px) {
    .pm-attention-board { flex-wrap: wrap; }
    .pm-attention-col   { flex: 1 1 45%; }
}

@media (max-width: 600px) {
    .pm-attention-col { flex: 1 1 100%; }
}

/* ── Detail Panel (PlannerOverview Session 4) ───────────────────────────── */

.pm-attention-detail {
    position: sticky;
    bottom: 0;
    background: var(--color-surface-1, #fff);
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-medium);
    padding: var(--space-12);
    margin-top: var(--space-10);
}

.pm-attention-detail__header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--space-8);
    font-weight: 600;
    font-size: var(--font-size-sm, 0.8125rem);
    margin-bottom: var(--space-8);
}

.pm-attention-detail__close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    color: var(--color-text-secondary, #6b7280);
    flex-shrink: 0;
    line-height: 1;
}

.pm-attention-detail__close:hover {
    color: var(--color-text-primary, #111827);
}

.pm-attention-detail__body {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: var(--space-4) var(--space-12);
    font-size: var(--font-size-sm, 0.8125rem);
    margin: 0;
}

.pm-attention-detail__body dt {
    color: var(--color-text-secondary, #6b7280);
    white-space: nowrap;
}

.pm-attention-detail__body dd {
    margin: 0;
    word-break: break-word;
}

.pm-attention-detail__events {
    margin-top: var(--space-8);
    font-size: var(--font-size-xs, 0.75rem);
}

.pm-attention-detail__events strong {
    display: block;
    margin-bottom: var(--space-4);
    font-size: var(--font-size-sm, 0.8125rem);
}

.pm-attention-detail__event-row {
    display: flex;
    gap: var(--space-10);
    padding: var(--space-4) 0;
    border-bottom: 1px solid var(--color-border-subtle);
    color: var(--color-text-secondary, #6b7280);
}

/* ── Hover tooltip (Planning_Fix.txt §tooltip) ──────────────────────────────
   Primary blue background, white text – consistent with timeline diagram
   tooltips.  MudTooltip portals the content outside the overflow clip.   */

.pm-attention-tooltip {
    min-width: 260px;
    max-width: 320px;
    font-size: var(--font-size-sm, 0.8125rem);
    color: #fff;
    background: var(--color-primary, #0064b4);
    border-radius: var(--radius-default, 6px);
    padding: var(--space-12, 12px) var(--space-16, 16px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.24);
}

.pm-attention-tooltip__title {
    font-weight: 600;
    font-size: var(--font-size-sm, 0.8125rem);
    margin-bottom: var(--space-8);
    word-break: break-word;
    color: #fff;
}

/* MudBlazor renders the tooltip surface with mud-theme-surface; reinforce
   colours so tooltip reads correctly in both light and dark themes.       */
.mud-tooltip .pm-attention-tooltip {
    color: #fff;
    background: var(--color-primary, #0064b4);
}

/* Ensure all child text inside the tooltip is white (dt/dd default to
   secondary grey which is illegible against the blue background).        */
.pm-attention-tooltip .pm-attention-detail__body dt,
.pm-attention-tooltip .pm-attention-detail__body dd,
.pm-attention-tooltip .pm-attention-detail__events strong,
.pm-attention-tooltip .pm-attention-detail__event-row {
    color: #fff;
}

.pm-attention-tooltip .pm-attention-detail__event-row {
    border-bottom-color: rgba(255, 255, 255, 0.2);
}
