:root {
  --bg: #f3f5f1;
  --surface: #ffffff;
  --surface-soft: #f7f8f5;
  --ink: #17221f;
  --muted: #5e6965;
  --line: #dce2de;
  --brand: #1b5547;
  --brand-dark: #173f35;
  --brand-soft: #dfeee8;
  --lime: #c7e572;
  --food: #db745c;
  --exercise: #3a9c8a;
  --net: #7459a8;
  --goal: #b98b25;
  --remaining: #3978b7;
  --danger: #b8473f;
  --danger-soft: #fae7e4;
  --shadow: 0 18px 45px rgba(24, 53, 45, 0.08);
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 11px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--bg);
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 10% -10%, rgba(199, 229, 114, 0.18), transparent 27rem),
    var(--bg);
  color: var(--ink);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.login-page {
  display: grid;
  min-height: 100dvh;
  padding: calc(24px + env(safe-area-inset-top)) 18px calc(24px + env(safe-area-inset-bottom));
  place-items: center;
}

.login-card {
  width: min(100%, 430px);
  padding: 29px 24px 25px;
  border: 1px solid var(--line);
  border-radius: 26px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.login-card::before {
  display: grid;
  width: 42px;
  height: 42px;
  margin-bottom: 24px;
  place-items: center;
  border-radius: 13px;
  color: var(--brand-dark);
  background: var(--lime);
  content: "f";
  font-size: 27px;
  font-weight: 900;
}

.login-card h1 {
  font-size: clamp(31px, 10vw, 43px);
}

.login-copy {
  margin: 12px 0 23px;
  color: var(--muted);
}

.login-card form {
  display: grid;
  gap: 9px;
}

.login-card label {
  color: #42504b;
  font-size: 12px;
  font-weight: 750;
}

.login-card input {
  min-height: 50px;
}

.login-card button {
  min-height: 50px;
  margin-top: 7px;
  padding: 0 18px;
  border: 0;
  border-radius: 13px;
  color: #fff;
  background: var(--brand);
  font-size: 15px;
  font-weight: 800;
}

button,
input,
select {
  font: inherit;
}

button {
  color: inherit;
}

button,
summary,
input[type="date"] {
  -webkit-tap-highlight-color: transparent;
}

button:not(:disabled),
summary {
  cursor: pointer;
}

button:disabled {
  cursor: default;
  opacity: 0.55;
}

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 3px solid #3978b7;
  outline-offset: 2px;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 8px;
  left: 8px;
  padding: 10px 14px;
  border-radius: 9px;
  color: #fff;
  background: var(--brand-dark);
  transform: translateY(-150%);
}

.skip-link:focus {
  transform: translateY(0);
}

.app-shell {
  width: min(100%, 1160px);
  margin: 0 auto;
  padding: 0 max(16px, env(safe-area-inset-right)) calc(28px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: calc(68px + env(safe-area-inset-top));
  padding-top: env(safe-area-inset-top);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-size: 21px;
  font-weight: 800;
  letter-spacing: -0.04em;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 11px;
  color: var(--brand-dark);
  background: var(--lime);
  font-size: 22px;
  font-weight: 900;
}

.icon-button {
  display: inline-grid;
  width: 44px;
  height: 44px;
  padding: 10px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.8);
}

.icon-button svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.date-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 22px 0 20px;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--brand);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.eyebrow-light {
  color: #c8d8d3;
}

h1,
h2,
h3,
h4,
p {
  overflow-wrap: anywhere;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  line-height: 1.15;
}

h1 {
  font-size: clamp(27px, 8vw, 40px);
  letter-spacing: -0.045em;
}

h2 {
  font-size: 25px;
  letter-spacing: -0.035em;
}

h3 {
  font-size: 16px;
}

.date-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.date-step,
.today-button,
.date-picker-label,
#datePicker {
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface);
}

.date-step,
.today-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 13px;
  font-size: 14px;
  font-weight: 750;
}

.date-picker-label {
  display: none;
}

