/* ── Google Fonts (loaded via HTML preconnect + link) ── */

/* ── Design Tokens ── */
:root {
    --primary: #6366f1;        /* Indigo 500 */
    --primary-dark: #4f46e5;   /* Indigo 600 */
    --primary-light: #818cf8;  /* Indigo 400 */
    --primary-bg: #eef2ff;     /* Indigo 50 */

    --accent: #8b5cf6;         /* Violet 500 */
    --accent-bg: #f5f3ff;

    --bg-main: #f1f5f9;        /* Slate 100 */
    --bg-surface: #f8fafc;     /* Slightly lighter surface */
    --card-bg: #ffffff;
    --card-shadow: 0 1px 3px rgb(0 0 0 / .08), 0 4px 16px rgb(99 102 241 / .06);
    --card-shadow-hover: 0 4px 12px rgb(0 0 0 / .1), 0 8px 24px rgb(99 102 241 / .1);

    --text-main: #0f172a;      /* Slate 900 */
    --text-sub: #334155;       /* Slate 700 */
    --text-muted: #64748b;     /* Slate 500 */
    --text-faint: #94a3b8;     /* Slate 400 */

    --border-color: #e2e8f0;   /* Slate 200 */
    --border-subtle: #f1f5f9;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;

    --transition: 0.18s ease;

    /* Type Colors */
    --color-job: #4f46e5;
    --bg-job: #eef2ff;
    --color-skill: #7c3aed;
    --bg-skill: #f5f3ff;
    --color-rule: #059669;
    --bg-rule: #ecfdf5;
    --color-mentoring: #d97706;
    --bg-mentoring: #fffbeb;

    /* Success Colors */
    --success-high: #10b981;
    --success-medium: #f59e0b;
    --success-low: #ef4444;

    /* Stat card accent colors */
    --stat-total: #6366f1;
    --stat-success: #10b981;
}

/* ── Reset ── */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ── Base ── */
html { scroll-behavior: smooth; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
    background: var(--bg-main);
    color: var(--text-main);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ── Container ── */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 28px 24px 48px;
}

/* ── Header ── */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
    padding: 20px 24px;
    background: linear-gradient(135deg, #1e1b4b 0%, #312e81 45%, #4338ca 100%);
    border-radius: var(--radius-lg);
    box-shadow: 0 4px 20px rgb(99 102 241 / .25);
    position: relative;
    overflow: hidden;
}

.header::before {
    content: '';
    position: absolute;
    inset: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    pointer-events: none;
}

.header h1 {
    font-size: clamp(18px, 3vw, 24px);
    font-weight: 700;
    color: #fff;
    letter-spacing: -0.3px;
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative;
}

.header h1::before {
    content: '◈';
    font-size: 1.1em;
    opacity: 0.85;
    color: #a5b4fc;
}

.header-controls {
    display: flex;
    gap: 12px;
    align-items: center;
    position: relative;
}

.admin-controls {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 6px 12px;
    background: rgb(255 255 255 / .15);
    border: 1px solid rgb(255 255 255 / .25);
    border-radius: var(--radius-md);
    font-size: 13px;
    backdrop-filter: blur(8px);
}

.admin-controls label {
    font-weight: 500;
    color: #c7d2fe;
}

.user-select {
    padding: 4px 8px;
    border: 1px solid rgb(255 255 255 / .3);
    border-radius: var(--radius-sm);
    background: rgb(255 255 255 / .1);
    color: #fff;
    font-size: 13px;
    cursor: pointer;
    min-width: 140px;
}

.user-select option {
    background: #312e81;
    color: #fff;
}

.repo-selector {
    padding: 6px 32px 6px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-surface);
    color: var(--text-main);
    font-size: 13px;
    cursor: pointer;
    min-width: 180px;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    transition: border-color var(--transition), background var(--transition);
}

.repo-selector:hover {
    border-color: var(--primary-light);
    background: #fff;
}

.repo-selector:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 2px rgb(99 102 241 / .2);
}

.repo-selector option {
    background: #fff;
    color: var(--text-main);
}

.analytics-inline-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 14px;
    flex-wrap: wrap;
}

.analytics-inline-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-faint);
    text-transform: uppercase;
    letter-spacing: .06em;
}

.team-activity-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 4px;
    flex-wrap: wrap;
}

.page-toolbar {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
    padding: 12px 16px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: 0 1px 3px rgb(15 23 42 / .06);
    flex-wrap: wrap;
}

.page-toolbar .team-member-period-bar {
    padding: 0;
}

.custom-period-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.custom-date-input {
    min-height: 32px;
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-surface);
    color: var(--text-main);
    font-size: 13px;
}

