:root {
  color-scheme: light;
  --bg: #f4f6f5;
  --surface: #ffffff;
  --surface-muted: #eef3f1;
  --ink: #17201d;
  --ink-soft: #52605b;
  --muted: #7a8581;
  --line: #dce4e0;
  --accent: #1f8a70;
  --accent-dark: #126b56;
  --accent-soft: #dff2ec;
  --blue: #3366a9;
  --blue-soft: #e4edf9;
  --amber: #b56c1f;
  --amber-soft: #f7eadb;
  --red: #bc3f3f;
  --red-soft: #f8e3e3;
  --shadow: 0 20px 45px rgba(24, 37, 33, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

html {
  min-height: 100%;
  background: var(--bg);
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(31, 138, 112, 0.08), transparent 320px),
    var(--bg);
  font-family:
    Inter, "SF Pro Display", "PingFang SC", "Microsoft YaHei", Arial,
    sans-serif;
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
}

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

button {
  cursor: pointer;
}

svg {
  display: block;
}

.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.app-shell {
  width: min(1480px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 36px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 0 24px;
}

.brand,
.topbar-actions,
.filter-title,
.section-heading,
.form-actions,
.metric-switch {
  display: flex;
  align-items: center;
}

.brand {
  min-width: 0;
  gap: 14px;
}

.brand-mark {
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  border-radius: var(--radius);
  background: url("./icons/icon.svg?v=20260604iconv2") center / cover no-repeat;
  box-shadow: 0 8px 18px rgba(4, 16, 12, 0.16);
}

.brand h1,
.section-heading h2 {
  margin: 0;
  overflow-wrap: anywhere;
}

.brand h1 {
  font-size: 1.65rem;
  line-height: 1.15;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent-dark);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

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

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 11px;
  border: 1px solid #bcded5;
  border-radius: 7px;
  color: var(--accent-dark);
  background: var(--accent-soft);
  font-size: 0.78rem;
  font-weight: 850;
  white-space: nowrap;
}

.status-pill[data-state="draft"] {
  border-color: #edd0a6;
  color: var(--amber);
  background: var(--amber-soft);
}

.status-pill[data-state="syncing"] {
  border-color: #bed0ed;
  color: var(--blue);
  background: var(--blue-soft);
}

.status-pill[data-state="error"] {
  border-color: #f0caca;
  color: var(--red);
  background: var(--red-soft);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.entry-panel,
.filters,
.sync-panel,
.chart-panel,
.kpi-card,
.record-tools-bottom {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.entry-panel {
  position: sticky;
  top: 16px;
  padding: 18px;
}

.analytics {
  display: grid;
  gap: 16px;
  min-width: 0;
  max-width: 100%;
}

.sync-panel {
  min-width: 0;
  padding: 16px;
}

.sync-simple {
  display: grid;
}

.sync-now-button {
  width: 100%;
  min-height: 48px;
}

.sync-now-button[data-state="ready"] {
  background: var(--accent);
}

.sync-now-button[data-state="syncing"] {
  background: var(--blue);
}

.sync-now-button[data-state="pending"] {
  color: var(--ink);
  background: var(--amber-soft);
  border-color: #edd0a6;
}

.sync-now-button[data-state="idle"] {
  color: var(--accent-dark);
  background: var(--surface);
  border-color: var(--line);
}

.sync-now-button[data-state="error"] {
  color: var(--red);
  background: var(--red-soft);
  border-color: #f0caca;
}

.sync-form {
  display: grid;
  grid-template-columns: minmax(180px, 1.4fr) minmax(150px, 0.9fr) auto auto;
  gap: 10px;
  align-items: end;
}

.sync-save-button {
  min-width: 140px;
  min-height: 42px;
  padding: 0 14px;
}

.toggle-row {
  display: flex;
  align-items: center;
  min-height: 42px;
  gap: 8px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
}

.toggle-row input {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.toggle-row span {
  color: var(--ink-soft);
  font-size: 0.82rem;
  font-weight: 800;
}

.sync-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
}

#syncStatus[data-state="ready"] {
  color: var(--accent-dark);
}

#syncStatus[data-state="syncing"] {
  color: var(--blue);
}

#syncStatus[data-state="pending"] {
  color: var(--amber);
}

#syncStatus[data-state="error"] {
  color: var(--red);
}

