*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --primary: #6366f1;
  --primary-light: #818cf8;
  --primary-dark: #4f46e5;
  --primary-bg: #eef2ff;
  --shadow-color: 99, 102, 241;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --text: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --bg: #f8fafc;
  --card: #ffffff;
  --border: #e2e8f0;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 12px rgba(0,0,0,.04);
  --shadow-lg: 0 4px 20px rgba(var(--shadow-color), .15);
  --radius: 14px;
  --radius-sm: 10px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --nav-height: 64px;
}

[data-theme="pink"] {
  --primary: #ec4899;
  --primary-light: #f472b6;
  --primary-dark: #db2777;
  --primary-bg: #fdf2f8;
  --shadow-color: 236, 72, 153;
  --bg: #fef7fb;
}

[data-mode="dark"] {
  --text: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --bg: #0f172a;
  --card: #1e293b;
  --border: #334155;
  --primary-bg: rgba(99, 102, 241, .18);
  --shadow: 0 1px 3px rgba(0,0,0,.35), 0 4px 12px rgba(0,0,0,.25);
  --desktop-bg: #020617;
}

[data-mode="dark"][data-theme="pink"] {
  --primary-bg: rgba(236, 72, 153, .18);
  --bg: #1a0f18;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

.hidden {
  display: none !important;
}

button,
.nav-item,
.btn-icon,
.date-display,
.template-chip,
.cat-chip,
.tool-btn {
  touch-action: manipulation;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

/* Header */
.header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  padding: 16px 20px 20px;
  padding-top: max(16px, env(safe-area-inset-top));
  border-radius: 0 0 24px 24px;
  box-shadow: var(--shadow-lg);
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-theme {
  position: relative;
  overflow: hidden;
}

.theme-dot {
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,.6);
  transition: transform .3s, opacity .3s;
}

.theme-dot-purple {
  background: #818cf8;
  top: 8px;
  left: 7px;
}

.theme-dot-pink {
  background: #f472b6;
  bottom: 8px;
  right: 7px;
}

[data-theme="pink"] .theme-dot-purple {
  transform: scale(.85);
  opacity: .6;
}

[data-theme="pink"] .theme-dot-pink {
  transform: scale(1.15);
}

[data-theme="purple"] .theme-dot-purple,
:root:not([data-theme]) .theme-dot-purple {
  transform: scale(1.15);
}

[data-theme="purple"] .theme-dot-pink,
:root:not([data-theme]) .theme-dot-pink {
  transform: scale(.85);
  opacity: .6;
}

.title {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: .5px;
}

.btn-icon {
  width: 40px;
  height: 40px;
  border: none;
  background: rgba(255,255,255,.15);
  border-radius: 12px;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .2s, transform .15s;
  flex-shrink: 0;
}

.btn-icon svg {
  width: 20px;
  height: 20px;
}

.btn-icon:active {
  transform: scale(.92);
  background: rgba(255,255,255,.25);
}

.btn-icon.active-notify {
  background: rgba(255,255,255,.3);
}

.btn-panel {
  background: var(--bg) !important;
  color: var(--text) !important;
  border: 1px solid var(--border);
}

.date-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.date-display {
  flex: 1;
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.2);
  border-radius: var(--radius);
  padding: 10px 16px;
  color: #fff;
  cursor: pointer;
  text-align: center;
  transition: background .2s;
}

.date-display:active {
  background: rgba(255,255,255,.2);
}

.date-main {
  display: block;
  font-size: 1.1rem;
  font-weight: 600;
}

.date-sub {
  display: block;
  font-size: .8rem;
  opacity: .8;
  margin-top: 2px;
}

.btn-today {
  display: none;
  margin-top: 12px;
  width: 100%;
  padding: 8px;
  background: rgba(255,255,255,.15);
  border: 1px solid rgba(255,255,255,.25);
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: .85rem;
  cursor: pointer;
  transition: background .2s;
}

.btn-today.show {
  display: block;
}

.btn-today:active {
  background: rgba(255,255,255,.25);
}

/* Main */
.main {
  flex: 1;
  padding: 16px 16px calc(var(--nav-height) + var(--safe-bottom) + 16px);
  overflow-y: auto;
}

.panel {
  display: none;
}

