:root {
    --color-sidebar: #0d1723;
    --color-sidebar-muted: #8d98aa;
    --color-primary: #db1f31;
    --color-primary-dark: #b51223;
    --color-background: #f4f7fb;
    --color-surface: #ffffff;
    --color-surface-alt: #eef2f7;
    --color-text: #162033;
    --color-text-muted: #667188;
    --color-success: #1f9d55;
    --color-danger: #db1f31;
    --color-warning: #f59e0b;
    --color-border: #dde4ee;
    --shadow-card: 0 18px 35px rgba(13, 23, 35, 0.08);
    --shadow-soft: 0 8px 20px rgba(13, 23, 35, 0.06);
    --radius-card: 18px;
    --radius-small: 12px;
    --content-width: 1280px;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: Arial, Helvetica, sans-serif;
    color: var(--color-text);
    background: var(--color-background);
    line-height: 1.5;
}

a {
    color: inherit;
    text-decoration: none;
}

img {
    max-width: 100%;
    display: block;
}

button,
input,
textarea,
select {
    font: inherit;
}

.app-body {
    overflow-x: hidden;
}

.public-body {
    background:
        radial-gradient(circle at top right, rgba(219, 31, 49, 0.08), transparent 22%),
        linear-gradient(180deg, #fbfcfe 0%, #f4f7fb 100%);
}

.public-header {
    position: sticky;
    top: 0;
    z-index: 30;
    background: rgba(251, 252, 254, 0.92);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid rgba(221, 228, 238, 0.9);
}

.public-header__inner,
.public-footer__inner,
.public-section,
.hero-section,
.auth-section {
    width: min(100% - 2rem, var(--content-width));
    margin: 0 auto;
}

.public-header__inner,
.public-footer__inner {
    min-height: 84px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
}

.brand-link {
    display: inline-flex;
    flex-direction: column;
    gap: 0.2rem;
}

.brand-link--sidebar {
    color: #fff;
}

.brand-mark {
    font-size: 1.9rem;
    font-weight: 800;
    letter-spacing: 0;
}

.brand-mark strong {
    color: var(--color-primary);
}

.brand-subtitle {
    font-size: 0.84rem;
    text-transform: uppercase;
    color: var(--color-text-muted);
    letter-spacing: 0.08em;
}

.brand-link--sidebar .brand-subtitle {
    color: var(--color-sidebar-muted);
}

.public-nav,
.public-actions,
.button-row,
.form-actions,
.card-actions {
    display: flex;
    align-items: center;
    gap: 0.9rem;
}

.public-nav a {
    padding: 0.8rem 1rem;
    border-radius: var(--radius-small);
    color: var(--color-text-muted);
    font-weight: 600;
}

.public-nav a:hover,
.public-nav a.is-active {
    background: rgba(219, 31, 49, 0.08);
    color: var(--color-text);
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 46px;
    padding: 0.75rem 1.2rem;
    border: 1px solid transparent;
    border-radius: 14px;
    cursor: pointer;
    font-weight: 700;
    transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.button:hover,
.button:focus-visible,
.icon-button:hover,
.icon-button:focus-visible {
    transform: translateY(-1px);
}

.button-primary {
    background: var(--color-primary);
    color: #fff;
}

.button-primary:hover,
.button-primary:focus-visible {
    background: var(--color-primary-dark);
}

.button-danger {
    background: rgba(219, 31, 49, 0.1);
    color: var(--color-danger);
    border-color: rgba(219, 31, 49, 0.15);
}

.button-ghost {
    background: transparent;
    border-color: var(--color-border);
    color: var(--color-text);
}

.button-small {
    min-height: 38px;
    padding: 0.55rem 0.9rem;
    font-size: 0.92rem;
}

.button-block {
    width: 100%;
}

.hero-section {
    padding: 3rem 0 2rem;
}

.hero-panel {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(360px, 0.85fr);
    gap: 2rem;
    align-items: stretch;
    padding: 2rem 0 4rem;
}

.hero-copy,
.hero-preview,
.content-card,
.auth-card,
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
}

.hero-copy {
    padding: 3.5rem;
}

.hero-copy h1 {
    margin: 0 0 1rem;
    font-size: clamp(2.8rem, 6vw, 4.8rem);
    line-height: 1.05;
}

.hero-copy p,
.section-header p,
.content-card p,
.auth-card p,
.card p,
.helper-text,
.empty-copy {
    color: var(--color-text-muted);
}

.hero-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1.8rem;
    flex-wrap: wrap;
}

