:root {
    --bg1: hsl(0, 0%, 96%);
    --bg2: hsl(0, 0%, 98%);
    --bg3: hsl(0, 0%, 100%);
    --shadow: 0px 0px 4px hsla(0, 0%, 0%, 10%);
    --text-primary: black;
    --text-muted: grey;
    --saturation: 80%;
    --red: hsl(0, var(--saturation), 90%);
    --yellow: hsl(30, var(--saturation), 90%);
    --green: hsl(90, var(--saturation), 90%);
    --blue: hsl(210, var(--saturation), 90%);
    --blue-light: hsl(210, var(--saturation), 95%);
    --purple: hsl(240, var(--saturation), 90%);
    --purple-light: hsl(240, var(--saturation), 95%);
}

/* Global Styles */
* {
    box-sizing: border-box;
    margin: 0px;
    padding: 0px;
    font-weight: 400;
}

html {
    min-height: 100%;
}

body {
    background: var(--bg1);
    font-family: Helvetica, Arial, sans-serif;
    color: var(--text-primary);
    margin: 0px;
    min-height: 100%;
}

/* Typography */
h1 {
    font-size: 2rem;
}

h2 {
    font-size: 1rem;
}

h3 {
    font-size: 1.5rem;
    margin: 10px 0px 10px;
}

h4 {
    font-size: 1.5rem;
    font-weight: 500;
}

/* Layout */
#page {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

#page > .header {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    background: var(--blue-light);
    padding: 10px 20px 10px 20px;
    box-shadow: var(--shadow);
}

.header-text {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.greeting {
    font-size: 2rem;
}

.username {
    font-weight: 600;
}

.categories {
    padding: 0px 20px;
}

#empty-message {
    font-size: 2rem;
    color: var(--text-muted);
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Components */
.category {
    border-radius: 64px;
    box-shadow: var(--shadow);
    padding: 10px 40px 40px 40px;
    margin: 20px 0px;
    background-color: var(--bg2);
}

.category > .header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    gap: 40px;
}

.statusbar {
    height: 32px;
    background: white;
    border-radius: 999px;
    position: relative;
    flex: 1;
    box-shadow: var(--shadow);
}

.segment {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    min-width: fit-content;
    border-radius: 999px;
    display: flex;
    justify-content: end;
    align-items: center;
}

.average.red {
    background: var(--red);
}

.average.yellow {
    background: var(--yellow);
}

.average.green {
    background: var(--green);
}

.label {
    margin: 10px;
    white-space: nowrap;
}

.cards {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 40px;
}

.card {
    border-radius: 32px;
    box-shadow: var(--shadow);
    flex: 1 1 33%;
    padding: 20px;
    background: var(--bg3);
    max-width: 400px;
}

.card > .header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.card > .header > .top-percent {
    border-radius: 999px;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px 20px;
}

.top-percent.red {
    background-color: var(--red);
}

.top-percent.yellow {
    background-color: var(--yellow);
}

.top-percent.green {
    background-color: var(--green);
}

.top-percent > span {
    font-size: 1.5rem;
    white-space: nowrap;
}

.stat {
    display: flex;
}

.stat > .value {
    font-size: 4rem;
}

.stat > .column > .unit {
    font-size: 1.5rem;
}

