html, body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
    background: #0d1117;
}

/* Sidebar nav overrides — must beat Bootstrap's a { text-decoration: underline } */
a.sidebar-nav-link,
a.sidebar-nav-link:hover,
a.sidebar-nav-link:focus,
a.sidebar-nav-link:visited {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 0.85rem !important;
    text-decoration: none !important;
}

.content {
    padding-top: 0;
}

.main-scroll {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

h1:focus { outline: none; }

/* Stats badges */
.stat-badge {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    padding: 4px 14px;
    border-radius: 20px;
    background: rgba(56, 139, 253, 0.1);
    border: 1px solid rgba(56, 139, 253, 0.25);
    margin-left: 8px;
}
.stat-value { font-weight: 700; font-size: 1.1rem; color: #58a6ff; }
.stat-label { font-size: 0.8rem; color: #8b949e; }

/* Cards */
.card {
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 8px;
}
.card-header {
    background: #161b22;
    border-bottom: 1px solid #30363d;
    padding: 12px 16px;
}

/* Heatmap */
.heatmap-table {
    overflow: auto;
    height: calc(100vh - 420px);
    min-height: 200px;
    width: 100%;
    font-size: 0.75rem;
    padding-top: 4px;
}
.heatmap-header-row, .heatmap-row {
    display: flex;
    align-items: center;
    gap: 2px;
    min-width: fit-content;
}
.heatmap-header-row {
    margin-bottom: 4px;
    position: sticky;
    top: 0;
    z-index: 3;
    background: #161b22;
}
.heatmap-row { margin-bottom: 2px; border-radius: 3px; padding: 2px 4px; }
.heatmap-row:nth-child(even) { background-color: rgba(148,159,172,0.06); box-shadow: inset 2px 0 0 rgba(148,159,172,0.15); }
.heatmap-user-label {
    width: 180px;
    min-width: 180px;
    max-width: 180px;
    flex-shrink: 0;
    flex-grow: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding-right: 8px;
    font-size: 0.8rem;
    position: sticky;
    left: 0;
    z-index: 2;
    background: #161b22;
}
.heatmap-row:nth-child(even) .heatmap-user-label {
    background: #171c24;
}
.heatmap-header-row .heatmap-user-label {
    z-index: 4;
}
.heatmap-user-link {
    color: #58a6ff;
    text-decoration: none;
}
.heatmap-user-link:hover { text-decoration: underline; }
.heatmap-team-label {
    width: 160px;
    min-width: 160px;
    max-width: 160px;
    flex-shrink: 0;
    flex-grow: 0;
    padding-right: 8px;
    font-size: 0.7rem;
    color: #8b949e;
    position: sticky;
    left: 180px;
    z-index: 2;
    background: #161b22;
    display: flex;
    flex-direction: column;
    gap: 1px;
}
.hm-team-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.hm-last-activity {
    font-size: 0.62rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.heatmap-row:nth-child(even) .heatmap-team-label {
    background: #171c24;
}
.heatmap-header-row .heatmap-team-label {
    z-index: 4;
    background: #161b22;
}
.heatmap-tier-label {
    width: 65px;
    min-width: 65px;
    max-width: 65px;
    flex-shrink: 0;
    flex-grow: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding-right: 6px;
    font-size: 0.7rem;
    color: #8b949e;
    position: sticky;
    left: 340px;
    z-index: 2;
    background: #161b22;
}
.heatmap-row:nth-child(even) .heatmap-tier-label {
    background: #171c24;
}
.heatmap-header-row .heatmap-tier-label {
    z-index: 4;
    background: #161b22;
}
.heatmap-price-label {
    width: 55px;
    min-width: 55px;
    max-width: 55px;
    flex-shrink: 0;
    flex-grow: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding-right: 6px;
    font-size: 0.7rem;
    color: #8b949e;
    position: sticky;
    left: 405px;
    z-index: 2;
    background: #161b22;
}
.heatmap-row:nth-child(even) .heatmap-price-label {
    background: #171c24;
}
.heatmap-header-row .heatmap-price-label {
    z-index: 4;
    background: #161b22;
}
.heatmap-date-label {
    width: 28px;
    flex-shrink: 0;
    text-align: center;
    color: #8b949e;
    font-size: 0.65rem;
    line-height: 1.1;
    display: flex;
    flex-direction: column;
}
.heatmap-month { font-size: 0.55rem; color: #484f58; }
.heatmap-total-label, .heatmap-total-value {
    min-width: 60px;
    flex-shrink: 0;
    text-align: right;
    padding-left: 8px;
    font-size: 0.8rem;
    color: #8b949e;
}
.heatmap-total-value { color: #c9d1d9; font-weight: 600; }
.heatmap-cell {
    width: 28px;
    height: 16px;
    flex-shrink: 0;
    border-radius: 3px;
    cursor: default;
    position: relative;
    transition: outline 0.1s;
}
.heatmap-cell:hover {
    outline: 2px solid #58a6ff;
    outline-offset: -1px;
}
.level-0 { background-color: #161b22; border: 1px solid #21262d; }
.level-1 { background-color: #0e4429; }
.level-2 { background-color: #006d32; }
.level-3 { background-color: #26a641; }
.level-4 { background-color: #39d353; }

.heatmap-legend {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Custom tooltip */
.heatmap-cell .tooltip-content {
    display: none;
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: #1c2128;
    border: 1px solid #30363d;
    border-radius: 6px;
    padding: 8px 12px;
    white-space: nowrap;
    font-size: 0.8rem;
    color: #c9d1d9;
    z-index: 100;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    line-height: 1.5;
}
.heatmap-cell .tooltip-content::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: #30363d;
}
.heatmap-cell:hover .tooltip-content {
    display: block;
}

/* Tooltip flipped below when JS adds .tooltip-below */
.heatmap-cell.tooltip-below .tooltip-content {
    bottom: auto;
    top: calc(100% + 8px);
}
.heatmap-cell.tooltip-below .tooltip-content::after {
    top: auto;
    bottom: 100%;
    border-top-color: transparent;
    border-bottom-color: #30363d;
}

/* Detail sections */
.detail-user-section { border-bottom: 1px solid #21262d; }
.detail-user-section.collapsed .detail-user-body { display: none; }
.detail-user-section.collapsed .detail-toggle { transform: rotate(-90deg); }
.detail-user-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    cursor: pointer;
    user-select: none;
}
.detail-user-header:hover { background: rgba(56, 139, 253, 0.05); }
.detail-toggle {
    display: inline-block;
    transition: transform 0.15s;
    color: #8b949e;
    font-size: 0.9rem;
}
.detail-user-stats { display: flex; gap: 6px; align-items: center; }
.detail-user-body { overflow-x: auto; }

.table thead th {
    background: #0d1117;
    border-bottom: 1px solid #30363d;
    font-size: 0.8rem;
    color: #8b949e;
    position: sticky;
    top: 0;
    z-index: 1;
}
.table td {
    border-color: #21262d;
    font-size: 0.85rem;
    padding: 4px 8px;
    vertical-align: middle;
}
.text-warning { color: #d29922 !important; }

html { scroll-behavior: smooth; }

footer { border-top: 1px solid #21262d; }

/* Page header */
/* Toolbar buttons */
.toolbar-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 5px 12px;
    border-radius: 6px;
    letter-spacing: 0.01em;
    transition: opacity 0.15s, box-shadow 0.15s;
}
.toolbar-btn:disabled { opacity: 0.55; }
.toolbar-btn svg { flex-shrink: 0; }
.toolbar-btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 5px 8px;
    border-radius: 6px;
    font-size: 0.8rem;
    transition: opacity 0.15s;
}
.toolbar-currency .btn {
    font-size: 0.8rem;
    font-weight: 600;
    padding: 5px 10px;
    border-radius: 0;
    letter-spacing: 0.02em;
}
.toolbar-currency .btn:first-child { border-radius: 6px 0 0 6px; }
.toolbar-currency .btn:last-child  { border-radius: 0 6px 6px 0; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.spin-icon { animation: spin 0.9s linear infinite; display: inline-flex; }

.page-header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: #0d1117;
    padding-top: 1.25rem;
    padding-bottom: 1.25rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid #21262d;
}

/* Filter row */
.filter-row .form-label {
    font-size: 0.8rem;
    color: #8b949e;
    margin-bottom: 2px;
}

@media (max-width: 768px) {
    .heatmap-user-label {
        min-width: 120px;
        max-width: 120px;
    }
    .stat-badge { margin-bottom: 4px; }
}

/* Cost breakdown table */
.cost-table-wrapper {
    overflow-x: auto;
}

.cost-table thead th {
    white-space: nowrap;
}

.cost-table th:first-child,
.cost-table td:first-child {
    position: sticky;
    left: 0;
    z-index: 1;
    min-width: 200px;
    background: #161b22;
}

.cost-table thead th:first-child {
    background: #0d1117;
    z-index: 2;
}

.cost-group-row {
    background: #1c2128;
    cursor: pointer;
    user-select: none;
}

.cost-group-row:hover { background: #21262d; }

.cost-group-row td:first-child { background: #1c2128; }
.cost-group-row:hover td:first-child { background: #21262d; }

.cost-detail-row td:first-child { padding-left: 2rem; }
.cost-detail-name { color: #c9d1d9; }

.cost-nzd { color: #3fb950; white-space: nowrap; }

/* Cost breakdown table tooltip */
.cost-tooltip-cell {
    position: relative;
}
.cost-tooltip-cell .tooltip-content {
    display: none;
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: #1c2128;
    border: 1px solid #30363d;
    border-radius: 6px;
    padding: 8px 12px;
    white-space: nowrap;
    font-size: 0.8rem;
    color: #c9d1d9;
    z-index: 100;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    line-height: 1.5;
    text-align: left;
}
.cost-tooltip-cell .tooltip-content::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: #30363d;
}
.cost-tooltip-cell:hover .tooltip-content {
    display: block;
}
.cost-tooltip-cell.tooltip-below .tooltip-content {
    bottom: auto;
    top: calc(100% + 8px);
}
.cost-tooltip-cell.tooltip-below .tooltip-content::after {
    top: auto;
    bottom: 100%;
    border-top-color: transparent;
    border-bottom-color: #30363d;
}

.cost-total-row td { border-top: 2px solid #30363d !important; }
.cost-total-row td:first-child { background: #161b22; }

.cost-rate-row td {
    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I1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}
.blazor-error-boundary::after { content: "An error has occurred." }

/* ─── Settings page ─────────────────────────────────────────────────────────── */
.settings-narrow-input {
    width: 130px;
}

.settings-empty-state {
    padding: 1rem 1.25rem;
    font-size: .9rem;
}

.settings-fallback-row {
    display: flex;
    flex-direction: column;
    gap: .25rem;
}

.settings-instance-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .75rem 1.25rem;
    border-bottom: 1px solid var(--bs-border-color, #30363d);
    flex-wrap: wrap;
}

.settings-instance-row:last-child {
    border-bottom: none;
}

.settings-instance-editing {
    background: rgba(88, 166, 255, .05);
    border-left: 3px solid #58a6ff;
}

.settings-form {
    padding: 1rem 1.25rem 1.25rem;
    border-bottom: 1px solid var(--bs-border-color, #30363d);
    background: rgba(255, 255, 255, .02);
}