#datePicker {
  width: 100%;
  min-width: 0;
  padding: 0 11px;
  color: var(--ink);
  font-size: 16px;
}

.today-button {
  color: #fff;
  border-color: var(--brand);
  background: var(--brand);
}

.notice {
  margin-bottom: 16px;
  padding: 13px 15px;
  border: 1px solid #e3c5c1;
  border-radius: 13px;
  color: #802f2a;
  background: #fff1ef;
  font-weight: 650;
}

.calorie-card {
  position: relative;
  overflow: hidden;
  padding: 24px;
  border-radius: var(--radius-lg);
  color: #fff;
  background:
    radial-gradient(circle at 95% 0%, rgba(199, 229, 114, 0.26), transparent 18rem),
    var(--brand-dark);
  box-shadow: var(--shadow);
}

.calorie-card::after {
  position: absolute;
  right: -45px;
  bottom: -65px;
  width: 150px;
  height: 150px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 50%;
  content: "";
}

.calorie-lead,
.calorie-progress-block,
.totals-grid {
  position: relative;
  z-index: 1;
}

.remaining-number {
  margin: 2px 0 0;
  font-size: clamp(45px, 14vw, 68px);
  font-weight: 850;
  letter-spacing: -0.07em;
  line-height: 1;
}

.remaining-number .unit {
  font-size: 17px;
  font-weight: 650;
  letter-spacing: 0;
}

.remaining-copy {
  min-height: 21px;
  margin: 8px 0 22px;
  color: #c8d8d3;
  font-size: 14px;
}

.progress-meter {
  display: block;
  width: 100%;
  height: 7px;
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  background: #e7ebe8;
  color: var(--brand);
  appearance: none;
  -webkit-appearance: none;
}

.progress-meter::-webkit-progress-bar {
  border-radius: 999px;
  background: #e7ebe8;
}

.progress-meter::-webkit-progress-value {
  border-radius: 999px;
  background: var(--brand);
  transition: width 400ms ease;
}

.progress-meter::-moz-progress-bar {
  border-radius: 999px;
  background: var(--brand);
}

.progress-meter.is-over::-webkit-progress-value {
  background: var(--food);
}

.progress-meter.is-over::-moz-progress-bar {
  background: var(--food);
}

.progress-meter-calories {
  height: 11px;
  background: rgba(255, 255, 255, 0.16);
  color: var(--lime);
}

.progress-meter-calories::-webkit-progress-bar {
  background: rgba(255, 255, 255, 0.16);
}

.progress-meter-calories::-webkit-progress-value {
  background: var(--lime);
}

.progress-meter-calories::-moz-progress-bar {
  background: var(--lime);
}

.progress-meter-calories.is-over::-webkit-progress-value {
  background: #f3a18e;
}

.progress-meter-calories.is-over::-moz-progress-bar {
  background: #f3a18e;
}

.calorie-progress-labels {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 8px;
  color: #c8d8d3;
  font-size: 12px;
  font-weight: 650;
}

.totals-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  margin: 23px 0 0;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.11);
}

.totals-grid div {
  min-width: 0;
  padding: 13px 14px;
  background: rgba(255, 255, 255, 0.045);
}

.totals-grid dt {
  margin-bottom: 2px;
  color: #b9cbc5;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.totals-grid dd {
  margin: 0;
  font-size: 16px;
  font-weight: 750;
}

.section-block {
  margin-top: 36px;
}

.section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 15px;
}