.column {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.stats {
    justify-content: space-between;
}

.improvements {
    display: flex;
    justify-content: space-around;
    gap: 20px;
}

.improvement > .value {
    font-size: 1.5rem;
}

.improvement > .unit {
    font-size: 0.75rem;
}

.next {
    border-radius: 16px;
    box-shadow: var(--shadow);
    padding: 10px 20px;
    flex: 1;
}

.next > .header {
    display: flex;
    align-items: center;
    gap: 5px;
}

.next > .header > p {
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.next > p {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.next.percentile {
    background: var(--blue-light);
}

.next.decile {
    background: var(--purple-light);
}

/* Buttons */
.edit-button,
.save-button,
.delete-button,
.icon-button {
    background: none;
    border: none;
}

.edit-button {
    align-self: flex-start;
}

.edit-input {
    border: none;
    outline: none;
    background: transparent;
    font-size: 4rem;
    font-family: inherit;
    padding: 0;
    margin: 0;
}

.header-buttons {
    display: flex;
    gap: 10px;
}

.add-metric-button {
    border: none;
    border-radius: 999px;
    box-shadow: var(--shadow);
    background: hsl(210, var(--saturation), 70%);
    color: white;
    padding: 12px 18px;
    display: flex;
    align-items: center;
    gap: 10px;
    font: inherit;
    cursor: pointer;
}

.add-metric-button:hover {
    background: hsl(210, var(--saturation), 50%);
}

.report-button, .request-button {
    border: none;
    border-radius: 999px;
    box-shadow: var(--shadow);
    background: white;
    color: hsl(210, var(--saturation), 70%);
    padding: 12px 18px;
    display: flex;
    align-items: center;
    gap: 10px;
    font: inherit;
    cursor: pointer;
}

.report-button:hover {
    background: hsl(210, var(--saturation), 50%);
    color: white;
}

.primary-button {
    border: none;
    border-radius: 999px;
    box-shadow: var(--shadow);
    background: var(--blue-light);
    padding: 12px 20px;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.primary-button:hover {
    background: var(--blue);
}

.primary-button:disabled {
    cursor: default;
    opacity: 0.6;
}

/* Auth */
.auth-page {
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

.auth-card {
    width: min(100%, 480px);
    border-radius: 48px;
    box-shadow: var(--shadow);
    padding: 40px;
    background-color: var(--bg2);
}

.auth-card h1 {
    margin-bottom: 24px;
}

.auth-card form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.auth-card label {
    display: block;
    font-size: 0.9rem;
    margin-bottom: 8px;
}

.auth-card input,
.auth-card select {
    width: 100%;
    border: none;
    outline: none;
    border-radius: 20px;
    box-shadow: var(--shadow);
    background: var(--bg3);
    padding: 14px 18px;
    font: inherit;
    color: inherit;
}

.auth-card button {
    border: none;
    border-radius: 999px;
    box-shadow: var(--shadow);
    background: hsl(210, var(--saturation), 70%);
    color: white;
    padding: 14px 20px;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.auth-card button:hover {
    background: hsl(210, var(--saturation), 50%);
}

.auth-card button:disabled {
    cursor: default;
    opacity: 0.7;
}

.auth-card p {
    margin-top: 20px;
}

.auth-card a {
    color: inherit;
    font-weight: 600;
}

.auth-card a:hover {
    opacity: 0.7;
}

#error-message {
    margin-top: 4px;
    color: var(--red) !important;
    font-size: 0.95rem;
}

/* Modal */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: hsla(0, 0%, 0%, 25%);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    z-index: 100;
}

.modal-card {
    width: min(100%, 720px);
    max-height: 90vh;
    overflow: auto;
    border-radius: 40px;
    box-shadow: var(--shadow);
    background: var(--bg2);
    padding: 30px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    margin-bottom: 24px;
}

.modal-body {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.modal-footer {
    margin-top: 24px;
    display: flex;
    justify-content: flex-end;
}

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

.picker-label {
    font-size: 0.95rem;
    font-weight: 600;
}

.pill-list {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.pill-button {
    border: none;
    border-radius: 999px;
    box-shadow: var(--shadow);
    background: var(--bg3);
    padding: 10px 16px;
    font: inherit;
    cursor: pointer;
}

.pill-button.selected {
    background: var(--blue);
}

.value-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

#new-measurement-value, #report-text, #request-text {
    border: none;
    outline: none;
    border-radius: 20px;
    box-shadow: var(--shadow);
    background: var(--bg3);
    padding: 14px 18px;
    font: inherit;
    color: inherit;
    width: 220px;
}

#report-text, #request-text {
    width: 100%;
}

.value-unit {
    font-size: 1.1rem;
}

.modal-error {
    color: hsl(0, 70%, 45%);
    font-size: 0.95rem;
}

/* Utility */
.hidden {
    display: none !important;
}