.custom-date-input:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 2px rgb(99 102 241 / .2);
}

/* ── Toolbar (period + export) ── */
.team-member-period-bar {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px 0 14px;
    flex-wrap: wrap;
}

.team-member-period-bar > span {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-faint);
    text-transform: uppercase;
    letter-spacing: .06em;
    margin-right: 4px;
}

.team-period-btn {
    padding: 5px 12px;
    border-radius: var(--radius-xl);
    border: 1.5px solid var(--border-color);
    background: var(--card-bg);
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    transition: background var(--transition), color var(--transition), border-color var(--transition), box-shadow var(--transition);
    white-space: nowrap;
    min-height: 32px;
}

.team-period-btn:hover {
    border-color: var(--primary-light);
    color: var(--primary-dark);
    background: var(--primary-bg);
}

.team-period-btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgb(99 102 241 / .35);
}

/* ── Export Button ── */
.export-btn {
    padding: 6px 14px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-xl);
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .02em;
    transition: background var(--transition), box-shadow var(--transition), transform var(--transition);
    min-height: 32px;
    white-space: nowrap;
}

.export-btn:hover {
    background: var(--primary-dark);
    box-shadow: 0 4px 12px rgb(99 102 241 / .4);
    transform: translateY(-1px);
}

.export-btn:active { transform: translateY(0); }

/* ── Manager Notice ── */
.manager-notice {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--primary-bg);
    border: 1px solid #c7d2fe;
    border-left: 4px solid var(--primary);
    border-radius: var(--radius-md);
    padding: 10px 16px;
    font-size: 13px;
    color: var(--primary-dark);
    margin-bottom: 24px;
}

/* ── Stats Grid ── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--card-bg);
    padding: 20px 24px;
    border-radius: var(--radius-lg);
    box-shadow: var(--card-shadow);
    text-align: left;
    position: relative;
    overflow: hidden;
    transition: box-shadow var(--transition), transform var(--transition);
    border-top: 3px solid transparent;
}

.stat-card:nth-child(1) { border-top-color: var(--stat-total); }
.stat-card:nth-child(2) { border-top-color: var(--stat-success); }
.stat-card:nth-child(3) { border-top-color: var(--accent); }

.stat-card::after {
    content: '';
    position: absolute;
    top: -20px;
    right: -20px;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    opacity: .04;
    background: var(--primary);
}

.stat-card:hover {
    box-shadow: var(--card-shadow-hover);
    transform: translateY(-2px);
}

.stat-card h3 {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-faint);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: .07em;
}

.stat-value {
    font-size: 36px;
    font-weight: 800;
    color: var(--text-main);
    letter-spacing: -1px;
    line-height: 1.1;
}

/* ── Charts Grid ── */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.chart-container {
    background: var(--card-bg);
    padding: 20px;
    border-radius: var(--radius-lg);
    box-shadow: var(--card-shadow);
    transition: box-shadow var(--transition);
}

.chart-container:hover { box-shadow: var(--card-shadow-hover); }

.chart-container h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-sub);
    margin-bottom: 14px;
    text-transform: uppercase;
    letter-spacing: .05em;
}

.chart-container canvas {
    max-height: 300px;
}

/* ── Components Table ── */
.components-table-container {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--card-shadow);
    overflow: hidden;
    transition: box-shadow var(--transition);
}

.components-table-container:hover { box-shadow: var(--card-shadow-hover); }

.components-table-container > div:first-child {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-surface);
}

.components-table-container h3 {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-sub);
    text-transform: uppercase;
    letter-spacing: .06em;
    padding: 0;
}

.table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.components-table { width: 100%; border-collapse: collapse; }

.components-table th {
    background: var(--bg-surface);
    padding: 10px 16px;
    text-align: left;
    font-weight: 700;
    font-size: 11px;
    color: var(--text-faint);
    text-transform: uppercase;
    letter-spacing: .06em;
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
}

.components-table th.sort-asc::after { content: ' ▲'; font-size: 9px; }
.components-table th.sort-desc::after { content: ' ▼'; font-size: 9px; }

.components-table td {
    padding: 11px 16px;
    border-bottom: 1px solid var(--border-subtle);
    font-size: 13px;
    color: var(--text-sub);
}

.components-table tbody tr {
    transition: background var(--transition);
}

.components-table tbody tr:hover {
    background: var(--primary-bg);
    cursor: pointer;
}

.components-table tbody tr:last-child td { border-bottom: none; }

/* ── Type Badges ── */
.type-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 9px;
    border-radius: var(--radius-xl);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.type-badge.job      { background: var(--bg-job);      color: var(--color-job); }
