:root {
  --app-bg: #f5f6fa;
  --app-surface: #ffffff;
  --app-primary: #1677ff;
  --app-primary-hover: #0958d9;
  --app-primary-light: rgba(22, 119, 255, 0.08);
  --app-primary-ring: rgba(22, 119, 255, 0.18);
  --app-success: #00b578;
  --app-success-light: rgba(0, 181, 120, 0.08);
  --app-danger: #ff3141;
  --app-danger-light: rgba(255, 49, 65, 0.08);
  --app-warning: #ff8f1f;
  --app-warning-light: rgba(255, 143, 31, 0.1);
  --app-text: #1d2129;
  --app-text-secondary: #86909c;
  --app-text-tertiary: #c9cdd4;
  --app-border: rgba(29, 33, 41, 0.06);
  --app-radius: 16px;
  --app-radius-sm: 10px;
  --app-radius-xs: 8px;
  --app-shadow: 0 2px 16px rgba(29, 33, 41, 0.06);
  --app-shadow-sm: 0 1px 4px rgba(29, 33, 41, 0.04);
  --app-header-h: 52px;
  --app-tabbar-h: 56px;
  --app-safe-bottom: env(safe-area-inset-bottom, 0px);
  --app-transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  background: var(--app-bg);
  color: var(--app-text);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-x: none;
}

.app-page-shell {
  min-height: 100%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  will-change: transform;
}

body.app-back-dragging {
  overflow: hidden;
}

body.app-back-dragging .app-page-shell {
  box-shadow: 4px 0 24px rgba(29, 33, 41, 0.12);
}

body.has-tabbar {
  padding-bottom: calc(var(--app-tabbar-h) + var(--app-safe-bottom) + 12px);
}

body.has-calc-keyboard {
  padding-bottom: calc(280px + var(--app-safe-bottom));
}

body.has-tabbar.has-calc-keyboard {
  padding-bottom: calc(280px + var(--app-safe-bottom));
}

a { color: inherit; }

.text-mono { font-variant-numeric: tabular-nums; }
.truncate-1 {
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.truncate-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Layout */
.app-container {
  max-width: 480px;
  margin: 0 auto;
  padding-left: 16px;
  padding-right: 16px;
}

.app-page {
  padding-top: 12px;
  padding-bottom: 16px;
}

/* Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--app-header-h);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 0.5px solid var(--app-border);
}

.app-header-inner {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.app-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.app-back-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--app-text);
  text-decoration: none;
  flex-shrink: 0;
  transition: background var(--app-transition);
}
.app-back-btn:active { background: var(--app-primary-light); }

.app-header-title {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-header-action {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  border-radius: 999px;
  border: none;
  background: var(--app-bg);
  color: var(--app-text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: background var(--app-transition);
}
.app-header-action:active { background: var(--app-primary-light); }

.app-header-notify {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: var(--app-text-secondary);
  text-decoration: none;
  flex-shrink: 0;
}
.app-header-notify:active { background: var(--app-primary-light); }
.app-header-notify-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--app-danger);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  line-height: 16px;
  text-align: center;
}

.app-header-inner > .dropdown { flex-shrink: 0; }
.app-header-left + .app-header-notify { margin-left: auto; }

.app-home-tagline {
  margin: -4px 0 16px;
  padding: 12px 16px;
  border-radius: var(--app-radius-sm);
  background: linear-gradient(135deg, rgba(255, 193, 7, 0.18), rgba(22, 119, 255, 0.08));
  font-size: 15px;
  font-weight: 600;
  color: var(--app-text);
  text-align: center;
}

/* Tab bar */
.app-tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 0.5px solid var(--app-border);
  padding-bottom: var(--app-safe-bottom);
}

.app-tabbar-inner {
  display: flex;
  height: var(--app-tabbar-h);
  max-width: 480px;
  margin: 0 auto;
}

.app-tabbar-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  text-decoration: none;
  color: var(--app-text-tertiary);
  font-size: 10px;
  transition: color var(--app-transition);
  position: relative;
}
.app-tabbar-item i { font-size: 20px; line-height: 1; }
.app-tabbar-icon-wrap { position: relative; display: inline-flex; line-height: 1; }
.app-tabbar-badge {
  position: absolute;
  top: -2px;
  right: -4px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--app-danger);
  border: 1.5px solid #fff;
}
.app-tabbar-item.active { color: var(--app-primary); font-weight: 500; }
.app-tabbar-item.active::before {
  content: "";
  position: absolute;
  top: 4px;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--app-primary-light);
  z-index: -1;
}

