:root {
    color-scheme: light;
    --ink: #203630;
    --muted: #61776d;
    --green: #087f65;
    --green-dark: #05634f;
    --line: #dce9e2;
    --paper: #fff;
    --background: #eff8f3;
    font-family: 'DM Sans', Inter, ui-sans-serif, system-ui, sans-serif;
    font-synthesis: none;
    text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    color: var(--ink);
    background:
        radial-gradient(ellipse at 8% 0%, rgb(139 238 186 / 55%), transparent 31rem),
        radial-gradient(ellipse at 96% 18%, rgb(255 185 142 / 38%), transparent 27rem),
        radial-gradient(ellipse at 75% 75%, rgb(180 190 255 / 24%), transparent 32rem),
        var(--background);
    font-size: 14px;
}

button, input { font: inherit; }
input { min-width: 0; max-width: 100%; }
button { cursor: pointer; }

.topbar {
    height: 70px;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #fff;
    border-bottom: 1px solid #e9efec;
    box-shadow: 0 5px 22px rgb(39 82 65 / 4%);
}

.brand {
    display: inline-flex;
    gap: 10px;
    align-items: center;
    color: var(--ink);
    text-decoration: none;
    font: 800 19px 'Manrope', sans-serif;
    letter-spacing: -1px;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: 10px;
    background: linear-gradient(145deg, #22bc85, #087f65 62%, #5969eb);
    color: white;
    font: 600 23px 'DM Sans', sans-serif;
}

.brand-light { color: var(--green); }
.topbar-note { color: #829089; font-size: 12px; }
.container { width: calc(100% - 40px); max-width: 820px; margin: 0 auto; }

.login-shell {
    display: flex;
    width: calc(100% - 36px);
    min-height: calc(100vh - 70px);
    max-width: 510px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    padding: 38px 0;
}
.login-card {
    position: relative;
    width: 100%;
    overflow: hidden;
    padding: 42px 42px 34px;
    border: 1px solid rgb(255 255 255 / 92%);
    border-radius: 24px;
    background: rgb(255 255 255 / 94%);
    box-shadow: 0 24px 65px rgb(31 65 51 / 12%), 0 4px 14px rgb(31 65 51 / 5%);
}
.login-card::before {
    position: absolute;
    top: 0;
    right: 0;
    left: 0;
    height: 6px;
    background: linear-gradient(90deg, #13bd7e, #526cf1 58%, #ff874f);
    content: "";
}
.login-emblem {
    display: grid;
    width: 62px;
    height: 62px;
    place-items: center;
    margin: 0 auto 24px;
    border: 1px solid #a6edc3;
    border-radius: 20px;
    background: linear-gradient(145deg, #d1f8dd, #dce4ff 72%, #ffe5d1);
    box-shadow: 0 8px 18px rgb(8 127 101 / 12%);
}
.login-emblem span {
    color: #087f65;
    font: 500 43px/1 'DM Sans', sans-serif;
}
.login-card > .eyebrow { margin-bottom: 10px; text-align: center; }
.login-card h1 {
    margin: 0 0 11px;
    color: #203630;
    font: 750 30px/1.2 'Manrope', ui-sans-serif, system-ui, sans-serif;
    letter-spacing: -1px;
    text-align: center;
}
.login-description {
    max-width: 340px;
    margin: 0 auto 28px;
    color: #687a72;
    font-size: 14px;
    line-height: 1.6;
    text-align: center;
}
.login-form { display: grid; gap: 17px; }
.login-form .field { gap: 9px; color: #33483e; font-size: 12px; }
.login-form .field input {
    height: 50px;
    padding: 0 14px;
    border: 1px solid #dce9e2;
    border-radius: 10px;
    background: #fbfdfc;
    font-size: 14px;
    transition: border-color .18s ease, box-shadow .18s ease, background-color .18s ease;
}
.login-form .field input:focus {
    border-color: #13ad78;
    background: #fff;
    box-shadow: 0 0 0 4px rgb(14 171 113 / 13%);
}
.login-form .primary-button {
    width: 100%;
    min-height: 50px;
    border-radius: 10px;
    font-size: 14px;
}
.login-form .primary-button span { margin-right: 7px; font-size: 17px; }
.login-privacy {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    margin: 24px 0 0;
    color: #71827a;
    font-size: 11px;
}
.login-privacy span { color: #0ba66d; font-size: 9px; }
.login-error { margin: 0 0 18px; }
.login-config-note {
    padding: 15px;
    border: 1px solid #cbd5ff;
    border-radius: 11px;
    color: #3e4d94;
    background: #eef0ff;
    font-size: 12px;
    line-height: 1.65;
    text-align: center;
}
.login-config-note code {
    padding: 2px 5px;
    border-radius: 4px;
    color: #33418e;
    background: rgb(255 255 255 / 72%);
    font-size: 11px;
}
.login-footer {
    margin: 21px 0 0;
    color: #70827a;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1px;
    text-align: center;
}
.login-footer span { padding: 0 5px; color: #f08050; }

.intro {
    margin: 25px 0 18px;
    padding: 31px 32px;
    border: 1px solid rgb(255 255 255 / 80%);
    border-radius: 20px;
    background: linear-gradient(112deg, #c9f5dc 0%, #dfe5ff 58%, #ffe1cd 100%);
    box-shadow: 0 12px 32px rgb(39 82 65 / 9%);
}
.eyebrow { margin: 0 0 9px; color: #16836c; font-size: 10px; font-weight: 700; letter-spacing: 1.25px; }
h1, h2, h3, p { margin-top: 0; }
.intro h1 { margin-bottom: 9px; font: 700 32px 'Manrope', sans-serif; letter-spacing: -1.3px; }
.intro h1 span { color: var(--green); }
.intro > p:last-child { margin-bottom: 0; color: var(--muted); font-size: 13px; }

.card {
    margin-bottom: 15px;
    padding: 23px 24px 24px;
    border: 1px solid #d9e9df;
    border-top: 4px solid #16b879;
    border-radius: 15px;
    background: var(--paper);
    box-shadow: 0 8px 24px rgb(31 65 51 / 5%);
}

.entry-form > .card:nth-of-type(2) { border-top-color: #526cf1; }
.entry-form > .card:nth-of-type(3) { border-top-color: #ff834e; }
.section-heading { display: flex; align-items: center; gap: 12px; margin-bottom: 21px; }
.section-heading h2, .history-heading h2 { margin: 0 0 3px; font: 700 17px 'Manrope', sans-serif; letter-spacing: -.35px; }
.section-heading p { margin: 0; color: var(--muted); font-size: 12px; }
.section-icon { display: grid; width: 36px; height: 36px; flex: 0 0 36px; place-items: center; border-radius: 11px; font-size: 11px; font-weight: 700; }
.icon-green { color: #087f65; background: #c9f7dc; }
.icon-blue { color: #455ce2; background: #dce4ff; }
.icon-peach { color: #c64e25; background: #ffe0ca; }
.field-grid { display: grid; min-width: 0; gap: 15px; }
.three-columns { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field { display: flex; min-width: 0; flex-direction: column; gap: 7px; color: #475650; font-size: 11px; font-weight: 600; }
.unit { color: #9aa6a0; font-size: 10px; font-weight: 400; }
.field input {
    display: block;
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    height: 40px;
    padding: 0 11px;
    border: 1px solid #e5ebe7;
    border-radius: 7px;
    outline: 0;
    color: var(--ink);
    background: #fff;
    font-size: 12px;
    font-weight: 400;
}
.field input[type="date"],
.field input[type="time"] {
    -webkit-appearance: none;
    appearance: none;
    min-inline-size: 0;
    text-align: left;
}
.field input[type="date"]::-webkit-date-and-time-value,
.field input[type="time"]::-webkit-date-and-time-value {
    display: flex;
    height: 100%;
    align-items: center;
    min-width: 0;
    text-align: left;
}
.field input::placeholder { color: #aab4af; }
.field input:focus, .meal-fields textarea:focus { border-color: #13ad78; box-shadow: 0 0 0 3px rgb(14 171 113 / 16%); }
.weight-comparison {
    display: flex;
    width: fit-content;
    max-width: 100%;
    align-items: center;
    gap: 8px;
    margin-top: 2px;
    padding: 7px 10px;
    border: 1px solid transparent;
    border-radius: 9px;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.35;
    transition: background-color .18s ease, border-color .18s ease, color .18s ease;
}
.weight-comparison:empty { display: none; }
.weight-comparison::before {
    display: grid;
    width: 20px;
    height: 20px;
    flex: 0 0 20px;
    place-items: center;
    border-radius: 50%;
    font-size: 13px;
}
.weight-increase { color: #b42332; background: #fff0f1; border-color: #ffd3d8; }
.weight-decrease { color: #087345; background: #e6f8ed; border-color: #bdebcf; }
.weight-neutral { color: #4d6177; background: #edf3fb; border-color: #d5e3f3; }
.weight-comparison.weight-increase::before { content: "↑"; color: #a91f2c; background: #ffdadd; }
.weight-comparison.weight-decrease::before { content: "↓"; color: #06663d; background: #c8f0d6; }
.weight-comparison.weight-neutral::before { content: "↔"; color: #3c5877; background: #dbe8f7; }

.measurements { display: grid; gap: 10px; }
.measurement-row { display: grid; grid-template-columns: 1fr 1.1fr 1fr 1fr 1fr 22px; align-items: end; gap: 10px; }
.pressure-inputs { display: flex; min-width: 0; align-items: center; gap: 5px; color: #6d7b74; }
.pressure-inputs input { flex: 1 1 0; width: 0; padding-right: 5px; padding-left: 5px; text-align: center; }
.pressure-inputs > span { flex: 0 0 auto; color: #087f65; font-size: 15px; font-weight: 800; }
.remove-row { align-self: end; width: 24px; height: 39px; padding: 0; border: 0; color: #9da9a3; background: transparent; font-size: 23px; }
.remove-row:hover { color: #ba5753; }
.add-button { display: inline-flex; align-items: center; gap: 5px; margin-top: 14px; padding: 0; border: 0; color: var(--green); background: transparent; font-size: 12px; font-weight: 700; }
.add-button span { font-size: 16px; }
.add-button:disabled { color: #9da9a3; cursor: not-allowed; }
.helper { margin: 8px 0 0; color: #929e98; font-size: 10px; }

.meals-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.meal-card { min-height: 174px; padding: 18px; border: 1px solid #f1cdb7; border-radius: 14px; background: #fff0e4; box-shadow: 0 5px 15px rgb(188 95 48 / 7%); }
.meal-card:nth-child(even) { border-color: #cdd6ff; background: #edf0ff; box-shadow: 0 5px 15px rgb(72 83 195 / 7%); }
.meal-title { color: #253d33; font-size: 13px; font-weight: 800; }
.meal-fields { display: grid; min-width: 0; grid-template-columns: minmax(0, 90px) minmax(0, 1fr); column-gap: 10px; row-gap: 8px; }
.meal-fields input, .meal-fields textarea { display: block; box-sizing: border-box; width: 100%; min-width: 0; max-width: 100%; border: 1px solid #dbe5df; border-radius: 8px; color: var(--ink); background: #fff; font: inherit; font-size: 12px; }
.meal-fields input { height: 40px; padding: 0 8px; }
.meal-fields textarea { grid-column: 1 / -1; min-height: 82px; padding: 10px; resize: vertical; line-height: 1.45; }
.meal-fields .meal-calories { grid-column: 1 / -1; max-width: 220px; height: 40px; padding: 0 10px; border-color: #e0c19c; font-weight: 700; }
.meal-card:nth-child(even) .meal-fields .meal-calories { border-color: #c4cdf4; }
.meal-fields textarea::placeholder { color: #899a91; }

.form-actions { display: flex; justify-content: space-between; align-items: center; padding: 4px 0 12px; }
.form-actions p { margin: 0; color: #89958f; font-size: 11px; }
.primary-button { min-height: 42px; padding: 0 17px; border: 0; border-radius: 8px; color: #fff; background: linear-gradient(115deg, #10a975, #087f65); font-size: 12px; font-weight: 700; box-shadow: 0 4px 12px rgb(8 127 101 / 25%); }
.primary-button:hover { background: var(--green-dark); }
.primary-button span { margin-right: 5px; }
.notice { margin: 0 0 14px; padding: 12px 14px; border-radius: 8px; font-size: 12px; }
.edit-notice { color: #3449ba; background: #e5e9ff; }
.success { color: #075d42; background: #ccf7dd; }
.error { color: #a52831; background: #ffe0e1; }

.weekly-section {
    margin: 0 0 20px;
    padding: 22px;
    border: 1px solid #d7e5ff;
    border-radius: 17px;
    background: linear-gradient(130deg, #f1f4ff, #f0fff6 62%, #fff5ec);
    box-shadow: 0 9px 25px rgb(55 75 150 / 7%);
}
.weekly-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; margin-bottom: 17px; }
.weekly-heading .eyebrow { margin-bottom: 5px; color: #4b5fdb; }
.weekly-heading h2 { margin: 0 0 5px; font: 750 20px/1.25 'Manrope', ui-sans-serif, system-ui, sans-serif; letter-spacing: -.5px; }
.weekly-heading p:last-child { margin: 0; color: #677a70; font-size: 11px; line-height: 1.5; }
.weekly-badge { flex: 0 0 auto; padding: 6px 9px; border: 1px solid #c6d0ff; border-radius: 20px; color: #4354c1; background: #e3e8ff; font-size: 9px; font-weight: 800; letter-spacing: .5px; }
.weekly-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px; }
.weekly-stat-card { min-width: 0; padding: 14px; border: 1px solid rgb(255 255 255 / 90%); border-radius: 12px; background: rgb(255 255 255 / 88%); box-shadow: 0 4px 12px rgb(39 65 80 / 4%); }
.weekly-stat-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.weekly-stat-top h3 { margin: 0; color: #34483f; font-size: 12px; font-weight: 800; }
.weekly-status { max-width: 65%; padding: 4px 7px; border-radius: 20px; font-size: 9px; font-weight: 800; line-height: 1.25; text-align: right; }
.trend-positive { color: #087345; background: #d9f6e4; }
.trend-negative { color: #b42332; background: #ffe2e4; }
.trend-neutral { color: #50637a; background: #e8eef7; }
.weekly-current-value { display: block; margin-bottom: 7px; color: #1d392f; font: 750 23px/1.15 'Manrope', ui-sans-serif, system-ui, sans-serif; letter-spacing: -.6px; }
.weekly-previous { min-height: 31px; margin: 0 0 8px; color: #697a73; font-size: 10px; line-height: 1.5; }
.weekly-previous strong { color: #42544b; }
.weekly-change { display: inline-block; margin-left: 3px; padding: 1px 5px; border-radius: 8px; font-weight: 800; }
.weekly-reference { margin: 0; padding-top: 7px; border-top: 1px solid #edf1f5; color: #7a8982; font-size: 9px; line-height: 1.4; }
.weekly-empty { padding: 16px; border: 1px dashed #b9c6f5; border-radius: 11px; color: #596a86; background: rgb(255 255 255 / 72%); font-size: 12px; text-align: center; }
.weekly-disclaimer { margin: 12px 1px 0; color: #76847e; font-size: 9px; line-height: 1.5; }

.history-section { padding-top: 30px; }
.history-heading { display: flex; align-items: end; justify-content: space-between; margin-bottom: 15px; }
.history-heading .eyebrow { margin-bottom: 5px; }
.history-heading h2 { font-size: 20px; }
.record-count { padding: 6px 10px; border-radius: 20px; color: #075f48; background: #c6f3d7; font-size: 10px; font-weight: 700; }
.empty-state { display: flex; align-items: center; gap: 11px; padding: 18px; border: 1px dashed #dbe4df; border-radius: 10px; color: #85928b; background: rgb(255 255 255 / 65%); }
.empty-state span { color: #7ba28e; font-size: 20px; }
.empty-state p { margin: 0; font-size: 12px; }
.records-list { display: grid; gap: 10px; }
.record-card { padding: 16px 18px; border: 1px solid var(--line); border-left: 4px solid #17b779; border-radius: 12px; background: #fff; box-shadow: 0 5px 16px rgb(31 65 51 / 7%); }
.record-main, .record-date, .record-stats, .record-actions { display: flex; align-items: center; }
.record-main { justify-content: space-between; }
.record-date { gap: 10px; }
.date-mark { width: 9px; height: 9px; border-radius: 50%; background: #0db976; box-shadow: 0 0 0 4px #cff6df; }
.record-date h3 { margin: 0 0 3px; font: 700 13px 'Manrope', sans-serif; }
.record-date p { margin: 0; color: #89958f; font-size: 10px; }
.record-stats { align-items: flex-start; gap: 13px; color: #7a8881; font-size: 11px; }
.record-stats strong { color: #33473e; font-size: 13px; }
.record-weight { display: grid; gap: 3px; }
.weight-change { width: fit-content; padding: 3px 7px; border: 1px solid transparent; border-radius: 20px; font-size: 10px; font-weight: 700; }
.record-actions { justify-content: space-between; gap: 13px; margin-top: 13px; padding-top: 11px; border-top: 1px solid #f0f3f1; }
.record-actions form { margin: 0; }
.form-buttons { display: flex; align-items: center; gap: 9px; }
.cancel-edit-button { display: inline-flex; min-height: 42px; align-items: center; padding: 0 14px; border-radius: 8px; color: #4d5fc1; background: #e8ebff; font-size: 12px; font-weight: 700; text-decoration: none; }
.text-button { padding: 8px 12px; border: 0; border-radius: 7px; color: #086b52; background: #d3f5e1; font-size: 11px; font-weight: 700; text-decoration: none; }
.text-button:hover { color: #064f3e; background: #b8edce; }
.edit-button { color: #3c50c3; background: #e0e5ff; }
.edit-button:hover { color: #2c3da8; background: #cbd4ff; }
.delete-button { color: #b24c52; background: #fff0f0; }
.delete-button:hover { color: #953940; background: #ffe2e3; }
.disclaimer { padding: 26px 0 30px; color: #98a39d; text-align: center; font-size: 10px; }

@media (max-width: 650px) {
    .topbar { height: 60px; padding: 0 20px; }
    .container { width: calc(100% - 32px); max-width: 500px; }
    .login-shell { min-height: calc(100vh - 60px); padding: 26px 0; }
    .login-card { padding: 35px 25px 29px; border-radius: 20px; }
    .login-card h1 { font-size: 27px; }
    .weekly-section { padding: 17px; }
    .weekly-heading { flex-direction: column; gap: 10px; }
    .weekly-grid { grid-template-columns: 1fr; }
    .intro { margin: 18px 0 14px; padding: 25px 21px; }
    .intro h1 { font-size: 27px; }
    .intro > p:last-child { max-width: 370px; line-height: 1.55; }
    .card { min-width: 0; padding: 19px 17px; }
    .section-heading { margin-bottom: 17px; }
    .three-columns { grid-template-columns: minmax(0, 1fr); }
    .three-columns > .field,
    .three-columns > .field input { min-width: 0; max-width: 100%; }
    .measurement-row { grid-template-columns: repeat(2, minmax(0, 1fr)) 24px; gap: 10px; padding: 12px; border: 1px solid #edf0ee; border-radius: 9px; background: #fcfdfc; }
    .measurement-row .field:first-child { grid-column: span 1; }
    .measurement-row .remove-row { grid-column: 3; grid-row: 1; justify-self: end; align-self: center; height: 30px; }
    .measurement-row .field:nth-child(2) { grid-column: 1; }
    .measurement-row .field:nth-child(3) { grid-column: 2; }
    .measurement-row .field:nth-child(4) { grid-column: 1; }
    .measurement-row .field:nth-child(5) { grid-column: 2; }
    .meals-grid { grid-template-columns: 1fr; gap: 9px; }
    .meal-card { padding: 12px; }
    .meal-fields { grid-template-columns: minmax(0, 90px) minmax(0, 1fr); column-gap: 10px; }
    .meal-fields input[type="time"] { padding-right: 4px; padding-left: 6px; }
    .form-buttons { width: 100%; flex-direction: column-reverse; }
    .form-buttons > * { width: 100%; justify-content: center; }
    .form-actions { align-items: stretch; flex-direction: column-reverse; gap: 10px; }
    .form-actions p { text-align: center; }
    .primary-button { width: 100%; min-height: 46px; }
    .record-card { padding: 14px; }
}

@media (max-width: 370px) {
    .container { width: calc(100% - 24px); }
    .card { padding: 16px 13px; }
    .three-columns { grid-template-columns: minmax(0, 1fr); }
    .record-stats { gap: 7px; font-size: 10px; }
    .meal-fields { grid-template-columns: minmax(0, 82px) minmax(0, 1fr); column-gap: 8px; }
    .meal-fields input[type="time"] { padding-right: 2px; padding-left: 4px; }
}
