:root {
  color-scheme: light;
  --bg: #f2f6fd;
  --surface: #fbfdff;
  --surface-strong: #ffffff;
  --ink: #10234a;
  --muted: #6d7b99;
  --line: #dce6f5;
  --primary: #2f6df6;
  --primary-dark: #1947b8;
  --accent: #10a999;
  --amber: #d58a16;
  --blue: #416df6;
  --green-soft: #e4f8f4;
  --red-soft: #fff1eb;
  --blue-soft: #e8f0ff;
  --shadow: 0 18px 58px rgba(53, 89, 148, 0.12);
  --shadow-soft: 0 10px 30px rgba(53, 89, 148, 0.08);
  --radius: 18px;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.96) 0%, rgba(237, 246, 255, 0.84) 42%, rgba(255, 255, 255, 0.9) 100%),
    var(--bg);
}

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

button {
  cursor: pointer;
}

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

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 26px 20px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(18px);
  box-shadow: 12px 0 40px rgba(53, 89, 148, 0.08);
}

.brand {
  display: grid;
  align-items: start;
  gap: 4px;
  margin-bottom: 28px;
}

.brand-logo {
  display: block;
  width: min(172px, 100%);
  height: auto;
  object-fit: contain;
}

.brand h1,
.brand p,
.topbar h2,
.topbar p,
.panel h3,
.panel p {
  margin: 0;
}

.brand h1 {
  font-size: 0;
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.brand p,
.panel p,
.eyebrow {
  color: var(--muted);
  font-size: 0.88rem;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav-button {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 54px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 16px;
  color: var(--muted);
  background: transparent;
  text-align: left;
  transition:
    background 0.18s ease,
    color 0.18s ease,
    border-color 0.18s ease;
}

.nav-button::before {
  content: "";
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  border-radius: 10px;
  color: var(--primary);
  background: var(--blue-soft);
  font-size: 0.9rem;
  font-weight: 800;
}

.nav-button[data-icon="chart"]::before {
  content: "▥";
}

.nav-button[data-icon="bowl"]::before {
  content: "◒";
}

.nav-button[data-icon="dumbbell"]::before {
  content: "↔";
}

.nav-button[data-icon="body"]::before {
  content: "◎";
}

.nav-button[data-icon="moon"]::before {
  content: "☾";
}

.nav-button[data-icon="people"]::before {
  content: "◇";
}

.nav-button:hover,
.nav-button.is-active {
  color: var(--primary);
  border-color: #b9cdfd;
  background: var(--surface-strong);
  box-shadow: var(--shadow-soft);
}

.nav-button:hover::before,
.nav-button.is-active::before {
  color: #fff;
  background: linear-gradient(135deg, var(--primary), #18c2bd);
}

.sidebar-footer {
  margin-top: auto;
  color: var(--muted);
  font-size: 0.82rem;
}

.workspace {
  min-width: 0;
  padding: 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
  padding: 18px;
  border: 1px solid rgba(220, 230, 245, 0.95);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(18px);
}

.topbar h2 {
  margin-top: 4px;
  font-size: clamp(1.55rem, 2vw, 2.25rem);
  letter-spacing: 0;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

body:not([data-view="today"]) .topbar-actions {
  display: none;
}

.user-control {
  display: flex;
  align-items: stretch;
  gap: 6px;
}

.login-status {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--muted);
  background: var(--surface-strong);
  white-space: nowrap;
}

.profile-select-label {
  display: grid;
  gap: 0;
  min-width: 170px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--muted);
  background: var(--surface-strong);
  font-size: 0.72rem;
}

.profile-select-label select {
  min-height: 24px;
  border: 0;
  padding: 0;
  background: transparent;
  box-shadow: none;
  font-size: 0.94rem;
}

.profile-select-label select:focus {
  box-shadow: none;
}

.date-control {
  display: grid;
  grid-template-columns: 36px minmax(160px, 1fr) 36px auto;
  align-items: stretch;
  gap: 6px;
  min-height: 44px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-strong);
  box-shadow: 0 8px 22px rgba(53, 89, 148, 0.06);
}

.date-field {
  display: grid;
  gap: 0;
  min-width: 160px;
  color: var(--muted);
  font-size: 0.72rem;
}

.date-field input {
  min-height: 24px;
  border: 0;
  padding: 0;
  background: transparent;
  box-shadow: none;
  font-size: 0.94rem;
}

.date-field input:focus {
  box-shadow: none;
}

.date-step {
  width: 36px;
  min-height: 36px;
  font-size: 1.35rem;
}

#todayDate {
  min-width: 62px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--surface-strong);
  padding: 9px 10px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(47, 109, 246, 0.13);
}

