:root {
    --primary: #0066cc;
    --urgent: #dc3545;
    --active: #fd7e14;
    --blocked: #6c757d;
    --done: #28a745;
    --review: #0c8ea4;
    --bg: #f8f9fa;
    --card-bg: #ffffff;
    --text: #212529;
    --text-light: #6c757d;
    --border: #dee2e6;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
header {
    background: var(--card-bg);
    padding: 30px;
    border-radius: 12px;
    margin-bottom: 30px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 {
    font-size: 32px;
    color: var(--primary);
    margin-bottom: 5px;
}

.subtitle {
    color: var(--text-light);
    font-size: 14px;
}

.header-meta {
    display: flex;
    align-items: center;
    gap: 15px;
}

#last-updated {
    color: var(--text-light);
    font-size: 13px;
}

.btn-refresh {
    background: var(--primary);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s;
}

.btn-refresh:hover {
    background: #0052a3;
    transform: translateY(-1px);
}

/* Summary Cards */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.card {
    background: var(--card-bg);
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    gap: 20px;
    transition: transform 0.2s;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.card-icon {
    font-size: 48px;
}

.card-content h3 {
    font-size: 36px;
    font-weight: 700;
    margin-bottom: 5px;
}

.card-content p {
    color: var(--text-light);
    font-size: 14px;
}

.card-urgent  { border-left: 4px solid var(--urgent); }
.card-active  { border-left: 4px solid var(--active); }
.card-blocked { border-left: 4px solid var(--blocked); }
.card-done    { border-left: 4px solid var(--done); }
.card-review  { border-left: 4px solid var(--review); }

/* Section */
.section {
    background: var(--card-bg);
    padding: 25px;
    border-radius: 12px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.section h2 {
    font-size: 20px;
    margin-bottom: 20px;
    color: var(--text);
}

/* Issue List */
.issue-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.issue-item {
    background: var(--bg);
    padding: 15px;
    border-radius: 8px;
    border-left: 4px solid var(--border);
    transition: all 0.2s;
}

.issue-item:hover {
    background: #e9ecef;
    border-left-color: var(--primary);
}

.issue-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}

.issue-id {
    font-weight: 700;
    color: var(--primary);
    font-size: 13px;
}

.issue-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 5px;
}

.issue-meta {
    display: flex;
    gap: 15px;
    font-size: 13px;
    color: var(--text-light);
    flex-wrap: wrap;
}

.issue-meta span {
    display: flex;
    align-items: center;
    gap: 5px;
}

.priority-urgent { color: var(--urgent); font-weight: 600; }
.priority-high   { color: var(--active); font-weight: 600; }

.due-soon {
    background: #fff3cd;
    color: #856404;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 600;
}

.status-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.status-active      { background: #fff3cd; color: #856404; }
.status-blocked     { background: #f8d7da; color: #721c24; }
.status-in-review   { background: #d1ecf1; color: #0c5460; }
.status-in-progress { background: #cce5ff; color: #004085; }

/* Chart */
.chart-container {
    position: relative;
    height: 300px;
    padding: 20px 0;
}

/* Loading */
.loading {
    text-align: center;
    color: var(--text-light);
    padding: 20px;
    font-style: italic;
}

/* Footer */
footer {
    text-align: center;
    color: var(--text-light);
    font-size: 13px;
    padding: 20px;
    margin-top: 30px;
}

/* ─── Gantt Chart ─────────────────────────────────────────────────────────── */

/* Outer wrapper scrolls horizontally on small screens */
.gantt-wrap {
    overflow-x: auto;
    padding: 0 20px 12px;
}

.gantt-row {
    display: flex;
    align-items: stretch;
    border-bottom: 1px solid #f0f2f4;
    min-height: 54px;
}

/* Fixed-width label column — sticky so it stays visible when timeline scrolls */
.gantt-label {
    flex: 0 0 240px;
    min-width: 0;
    padding: 6px 12px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
    overflow: hidden;
    white-space: nowrap;
    position: sticky;
    left: 0;
    z-index: 20;
    background: inherit;
}

.gantt-header-row { background: var(--card-bg); }

.gantt-label a {
    color: var(--text);
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gantt-label a:hover {
    color: var(--primary);
    text-decoration: underline;
}

.gantt-indent {
    color: var(--text-light);
    flex-shrink: 0;
}

/* Flexible timeline column — min-width set dynamically via JS */
.gantt-timeline {
    flex: 1;
    position: relative;
    min-width: var(--gantt-tl-width, 700px);
    min-height: 54px;
}

/* Header row: taller to fit month labels */
.gantt-header-row {
    border-bottom: 2px solid var(--border);
}

.gantt-header-timeline {
    min-height: 44px;
}

/* Month grid markers (in header only) */
.gantt-month-mark {
    position: absolute;
    top: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
}

.gantt-grid-line {
    position: absolute;
    top: 0;
    bottom: -9999px; /* extend through all rows */
    width: 1px;
    background: #e9ecef;
    pointer-events: none;
}

.gantt-month-label {
    position: absolute;
    top: 4px;
    font-size: 11px;
    color: var(--text-light);
    white-space: nowrap;
    padding-left: 4px;
    user-select: none;
}

/* Today vertical line */
.gantt-today-line {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background: rgba(220, 53, 69, 0.35);
    pointer-events: none;
    z-index: 5;
}

.gantt-today-header {
    background: rgba(220, 53, 69, 0.6);
}

.gantt-today-label {
    position: absolute;
    top: 26px;
    left: 4px;
    font-size: 10px;
    font-weight: 600;
    color: var(--urgent);
    white-space: nowrap;
}

/* Initiative rows */
.gantt-initiative-row {
    background: #f8f9fb;
}

.gantt-initiative-row + .gantt-initiative-row {
    margin-top: 4px;
}

.gantt-initiative-label {
    font-weight: 700;
    font-size: 14px;
    color: var(--primary);
}

/* Thin initiative span bar */
.gantt-initiative-bar {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    height: 6px;
    border-radius: 3px;
    background: var(--primary);
    opacity: 0.4;
    min-width: 4px;
    z-index: 4;
}

/* Project rows */
.gantt-project-row {
    background: white;
}

.gantt-project-row:hover {
    background: #f5f8ff;
}

/* Project bars */
.gantt-bar {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    height: 33px;
    border-radius: 4px;
    min-width: 4px;
    z-index: 10;
    display: flex;
    align-items: center;
    padding: 0 7px;
    overflow: hidden;
    cursor: default;
}

.gantt-bar span {
    font-size: 11px;
    font-weight: 500;
    color: white;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bar-active    { background: #3b82f6; }
.bar-completed { background: #22c55e; }
.bar-cancelled { background: #9ca3af; }
.bar-paused    { background: #f59e0b; }
.bar-backlog   { background: #93c5fd; }
.bar-overdue   { background: var(--urgent); }

/* No-dates placeholder */
.gantt-no-date {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    left: 10px;
    font-size: 11px;
    color: #adb5bd;
    font-style: italic;
}

/* Status pills (project label area) */
.gantt-pill {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0;
}

.pill-active    { background: #dbeafe; color: #1d4ed8; }
.pill-completed { background: #dcfce7; color: #166534; }
.pill-cancelled { background: #f3f4f6; color: #6b7280; }
.pill-overdue   { background: #fee2e2; color: #991b1b; }
.pill-default   { background: #e0eaff; color: #3b4fc8; }

/* Gantt legend */
.gantt-legend {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-light);
}

.gantt-legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

.gantt-legend-swatch {
    width: 14px;
    height: 10px;
    border-radius: 2px;
}

/* ─── Full-width Gantt section ────────────────────────────────────────────── */

.section-full {
    background: var(--card-bg);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin: 0 2rem 20px;
    border-radius: 12px;
    padding-top: 25px;
    padding-bottom: 20px;
    overflow: hidden;
}

.gantt-inner-header {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.gantt-inner-header h2 {
    font-size: 20px;
    color: var(--text);
}

/* Scale controls */
.gantt-scale-controls {
    display: flex;
    align-items: center;
    gap: 6px;
}

.gantt-scale-label {
    font-size: 13px;
    color: var(--text-light);
    margin-right: 2px;
}

.gantt-range-input {
    width: 56px;
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    text-align: right;
    background: white;
    color: var(--text);
    -moz-appearance: textfield;
}

.gantt-range-input::-webkit-outer-spin-button,
.gantt-range-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.gantt-range-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(0,102,204,0.15);
}

.gantt-scale-hint {
    font-size: 11px;
    color: #adb5bd;
    white-space: nowrap;
}

/* Accordion toggle row */
.gantt-accordion-row {
    background: #f0f4f8;
    cursor: pointer;
    user-select: none;
}

.gantt-accordion-row:hover {
    background: #e4ecf5;
}

.gantt-accordion-label {
    color: var(--text-light);
    font-size: 12px;
    font-style: italic;
    gap: 5px;
}

.gantt-accordion-icon {
    font-size: 9px;
    flex-shrink: 0;
}

/* Fade right edge for bars with no end date */
.gantt-bar-fade-end {
    -webkit-mask-image: linear-gradient(to right, black 50%, transparent 100%);
    mask-image: linear-gradient(to right, black 50%, transparent 100%);
}

/* Responsive */
@media (max-width: 768px) {
    header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }

    .summary-cards {
        grid-template-columns: 1fr;
    }

    .issue-header {
        flex-direction: column;
        gap: 5px;
    }

    .gantt-label {
        flex: 0 0 160px;
        font-size: 12px;
    }
}
