:root {
  color-scheme: light;
  --bg: #f7f8fb;
  --bg-top: #f3f9ff;
  --bg-mid: #fff8f2;
  --bg-bottom: #f4fbf7;
  --surface: rgba(255, 255, 255, 0.86);
  --surface-solid: #ffffff;
  --surface-raised: rgba(255, 255, 255, 0.74);
  --ink: #18181b;
  --muted: #666a73;
  --tertiary: #9498a3;
  --line: rgba(37, 43, 55, 0.11);
  --line-strong: rgba(37, 43, 55, 0.2);
  --primary: #176bff;
  --primary-strong: #0a4fd3;
  --primary-soft: #eaf2ff;
  --success: #0f7c55;
  --success-soft: #e5f7ef;
  --warning: #a65f00;
  --warning-soft: #fff0d8;
  --danger: #c91f37;
  --danger-soft: #ffe8ed;
  --info: #4f46e5;
  --info-soft: #eef0ff;
  --purchase: #a14f00;
  --purchase-soft: #fff1df;
  --shadow: 0 20px 48px rgba(33, 43, 68, 0.16);
  --shadow-soft: 0 10px 28px rgba(33, 43, 68, 0.08);
  --shadow-tiny: 0 1px 2px rgba(24, 24, 27, 0.06), 0 8px 20px rgba(33, 43, 68, 0.06);
  --radius: 8px;
  --control-radius: 14px;
  --ease-fluid: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.2, 0.9, 0.2, 1);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --app-viewport-height: 100vh;
  --sheet-max-height: calc(92vh - var(--safe-top));
  --sheet-top: 0px;
}

* {
  box-sizing: border-box;
}

html {
  width: 100%;
  max-width: 100%;
  min-height: 100%;
  background: var(--bg);
  overflow-x: hidden;
  overscroll-behavior: none;
  touch-action: auto;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 100vh;
  min-height: 100dvh;
  min-height: var(--app-viewport-height);
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(145deg, var(--bg-top) 0%, var(--bg) 34%, var(--bg-mid) 67%, var(--bg-bottom) 100%);
  font-family:
    -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Segoe UI",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  touch-action: auto;
  overscroll-behavior: none;
}

html.is-android,
html.is-android body,
html.is-android .app-shell {
  overscroll-behavior: auto;
}

html.is-android .app-shell {
  overflow-x: hidden;
}

body.is-scroll-locked {
  position: fixed;
  right: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

body.is-scroll-locked .app-shell {
  touch-action: none;
}

body.is-android-scroll-locked {
  position: static;
  height: auto;
  overflow: hidden;
}

body.is-android-scroll-locked .app-shell {
  touch-action: pan-y;
}

html.is-android-wechat body.is-scroll-locked {
  position: static;
  height: auto;
  overflow: hidden;
}

html.is-android-wechat body.is-scroll-locked .app-shell {
  touch-action: auto;
}

html.is-android-wechat body.is-android-sheet-open {
  overflow-x: hidden;
  overflow-y: auto;
}

html.is-android-wechat body.is-android-sheet-open .app-shell {
  touch-action: auto;
}

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

button,
a,
input,
select,
textarea {
  touch-action: manipulation;
}

button {
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(0, 122, 255, 0.28);
  outline-offset: 2px;
}

svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-chip {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  color: var(--primary);
  background: var(--primary-soft);
  border: 1px solid rgba(23, 107, 255, 0.16);
  border-radius: 12px;
}

.icon-chip svg {
  width: 20px;
  height: 20px;
}

.icon-chip.start {
  color: var(--primary);
  background: var(--primary-soft);
  border-color: rgba(23, 107, 255, 0.16);
}

.icon-chip.finish,
.icon-chip.success {
  color: var(--success);
  background: var(--success-soft);
  border-color: rgba(15, 124, 85, 0.16);
}

.icon-chip.warning {
  color: var(--warning);
  background: var(--warning-soft);
  border-color: rgba(166, 95, 0, 0.16);
}

.icon-chip.discard,
.icon-chip.danger {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: rgba(201, 31, 55, 0.16);
}

.icon-chip.info,
.icon-chip.settings {
  color: var(--info);
  background: var(--info-soft);
  border-color: rgba(79, 70, 229, 0.16);
}

.icon-chip.purchase {
  color: var(--purchase);
  background: var(--purchase-soft);
  border-color: rgba(161, 79, 0, 0.16);
}

.icon-chip.neutral,
.icon-chip.empty {
  color: var(--muted);
  background: #f2f5f8;
  border-color: rgba(37, 43, 55, 0.1);
}

.app-shell {
  position: relative;
  width: 100%;
  max-width: 760px;
  min-width: 0;
  min-height: 100vh;
  min-height: 100dvh;
  min-height: var(--app-viewport-height);
  margin: 0 auto;
  overflow-x: clip;
  overscroll-behavior: none;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: calc(74px + var(--safe-top));
  padding: calc(16px + var(--safe-top)) 16px 12px;
  background: rgba(250, 252, 255, 0.82);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(24px) saturate(1.45);
}

.topbar h1,
.sheet-title-row h2 {
  margin: 0;
  font-size: 28px;
  font-weight: 750;
  line-height: 1.05;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0;
}

.content {
  padding: 14px 14px calc(110px + var(--safe-bottom));
}

.screen {
  display: grid;
  gap: 12px;
}

.today-panel,
.section,
.metric-strip,
.empty-state,
.insight-card,
.product-card,
.timeline-item,
.settings-row,
.settings-card,
.settings-hero,
.chart-panel,
.unit-row {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-tiny);
  backdrop-filter: blur(20px) saturate(1.35);
}