/* Cards */
.app-card {
  background: var(--app-surface);
  border-radius: var(--app-radius);
  box-shadow: var(--app-shadow-sm);
  overflow: hidden;
}
.app-card + .app-card { margin-top: 12px; }
.app-card-body { padding: 16px; }
.app-card-body-compact { padding: 14px 16px; }

.app-card-clickable {
  display: block;
  text-decoration: none;
  color: inherit;
  transition: transform var(--app-transition), box-shadow var(--app-transition);
}
.app-card-clickable:active {
  transform: scale(0.985);
  box-shadow: var(--app-shadow);
}

/* Section */
.app-section-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--app-text-secondary);
  margin: 20px 0 8px 4px;
}
.app-section-title:first-child { margin-top: 0; }

/* Tags / badges */
.app-tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.4;
  vertical-align: middle;
}
.app-tag-primary { background: var(--app-primary-light); color: var(--app-primary); }
.app-tag-muted { background: var(--app-bg); color: var(--app-text-secondary); }
.app-tag-success { background: var(--app-success-light); color: var(--app-success); }
.app-tag-danger { background: var(--app-danger-light); color: var(--app-danger); }
.app-tag-warning { background: var(--app-warning-light); color: var(--app-warning); }

/* Value chips */
.app-value {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
}
.app-value-loss { background: var(--app-danger-light); color: var(--app-danger); }
.app-value-budget { background: var(--app-primary-light); color: var(--app-primary); }
.app-tag-xs {
  font-size: 10px;
  padding: 2px 6px;
  line-height: 1.2;
}
.app-value-gain { background: var(--app-success-light); color: var(--app-success); }

/* Empty state */
.app-empty {
  text-align: center;
  padding: 48px 24px;
}
.app-empty-icon {
  width: 72px;
  height: 72px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: var(--app-primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  color: var(--app-primary);
}
.app-empty-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 6px;
}
.app-empty-desc {
  font-size: 14px;
  color: var(--app-text-secondary);
  margin-bottom: 20px;
}

/* Cell group (WeChat-style list) */
.app-cell-group {
  background: var(--app-surface);
  border-radius: var(--app-radius);
  box-shadow: var(--app-shadow-sm);
  overflow: hidden;
}
.app-cell {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  gap: 12px;
  border-bottom: 0.5px solid var(--app-border);
  transition: background var(--app-transition);
}
.app-cell:last-child { border-bottom: none; }
.app-cell:active { background: var(--app-bg); }
.app-cell-main { flex: 1; min-width: 0; }
.app-cell-title { font-size: 15px; font-weight: 500; }
.app-cell-desc { font-size: 12px; color: var(--app-text-secondary); margin-top: 2px; }
.app-cell-extra { flex-shrink: 0; color: var(--app-text-tertiary); }
.app-cell-arrow { color: var(--app-text-tertiary); font-size: 14px; }

/* Segmented control */
.app-segment {
  display: flex;
  background: rgba(29, 33, 41, 0.04);
  border-radius: 12px;
  padding: 3px;
  gap: 2px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.app-segment::-webkit-scrollbar { display: none; }
.app-segment-item {
  flex: 1;
  min-width: max-content;
  padding: 8px 12px;
  border-radius: 10px;
  text-align: center;
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  color: var(--app-text-secondary);
  white-space: nowrap;
  transition: all var(--app-transition);
}
.app-segment-item.active {
  background: var(--app-surface);
  color: var(--app-primary);
  box-shadow: 0 1px 4px rgba(29, 33, 41, 0.08);
}

/* Forms */
.app-form-group { margin-bottom: 16px; }
.app-form-label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 8px;
  color: var(--app-text);
}
.app-form-hint {
  font-size: 12px;
  color: var(--app-text-secondary);
  margin-top: 6px;
}
.app-input {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border: 1.5px solid transparent;
  border-radius: var(--app-radius-sm);
  background: var(--app-bg);
  font-size: 15px;
  color: var(--app-text);
  outline: none;
  transition: border-color var(--app-transition), background var(--app-transition);
}
.app-input:focus {
  border-color: var(--app-primary);
  background: var(--app-surface);
  box-shadow: 0 0 0 3px var(--app-primary-ring);
}
.app-input::placeholder { color: var(--app-text-tertiary); }
textarea.app-input { height: auto; padding: 12px 14px; resize: vertical; min-height: 80px; }
select.app-input { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2386909c' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px; }

.app-input-row {
  display: flex;
  gap: 10px;
  align-items: stretch;
}
.app-input-row .app-input { flex: 1; }

.app-budget-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.app-budget-input {
  width: 112px;
  flex-shrink: 0;
  text-align: right;
}

.app-budget-summary-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 0.5px solid var(--app-border);
}

