/* ============================================
   LifeOS - 极简黑白蓝设计系统
   ============================================ */

/* ---------- 设计变量 ---------- */
:root {
  /* 主色系 - 黑白蓝 */
  --bg: #f5f5f7;
  --bg-soft: #ebebf0;
  --card: #ffffff;
  --card-soft: #fafafa;
  --primary: #0071e3;       /* 经典蓝 */
  --primary-light: #d6e8fa;
  --primary-dark: #0058b8;
  --secondary: #6e6e73;     /* 中灰 */
  --secondary-light: #d2d2d7;
  --success: #43c07c;       /* 清新绿 */
  --success-light: #d9f2e3;
  --warning: #ff9f43;       /* 暖橙 */
  --warning-light: #ffe8cc;
  --danger: #e5484d;        /* 危险红 */
  --text: #1d1d1f;
  --text-soft: #6e6e73;
  --text-faint: #aeaeb2;
  --border: #e5e5ea;
  --border-soft: #f0f0f2;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 4px 24px rgba(0, 0, 0, 0.08);
  --shadow-sm: 0 1px 4px rgba(0, 0, 0, 0.04);
  --radius: 16px;
  --radius-sm: 10px;
  --radius-lg: 20px;
  --radius-full: 999px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---------- 基础重置 ---------- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  height: 100%;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

a { color: var(--primary-dark); text-decoration: none; }

/* ---------- 滚动条美化 ---------- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--primary-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

/* ---------- 布局：侧边栏 + 内容 ---------- */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* 侧边栏（桌面） */
.sidebar {
  width: 220px;
  background: var(--card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  padding: 20px 0;
  overflow-y: auto;
}

.sidebar-logo {
  padding: 8px 24px 24px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-logo-icon {
  width: 36px; height: 36px;
  background: var(--primary);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 18px; font-weight: 700;
  flex-shrink: 0;
}

.sidebar-logo-text {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.sidebar-nav {
  flex: 1;
  padding: 0 12px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-soft);
  font-size: 14px;
  margin-bottom: 1px;
  transition: var(--transition);
  user-select: none;
}

.nav-item:hover {
  background: var(--bg-soft);
  color: var(--text);
}

.nav-item.active {
  background: var(--primary-light);
  color: var(--primary-dark);
  font-weight: 600;
}

.nav-item-icon {
  width: 20px; height: 20px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.nav-item-icon svg { width: 18px; height: 18px; }

.nav-item-label { flex: 1; }

.nav-item-badge {
  background: var(--warning);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: var(--radius-full);
}

.sidebar-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-soft);
  font-size: 12px;
  color: var(--text-faint);
}

/* 主内容区 */
.main-content {
  flex: 1;
  margin-left: 220px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.content-header {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 16px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.content-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
}

.content-subtitle {
  font-size: 13px;
  color: var(--text-soft);
  margin-top: 2px;
}

.content-body {
  padding: 24px 28px;
  flex: 1;
  max-width: 1100px;
  width: 100%;
}

/* ---------- 移动端 ---------- */
.mobile-header {
  display: none;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 14px 18px;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.mobile-header-title {
  font-size: 17px;
  font-weight: 600;
}

.mobile-menu-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  color: var(--text-soft);
  display: flex;
  align-items: center;
}

.bottom-tabbar {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--card);
  border-top: 1px solid var(--border);
  z-index: 100;
  padding: 6px 0 calc(6px + env(safe-area-inset-bottom));
}

.bottom-tabbar-inner {
  display: flex;
  justify-content: space-around;
}

.bottom-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 14px;
  cursor: pointer;
  color: var(--text-faint);
  font-size: 11px;
  transition: var(--transition);
}

.bottom-tab.active { color: var(--primary); }
.bottom-tab svg { width: 22px; height: 22px; }

/* 移动端抽屉菜单 */
.mobile-drawer {
  display: flex;
  visibility: hidden;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: 260px;
  background: var(--card);
  z-index: 200;
  transform: translateX(-100%);
  transition: transform 0.3s ease, visibility 0.3s;
  flex-direction: column;
  padding: 20px 0;
  overflow-y: auto;
  box-shadow: 0 0 24px rgba(0, 0, 0, 0.12);
}

.mobile-drawer.open { transform: translateX(0); visibility: visible; }

.drawer-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.3);
  z-index: 199;
  opacity: 0;
  transition: opacity 0.3s;
}