.today-panel {
  display: grid;
  gap: 16px;
  position: relative;
  overflow: hidden;
  padding: 18px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.9), rgba(238, 246, 255, 0.78)),
    var(--surface);
}

.today-panel.quiet {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.92), rgba(255, 246, 235, 0.72)),
    var(--surface);
}

.today-panel h2 {
  margin: 0;
  font-size: 27px;
  font-weight: 760;
  line-height: 1.12;
  letter-spacing: 0;
}

.today-panel p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 15px;
}

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

.action-card {
  --action-color: var(--primary);
  --action-soft: var(--primary-soft);
  --action-chip-bg: var(--primary-soft);
  --action-border: rgba(23, 107, 255, 0.18);
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 8px;
  min-height: 112px;
  padding: 14px;
  text-align: left;
  background: linear-gradient(145deg, #ffffff, var(--action-soft));
  border: 1px solid var(--action-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-tiny);
  cursor: pointer;
  transition:
    transform 150ms ease,
    background 150ms ease,
    border-color 150ms ease,
    box-shadow 150ms ease;
}

.action-card:active {
  transform: scale(0.97);
  background: linear-gradient(145deg, #ffffff, var(--action-chip-bg));
  box-shadow: 0 4px 12px rgba(33, 43, 68, 0.06);
}

.action-card .icon-chip {
  color: var(--action-color);
  background: var(--action-chip-bg);
  border-color: var(--action-border);
}

.action-card strong {
  font-size: 18px;
  font-weight: 760;
  line-height: 1.15;
}

.action-card span {
  align-self: end;
  color: var(--muted);
  font-size: 13px;
}

.action-card-start {
  --action-color: var(--primary);
  --action-soft: var(--primary-soft);
  --action-chip-bg: #e7f0ff;
  --action-border: rgba(23, 107, 255, 0.2);
}

.action-card-finish {
  --action-color: var(--success);
  --action-soft: var(--success-soft);
  --action-chip-bg: #e0f5ec;
  --action-border: rgba(15, 124, 85, 0.2);
}

.action-card-discard {
  --action-color: var(--danger);
  --action-soft: var(--danger-soft);
  --action-chip-bg: #ffe0e7;
  --action-border: rgba(201, 31, 55, 0.2);
}

.action-card-purchase {
  --action-color: var(--purchase);
  --action-soft: var(--purchase-soft);
  --action-chip-bg: #ffe9cf;
  --action-border: rgba(161, 79, 0, 0.2);
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  overflow: visible;
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
  backdrop-filter: none;
}

.metric {
  position: relative;
  min-width: 0;
  padding: 13px;
  background: rgba(255, 255, 255, 0.76);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-tiny);
  backdrop-filter: blur(18px) saturate(1.3);
}

.metric-icon {
  width: 18px;
  height: 18px;
  margin-bottom: 8px;
  color: var(--primary);
}

.metric strong {
  display: block;
  overflow-wrap: normal;
  word-break: keep-all;
  white-space: nowrap;
  color: var(--ink);
  font-size: 23px;
  font-weight: 760;
  line-height: 1.08;
  font-variant-numeric: tabular-nums;
}

.metric > span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.reminder-panel {
  border-color: rgba(181, 106, 0, 0.22);
  background: linear-gradient(180deg, #fffdfa, var(--surface-solid));
}

.reminder-list,
.reminder-preview {
  display: grid;
  gap: 8px;
}

.reminder-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
  width: 100%;
  min-height: 58px;
  padding: 10px;
  text-align: left;
  background: var(--surface-solid);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  transition:
    transform 150ms ease,
    border-color 150ms ease,
    background 150ms ease;
}

.reminder-card:active {
  transform: scale(0.985);
  background: #f8f8fa;
}

.reminder-card.warning {
  border-color: rgba(181, 106, 0, 0.2);
}

.reminder-card.danger {
  border-color: rgba(215, 0, 21, 0.2);
}

.reminder-dot {
  width: 9px;
  height: 9px;
  margin-top: 8px;
  border-radius: 999px;
  background: var(--info);
}

.reminder-dot.warning {
  background: var(--warning);
}

.reminder-dot.danger {
  background: var(--danger);
}

.reminder-copy {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.reminder-copy strong {
  overflow-wrap: anywhere;
  font-size: 15px;
  font-weight: 740;
  line-height: 1.25;
}

.reminder-copy small {
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.section,
.chart-panel {
  padding: 15px;
}

.section-header,
.row-between {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.section-header {
  margin-bottom: 12px;
}

.section-header h2,
.section-header h3,
.settings-row h3,
.chart-panel h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 730;
  line-height: 1.22;
  letter-spacing: 0;
}

.section-header p,
.subtext,
.meta,
.hint {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.stack {
  display: grid;
  gap: 10px;
}

.inline-actions,
.chip-row,
.segmented,
.card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  touch-action: pan-x pan-y;
  -webkit-overflow-scrolling: touch;
}

.inline-actions::-webkit-scrollbar,
.chip-row::-webkit-scrollbar,
.segmented::-webkit-scrollbar,
.card-actions::-webkit-scrollbar {
  display: none;
}

.button,
.chip,
.segmented button,
.icon-button {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: var(--control-radius);
  cursor: pointer;
  transition:
    transform 150ms ease,
    background 150ms ease,
    border-color 150ms ease,
    color 150ms ease,
    box-shadow 150ms ease;
}

.button:active,
.chip:active,
.segmented button:active,
.icon-button:active,
.product-card:active {
  transform: scale(0.97);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 48px;
  padding: 0 16px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.button-icon {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  stroke-width: 2.2;
}

.button.primary {
  color: #fff;
  background: linear-gradient(180deg, var(--primary), var(--primary-strong));
  box-shadow: 0 12px 22px rgba(23, 107, 255, 0.24);
}

.button.secondary {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.82);
  border-color: var(--line);
  box-shadow: var(--shadow-tiny);
}

.button.danger {
  color: #fff;
  background: linear-gradient(180deg, #df3349, var(--danger));
  box-shadow: 0 12px 22px rgba(201, 31, 55, 0.2);
}

.button.text {
  width: auto;
  color: var(--primary);
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}

.button.compact {
  width: auto;
  min-height: 42px;
  padding: 0 13px;
  font-size: 14px;
}

.button.main-action {
  flex: 1 1 0;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 46px;
  min-width: 46px;
  padding: 0;
  color: var(--primary);
  background: rgba(255, 255, 255, 0.84);
  border-color: var(--line);
  box-shadow: var(--shadow-soft);
}

.icon-button.ghost {
  color: var(--muted);
  background: rgba(244, 247, 250, 0.88);
  box-shadow: none;
}

.chip,
.segmented button {
  flex: 0 0 auto;
  min-height: 36px;
  padding: 0 13px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.7);
  border-color: var(--line);
  font-size: 14px;
  font-weight: 650;
}

.chip.is-active,
.segmented button.is-active {
  color: #fff;
  background: linear-gradient(180deg, var(--primary), var(--primary-strong));
  border-color: rgba(0, 122, 255, 0.24);
  box-shadow: 0 8px 16px rgba(23, 107, 255, 0.18);
}

.inventory-controls {
  display: grid;
  gap: 12px;
}

.filter-panel {
  display: grid;
  gap: 9px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-tiny);
  backdrop-filter: blur(18px) saturate(1.4);
}

.filter-line {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
}

.filter-line > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.search-box {
  position: relative;
}

.search-box svg {
  position: absolute;
  top: 50%;
  left: 13px;
  width: 18px;
  height: 18px;
  color: var(--tertiary);
  transform: translateY(-50%);
}

.search-box input {
  width: 100%;
  height: 52px;
  padding: 0 14px 0 42px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.84);
  border: 1px solid var(--line);
  border-radius: var(--control-radius);
  box-shadow: var(--shadow-tiny);
}

.product-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  transition:
    transform 150ms ease,
    box-shadow 150ms ease;
}