.type-badge.skill    { background: var(--bg-skill);    color: var(--color-skill); }
.type-badge.rule     { background: var(--bg-rule);     color: var(--color-rule); }
.type-badge.mentoring { background: var(--bg-mentoring); color: var(--color-mentoring); }

/* ── Success Rate ── */
.success-rate { font-weight: 600; }
.success-rate.high   { color: var(--success-high); }
.success-rate.medium { color: var(--success-medium); }
.success-rate.low    { color: var(--success-low); }

/* ── Loading / Error / Empty ── */
.loading {
    text-align: center;
    color: var(--text-faint);
    font-style: italic;
    padding: 32px !important;
}

.loading-spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2.5px solid var(--border-color);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.error-message {
    background: #fef2f2;
    color: #991b1b;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    margin: 16px 0;
    border: 1px solid #fecaca;
    font-size: 13px;
}

.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-faint);
}

.empty-state h4 { font-size: 16px; margin-bottom: 6px; color: var(--text-muted); }
.empty-state p  { font-size: 13px; }

/* ── Section Collapsible (You / Your Team) ── */
.section-item {
    border-radius: var(--radius-lg);
    background: var(--card-bg);
    box-shadow: var(--card-shadow);
    margin-top: 20px;
    overflow: hidden;
    transition: box-shadow var(--transition);
}

.section-item:hover { box-shadow: var(--card-shadow-hover); }

.section-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 20px;
    cursor: pointer;
    user-select: none;
    background: var(--card-bg);
    border-bottom: 2px solid transparent;
    transition: background var(--transition), border-color var(--transition);
}

.section-header:hover {
    background: var(--primary-bg);
    border-bottom-color: var(--primary-bg);
}

.section-item.open .section-header {
    border-bottom-color: var(--border-color);
}

.section-header h2 {
    font-size: 16px;
    font-weight: 700;
    flex: 1;
    min-width: 0;
    color: var(--text-main);
    letter-spacing: -0.2px;
    transition: color var(--transition);
}

.section-header:hover h2 { color: var(--primary); }

.section-chevron {
    flex-shrink: 0;
    transition: transform 0.25s cubic-bezier(.4,0,.2,1);
    color: var(--text-faint);
}

.section-item.open .section-chevron { transform: rotate(180deg); }

.section-body { display: none; padding: 20px; }
.section-item.open .section-body { display: block; }

/* ── Team Member Count Badge ── */
#teamMemberCount {
    background: var(--primary-bg);
    color: var(--primary-dark);
    border-radius: var(--radius-xl);
    padding: 3px 10px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .02em;
}

/* ── Team Accordion ── */
.team-accordion-item {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: 8px;
    overflow: hidden;
    transition: box-shadow var(--transition), border-color var(--transition);
}

.team-accordion-item:hover {
    border-color: #c7d2fe;
    box-shadow: 0 2px 12px rgb(99 102 241 / .08);
}

.team-accordion-item.open {
    border-color: var(--primary-light);
    box-shadow: 0 4px 16px rgb(99 102 241 / .12);
}

.team-accordion-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    cursor: pointer;
    user-select: none;
    transition: background var(--transition);
}

.team-accordion-header:hover { background: var(--primary-bg); }

.team-accordion-item.open .team-accordion-header {
    background: linear-gradient(90deg, var(--primary-bg) 0%, #fff 100%);
}

.team-member-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 13px;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgb(99 102 241 / .3);
}

.team-member-info  { flex: 1; min-width: 0; }
.team-member-name  { font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-main); }
.team-member-email { font-size: 11px; color: var(--text-faint); }
.team-member-labels { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.team-label-badge {
    padding: 2px 7px;
    border-radius: var(--radius-sm);
    font-size: 10px;
    font-weight: 700;
    background: #ecfdf5;
    color: #047857;
    border: 1px solid #a7f3d0;
    max-width: 140px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.team-category-badge {
    padding: 3px 10px;
    border-radius: var(--radius-xl);
    font-size: 11px;
    font-weight: 700;
    background: var(--primary-bg);
    color: var(--primary-dark);
    white-space: nowrap;
    flex-shrink: 0;
    letter-spacing: .03em;
}

.key-expiry-pill {
    display: inline-flex;
    align-items: center;
    max-width: 200px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 0;
}

.key-expiry-pill.is-active {
    background: rgba(16, 185, 129, 0.12);
    border: 1px solid rgba(16, 185, 129, 0.35);
    color: var(--success-high);
}

.key-expiry-pill.is-expired {
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.35);
    color: var(--success-low);
}

.key-expiry-pill.is-unavailable {
    background: rgba(148, 163, 184, 0.14);
    border: 1px solid rgba(148, 163, 184, 0.3);
    color: var(--text-muted);
}

.team-member-meta   { text-align: right; flex-shrink: 0; }
.team-member-meta .last-active { font-size: 11px; color: var(--text-faint); }
.team-member-meta .event-count { font-size: 11px; color: var(--text-faint); font-weight: 600; }

.team-chevron {
    flex-shrink: 0;
    transition: transform 0.25s cubic-bezier(.4,0,.2,1);
    color: var(--text-faint);
}

.team-accordion-item.open .team-chevron { transform: rotate(180deg); }

.team-accordion-body {
    display: none;
    padding: 0 16px 16px;
    border-top: 1px solid var(--border-subtle);
}

.team-accordion-item.open .team-accordion-body { display: block; }

/* ── Team Stats ── */
.team-member-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 12px;
}