.hero-preview {
    padding: 1.4rem;
    background:
        linear-gradient(180deg, rgba(13, 23, 35, 0.04), transparent),
        var(--color-surface);
    display: grid;
    gap: 1rem;
}

.preview-card,
.preview-stat {
    border-radius: 16px;
    border: 1px solid var(--color-border);
    background: var(--color-surface-alt);
    padding: 1.1rem 1.2rem;
}

.preview-card--sidebar {
    background: linear-gradient(180deg, #111a28 0%, #0d1723 100%);
    border-color: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.preview-card__label,
.stat-card__label,
.topbar__eyebrow,
.eyebrow {
    display: inline-block;
    color: var(--color-primary);
    text-transform: uppercase;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.08em;
}

.preview-stats {
    display: grid;
    gap: 1rem;
}

.preview-stat span,
.stat-card__meta,
.stat-card__note,
.metric-row span,
.measurement-item span,
.photo-card__meta span,
.entry-list__meta span,
.footer-copy {
    color: var(--color-text-muted);
}

.public-section,
.auth-section {
    padding: 0 0 4rem;
}

.section-header {
    margin-bottom: 1.5rem;
}

.section-header h1,
.section-header h2,
.page-head h1,
.card-header h2,
.goal-card h2,
.placeholder-card h2 {
    margin: 0.35rem 0 0.6rem;
    line-height: 1.1;
}

.feature-grid,
.summary-grid,
.measurement-grid,
.metric-grid {
    display: grid;
    gap: 1rem;
}

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

.feature-card {
    padding: 1.6rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-soft);
}

.content-card,
.auth-card {
    padding: 2rem;
}

.content-card--wide {
    max-width: 920px;
}

.content-card--narrow,
.auth-card {
    max-width: 760px;
}

.auth-card--wide {
    max-width: 920px;
}

.auth-card {
    margin: 0 auto;
}

.auth-footer {
    margin: 1rem 0 0;
}

.auth-footer a {
    color: var(--color-primary);
    font-weight: 700;
}

.app-shell {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    min-height: 100vh;
}

.app-sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 1.5rem 1.1rem;
    background: linear-gradient(180deg, #111a28 0%, #0d1723 100%);
    color: #fff;
    display: flex;
    flex-direction: column;
    gap: 1.3rem;
}

.sidebar-nav {
    display: grid;
    gap: 0.35rem;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.92rem 1rem;
    border-radius: 14px;
    color: #f4f6fb;
    font-weight: 700;
}

.sidebar-link:hover,
.sidebar-link.is-active {
    background: linear-gradient(90deg, rgba(219, 31, 49, 1) 0%, rgba(219, 31, 49, 0.9) 100%);
}

.sidebar-link__icon,
.stat-card__icon,
.sidebar-promo__icon,
.photo-empty__icon {
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.08);
}

.sidebar-link__icon svg,
.stat-card__icon svg,
.sidebar-promo__icon svg,
.photo-empty__icon svg,
.icon-button svg {
    width: 22px;
    height: 22px;
}

.sidebar-promo {
    margin-top: auto;
}