.inventory-card {
  cursor: pointer;
}

.inventory-card:hover {
  border-color: var(--line-strong);
}

.card-trailing {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--tertiary);
}

.card-trailing svg {
  width: 18px;
  height: 18px;
}

.swipe-edit-shell {
  --swipe-x: 0px;
  --swipe-action-opacity: 0;
  --swipe-action-x: 14px;
  --swipe-action-scale: 0.96;
  position: relative;
  overflow: hidden;
  border-radius: var(--radius);
  isolation: isolate;
}

.swipe-edit-card {
  position: relative;
  z-index: 2;
  transform: translateX(var(--swipe-x));
  touch-action: pan-y;
  user-select: none;
  transition:
    transform 320ms var(--ease-spring),
    box-shadow 220ms ease;
  will-change: transform;
}

.swipe-edit-shell.is-dragging .swipe-edit-card {
  transition: none;
}

.swipe-edit-shell.is-open .swipe-edit-card {
  box-shadow: var(--shadow-soft);
}

.swipe-edit-action {
  position: absolute;
  top: 8px;
  right: 0;
  bottom: 8px;
  z-index: 1;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 6px;
  width: 84px;
  color: #fff;
  background: linear-gradient(180deg, var(--info), #3730a3);
  border: 0;
  border-radius: 18px;
  box-shadow: 0 14px 24px rgba(79, 70, 229, 0.2);
  opacity: var(--swipe-action-opacity);
  transform: translateX(var(--swipe-action-x)) scale(var(--swipe-action-scale));
  transition:
    opacity 220ms ease,
    transform 320ms var(--ease-fluid);
  will-change: opacity, transform;
}

.swipe-edit-action svg {
  width: 22px;
  height: 22px;
}

.swipe-edit-action span {
  font-size: 13px;
  font-weight: 760;
}

.product-main {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 11px;
  align-items: start;
}

.product-title {
  min-width: 0;
}

.product-title h3 {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 16px;
  font-weight: 730;
  line-height: 1.25;
}

.product-title p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 9px;
  border-radius: 999px;
  color: var(--muted);
  background: #f2f5f8;
  font-size: 12px;
  font-weight: 760;
  white-space: nowrap;
}

.status-badge.info {
  color: var(--info);
  background: var(--info-soft);
}

.status-badge.success {
  color: var(--success);
  background: var(--success-soft);
}

.status-badge.warning {
  color: var(--warning);
  background: var(--warning-soft);
}

.status-badge.danger {
  color: var(--danger);
  background: var(--danger-soft);
}

.status-badge.neutral {
  color: var(--muted);
  background: #f2f5f8;
}

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

.mini-stat {
  min-width: 0;
  padding: 9px 10px;
  background: rgba(248, 250, 253, 0.86);
  border: 1px solid rgba(60, 60, 67, 0.08);
  border-radius: var(--radius);
}

.mini-stat strong {
  display: block;
  overflow-wrap: normal;
  word-break: keep-all;
  white-space: nowrap;
  color: var(--ink);
  font-size: 15px;
  font-weight: 760;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}