.section-heading {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.section-heading.compact {
  margin-bottom: 12px;
}

.section-heading h2 {
  font-size: 1.08rem;
  line-height: 1.25;
}

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

.record-tools {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.record-tools-bottom {
  margin-top: 0;
  padding: 14px;
  border-top: 1px solid var(--line);
}

.record-tools .icon-button {
  flex-direction: column;
  justify-content: center;
  width: 100%;
  min-height: 58px;
  gap: 5px;
  padding: 6px;
  text-align: center;
  white-space: normal;
}

.record-tools .icon-button span {
  max-width: 100%;
  font-size: 0.78rem;
  line-height: 1.2;
}

label {
  display: grid;
  gap: 7px;
  min-width: 0;
}

label span,
.filter-title,
.kpi-card span {
  color: var(--ink-soft);
  font-size: 0.82rem;
  font-weight: 750;
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
  background: var(--surface);
  outline: none;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease;
}

input,
select {
  height: 42px;
  padding: 0 11px;
}

input[type="date"] {
  display: block;
  inline-size: 100%;
  max-inline-size: 100%;
  min-inline-size: 0;
  overflow: hidden;
  -webkit-appearance: none;
  appearance: none;
  line-height: 42px;
  text-align: left;
}

input[type="date"]::-webkit-date-and-time-value {
  width: 100%;
  min-width: 0;
  margin: 0;
  text-align: left;
}

.suggest-field {
  position: relative;
  min-width: 0;
}

.suggestion-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  left: 0;
  z-index: 20;
  max-height: 240px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  box-shadow: 0 16px 30px rgba(24, 37, 33, 0.16);
}

.suggestion-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 0;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  background: var(--surface);
  text-align: left;
}

.suggestion-option:last-child {
  border-bottom: 0;
}

.suggestion-option:active,
.suggestion-option:hover {
  background: var(--surface-muted);
}

.suggestion-option span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 850;
}

.suggestion-option small {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
}

.add-option {
  color: var(--accent-dark);
  background: var(--accent-soft);
}

textarea {
  resize: vertical;
  height: 42px;
  min-height: 42px;
  padding: 10px 11px;
  line-height: 1.35;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 138, 112, 0.16);
}

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

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

.field-grid.body-action-grid {
  grid-template-columns: minmax(104px, 0.72fr) minmax(0, 1.58fr);
}

.exercise-history {
  display: grid;
  gap: 4px;
  padding: 9px 10px;
  border: 1px solid #bcded5;
  border-radius: 7px;
  background: var(--accent-soft);
}

