:root {
    color-scheme: light;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: #202821;
    background: #f5f4ef;
    font-synthesis: none;
    text-rendering: optimizeLegibility;
    --ink: #202821;
    --muted: #70786f;
    --line: #e6e7df;
    --surface: #ffffff;
    --green: #285c45;
    --green-dark: #1c4835;
    --soft-green: #e9f1eb;
    --error: #a63f36;
}

* {
    box-sizing: border-box;
}

body {
    min-width: 320px;
    min-height: 100vh;
    margin: 0;
    background:
        radial-gradient(ellipse at 10% 0%, rgba(217, 229, 213, 0.52), transparent 35rem),
        #f5f4ef;
}

button,
input {
    font: inherit;
}

button {
    cursor: pointer;
}

.page-shell {
    width: min(100% - 32px, 760px);
    margin: 0 auto;
    padding: 34px 0 56px;
}

[hidden] {
    display: none !important;
}

.auth-card,
.panel {
    border: 1px solid rgba(36, 61, 46, 0.08);
    border-radius: 24px;
    background: var(--surface);
    box-shadow: 0 12px 40px rgba(35, 50, 37, 0.055);
}

.auth-card {
    width: min(100%, 440px);
    margin: min(10vh, 100px) auto 0;
    padding: 32px;
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--green);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

h1,
h2,
p {
    margin-top: 0;
}

h1,
h2 {
    letter-spacing: -0.045em;
}

h1 {
    margin-bottom: 8px;
    font-size: clamp(2rem, 8vw, 2.65rem);
    line-height: 1.08;
}

h2 {
    margin-bottom: 0;
    font-size: 1.3rem;
}

.muted {
    margin-bottom: 28px;
    color: var(--muted);
    line-height: 1.5;
}

.field-help {
    margin: -3px 0 8px;
    color: var(--muted);
    font-size: 0.79rem;
    line-height: 1.45;
}

.field-help code {
    overflow-wrap: anywhere;
    color: #465a4b;
    font-size: 0.76rem;
}

.topbar,
.section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.main-nav {
    display: flex;
    gap: 8px;
    margin: -7px 0 20px;
    padding: 5px;
    border: 1px solid rgba(36, 61, 46, 0.08);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.72);
}

.nav-link {
    flex: 1;
    padding: 11px 14px;
    border-radius: 10px;
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 700;
    text-align: center;
    text-decoration: none;
}

.nav-link:hover {
    background: #f3f5f0;
    color: var(--green-dark);
}

.nav-link.is-active {
    background: var(--green);
    color: #fff;
}

.topbar {
    margin: 4px 2px 25px;
}

.panel {
    margin-bottom: 18px;
    padding: 24px;
}

.section-heading {
    margin-bottom: 22px;
}

.form-stack {
    display: grid;
    gap: 10px;
}

.metric-input {
    display: grid;
    gap: 8px;
    padding: 14px;
    border: 1px solid #ebede7;
    border-radius: 15px;
    background: #fdfdfb;
}

.import-preview {
    margin: 4px 0;
    padding: 13px 14px;
    border: 1px solid #e6e7df;
    border-radius: 13px;
    background: #f8f9f5;
    color: #56634f;
    font-size: 0.86rem;
    line-height: 1.5;
}

.button:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

.metric-input .check-row {
    min-height: 28px;
    margin: 0;
    color: var(--muted);
    font-size: 0.84rem;
}

label {
    margin-top: 4px;
    color: #39433b;
    font-size: 0.87rem;
    font-weight: 600;
}

input:not([type="checkbox"]) {
    width: 100%;
    min-height: 48px;
    padding: 11px 13px;
    border: 1px solid #dce0d8;
    border-radius: 12px;
    outline: none;
    background: #fdfdfb;
    color: var(--ink);
    transition: border-color 140ms ease, box-shadow 140ms ease;
}

input:focus-visible {
    border-color: #5f8d70;
    box-shadow: 0 0 0 3px rgba(67, 124, 88, 0.15);
}

input:disabled {
    color: #8b918a;
    background: #f1f2ee;
}