.money-text {
  display: inline-block;
  max-width: 100%;
  color: inherit;
  white-space: nowrap;
  word-break: keep-all;
  overflow-wrap: normal;
  line-height: inherit;
  vertical-align: baseline;
  font-variant-numeric: tabular-nums;
}

.money-text-md {
  font-size: 0.92em;
}

.money-text-sm {
  font-size: 0.84em;
}

.money-text-xs {
  font-size: 0.74em;
}

.money-text-xxs {
  font-size: 0.64em;
}

.mini-stat > span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

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

.timeline-item {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 11px;
  align-items: start;
  padding: 12px;
  box-shadow: none;
  touch-action: pan-y;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  transition:
    padding-right 180ms var(--ease-fluid),
    border-color 180ms ease,
    background 180ms ease;
}

.timeline-item.is-action-open {
  padding-right: 84px;
  border-color: rgba(201, 31, 55, 0.18);
  background: rgba(255, 255, 255, 0.9);
}

.timeline-actions {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  opacity: 0;
  pointer-events: none;
  transform: translateX(8px) scale(0.96);
  transition:
    opacity 160ms ease,
    transform 180ms var(--ease-fluid);
}

.timeline-item.is-action-open .timeline-actions {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0) scale(1);
}

.timeline-delete {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 64px;
  height: 36px;
  padding: 0 10px;
  color: var(--danger);
  background: rgba(255, 236, 240, 0.75);
  border: 1px solid rgba(201, 31, 55, 0.14);
  border-radius: 999px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 740;
  transition:
    transform 150ms ease,
    background 150ms ease,
    opacity 150ms ease;
}

.timeline-delete svg {
  width: 18px;
  height: 18px;
}

.timeline-delete:active {
  transform: scale(0.96);
}

.timeline-delete.is-disabled {
  color: var(--muted);
  background: rgba(244, 247, 250, 0.8);
  border-color: var(--line);
  opacity: 0.52;
}

.timeline-dot {
  width: 9px;
  height: 9px;
  margin-top: 7px;
  border-radius: 999px;
  background: var(--primary);
}

.timeline-dot.success {
  background: var(--success);
}

.timeline-dot.warning {
  background: var(--warning);
}

.timeline-dot.danger {
  background: var(--danger);
}

.timeline-dot.neutral {
  background: var(--tertiary);
}

.timeline-item h3 {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 15px;
  font-weight: 700;
}

.timeline-item p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.empty-state {
  display: grid;
  gap: 12px;
  justify-items: start;
  padding: 16px;
  box-shadow: none;
}

.empty-state h2,
.empty-state h3 {
  margin: 0;
  font-size: 18px;
}

.empty-state p {
  margin: 0;
  color: var(--muted);
}

.bar-list {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.bar-row {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) 76px;
  gap: 10px;
  align-items: center;
  font-size: 13px;
}

.chart-drill-row {
  width: 100%;
  min-height: 32px;
  padding: 0;
  color: inherit;
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
}

.chart-drill-row:active {
  background: rgba(23, 107, 255, 0.08);
}

.bar-track {
  height: 10px;
  overflow: hidden;
  background: #e8e8ed;
  border-radius: 999px;
}

.bar-fill {
  display: block;
  width: var(--value);
  min-width: 3px;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
}

.bar-fill.accent {
  background: var(--info);
}

.bar-value {
  text-align: right;
  color: var(--muted);
  white-space: nowrap;
  word-break: keep-all;
  overflow-wrap: normal;
  font-variant-numeric: tabular-nums;
}

.category-stat-list,
.category-time-list,
.category-time-rows,
.drill-cause-list {
  display: grid;
  gap: 10px;
}

.category-stat-row,
.category-time-row,
.drill-cause-row {
  width: 100%;
  min-width: 0;
  padding: 12px;
  color: inherit;
  text-align: left;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: none;
  cursor: pointer;
}

.category-stat-row:active,
.category-time-row:active,
.drill-cause-row:active {
  transform: scale(0.99);
  background: rgba(247, 250, 255, 0.92);
}

.category-row-head,
.category-time-title {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-width: 0;
}

.category-time-title {
  grid-template-columns: auto minmax(0, 1fr);
}

.category-row-copy,
.category-time-title span,
.drill-cause-row > span:first-child {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.category-row-copy strong,
.category-time-title strong,
.drill-cause-row strong {
  overflow-wrap: anywhere;
  font-size: 16px;
  font-weight: 740;
  line-height: 1.2;
}

.category-row-copy small,
.category-time-title small,
.drill-cause-row small {
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 12px;
}

.category-mini-bars {
  display: grid;
  gap: 7px;
  margin-top: 10px;
}

.mini-bar-line {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) minmax(74px, auto);
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
}

.mini-bar-line strong {
  color: var(--ink);
  text-align: right;
  font-weight: 720;
  white-space: nowrap;
  word-break: keep-all;
  overflow-wrap: normal;
  font-variant-numeric: tabular-nums;
}

.mini-bar-track {
  height: 7px;
  overflow: hidden;
  background: #e8edf4;
  border-radius: 999px;
}

.mini-bar-track span {
  display: block;
  width: var(--value);
  min-width: 3px;
  height: 100%;
  background: var(--primary);
  border-radius: inherit;
}

.category-time-group {
  display: grid;
  gap: 8px;
  padding: 10px;
  background: rgba(248, 250, 253, 0.78);
  border: 1px solid rgba(37, 43, 55, 0.08);
  border-radius: var(--radius);
}

.category-time-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 0 2px;
}

.category-time-head h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 760;
}