.team-stat-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    transition: box-shadow var(--transition);
}

.team-stat-card:hover { box-shadow: 0 2px 8px rgb(0 0 0 / .06); }

.team-stat-label {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-faint);
    text-transform: uppercase;
    letter-spacing: .06em;
    margin-bottom: 4px;
}

.team-stat-value {
    font-size: 22px;
    font-weight: 800;
    color: var(--text-main);
    letter-spacing: -.5px;
    line-height: 1.1;
}

/* ── Team Charts ── */
.team-charts-row {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 10px;
}

.team-chart-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px;
    transition: box-shadow var(--transition);
}

.team-chart-card:hover { box-shadow: 0 2px 8px rgb(0 0 0 / .06); }

.team-chart-title {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-faint);
    text-transform: uppercase;
    letter-spacing: .07em;
    margin-bottom: 8px;
}

/* ── Legacy admin table styles ── */
.period-select, .rollup-select {
    padding: 6px 10px;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-sm);
    outline: none;
    cursor: pointer;
    background: var(--card-bg);
    font-size: 13px;
}

.period-select:focus, .rollup-select:focus { border-color: var(--primary); }

.user-info { background: var(--bg-surface); padding: 1rem; border-radius: var(--radius-md); margin: 1rem 0; border-left: 4px solid var(--primary); }
.user-info h3 { margin: 0 0 .5rem; color: var(--primary); }
.user-info p  { margin: .25rem 0; font-size: .875rem; }

.users-table { width: 100%; border-collapse: collapse; margin-top: 1rem; }
.users-table th, .users-table td { padding: .75rem; text-align: left; border-bottom: 1px solid var(--border-color); font-size: 13px; }
.users-table th { background: var(--bg-surface); font-weight: 700; color: var(--text-faint); text-transform: uppercase; font-size: 11px; letter-spacing: .05em; }
.users-table code { background: var(--bg-main); padding: .15rem .4rem; border-radius: 4px; font-size: .8rem; }

