:root {
    --primary: #ff5f8f;
    --primary-dark: #ff477d;
    --soft: #fff1f5;
    --bg: #f8f8fb;
    --card: #ffffff;
    --text: #222222;
    --muted: #888888;
    --line: #f0edf2;
    --shadow: 0 14px 34px rgba(255, 95, 143, .12);
    --radius: 20px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(255, 95, 143, .10), transparent 34%),
        linear-gradient(180deg, #fff8fb 0, var(--bg) 270px);
}

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

button,
input,
textarea {
    font: inherit;
}

.app-shell {
    width: 100%;
    max-width: 430px;
    min-height: 100vh;
    margin: 0 auto;
    padding: 18px 16px 96px;
}

.page-hero,
.sub-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.page-hero h1,
.sub-header h1,
.profile-hero h1 {
    margin: 0;
    font-size: 22px;
    line-height: 1.25;
}

.sub-header h1 {
    font-size: 18px;
}

.back-link {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    font-size: 28px;
    background: rgba(255, 255, 255, .72);
}

.muted {
    color: var(--muted);
}

.page-hero p,
.profile-hero p,
.vip-card p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.avatar-small,
.avatar-large {
    display: grid;
    place-items: center;
    border-radius: 50%;
    color: #fff;
    font-weight: 700;
    background: linear-gradient(135deg, #ffc1d4, var(--primary));
    box-shadow: var(--shadow);
}

.avatar-small {
    width: 42px;
    height: 42px;
}

.avatar-large {
    width: 72px;
    height: 72px;
    font-size: 28px;
}

.card,
.soft-card {
    background: var(--card);
    border: 1px solid rgba(255, 255, 255, .7);
    border-radius: var(--radius);
    box-shadow: 0 10px 28px rgba(28, 31, 46, .06);
    padding: 16px;
    margin-bottom: 14px;
}

.soft-card {
    background: linear-gradient(135deg, #ffe3ec, #fff5f8 55%, #fff);
    box-shadow: var(--shadow);
}

.period-overview {
    background: linear-gradient(135deg, #eaf2ff, #f7fbff 58%, #fff);
}

.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.card-head h2,
.card h2 {
    margin: 0;
    font-size: 16px;
}

.card-head a,
.card-head span,
.card small {
    color: var(--muted);
    font-size: 12px;
}

.section-label {
    color: var(--primary);
    font-size: 13px;
    font-weight: 700;
}

.section-label.blue {
    color: #4f83ff;
}

.overview-grid {
    display: grid;
    grid-template-columns: 1fr 132px;
    align-items: end;
    gap: 8px;
}

.big-number {
    margin: 8px 0 6px;
    font-size: 36px;
    font-weight: 800;
    letter-spacing: 0;
}

.big-number span {
    font-size: 15px;
    font-weight: 700;
}

.success {
    color: #15b779;
}

.danger,
.text-danger {
    color: var(--primary);
}

.mini-chart {
    min-height: 82px;
    border-radius: 14px;
    background: linear-gradient(180deg, rgba(255, 255, 255, .62), rgba(255, 95, 143, .08));
    overflow: hidden;
}

.period-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.period-row > div + div {
    border-left: 1px solid rgba(89, 117, 169, .12);
    padding-left: 16px;
}

.period-row strong {
    display: block;
    margin: 6px 0 2px;
    font-size: 22px;
}

.period-row small {
    color: var(--muted);
}

.quick-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 14px;
}

.gradient-btn,
.logout-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    padding: 0 18px;
    border: 0;
    border-radius: 15px;
    color: #fff;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), #ff7aa6);
    box-shadow: 0 12px 24px rgba(255, 95, 143, .24);
    cursor: pointer;
}

.gradient-btn.secondary {
    background: linear-gradient(135deg, #ff7bad, #ff5f8f);
}

.gradient-btn.full,
.ghost-btn {
    width: 100%;
}

.ghost-btn {
    display: grid;
    place-items: center;
    min-height: 44px;
    border-radius: 14px;
    color: var(--primary);
    background: var(--soft);
    font-weight: 700;
}

.record-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.record-list li {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 58px;
    border-bottom: 1px solid var(--line);
}

.record-list li:last-child {
    border-bottom: 0;
}

.record-list p {
    margin: 0 0 4px;
    font-size: 14px;
}

.record-list small {
    display: block;
    max-width: 170px;
    overflow: hidden;
    color: var(--muted);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.record-list strong {
    margin-left: auto;
    font-size: 15px;
}

.dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #19c58a;
    flex: 0 0 auto;
}

.dot.period,
.dot.predict,
.dot.today-dot,
.dot.period {
    display: inline-block;
}

.dot.weight {
    background: #19c58a;
}

.dot.period,
.predict {
    background: var(--primary);
}

.today-dot {
    background: #4f83ff;
}

.empty-state {
    padding: 22px 10px;
    color: var(--muted);
    text-align: center;
    font-size: 14px;
}

.segmented,
.tabs-line {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
    padding: 4px;
    margin-bottom: 14px;
    border-radius: 18px;
    background: #f5f4f7;
    color: #666;
    font-size: 13px;
    text-align: center;
}

.tabs-line {
    grid-template-columns: repeat(3, 1fr);
}

.segmented span,
.tabs-line span {
    padding: 8px 4px;
    border-radius: 14px;
}

.segmented .active,
.tabs-line .active {
    color: #fff;
    background: linear-gradient(135deg, var(--primary), #ff7aa6);
}

canvas {
    display: block;
    width: 100%;
    border-radius: 16px;
}

.form-stack {
    display: grid;
    gap: 12px;
    margin-top: 14px;
}

.form-stack label,
.field-title {
    display: grid;
    gap: 7px;
    color: #555;
    font-size: 13px;
    font-weight: 700;
}

.form-stack input,
.form-stack textarea {
    width: 100%;
    border: 1px solid #eceaf0;
    border-radius: 14px;
    padding: 12px 13px;
    color: var(--text);
    background: #fbfbfd;
    outline: none;
}

.form-stack textarea {
    resize: vertical;
}

.compact {
    gap: 10px;
}

.editable li {
    align-items: center;
}

.date-badge {
    min-width: 62px;
    padding: 7px 8px;
    border-radius: 12px;
    color: var(--primary);
    background: var(--soft);
    font-size: 12px;
    text-align: center;
}

.date-badge.period {
    color: #fff;
    background: var(--primary);
}

.row-actions {
    display: grid;
    justify-items: end;
    gap: 4px;
    margin-left: auto;
}

.row-actions a,
.row-actions button,
.record-list form button {
    border: 0;
    padding: 2px 0;
    color: var(--primary);
    background: transparent;
    font-size: 12px;
    cursor: pointer;
}

.calendar-card {
    padding-top: 14px;
}

.month-switch {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.month-switch a {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #fbf5f8;
    font-size: 24px;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 7px;
}

.calendar-grid.week {
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 12px;
    text-align: center;
}

.calendar-day {
    display: grid;
    place-items: center;
    aspect-ratio: 1;
    border-radius: 50%;
    font-size: 14px;
    background: transparent;
}

.period-start,
.period-range {
    color: #fff;
    background: var(--primary);
}

.period-range {
    opacity: .74;
}

.predicted {
    color: var(--primary);
    border: 1px dashed var(--primary);
    background: #fff;
}

.today {
    color: #fff;
    background: #4f83ff;
}

.muted-day {
    visibility: hidden;
}

.legend {
    display: flex;
    justify-content: center;
    gap: 14px;
    margin-top: 14px;
    color: var(--muted);
    font-size: 12px;
}

.legend span {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.stats-strip,
.metric-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 14px;
}

.stat-card,
.metric-card {
    padding: 15px;
    border-radius: 18px;
    background: #fff;
    box-shadow: 0 10px 24px rgba(28, 31, 46, .05);
}

.stat-card.pink,
.metric-card.red {
    background: linear-gradient(135deg, #fff, #fff0f5);
}

.metric-card.green {
    background: linear-gradient(135deg, #fff, #effcf7);
}

.metric-card.blue {
    background: linear-gradient(135deg, #fff, #f0f6ff);
}

.stat-card span,
.metric-card span,
.period-stats span {
    display: block;
    color: #666;
    font-size: 13px;
}

.stat-card strong,
.metric-card strong,
.period-stats strong {
    display: block;
    margin: 8px 0 3px;
    font-size: 26px;
}

.stat-card small,
.period-stats small {
    font-size: 14px;
}

.stat-card em,
.metric-card small {
    color: var(--muted);
    font-size: 12px;
    font-style: normal;
}

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.chip input {
    display: none;
}

.chip span {
    display: inline-flex;
    padding: 9px 13px;
    border-radius: 999px;
    color: #777;
    background: #f5f4f7;
    font-size: 13px;
}

.chip input:checked + span {
    color: #fff;
    background: var(--primary);
}

.period-stats {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
}

.period-stats > div {
    padding: 12px;
    border-radius: 16px;
    background: #fbfbfd;
}

.progress-bar {
    height: 8px;
    margin-top: 14px;
    border-radius: 999px;
    background: #f0edf2;
    overflow: hidden;
}

.progress-bar span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--primary), #4f83ff);
}

.profile-hero {
    display: grid;
    grid-template-columns: 72px 1fr 18px;
    align-items: center;
    gap: 14px;
    padding: 22px 4px;
}

.vip-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 16px;
    margin-bottom: 14px;
    border-radius: 18px;
    color: #fff;
    background: linear-gradient(135deg, #26242b, #4d3d43);
}

.vip-card p {
    color: rgba(255, 255, 255, .68);
}

.vip-card button {
    border: 0;
    border-radius: 999px;
    padding: 9px 14px;
    color: #5d3b20;
    background: #ffd99b;
    font-weight: 700;
}

.menu-list {
    padding: 2px 16px;
}

.menu-list button {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    min-height: 54px;
    border: 0;
    border-bottom: 1px solid var(--line);
    background: transparent;
    color: #333;
    text-align: left;
}

.menu-list button:last-child {
    border-bottom: 0;
}

.menu-list span {
    color: var(--muted);
}

.logout-btn {
    width: 100%;
    margin-top: 6px;
}

.flash {
    position: sticky;
    top: 10px;
    z-index: 5;
    margin-bottom: 12px;
    padding: 12px 14px;
    border-radius: 14px;
    color: #fff;
    font-size: 14px;
    background: #333;
    box-shadow: 0 10px 22px rgba(0, 0, 0, .12);
}

.flash-success {
    background: #18b87c;
}

.flash-error {
    background: var(--primary);
}

.tabbar {
    position: fixed;
    left: 50%;
    bottom: 0;
    z-index: 10;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    width: 100%;
    max-width: 430px;
    padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
    border-top: 1px solid rgba(0, 0, 0, .05);
    background: rgba(255, 255, 255, .94);
    transform: translateX(-50%);
    backdrop-filter: blur(14px);
}

.tab-item {
    display: grid;
    justify-items: center;
    gap: 3px;
    color: #72727d;
    font-size: 11px;
}

.tab-icon {
    display: grid;
    place-items: center;
    width: 25px;
    height: 25px;
    border-radius: 10px;
    font-size: 17px;
}

.tab-item.active {
    color: var(--primary);
    font-weight: 700;
}

.tab-item.active .tab-icon {
    color: #fff;
    background: var(--primary);
}

@media (min-width: 431px) {
    body {
        background: #f2f2f6;
    }

    .app-shell {
        margin-top: 18px;
        margin-bottom: 18px;
        border-radius: 28px;
        background:
            radial-gradient(circle at top left, rgba(255, 95, 143, .10), transparent 34%),
            linear-gradient(180deg, #fff8fb 0, var(--bg) 270px);
        box-shadow: 0 24px 60px rgba(22, 25, 39, .12);
    }
}