.category-time-head > span {
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

.category-time-row,
.drill-cause-row {
  display: grid;
  gap: 10px;
}

.category-time-values {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  min-width: 0;
}

.category-time-values > span {
  min-width: 0;
  padding: 7px 6px;
  text-align: center;
  background: rgba(248, 250, 253, 0.9);
  border: 1px solid rgba(37, 43, 55, 0.08);
  border-radius: 6px;
}

.category-time-values strong {
  display: block;
  overflow-wrap: normal;
  word-break: keep-all;
  white-space: nowrap;
  color: var(--ink);
  font-size: 13px;
  font-weight: 760;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}

.category-time-values small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.insight-grid,
.settings-list,
.settings-stack,
.unit-list {
  display: grid;
  gap: 10px;
}

.settings-screen {
  gap: 14px;
}

.settings-hero {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding: 16px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.92), rgba(238, 240, 255, 0.72)),
    var(--surface);
}

.settings-hero h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 760;
  line-height: 1.15;
}

.settings-hero p:not(.eyebrow) {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.insight-card {
  display: grid;
  gap: 10px;
  padding: 13px;
  box-shadow: none;
}

.insight-card h3 {
  margin: 0;
  font-size: 16px;
}

.insight-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.settings-row {
  display: grid;
  gap: 10px;
  padding: 14px;
  box-shadow: none;
}

.settings-card {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.settings-card-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 11px;
  align-items: start;
}

.settings-card-head h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 740;
  line-height: 1.2;
}

.settings-card-reminder {
  border-color: rgba(166, 95, 0, 0.14);
}

.settings-card-menu {
  border-color: rgba(79, 70, 229, 0.14);
}

.settings-card-dictionary {
  border-color: rgba(15, 124, 85, 0.14);
}

.settings-card-data {
  border-color: rgba(79, 70, 229, 0.14);
}

.settings-card-danger {
  border-color: rgba(201, 31, 55, 0.14);
}

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

.settings-menu-list,
.settings-detail-form {
  display: grid;
  gap: 10px;
}

.settings-menu-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 11px;
  align-items: center;
  width: 100%;
  min-height: 66px;
  min-width: 0;
  padding: 12px;
  color: inherit;
  text-align: left;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: none;
  cursor: pointer;
}

.settings-menu-row:active {
  transform: scale(0.99);
  background: rgba(247, 250, 255, 0.92);
}

.settings-menu-row > span {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.settings-menu-row strong {
  overflow-wrap: anywhere;
  font-size: 16px;
  font-weight: 740;
  line-height: 1.2;
}

.settings-menu-row small {
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.stats-overview .section-header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  justify-content: start;
}

.wechat-note,
.migration-summary {
  display: grid;
  gap: 4px;
  padding: 11px;
  color: var(--ink);
  background: var(--primary-soft);
  border: 1px solid rgba(0, 122, 255, 0.18);
  border-radius: var(--radius);
}

.wechat-note strong,
.migration-summary strong {
  font-size: 14px;
}

.wechat-note span,
.migration-summary span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.migration-code-area {
  min-height: 168px;
  font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.45;
  word-break: break-all;
}

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

.migration-part-card {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.migration-part-card .migration-code-area {
  min-height: 104px;
}

.migration-part-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.migration-part-meta strong {
  font-size: 13px;
}

.migration-part-meta span {
  color: var(--muted);
  font-size: 12px;
}

.reminder-rule-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.reminder-rule-grid > div {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 11px;
  background: #f6f6f8;
  border: 1px solid rgba(60, 60, 67, 0.08);
  border-radius: var(--radius);
}

.reminder-rule-grid strong {
  font-size: 14px;
}

.reminder-rule-grid span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.bottom-nav {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  max-width: 760px;
  margin: 0 auto;
  padding: 8px 10px calc(8px + var(--safe-bottom));
  background: rgba(255, 255, 255, 0.86);
  border-top: 1px solid var(--line);
  box-shadow: 0 -10px 30px rgba(33, 43, 68, 0.08);
  backdrop-filter: blur(24px) saturate(1.55);
}

.bottom-nav button {
  display: grid;
  gap: 3px;
  place-items: center;
  min-width: 0;
  min-height: 55px;
  padding: 5px 4px;
  color: var(--tertiary);
  background: transparent;
  border: 0;
  border-radius: var(--radius);
  font-size: 11px;
  font-weight: 650;
  cursor: pointer;
}

.bottom-nav button.is-active {
  color: var(--primary);
  background: var(--primary-soft);
}

.bottom-nav svg {
  width: 22px;
  height: 22px;
}

.fab {
  position: fixed;
  right: max(18px, calc((100vw - 760px) / 2 + 18px));
  bottom: calc(88px + var(--safe-bottom));
  z-index: 28;
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  color: #fff;
  background: linear-gradient(180deg, var(--primary), var(--primary-strong));
  border: 0;
  border-radius: 50%;
  box-shadow: 0 18px 32px rgba(23, 107, 255, 0.28);
  cursor: pointer;
}

.fab[hidden],
.fab.is-hidden {
  display: none !important;
}

.fab svg {
  width: 26px;
  height: 26px;
}

.sheet {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  align-items: end;
  pointer-events: none;
  overscroll-behavior: contain;
  touch-action: pan-y;
}

.sheet[aria-hidden="true"] {
  visibility: hidden;
}

.sheet[aria-hidden="false"] {
  pointer-events: auto;
  visibility: visible;
}

html.is-android-wechat .sheet[aria-hidden="false"] {
  display: block;
  position: absolute;
  top: var(--sheet-top);
  right: 0;
  bottom: auto;
  left: 0;
  min-height: var(--app-viewport-height);
  overflow-x: hidden;
  overflow-y: visible;
  overscroll-behavior: auto;
  touch-action: auto;
  -webkit-overflow-scrolling: touch;
}

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(16, 20, 30, 0.34);
  opacity: 0;
  transition: opacity 180ms ease;
  touch-action: none;
}

html.is-android-wechat .sheet-backdrop {
  position: fixed;
  touch-action: auto;
}

.sheet[aria-hidden="false"] .sheet-backdrop {
  opacity: 1;
}

.sheet-panel {
  position: relative;
  z-index: 1;
  width: min(760px, 100vw);
  max-width: 100%;
  max-height: calc(92vh - var(--safe-top));
  max-height: calc(92dvh - var(--safe-top));
  max-height: var(--sheet-max-height);
  margin: 0 auto;
  overflow-x: hidden;
  overflow-y: scroll;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  padding: 0 14px 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(247, 248, 251, 0.98)),
    var(--bg);
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 22px 22px 0 0;
  box-shadow: var(--shadow);
  backdrop-filter: blur(24px) saturate(1.3);
  transform: translateY(26px);
  transition: transform 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

html.is-android-wechat .sheet-panel {
  width: min(760px, calc(100vw - 20px));
  max-height: none;
  margin: max(12px, var(--safe-top)) auto 0;
  overflow: visible;
  overscroll-behavior: auto;
  touch-action: auto;
}

.sheet[aria-hidden="false"] .sheet-panel {
  transform: translateY(0);
}

html.is-android-wechat .sheet[aria-hidden="false"] .sheet-panel {
  transform: none;
}

.sheet-handle {
  position: sticky;
  top: 0;
  z-index: 9;
  width: auto;
  height: 28px;
  margin: 0 -14px;
  border-radius: 22px 22px 0 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 1) 0%, rgba(255, 255, 255, 0.99) 72%, rgba(255, 255, 255, 0.96) 100%);
  backdrop-filter: blur(18px) saturate(1.2);
}

