* { box-sizing: border-box; margin: 0; padding: 0; }
html { color-scheme: light dark; }
body {
    font-family: Avenir, Montserrat, Corbel, 'URW Gothic', source-sans-pro, sans-serif;
    background: Canvas;
    color: CanvasText;
    padding: 2rem;
    max-width: 1200px;
    margin: 0 auto;
}
header {
    margin-bottom: 1.25rem;
}
header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}
header p {
    opacity: 0.5;
    font-size: 0.875rem;
    margin-top: 0.25rem;
}
header p a {
    color: CanvasText;
}
#controls {
    margin-bottom: 0.75rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1rem;
    align-items: center;
}
#controls label {
    font-size: 0.875rem;
    opacity: 0.6;
}
#controls select,
#controls input[type="date"] {
    background: Canvas;
    color: CanvasText;
    border: 1px solid;
    border-radius: 4px;
    padding: 0.375rem 0.5rem;
    font-size: 0.875rem;
    margin-left: 0.5rem;
    opacity: 0.8;
}
#controls .toggle {
    font-size: 0.8125rem;
    opacity: 0.7;
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}
#controls .toggle:hover {
    opacity: 1;
}
#controls .toggle input {
    cursor: pointer;
}
#chart-container {
    border: 1px solid color-mix(in srgb, CanvasText 20%, transparent);
    padding: 1rem;
    height: 420px;
    opacity: 0.95;
}
.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 1rem;
    margin: 0.5rem 0 1.25rem;
    font-size: 0.75rem;
}
.legend-item {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    cursor: pointer;
    opacity: 0.8;
}
.legend-item:hover {
    opacity: 1;
}
.legend-item.hidden {
    opacity: 0.3;
}
.legend-swatch {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    flex-shrink: 0;
    display: inline-block;
    vertical-align: -1px;
}
#table-container h2 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}
table {
    width: 100%;
    border-collapse: collapse;
}
th, td {
    text-align: left;
    padding: 0.4rem 0.75rem;
    font-size: 0.8125rem;
    font-variant-numeric: tabular-nums;
}
th {
    opacity: 0.5;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.6875rem;
    letter-spacing: 0.05em;
    border-bottom: 1px solid;
}
td {
    opacity: 0.85;
    border-bottom: 1px solid;
    border-bottom-color: color-mix(in srgb, CanvasText 10%, transparent);
}
tr:last-child td {
    border-bottom: none;
}
tr:hover td {
    opacity: 1;
}
.pct-cell {
    position: relative;
    min-width: 8rem;
}
.pct-bar {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    max-width: calc(100% - 1rem);
    background: CanvasText;
    opacity: 0.07;
    border-radius: 2px;
}
.pct-label {
    position: relative;
}
.api-cell {
    opacity: 0.5;
    font-size: 0.75rem;
}
/* Breakdown horizontal stacked bars */
#breakdown-container {
    margin-top: 1.5rem;
}
#breakdown-container h2 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
}
.breakdown-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.35rem;
}
.breakdown-label {
    width: 11rem;
    flex-shrink: 0;
    font-size: 0.8125rem;
    text-align: right;
    opacity: 0.85;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.breakdown-label a {
    color: CanvasText;
    text-decoration: none;
}
.breakdown-label a:hover {
    text-decoration: underline;
}
.breakdown-bar {
    flex: 1;
    display: flex;
    height: 1.25rem;
    border-radius: 3px;
    overflow: hidden;
}
.breakdown-seg {
    display: block;
    height: 100%;
    transition: opacity 0.1s;
}
.breakdown-seg:hover {
    opacity: 0.75;
}
.breakdown-tooltip {
    display: none;
    position: absolute;
    z-index: 100;
    background: Canvas;
    color: CanvasText;
    border: 1px solid;
    border-radius: 4px;
    padding: 0.35rem 0.6rem;
    font-size: 0.75rem;
    pointer-events: none;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0,0,0,0.25);
    line-height: 1.4;
}
#loading, #no-data {
    text-align: center;
    padding: 2rem;
    opacity: 0.5;
}
footer {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.35em;
    font-size: 0.8125rem;
    opacity: 0.5;
}
footer:hover {
    opacity: 0.8;
}
footer .logo-light {
    display: inline-block;
}
footer .logo-dark {
    display: none;
}
@media (prefers-color-scheme: dark) {
    footer .logo-light { display: none; }
    footer .logo-dark { display: inline-block; }
}
footer img {
    height: 1.4em;
    vertical-align: middle;
    display: inline-block;
    margin: 0 0.15em;
}
footer a {
    color: CanvasText;
    text-decoration: none;
}
footer a:hover {
    text-decoration: underline;
}