.view {
  display: none;
}

.view.is-visible {
  display: block;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.summary-card,
.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.summary-card {
  min-height: 124px;
  padding: 16px;
}

.summary-card span {
  color: var(--muted);
  font-size: 0.85rem;
}

.summary-card strong {
  display: block;
  margin-top: 12px;
  font-size: 1.9rem;
  line-height: 1;
}

.summary-card small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
}

.content-grid,
.split-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(340px, 0.65fr);
  gap: 18px;
}

.dashboard-lower-grid {
  margin-top: 18px;
}

.stacked-panels {
  display: grid;
  gap: 18px;
}

.wide-panel {
  min-width: 0;
}

.panel {
  padding: 20px;
}

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

.panel-heading h3,
.compact-heading {
  margin: 0;
  font-size: 1rem;
}

.panel-heading h3 {
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel-heading h3::before {
  content: "";
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  border-radius: 9px;
  background:
    linear-gradient(135deg, rgba(47, 109, 246, 0.95), rgba(24, 194, 189, 0.9));
  box-shadow: 0 8px 18px rgba(47, 109, 246, 0.22);
}

.form-panel {
  display: grid;
  align-content: start;
  gap: 14px;
}

.form-panel.is-editing {
  border-color: rgba(16, 169, 153, 0.55);
  box-shadow:
    0 0 0 3px rgba(16, 169, 153, 0.12),
    var(--shadow);
}

.edit-panel {
  display: grid;
  gap: 10px;
  border: 1px solid rgba(16, 169, 153, 0.35);
  border-radius: var(--radius);
  background: #f0fffc;
  padding: 12px;
}

.edit-panel[hidden] {
  display: none;
}

.edit-panel strong {
  display: block;
  color: var(--ink);
}

.edit-panel span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.8rem;
}

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

label,
fieldset {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.84rem;
}

fieldset {
  margin: 0;
  padding: 0;
  border: 0;
}

legend {
  padding: 0 0 7px;
  color: var(--muted);
}

.chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.person-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 40px;
  padding: 0 12px 0 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  background: var(--surface-strong);
  box-shadow: 0 6px 18px rgba(53, 89, 148, 0.05);
}

.person-chip input {
  width: auto;
  min-height: auto;
}

.avatar,
.avatar-preview {
  --avatar-a: #2f6df6;
  --avatar-b: #18c2bd;
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  border: 2px solid rgba(255, 255, 255, 0.82);
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(135deg, var(--avatar-a), var(--avatar-b));
  box-shadow: 0 9px 20px rgba(47, 109, 246, 0.2);
  font-size: 0.9rem;
  font-weight: 800;
  line-height: 1;
  overflow: hidden;
}

.avatar img,
.avatar-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-xs {
  width: 24px;
  height: 24px;
  flex-basis: 24px;
  border-width: 1px;
  font-size: 0.7rem;
  box-shadow: none;
}

.avatar-md {
  width: 42px;
  height: 42px;
  flex-basis: 42px;
}

.avatar-lg {
  width: 58px;
  height: 58px;
  flex-basis: 58px;
  font-size: 1.15rem;
}

.avatar-xl {
  width: 78px;
  height: 78px;
  flex-basis: 78px;
  font-size: 1.5rem;
}