.status { padding: .15rem .5rem; border-radius: var(--radius-xl); font-size: .75rem; font-weight: 600; }
.status.active    { background: #d1fae5; color: #065f46; }
.status.suspended { background: #fee2e2; color: #991b1b; }
.status.expired   { background: #fef9c3; color: #854d0e; }

.btn-small { padding: .3rem .6rem; font-size: .75rem; background: var(--primary); color: #fff; border: none; border-radius: var(--radius-sm); cursor: pointer; }
.btn-small:hover { background: var(--primary-dark); }

.btn-secondary { padding: .5rem 1rem; background: var(--text-muted); color: #fff; border: none; border-radius: var(--radius-sm); cursor: pointer; }
.btn-secondary:hover { background: #475569; }

/* ── Responsive ── */
@media (max-width: 768px) {
    .container {
        padding: 16px 14px 40px;
    }

    /* Reduce fixed-height timeline card on mobile */
    .chart-container[style*="height: 400px"] {
        height: 280px !important;
    }

    .header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
        padding: 16px;
        margin-bottom: 20px;
        border-radius: var(--radius-md);
    }

    .header h1 { font-size: 18px; }

    .header-controls { width: 100%; }
    .admin-controls   { width: 100%; }
    .user-select      { flex: 1; }

    .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
    .stat-value { font-size: 28px; }

    .charts-grid {
        grid-template-columns: 1fr;
        gap: 12px;
        margin-bottom: 16px;
    }

    .chart-container { padding: 14px; }

    .section-item { margin-top: 14px; }
    .section-header { padding: 14px 16px; }
    .section-item.open .section-body { padding: 14px 16px; }

    .team-member-period-bar { gap: 4px; }
    .team-period-btn { padding: 5px 10px; font-size: 11px; }
    .export-btn { padding: 6px 12px; font-size: 11px; }

    .components-table th,
    .components-table td { padding: 9px 12px; font-size: 12px; }

    .team-member-stats { grid-template-columns: 1fr 1fr; }
    .team-accordion-header { padding: 10px 12px; gap: 10px; }
    .team-member-avatar { width: 34px; height: 34px; font-size: 12px; }
    .team-category-badge { display: none; } /* hide on small screens to save space */
    .key-expiry-pill { max-width: 160px; }
    .team-member-labels { display: none; }

    .team-charts-row { grid-template-columns: 1fr; }
    .team-member-meta { display: none; } /* truncate on mobile */
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; gap: 10px; }
    .stat-card  { padding: 16px 18px; }
    .stat-value { font-size: 30px; }
    .header h1  { font-size: 16px; }
}

/* ── Timeline chart header ── */
.timeline-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

/* ── Job Runs & Phase Timeline ── */
.components-table tbody tr { cursor: pointer; }
.components-table tbody tr:hover { background: var(--primary-bg); }

.job-runs-list { display: flex; flex-direction: column; gap: 8px; }
.job-run-card {
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px 16px; background: var(--card-bg); border: 1px solid var(--border-color);
    border-radius: 8px; cursor: pointer; transition: border-color 0.15s;
}
.job-run-card:hover { border-color: var(--primary); }
.job-run-status { font-size: 0.75rem; font-weight: 600; padding: 2px 8px; border-radius: 12px; }
.job-run-status.completed { background: #dcfce7; color: #166534; }
.job-run-status.in-progress { background: #fef9c3; color: #854d0e; }
.job-run-duration { font-size: 0.85rem; color: var(--text-muted); }
.job-run-date { font-size: 0.8rem; color: var(--text-faint); }

.run-stage-status {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 10px 12px;
    margin-bottom: 12px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-left: 3px solid var(--primary);
    border-radius: 8px;
    color: var(--text-sub);
    font-size: 0.85rem;
}
.run-stage-status strong {
    color: var(--text-main);
    font-size: 0.9rem;
}
.run-stage-status.finalized { border-left-color: #22c55e; }
.run-stage-status.loaded-only,
.run-stage-status.drafted,
.run-stage-status.reviewed,
.run-stage-status.applied { border-left-color: #f59e0b; }
.run-stage-status.partial { border-left-color: var(--primary); }

.run-stage-tracker {
    display: flex;
    align-items: flex-start;
    gap: 0;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 4px 2px 18px;
    margin-bottom: 14px;
    border-bottom: 1px solid var(--border-color);
}
.run-stage-step {
    position: relative;
    min-width: 118px;
    flex: 1 0 118px;
    text-align: center;
    color: var(--text-muted);
}
.run-stage-line {
    position: absolute;
    top: 14px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--border-color);
}
.run-stage-step:first-child .run-stage-line { left: 50%; }
.run-stage-step:last-child .run-stage-line { right: 50%; }
.run-stage-dot {
    position: relative;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 2px solid var(--border-color);
    background: var(--bg);
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 700;
}
.run-stage-step.done .run-stage-dot {
    background: #22c55e;
    border-color: #22c55e;
    color: white;
}
.run-stage-step.current .run-stage-dot {
    border-color: var(--primary);
    color: var(--primary);
}
.run-stage-step.missing .run-stage-dot {
    background: var(--card-bg);
    border-style: dashed;
}
.run-stage-step.done .run-stage-line { background: #bbf7d0; }
.run-stage-label {
    margin-top: 8px;
    padding: 0 6px;
    color: var(--text-main);
    font-size: 0.78rem;
    font-weight: 600;
    line-height: 1.25;
}
.run-stage-state {
    margin-top: 3px;
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-faint);
}
.run-stage-step.done .run-stage-state { color: #166534; }
.run-stage-step.current .run-stage-state { color: var(--primary); }

.phase-timeline { display: flex; flex-direction: column; gap: 0; }
.phase-event {
    display: flex; align-items: stretch; gap: 16px; padding: 0;
}
.phase-event-line {
    display: flex; flex-direction: column; align-items: center; width: 24px; flex-shrink: 0;
}
.phase-event-dot {
    width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; margin-top: 14px;
}
.phase-event-dot.job-start { background: var(--primary); }
.phase-event-dot.mentoring { background: var(--accent); }
.phase-event-dot.job-complete { background: #22c55e; }
.phase-event-connector {
    width: 2px; flex: 1; background: var(--border-color); min-height: 8px;
}
.phase-event-content {
    flex: 1; padding: 8px 0; border-bottom: 1px solid var(--border-color);
}
.phase-event-header { display: flex; justify-content: space-between; align-items: center; }
.phase-event-label { font-weight: 600; font-size: 0.9rem; }
.phase-event-time { font-size: 0.8rem; color: var(--text-faint); }
.phase-event-duration {
    font-size: 0.75rem; color: var(--text-muted); margin-top: 2px;
}
.phase-event-tokens {
    font-size: 0.75rem; color: var(--accent); margin-top: 2px;
}
.phase-event-meta { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }

/* ── Scrollbar styling (webkit) ── */
::-webkit-scrollbar       { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

/* ── Quality Optics (Issue #251) ── */

/* Quality indicator dot on collapsed accordion row */
.quality-dot {
    width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; display: inline-block;
}

/* Quality gate badge on collapsed row */
.quality-gate-badge {
    padding: 2px 8px; border-radius: 999px; font-size: 0.7rem; font-weight: 600; white-space: nowrap;
}
.quality-gate-badge.gate-pass { background: rgba(16,185,129,0.1); border: 1px solid var(--success-high); color: var(--success-high); }
.quality-gate-badge.gate-flag { background: rgba(245,158,11,0.1); border: 1px solid var(--success-medium); color: var(--success-medium); }
.quality-gate-badge.gate-fail { background: rgba(239,68,68,0.1); border: 1px solid var(--success-low); color: var(--success-low); }

/* Quality tab bar */
.quality-tab-bar {
    display: flex; gap: 0; margin-bottom: 16px; border-bottom: 1px solid var(--border-color);
}
.quality-tab-btn {
    padding: 8px 20px; border: none; background: transparent; color: var(--text-sub);
    font-size: 0.875rem; font-weight: 500; cursor: pointer;
    border-bottom: 2px solid transparent; transition: all 0.15s; margin-bottom: -1px;
}
.quality-tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.quality-tab-btn:hover:not(.active) { color: var(--text-main); }

/* Gate 1 status card */
.quality-gate-card {
    border-radius: var(--radius-md); padding: 20px; margin-bottom: 16px;
}
.quality-gate-card.gate-pass { background: rgba(16,185,129,0.06); border: 1px solid rgba(16,185,129,0.25); }
.quality-gate-card.gate-flag { background: rgba(245,158,11,0.06); border: 1px solid rgba(245,158,11,0.25); }
.quality-gate-card.gate-fail { background: rgba(239,68,68,0.06); border: 1px solid rgba(239,68,68,0.25); }

.quality-gate-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.quality-gate-label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-sub); font-weight: 600; }
.quality-gate-decision { font-size: 1.5rem; font-weight: 800; }
.gate-pass .quality-gate-decision { color: var(--success-high); }
.gate-flag .quality-gate-decision { color: var(--success-medium); }
.gate-fail .quality-gate-decision { color: var(--success-low); }

.quality-gate-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 12px; }
.quality-gate-stat { display: flex; flex-direction: column; gap: 2px; }
.qg-label { font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.qg-value { font-size: 1rem; font-weight: 700; color: var(--text-main); }
.qg-target { font-size: 0.75rem; font-weight: 400; color: var(--text-muted); }

.quality-gate-gaps { border-top: 1px solid var(--border-color); padding-top: 12px; margin-top: 4px; }
.quality-gate-gaps strong { font-size: 0.8rem; color: var(--text-sub); }
.quality-gate-gaps ul { list-style: disc; padding-left: 20px; margin-top: 6px; }
.quality-gate-gaps li { font-size: 0.8rem; color: var(--text-sub); line-height: 1.5; margin-bottom: 4px; }

/* Quality section card */
.quality-section-card {
    background: var(--card-bg); border: 1px solid var(--border-color);
    border-radius: var(--radius-md); padding: 20px; margin-bottom: 16px;
}
.quality-section-card h4 { font-size: 0.9rem; font-weight: 600; margin-bottom: 4px; }

/* Quality score bars */
.quality-score-bars { display: flex; flex-direction: column; gap: 8px; }
.quality-score-row { display: flex; align-items: center; gap: 10px; }
.qs-label { width: 140px; font-size: 0.8rem; color: var(--text-sub); flex-shrink: 0; }
.qs-bar-track { flex: 1; height: 14px; background: var(--hover-bg); border-radius: 4px; overflow: hidden; }
.qs-bar-fill { height: 100%; border-radius: 4px; transition: width 0.5s ease; }
.qs-value { width: 40px; font-size: 0.8rem; font-weight: 600; color: var(--text-sub); text-align: right; }

/* Coaching card */
.quality-coaching-card {
    padding: 12px 16px; background: rgba(99,102,241,0.05); border: 1px solid rgba(99,102,241,0.15);
    border-radius: var(--radius-md); font-size: 0.8rem; color: var(--text-sub); line-height: 1.6;
}
.quality-coaching-card strong { color: var(--primary); }

@media (max-width: 768px) {
    .quality-gate-stats { grid-template-columns: repeat(2, 1fr); }
}

/* ===== Quality Scorecard Tile Grid ===== */

.quality-tile-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
    gap: 10px;
}

.quality-tile {
    background: var(--card-bg, #fff);
    border-radius: var(--radius-lg, 14px);
    padding: 12px;
    box-shadow: var(--card-shadow);
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    border-top: 3px solid var(--border-color, #e2e8f0);
    position: relative;
}
.quality-tile:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99,102,241,0.12), 0 8px 24px rgba(99,102,241,0.08);
}
.quality-tile.green { border-top-color: var(--success-high, #10b981); }
.quality-tile.amber { border-top-color: var(--success-medium, #f59e0b); }
.quality-tile.red   { border-top-color: var(--success-low, #ef4444); }
.quality-tile.grey  { border-top-color: #cbd5e1; cursor: default; }
.quality-tile.grey:hover { transform: none; box-shadow: var(--card-shadow); }

.quality-tile-header {
    display: flex; align-items: center; gap: 6px; margin-bottom: 8px;
}
.quality-tile-icon {
    width: 28px; height: 28px; border-radius: var(--radius-sm, 6px);
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; flex-shrink: 0; background: var(--bg-surface, #f8fafc);
}
.quality-tile.green .quality-tile-icon { background: #ecfdf5; }
.quality-tile.amber .quality-tile-icon { background: #fffbeb; }
.quality-tile.red   .quality-tile-icon { background: #fef2f2; }

.quality-tile-name {
    font-size: 10px; font-weight: 700; color: var(--text-sub, #334155);
    text-transform: uppercase; letter-spacing: 0.3px;
}
.quality-tile-score-row {
    display: flex; align-items: baseline; gap: 6px; margin-bottom: 4px;
}
.quality-tile-score {
    font-size: 28px; font-weight: 800; line-height: 1;
}
.quality-tile.green .quality-tile-score { color: var(--success-high); }
.quality-tile.amber .quality-tile-score { color: var(--success-medium); }
.quality-tile.red   .quality-tile-score { color: var(--success-low); }
.quality-tile.grey  .quality-tile-score { color: #cbd5e1; }

.quality-tile-trend { font-size: 15px; font-weight: 600; }
.quality-tile-trend.trend-up   { color: var(--success-high); }
.quality-tile-trend.trend-flat { color: var(--text-faint, #94a3b8); }
.quality-tile-trend.trend-down { color: var(--success-low); }

.quality-tile-sparkline { height: 18px; margin-bottom: 4px; }
.quality-tile-sparkline svg { width: 100%; height: 18px; }

.quality-tile-meta {
    font-size: 11px; color: var(--text-faint, #94a3b8);
}
.quality-tile-empty-prompt {
    font-size: 11px; color: var(--text-faint); font-style: italic; margin-top: 4px; line-height: 1.4;
}

@media (min-width: 1024px) {
    .quality-tile-grid {
        grid-template-columns: repeat(9, minmax(0, 1fr));
    }
}

/* ===== Quality Detail Panel ===== */

.quality-detail-panel {
    background: var(--card-bg, #fff);
    border-radius: var(--radius-xl, 20px);
    box-shadow: var(--card-shadow);
    padding: 24px;
    margin-top: 16px;
}
.quality-detail-header {
    display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px;
}
.quality-detail-title { font-size: 17px; font-weight: 700; }
.quality-detail-close {
    background: none; border: 1px solid var(--border-color, #e2e8f0);
    border-radius: var(--radius-sm, 6px); padding: 5px 10px;
    cursor: pointer; font-size: 12px; color: var(--text-sub);
}
.quality-detail-close:hover { background: var(--bg-surface); }

.quality-detail-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
}
.quality-detail-grid .full-width { grid-column: 1 / -1; }

.quality-detail-card {
    background: var(--bg-surface, #f8fafc);
    border-radius: var(--radius-md, 10px); padding: 14px;
}
.quality-detail-card h3 {
    font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px;
    color: var(--text-faint); margin-bottom: 10px;
}

.quality-score-row {
    display: flex; align-items: center; margin-bottom: 8px;
}
.quality-score-row-label { font-size: 13px; color: var(--text-sub); min-width: 120px; }
.quality-score-bar-track {
    flex: 1; height: 6px; background: #e2e8f0; border-radius: 3px;
    margin: 0 10px; overflow: hidden;
}
.quality-score-bar-fill { height: 100%; border-radius: 3px; }
.quality-score-row-value { font-size: 13px; font-weight: 700; min-width: 30px; text-align: right; }

.quality-detail-coaching {
    grid-column: 1 / -1;
    background: #eef2ff; border-radius: var(--radius-md); padding: 14px;
    border-left: 3px solid var(--primary, #6366f1);
}
.quality-detail-coaching h3 {
    font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px;
    color: var(--primary); margin-bottom: 6px;
}
.quality-detail-coaching p {
    font-size: 13px; color: var(--text-sub); line-height: 1.5;
}

.quality-assessment-item {
    display: flex; align-items: center; padding: 8px 0;
    border-bottom: 1px solid #f1f5f9; gap: 10px;
}
.quality-assessment-item:last-child { border-bottom: none; }

.quality-assessment-badge {
    width: 36px; height: 36px; border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 13px; color: #fff; flex-shrink: 0;
}
.quality-assessment-badge.green { background: var(--success-high); }
.quality-assessment-badge.amber { background: var(--success-medium); }
.quality-assessment-badge.red   { background: var(--success-low); }

.quality-assessment-info { flex: 1; }
.quality-assessment-title { font-size: 13px; font-weight: 600; }
.quality-assessment-summary { font-size: 11px; color: var(--text-faint); margin-top: 1px; }
.quality-assessment-date { font-size: 11px; color: var(--text-faint); flex-shrink: 0; }

@media (max-width: 768px) {
    .quality-tile-grid { grid-template-columns: repeat(auto-fit, minmax(148px, 1fr)); }
    .quality-detail-grid { grid-template-columns: 1fr; }
}

/* === Issue #330: Cost / token cards === */
.stat-card.stat-cost { border-left: 3px solid #f59e0b; }
.stat-card.stat-tokens { border-left: 3px solid #8b5cf6; }
.stat-subtitle { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.stat-coverage {
    font-size: 11px;
    color: var(--success-medium);
    margin-top: 6px;
    cursor: help;
    border-top: 1px dashed var(--border-color);
    padding-top: 6px;
}

.agent-cost-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    margin-bottom: 16px;
}
.agent-cost-card h3 {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-faint);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 8px;
}
.agent-bar {
    height: 14px;
    background: var(--bg-main);
    border-radius: 999px;
    overflow: hidden;
    display: flex;
    margin: 8px 0 6px;
}
.agent-bar > div { height: 100%; }
.agent-bar .seg-claude { background: linear-gradient(90deg, #4f46e5, #6366f1); }
.agent-bar .seg-codex { background: linear-gradient(90deg, #10b981, #34d399); }
.agent-bar .seg-other { background: linear-gradient(90deg, #94a3b8, #cbd5e1); }
.agent-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    font-size: 12px;
    color: var(--text-sub);
}
.agent-legend .dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
    vertical-align: middle;
}
.agent-legend .dot.claude { background: var(--primary-dark); }
.agent-legend .dot.codex { background: #10b981; }
.agent-legend .dot.other { background: var(--text-faint); }
.agent-drilldown {
    margin-top: 12px;
    border-top: 1px dashed var(--border-color);
    padding-top: 10px;
}
.agent-drilldown table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.agent-drilldown th,
.agent-drilldown td {
    text-align: left;
    padding: 6px 8px;
    border-bottom: 1px solid var(--border-color);
}
.agent-drilldown th {
    color: var(--text-faint);
    font-weight: 700;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

[data-theme="dark"] {
    --bg-main: #0f172a;
    --bg-surface: #1e293b;
    --card-bg: #1e293b;
    --card-shadow: 0 1px 3px rgb(0 0 0 / .3), 0 4px 16px rgb(99 102 241 / .1);
    --card-shadow-hover: 0 4px 12px rgb(0 0 0 / .4), 0 8px 24px rgb(99 102 241 / .15);

    --text-main: #f1f5f9;
    --text-sub: #cbd5e1;
    --text-muted: #94a3b8;
    --text-faint: #64748b;

    --border-color: #334155;
    --border-subtle: #1e293b;

    --primary-bg: rgba(99, 102, 241, 0.12);
    --bg-job: rgba(79, 70, 229, 0.15);
    --bg-skill: rgba(124, 58, 237, 0.15);
    --bg-rule: rgba(5, 150, 105, 0.15);
    --bg-mentoring: rgba(217, 119, 6, 0.15);
}

html, body { transition: background-color 0.25s ease, color 0.25s ease; }
