:root {
    color-scheme: light;
    --ink: #18323a;
    --muted: #61747a;
    --paper: #f5f8f7;
    --card: #ffffff;
    --line: #dce7e5;
    --accent: #087f75;
    --accent-dark: #06645d;
    --accent-soft: #e2f3ef;
    --danger: #a33f38;
    --shadow: 0 18px 45px rgb(24 50 58 / 9%);
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--paper); }

body {
    min-height: 100vh;
    margin: 0;
    color: var(--ink);
    background: radial-gradient(circle at top right, rgb(207 237 231 / 60%), transparent 32rem), var(--paper);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.55;
}

button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .65; }
button:focus-visible, input:focus-visible { outline: 3px solid rgb(8 127 117 / 28%); outline-offset: 2px; }

.site-body { padding: 1.25rem; }
.page-shell { width: min(100%, 68rem); margin: 0 auto; }

.auth-page {
    display: grid;
    min-height: calc(100vh - 2.5rem);
    align-content: center;
    justify-items: center;
    gap: 1.5rem;
}

.auth-toolbar { display: flex; width: min(100%, 30rem); align-items: center; justify-content: space-between; gap: 1rem; }
.language-switcher { display: flex; gap: .25rem; }
.language-switcher form { margin: 0; }
.language-button { padding: .35rem .45rem; border: 0; border-radius: .45rem; color: var(--muted); background: transparent; font-size: .78rem; font-weight: 750; }
.language-button:hover, .language-button.active { color: var(--accent-dark); background: var(--accent-soft); }

.brand { display: inline-flex; align-items: center; gap: .65rem; color: var(--accent-dark); font-size: .82rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.brand-mark { display: grid; width: 2.4rem; height: 2.4rem; place-items: center; border-radius: .8rem; color: #fff; background: var(--accent); box-shadow: 0 8px 18px rgb(8 127 117 / 25%); font-size: 1.3rem; }
.card { border: 1px solid var(--line); border-radius: 1.25rem; background: var(--card); box-shadow: var(--shadow); }
.auth-card { width: min(100%, 30rem); padding: clamp(1.5rem, 5vw, 3rem); }
.auth-card h1, .page-header h1 { margin: 0; color: var(--ink); font-size: clamp(1.8rem, 4vw, 2.5rem); letter-spacing: -.04em; line-height: 1.1; }
.lede { margin: .8rem 0 1.8rem; color: var(--muted); }

.stack-form { display: grid; gap: 1rem; }
.stack-form > div { display: grid; gap: .4rem; }
label { color: var(--ink); font-size: .88rem; font-weight: 700; }
input { width: 100%; min-height: 2.9rem; padding: .65rem .8rem; border: 1px solid #c8d8d5; border-radius: .65rem; color: var(--ink); background: #fbfdfc; }
input:focus { border-color: var(--accent); }
.form-errors, .form-error-message { color: var(--danger); font-size: .82rem; }

.primary-button, .secondary-button { min-height: 2.9rem; padding: .65rem 1rem; border: 0; border-radius: .65rem; font-weight: 750; transition: background-color .15s ease, transform .15s ease; }
.primary-button { color: #fff; background: var(--accent); }
.primary-button:hover { background: var(--accent-dark); transform: translateY(-1px); }
.secondary-button { color: var(--accent-dark); background: var(--accent-soft); }
.secondary-button:hover { background: #cdebe4; }
.muted-note { margin: 1.2rem 0 0; color: var(--muted); font-size: .82rem; }
.flash { margin: 1rem 0; padding: .8rem 1rem; border-radius: .65rem; }
.flash-error { color: #7e2925; background: #fbe8e5; }

.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin: 1rem 0 2rem; }
.page-header p { margin: .55rem 0 0; color: var(--muted); }
.header-actions { display: flex; align-items: center; gap: .75rem; flex: 0 0 auto; }
.inline-form { flex: 0 0 auto; }
.overview-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .8rem; margin-bottom: 1rem; }
.stat-card { padding: 1.1rem; }
.stat-card strong { display: block; color: var(--accent-dark); font-size: clamp(1.6rem, 5vw, 2.25rem); letter-spacing: -.05em; line-height: 1; }
.stat-card span { display: block; margin-top: .45rem; color: var(--muted); font-size: .82rem; font-weight: 700; }

.download-card { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; padding: 1rem 1.1rem; border: 1px solid #bfe3db; border-radius: 1rem; background: var(--accent-soft); }
.download-card h2 { margin: 0; font-size: 1rem; }
.download-card p { margin: .2rem 0 0; color: var(--muted); font-size: .85rem; }
.download-status { flex-basis: 100%; color: var(--accent-dark); font-size: .84rem; font-weight: 700; }
progress { display: block; width: 100%; height: .65rem; accent-color: var(--accent); }

.breakdown-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.breakdown-card { padding: 1.25rem; }
.breakdown-card h2 { margin: 0 0 .8rem; font-size: 1rem; }
.metric-list { display: grid; gap: .55rem; margin: 0; padding: 0; list-style: none; }
.metric-list li { display: flex; align-items: center; justify-content: space-between; gap: 1rem; color: var(--muted); }
.metric-list strong { color: var(--ink); }
.page-footer { margin: 1.5rem 0 2rem; color: var(--muted); font-size: .85rem; }

@media (min-width: 42rem) {
    .site-body { padding: 2rem; }
    .overview-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 38rem) {
    .page-header, .download-card { align-items: stretch; flex-direction: column; }
    .header-actions { align-items: stretch; flex-direction: column; }
    .header-actions .language-switcher { align-self: flex-end; }
    .inline-form, .download-card form, .download-card button { width: 100%; }
    .breakdown-grid { grid-template-columns: 1fr; }
}