.drawer-overlay.show { display: block; opacity: 1; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}

.card-soft {
  background: var(--card-soft);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  border: 1px solid var(--border-soft);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title svg { width: 18px; height: 18px; color: var(--primary); }

.card-subtitle {
  font-size: 13px;
  color: var(--text-soft);
  margin-top: 2px;
}

/* ---------- 网格 ---------- */
.grid {
  display: grid;
  gap: 16px;
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* ---------- 统计卡片 ---------- */
.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: var(--transition);
  cursor: pointer;
}

.stat-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }

.stat-card-icon {
  width: 38px; height: 38px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

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

.stat-card-label {
  font-size: 13px;
  color: var(--text-soft);
}

.stat-card-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
}

.stat-card-trend {
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  user-select: none;
  white-space: nowrap;
}

.btn svg { width: 16px; height: 16px; }

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-dark); }

.btn-secondary {
  background: var(--secondary);
  color: #fff;
}
.btn-secondary:hover { background: #5a5a5f; }

.btn-ghost {
  background: var(--bg-soft);
  color: var(--text);
}
.btn-ghost:hover { background: var(--primary-light); color: var(--primary-dark); }

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--text);
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary-dark); }

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1.5px solid var(--danger);
}
.btn-danger:hover { background: var(--danger); color: #fff; }

.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-lg { padding: 12px 24px; font-size: 16px; }
.btn-block { width: 100%; }
.btn-icon { padding: 8px; width: 34px; height: 34px; }

/* ---------- 表单 ---------- */
.form-group { margin-bottom: 16px; }

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 6px;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  font-size: 14px;
  color: var(--text);
  transition: var(--transition);
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.form-textarea { resize: vertical; min-height: 80px; }

.form-row {
  display: flex;
  gap: 12px;
}
.form-row > * { flex: 1; }

/* ---------- 标签/徽章 ---------- */
.tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 500;
  gap: 4px;
}

.tag-primary { background: var(--primary-light); color: var(--primary-dark); }
.tag-success { background: var(--success-light); color: #2e8b57; }
.tag-warning { background: var(--warning-light); color: #c77700; }
.tag-secondary { background: var(--secondary-light); color: #48484a; }
.tag-soft { background: var(--bg-soft); color: var(--text-soft); }

/* ---------- 进度条 ---------- */
.progress {
  height: 8px;
  background: var(--bg-soft);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: var(--primary);
  border-radius: var(--radius-full);
  transition: width 0.4s ease;
}

.progress-bar.success { background: var(--success); }
.progress-bar.warning { background: var(--warning); }

/* ---------- 列表项 ---------- */
.list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-soft);
}

.list-item:last-child { border-bottom: none; }

.list-item-icon {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.list-item-content { flex: 1; min-width: 0; }
.list-item-title { font-size: 14px; font-weight: 500; color: var(--text); }
.list-item-sub { font-size: 12px; color: var(--text-soft); margin-top: 2px; }

.list-item-action { flex-shrink: 0; }

/* ---------- 复选框 ---------- */
.checkbox {
  width: 22px; height: 22px;
  border: 2px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: var(--transition);
  flex-shrink: 0;
}

.checkbox.checked {
  background: var(--success);
  border-color: var(--success);
}

.checkbox.checked::after {
  content: '';
  width: 6px; height: 10px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) translate(-1px, -1px);
}

/* ---------- 空状态 ---------- */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-faint);
}

.empty-state-icon {
  width: 56px; height: 56px;
  margin: 0 auto 12px;
  background: var(--bg-soft);
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-faint);
}

.empty-state-icon svg { width: 28px; height: 28px; }
.empty-state-text { font-size: 14px; }

/* ---------- 模态框 ---------- */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.35);
  z-index: 300;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.show { display: flex; }

.modal {
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 500px;
  max-height: 85vh;
  overflow-y: auto;
  animation: modalIn 0.25s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-soft);
}

.modal-title { font-size: 17px; font-weight: 600; }

.modal-close {
  background: none; border: none; cursor: pointer;
  color: var(--text-soft); padding: 4px;
  display: flex; align-items: center;
}