.exercise-history__title,
.exercise-history__best {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.exercise-history__title {
  color: var(--accent-dark);
  font-size: 0.74rem;
  font-weight: 850;
}

.exercise-history__best {
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 850;
}

.exercise-history__best small,
.exercise-history__empty {
  color: var(--ink-soft);
  font-size: 0.76rem;
  font-weight: 750;
}

.exercise-history__best strong {
  flex: 0 0 auto;
  color: var(--accent-dark);
}

.form-actions {
  gap: 8px;
  margin-top: 2px;
}

.primary-button,
.ghost-button,
.icon-button,
.icon-only {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 0;
  border: 1px solid transparent;
  border-radius: 7px;
  font-weight: 800;
  white-space: nowrap;
}

.primary-button svg,
.ghost-button svg,
.icon-button svg,
.icon-only svg,
.filter-title svg,
.accordion-heading svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.primary-button {
  flex: 1 1 auto;
  min-height: 44px;
  padding: 0 14px;
  color: white;
  background: var(--accent);
}

.primary-button:hover {
  background: var(--accent-dark);
}

.ghost-button,
.icon-button,
.icon-only {
  color: var(--ink);
  background: var(--surface);
  border-color: var(--line);
}

.ghost-button {
  min-height: 42px;
  padding: 0 13px;
}

.ghost-button:hover,
.icon-button:hover,
.icon-only:hover {
  border-color: #b8c7c1;
  background: var(--surface-muted);
}

.ghost-button.small {
  min-height: 34px;
  padding: 0 10px;
  font-size: 0.82rem;
}

.icon-button {
  min-height: 40px;
  padding: 0 12px;
  color: var(--accent-dark);
}

.icon-only {
  width: 38px;
  height: 38px;
  padding: 0;
  flex: 0 0 auto;
  color: var(--accent-dark);
}

.danger-soft {
  color: var(--red);
  background: var(--red-soft);
  border-color: #f0caca;
}

.danger-soft:hover {
  border-color: #e4abab;
  background: #f5d6d6;
}

.file-button {
  position: relative;
  overflow: hidden;
}

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

.filters {
  display: grid;
  grid-template-columns: minmax(120px, 0.9fr) repeat(6, minmax(118px, 1fr));
  gap: 10px;
  align-items: end;
  padding: 14px;
}

.filter-title {
  align-self: center;
  gap: 8px;
  color: var(--accent-dark);
}

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

.kpi-card {
  padding: 16px;
  min-width: 0;
}

.kpi-card strong {
  display: block;
  margin: 6px 0 2px;
  font-size: 1.65rem;
  line-height: 1.08;
  overflow-wrap: anywhere;
}

.kpi-card small {
  color: var(--muted);
  font-weight: 700;
  overflow-wrap: anywhere;
}

.chart-panel {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  padding: 16px;
}

.metric-switch {
  gap: 4px;
  min-width: 0;
  padding: 3px;
  border-radius: 7px;
  background: var(--surface-muted);
}

.switch-button {
  min-height: 30px;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  color: var(--ink-soft);
  background: transparent;
  font-size: 0.82rem;
  font-weight: 800;
}

.switch-button.active {
  color: var(--accent-dark);
  background: var(--surface);
  box-shadow: 0 1px 4px rgba(23, 32, 29, 0.08);
}

.timeline-chart {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 246px;
  overflow: hidden;
  padding: 6px 0 0;
}

.line-chart-frame {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  width: 100%;
  min-width: 0;
  height: 246px;
}

.line-y-axis-svg {
  position: relative;
  z-index: 2;
  display: block;
  width: 54px;
  height: 246px;
  background: var(--surface);
}

.line-chart-scroll {
  min-width: 0;
  height: 246px;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
}

.line-chart-canvas {
  width: var(--chart-width, 100%);
  min-width: 100%;
  height: 246px;
}

.line-chart-svg {
  display: block;
  width: 100%;
  height: 100%;
}

.line-grid {
  stroke: rgba(91, 109, 103, 0.18);
  stroke-width: 1;
}

.line-axis {
  stroke: rgba(91, 109, 103, 0.32);
  stroke-width: 1.2;
}

.line-path {
  fill: none;
  stroke: var(--blue);
  stroke-width: 3.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.line-point {
  fill: var(--surface);
  stroke: var(--blue);
  stroke-width: 2.4;
}

.line-point.is-zero {
  fill: var(--surface-muted);
  stroke: #9eb0aa;
  stroke-width: 1.5;
}

.line-tick-label,
.line-y-label {
  fill: var(--muted);
  font-size: 0.62rem;
  font-weight: 800;
}

.line-y-label {
  text-anchor: end;
}

.line-chart-empty {
  display: grid;
  min-height: 224px;
  place-items: center;
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(270px, 0.78fr) minmax(0, 1.22fr);
  gap: 16px;
}

.accordion-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 0;
  border: 0;
  color: inherit;
  background: transparent;
  text-align: left;
}

.accordion-heading h2 {
  margin: 0;
  font-size: 1.08rem;
  line-height: 1.25;
}

.accordion-heading[aria-expanded="true"] {
  margin-bottom: 12px;
}

.accordion-heading svg {
  flex: 0 0 auto;
  color: var(--accent-dark);
  transition: transform 160ms ease;
}

.accordion-heading[aria-expanded="true"] svg {
  transform: rotate(180deg);
}

.rank-list {
  display: grid;
  gap: 11px;
}

.rank-row {
  display: grid;
  gap: 7px;
}

.rank-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 850;
}

.rank-meta span:last-child {
  color: var(--ink-soft);
  font-weight: 800;
  text-align: right;
}

.rank-bar {
  height: 10px;
  border-radius: 999px;
  background: var(--surface-muted);
  overflow: hidden;
}

.rank-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--amber));
}

.table-wrap {
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
}

.exercise-rank-list,
.exercise-rank-list > div {
  display: grid;
  gap: 10px;
}