html.is-android-wechat .sheet-handle,
html.is-android-wechat .sheet-title-row,
html.is-android-wechat .sheet-actions {
  position: static;
}

.sheet-handle::after {
  content: "";
  position: absolute;
  top: 12px;
  left: 50%;
  width: 38px;
  height: 5px;
  border-radius: 999px;
  background: rgba(60, 60, 67, 0.28);
  transform: translateX(-50%);
}

.sheet-title-row {
  position: sticky;
  top: 28px;
  z-index: 8;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin: 0 -14px 14px;
  padding: 4px 14px 15px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.99) 0%, rgba(255, 255, 255, 0.98) 72%, rgba(247, 248, 251, 0.95) 100%);
  box-shadow: 0 12px 22px rgba(33, 43, 68, 0.05);
  backdrop-filter: blur(18px) saturate(1.2);
}

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

.field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

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

.field span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: none;
  appearance: none;
}

.field textarea {
  resize: vertical;
}

.field input:disabled {
  color: var(--tertiary);
  background: #eef1f5;
}

.input-action-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 46px;
  gap: 8px;
  align-items: stretch;
}

.input-icon-button {
  display: grid;
  place-items: center;
  min-height: 46px;
  color: var(--primary);
  background: var(--primary-soft);
  border: 1px solid rgba(23, 107, 255, 0.18);
  border-radius: 12px;
  box-shadow: var(--shadow-tiny);
  cursor: pointer;
  transition:
    transform 150ms ease,
    background 150ms ease,
    box-shadow 150ms ease;
}

.input-icon-button:active {
  transform: scale(0.97);
  background: #ffffff;
  box-shadow: 0 4px 12px rgba(33, 43, 68, 0.06);
}

.input-icon-button svg {
  width: 22px;
  height: 22px;
}

.date-control {
  position: relative;
  min-width: 0;
}

.date-control [data-date-input] {
  padding-right: 44px;
  cursor: pointer;
}

.native-date-picker {
  position: absolute;
  inset: 0;
  z-index: 3;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  appearance: auto;
  -webkit-appearance: auto;
}

.date-picker-button {
  position: absolute;
  top: 0;
  bottom: 0;
  right: 12px;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  margin: auto 0;
  color: var(--ink);
  pointer-events: none;
}

.date-picker-button svg {
  width: 20px;
  height: 20px;
}

.scanner-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: stretch center;
  pointer-events: none;
  visibility: hidden;
  background: rgba(5, 7, 12, 0.001);
}

.scanner-overlay[aria-hidden="false"] {
  pointer-events: auto;
  visibility: visible;
}

.scanner-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(16, 20, 30, 0.48);
  opacity: 0;
  transition: opacity 180ms ease;
}

.scanner-overlay[aria-hidden="false"] .scanner-backdrop {
  opacity: 1;
}

.scanner-panel {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  gap: 14px;
  width: min(760px, 100%);
  height: 100vh;
  height: 100dvh;
  height: var(--app-viewport-height);
  min-height: 100vh;
  min-height: 100dvh;
  min-height: var(--app-viewport-height);
  max-height: 100vh;
  max-height: 100dvh;
  max-height: var(--app-viewport-height);
  padding: calc(14px + var(--safe-top)) 14px calc(14px + var(--safe-bottom));
  color: #fff;
  background: #070a12;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  transform: translateY(18px);
  transition: transform 220ms var(--ease-fluid);
}

.scanner-overlay[aria-hidden="false"] .scanner-panel {
  transform: translateY(0);
}

.scanner-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.scanner-panel .eyebrow {
  color: rgba(255, 255, 255, 0.64);
}

.scanner-header h2 {
  margin: 0;
  font-size: 24px;
  font-weight: 780;
  line-height: 1.08;
}