.card-dark {
    background: rgba(255, 255, 255, 0.03);
    border-color: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.app-main {
    min-width: 0;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 15;
    min-height: 84px;
    padding: 1rem 2rem;
    background: rgba(244, 247, 251, 0.92);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.topbar__left,
.topbar__right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.topbar__summary {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.role-badge {
    display: inline-flex;
    align-items: center;
    min-height: 38px;
    padding: 0.55rem 0.85rem;
    border-radius: 999px;
    background: #fff;
    border: 1px solid var(--color-border);
    color: var(--color-text-muted);
    font-weight: 700;
}

.icon-button {
    width: 42px;
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--color-border);
    border-radius: 12px;
    background: #fff;
    cursor: pointer;
    color: var(--color-text);
}

.topbar__menu {
    display: none;
    flex-direction: column;
    gap: 4px;
}

.topbar__menu span {
    width: 18px;
    height: 2px;
    background: var(--color-text);
    border-radius: 999px;
}

.app-content {
    padding: 1.5rem 2rem 2.5rem;
}

.page-head {
    margin-bottom: 1.5rem;
}

.page-head p {
    margin: 0;
    color: var(--color-text-muted);
}

.flash-stack {
    display: grid;
    gap: 0.85rem;
    margin-bottom: 1.5rem;
}

.flash {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.1rem;
    border-radius: 14px;
    border: 1px solid var(--color-border);
    background: #fff;
    box-shadow: var(--shadow-soft);
}

.flash-success {
    border-color: rgba(31, 157, 85, 0.25);
}

.flash-error {
    border-color: rgba(219, 31, 49, 0.2);
}

.flash-warning {
    border-color: rgba(245, 158, 11, 0.25);
}

.flash-info {
    border-color: rgba(22, 32, 51, 0.12);
}

.flash__close {
    border: 0;
    background: transparent;
    font-size: 1.3rem;
    cursor: pointer;
    color: var(--color-text-muted);
}

.card,
.welcome-card {
    padding: 1.5rem;
}

.welcome-card {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    padding: 0.55rem 0.9rem;
    border-radius: 999px;
    background: rgba(219, 31, 49, 0.08);
    color: var(--color-primary);
    font-weight: 700;
}

.summary-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-bottom: 1rem;
}

.stat-card {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    padding: 1.35rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-soft);
}

.stat-card__icon--primary {
    color: #2563eb;
    background: rgba(37, 99, 235, 0.08);
}

.stat-card__icon--danger {
    color: var(--color-danger);
    background: rgba(219, 31, 49, 0.08);
}

.stat-card__icon--success {
    color: var(--color-success);
    background: rgba(31, 157, 85, 0.08);
}

.stat-card__icon--warning {
    color: var(--color-warning);
    background: rgba(245, 158, 11, 0.09);
}

.stat-card__value {
    margin: 0.35rem 0 0.3rem;
    font-size: 2rem;
    line-height: 1;
}

.dashboard-grid,
.two-column-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(340px, 0.75fr);
    gap: 1rem;
}

.dashboard-main,
.dashboard-side {
    display: grid;
    gap: 1rem;
    align-content: start;
}

.goal-card__header,
.card-header,
.card-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.goal-card__percent {
    color: var(--color-success);
    font-size: 2rem;
    font-weight: 800;
}

.progress-bar {
    margin: 1rem 0;
    width: 100%;
    height: 12px;
    border-radius: 999px;
    background: #e4e9f1;
    overflow: hidden;
}

.progress-bar span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #1f9d55 0%, #27c86c 100%);
}

.goal-card__meta {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.segmented-control {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem;
    border-radius: 14px;
    background: var(--color-surface-alt);
    border: 1px solid var(--color-border);
}

.segmented-control--wrap {
    flex-wrap: wrap;
}

.segmented-control__button {
    min-height: 38px;
    padding: 0.55rem 0.9rem;
    border-radius: 10px;
    border: 0;
    background: transparent;
    color: var(--color-text-muted);
    cursor: pointer;
    font-weight: 700;
}

.segmented-control__button.is-active,
.segmented-control__button:hover {
    background: var(--color-primary);
    color: #fff;
}

.chart-wrap {
    position: relative;
    min-height: 320px;
}

.chart-wrap canvas {
    width: 100% !important;
    height: 320px !important;
}

.chart-empty {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    text-align: center;
    color: var(--color-text-muted);
}

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

.measurement-item,
.metric-row,
.entry-list__item,
.photo-card,
.photo-detail__meta {
    border: 1px solid var(--color-border);
    border-radius: 14px;
    background: #fff;
}

.measurement-item {
    padding: 1rem;
}

.measurement-item strong {
    display: block;
    margin: 0.35rem 0;
    font-size: 1.35rem;
}

.delta-up {
    color: var(--color-success);
}

.delta-down {
    color: var(--color-danger);
}

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

.photo-card {
    overflow: hidden;
    display: block;
}

.photo-card img {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    background: #eff2f7;
}

.photo-card__meta {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.9rem 1rem;
}

.photo-empty {
    border: 1px dashed var(--color-border);
    border-radius: var(--radius-card);
    padding: 2rem;
    text-align: center;
}

.photo-empty__icon {
    margin: 0 auto 1rem;
    color: var(--color-text-muted);
    background: var(--color-surface-alt);
}

.entry-list {
    display: grid;
    gap: 0.75rem;
}

.entry-list__item {
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    gap: 1rem;
}

.entry-list__item strong,
.metric-row strong {
    display: block;
    margin-bottom: 0.2rem;
}

.entry-list__meta {
    text-align: right;
}

.empty-state {
    border: 1px dashed var(--color-border);
    border-radius: var(--radius-card);
    padding: 1.8rem;
}

.placeholder-layout {
    max-width: 920px;
}

.placeholder-card {
    padding: 2rem;
}

.form-grid {
    display: grid;
    gap: 1rem;
}

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

.form-field {
    display: grid;
    gap: 0.45rem;
}

.form-field--full,
.form-actions,
.range-field {
    grid-column: 1 / -1;
}

.input,
.form-field input,
.form-field select,
.form-field textarea {
    width: 100%;
    min-height: 48px;
    padding: 0.85rem 1rem;
    border-radius: 14px;
    border: 1px solid var(--color-border);
    background: #f9fbfd;
    color: var(--color-text);
}

.form-field textarea {
    min-height: 120px;
    resize: vertical;
}

.input:focus,
.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
    outline: 3px solid rgba(219, 31, 49, 0.12);
    border-color: rgba(219, 31, 49, 0.4);
    background: #fff;
}