.app-budget-summary-row:last-child { border-bottom: none; }

.app-budget-summary-main { min-width: 0; flex: 1; }

.budget-form-row {
  display: grid;
  grid-template-columns: 1fr 112px 40px;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.budget-item-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 112px 64px;
  gap: 8px;
  align-items: center;
}

.budget-item-form-label { min-width: 0; }

.budget-item-form-type { min-width: 0; }

.budget-form-type { min-width: 0; }

.budget-form-amount { text-align: right; }

.budget-item-save {
  white-space: nowrap;
  padding-left: 10px;
  padding-right: 10px;
}

.budget-form-remove {
  width: 40px;
  height: 40px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.app-form-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Buttons */
.app-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 44px;
  padding: 0 20px;
  border: none;
  border-radius: var(--app-radius-sm);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: all var(--app-transition);
  white-space: nowrap;
}
.app-btn:active { transform: scale(0.97); }
.app-btn-primary {
  background: var(--app-primary);
  color: #fff;
}
.app-btn-primary:active { background: var(--app-primary-hover); }
.app-btn-secondary {
  background: var(--app-bg);
  color: var(--app-text);
}
.app-btn-secondary:active { background: var(--app-border); }
.app-btn-danger-outline {
  background: transparent;
  color: var(--app-danger);
  border: 1.5px solid rgba(255, 49, 65, 0.3);
}
.app-btn-success-outline {
  background: transparent;
  color: var(--app-success);
  border: 1.5px solid rgba(0, 181, 120, 0.3);
}
.app-btn-sm {
  height: 34px;
  padding: 0 12px;
  font-size: 13px;
  border-radius: var(--app-radius-xs);
}
.app-btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: var(--app-radius-xs);
}
.app-btn-block { width: 100%; }

/* Direction toggle */
.app-direction-toggle {
  display: flex;
  gap: 10px;
}
.app-direction-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.app-direction-toggle label {
  flex: 1;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--app-radius-sm);
  font-weight: 500;
  cursor: pointer;
  border: 1.5px solid transparent;
  background: var(--app-bg);
  color: var(--app-text-secondary);
  transition: all var(--app-transition);
}
.app-direction-toggle input:checked + label.dir-loss {
  background: var(--app-danger-light);
  color: var(--app-danger);
  border-color: rgba(255, 49, 65, 0.25);
}
.app-direction-toggle input:checked + label.dir-gain {
  background: var(--app-success-light);
  color: var(--app-success);
  border-color: rgba(0, 181, 120, 0.25);
}

/* Summary hero */
.app-summary-hero {
  background: linear-gradient(135deg, #1677ff 0%, #0958d9 100%);
  border-radius: var(--app-radius);
  padding: 20px;
  color: #fff;
  margin-bottom: 16px;
}
.app-summary-hero .app-tag { background: rgba(255,255,255,0.2); color: #fff; }
.app-project-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.app-project-name {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  line-height: 1.3;
  flex: 1;
  min-width: 0;
}
.app-project-name-edit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  flex-shrink: 0;
  cursor: pointer;
  font-size: 14px;
}
.app-project-name-edit:active {
  background: rgba(255, 255, 255, 0.32);
}
.app-summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 0.5px solid rgba(255,255,255,0.15);
}
.app-summary-row:last-child { border-bottom: none; }
.app-summary-type { font-size: 14px; opacity: 0.9; }
.app-summary-values { display: flex; gap: 8px; flex-shrink: 0; }
.app-summary-values .app-value-loss,
.app-summary-values .app-value-gain {
  background: rgba(255,255,255,0.15);
  color: #fff;
  font-size: 12px;
}