.scanner-panel .icon-button.ghost {
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.16);
}

.scanner-frame {
  position: relative;
  overflow: hidden;
  min-height: 0;
  background: #10141e;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 18px;
}

.scanner-frame video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scanner-reticle {
  position: absolute;
  top: 50%;
  left: 7%;
  right: 7%;
  height: min(38%, 220px);
  transform: translateY(-50%);
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: 14px;
  box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.28);
}

.scanner-reticle::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 10%;
  right: 10%;
  height: 2px;
  background: var(--primary);
  box-shadow: 0 0 16px rgba(23, 107, 255, 0.82);
}

.scanner-status {
  margin: 0;
  color: rgba(255, 255, 255, 0.72);
  font-size: 13px;
  text-align: center;
}

.scanner-manual {
  display: grid;
  gap: 8px;
}

.scanner-manual label {
  color: rgba(255, 255, 255, 0.68);
  font-size: 13px;
  font-weight: 650;
}

.scanner-manual-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.scanner-manual input {
  width: 100%;
  min-width: 0;
  min-height: 48px;
  padding: 0 14px;
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: var(--control-radius);
  font: inherit;
  outline: none;
}

.scanner-manual input::placeholder {
  color: rgba(255, 255, 255, 0.38);
}

.scanner-manual .button {
  width: auto;
  color: #fff;
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.18);
  box-shadow: none;
}

@media (min-width: 820px) {
  .scanner-overlay {
    place-items: center;
  }

  .scanner-panel {
    width: min(760px, calc(100vw - 48px));
    height: min(860px, calc(100vh - 32px));
    height: min(860px, calc(100dvh - 32px));
    height: min(860px, calc(var(--app-viewport-height) - 32px));
    min-height: 0;
    max-height: calc(100vh - 32px);
    max-height: calc(100dvh - 32px);
    max-height: calc(var(--app-viewport-height) - 32px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 24px;
  }
}

.action-choice-field {
  gap: 8px;
}

.segmented-choices {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
  min-height: 48px;
  padding: 4px;
  background: rgba(238, 242, 247, 0.82);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.segmented-choice {
  position: relative;
  min-width: 0;
}

.segmented-choice input {
  position: absolute;
  inset: 0;
  opacity: 0;
}

.segmented-choice span {
  display: grid;
  place-items: center;
  min-height: 40px;
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  font-weight: 740;
  line-height: 1;
  border-radius: 11px;
  transition:
    color 160ms ease,
    background 160ms ease,
    box-shadow 160ms ease,
    transform 160ms ease;
}

.segmented-choice input:checked + span {
  color: var(--primary);
  background: #ffffff;
  box-shadow: 0 8px 18px rgba(33, 43, 68, 0.1), inset 0 0 0 1px rgba(23, 107, 255, 0.12);
}

.segmented-choice input:focus-visible + span {
  outline: 3px solid rgba(0, 122, 255, 0.22);
  outline-offset: 2px;
}

.segmented-choice:active span {
  transform: scale(0.98);
}

.sheet-actions {
  position: sticky;
  bottom: 0;
  z-index: 6;
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 10px;
  margin: 16px -14px 0;
  padding: 12px 14px calc(14px + var(--safe-bottom));
  background:
    linear-gradient(180deg, rgba(247, 248, 251, 0) 0%, rgba(247, 248, 251, 0.96) 18%, rgba(247, 248, 251, 0.98) 100%);
  border-top: 1px solid rgba(37, 43, 55, 0.08);
  backdrop-filter: blur(20px) saturate(1.25);
}

.detail-panel {
  display: block;
  width: 100%;
  min-width: 0;
  max-width: 100vw;
  background:
    linear-gradient(180deg, rgba(250, 252, 255, 0.98), rgba(247, 248, 251, 0.98)),
    var(--surface-solid);
}

.detail-panel * {
  min-width: 0;
}

.detail-panel #detailContent {
  display: grid;
  gap: 14px;
  padding-bottom: 14px;
}

.detail-hero {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  padding: 16px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.98), rgba(243, 249, 255, 0.78)),
    var(--surface-solid);
  border: 1px solid rgba(23, 107, 255, 0.12);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  max-width: 100%;
  overflow: hidden;
}

.detail-hero-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  color: var(--primary);
  background: rgba(234, 242, 255, 0.9);
  border: 1px solid rgba(23, 107, 255, 0.14);
  border-radius: 14px;
}

.detail-hero-icon svg {
  width: 24px;
  height: 24px;
}

.detail-hero-copy {
  min-width: 0;
}

.detail-hero-copy > p,
.detail-hero-copy > span,
.detail-hero-expiry > span {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.detail-hero strong {
  display: block;
  margin: 5px 0 4px;
  color: var(--ink);
  font-size: 22px;
  font-weight: 760;
  line-height: 1.12;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.detail-hero-expiry {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  padding-top: 10px;
  border-top: 1px solid rgba(37, 43, 55, 0.08);
}

.detail-hero-expiry strong {
  margin: 0;
  font-size: 14px;
  text-align: right;
  overflow-wrap: anywhere;
}

.detail-section {
  display: grid;
  gap: 10px;
  max-width: 660px;
  width: 100%;
  min-width: 0;
  margin: 0 auto;
}

.detail-section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 0 2px;
  min-width: 0;
}

.detail-section-title h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 760;
}

.detail-section-title span {
  color: var(--muted);
  font-size: 12px;
  text-align: right;
  overflow-wrap: anywhere;
}