.modal-body { padding: 20px 24px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-soft);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ---------- Tab 切换 ---------- */
.tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-soft);
  border-radius: var(--radius-full);
  padding: 3px;
  margin-bottom: 16px;
  width: fit-content;
}

.tab {
  padding: 7px 16px;
  border-radius: var(--radius-full);
  cursor: pointer;
  font-size: 13px;
  color: var(--text-soft);
  transition: var(--transition);
  white-space: nowrap;
}

.tab.active {
  background: var(--card);
  color: var(--text);
  font-weight: 500;
  box-shadow: var(--shadow-sm);
}

/* ---------- 日历 ---------- */
.calendar {
  width: 100%;
}

.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

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

.calendar-day-name {
  text-align: center;
  font-size: 12px;
  color: var(--text-faint);
  padding: 4px;
  font-weight: 500;
}

.calendar-day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  position: relative;
  color: var(--text);
  transition: var(--transition);
}

.calendar-day:hover { background: var(--bg-soft); }
.calendar-day.other-month { color: var(--text-faint); opacity: 0.5; }
.calendar-day.today {
  background: var(--primary);
  color: #fff;
  font-weight: 600;
}
.calendar-day.selected {
  background: var(--secondary);
  color: #fff;
}
.calendar-day.has-data::after {
  content: '';
  position: absolute;
  bottom: 4px;
  width: 4px; height: 4px;
  background: var(--warning);
  border-radius: 50%;
}

/* ---------- 图表容器 ---------- */
.chart-container {
  position: relative;
  width: 100%;
}

.chart-container canvas { max-width: 100%; }

/* ---------- 工具类 ---------- */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.flex-1 { flex: 1; }
.flex-wrap { flex-wrap: wrap; }
.text-center { text-align: center; }
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }
.text-soft { color: var(--text-soft); }
.text-faint { color: var(--text-faint); }
.text-primary { color: var(--primary-dark); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }
.font-bold { font-weight: 600; }
.font-semibold { font-weight: 500; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.p-0 { padding: 0; }
.hidden { display: none !important; }

/* ---------- 视图切换动画 ---------- */
.view {
  animation: viewIn 0.3s ease;
}

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

/* ---------- Toast 提示 ---------- */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: #fff;
  padding: 10px 20px;
  border-radius: var(--radius-full);
  font-size: 14px;
  z-index: 400;
  opacity: 0;
  transition: opacity 0.3s, bottom 0.3s;
  pointer-events: none;
}

.toast.show { opacity: 1; bottom: 100px; }

/* ---------- 响应式 ---------- */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .main-content { margin-left: 0; }
  .mobile-header { display: flex; }
  .bottom-tabbar { display: block; }
  .content-body { padding: 16px; padding-bottom: 80px; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .form-row { flex-direction: column; }
  .modal { max-width: 100%; }
  .content-header { display: none; }
  .card { padding: 16px; }
  .stat-card-value { font-size: 20px; }
}

@media (min-width: 769px) {
  .mobile-drawer { display: none !important; }
}

/* ---------- 首页模块卡片 ---------- */
.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
}

.module-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.module-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-3px);
}

.module-card-icon {
  width: 44px; height: 44px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
}

.module-card-icon svg { width: 24px; height: 24px; }

.module-card-title { font-size: 15px; font-weight: 600; color: var(--text); }
.module-card-desc { font-size: 12px; color: var(--text-soft); }

/* 纯色背景图标（Days Matter / iCost 多彩风） */
.bg-grad-1 { background: #4a90e2; color: #fff; }
.bg-grad-2 { background: #f283a0; color: #fff; }
.bg-grad-3 { background: #43c07c; color: #fff; }
.bg-grad-4 { background: #ffab2e; color: #fff; }
.bg-grad-5 { background: #9b7ede; color: #fff; }
.bg-grad-6 { background: #3cb8b2; color: #fff; }
.bg-grad-7 { background: #7d85d8; color: #fff; }
.bg-grad-8 { background: #f2707d; color: #fff; }
.bg-grad-9 { background: #5e60ce; color: #fff; }

/* 背景色 */
.bg-primary-light { background: var(--primary-light); }
.bg-success-light { background: var(--success-light); }
.bg-warning-light { background: var(--warning-light); }
.bg-secondary-light { background: var(--secondary-light); }
.bg-soft { background: var(--bg-soft); }
