/* ===== 基礎變數 ===== */
:root {
  --bg: #f2f2f7; --card: #ffffff; --field: #f4f4f7;
  --text: #1c1c1e; --sub: #8e8e93; --line: #e6e6eb;
  --blue: #0a84ff; --green: #34c759; --red: #ff3b30;
  --orange: #ff9f0a; --purple: #bf5af2;
  --accent: #0a84ff;
  --shadow: 0 1px 3px rgba(0,0,0,.07), 0 8px 20px rgba(0,0,0,.03);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000; --card: #1c1c1e; --field: #2c2c2e;
    --text: #f2f2f7; --sub: #8e8e93; --line: #2f2f33;
    --blue: #0a84ff; --green: #30d158; --red: #ff453a;
    --orange: #ff9f0a; --purple: #bf5af2;
    --accent: #0a84ff;
    --shadow: none;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue",
               "PingFang TC", "Microsoft JhengHei", "Noto Sans TC", sans-serif;
  background: var(--bg); color: var(--text);
  font-size: 16px; line-height: 1.45; min-height: 100vh;
  overscroll-behavior-y: none; touch-action: manipulation;
  -webkit-user-select: none; user-select: none;
  padding-bottom: calc(80px + env(safe-area-inset-bottom));
}
input, textarea { -webkit-user-select: text; user-select: text; }

.app-header {
  position: sticky; top: 0; z-index: 20;
  padding: calc(env(safe-area-inset-top) + 16px) 20px 10px;
  background: var(--bg);
}
.app-header h1 { margin: 0; font-size: 28px; font-weight: 700; letter-spacing: -0.6px; }
.app-date { margin: 3px 0 0; font-size: 13px; color: var(--sub); }