.detail-stats {
  margin-bottom: 2px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  padding: 6px;
  background: rgba(255, 255, 255, 0.76);
  border: 1px solid rgba(37, 43, 55, 0.08);
  border-radius: var(--radius);
  box-shadow: 0 8px 18px rgba(33, 43, 68, 0.05);
  min-width: 0;
  overflow: hidden;
}

.unit-list {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.detail-stats .mini-stat {
  padding: 8px 6px;
  text-align: center;
  background: transparent;
  border: 0;
  border-radius: 6px;
}

.detail-stats .mini-stat strong {
  font-size: 17px;
}

.unit-row {
  display: grid;
  gap: 12px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(37, 43, 55, 0.09);
  box-shadow: 0 8px 18px rgba(33, 43, 68, 0.05);
  min-width: 0;
  overflow: hidden;
}

.unit-title-block {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 9px;
  align-items: start;
}

.unit-status-dot {
  width: 8px;
  height: 8px;
  margin-top: 6px;
  border-radius: 999px;
  background: var(--tertiary);
  box-shadow: 0 0 0 4px rgba(148, 152, 163, 0.13);
}

.unit-status-dot.info {
  background: var(--info);
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.13);
}

.unit-status-dot.success {
  background: var(--success);
  box-shadow: 0 0 0 4px rgba(15, 124, 85, 0.12);
}

.unit-status-dot.warning {
  background: var(--warning);
  box-shadow: 0 0 0 4px rgba(166, 95, 0, 0.13);
}

.unit-status-dot.danger {
  background: var(--danger);
  box-shadow: 0 0 0 4px rgba(201, 31, 55, 0.13);
}

.unit-row h3 {
  margin: 0;
  font-size: 15px;
}

.unit-row p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

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

.unit-facts > span {
  display: grid;
  gap: 2px;
  min-width: 0;
  padding: 9px;
  background: rgba(247, 248, 251, 0.84);
  border: 1px solid rgba(60, 60, 67, 0.08);
  border-radius: 7px;
}

.unit-facts strong {
  overflow-wrap: normal;
  word-break: keep-all;
  white-space: nowrap;
  font-size: 14px;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}

.unit-facts small {
  color: var(--muted);
  font-size: 11px;
}

.unit-lifecycle {
  display: grid;
  gap: 10px;
  padding-top: 2px;
  border-top: 1px solid rgba(37, 43, 55, 0.08);
}

.unit-lifecycle summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 44px;
  color: inherit;
  cursor: pointer;
  list-style: none;
}

.unit-lifecycle summary::-webkit-details-marker {
  display: none;
}

.unit-lifecycle summary > span {
  display: flex;
  flex-wrap: nowrap;
  gap: 4px 8px;
  align-items: baseline;
  min-width: 0;
  overflow: hidden;
}

.unit-lifecycle summary strong {
  flex: 0 0 auto;
  font-size: 14px;
  font-weight: 740;
  line-height: 1.2;
}

.unit-lifecycle summary small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  white-space: nowrap;
}

.unit-lifecycle summary svg {
  width: 18px;
  height: 18px;
  color: var(--muted);
  transition: transform 180ms var(--ease-fluid);
}

.unit-lifecycle[open] summary svg {
  transform: rotate(90deg);
}

.unit-lifecycle-track {
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--step-count), minmax(0, 1fr));
  gap: 4px;
  padding: 10px 2px 4px;
}

.unit-lifecycle-track::before {
  content: "";
  position: absolute;
  top: 17px;
  right: calc(100% / var(--step-count) / 2);
  left: calc(100% / var(--step-count) / 2);
  height: 2px;
  background: rgba(37, 43, 55, 0.12);
  border-radius: 999px;
}

.unit-lifecycle-step {
  position: relative;
  z-index: 1;
  display: grid;
  justify-items: center;
  gap: 4px;
  min-width: 0;
  text-align: center;
}

.unit-lifecycle-step i {
  width: 10px;
  height: 10px;
  background: var(--tertiary);
  border: 2px solid var(--surface-solid);
  border-radius: 999px;
  box-shadow: 0 0 0 4px rgba(148, 152, 163, 0.13);
}

.unit-lifecycle-step.info i {
  background: var(--info);
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.13);
}

.unit-lifecycle-step.success i {
  background: var(--success);
  box-shadow: 0 0 0 4px rgba(15, 124, 85, 0.12);
}

.unit-lifecycle-step.danger i {
  background: var(--danger);
  box-shadow: 0 0 0 4px rgba(201, 31, 55, 0.13);
}

.unit-lifecycle-step strong {
  overflow-wrap: anywhere;
  font-size: 12px;
  font-weight: 740;
  line-height: 1.2;
}

.unit-lifecycle-step small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
}

.edit-form {
  display: grid;
  gap: 12px;
}

.toast {
  position: fixed;
  right: 14px;
  bottom: calc(154px + var(--safe-bottom));
  left: 14px;
  z-index: 80;
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 720px;
  min-height: 48px;
  margin: 0 auto;
  padding: 11px 12px;
  color: #fff;
  background: rgba(28, 28, 30, 0.94);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.toast.is-visible {
  display: flex;
}

.toast button {
  min-height: 36px;
  padding: 0 10px;
  color: #fff;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: var(--radius);
  font-weight: 760;
}

@media (min-width: 680px) {
  .reminder-rule-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .today-panel {
    grid-template-columns: minmax(0, 1fr) minmax(250px, 0.72fr);
    align-items: start;
  }

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

  .category-time-row,
  .drill-cause-row {
    grid-template-columns: minmax(0, 1fr) minmax(260px, 0.9fr);
    align-items: center;
  }
}

@media (max-width: 360px) {
  .detail-stats,
  .unit-facts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

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