.exercise-rank-card {
  display: grid;
  gap: 11px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.exercise-rank-main {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.exercise-rank-main > div {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.exercise-rank-main strong {
  overflow-wrap: anywhere;
}

.rank-index {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  border-radius: 7px;
  color: var(--accent-dark);
  background: var(--accent-soft);
  font-size: 0.82rem;
  font-weight: 900;
}

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

.exercise-rank-metrics div {
  display: grid;
  gap: 2px;
  min-width: 0;
  padding: 9px;
  border-radius: 7px;
  background: var(--surface-muted);
}

.exercise-rank-metrics dt {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 850;
}

.exercise-rank-metrics dd {
  margin: 0;
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 850;
  overflow-wrap: anywhere;
}

table {
  width: 100%;
  min-width: 650px;
  border-collapse: collapse;
}

th,
td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--ink-soft);
  font-size: 0.78rem;
  font-weight: 850;
}

td {
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 650;
}

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

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

.history-content {
  display: grid;
  gap: 10px;
}

.calendar-toolbar,
.history-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.calendar-toolbar strong {
  font-size: 0.96rem;
}

.calendar-toolbar .icon-only {
  width: 34px;
  height: 34px;
}

.calendar-toolbar .icon-only:first-child svg {
  transform: rotate(90deg);
}

.calendar-toolbar .icon-only.next svg {
  transform: rotate(-90deg);
}

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

.calendar-weekday {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 850;
  line-height: 1;
  text-align: center;
}

.calendar-day {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  height: clamp(34px, 8.5vw, 42px);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: var(--surface);
  font-size: 0.88rem;
  font-weight: 850;
  line-height: 1;
}

.calendar-day.outside {
  color: #a4ada9;
  background: #f8faf9;
}

.calendar-day.has-record::after {
  position: absolute;
  right: 5px;
  bottom: 5px;
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--accent-dark);
  box-shadow: 0 0 0 2px rgba(31, 138, 112, 0.14);
  content: "";
}

.calendar-day.today {
  border-color: #bcded5;
}

.calendar-day.selected {
  color: white;
  border-color: var(--accent);
  background: var(--accent);
}

.calendar-day.selected::after {
  background: white;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.3);
}

.history-summary {
  flex-wrap: wrap;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-muted);
}

.history-summary strong {
  font-size: 0.94rem;
}

.history-summary span {
  color: var(--ink-soft);
  font-size: 0.82rem;
  font-weight: 800;
}

.load-more-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px 12px;
  padding: 4px 0 2px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
}

.record-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.record-card-group {
  grid-template-columns: 1fr;
}

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

.record-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.record-title strong {
  font-size: 0.98rem;
  overflow-wrap: anywhere;
}

.record-title-metric {
  color: var(--ink-soft);
  font-size: 0.82rem;
  font-weight: 850;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  color: var(--accent-dark);
  background: var(--accent-soft);
  font-size: 0.75rem;
  font-weight: 850;
}

.record-detail {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  color: var(--ink-soft);
  font-size: 0.82rem;
  font-weight: 700;
}

.record-note {
  margin-top: 7px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.record-set-list {
  display: grid;
  gap: 7px;
  margin-top: 10px;
}

.record-set-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  min-width: 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-muted);
}

.record-set-main {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  min-width: 0;
  color: var(--ink-soft);
  font-size: 0.84rem;
  font-weight: 800;
}

.record-set-main strong {
  color: var(--ink);
  font-weight: 900;
}

.record-set-note {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.record-set-index {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  color: var(--accent-dark);
  background: var(--accent-soft);
  font-size: 0.74rem;
  font-weight: 900;
}

.record-set-actions {
  display: flex;
  gap: 5px;
}

.record-set-actions button {
  width: 32px;
  height: 32px;
}

.record-actions {
  display: flex;
  gap: 6px;
}

.record-actions button {
  width: 34px;
  height: 34px;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 120px;
  border: 1px dashed #b8c7c1;
  border-radius: var(--radius);
  color: var(--muted);
  background: rgba(238, 243, 241, 0.65);
  font-weight: 750;
  text-align: center;
  padding: 18px;
}

.backup-dialog[hidden] {
  display: none;
}

.backup-dialog {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: end center;
  padding: 18px;
}

.backup-dialog__scrim {
  position: absolute;
  inset: 0;
  background: rgba(18, 27, 24, 0.46);
}

.backup-dialog__panel {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 14px;
  width: min(100%, 540px);
  max-height: min(86vh, 680px);
  overflow-y: auto;
  padding: 16px;
  border: 1px solid rgba(184, 199, 193, 0.96);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 22px 52px rgba(24, 37, 33, 0.24);
}

.backup-dialog__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.backup-dialog__header .icon-only svg {
  transform: rotate(90deg);
}

.backup-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  padding: 3px;
  border-radius: 7px;
  background: var(--surface-muted);
}

.backup-pane {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(238, 243, 241, 0.62);
}

.backup-pane h3 {
  margin: 0;
  font-size: 1rem;
}

.backup-pane p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.88rem;
  font-weight: 700;
  line-height: 1.55;
}