main { padding: 4px 16px 20px; }
.page { display: none; }
.page.active { display: block; animation: fadeIn .18s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.card {
  background: var(--card); border-radius: 16px; padding: 16px;
  margin-bottom: 14px; box-shadow: var(--shadow);
}
.card-title { font-size: 15px; font-weight: 700; margin-bottom: 10px; }
.hint { font-size: 13px; color: var(--sub); line-height: 1.6; margin: 0 0 14px; }
.red { color: var(--red); }
.green { color: var(--green); }
.orange { color: var(--orange); }

.link-btn {
  background: none; border: none; color: var(--accent);
  font-family: inherit; font-size: 14px; font-weight: 600;
  padding: 8px 4px; min-height: 36px; cursor: pointer;
}
.link-btn:active { opacity: .6; }

input[type="text"], input[type="number"], input[type="url"],
input[type="time"], input[type="date"], input[type="month"], select {
  width: 100%; font-size: 16px; font-family: inherit;
  color: var(--text); background: var(--field);
  border: 1px solid transparent; border-radius: 12px;
  padding: 13px 14px; min-height: 50px; outline: none;
  transition: border-color .15s, background .15s;
  appearance: none; -webkit-appearance: none;
}
input:focus, select:focus { border-color: var(--accent); background: var(--card); }
input::placeholder { color: var(--sub); }
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.input-row { display: flex; gap: 10px; align-items: center; }
.input-row input { flex: 1 1 auto; }
.field-label {
  display: block; font-size: 13px; font-weight: 600;
  color: var(--sub); margin: 0 0 7px 2px;
}
.field-block { margin-top: 14px; }

.btn-primary {
  background: var(--accent); color: #fff; border: none; border-radius: 12px;
  font-family: inherit; font-size: 16px; font-weight: 600;
  min-height: 50px; padding: 0 18px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  transition: opacity .15s, transform .1s;
}
.btn-primary:active { opacity: .75; transform: scale(.98); }
.btn-primary.full { width: 100%; }
.btn-secondary {
  background: var(--field); color: var(--text);
  border: 1px solid var(--line); border-radius: 12px;
  font-family: inherit; font-size: 16px; font-weight: 600;
  min-height: 50px; width: 100%; padding: 0 18px;
  cursor: pointer; transition: opacity .15s;
}
.btn-secondary:active { opacity: .7; }
.btn-danger {
  background: transparent; color: var(--red);
  border: 1px solid var(--red); border-radius: 12px;
  font-family: inherit; font-size: 16px; font-weight: 600;
  min-height: 50px; width: 100%; padding: 0 18px;
  cursor: pointer; transition: opacity .15s;
}
.btn-danger:active { opacity: .7; }

.segmented {
  display: flex; background: var(--field);
  border-radius: 12px; padding: 4px; gap: 4px;
}
.segmented button {
  flex: 1 1 0; border: none; background: transparent;
  color: var(--sub); font-family: inherit; font-size: 15px;
  font-weight: 600; padding: 10px 0; border-radius: 9px;
  cursor: pointer; min-height: 44px;
  transition: background .15s, color .15s;
}
.segmented button.active {
  background: var(--card); color: var(--text);
  box-shadow: 0 1px 3px rgba(0,0,0,.12);
}
.segmented button.active[data-type="expense"] { color: var(--red); }
.segmented button.active[data-type="income"]  { color: var(--green); }

.row-between { display: flex; justify-content: space-between; align-items: center; }
.label { font-size: 14px; color: var(--sub); font-weight: 500; }
.value { font-size: 14px; font-weight: 700; }
.progress {
  margin-top: 11px; height: 10px; border-radius: 999px;
  background: var(--field); overflow: hidden;
}
.progress-fill {
  height: 100%; width: 0%; border-radius: 999px;
  background: linear-gradient(90deg, #30d158, #34c759);
  transition: width .3s ease;
}

.asset-card {
  background: linear-gradient(135deg, var(--accent) 0%, #5e5ce6 100%);
  color: #fff;
  border-radius: 16px;
  padding: 18px;
  margin-bottom: 14px;
  box-shadow: 0 6px 20px rgba(10,132,255,.25);
}
.asset-card .asset-label { font-size: 12px; opacity: .85; margin-bottom: 4px; }
.asset-card .asset-value {
  font-size: 30px; font-weight: 800; letter-spacing: -1px; line-height: 1.1;
}
.asset-card .asset-row {
  display: flex; gap: 16px; margin-top: 14px; padding-top: 14px;
  border-top: 1px solid rgba(255,255,255,.25);
}
.asset-card .asset-sub { flex: 1 1 0; }
.asset-card .asset-sub-label { font-size: 11px; opacity: .85; }
.asset-card .asset-sub-value { font-size: 16px; font-weight: 700; margin-top: 2px; }

.day-tl-wrap {
  position: relative;
  display: grid;
  grid-template-columns: 46px 1fr 1fr;
  gap: 0;
}
.day-tl-headers {
  display: grid;
  grid-template-columns: 46px 1fr 1fr;
  gap: 0;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
  margin-bottom: 6px;
  font-size: 11px;
  color: var(--sub);
  font-weight: 600;
  text-align: center;
}
.tl-hour-slot {
  height: 60px;
  position: relative;
  border-top: 1px solid var(--line);
  font-size: 10px;
  color: var(--sub);
  padding-right: 6px;
  text-align: right;
  padding-top: 2px;
}
.tl-hour-slot:first-child { border-top: none; }
.tl-plan-col, .tl-actual-col {
  position: relative;
  border-left: 1px solid var(--line);
}
.tl-plan-col.has-divider, .tl-actual-col { background: rgba(0,0,0,.01); }
@media (prefers-color-scheme: dark) {
  .tl-plan-col.has-divider, .tl-actual-col { background: rgba(255,255,255,.02); }
}
.tl-event {
  position: absolute;
  left: 3px; right: 3px;
  border-radius: 8px;
  padding: 4px 6px;
  font-size: 11px;
  color: #fff;
  overflow: hidden;
  cursor: pointer;
  border-left: 3px solid rgba(255,255,255,.5);
}
.tl-event-title {
  font-weight: 700; line-height: 1.2;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tl-event-meta {
  font-size: 9px; opacity: .9; line-height: 1.2;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tl-now-line {
  position: absolute;
  left: 46px; right: 0;
  height: 0;
  border-top: 2px dashed var(--red);
  z-index: 5;
  pointer-events: none;
}
.tl-now-line::before {
  content: '';
  position: absolute;
  left: -4px; top: -5px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--red);
}

.all-day-area { padding: 10px 0; margin-bottom: 8px; border-bottom: 1px solid var(--line); }
.all-day-label { font-size: 11px; color: var(--sub); font-weight: 600; margin-bottom: 6px; }
.allday-todo {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
}
.allday-todo:last-child { border-bottom: none; }
.check-btn {
  flex: 0 0 auto; width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  background: none; border: none; padding: 0; cursor: pointer;
}
.check {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid #c7c7cc;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff;
}
.allday-todo.done .check, .mini-todo.done .check { background: var(--green); border-color: var(--green); }
.allday-todo .todo-text {
  flex: 1 1 auto; min-width: 0; font-size: 15px;
  word-break: break-word;
}
.allday-todo.done .todo-text { color: var(--sub); text-decoration: line-through; }
.del-btn {
  flex: 0 0 auto; width: 40px; height: 40px;
  background: none; border: none; color: var(--sub);
  font-size: 16px; border-radius: 50%; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.del-btn:active { background: var(--field); }
.del-btn.red { color: var(--red); }
.timer-btn {
  flex: 0 0 auto; background: none; border: 1px solid var(--line);
  border-radius: 8px; padding: 5px 8px; color: var(--sub);
  font-family: inherit; font-size: 11px; font-weight: 600;
  cursor: pointer;
}
.timer-btn.running { background: var(--red); color: #fff; border-color: var(--red); }

.week-strip {
  display: grid;
  grid-template-columns: 24px repeat(7, 1fr);
  gap: 2px;
  margin-top: 8px;
}
.week-header-cell {
  text-align: center; font-size: 11px;
  color: var(--sub); padding: 4px 0; font-weight: 600;
}
.week-header-cell.today { color: var(--accent); }
.week-hour-axis {
  position: relative; height: 192px;
  grid-column: 1; grid-row: 2;
}
.week-hour-axis span {
  position: absolute; right: 4px;
  font-size: 9px; color: var(--sub);
  transform: translateY(-50%);
}
.week-col {
  position: relative; height: 192px;
  background: var(--field); border-radius: 6px;
  cursor: pointer; grid-row: 2; overflow: hidden;
}
.week-col.today { background: rgba(10,132,255,.08); }
.week-event {
  position: absolute;
  left: 1px; right: 1px;
  border-radius: 3px; font-size: 8px;
  color: #fff; padding: 1px 2px;
  overflow: hidden; line-height: 1.1;
}
.week-hour-line {
  position: absolute; left: 0; right: 0;
  border-top: 1px solid rgba(0,0,0,.05);
}
@media (prefers-color-scheme: dark) {
  .week-hour-line { border-top-color: rgba(255,255,255,.05); }
}
.week-now-line {
  position: absolute; left: 0; right: 0;
  border-top: 1.5px dashed var(--red);
  z-index: 2; pointer-events: none;
}

.month-nav {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.month-label { font-size: 16px; font-weight: 700; }
.month-nav-btn {
  width: 44px; height: 44px; border-radius: 12px; border: none;
  background: var(--field); color: var(--text); font-size: 20px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.month-nav-btn:active { opacity: .6; }
.month-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.month-weekday {
  text-align: center; font-size: 11px; color: var(--sub);
  font-weight: 600; padding: 4px 0;
}
.month-cell {
  min-height: 52px; border-radius: 8px;
  background: var(--field);
  display: flex; flex-direction: column;
  padding: 3px;
  font-size: 12px; cursor: pointer;
  position: relative; overflow: hidden;
}
.month-cell.empty { background: transparent; cursor: default; }
.month-cell.today { outline: 2px solid var(--accent); outline-offset: -2px; }
.month-day-num {
  font-size: 12px; font-weight: 700;
  line-height: 1; margin-bottom: 2px;
}
.month-cell.today .month-day-num { color: var(--accent); }
.month-summary {
  font-size: 9px; line-height: 1.2; color: var(--sub); overflow: hidden;
}
.month-summary-item {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  padding: 1px 2px; border-radius: 2px; margin-bottom: 1px;
}

.schedule-item {
  display: flex; align-items: stretch; gap: 10px;
  padding: 10px 0; border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.schedule-item:last-child { border-bottom: none; }
.sch-time {
  flex: 0 0 auto; width: 54px; text-align: right;
  padding-top: 2px; line-height: 1.3;
}
.sch-start { font-size: 14px; font-weight: 700; }
.sch-end { font-size: 11px; color: var(--sub); }
.sch-color-bar { flex: 0 0 auto; width: 4px; border-radius: 2px; background: var(--accent); }
.sch-content { flex: 1 1 auto; min-width: 0; padding-top: 1px; }
.sch-title { font-size: 15px; font-weight: 600; word-break: break-word; }
.sch-title.done { text-decoration: line-through; color: var(--sub); }
.sch-meta {
  font-size: 11px; color: var(--sub);
  margin-top: 3px; display: flex; gap: 8px; flex-wrap: wrap;
}
.sch-note { font-size: 12px; color: var(--sub); margin-top: 3px; word-break: break-word; }

.cat-badge {
  display: inline-block; font-size: 11px; font-weight: 600;
  padding: 2px 8px; border-radius: 999px;
  margin-top: 4px; line-height: 1.5;
  background: var(--field); color: var(--sub);
}

.empty {
  text-align: center; color: var(--sub); font-size: 14px;
  line-height: 1.8; padding: 26px 8px;
}

.chart-donut { display: flex; align-items: center; justify-content: center; padding: 12px 0; }
.chart-legend { margin-top: 10px; }
.chart-legend-item { display: flex; align-items: center; gap: 8px; padding: 5px 0; font-size: 13px; }
.chart-legend-dot { width: 10px; height: 10px; border-radius: 50%; }
.chart-legend-name { flex: 1 1 auto; }
.chart-legend-val { font-weight: 700; }
.chart-bar {
  display: flex; align-items: flex-end; gap: 3px;
  height: 140px; padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.chart-bar-item {
  flex: 1 1 0; display: flex; flex-direction: column;
  align-items: center; justify-content: flex-end;
  height: 100%; position: relative;
}
.chart-bar-fill {
  width: 60%; border-radius: 4px 4px 0 0;
  background: var(--accent); min-height: 2px;
}
.chart-bar-fill.income { background: var(--green); }
.chart-bar-labels { display: flex; margin-top: 20px; }
.chart-bar-labels > div {
  flex: 1 1 0; text-align: center; font-size: 9px; color: var(--sub);
}

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat { background: var(--field); border-radius: 14px; padding: 14px; }
.stat-label { font-size: 13px; color: var(--sub); }
.stat-value { font-size: 22px; font-weight: 700; margin-top: 4px; letter-spacing: -0.5px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  font-family: inherit; font-size: 14px; font-weight: 500;
  padding: 10px 14px; min-height: 42px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--card);
  color: var(--text); cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip:active { opacity: .8; }

.cat-list { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.cat-item {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 8px 8px 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--card);
  font-size: 14px;
}
.cat-item .dot { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; }
.cat-item .cat-icon { font-size: 16px; }
.cat-item .cat-del {
  background: none; border: none; color: var(--sub);
  font-size: 13px; padding: 4px 4px 4px 6px; cursor: pointer;
  min-height: 28px; font-family: inherit;
}
.cat-item .cat-del:active { color: var(--red); }

.color-picker { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.color-dot {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid transparent; cursor: pointer; padding: 0;
}
.color-dot.active {
  border-color: var(--text);
  box-shadow: 0 0 0 2px var(--card) inset;
}

.exp-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0; border-bottom: 1px solid var(--line);
}
.exp-item:last-child { border-bottom: none; }
.exp-cat-icon {
  flex: 0 0 auto; width: 40px; height: 40px; border-radius: 13px;
  background: var(--field); display: flex; align-items: center;
  justify-content: center; font-size: 19px;
}
.exp-main { flex: 1 1 auto; min-width: 0; }
.exp-note { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.exp-meta { font-size: 12px; color: var(--sub); margin-top: 2px; }
.exp-amount { flex: 0 0 auto; font-size: 16px; font-weight: 700; color: var(--red); }
.exp-amount.income { color: var(--green); }

/* 舊仪表板（保留兼容，被新版取代） */
.dash-greet-card { padding: 20px 18px; }
.dash-greet { font-size: 20px; font-weight: 700; letter-spacing: -0.4px; }
.dash-sub { font-size: 13px; color: var(--sub); margin-top: 2px; }
.mini-todo {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 0; border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.mini-todo:last-child { border-bottom: none; }
.mini-todo .check-btn { width: 34px; height: 34px; flex: 0 0 auto; }
.mini-todo .check {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid #c7c7cc;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff;
}
.mini-text { flex: 1 1 auto; min-width: 0; font-size: 15px; word-break: break-word; }
.mini-todo.done .mini-text { color: var(--sub); text-decoration: line-through; }
.mini-time {
  flex: 0 0 auto; font-size: 12px; font-weight: 700; color: var(--sub);
  width: 44px; text-align: right;
}
.dash-month {
  margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line);
}
.dash-month-row {
  display: flex; justify-content: space-between;
  font-size: 14px; color: var(--sub); padding: 4px 2px;
}
.dash-month-row span:last-child { color: var(--text); font-weight: 600; }

/* 目標 OKR */
.goal-tree { padding-left: 0; }
.goal-node {
  margin-bottom: 8px;
  border-left: 3px solid var(--accent);
  padding-left: 10px;
}
.goal-node[data-type="kr"] { border-left-color: var(--orange); margin-left: 20px; }
.goal-node[data-type="task"] { border-left-color: var(--blue); margin-left: 40px; }
.goal-node[data-type="subtask"] { border-left-color: var(--green); margin-left: 60px; }

.goal-card {
  background: var(--field);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 8px;
}
.goal-header {
  display: flex; align-items: flex-start; gap: 8px;
}
.goal-badge {
  flex: 0 0 auto;
  font-size: 10px; font-weight: 700;
  padding: 2px 8px; border-radius: 999px;
  background: var(--accent); color: #fff;
  line-height: 1.5;
}
.goal-badge.kr { background: var(--orange); }
.goal-badge.task { background: var(--blue); }
.goal-badge.subtask { background: var(--green); }
.goal-title { flex: 1 1 auto; font-weight: 600; font-size: 15px; word-break: break-word; }
.goal-title.done { color: var(--sub); text-decoration: line-through; }
.goal-meta { font-size: 11px; color: var(--sub); margin-top: 6px; display: flex; gap: 8px; flex-wrap: wrap; }
.goal-progress {
  height: 4px; border-radius: 2px; background: var(--line);
  margin-top: 8px; overflow: hidden;
}
.goal-progress-fill {
  height: 100%; background: var(--accent); border-radius: 2px;
  transition: width .3s;
}
.goal-actions {
  display: flex; gap: 6px; margin-top: 8px;
  flex-wrap: wrap;
}
.goal-actions button {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-family: inherit; font-size: 12px;
  padding: 5px 10px; cursor: pointer;
  color: var(--text);
}
.goal-actions button.danger { color: var(--red); }
.goal-actions button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }

.gantt-wrap { overflow-x: auto; padding: 8px 0; -webkit-overflow-scrolling: touch; }
.gantt { min-width: 100%; display: flex; flex-direction: column; gap: 4px; }
.gantt-row { display: flex; align-items: center; gap: 4px; height: 26px; font-size: 11px; }
.gantt-label {
  flex: 0 0 auto; width: 100px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  padding-right: 6px;
}
.gantt-label[data-type="kr"] { padding-left: 10px; color: var(--orange); }
.gantt-label[data-type="task"] { padding-left: 20px; color: var(--blue); }
.gantt-label[data-type="subtask"] { padding-left: 30px; color: var(--green); }
.gantt-track {
  flex: 1 1 auto; height: 18px;
  background: var(--field); border-radius: 4px;
  position: relative;
}
.gantt-bar {
  position: absolute; height: 100%;
  border-radius: 4px; background: var(--accent);
  min-width: 3px;
}
.gantt-bar[data-type="kr"] { background: var(--orange); }
.gantt-bar[data-type="task"] { background: var(--blue); }
.gantt-bar[data-type="subtask"] { background: var(--green); }
.gantt-days {
  display: flex; margin-left: 104px;
  font-size: 9px; color: var(--sub);
}
.gantt-days > span { flex: 1 1 0; text-align: center; }

.checkin-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.checkin-item:last-child { border-bottom: none; }
.checkin-icon {
  flex: 0 0 auto; width: 40px; height: 40px;
  border-radius: 12px; background: var(--field);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
}
.checkin-main { flex: 1 1 auto; min-width: 0; }
.checkin-title { font-size: 15px; font-weight: 600; }
.checkin-meta { font-size: 11px; color: var(--sub); margin-top: 3px; }
.checkin-btn {
  flex: 0 0 auto;
  border: 1px solid var(--accent);
  background: var(--card);
  color: var(--accent);
  border-radius: 8px;
  padding: 8px 12px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  min-height: 40px;
}
.checkin-btn.checked {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
}
.checkin-streak { font-size: 11px; color: var(--orange); font-weight: 700; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  display: flex; background: var(--card);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar button {
  flex: 1 1 0; background: none; border: none; cursor: pointer;
  font-family: inherit; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px;
  padding: 8px 0 6px; min-height: 54px;
  color: var(--sub); font-size: 10px; font-weight: 500;
  transition: color .15s;
}
.tabbar button .icon { font-size: 20px; line-height: 1; }
.tabbar button.active { color: var(--accent); }
.tabbar button:active { opacity: .6; }

.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,.45);
  display: flex; align-items: flex-end; justify-content: center;
}
.modal {
  width: 100%; max-width: 480px; background: var(--card);
  border-radius: 20px 20px 0 0;
  padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
  animation: slideUp .22s ease;
  max-height: 92vh; overflow-y: auto;
}
@keyframes slideUp { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-title { font-size: 17px; font-weight: 700; margin-bottom: 14px; }
.modal-actions { display: flex; gap: 10px; margin-top: 16px; }
.modal-actions .btn-primary, .modal-actions .btn-secondary { flex: 1 1 0; width: auto; }
.modal-tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.modal-tabs button {
  flex: 1 1 0; font-family: inherit; font-size: 14px;
  padding: 10px 0; min-height: 44px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--card); color: var(--text);
  cursor: pointer; font-weight: 600;
}
.modal-tabs button.active {
  background: var(--accent); border-color: var(--accent); color: #fff;
}

.sync-status { font-size: 13px; margin-top: 10px; margin-bottom: 0; }

.reminder-banner {
  position: fixed; top: calc(env(safe-area-inset-top) + 12px);
  left: 16px; right: 16px; z-index: 9999;
  background: var(--accent); color: #fff;
  padding: 14px 18px; border-radius: 14px;
  box-shadow: 0 6px 24px rgba(0,0,0,.25);
  font-size: 15px; cursor: pointer;
  animation: slideDown .25s ease;
}
@keyframes slideDown {
  from { transform: translateY(-20px); opacity: 0; }
  to { transform: none; opacity: 1; }
}
.reminder-banner .rb-title { font-weight: 700; margin-bottom: 4px; }
.reminder-banner .rb-body { font-size: 13px; opacity: .9; }

body.theme-warm { --bg: #faf6f0; }
body.theme-cool { --bg: #eef4fb; }
body.theme-mint { --bg: #eefaf3; }
body.theme-rose { --bg: #faf0f3; }
@media (prefers-color-scheme: dark) {
  body.theme-warm { --bg: #1a1610; }
  body.theme-cool { --bg: #0e1420; }
  body.theme-mint { --bg: #0e1a14; }
  body.theme-rose { --bg: #1a0e14; }
}

.budget-bar-wrap {
  background: var(--field);
  border-radius: 8px;
  height: 8px;
  overflow: hidden;
  margin-top: 8px;
}
.budget-bar-fill {
  height: 100%;
  background: var(--green);
  border-radius: 8px;
  transition: width .3s, background .3s;
}
.budget-bar-fill.warn { background: var(--orange); }
.budget-bar-fill.danger { background: var(--red); }

/* ==================================================
   ===== 新增：新版精簡儀表板 =====
   ================================================== */
.dash-hero {
  padding: 20px 18px;
  background: linear-gradient(135deg, var(--accent) 0%, #5e5ce6 100%);
  color: #fff;
  border-radius: 18px;
  margin-bottom: 14px;
  box-shadow: 0 4px 16px rgba(10,132,255,.22);
  position: relative;
  overflow: hidden;
}
.dash-hero::after {
  content: '';
  position: absolute;
  right: -40px; top: -40px;
  width: 140px; height: 140px;
  background: rgba(255,255,255,.08);
  border-radius: 50%;
  pointer-events: none;
}
.dash-hero .dash-greet {
  font-size: 20px; font-weight: 700;
  letter-spacing: -0.3px;
  margin-bottom: 2px;
}
.dash-hero .dash-sub {
  font-size: 13px;
  opacity: .85;
}
.dash-hero .dash-asset-block {
  text-align: right;
  position: relative;
  z-index: 1;
}
.dash-hero .dash-asset-label {
  font-size: 11px;
  opacity: .8;
  margin-bottom: 2px;
}
.dash-hero .dash-asset-value {
  font-size: 26px; font-weight: 800;
  letter-spacing: -0.6px; line-height: 1.1;
}
.dash-hero .dash-asset-meta {
  display: flex;
  gap: 18px;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid rgba(255,255,255,.2);
  font-size: 12px;
  opacity: .95;
  position: relative;
  z-index: 1;
}
.dash-hero .dash-asset-meta b {
  font-weight: 700; font-size: 13px;
  margin-left: 2px;
}

.dash-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}
.dash-tile {
  background: var(--card);
  border-radius: 14px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  min-height: 76px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.dash-tile .tile-label {
  font-size: 12px;
  color: var(--sub);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 4px;
}
.dash-tile .tile-icon {
  font-size: 14px;
}
.dash-tile .tile-value {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.4px;
  margin-top: 6px;
}
.dash-tile .tile-value.red { color: var(--red); }
.dash-tile .tile-value.green { color: var(--green); }
.dash-tile .tile-value.orange { color: var(--orange); }

/* ==================================================
   ===== 新增：設定頁分組與並排 =====
   ================================================== */
.section-header {
  font-size: 12px;
  font-weight: 700;
  color: var(--sub);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 8px 6px 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.settings-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.settings-tile {
  background: var(--field);
  border-radius: 12px;
  padding: 10px 12px;
}
.settings-tile .st-label {
  display: block;
  font-size: 12px;
  color: var(--sub);
  font-weight: 600;
  margin-bottom: 6px;
}
.settings-tile input {
  margin-bottom: 0;
  min-height: 44px;
  padding: 10px 12px;
  font-size: 15px;
}
.settings-tile .btn-primary {
  font-size: 14px;
  min-height: 40px;
  width: 100%;
  padding: 0 12px;
}