:root {
    --background: #0d0f12;
    --panel: #171a1f;
    --border: #2a2f37;
    --text: #e8eaed;
    --muted: #9aa0a6;
    --accent: #7cff4f;
    --error: #ff6b6b;
    --chart-primary: #7cff4f;
    --chart-secondary: #4fb3ff;
    --chart-median: #9aa0a6;
    --chart-target: #ff8ad8;
    color-scheme: dark;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--background);
    color: var(--text);
    font: 16px/1.5 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.admin {
    width: 100%;
    max-width: 960px;
    margin: 0 auto;
    padding: 24px 16px;
}

h1 {
    margin: 0 0 24px;
    font-size: 1.5rem;
}

.panel {
    max-width: 420px;
    padding: 24px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
}

#signed-in-view {
    max-width: none;
}

.stack {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 12px;
    color: var(--muted);
    font-size: 0.875rem;
}

input,
select,
button {
    min-height: 44px;
    padding: 8px 12px;
    font: inherit;
    color: var(--text);
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 8px;
}

button {
    cursor: pointer;
}

button[type='submit'],
button.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--background);
    font-weight: 600;
}

button:disabled,
input:disabled,
select:disabled {
    opacity: 0.5;
    cursor: wait;
}

.divider {
    margin: 16px 0;
    text-align: center;
    color: var(--muted);
}

.message {
    min-height: 1.5em;
    margin: 16px 0 0;
    color: var(--error);
}

.signed-in-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.signed-in-as {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--muted);
}

.environment-switch {
    display: flex;
    gap: 8px;
}

.sign-in-prompt {
    margin: 0 0 16px;
    font-weight: 600;
}

#signed-in-view:not([hidden]) + #sign-in-view {
    margin-top: 16px;
}

.cancel-sign-in {
    width: 100%;
    margin-top: 12px;
}

#admin-content {
    margin-top: 16px;
}

.admin-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.tab[aria-pressed='true'] {
    border-color: var(--accent);
    color: var(--accent);
}

.window-form {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px;
}

.window-form .field {
    margin-bottom: 0;
}

.note {
    margin: 8px 0;
    color: var(--muted);
    font-size: 0.875rem;
}

.dashboard-section {
    margin-top: 24px;
}

.dashboard-section h2 {
    margin: 0 0 8px;
    font-size: 1.125rem;
}

.stat-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
}

.stat-tile {
    display: flex;
    flex-direction: column;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.stat-label,
.stat-note {
    color: var(--muted);
    font-size: 0.8125rem;
}

.stat-value {
    font-size: 1.375rem;
    font-weight: 600;
}

.numeric {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.table-scroll {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

th,
td {
    padding: 6px 8px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    white-space: nowrap;
}

.wraps {
    white-space: normal;
}

th {
    color: var(--muted);
    font-weight: 500;
}

.bar-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.bar-row {
    display: grid;
    grid-template-columns: minmax(120px, 2fr) 3fr minmax(96px, auto);
    align-items: center;
    gap: 12px;
    font-size: 0.875rem;
}

.bar-label {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.bar-meter {
    appearance: none;
    width: 100%;
    height: 12px;
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
}

.bar-meter::-webkit-meter-bar {
    background: var(--background);
    border: none;
}

.bar-meter::-webkit-meter-optimum-value {
    background: var(--chart-primary);
}

.bar-meter::-moz-meter-bar {
    background: var(--chart-primary);
}

.tag {
    padding: 0 6px;
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--muted);
    font-size: 0.75rem;
}

.chart {
    width: 100%;
    overflow: hidden;
}

.chart .u-legend {
    color: var(--text);
    font-size: 0.8125rem;
}

@media (max-width: 480px) {
    .bar-row {
        grid-template-columns: 1fr auto;
    }

    .bar-meter {
        grid-column: 1 / -1;
        grid-row: 2;
    }
}

.notice {
    margin-top: 24px;
    padding: 16px;
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent);
    border-radius: 8px;
}

.notice-headline {
    margin: 0;
    font-weight: 600;
}

.notice .note {
    margin-bottom: 0;
}

.notice button {
    margin-top: 12px;
}

.placeholder {
    background: var(--border);
    border-radius: 8px;
    animation: placeholder-pulse 1.4s ease-in-out infinite;
}

.placeholder-heading {
    width: 180px;
    height: 20px;
    margin-bottom: 12px;
}

.placeholder-tile {
    height: 82px;
}

.placeholder-chart {
    height: 220px;
}

.placeholder-row {
    height: 24px;
}

@keyframes placeholder-pulse {
    50% {
        opacity: 0.4;
    }
}

@media (prefers-reduced-motion: reduce) {
    .placeholder {
        animation: none;
    }
}

a {
    color: var(--accent);
}

.user-search {
    flex: 1 1 280px;
    max-width: 420px;
}

.with-tags {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

th[aria-sort] {
    padding: 0;
}

.sort-button {
    width: 100%;
    padding: 6px 8px;
    border: none;
    border-radius: 0;
    background: none;
    color: inherit;
    font-weight: inherit;
    text-align: inherit;
}

th[aria-sort='ascending'] .sort-button,
th[aria-sort='descending'] .sort-button {
    color: var(--accent);
}

.load-more {
    margin-top: 12px;
}

.back-link {
    display: inline-block;
    margin-bottom: 8px;
}

.profile-card {
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.profile-heading {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.profile-heading h2 {
    margin: 0;
    font-size: 1.375rem;
    overflow-wrap: anywhere;
}

.email-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    margin: 8px 0 16px;
}

.email-row .note {
    margin: 0;
}

.subsection {
    margin-top: 16px;
}

.subsection h3 {
    margin: 0 0 8px;
    font-size: 1rem;
}

.day-strip {
    display: flex;
    gap: 3px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.day-cell {
    flex: 1 1 0;
    min-width: 0;
    height: 28px;
    background: var(--border);
    border-radius: 3px;
}

.day-cell.active {
    background: var(--accent);
}

.day-strip-ends {
    display: flex;
    justify-content: space-between;
    margin-top: 4px;
}

[hidden] {
    display: none !important;
}