.checkbox-field {
    display: flex;
    align-items: flex-start;
    gap: 0.8rem;
    color: var(--color-text);
}

.checkbox-field input {
    margin-top: 0.25rem;
}

.field-errors {
    margin: 0;
    padding-left: 1rem;
    color: var(--color-danger);
    font-size: 0.92rem;
}

.range-field {
    display: grid;
    gap: 0.55rem;
}

.range-field__control {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 1rem;
    align-items: center;
}

input[type="range"] {
    accent-color: var(--color-primary);
    min-height: auto;
    padding: 0;
    background: transparent;
    border: 0;
}

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

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 1rem 0.8rem;
    border-bottom: 1px solid var(--color-border);
    text-align: left;
}

.data-table th {
    color: var(--color-text-muted);
    font-size: 0.9rem;
}

.table-actions {
    display: flex;
    gap: 0.9rem;
    flex-wrap: wrap;
}

.table-actions a {
    color: var(--color-primary);
    font-weight: 700;
}

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

.metric-row {
    padding: 0.95rem 1rem;
}

.photo-detail {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 1rem;
    margin-top: 1rem;
}

.photo-detail > img {
    width: 100%;
    border-radius: var(--radius-card);
    border: 1px solid var(--color-border);
    background: #eff2f7;
}

.photo-detail__meta {
    padding: 1rem;
    display: grid;
    gap: 0.75rem;
    align-content: start;
}

.public-main {
    padding-bottom: 2rem;
}

.public-footer {
    border-top: 1px solid rgba(221, 228, 238, 0.9);
    background: rgba(255, 255, 255, 0.8);
}

.footer-brand {
    margin: 0;
    font-weight: 800;
}

@media (max-width: 1180px) {
    .summary-grid,
    .feature-grid,
    .photo-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

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

    .dashboard-grid,
    .two-column-layout,
    .photo-detail,
    .hero-panel {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 980px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .app-sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        width: min(88vw, 320px);
        transform: translateX(-102%);
        transition: transform 0.2s ease;
        z-index: 40;
    }

    .app-body.sidebar-open .app-sidebar {
        transform: translateX(0);
    }

    .topbar {
        padding: 1rem 1.2rem;
    }

    .topbar__menu {
        display: inline-flex;
    }

    .app-content {
        padding: 1.25rem;
    }
}

@media (max-width: 720px) {
    .public-header__inner,
    .public-footer__inner {
        min-height: auto;
        padding: 1rem 0;
        flex-direction: column;
        align-items: flex-start;
    }

    .public-actions,
    .public-nav,
    .button-row,
    .card-actions,
    .goal-card__meta {
        width: 100%;
        flex-wrap: wrap;
    }

    .hero-copy,
    .content-card,
    .auth-card,
    .card {
        padding: 1.25rem;
    }

    .summary-grid,
    .feature-grid,
    .measurement-grid,
    .photo-grid,
    .metric-grid,
    .form-grid--two {
        grid-template-columns: 1fr;
    }

    .topbar {
        align-items: flex-start;
    }

    .topbar__right {
        align-self: stretch;
        justify-content: space-between;
    }

    .entry-list__item {
        flex-direction: column;
    }

    .entry-list__meta {
        text-align: left;
    }
}