.person-heading,
.person-card-main {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.person-heading > div,
.person-card-main > div {
  min-width: 0;
}

.person-form-card {
  display: flex;
  align-items: center;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(135deg, #ffffff, #f2fbff);
  padding: 14px;
  box-shadow: 0 12px 30px rgba(53, 89, 148, 0.08);
}

.avatar-actions {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.avatar-actions strong {
  color: var(--ink);
  font-size: 1rem;
}

.avatar-actions span,
.person-card small {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.button-row,
.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.avatar-upload-button {
  position: relative;
  overflow: hidden;
}

.avatar-upload-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.toggle-line {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--ink);
}

.toggle-line input {
  width: 18px;
  min-height: 18px;
}

.primary-button,
.ghost-button,
.subtle-button,
.danger-button,
.icon-button {
  min-height: 40px;
  border-radius: 12px;
  border: 1px solid transparent;
  padding: 0 13px;
  white-space: nowrap;
}

.primary-button {
  color: #fff;
  background: linear-gradient(135deg, var(--primary), #18c2bd);
  box-shadow: 0 12px 24px rgba(47, 109, 246, 0.2);
}

.primary-button:hover {
  background: linear-gradient(135deg, var(--primary-dark), #0f9f8f);
}

.ghost-button,
.subtle-button {
  color: var(--ink);
  border-color: var(--line);
  background: var(--surface-strong);
  box-shadow: 0 6px 18px rgba(53, 89, 148, 0.05);
}

.danger-button {
  color: #8b2f24;
  border-color: #efc9bf;
  background: #fff5f1;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 40px;
  padding: 0;
  color: var(--muted);
  border-color: var(--line);
  background: var(--surface-strong);
  font-size: 1.2rem;
}

.align-end {
  align-self: end;
}

.segmented-control {
  display: inline-grid;
  grid-auto-flow: column;
  gap: 2px;
  min-height: 40px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #edf4ff;
}

.segmented-control button {
  min-width: 62px;
  border: 0;
  border-radius: 10px;
  color: var(--muted);
  background: transparent;
  padding: 0 11px;
}

.segmented-control button.is-active {
  color: #fff;
  background: var(--primary);
  box-shadow: 0 8px 18px rgba(47, 109, 246, 0.22);
}

.compact-segment {
  margin-bottom: 14px;
}

.compact-controls {
  align-items: end;
  margin-bottom: 14px;
}

.import-label {
  position: relative;
  display: inline-grid;
  place-items: center;
  min-width: 54px;
}

.import-label input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.meal-items-header,
.meal-item-row {
  display: grid;
  grid-template-columns: minmax(130px, 1.2fr) minmax(86px, 0.8fr) minmax(78px, 0.7fr) minmax(78px, 0.7fr) 40px;
  gap: 8px;
  align-items: center;
}

.meal-items-header {
  color: var(--muted);
  font-size: 0.78rem;
}

#mealItems {
  display: grid;
  gap: 8px;
}

.record-list,
.timeline,
.template-list,
.trend-list,
.people-list {
  display: grid;
  gap: 10px;
}

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

.dashboard-grid.single-column {
  grid-template-columns: 1fr;
}

.record-card,
.timeline-item,
.template-card,
.person-card,
.trend-card,
.chart-card,
.stat-row,
.detail-item {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.92);
  padding: 15px;
  box-shadow: 0 10px 30px rgba(53, 89, 148, 0.06);
}

.record-card:hover,
.template-card:hover,
.person-card:hover,
.chart-card:hover,
.month-day:hover {
  border-color: rgba(47, 109, 246, 0.38);
  box-shadow: 0 16px 38px rgba(53, 89, 148, 0.11);
}

.record-card header,
.timeline-item header,
.template-card header,
.person-card header,
.person-card footer,
.chart-card header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.person-card {
  display: grid;
  gap: 14px;
}

.person-card footer {
  justify-content: flex-end;
}

.record-card h4,
.timeline-item h4,
.template-card h4,
.person-card h4,
.chart-card h4,
.detail-box h4 {
  margin: 0;
  font-size: 0.98rem;
}

.record-card p,
.timeline-item p,
.template-card p,
.person-card p,
.chart-card p,
.detail-item p,
.detail-box p {
  margin: 7px 0 0;
  color: var(--muted);
  line-height: 1.48;
}

.record-card > p,
.detail-item p {
  color: var(--ink);
}

.card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.meta-line {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 9px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  color: var(--primary-dark);
  background: var(--green-soft);
  font-size: 0.78rem;
  font-weight: 650;
}

.pill.is-food {
  color: #8a3d27;
  background: var(--red-soft);
}

.pill.is-rest {
  color: #304f74;
  background: var(--blue-soft);
}

.divider {
  height: 1px;
  margin: 16px 0;
  background: var(--line);
}

.chart-card {
  min-height: 250px;
}

.wide-chart-card {
  min-height: 270px;
}

.chart-shell {
  margin-top: 12px;
  color: var(--primary);
}

.line-chart {
  display: block;
  width: 100%;
  height: 150px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.88), rgba(244, 249, 255, 0.88)),
    repeating-linear-gradient(0deg, transparent 0, transparent 29px, rgba(220, 230, 245, 0.82) 30px);
}

.line-chart circle {
  fill: var(--primary);
  stroke: var(--surface-strong);
  stroke-width: 2;
}

.chart-axis {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.78rem;
}

.chart-axis strong {
  color: var(--ink);
  font-size: 0.86rem;
}

.chart-axis span:last-child {
  text-align: right;
}

.chart-empty {
  min-height: 150px;
  display: grid;
  place-items: center;
  margin-top: 12px;
}

.time-chip-row {
  display: flex;
  gap: 6px;
  margin-top: 10px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.time-chip {
  display: grid;
  gap: 2px;
  min-width: 52px;
  color: var(--muted);
  font-size: 0.72rem;
}

.time-chip strong {
  color: var(--ink);
  font-size: 0.8rem;
}

.stat-list {
  display: grid;
  gap: 10px;
}

.stat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.stat-row span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}

.stat-row strong {
  font-size: 1.8rem;
  color: var(--primary);
}

.month-panel {
  margin-bottom: 14px;
  border: 1px solid rgba(220, 230, 245, 0.95);
  border-radius: 22px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(246, 250, 255, 0.86));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.86);
  padding: 14px;
}