/* Cost timeline */
.app-timeline-item {
  display: flex;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 0.5px solid var(--app-border);
}
.app-timeline-item:last-child { border-bottom: none; }
.app-timeline-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-top: 6px;
  flex-shrink: 0;
}
.app-timeline-dot.loss { background: var(--app-danger); box-shadow: 0 0 0 3px var(--app-danger-light); }
.app-timeline-dot.gain { background: var(--app-success); box-shadow: 0 0 0 3px var(--app-success-light); }
.app-timeline-content { flex: 1; min-width: 0; }
.app-timeline-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}
.app-timeline-note {
  font-size: 13px;
  color: var(--app-text-secondary);
  margin-top: 6px;
}

/* Action bar */
.app-action-bar {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 0.5px solid var(--app-border);
}

/* Toast */
.app-toast-container {
  position: fixed;
  top: calc(var(--app-header-h) + 12px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  width: calc(100% - 32px);
  max-width: 448px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.app-toast {
  padding: 12px 16px;
  border-radius: var(--app-radius-sm);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--app-shadow);
  animation: toast-in 0.3s ease;
  pointer-events: auto;
}
.app-toast-success { background: #fff; color: var(--app-success); border-left: 3px solid var(--app-success); }
.app-toast-danger { background: #fff; color: var(--app-danger); border-left: 3px solid var(--app-danger); }
.app-toast-warning { background: #fff; color: var(--app-warning); border-left: 3px solid var(--app-warning); }
.app-toast-info { background: #fff; color: var(--app-primary); border-left: 3px solid var(--app-primary); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Auth pages */
.app-auth-page {
  min-height: calc(100vh - var(--app-header-h));
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 24px 0 48px;
}
.app-auth-hero {
  text-align: center;
  margin-bottom: 32px;
}
.app-auth-logo {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  border-radius: 18px;
  background: linear-gradient(135deg, #1677ff, #0958d9);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  color: #fff;
  box-shadow: 0 8px 24px rgba(22, 119, 255, 0.3);
}
.app-auth-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.app-auth-subtitle {
  font-size: 14px;
  color: var(--app-text-secondary);
  margin-top: 6px;
}

/* Dropdown menu override */
.app-dropdown-menu {
  border: none;
  border-radius: var(--app-radius-sm);
  box-shadow: var(--app-shadow);
  padding: 6px;
  min-width: 160px;
  background: var(--app-surface);
  list-style: none;
  margin: 0;
}
.app-dropdown-item {
  border-radius: var(--app-radius-xs);
  padding: 10px 12px;
  font-size: 14px;
  color: var(--app-text);
  text-decoration: none;
}
.app-dropdown-item:hover,
.app-dropdown-item:focus {
  background: var(--app-bg);
  color: var(--app-text);
}
.app-dropdown-item.text-danger {
  color: var(--app-danger);
}
.app-dropdown-item.text-danger:hover,
.app-dropdown-item.text-danger:focus {
  background: var(--app-danger-light);
  color: var(--app-danger);
}

/* User card list (admin) */
.app-user-card {
  padding: 14px 16px;
  border-bottom: 0.5px solid var(--app-border);
}
.app-user-card:last-child { border-bottom: none; }
.app-user-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.app-user-card-name { font-weight: 600; font-size: 15px; }
.app-user-card-meta { font-size: 12px; color: var(--app-text-secondary); }

/* Sticky add bar */
.app-sticky-bar {
  position: sticky;
  top: calc(var(--app-header-h) + 8px);
  z-index: 50;
  margin-bottom: 16px;
}

/* Override bootstrap remnants */
.card { border: none; background: transparent; box-shadow: none; }
.btn-check:checked + .btn { box-shadow: none; }

/* Minimal utilities (replacing Bootstrap grid helpers) */
.d-flex { display: flex; }
.d-grid { display: grid; }
.d-inline { display: inline; }
.flex-wrap { flex-wrap: wrap; }
.flex-fill { flex: 1 1 auto; }
.flex-grow-1 { flex-grow: 1; }
.flex-shrink-0 { flex-shrink: 0; }
.justify-content-between { justify-content: space-between; }
.align-items-start { align-items: flex-start; }
.align-items-center { align-items: center; }
.text-end { text-align: right; }
.text-center { text-align: center; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.pt-3 { padding-top: 12px; }
.m-0 { margin: 0; }
.min-w-0 { min-width: 0; }
.fw-semibold { font-weight: 600; }

/* Bootstrap dropdown (JS dependency) */
.dropdown { position: relative; }
.dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  z-index: 1000;
  display: none;
  min-width: 10rem;
  margin-top: 6px;
  background: var(--app-surface);
  border-radius: var(--app-radius-sm);
  box-shadow: var(--app-shadow);
  padding: 6px;
  list-style: none;
  margin-left: 0;
}
.dropdown-menu-end {
  right: 0;
  left: auto;
}
.dropdown-menu.show { display: block; }
.dropdown-item {
  display: block;
  width: 100%;
  border: none;
  background: transparent;
  text-align: left;
  cursor: pointer;
  color: var(--app-text);
  font-size: 14px;
  padding: 10px 12px;
  border-radius: var(--app-radius-xs);
  text-decoration: none;
}
.dropdown-item:hover,
.dropdown-item:focus {
  background: var(--app-bg);
  color: var(--app-text);
}
.dropdown-divider {
  height: 0;
  margin: 6px 0;
  border-top: 0.5px solid var(--app-border);
}
.dropdown-toggle::after {
  display: inline-block;
  margin-left: 4px;
  vertical-align: 0.15em;
  content: "";
  border-top: 0.3em solid;
  border-right: 0.3em solid transparent;
  border-left: 0.3em solid transparent;
}

/* Notifications */
.app-notification-item {
  padding: 14px 16px;
  border-bottom: 0.5px solid var(--app-border);
}
.app-notification-item:last-child { border-bottom: none; }
.app-notification-item.is-unread { background: rgba(22, 119, 255, 0.03); }
.app-notification-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--app-primary);
  flex-shrink: 0;
}

/* Invite modal */
.app-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(29, 33, 41, 0.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
  padding-bottom: calc(16px + var(--app-safe-bottom));
}
.app-modal-overlay.is-hidden { display: none; }
.app-modal {
  width: 100%;
  max-width: 448px;
  background: var(--app-surface);
  border-radius: 20px 20px 16px 16px;
  padding: 24px 20px 20px;
  box-shadow: var(--app-shadow);
  animation: modal-up 0.3s ease;
}
.app-modal-title {
  font-size: 18px;
  font-weight: 700;
  text-align: center;
}
.app-modal-desc {
  font-size: 14px;
  color: var(--app-text-secondary);
  text-align: center;
  margin-top: 8px;
  line-height: 1.6;
}
.app-invite-project-name {
  font-size: 18px;
  font-weight: 700;
  color: var(--app-primary);
  margin-top: 8px;
}
.app-invite-banner {
  border: 1.5px solid var(--app-primary-ring);
  background: linear-gradient(180deg, rgba(22,119,255,0.06) 0%, #fff 100%);
}

@keyframes modal-up {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Bottom sheet (action dialogs) */
.app-sheet-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(29, 33, 41, 0.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
  padding-bottom: calc(16px + var(--app-safe-bottom));
}
.app-sheet-overlay.is-hidden { display: none; }
.app-sheet {
  width: 100%;
  max-width: 448px;
  max-height: min(85vh, 640px);
  background: var(--app-surface);
  border-radius: 20px 20px 16px 16px;
  box-shadow: var(--app-shadow);
  animation: modal-up 0.3s ease;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.app-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px 12px;
  border-bottom: 0.5px solid var(--app-border);
  flex-shrink: 0;
}
.app-sheet-title {
  font-size: 17px;
  font-weight: 700;
}
.app-sheet-close {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: var(--app-bg);
  color: var(--app-text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
.app-sheet-close:active { background: var(--app-primary-light); }
.app-sheet-body {
  padding: 16px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.app-sheet-divider {
  font-size: 13px;
  font-weight: 500;
  color: var(--app-text-secondary);
  margin: 20px 0 12px;
  padding-top: 16px;
  border-top: 0.5px solid var(--app-border);
}
.app-link-item {
  padding: 12px 0;
  border-bottom: 0.5px solid var(--app-border);
}
.app-link-item:last-child { border-bottom: none; padding-bottom: 0; }
.app-link-text {
  font-size: 12px;
  line-height: 1.5;
  word-break: break-all;
  padding: 10px 12px;
  border-radius: var(--app-radius-xs);
  background: var(--app-bg);
  color: var(--app-text-secondary);
}

/* Calculator keyboard */
.app-calc-field { position: relative; }
.app-calc-input {
  cursor: pointer;
  caret-color: transparent;
  font-size: 20px;
  font-weight: 600;
  text-align: right;
  letter-spacing: 0.02em;
}
.app-calc-input:focus {
  border-color: var(--app-primary);
  background: var(--app-surface);
  box-shadow: 0 0 0 3px var(--app-primary-ring);
}
.app-calc-preview {
  min-height: 20px;
  margin-top: 6px;
  text-align: right;
  font-size: 13px;
  color: var(--app-text-secondary);
  font-variant-numeric: tabular-nums;
}
.app-calc-keyboard {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 250;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 0.5px solid var(--app-border);
  padding: 8px 8px calc(8px + var(--app-safe-bottom));
  transform: translateY(100%);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 -4px 24px rgba(29, 33, 41, 0.08);
}
.app-calc-keyboard.is-open { transform: translateY(0); }
.app-calc-keyboard-inner {
  max-width: 480px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.app-calc-key {
  height: 48px;
  border: none;
  border-radius: 12px;
  background: var(--app-bg);
  color: var(--app-text);
  font-size: 18px;
  font-weight: 500;
  cursor: pointer;
  transition: transform 0.1s, background 0.1s;
  -webkit-tap-highlight-color: transparent;
}
.app-calc-key:active { transform: scale(0.96); background: var(--app-border); }
.app-calc-key-num { background: var(--app-surface); box-shadow: var(--app-shadow-sm); }
.app-calc-key-op {
  background: rgba(22, 119, 255, 0.08);
  color: var(--app-primary);
  font-size: 20px;
}
.app-calc-key-fn { color: var(--app-text-secondary); font-size: 15px; }
.app-calc-key-eq {
  background: var(--app-primary);
  color: #fff;
  font-size: 20px;
}
.app-calc-key-eq:active { background: var(--app-primary-hover); }
.app-calc-key-done {
  grid-column: span 2;
  background: var(--app-success-light);
  color: var(--app-success);
  font-size: 15px;
  font-weight: 600;
}
.app-calc-key-wide { grid-column: span 2; }

/* Cost entry page */
.cost-entry-body {
  background: var(--app-bg);
}

.app-fullscreen-main {
  max-width: 480px;
  width: 100%;
  margin: 0 auto;
  padding: 0;
  min-height: 100dvh;
}

.cost-entry-page {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--app-bg);
  width: 100%;
}

.cost-entry-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 0.5px solid var(--app-border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.cost-entry-cancel {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  text-decoration: none;
  color: var(--app-primary);
  font-size: 15px;
  flex-shrink: 0;
}

.cost-entry-title {
  font-size: 17px;
  font-weight: 600;
  text-align: center;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cost-entry-header-spacer {
  width: 52px;
  flex-shrink: 0;
}

.cost-entry-tabs-wrap {
  padding: 12px 16px 0;
}

.cost-entry-swipe-zone,
.app-tab-swipe-zone,
.app-chart-swipe-zone {
  touch-action: pan-y pinch-zoom;
}

.is-swipe-touching {
  touch-action: none;
}

.cost-entry-swipe-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

[data-swipe-panel] {
  overflow: hidden;
  touch-action: pan-y pinch-zoom;
}

.app-swipe-slider {
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  transform: translate3d(0, 0, 0);
}

.app-swipe-slider.is-dragging {
  will-change: transform;
}

.cost-entry-segment .app-segment-item {
  border: none;
  cursor: pointer;
  font-family: inherit;
}

.cost-entry-segment .app-segment-item.active {
  color: var(--app-primary);
}

.cost-type-section {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px 16px;
  min-height: 0;
}

.cost-type-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px 8px;
  background: var(--app-surface);
  border-radius: var(--app-radius);
  box-shadow: var(--app-shadow-sm);
  padding: 16px 12px;
}

.cost-type-item {
  border: none;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 0;
  min-width: 0;
}

.cost-type-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 1px solid var(--app-border);
  background: var(--app-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--app-text-secondary);
  font-size: 20px;
  transition: all var(--app-transition);
}

.cost-type-label {
  font-size: 11px;
  color: var(--app-text-secondary);
  max-width: 100%;
  text-align: center;
}

.cost-type-item.is-active .cost-type-icon {
  background: var(--app-primary-light);
  border-color: var(--app-primary);
  color: var(--app-primary);
  box-shadow: 0 0 0 3px var(--app-primary-ring);
}

.cost-type-item.is-active .cost-type-label {
  color: var(--app-primary);
  font-weight: 600;
}

.cost-entry-form {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}

.cost-entry-panel {
  background: var(--app-surface);
  border-radius: var(--app-radius) var(--app-radius) 0 0;
  box-shadow: 0 -4px 20px rgba(29, 33, 41, 0.06);
  padding-bottom: var(--app-safe-bottom);
}

.cost-value-display {
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: 6px;
  padding: 14px 16px 6px;
  min-height: 44px;
}

.cost-amount-display {
  padding: 0;
  text-align: right;
  font-size: 32px;
  font-weight: 700;
  line-height: 1.1;
  color: var(--app-text);
}

.cost-unit-label {
  font-size: 16px;
  font-weight: 500;
  color: var(--app-text-secondary);
  flex-shrink: 0;
  padding-bottom: 2px;
}

.cost-note-row {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 0 12px 10px;
  padding: 10px 12px;
  background: var(--app-bg);
  border-radius: var(--app-radius-sm);
}

.cost-note-label {
  font-size: 14px;
  color: var(--app-text-secondary);
  flex-shrink: 0;
}

.cost-note-input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 14px;
  color: var(--app-text);
  outline: none;
  min-width: 0;
}

.cost-note-input::placeholder { color: var(--app-text-tertiary); }

.cost-input-area {
  position: relative;
  min-height: 268px;
}

.cost-keyboard {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 0 8px 8px;
  background: var(--app-surface);
}

.cost-keyboard.is-hidden {
  display: none;
}

.cost-key {
  min-height: 46px;
  border: none;
  border-radius: var(--app-radius-xs);
  background: var(--app-bg);
  font-size: 20px;
  font-weight: 500;
  color: var(--app-text);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--app-transition), transform 0.1s;
}

.cost-key:active {
  transform: scale(0.97);
  background: var(--app-border);
}

.cost-key-num {
  background: var(--app-surface);
  box-shadow: var(--app-shadow-sm);
  font-size: 22px;
}

.cost-key-op {
  background: var(--app-primary-light);
  color: var(--app-primary);
  font-size: 22px;
}

.cost-key-fn {
  font-size: 16px;
  color: var(--app-text-secondary);
}

.cost-key-date {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 11px;
  line-height: 1.2;
  color: var(--app-text-secondary);
  background: var(--app-bg);
}

.cost-key-date.is-active {
  background: var(--app-primary-light);
  color: var(--app-primary);
  box-shadow: inset 0 0 0 1.5px var(--app-primary);
}

.cost-key-date.is-active i { color: var(--app-primary); }

.cost-key-date i { font-size: 14px; }

.cost-key-eq {
  background: var(--app-primary-light);
  color: var(--app-primary);
  font-size: 22px;
  font-weight: 700;
}

.cost-key-done {
  background: var(--app-primary);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
}

.cost-key-done:active {
  background: var(--app-primary-hover);
}

/* Inline date picker (replaces keyboard) */
.cost-date-panel {
  padding: 0 12px 8px;
  background: var(--app-surface);
  animation: cost-date-in 0.2s ease;
}

.cost-date-panel.is-hidden {
  display: none;
}

@keyframes cost-date-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.cost-date-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 0 10px;
}

.cost-date-month {
  flex: 1;
  text-align: center;
  font-size: 16px;
  font-weight: 600;
  color: var(--app-text);
}

.cost-date-nav {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: var(--app-bg);
  color: var(--app-text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--app-transition), color var(--app-transition);
}

.cost-date-nav:active {
  background: var(--app-primary-light);
  color: var(--app-primary);
}

.cost-date-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  margin-bottom: 6px;
}

.cost-date-weekdays span {
  text-align: center;
  font-size: 12px;
  color: var(--app-text-tertiary);
  padding: 4px 0;
}

.cost-date-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  min-height: 216px;
}

.cost-date-day {
  aspect-ratio: 1;
  min-height: 36px;
  border: none;
  border-radius: 50%;
  background: transparent;
  font-size: 15px;
  color: var(--app-text);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--app-transition), color var(--app-transition), box-shadow var(--app-transition);
}

.cost-date-day:active {
  transform: scale(0.94);
}

.cost-date-day.is-other {
  color: var(--app-text-tertiary);
}

.cost-date-day.is-today:not(.is-selected) {
  color: var(--app-primary);
  font-weight: 600;
  box-shadow: inset 0 0 0 1.5px var(--app-primary-ring);
}

.cost-date-day.is-selected {
  background: var(--app-primary);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(22, 119, 255, 0.35);
}

.cost-date-day:disabled {
  opacity: 0.35;
  cursor: default;
}

.cost-date-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 10px;
  border-top: 0.5px solid var(--app-border);
  margin-top: 4px;
}

.cost-date-chip {
  border: none;
  border-radius: 999px;
  padding: 8px 14px;
  background: var(--app-bg);
  color: var(--app-text-secondary);
  font-size: 13px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--app-transition), color var(--app-transition);
}

.cost-date-chip:active,
.cost-date-chip.is-active {
  background: var(--app-primary-light);
  color: var(--app-primary);
  font-weight: 600;
}

.cost-date-confirm {
  margin-left: auto;
  border: none;
  border-radius: var(--app-radius-sm);
  padding: 8px 12px;
  background: var(--app-primary-light);
  color: var(--app-primary);
  font-size: 13px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.cost-date-confirm:active {
  background: var(--app-primary);
  color: #fff;
}

@media (max-width: 360px) {
  .cost-type-icon {
    width: 46px;
    height: 46px;
    font-size: 18px;
  }

  .cost-type-label {
    font-size: 10px;
  }

  .cost-key {
    min-height: 42px;
    font-size: 18px;
  }

  .cost-amount-display {
    font-size: 28px;
  }
}

/* Me page (mini-program style) */
.app-me-hero {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px 16px;
  margin-bottom: 16px;
  background: linear-gradient(135deg, rgba(22, 119, 255, 0.12), rgba(22, 119, 255, 0.04));
  border-radius: var(--app-radius);
  box-shadow: var(--app-shadow-sm);
}

.app-me-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--app-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  flex-shrink: 0;
}

.app-me-name {
  font-size: 18px;
  font-weight: 600;
}

.app-me-username {
  font-size: 13px;
  color: var(--app-text-secondary);
  margin-top: 4px;
}

.app-menu-section {
  margin-bottom: 16px;
}

.app-menu-section-title {
  font-size: 13px;
  color: var(--app-text-secondary);
  padding: 0 4px 8px;
}

.app-cell-link {
  text-decoration: none;
  color: inherit;
}

.app-cell-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  flex-shrink: 0;
}

.app-cell-icon-blue { background: rgba(22, 119, 255, 0.12); color: var(--app-primary); }
.app-cell-icon-green { background: rgba(0, 181, 120, 0.12); color: #00b578; }
.app-cell-icon-orange { background: rgba(255, 125, 0, 0.12); color: #ff7d00; }
.app-cell-icon-purple { background: rgba(114, 46, 209, 0.12); color: #722ed1; }

.app-me-logout {
  color: var(--app-danger);
}

.app-me-footer {
  text-align: center;
  font-size: 12px;
  color: var(--app-text-tertiary);
  padding: 8px 0 16px;
}

.app-textarea {
  min-height: 120px;
  resize: vertical;
  line-height: 1.5;
  padding-top: 12px;
  padding-bottom: 12px;
}

.app-feedback-decision {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--app-border);
  cursor: pointer;
}

.app-feedback-decision input {
  width: 18px;
  height: 18px;
  accent-color: var(--app-primary);
}