.panel.active {
  display: block;
  animation: fadeIn .25s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Add box */
.add-box {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  background: var(--card);
  padding: 8px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.add-box-record {
  align-items: flex-start;
}

.add-main {
  flex: 1;
  min-width: 0;
}

.add-tools {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.tool-btn {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: 10px;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: color .2s, border-color .2s, background .2s;
}

.tool-btn svg {
  width: 18px;
  height: 18px;
}

.tool-btn:active,
.tool-btn.listening {
  color: var(--primary);
  border-color: var(--primary-light);
  background: var(--primary-bg);
}

.tool-btn.listening {
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .6; }
}

.category-filter {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 12px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.category-filter::-webkit-scrollbar {
  display: none;
}

.category-select {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  flex: 1;
}

.template-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.template-list {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  flex: 1;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: 2px;
}

.template-list::-webkit-scrollbar {
  display: none;
}

.template-chip {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 16px;
  font-size: .78rem;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  box-shadow: var(--shadow);
  transition: transform .15s, border-color .15s;
}

.template-chip:active {
  transform: scale(.96);
  border-color: var(--primary-light);
  background: var(--primary-bg);
}

.template-add-btn,
.template-manage-btn {
  border: 1px dashed var(--border);
  background: var(--card);
  color: var(--text-secondary);
  border-radius: 16px;
  font-size: .75rem;
  cursor: pointer;
  flex-shrink: 0;
  height: 32px;
}

.template-add-btn {
  width: 32px;
  font-size: 1.1rem;
  line-height: 1;
}

.template-manage-btn {
  padding: 0 10px;
}

.template-manage-list {
  list-style: none;
  margin-top: 16px;
  max-height: 240px;
  overflow-y: auto;
}

.template-manage-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.template-manage-item:last-child {
  border-bottom: none;
}

.template-manage-text {
  flex: 1;
  font-size: .9rem;
  min-width: 0;
}

.template-manage-tag {
  font-size: .68rem;
  padding: 2px 7px;
  border-radius: 8px;
  color: #fff;
  background: var(--cat-color, var(--primary));
  flex-shrink: 0;
}

.cat-chip {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-secondary);
  padding: 5px 10px;
  border-radius: 16px;
  font-size: .75rem;
  cursor: pointer;
  white-space: nowrap;
  transition: all .2s;
  flex-shrink: 0;
}

.cat-chip.active {
  color: #fff;
  border-color: transparent;
  background: var(--cat-color, var(--primary));
}

.cat-chip.tag-only {
  font-size: .72rem;
  padding: 4px 8px;
}

.pending-images {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.pending-images.hidden {
  display: none;
}

.thumb-wrap {
  position: relative;
  width: 64px;
  height: 64px;
}

.thumb-wrap img,
.record-thumb {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid var(--border);
}

.thumb-remove {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  border: none;
  background: var(--danger);
  color: #fff;
  border-radius: 50%;
  font-size: .85rem;
  line-height: 1;
  cursor: pointer;
}

.input {
  flex: 1;
  border: none;
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: .95rem;
  color: var(--text);
  outline: none;
  min-width: 0;
}

.input:focus {
  box-shadow: 0 0 0 2px var(--primary-light);
}

.input-time {
  width: 90px;
  border: none;
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 12px 8px;
  font-size: .9rem;
  color: var(--text);
  outline: none;
  flex-shrink: 0;
}

.btn-add {
  width: 44px;
  height: 44px;
  border: none;
  background: var(--primary);
  border-radius: var(--radius-sm);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .2s, transform .15s;
}

.btn-add svg {
  width: 22px;
  height: 22px;
}

.btn-add:active {
  transform: scale(.92);
  background: var(--primary-dark);
}

/* Stats */
.stats-bar {
  font-size: .8rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
  padding: 0 4px;
}

/* Record list */
.record-list {
  list-style: none;
}

.swipe-item {
  position: relative;
  margin-bottom: 10px;
  border-radius: var(--radius);
  overflow: hidden;
}

.swipe-bg {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  font-size: .85rem;
  font-weight: 600;
}

.swipe-hint-left {
  color: #fff;
  background: var(--danger);
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.swipe-hint-right {
  color: #fff;
  background: var(--success);
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.swipe-content {
  position: relative;
  background: var(--card);
  transition: transform .2s ease;
  will-change: transform;
}

.swipe-content.dragging {
  transition: none;
}

.swipe-item .record-item,
.swipe-item .bill-item {
  margin-bottom: 0;
  box-shadow: none;
  border-radius: 0;
}

.swipe-hint-text {
  font-size: .72rem;
  color: var(--text-muted);
  text-align: center;
  margin: -6px 0 10px;
}

.record-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--card);
  padding: 14px 12px;
  border-radius: var(--radius);
  margin-bottom: 10px;
  box-shadow: var(--shadow);
  animation: slideIn .3s ease;
  position: relative;
}

.record-item.done {
  opacity: .75;
}

.record-item.done .record-content {
  text-decoration: line-through;
  color: var(--text-muted);
}

.record-check {
  width: 24px;
  height: 24px;
  border: 2px solid var(--border);
  background: var(--bg);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
  transition: all .2s;
  color: transparent;
}

.record-check svg {
  width: 14px;
  height: 14px;
}

.record-check.checked {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}

.record-body {
  flex: 1;
  min-width: 0;
}

.record-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.record-tag {
  font-size: .68rem;
  padding: 2px 7px;
  border-radius: 10px;
  color: #fff;
  background: var(--cat-color, var(--primary));
  font-weight: 600;
}

.record-images {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.record-images .record-thumb {
  width: 56px;
  height: 56px;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(-12px); }
  to { opacity: 1; transform: translateX(0); }
}

.record-time {
  font-size: .75rem;
  color: var(--primary);
  font-weight: 600;
  background: var(--primary-bg);
  padding: 4px 8px;
  border-radius: 6px;
  white-space: nowrap;
  flex-shrink: 0;
  margin-top: 2px;
}

.record-content {
  flex: 1;
  font-size: .95rem;
  word-break: break-word;
  line-height: 1.6;
}

.record-item.pinned {
  border-left: 3px solid var(--primary);
}

.record-actions {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex-shrink: 0;
}

.record-edit,
.record-link,
.record-pin,
.record-delete {
  width: 30px;
  height: 30px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: color .2s, background .2s;
}

.record-edit svg,
.record-link svg,
.record-pin svg,
.record-delete svg {
  width: 16px;
  height: 16px;
}

.record-pin.active {
  color: var(--primary);
}

.record-edit:active,
.record-link:active,
.record-pin:active {
  background: var(--primary-bg);
  color: var(--primary);
}

.record-delete:active {
  color: var(--danger);
  background: var(--danger-bg, #fef2f2);
}

[data-mode="dark"] .record-delete:active {
  --danger-bg: rgba(239, 68, 68, .15);
}

/* Reminder form */
.reminder-form {
  background: var(--card);
  padding: 14px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.form-row {
  display: flex;
  gap: 8px;
}

.input-date {
  flex: 1;
  min-width: 0;
}

.input-time-full {
  width: 120px;
  flex-shrink: 0;
  border: none;
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 12px 10px;
  font-size: .9rem;
  color: var(--text);
  outline: none;
}

.select-input {
  flex: 1;
  min-width: 0;
  appearance: none;
  background: var(--bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center;
  padding-right: 28px;
}

.link-record-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .85rem;
  color: var(--text-secondary);
  cursor: pointer;
}

.link-record-label input {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}

.link-date-row {
  align-items: center;
}

.link-date-row.hidden {
  display: none;
}

.form-label {
  font-size: .82rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.btn-submit {
  width: 100%;
  padding: 12px;
  border: none;
  background: var(--primary);
  color: #fff;
  border-radius: var(--radius-sm);
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-submit:active {
  background: var(--primary-dark);
}

.reminder-form .input-date.hidden {
  display: none;
}

.reminder-hint {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--hint-bg, #fffbeb);
  border: 1px solid var(--hint-border, #fde68a);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: .82rem;
  color: var(--hint-text, #92400e);
  margin-bottom: 16px;
}

[data-mode="dark"] .reminder-hint {
  --hint-bg: rgba(245, 158, 11, .12);
  --hint-border: rgba(245, 158, 11, .3);
  --hint-text: #fbbf24;
}

.reminder-hint.hidden {
  display: none;
}

.hint-icon {
  font-size: 1rem;
}

.reminder-list {
  list-style: none;
}

.reminder-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--card);
  padding: 14px 16px;
  border-radius: var(--radius);
  margin-bottom: 10px;
  box-shadow: var(--shadow);
  animation: slideIn .3s ease;
}

.reminder-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.reminder-badge {
  font-size: .68rem;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--primary-bg);
  color: var(--primary);
  font-weight: 600;
}

.reminder-badge.link {
  background: var(--bg);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.reminder-actions {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-shrink: 0;
}

.reminder-goto {
  width: 30px;
  height: 30px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.reminder-goto svg {
  width: 16px;
  height: 16px;
}

.reminder-goto:active {
  background: var(--primary-bg);
  color: var(--primary);
}

.reminder-item.disabled {
  opacity: .5;
}

.reminder-toggle {
  width: 44px;
  height: 26px;
  border-radius: 13px;
  background: var(--border);
  border: none;
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  transition: background .25s;
}

.reminder-toggle::after {
  content: '';
  position: absolute;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  top: 2px;
  left: 2px;
  transition: transform .25s;
  box-shadow: 0 1px 3px rgba(0,0,0,.15);
}

.reminder-toggle.on {
  background: var(--primary);
}

.reminder-toggle.on::after {
  transform: translateX(18px);
}

.reminder-info {
  flex: 1;
  min-width: 0;
}

.reminder-text {
  font-size: .95rem;
  word-break: break-word;
}

.reminder-time-label {
  font-size: .78rem;
  color: var(--primary);
  font-weight: 600;
  margin-top: 2px;
}

.reminder-repeat {
  font-size: .72rem;
  color: var(--text-muted);
}

/* Calendar */
.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.calendar-title {
  font-size: 1.05rem;
  font-weight: 600;
}

.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: .78rem;
  color: var(--text-muted);
  margin-bottom: 8px;
  font-weight: 500;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.cal-day {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  border-radius: 12px;
  font-size: .88rem;
  color: var(--text);
  cursor: pointer;
  position: relative;
  transition: background .15s;
  gap: 2px;
}

.cal-day:active {
  background: var(--primary-bg);
}

.cal-day.other-month {
  color: var(--text-muted);
  opacity: .5;
}

.cal-day.today {
  background: var(--primary);
  color: #fff;
  font-weight: 700;
}

.cal-day.selected:not(.today) {
  background: var(--primary-bg);
  color: var(--primary);
  font-weight: 600;
}

.cal-day .dot-indicator {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--primary);
}

.cal-day.today .dot-indicator {
  background: #fff;
}

.calendar-legend {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin-top: 16px;
  font-size: .78rem;
  color: var(--text-secondary);
}

.calendar-legend .dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
}

.dot.has-record {
  background: var(--primary);
}

.dot.today {
  background: var(--primary);
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}

.empty-state.hidden {
  display: none;
}

.empty-icon {
  font-size: 3rem;
  margin-bottom: 12px;
}

.empty-state p {
  font-size: 1rem;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.empty-state span {
  font-size: .85rem;
}

/* Search */
.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card);
  padding: 8px 14px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.search-icon {
  width: 20px;
  height: 20px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.search-input {
  background: transparent;
  padding: 10px 0;
}

.search-input:focus {
  box-shadow: none;
}

.search-clear {
  width: 28px;
  height: 28px;
  border: none;
  background: var(--bg);
  border-radius: 50%;
  color: var(--text-muted);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}

.search-clear.hidden {
  display: none;
}

.search-list {
  list-style: none;
}

.search-item {
  background: var(--card);
  padding: 14px 16px;
  border-radius: var(--radius);
  margin-bottom: 10px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform .15s, box-shadow .15s;
}

.search-item:active {
  transform: scale(.98);
}

.search-item-date {
  font-size: .78rem;
  color: var(--primary);
  font-weight: 600;
  margin-bottom: 4px;
}

.search-item-content {
  font-size: .92rem;
  line-height: 1.5;
  word-break: break-word;
}

.search-item-content mark {
  background: var(--primary-bg);
  color: var(--primary);
  border-radius: 3px;
  padding: 0 2px;
}

.search-item-meta {
  font-size: .72rem;
  color: var(--text-muted);
  margin-top: 6px;
}

.search-filter-toggle {
  border: none;
  background: var(--bg);
  color: var(--primary);
  font-size: .78rem;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
  flex-shrink: 0;
}

.search-filter-toggle.active {
  background: var(--primary-bg);
}

.search-filters {
  background: var(--card);
  border-radius: var(--radius);
  padding: 12px;
  margin: -8px 0 16px;
  box-shadow: var(--shadow);
}

.search-filters.hidden {
  display: none;
}

.search-filter-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.search-filter-row .select-input,
.search-filter-row .input-date {
  flex: 1;
  min-width: 0;
  font-size: .82rem;
  padding: 8px 10px;
}

.search-date-row {
  align-items: center;
}

.search-date-sep {
  font-size: .82rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.search-reset-btn {
  margin-bottom: 0;
}

.record-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.record-link-chip {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-secondary);
  font-size: .72rem;
  padding: 4px 8px;
  border-radius: 999px;
  cursor: pointer;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.record-link-chip:active {
  background: var(--primary-bg);
  color: var(--primary);
  border-color: var(--primary);
}

.record-item.highlight-flash {
  animation: recordFlash .8s ease;
}

@keyframes recordFlash {
  0%, 100% { box-shadow: var(--shadow); }
  50% { box-shadow: 0 0 0 2px var(--primary); }
}

.record-link {
  color: var(--text-muted);
}

.record-link.active {
  color: var(--primary);
}

.edit-links-section {
  margin: 12px 0;
}

.edit-links-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.btn-link-action {
  border: none;
  background: transparent;
  color: var(--primary);
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 0;
}

.edit-links-list:empty::before {
  content: '暂无关联记录';
  display: block;
  font-size: .78rem;
  color: var(--text-muted);
}

.record-link-chip .link-remove {
  margin-left: 4px;
  color: var(--text-muted);
  font-weight: 700;
}

.link-search-box {
  margin-bottom: 12px;
}

.link-pick-list {
  list-style: none;
  max-height: 50vh;
  overflow-y: auto;
}

.link-pick-item {
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 8px;
  cursor: pointer;
}

.link-pick-item:active {
  background: var(--primary-bg);
}

.link-pick-date {
  font-size: .72rem;
  color: var(--primary);
  font-weight: 600;
  margin-bottom: 4px;
}

.link-pick-content {
  font-size: .88rem;
  line-height: 1.4;
}

.link-pick-meta {
  font-size: .7rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.link-pick-empty {
  text-align: center;
  color: var(--text-muted);
  font-size: .85rem;
  padding: 24px 0;
}

/* Install banner */
.install-banner {
  position: fixed;
  bottom: calc(var(--nav-height) + var(--safe-bottom) + 12px);
  left: 16px;
  right: 16px;
  width: auto;
  max-width: 448px;
  margin-left: auto;
  margin-right: auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow-lg);
  z-index: 150;
  animation: slideUp .3s ease;
}

.install-banner.hidden {
  display: none;
}

#backupRemindBanner {
  border-color: #fbbf24;
  background: var(--card);
}

#backupRemindBanner .install-text strong {
  color: #d97706;
}

[data-mode="dark"] #backupRemindBanner .install-text strong {
  color: #fbbf24;
}

.backup-status {
  font-size: .82rem;
  color: var(--text-secondary);
  margin: -4px 0 12px;
}

.backup-status.warn {
  color: #d97706;
  font-weight: 600;
}

[data-mode="dark"] .backup-status.warn {
  color: #fbbf24;
}

.backup-remind-label {
  margin-bottom: 10px;
}

.backup-remind-select {
  width: 100%;
  margin-bottom: 12px;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.install-text {
  flex: 1;
  min-width: 0;
}

.install-text strong {
  display: block;
  font-size: .9rem;
  color: var(--text);
}

.install-text span {
  font-size: .78rem;
  color: var(--text-secondary);
}

.install-btn {
  border: none;
  background: var(--primary);
  color: #fff;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
}

.install-close {
  width: 28px;
  height: 28px;
  border: none;
  background: var(--bg);
  color: var(--text-muted);
  border-radius: 50%;
  font-size: 1.1rem;
  cursor: pointer;
  flex-shrink: 0;
  line-height: 1;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 300;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
  padding-bottom: calc(16px + var(--safe-bottom));
}

.modal-overlay.hidden {
  display: none;
}

.modal {
  width: 100%;
  max-width: 480px;
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  animation: slideUp .25s ease;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 0;
}

.modal-header h3 {
  font-size: 1rem;
}

.modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: var(--bg);
  color: var(--text-muted);
  border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer;
  line-height: 1;
}

.modal-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-textarea {
  resize: none;
  width: 100%;
  min-height: 80px;
}

.modal-footer {
  display: flex;
  gap: 10px;
  padding: 0 16px 16px;
}

.btn-primary,
.btn-secondary {
  flex: 1;
  padding: 12px;
  border-radius: var(--radius-sm);
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-secondary {
  background: var(--bg);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

/* Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.9);
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.lightbox.hidden {
  display: none;
}

.lightbox img {
  max-width: 100%;
  max-height: 90vh;
  max-height: 90dvh;
  border-radius: 8px;
}

.lightbox-close {
  position: absolute;
  top: max(16px, env(safe-area-inset-top));
  right: 16px;
  width: 40px;
  height: 40px;
  border: none;
  background: rgba(255,255,255,.15);
  color: #fff;
  border-radius: 50%;
  font-size: 1.4rem;
  cursor: pointer;
  line-height: 1;
}

/* Settings */
.settings-card {
  background: var(--card);
  padding: 16px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}

.settings-title {
  font-size: 1rem;
  margin-bottom: 8px;
}

.settings-desc {
  font-size: .85rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 14px;
}

.settings-stats {
  font-size: .82rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.settings-steps {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.step-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: .85rem;
  color: var(--text);
  line-height: 1.5;
}

.step-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: .75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.settings-card .btn-submit {
  margin-bottom: 10px;
}

.btn-secondary-full {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 8px;
}

.btn-secondary-full:last-child {
  margin-bottom: 0;
}

/* Week summary */
.week-summary {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.week-stat-card {
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 12px;
  text-align: center;
}

.week-stat-card.full {
  grid-column: 1 / -1;
}

.week-stat-label {
  font-size: .75rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.week-stat-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary);
}

.week-stat-value.expense {
  color: #ef4444;
}

.week-stat-value.income {
  color: #10b981;
}

/* Month report */
.month-report-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.month-report-head .settings-title {
  margin-bottom: 0;
}

.month-nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.month-nav-btn {
  width: 32px;
  height: 32px;
}

.month-nav-btn svg {
  width: 18px;
  height: 18px;
}

.month-nav-label {
  font-size: .85rem;
  font-weight: 600;
  color: var(--text-secondary);
  min-width: 72px;
  text-align: center;
}

.month-summary {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.month-stat-card {
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 12px;
  text-align: center;
}

.month-stat-card.full {
  grid-column: 1 / -1;
}

.month-stat-label {
  font-size: .75rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.month-stat-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary);
}

.month-stat-value.expense {
  color: #ef4444;
}

.month-stat-value.income {
  color: #10b981;
}

.daily-chart-full {
  overflow-x: auto;
  padding-bottom: 4px;
}

.daily-chart-full .daily-bar-item {
  min-width: 8px;
  flex: 1;
}

.daily-bar.expense {
  background: #ef4444;
}

.daily-bar.record {
  background: var(--primary);
}

/* Font size */
.font-size-toggle {
  display: flex;
  gap: 8px;
  background: var(--bg);
  padding: 4px;
  border-radius: var(--radius-sm);
}

.font-size-btn {
  flex: 1;
  border: none;
  background: transparent;
  padding: 10px;
  border-radius: 8px;
  font-size: .85rem;
  color: var(--text-secondary);
  cursor: pointer;
  font-weight: 600;
}

.font-size-btn.active {
  background: var(--card);
  color: var(--primary);
  box-shadow: var(--shadow);
}

html[data-font="large"] {
  font-size: 18px;
}

html[data-font="xlarge"] {
  font-size: 20px;
}

/* Bottom nav */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  width: 100%;
  max-width: 480px;
  margin-left: auto;
  margin-right: auto;
  height: calc(var(--nav-height) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--card);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 100;
  box-shadow: 0 -2px 12px rgba(0,0,0,.06);
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: .65rem;
  cursor: pointer;
  transition: color .2s;
  padding: 8px 0;
  min-width: 0;
}

.nav-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.nav-item svg {
  width: 22px;
  height: 22px;
}

.nav-item.active {
  color: var(--primary);
}

/* Bills */
.bill-overview {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  border-radius: var(--radius);
  padding: 16px;
  color: #fff;
  margin-bottom: 14px;
  box-shadow: var(--shadow-lg);
}

.bill-overview-title {
  font-size: .85rem;
  opacity: .9;
  margin-bottom: 12px;
}

.bill-overview-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.bill-stat {
  text-align: center;
  background: rgba(255,255,255,.12);
  border-radius: var(--radius-sm);
  padding: 10px 4px;
}

.bill-stat-label {
  display: block;
  font-size: .68rem;
  opacity: .85;
  margin-bottom: 4px;
}

.bill-stat-value {
  display: block;
  font-size: .82rem;
  font-weight: 700;
  word-break: break-all;
}

.bill-form {
  background: var(--card);
  padding: 14px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bill-type-toggle {
  display: flex;
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 4px;
  gap: 4px;
}

.bill-type-btn {
  flex: 1;
  border: none;
  background: transparent;
  padding: 8px;
  border-radius: 8px;
  font-size: .88rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all .2s;
}

.bill-type-btn.active[data-type="expense"] {
  background: #fef2f2;
  color: #ef4444;
}

.bill-type-btn.active[data-type="income"] {
  background: #ecfdf5;
  color: #10b981;
}

[data-mode="dark"] .bill-type-btn.active[data-type="expense"] {
  background: rgba(239, 68, 68, .2);
}

[data-mode="dark"] .bill-type-btn.active[data-type="income"] {
  background: rgba(16, 185, 129, .2);
}

.bill-amount-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
}

.bill-currency {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-muted);
}

.bill-amount-input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text);
  outline: none;
  min-width: 0;
}

.bill-amount-input::placeholder {
  color: var(--text-muted);
  font-weight: 400;
}

.bill-list {
  list-style: none;
}

.bill-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card);
  padding: 12px 12px 12px 14px;
  border-radius: var(--radius);
  margin-bottom: 10px;
  box-shadow: var(--shadow);
}

.bill-item .record-delete {
  flex-shrink: 0;
}

.bill-item-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.bill-item-icon.expense {
  background: #fef2f2;
}

.bill-item-icon.income {
  background: #ecfdf5;
}

[data-mode="dark"] .bill-item-icon.expense {
  background: rgba(239, 68, 68, .15);
}

[data-mode="dark"] .bill-item-icon.income {
  background: rgba(16, 185, 129, .15);
}

.bill-item-body {
  flex: 1;
  min-width: 0;
}

.bill-item-cat {
  font-size: .92rem;
  font-weight: 600;
}

.bill-item-note {
  font-size: .78rem;
  color: var(--text-muted);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bill-item-right {
  text-align: right;
  flex-shrink: 0;
}

.bill-item-amount {
  font-size: 1rem;
  font-weight: 700;
}

.bill-item-amount.expense {
  color: #ef4444;
}

.bill-item-amount.income {
  color: #10b981;
}

.bill-item-time {
  font-size: .72rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.bill-budget {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(255,255,255,.2);
}

.bill-budget.hidden {
  display: none;
}

.bill-budget-head {
  display: flex;
  justify-content: space-between;
  font-size: .75rem;
  margin-bottom: 8px;
  opacity: .95;
}

.bill-budget-bar {
  height: 6px;
  background: rgba(255,255,255,.2);
  border-radius: 3px;
  overflow: hidden;
}

.bill-budget-fill {
  height: 100%;
  background: #fff;
  border-radius: 3px;
  width: 0;
  transition: width .3s;
}

.bill-budget-fill.warn {
  background: #fde047;
}

.bill-budget-fill.over {
  background: #fca5a5;
}

.bill-budget-set {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.bill-budget-set .input {
  flex: 1;
  border: 1px solid var(--border);
  background: var(--card);
}

.btn-budget-save {
  border: none;
  background: var(--primary-bg);
  color: var(--primary);
  padding: 0 14px;
  border-radius: var(--radius-sm);
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  border: 1px solid var(--primary-light);
}

.bill-view-toggle {
  display: flex;
  background: var(--card);
  border-radius: var(--radius-sm);
  padding: 4px;
  gap: 4px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}

.bill-view-btn {
  flex: 1;
  border: none;
  background: transparent;
  padding: 8px;
  border-radius: 8px;
  font-size: .85rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
}

.bill-view-btn.active {
  background: var(--primary);
  color: #fff;
}

.bill-report.hidden {
  display: none;
}

.report-section {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}

.report-title {
  font-size: .9rem;
  margin-bottom: 12px;
  color: var(--text);
}

.report-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.report-row:last-child {
  margin-bottom: 0;
}

.report-row-label {
  width: 56px;
  font-size: .78rem;
  flex-shrink: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.report-row-bar-wrap {
  flex: 1;
  height: 8px;
  background: var(--bg);
  border-radius: 4px;
  overflow: hidden;
}

.report-row-bar {
  height: 100%;
  border-radius: 4px;
  background: var(--primary);
  min-width: 2px;
}

.report-row-val {
  width: 72px;
  text-align: right;
  font-size: .75rem;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.report-empty {
  font-size: .82rem;
  color: var(--text-muted);
  text-align: center;
  padding: 12px;
}

.daily-bar-item {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.daily-chart {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 100px;
  padding-top: 8px;
}

.daily-bar {
  width: 100%;
  background: var(--primary);
  border-radius: 4px 4px 0 0;
  min-height: 2px;
  opacity: .85;
}

.daily-bar-label {
  font-size: .62rem;
  color: var(--text-muted);
}

.bill-item-actions {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex-shrink: 0;
}

#editBillModal .bill-type-toggle {
  margin-bottom: 4px;
}

#editBillModal .bill-currency {
  font-size: 1.2rem;
}

#editBillModal .bill-amount-input {
  font-size: 1.4rem;
}

#billDetailView.hidden {
  display: none;
}

.nav-item:active {
  opacity: .7;
}

/* Hidden date picker */
.hidden-picker {
  position: fixed;
  opacity: 0;
  pointer-events: none;
  width: 0;
  height: 0;
}

/* Toast */
.toast {
  position: fixed;
  bottom: calc(var(--nav-height) + var(--safe-bottom) + 20px);
  left: 16px;
  right: 16px;
  width: auto;
  max-width: 90%;
  margin-left: auto;
  margin-right: auto;
  transform: translateY(20px);
  background: rgba(30,41,59,.88);
  color: #fff;
  padding: 10px 24px;
  border-radius: 24px;
  font-size: .88rem;
  z-index: 200;
  opacity: 0;
  transition: opacity .3s, transform .3s;
  pointer-events: none;
  white-space: nowrap;
  text-align: center;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* Shop / 店务表格 */
.shop-subtabs {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
  background: var(--card);
  padding: 4px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.shop-subtab {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: .78rem;
  padding: 8px 4px;
  border-radius: 8px;
  cursor: pointer;
  transition: background .2s, color .2s;
  white-space: nowrap;
}

.shop-subtab.active {
  background: var(--primary-bg);
  color: var(--primary);
  font-weight: 600;
}

.shop-form {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.shop-form-row {
  display: flex;
  gap: 8px;
}

.shop-form-row .input {
  flex: 1;
  min-width: 0;
}

.shop-amount-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding-left: 10px;
}

.shop-amount-wrap .bill-currency {
  color: var(--text-secondary);
  font-weight: 600;
}

.shop-amount-input {
  border: none !important;
  background: transparent !important;
  padding-left: 0 !important;
}

.shop-search-box {
  margin-bottom: 10px;
}

.shop-filter-chips {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.shop-filter-chip {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text-secondary);
  font-size: .78rem;
  padding: 6px 12px;
  border-radius: 20px;
  cursor: pointer;
}

.shop-filter-chip.active {
  border-color: var(--primary);
  background: var(--primary-bg);
  color: var(--primary);
  font-weight: 600;
}

.shop-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.shop-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  position: relative;
}

.shop-item-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.shop-item-customer {
  font-weight: 600;
  font-size: .95rem;
}

.shop-item-phone {
  font-size: .78rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.shop-item-badge {
  flex-shrink: 0;
  font-size: .7rem;
  padding: 3px 8px;
  border-radius: 10px;
  font-weight: 600;
}

.shop-item-badge.pending {
  background: #fef3c7;
  color: #b45309;
}

.shop-item-badge.done {
  background: #d1fae5;
  color: #047857;
}

.shop-item-badge.times {
  background: var(--primary-bg);
  color: var(--primary);
}

.shop-item-title {
  font-size: .88rem;
  color: var(--text);
  margin-bottom: 4px;
}

.shop-item-meta {
  font-size: .78rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.shop-item-note {
  font-size: .78rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.shop-item-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.shop-action-btn {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-secondary);
  font-size: .75rem;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
}

.shop-action-btn.primary {
  border-color: var(--primary);
  background: var(--primary-bg);
  color: var(--primary);
  font-weight: 600;
}

.shop-action-btn.danger {
  border-color: #fecaca;
  background: #fef2f2;
  color: var(--danger);
}

.shop-action-btn:active {
  transform: scale(.97);
}

.shop-view:not(.hidden) {
  display: block;
}

.auth-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.auth-tab {
  flex: 1;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-secondary);
  padding: 8px;
  border-radius: 8px;
  cursor: pointer;
  font-size: .88rem;
}

.auth-tab.active {
  border-color: var(--primary);
  background: var(--primary-bg);
  color: var(--primary);
  font-weight: 600;
}

.auth-tip {
  margin: 8px 0 12px;
}

.auth-name-input {
  margin-top: 10px;
}

.cloud-sync-status {
  font-size: .85rem;
  color: var(--text-secondary);
  margin: 8px 0 12px;
}

.cloud-sync-status.ok {
  color: var(--success);
}

.cloud-sync-status.warn {
  color: var(--warning);
}

.auth-logout-btn {
  margin-top: 8px;
  color: var(--danger);
  border-color: #fecaca;
}

.activity-batch-label {
  font-size: .82rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
  font-weight: 600;
}

.activity-batch-form {
  gap: 10px;
}

.activity-table-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 4px;
}

.activity-add-row-btn {
  border: 1px dashed var(--primary);
  background: var(--primary-bg);
  color: var(--primary);
  font-size: .78rem;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
}

.activity-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
}

.activity-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 280px;
}

.activity-table th,
.activity-table td {
  padding: 8px 6px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

.activity-table th {
  font-size: .75rem;
  color: var(--text-secondary);
  font-weight: 600;
  background: var(--card);
}

.activity-table tbody tr:last-child td {
  border-bottom: none;
}

.activity-table .col-num {
  width: 32px;
  text-align: center;
  color: var(--text-muted);
  font-size: .78rem;
}

.activity-table .col-action {
  width: 36px;
  text-align: center;
}

.activity-cell-input {
  width: 100%;
  min-width: 0;
  padding: 8px 10px !important;
  font-size: .88rem;
}

.activity-row-del {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  padding: 4px;
}

.activity-row-del:active {
  color: var(--danger);
}

.activity-group-item {
  cursor: pointer;
}

.activity-group-item:active {
  transform: scale(.99);
}

.activity-group-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.modal-wide {
  max-width: 420px;
}

.activity-content-input {
  min-height: 56px;
  resize: vertical;
}

.shop-item-content {
  font-size: .82rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-top: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.activity-detail-info {
  background: var(--primary-bg);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 12px;
  font-size: .85rem;
  line-height: 1.6;
}

.activity-detail-info strong {
  display: block;
  font-size: 1rem;
  margin-bottom: 4px;
  color: var(--text);
}

.activity-detail-add {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.activity-detail-add .input {
  flex: 1;
  min-width: 100px;
}

.activity-detail-add .btn-secondary {
  flex-shrink: 0;
}

.activity-detail-footer {
  flex-wrap: wrap;
  gap: 8px;
}

.activity-detail-footer .btn-secondary {
  flex: 1;
  min-width: 120px;
}

.activity-status-tag {
  display: inline-block;
  font-size: .72rem;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 600;
}

.activity-status-tag.pending {
  background: #fef3c7;
  color: #b45309;
}

.activity-status-tag.done {
  background: #d1fae5;
  color: #047857;
}

.activity-part-action {
  border: none;
  background: transparent;
  color: var(--primary);
  font-size: .75rem;
  cursor: pointer;
  padding: 2px 4px;
}

.activity-part-del {
  color: var(--danger);
  margin-left: 4px;
}

.bottom-nav .nav-item {
  font-size: .65rem;
}

/* Responsive tweaks */
@media (min-width: 481px) {
  body {
    background: var(--desktop-bg, #e2e8f0);
  }

  .app {
    box-shadow: 0 0 40px rgba(0,0,0,.1);
  }
}

@media (max-width: 360px) {
  .input-time {
    width: 80px;
    font-size: .82rem;
  }

  .date-main {
    font-size: 1rem;
  }
}
