:root {
    --bg: #f3f3f1;
    --bg-soft: #f8f8f7;
    --surface: #ffffff;
    --surface-muted: #fafafa;
    --surface-strong: #f0f0ef;
    --ink: #0f0f0f;
    --ink-soft: #555555;
    --ink-faint: #777777;
    --line: #ddddda;
    --line-strong: #bdbdb8;
    --line-dark: #151515;
    --shadow-soft: 0 14px 36px rgba(0, 0, 0, 0.04);
    --shadow-strong: 0 24px 56px rgba(0, 0, 0, 0.08);
    --radius-xl: 28px;
    --radius-lg: 22px;
    --radius-md: 16px;
    --radius-sm: 12px;
    --content-pad: 1rem;
    --font-main: "Avenir Next", "Helvetica Neue", "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font-main);
    color: var(--ink);
    background:
        radial-gradient(circle at top center, rgba(255, 255, 255, 0.92), transparent 38%),
        linear-gradient(180deg, #f8f8f7 0%, #f1f1ef 100%);
    letter-spacing: -0.01em;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

body.app-shell {
    position: relative;
}

.page-gradient {
    position: fixed;
    inset: 0;
    pointer-events: none;
    background:
        radial-gradient(circle at 50% 0%, rgba(255, 255, 255, 0.82), transparent 34%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.12), rgba(0, 0, 0, 0));
    opacity: 0.75;
    z-index: 0;
}

.container-xxl,
.topbar,
.hero-section,
.flash-section,
.dashboard-section {
    position: relative;
    z-index: 1;
}

.container-xxl {
    padding-inline: var(--content-pad);
}

.shadow-soft {
    box-shadow: var(--shadow-soft);
}

.eyebrow {
    margin-bottom: 0.65rem;
    color: var(--ink-faint);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.topbar {
    padding: 1rem 0 0.75rem;
}

.topbar-inner {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
}

.page-title {
    margin: 0;
    font-size: clamp(1.85rem, 8vw, 2.8rem);
    font-weight: 650;
    letter-spacing: -0.05em;
    line-height: 0.95;
}

.topbar-actions {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.last-entry-pill {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    padding: 0.95rem 1rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.86);
}

.last-entry-pill span {
    color: var(--ink-faint);
    font-size: 0.76rem;
}

.last-entry-pill strong {
    color: var(--ink);
    font-size: 0.94rem;
    font-weight: 600;
}

.logout-form {
    width: 100%;
}

.logout-form .btn {
    width: 100%;
}

.hero-section {
    padding-bottom: 0.6rem;
}

.hero-card,
.panel-card,
.login-card {
    border: 1px solid var(--line);
    border-radius: var(--radius-xl);
    background: rgba(255, 255, 255, 0.92);
    box-shadow: var(--shadow-soft);
}

.hero-card {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    padding: 1.15rem;
}

.hero-copy h2 {
    margin: 0 0 0.65rem;
    font-size: clamp(1.4rem, 6vw, 2.2rem);
    font-weight: 650;
    letter-spacing: -0.045em;
    line-height: 1;
}

.hero-copy p {
    margin: 0;
    color: var(--ink-soft);
    line-height: 1.65;
    max-width: 52ch;
}

.hero-meter {
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface);
    padding: 1rem;
}

.metric-label-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.metric-label-row span {
    color: var(--ink-soft);
    font-size: 0.92rem;
    line-height: 1.4;
}

.metric-label-row strong {
    font-size: 1.9rem;
    font-weight: 650;
    letter-spacing: -0.05em;
    white-space: nowrap;
}

.premium-progress {
    height: 12px;
    background: #e8e8e6;
    border-radius: 999px;
    overflow: hidden;
}

.premium-progress .progress-bar {
    border-radius: 999px;
    background: linear-gradient(90deg, #111111 0%, #4c4c4c 100%);
}

.hero-subline {
    margin-top: 0.75rem;
    color: var(--ink-faint);
    font-size: 0.88rem;
    line-height: 1.5;
}

.flash-section {
    padding: 0.55rem 0 0.3rem;
}

.flash-anchor {
    scroll-margin-top: 1rem;
}

.flash-stack {
    display: grid;
    gap: 0.7rem;
}

.alert {
    margin-bottom: 0;
    padding: 0.95rem 1rem;
    border: 1px solid var(--line);
    border-left: 4px solid var(--line-dark);
    border-radius: 18px;
    background: #ffffff;
    color: var(--ink);
    box-shadow: none;
}

.alert-success,
.alert-primary,
.alert-warning,
.alert-danger {
    color: var(--ink);
    background: #ffffff;
    border-color: var(--line);
}

.alert-success {
    border-left-color: #111111;
}

.alert-primary {
    border-left-color: #3b3b3b;
}

.alert-warning {
    border-left-color: #666666;
}

.alert-danger {
    border-left-color: #252525;
    background: #fcfcfc;
}

.dashboard-section {
    padding-bottom: 2.5rem;
}

.panel-card {
    padding: 1rem;
    height: 100%;
}

.section-head {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.45rem;
    margin-bottom: 1rem;
}

.section-head.compact {
    margin-bottom: 0.9rem;
}

.section-head h3 {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 650;
    letter-spacing: -0.035em;
    line-height: 1.15;
}

.section-meta {
    color: var(--ink-faint);
    font-size: 0.88rem;
    line-height: 1.45;
}

.upload-zone {
    padding: 1rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface-muted);
}

.upload-label {
    display: flex;
    flex-direction: column;
    gap: 0.22rem;
    margin-bottom: 0.9rem;
}

.upload-kicker {
    color: var(--ink-faint);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.upload-title {
    color: var(--ink);
    font-size: 1.05rem;
    font-weight: 600;
    line-height: 1.25;
}

.upload-meta {
    color: var(--ink-faint);
    font-size: 0.9rem;
    line-height: 1.5;
}

.clean-input {
    min-height: 54px;
    padding: 0.9rem 1rem;
    border: 1px solid var(--line-strong);
    border-radius: 16px;
    background: #ffffff;
    color: var(--ink);
    box-shadow: none;
}

.clean-input:focus {
    border-color: #101010;
    box-shadow: 0 0 0 0.22rem rgba(0, 0, 0, 0.07);
}

.form-control[type="file"]::file-selector-button {
    margin-right: 0.9rem;
    padding: 0.7rem 1rem;
    border: 0;
    border-radius: 12px;
    background: #111111;
    color: #ffffff;
    font-weight: 600;
    cursor: pointer;
}

.form-control[type="file"]:disabled::file-selector-button {
    background: #787878;
}

.form-label {
    color: var(--ink-soft);
    font-size: 0.92rem;
    font-weight: 500;
}

.form-action-row {
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
}

.action-button {
    min-height: 52px;
    padding: 0.9rem 1.2rem;
    border-radius: 999px;
    font-weight: 650;
    letter-spacing: -0.01em;
}

.action-button[disabled] {
    cursor: not-allowed;
}

.micro-note {
    color: var(--ink-faint);
    font-size: 0.88rem;
    line-height: 1.5;
}

.quick-stats {
    background: rgba(255, 255, 255, 0.96);
}

.avg-block + .avg-block {
    margin-top: 0.9rem;
}

.avg-title {
    margin-bottom: 0.55rem;
    color: var(--ink-faint);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.avg-values {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.55rem;
}

.avg-values span {
    display: flex;
    flex-direction: column;
    gap: 0.22rem;
    padding: 0.75rem;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--surface);
    color: var(--ink-faint);
    font-size: 0.8rem;
}

.avg-values strong {
    color: var(--ink);
    font-size: 1.05rem;
    font-weight: 650;
}

.motivation-note {
    margin-top: 1rem;
    padding-top: 0.95rem;
    border-top: 1px solid var(--line);
    color: var(--ink-soft);
    line-height: 1.6;
}

.metric-card {
    width: 100%;
    min-height: 132px;
    display: flex;
    flex-direction: column;
    gap: 0.42rem;
    padding: 0.95rem;
    border: 1px solid var(--line);
    border-radius: 22px;
    background: #ffffff;
    text-align: left;
    transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.metric-card:hover,
.metric-card.is-active {
    border-color: var(--line-dark);
    transform: translateY(-2px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.05);
}

.metric-label {
    color: var(--ink-faint);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.metric-value {
    color: var(--ink);
    font-size: 1.6rem;
    font-weight: 650;
    letter-spacing: -0.05em;
    line-height: 1;
}

.metric-value.small {
    font-size: 1rem;
    line-height: 1.35;
}

.metric-foot {
    margin-top: auto;
    color: var(--ink-soft);
    font-size: 0.88rem;
    line-height: 1.4;
}

.chart-range-switch {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.range-button {
    min-width: 68px;
    border-radius: 999px;
}

.range-button.active {
    background: #111111;
    border-color: #111111;
    color: #ffffff;
}

.chart-shell {
    position: relative;
    min-height: 276px;
    padding: 0.75rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface);
    overflow: hidden;
}

.chart-shell.compact {
    min-height: 260px;
}

.chart-shell.is-empty canvas {
    opacity: 0.12;
}

.chart-empty {
    position: absolute;
    inset: 0.75rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 1rem;
    text-align: center;
    color: var(--ink-soft);
}

.chart-empty h4 {
    margin: 0 0 0.45rem;
    color: var(--ink);
    font-size: 1.08rem;
    font-weight: 650;
}

.chart-empty p {
    margin: 0;
    max-width: 28ch;
    line-height: 1.55;
}

.chart-empty.compact p {
    max-width: 24ch;
}

.heatmap-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0.5rem;
}

.heatmap-cell {
    min-height: 72px;
    padding: 0.7rem 0.45rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: #ffffff;
    transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.heatmap-cell:hover {
    transform: translateY(-1px);
    border-color: var(--line-strong);
}

.heatmap-cell.has-entry {
    background: #161616;
    border-color: #161616;
    color: #ffffff;
}

.heatmap-cell.has-entry .heatmap-weekday {
    color: rgba(255, 255, 255, 0.72);
}

.heatmap-cell.is-empty {
    background: #fbfbfb;
}

.heatmap-number {
    font-size: 0.98rem;
    font-weight: 650;
    line-height: 1;
}

.heatmap-weekday {
    color: var(--ink-faint);
    font-size: 0.74rem;
    line-height: 1;
}

.table-responsive {
    border: 1px solid var(--line);
    border-radius: 20px;
    background: #ffffff;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.premium-table {
    min-width: 520px;
    margin-bottom: 0;
}

.premium-table thead th {
    padding: 0.95rem 1rem;
    border-bottom-color: var(--line);
    color: var(--ink-faint);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    background: #ffffff;
}

.premium-table tbody td {
    padding: 0.95rem 1rem;
    border-color: #ececea;
    color: var(--ink);
    white-space: nowrap;
}

.premium-table tbody tr:last-child td {
    border-bottom: 0;
}

.table-empty-state {
    padding: 1.65rem 1rem;
    border: 1px dashed var(--line-strong);
    border-radius: var(--radius-lg);
    background: #fcfcfc;
    text-align: center;
}

.table-empty-state h4 {
    margin: 0 0 0.4rem;
    font-size: 1.1rem;
    font-weight: 650;
    letter-spacing: -0.03em;
}

.table-empty-state p {
    margin: 0;
    color: var(--ink-soft);
    line-height: 1.6;
}

.btn {
    transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn-dark {
    background: #111111;
    border-color: #111111;
    color: #ffffff;
}

.btn-dark:hover,
.btn-dark:focus,
.btn-dark:active {
    background: #000000;
    border-color: #000000;
    color: #ffffff;
}

.btn-outline-dark {
    background: #ffffff;
    border-color: #111111;
    color: #111111;
}

.btn-outline-dark:hover,
.btn-outline-dark:focus,
.btn-outline-dark:active {
    background: #111111;
    border-color: #111111;
    color: #ffffff;
}

.login-shell {
    position: relative;
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1rem;
    overflow: hidden;
}

.login-backdrop {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at top center, rgba(255, 255, 255, 0.96), transparent 36%),
        linear-gradient(180deg, #f7f7f6 0%, #efefed 100%);
}

.login-card-wrap {
    position: relative;
    z-index: 1;
    width: min(100%, 32rem);
}

.brand-mark {
    width: 62px;
    height: 62px;
    margin: 0 auto 1rem;
    display: grid;
    place-items: center;
    border-radius: 18px;
    background: #111111;
    color: #ffffff;
    font-size: 1.18rem;
    font-weight: 700;
    letter-spacing: -0.04em;
    box-shadow: var(--shadow-strong);
}

.login-card {
    padding: 1.35rem;
}

.display-title {
    margin: 0 0 0.7rem;
    font-size: clamp(2rem, 10vw, 3.15rem);
    font-weight: 650;
    letter-spacing: -0.07em;
    line-height: 0.95;
}

.lead-copy {
    margin-bottom: 1.35rem;
    color: var(--ink-soft);
    line-height: 1.7;
}

.login-form {
    margin-top: 1.15rem;
}

.section-is-highlighted {
    box-shadow: 0 0 0 1px rgba(17, 17, 17, 0.16), 0 24px 52px rgba(0, 0, 0, 0.08);
}

@media (min-width: 576px) {
    :root {
        --content-pad: 1.2rem;
    }

    .topbar {
        padding-top: 1.25rem;
    }

    .hero-card,
    .panel-card,
    .login-card {
        border-radius: 30px;
    }

    .hero-card,
    .panel-card {
        padding: 1.2rem;
    }

    .metric-card {
        min-height: 146px;
        padding: 1rem;
    }

    .metric-value {
        font-size: 1.75rem;
    }

    .metric-value.small {
        font-size: 1.08rem;
    }

    .chart-shell {
        min-height: 295px;
    }

    .chart-shell.compact {
        min-height: 280px;
    }
}

@media (min-width: 768px) {
    :root {
        --content-pad: 1.4rem;
    }

    .topbar {
        padding: 1.6rem 0 1rem;
    }

    .topbar-actions {
        flex-direction: row;
        align-items: center;
    }

    .last-entry-pill,
    .logout-form {
        width: auto;
    }

    .logout-form .btn {
        width: auto;
    }

    .hero-card {
        padding: 1.5rem;
    }

    .panel-card {
        padding: 1.35rem;
    }

    .section-head {
        gap: 0.7rem;
    }

    .section-meta {
        white-space: nowrap;
    }

    .form-action-row {
        align-items: flex-start;
    }

    .chart-shell {
        min-height: 320px;
        padding: 1rem;
    }

    .chart-shell.compact {
        min-height: 320px;
    }

    .heatmap-grid {
        grid-template-columns: repeat(10, minmax(0, 1fr));
        gap: 0.7rem;
    }

    .heatmap-cell {
        min-height: 82px;
        padding: 0.8rem 0.55rem;
    }

    .premium-table thead th,
    .premium-table tbody td {
        padding-inline: 1.15rem;
    }

    .table-empty-state {
        padding: 2rem 1.5rem;
    }

    .login-shell {
        padding: 1.5rem;
    }

    .login-card {
        padding: 1.7rem;
    }
}

@media (min-width: 992px) {
    :root {
        --content-pad: 1.6rem;
    }

    .topbar-inner {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }

    .topbar-actions {
        width: auto;
        justify-content: flex-end;
    }

    .hero-card {
        grid-template-columns: minmax(0, 1.3fr) minmax(320px, 0.85fr);
        align-items: center;
        gap: 1.25rem;
        padding: 1.7rem;
    }

    .hero-meter {
        padding: 1.2rem;
    }

    .section-head,
    .form-action-row {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }

    .panel-card {
        padding: 1.45rem;
    }

    .metric-card {
        min-height: 154px;
    }

    .metric-value.small {
        font-size: 1.12rem;
    }
}

@media (min-width: 1200px) {
    .page-title {
        font-size: 3.25rem;
    }

    .hero-copy h2 {
        font-size: 2.5rem;
    }

    .panel-card {
        padding: 1.55rem;
    }
}