.month-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 12px;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 800;
}

.month-title::after {
  content: "双击/长按编辑";
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  color: var(--primary);
  background: var(--blue-soft);
  font-size: 0.72rem;
  font-weight: 700;
}

.month-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: #eef4ff;
  padding: 8px;
}

.month-weekday {
  color: #5f6f91;
  font-size: 0.72rem;
  font-weight: 800;
  text-align: center;
  padding: 6px 0 4px;
}

.month-day {
  display: grid;
  align-content: start;
  gap: 6px;
  min-height: 96px;
  border: 1px solid rgba(207, 219, 238, 0.9);
  border-radius: 18px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.9);
  padding: 10px;
  text-align: left;
  white-space: normal;
  transition:
    transform 0.16s ease,
    border-color 0.16s ease,
    box-shadow 0.16s ease,
    background 0.16s ease;
}

.month-day:hover {
  transform: translateY(-2px);
}

.month-day-number {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  color: var(--muted);
  background: #edf4ff;
  font-size: 0.8rem;
  font-weight: 800;
}

.month-day-main {
  color: var(--ink);
  font-size: 0.88rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.month-day-meta {
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.25;
  font-weight: 650;
}

.month-day.has-data {
  border-color: rgba(16, 169, 153, 0.45);
  background:
    linear-gradient(180deg, #ffffff, #effcf9);
  box-shadow: 0 10px 24px rgba(16, 169, 153, 0.08);
}

.month-day.is-selected {
  border-color: var(--primary);
  background:
    linear-gradient(180deg, #ffffff, #eff5ff);
  box-shadow:
    0 0 0 2px rgba(47, 109, 246, 0.16),
    0 14px 30px rgba(53, 89, 148, 0.12);
}

.month-day.is-selected .month-day-number {
  color: #fff;
  background: var(--primary);
  box-shadow: 0 8px 18px rgba(47, 109, 246, 0.24);
}

.month-day.is-today:not(.is-selected) .month-day-number {
  color: var(--primary);
  background: #dbe8ff;
  box-shadow: inset 0 0 0 1px rgba(47, 109, 246, 0.22);
}

.month-day.is-empty {
  min-height: 96px;
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}

.training-month-grid .month-day {
  min-height: 100px;
}

.pagination {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  justify-content: flex-end;
  margin-top: 14px;
}

.pagination button {
  min-height: 34px;
  min-width: 34px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  background: var(--surface-strong);
  padding: 0 10px;
}

.pagination button.is-active {
  color: #fff;
  border-color: var(--primary);
  background: var(--primary);
}

.pagination button:disabled {
  cursor: not-allowed;
  color: var(--muted);
  opacity: 0.5;
}

.detail-box {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.details-drawer {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
  padding: 0;
}

.details-drawer summary {
  cursor: pointer;
  color: var(--ink);
  padding: 12px 13px;
  font-size: 0.9rem;
}

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

.drawer-full {
  grid-column: 1 / -1;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.metric {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #faf8f2;
  padding: 10px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
}

.metric strong {
  display: block;
  margin-top: 4px;
}

.body-chart {
  display: flex;
  align-items: end;
  gap: 8px;
  height: 160px;
  padding: 14px 8px 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #fff, #faf8f2);
  overflow-x: auto;
}

.bar {
  display: grid;
  align-content: end;
  justify-items: center;
  min-width: 34px;
  height: 100%;
  color: var(--muted);
  font-size: 0.72rem;
}

.bar-fill {
  width: 100%;
  min-height: 4px;
  border-radius: 6px 6px 0 0;
  background: var(--primary);
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  padding: 18px;
  text-align: center;
  background: rgba(255, 255, 255, 0.5);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(20, 32, 30, 0.42);
  backdrop-filter: blur(8px);
}

.modal-backdrop[hidden] {
  display: none;
}

.login-dialog {
  display: grid;
  gap: 16px;
  width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
  box-shadow: 0 28px 80px rgba(20, 32, 30, 0.22);
  padding: 22px;
}

.login-dialog h3,
.login-dialog p {
  margin: 0;
}

.login-dialog p:not(.eyebrow) {
  margin-top: 6px;
  color: var(--muted);
  line-height: 1.5;
}

.known-user-list {
  display: grid;
  gap: 8px;
}

.known-user-list > span {
  color: var(--muted);
  font-size: 0.78rem;
}

.known-user-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

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

  .sidebar {
    position: static;
    height: auto;
    padding: 20px 18px 16px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .brand {
    margin-bottom: 16px;
  }

  .nav {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .nav-button {
    min-height: 48px;
    justify-content: center;
    text-align: center;
  }

  .summary-grid,
  .content-grid,
  .split-layout,
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .workspace {
    padding: 12px 14px 24px;
  }

  .sidebar {
    padding: 14px 14px 10px;
  }

  .brand {
    gap: 10px;
    margin-bottom: 10px;
  }

  .brand-logo {
    width: 136px;
  }

  .brand p {
    font-size: 0.76rem;
  }

  .sidebar-footer {
    margin-top: 8px;
    font-size: 0.72rem;
  }

  .nav {
    gap: 6px;
  }

  .nav-button {
    min-height: 38px;
    gap: 7px;
    padding: 0 8px;
    border-radius: 14px;
    font-size: 0.88rem;
  }

  .nav-button::before {
    width: 24px;
    height: 24px;
    flex-basis: 24px;
    border-radius: 9px;
    font-size: 0.76rem;
  }

  .topbar,
  .panel-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar {
    gap: 10px;
    margin-bottom: 14px;
    padding: 14px;
    border-radius: 20px;
  }

  .topbar h2 {
    font-size: 1.7rem;
    line-height: 1.12;
  }

  .eyebrow {
    font-size: 0.78rem;
  }

  .topbar-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    justify-content: stretch;
  }

  .topbar-actions > * {
    min-width: 0;
  }

  .user-control {
    display: grid;
    grid-column: 1 / -1;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 6px;
  }

  .profile-select-label {
    min-width: 0;
  }

  .date-control {
    grid-column: 1 / -1;
    grid-template-columns: 36px minmax(0, 1fr) 36px auto;
    min-height: 40px;
  }

  .date-field {
    min-width: 0;
  }

  #todayDate {
    grid-column: auto;
    min-height: 34px;
  }

  #exportData,
  #exportExcel,
  .import-label {
    min-width: 0;
  }

  .primary-button,
  .ghost-button,
  .subtle-button,
  .danger-button,
  .icon-button {
    min-height: 36px;
    padding: 0 10px;
  }

  .panel {
    padding: 14px;
    border-radius: 20px;
  }

  .panel-heading {
    gap: 8px;
    margin-bottom: 12px;
  }

  .field-row,
  .meal-items-header,
  .meal-item-row,
  .drawer-grid,
  .metrics-grid {
    grid-template-columns: 1fr;
  }

  .meal-items-header {
    display: none;
  }

  .month-panel {
    overflow-x: auto;
    padding: 10px;
  }

  .month-title {
    font-size: 0.92rem;
  }

  .month-title::after {
    min-height: 24px;
    padding: 0 8px;
    font-size: 0.66rem;
  }

  .month-grid {
    gap: 5px;
    min-width: 0;
    padding: 6px;
    border-radius: 16px;
  }

  .month-day,
  .month-day.is-empty {
    min-height: 72px;
    padding: 6px;
    border-radius: 13px;
  }

  .training-month-grid .month-day {
    min-height: 78px;
  }

  .month-day-number {
    width: 22px;
    height: 22px;
    font-size: 0.7rem;
  }

  .month-day-main {
    font-size: 0.72rem;
    line-height: 1.18;
  }

  .month-day-meta {
    display: none;
  }

  .segmented-control {
    width: 100%;
  }

  .segmented-control button {
    width: 100%;
  }

  .date-control .icon-button {
    width: 36px;
  }
}