.backup-pane strong {
  color: var(--ink);
}

.backup-action-button {
  width: 100%;
  min-height: 46px;
}

.backup-message {
  min-height: 22px;
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.85rem;
  font-weight: 800;
  line-height: 1.45;
}

.backup-message[data-state="success"] {
  color: var(--accent-dark);
}

.backup-message[data-state="error"] {
  color: var(--red);
}

.backup-message[data-state="pending"] {
  color: var(--amber);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 10;
  max-width: min(360px, calc(100% - 36px));
  padding: 11px 14px;
  border-radius: var(--radius);
  color: white;
  background: var(--ink);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition:
    opacity 180ms ease,
    transform 180ms ease;
  font-weight: 750;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.mobile-nav {
  display: none;
}

@media (max-width: 1380px) {
  .filters {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

  .filter-title {
    grid-column: 1 / -1;
  }
}

@media (max-width: 1120px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .entry-panel {
    position: static;
  }

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

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

  .filter-title {
    grid-column: 1 / -1;
  }
}

@media (max-width: 820px) {
  body {
    padding-bottom: calc(76px + env(safe-area-inset-bottom));
  }

  .app-shell {
    width: min(100% - 20px, 760px);
    padding-top: 12px;
  }

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

  .topbar-actions {
    width: 100%;
    justify-content: stretch;
  }

  .status-pill {
    justify-content: center;
    flex: 1 1 100%;
  }

  .topbar-actions .icon-button {
    flex: 1 1 0;
  }

  .sync-form,
  .detail-grid {
    grid-template-columns: 1fr;
  }

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

  .kpi-card {
    padding: 12px 10px;
  }

  .kpi-card span {
    font-size: 0.78rem;
  }

  .kpi-card strong {
    margin: 5px 0 1px;
    font-size: 1.35rem;
  }

  .kpi-card small {
    font-size: 0.78rem;
  }

  .filters {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    padding: 12px;
  }

  .filters label {
    gap: 5px;
  }

  .filters label span {
    font-size: 0.78rem;
  }

  .filters select,
  .filters input {
    min-height: 42px;
    padding: 0 10px;
    font-size: 0.92rem;
  }

  .sync-panel,
  .chart-panel,
  .entry-panel {
    padding: 14px;
  }

  .sync-save-button {
    width: 100%;
  }

  .record-card {
    grid-template-columns: 1fr;
  }

  .record-actions {
    justify-content: flex-end;
  }

  .mobile-nav {
    position: fixed;
    right: 10px;
    bottom: calc(10px + env(safe-area-inset-bottom));
    left: 10px;
    z-index: 9;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    padding: 7px;
    border: 1px solid rgba(184, 199, 193, 0.92);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 14px 35px rgba(24, 37, 33, 0.16);
    backdrop-filter: blur(16px);
  }

  .mobile-nav a {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-width: 0;
    min-height: 44px;
    border-radius: 7px;
    color: var(--accent-dark);
    text-decoration: none;
    font-size: 0.82rem;
    font-weight: 850;
  }

  .mobile-nav a:active {
    background: var(--accent-soft);
  }

  .mobile-nav svg {
    width: 18px;
    height: 18px;
    flex: 0 0 auto;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
  }
}

@media (max-width: 520px) {
  body {
    font-size: 15px;
  }

  .brand-mark {
    width: 40px;
    height: 40px;
  }

  .brand h1 {
    font-size: 1.38rem;
  }

  .field-grid {
    grid-template-columns: 1fr;
  }

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

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

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

  .topbar-actions .status-pill {
    grid-column: 1 / -1;
  }

  .icon-button {
    padding: 0 8px;
  }

  .icon-button span {
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .section-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .section-heading .icon-only,
  .section-heading .ghost-button {
    align-self: flex-end;
  }

  .entry-panel .section-heading {
    align-items: center;
    flex-direction: row;
    gap: 10px;
    margin-bottom: 10px;
  }

  .entry-panel .section-heading .icon-only {
    align-self: center;
    width: 34px;
    height: 34px;
  }

  .entry-panel .section-heading .eyebrow {
    margin-bottom: 2px;
    font-size: 0.7rem;
  }

  .entry-panel .section-heading h2 {
    font-size: 1rem;
  }

  .entry-form {
    gap: 10px;
  }

  .metric-switch {
    width: 100%;
  }

  .switch-button {
    flex: 1 1 0;
    padding: 0 6px;
  }
}