.button {
    min-height: 44px;
    padding: 10px 15px;
    border: 0;
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: 700;
    transition: background-color 140ms ease, transform 140ms ease;
}

.button:active {
    transform: translateY(1px);
}

.button-primary {
    margin-top: 8px;
    background: var(--green);
    color: white;
}

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

.button-secondary {
    border: 1px solid #dce5dc;
    background: var(--soft-green);
    color: var(--green-dark);
}

.button-secondary:hover {
    background: #dceade;
}

.button-quiet {
    border: 1px solid var(--line);
    background: transparent;
    color: #4e5c51;
}

.button-quiet:hover {
    background: #f3f5f0;
}

.check-row {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 42px;
    margin-top: 5px;
    cursor: pointer;
}

.check-row input {
    width: 19px;
    height: 19px;
    margin: 0;
    accent-color: var(--green);
}

.range-form {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    align-items: end;
    gap: 10px;
    margin-bottom: 18px;
}

.range-form > div {
    display: grid;
    gap: 7px;
}

.range-form input {
    min-height: 43px !important;
    padding: 8px 9px !important;
    font-size: 0.85rem;
}

.entries-list {
    display: grid;
    gap: 9px;
}

.chart-grid {
    display: grid;
    gap: 16px;
}

.summary-grid {
    display: grid;
    gap: 12px;
    margin-bottom: 16px;
}

.summary-card {
    margin: 0;
    padding: 20px;
}

.summary-measurement-history {
    margin-top: 15px;
    padding-top: 13px;
    border-top: 1px solid var(--line);
}

.summary-period {
    margin: 0 0 4px;
    color: var(--muted);
    font-size: 0.76rem;
    font-weight: 700;
}

.summary-number {
    margin: 4px 0 2px;
    font-family: system-ui, sans-serif;
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -0.06em;
}

.summary-number.is-goal-met,
.summary-goal.is-goal-met {
    color: var(--green);
}

.summary-caption,
.summary-goal {
    margin: 0;
    color: var(--muted);
    font-size: 0.82rem;
}

.summary-goal {
    margin-top: 11px;
    color: #56634f;
    font-weight: 700;
}

.chart-panel {
    position: relative;
    margin-bottom: 0;
}

.chart-panel canvas {
    display: block;
    width: 100%;
    height: 220px;
    touch-action: pan-y;
}

.chart-tooltip {
    position: absolute;
    z-index: 2;
    max-width: calc(100% - 20px);
    padding: 9px 11px;
    border: 1px solid rgba(36, 61, 46, 0.12);
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 5px 18px rgba(35, 50, 37, 0.14);
    color: var(--ink);
    font-size: 0.78rem;
    font-weight: 600;
    line-height: 1.5;
    pointer-events: none;
    white-space: pre-line;
}

@media (min-width: 700px) {
    .summary-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .chart-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.entry-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 14px 15px;
    border: 1px solid #ebede7;
    border-radius: 15px;
    background: #fdfdfb;
}

.entry-date-label {
    margin-bottom: 4px;
    color: var(--muted);
    font-size: 0.82rem;
}

.entry-value {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
}

.edit-button {
    min-width: 104px;
}

.status-message {
    min-height: 1.3em;
    margin: 12px 0 0;
    color: var(--muted);
    font-size: 0.86rem;
    line-height: 1.45;
}

.status-message.is-error {
    color: var(--error);
}

@media (max-width: 540px) {
    .page-shell {
        width: min(100% - 24px, 440px);
        padding-top: 20px;
    }

    .auth-card,
    .panel {
        border-radius: 19px;
        padding: 20px;
    }

    .auth-card {
        margin-top: 9vh;
    }

    .topbar {
        margin: 8px 2px 18px;
    }

    .section-heading {
        align-items: flex-start;
    }

    .range-form {
        grid-template-columns: 1fr 1fr;
    }

    .range-form button {
        grid-column: 1 / -1;
    }

    .entry-card {
        padding: 13px 12px;
    }

    .edit-button {
        min-width: 96px;
        padding-inline: 11px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
    }
}