.section-subtitle {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.macro-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.macro-card {
  min-width: 0;
  padding: 16px;
  border: 1px solid rgba(220, 226, 222, 0.9);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: 0 8px 24px rgba(24, 53, 45, 0.035);
}

.macro-card-head {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  gap: 3px;
  margin-bottom: 12px;
}

.macro-card h3 {
  min-width: 0;
  font-size: 14px;
}

.macro-value {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.macro-card .progress-meter {
  height: 7px;
}

.macro-remaining {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.macro-remaining.is-over {
  color: #a64137;
  font-weight: 700;
}

.count-pill {
  flex: 0 0 auto;
  padding: 5px 9px;
  border-radius: 999px;
  color: var(--brand);
  background: var(--brand-soft);
  font-size: 12px;
  font-weight: 750;
}

.entry-columns {
  display: grid;
  gap: 14px;
}

.entry-group {
  min-width: 0;
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.62);
}

.entry-group-heading {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 2px 13px;
}

.entry-group-heading h3 {
  flex: 1;
}

.entry-group-heading > span:last-child {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.entry-symbol {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.food-symbol {
  background: var(--food);
}

.exercise-symbol {
  background: var(--exercise);
}

.entry-list {
  display: grid;
  gap: 9px;
}

.entry-card {
  padding: 15px;
  border: 1px solid #e5e9e6;
  border-radius: 15px;
  background: var(--surface);
}

.entry-card-top {
  display: flex;
  align-items: flex-start;
  gap: 11px;
}

.entry-time {
  flex: 0 0 auto;
  min-width: 50px;
  padding-top: 2px;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.entry-copy {
  min-width: 0;
  flex: 1;
}

.entry-title-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.entry-title-line h4 {
  min-width: 0;
  font-size: 15px;
}

.estimated-badge {
  padding: 2px 6px;
  border-radius: 999px;
  color: #6c5113;
  background: #f6eac7;
  font-size: 9px;
  font-weight: 850;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.entry-calories {
  margin: 3px 0 0;
  font-size: 14px;
  font-weight: 800;
}

.entry-meta {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.entry-actions {
  display: flex;
  justify-content: flex-end;
  gap: 4px;
  margin: 10px -4px -4px 0;
}

.entry-action {
  min-height: 38px;
  padding: 0 10px;
  border: 0;
  border-radius: 10px;
  color: var(--brand);
  background: transparent;
  font-size: 13px;
  font-weight: 750;
}

.entry-action:hover {
  background: var(--brand-soft);
}

.entry-action-delete {
  color: var(--danger);
}

.entry-action-delete:hover {
  background: var(--danger-soft);
}

.empty-state {
  margin: 0;
  padding: 24px 10px;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
}

.history-section {
  padding: 20px 17px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.history-heading-row {
  align-items: center;
}

.segmented-control {
  display: flex;
  flex: 0 0 auto;
  padding: 3px;
  border-radius: 12px;
  background: var(--surface-soft);
}

.segmented-control button {
  min-width: 44px;
  min-height: 38px;
  padding: 0 8px;
  border: 0;
  border-radius: 9px;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
  font-weight: 800;
}

.segmented-control button[aria-pressed="true"] {
  color: #fff;
  background: var(--brand);
  box-shadow: 0 5px 13px rgba(27, 85, 71, 0.18);
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 7px 13px;
  margin: 20px 0 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

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

.chart-legend i {
  width: 14px;
  height: 3px;
  border-radius: 3px;
}

.legend-food {
  background: var(--food);
}

.legend-exercise {
  background: var(--exercise);
}

.legend-net {
  background: var(--net);
}

.legend-goal {
  background: var(--goal);
}

.legend-remaining {
  background: var(--remaining);
}

.chart-wrap {
  position: relative;
  min-height: 210px;
  margin: 0 -10px;
}

#historyChart {
  display: block;
  width: 100%;
  height: auto;
  min-height: 210px;
  overflow: visible;
}

.chart-grid-line {
  stroke: #e8ece9;
  stroke-width: 1;
}

.chart-zero-line {
  stroke: #aeb9b4;
  stroke-width: 1.2;
}

.chart-axis-label,
.chart-date-label {
  fill: #65716c;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 10px;
}

.chart-series {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.6;
  vector-effect: non-scaling-stroke;
}

.chart-series-food {
  stroke: var(--food);
}

.chart-series-exercise {
  stroke: var(--exercise);
}

.chart-series-net {
  stroke: var(--net);
}

.chart-series-goal {
  stroke: var(--goal);
  stroke-dasharray: 6 4;
}

.chart-series-remaining {
  stroke: var(--remaining);
}

.chart-point {
  stroke: #fff;
  stroke-width: 1.5;
}

.chart-point-food {
  fill: var(--food);
}

.chart-point-exercise {
  fill: var(--exercise);
}

.chart-point-net {
  fill: var(--net);
}

.chart-point-goal {
  fill: var(--goal);
}

.chart-point-remaining {
  fill: var(--remaining);
}

.chart-empty {
  position: absolute;
  inset: 50% 0 auto;
  margin: 0;
  color: var(--muted);
  text-align: center;
  transform: translateY(-50%);
}

.history-macro-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 7px;
}

.history-macro {
  padding: 12px;
  border-radius: 13px;
  background: var(--surface-soft);
}

.history-macro dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.history-macro dd {
  margin: 2px 0 0;
  font-size: 17px;
  font-weight: 800;
}

.history-details {
  margin-top: 17px;
  border-top: 1px solid var(--line);
}

.history-details summary {
  min-height: 48px;
  padding: 15px 2px 10px;
  color: var(--brand);
  font-size: 13px;
  font-weight: 800;
}

.table-scroll {
  overflow-x: auto;
  padding-bottom: 4px;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  min-width: 570px;
  border-collapse: collapse;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

th,
td {
  padding: 9px 8px;
  border-bottom: 1px solid #edf0ee;
  text-align: right;
  white-space: nowrap;
}

th:first-child,
td:first-child {
  padding-left: 2px;
  text-align: left;
}

th {
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 29px 2px 8px;
  color: var(--muted);
  font-size: 11px;
}

dialog {
  max-width: none;
  padding: 0;
  border: 0;
  color: var(--ink);
  background: transparent;
}

dialog::backdrop {
  background: rgba(13, 27, 23, 0.55);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}

.sheet-dialog {
  width: 100%;
  max-height: calc(100dvh - env(safe-area-inset-top));
  margin: auto 0 0;
}

.dialog-form {
  display: flex;
  flex-direction: column;
  max-height: calc(100dvh - env(safe-area-inset-top));
  overflow: hidden;
  border-radius: 24px 24px 0 0;
  background: var(--surface);
  box-shadow: 0 -18px 70px rgba(10, 24, 20, 0.22);
}

.dialog-header {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  padding: 19px 20px 15px;
  border-bottom: 1px solid var(--line);
}

.dialog-header h2 {
  font-size: 22px;
}

.close-button {
  border: 0;
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 27px;
  font-weight: 350;
  line-height: 1;
}

.dialog-body {
  display: grid;
  gap: 16px;
  min-height: 0;
  padding: 20px;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.dialog-body label,
.settings-section label {
  display: grid;
  gap: 6px;
  min-width: 0;
  color: #42504b;
  font-size: 12px;
  font-weight: 750;
}

.dialog-body label > span,
.settings-section label > span {
  color: var(--muted);
  font-weight: 550;
}

input,
select {
  width: 100%;
  min-width: 0;
  min-height: 46px;
  padding: 9px 11px;
  border: 1px solid #cfd7d2;
  border-radius: 11px;
  color: var(--ink);
  background: #fff;
  font-size: 16px;
}

input[readonly] {
  color: var(--muted);
  background: #f2f4f2;
}

input:focus,
select:focus {
  border-color: var(--brand);
}

fieldset {
  min-width: 0;
  margin: 0;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 14px;
}

legend {
  padding: 0 5px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

.form-grid {
  display: grid;
  gap: 13px;
}

.check-row {
  display: flex !important;
  align-items: center;
  gap: 10px !important;
  min-height: 44px;
  padding: 9px 11px;
  border-radius: 11px;
  background: var(--surface-soft);
}

.check-row input {
  flex: 0 0 auto;
  width: 20px;
  min-height: 20px;
  margin: 0;
  accent-color: var(--brand);
}

.check-row span {
  color: var(--ink) !important;
  font-size: 14px;
  font-weight: 650 !important;
}

.form-error {
  margin: 0;
  padding: 11px 12px;
  border-radius: 10px;
  color: #852f2a;
  background: var(--danger-soft);
  font-size: 13px;
  font-weight: 650;
}

.form-success {
  margin: 0;
  padding: 11px 12px;
  border-radius: 10px;
  color: #174f40;
  background: var(--brand-soft);
  font-size: 13px;
  font-weight: 700;
}

.settings-feedback {
  position: sticky;
  z-index: 2;
  top: 0;
}

.dialog-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  flex: 0 0 auto;
  gap: 9px;
  padding: 13px 20px calc(13px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
}

.button {
  min-height: 46px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 800;
}

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

.button-secondary {
  border-color: var(--line);
  background: var(--surface-soft);
}

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

.button-danger-outline {
  color: var(--danger);
  border-color: #e4beb9;
  background: #fff;
}

.button-full {
  width: 100%;
}

.confirm-dialog {
  width: min(calc(100% - 32px), 410px);
  margin: auto;
}

.confirm-dialog .dialog-form {
  border-radius: 21px;
  box-shadow: 0 22px 80px rgba(10, 24, 20, 0.28);
}

.confirm-body {
  justify-items: center;
  padding: 27px 24px 20px;
  text-align: center;
}

.confirm-body p {
  margin: -3px 0 0;
  color: var(--muted);
}

.danger-mark {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border-radius: 50%;
  color: var(--danger);
  background: var(--danger-soft);
  font-size: 29px;
  line-height: 1;
}

.settings-body {
  gap: 0;
  padding: 0 20px 24px;
}

.settings-section {
  display: grid;
  gap: 14px;
  padding: 22px 0;
  border-bottom: 1px solid var(--line);
}

.settings-section-heading p,
.logout-section p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.inline-save {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 9px;
}

.goal-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.goal-form-grid label:first-child {
  grid-column: 1 / -1;
}

.stacked-actions {
  display: grid;
  gap: 8px;
}

.logout-section {
  grid-template-columns: 1fr auto;
  align-items: center;
  border-bottom: 0;
}

.toast {
  position: fixed;
  z-index: 110;
  right: max(16px, env(safe-area-inset-right));
  bottom: calc(16px + env(safe-area-inset-bottom));
  left: max(16px, env(safe-area-inset-left));
  max-width: 440px;
  margin-left: auto;
  padding: 13px 16px;
  border-radius: 13px;
  color: #fff;
  background: #20332d;
  box-shadow: 0 12px 40px rgba(10, 24, 20, 0.25);
  font-size: 14px;
  font-weight: 700;
}

@media (min-width: 620px) {
  .app-shell {
    padding-right: max(24px, env(safe-area-inset-right));
    padding-left: max(24px, env(safe-area-inset-left));
  }

  .date-panel {
    flex-direction: row;
    align-items: end;
    justify-content: space-between;
  }

  .date-controls {
    grid-template-columns: auto minmax(150px, auto) auto auto;
  }

  .date-picker-label {
    display: none;
  }

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

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

  .macro-card-head {
    min-height: 49px;
  }

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

  .history-macro-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .sheet-dialog {
    width: min(calc(100% - 40px), 680px);
    max-height: min(88dvh, 820px);
    margin: auto;
  }

  .sheet-dialog .dialog-form {
    max-height: min(88dvh, 820px);
    border-radius: 24px;
  }
}

@media (min-width: 860px) {
  .topbar {
    min-height: 82px;
  }

  .date-panel {
    padding-top: 30px;
  }

  .calorie-card {
    display: grid;
    grid-template-columns: minmax(260px, 0.75fr) minmax(330px, 1.25fr);
    column-gap: 48px;
    padding: 31px;
  }

  .calorie-lead {
    grid-row: 1 / span 2;
  }

  .calorie-progress-block {
    align-self: end;
    padding-top: 11px;
  }

  .totals-grid {
    align-self: start;
    margin-top: 19px;
  }

  .entry-columns {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
  }

  .history-section {
    padding: 27px 29px;
  }

  .chart-wrap {
    min-height: 260px;
    margin-right: 0;
    margin-left: 0;
  }

  #historyChart {
    min-height: 260px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
