/* =============================================
   CSS Design Tokens
   ============================================= */
:root {
  --bg-0: #07090f;
  --bg-1: #0d1117;
  --bg-2: #161b27;
  --bg-3: #1e2435;
  --border: rgba(255,255,255,0.07);
  --border-hov: rgba(255,255,255,0.14);

  --gold: #f5a623;
  --gold-light: #fbbf24;
  --gold-dim: rgba(245,166,35,0.15);
  --green: #10b981;
  --green-light: #34d399;
  --red: #ef4444;
  --red-light: #f87171;

  --text-1: #f0f4ff;
  --text-2: #8b9db5;
  --text-3: #4a5568;

  --sidebar-w: 256px;
  --radius-s: 6px;
  --radius-m: 10px;

  --shadow-s: 0 1px 4px rgba(0,0,0,0.5);
  --shadow-m: 0 4px 16px rgba(0,0,0,0.5);
  --shadow-l: 0 8px 32px rgba(0,0,0,0.65);

  --tr: 0.18s ease;
  --tr-s: 0.3s ease;
}

/* =============================================
   Base Reset
   ============================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; scroll-behavior: smooth; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-0); color: var(--text-1); line-height: 1.6;
  min-height: 100vh; overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
input, textarea, select { font-family: inherit; }
ul, ol { list-style: none; }

/* =============================================
   Layout
   ============================================= */
#app { display: flex; height: 100vh; overflow: hidden; }

#sidebar {
  width: var(--sidebar-w); min-width: var(--sidebar-w);
  background: #060810; border-right: 1px solid var(--border);
  display: flex; flex-direction: column; overflow-y: auto; z-index: 100;
  transition: transform var(--tr-s);
}

#main { flex: 1; background: var(--bg-1); overflow-y: auto; }

#page-content {
  padding: 28px; max-width: 1320px; margin: 0 auto;
  animation: pageFade 0.22s ease;
}

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

/* =============================================
   Sidebar
   ============================================= */
.sidebar-logo {
  display: flex; align-items: center; gap: 12px;
  padding: 24px 20px; border-bottom: 1px solid var(--border);
}
.logo-icon {
  font-size: 22px; background: linear-gradient(135deg, var(--gold), #d4891a);
  border-radius: var(--radius-m); width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 12px rgba(245,166,35,0.35); flex-shrink: 0;
}
.logo-title { font-size: 1.05rem; font-weight: 800; letter-spacing: -0.5px; display: block; }
.logo-subtitle { font-size: 0.68rem; color: var(--text-3); display: block; margin-top: 1px; }

.nav-section { padding: 16px 12px 8px; }
.nav-section-label {
  font-size: 0.63rem; font-weight: 700; letter-spacing: 1.2px;
  color: var(--text-3); text-transform: uppercase; padding: 0 8px; margin-bottom: 6px;
}
.nav-link {
  display: flex; align-items: center; gap: 10px; padding: 9px 8px;
  border-radius: var(--radius-m); color: var(--text-2); font-size: 0.855rem;
  font-weight: 500; cursor: pointer; transition: all var(--tr); margin-bottom: 1px;
}
.nav-link:hover { background: var(--bg-3); color: var(--text-1); }
.nav-link.active {
  background: linear-gradient(135deg, rgba(245,166,35,0.14), rgba(245,166,35,0.06));
  color: var(--gold-light); border: 1px solid rgba(245,166,35,0.2);
}
.nav-icon { font-size: 1rem; width: 20px; text-align: center; flex-shrink: 0; }
.nav-badge {
  margin-left: auto; background: rgba(245,166,35,0.18); color: var(--gold-light);
  border: 1px solid rgba(245,166,35,0.3); font-size: 0.65rem; font-weight: 700;
  padding: 2px 7px; border-radius: 12px;
}
.sidebar-footer {
  margin-top: auto; padding: 16px; border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 7px;
}
.backup-info { font-size: 0.68rem; color: var(--text-3); text-align: center; margin-bottom: 2px; }
.btn-sidebar-action {
  background: transparent; border: 1px solid var(--border); color: var(--text-2);
  padding: 7px 12px; border-radius: var(--radius-m); font-size: 0.78rem;
  cursor: pointer; transition: all var(--tr); width: 100%;
}
.btn-sidebar-action:hover { border-color: var(--gold); color: var(--gold-light); }

/* Mobile sidebar toggle */
#sidebar-toggle {
  display: none; position: fixed; top: 14px; left: 14px; z-index: 150;
  background: var(--bg-2); border: 1px solid var(--border); color: var(--text-1);
  padding: 8px 11px; border-radius: var(--radius-m); cursor: pointer; font-size: 0.95rem;
}
#sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.6); z-index: 99;
}
#sidebar-overlay.visible { display: block; }

/* =============================================
   Cards
   ============================================= */
.card {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius-m); padding: 20px;
  transition: border-color var(--tr);
}
.card:hover { border-color: var(--border-hov); }
.card-sm { padding: 14px; border-radius: var(--radius-m); }
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px; flex-wrap: wrap; gap: 8px;
}
.card-title {
  font-size: 0.92rem; font-weight: 700; color: var(--text-1);
  display: flex; align-items: center; gap: 7px;
}

/* =============================================
   Buttons
   ============================================= */
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px;
  border-radius: var(--radius-m); font-size: 0.84rem; font-weight: 600;
  cursor: pointer; border: none; transition: all var(--tr); white-space: nowrap;
}
.btn-primary {
  background: linear-gradient(135deg, var(--gold), #d4891a); color: #000;
  box-shadow: 0 3px 10px rgba(245,166,35,0.35);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 5px 18px rgba(245,166,35,0.45); }
.btn-secondary {
  background: var(--bg-3); color: var(--text-1); border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg-3); border-color: var(--border-hov); }
.btn-success { background: linear-gradient(135deg, var(--green), #059669); color: #fff; }
.btn-danger { background: linear-gradient(135deg, var(--red), #dc2626); color: #fff; }
.btn-ghost {
  background: transparent; color: var(--text-2); border: 1px solid var(--border);
}
.btn-ghost:hover { color: var(--text-1); border-color: var(--border-hov); }
.btn-sm { padding: 5px 11px; font-size: 0.78rem; }
.btn-xs { padding: 3px 8px; font-size: 0.72rem; }
.btn-icon {
  padding: 6px; background: var(--bg-3); border: 1px solid var(--border);
  color: var(--text-2); border-radius: var(--radius-s);
}
.btn-icon:hover { color: var(--text-1); border-color: var(--border-hov); }

/* =============================================
   Forms
   ============================================= */
.form-group { margin-bottom: 14px; }
.form-label {
  display: block; font-size: 0.75rem; font-weight: 600; color: var(--text-2);
  margin-bottom: 5px; text-transform: uppercase; letter-spacing: 0.5px;
}
.form-input, .form-textarea, .form-select {
  width: 100%; background: var(--bg-0); border: 1px solid var(--border);
  border-radius: var(--radius-m); color: var(--text-1); font-size: 0.875rem;
  padding: 9px 13px; transition: border-color var(--tr); outline: none;
}
.form-input:focus, .form-textarea:focus, .form-select:focus {
  border-color: var(--gold); box-shadow: 0 0 0 3px rgba(245,166,35,0.1);
}
.form-textarea { min-height: 88px; resize: vertical; line-height: 1.55; }
.form-select option { background: var(--bg-2); }
.form-hint { font-size: 0.7rem; color: var(--text-3); margin-top: 4px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

/* =============================================
   Badges
   ============================================= */
.badge {
  display: inline-flex; align-items: center; padding: 2px 10px;
  border-radius: 20px; font-size: 0.7rem; font-weight: 600; letter-spacing: 0.2px;
}
.badge-gold   { background: rgba(245,166,35,0.15); color: var(--gold-light); border: 1px solid rgba(245,166,35,0.3); }
.badge-green  { background: rgba(16,185,129,0.15); color: var(--green-light); border: 1px solid rgba(16,185,129,0.3); }
.badge-blue   { background: rgba(245,166,35,0.15); color: var(--gold-light);  border: 1px solid rgba(245,166,35,0.3); }
.badge-red    { background: rgba(239,68,68,0.15);  color: var(--red-light);   border: 1px solid rgba(239,68,68,0.3); }
.badge-purple { background: rgba(245,166,35,0.15); color: var(--gold-light);border: 1px solid rgba(245,166,35,0.3); }
.badge-gray   { background: rgba(100,116,139,0.12);color: #94a3b8;            border: 1px solid rgba(100,116,139,0.25); }
.badge-cyan   { background: rgba(139,157,181,0.15);  color: var(--text-2);  border: 1px solid rgba(139,157,181,0.3); }

/* =============================================
   Page Header
   ============================================= */
.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 26px; flex-wrap: wrap; gap: 12px;
}
.page-title {
  font-size: 1.55rem; font-weight: 800; letter-spacing: -0.5px;
  display: flex; align-items: center; gap: 8px;
}
.page-desc { font-size: 0.82rem; color: var(--text-2); margin-top: 3px; }

/* =============================================
   Grid
   ============================================= */
.g2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.g3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 18px; }
.g4 { display: grid; grid-template-columns: repeat(4,1fr); gap: 16px; }
.dash-grid { display: grid; grid-template-columns: 1fr 300px; gap: 18px; }
.dash-left { min-width: 0; display: flex; flex-direction: column; gap: 18px; }
.dash-right { display: flex; flex-direction: column; gap: 18px; }

/* =============================================
   Stats
   ============================================= */
.stat-card {
  background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-m);
  padding: 18px; text-align: center;
}
.stat-value { font-size: 1.9rem; font-weight: 800; line-height: 1; margin-bottom: 4px; }
.stat-label { font-size: 0.72rem; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.5px; }

/* =============================================
   Progress
   ============================================= */
.progress-bar { background: var(--bg-0); border-radius: 10px; height: 7px; overflow: hidden; }
.progress-fill {
  height: 100%; background: linear-gradient(90deg, var(--gold), var(--gold-light));
  border-radius: 10px; transition: width 0.5s ease;
}

/* =============================================
   Todos
   ============================================= */
.todo-item {
  display: flex; align-items: flex-start; gap: 9px; padding: 9px 0;
  border-bottom: 1px solid var(--border); transition: opacity var(--tr);
}
.todo-item:last-child { border-bottom: none; }
.todo-item.done { opacity: 0.45; }
.todo-item.done .todo-text { text-decoration: line-through; }
.todo-cb {
  width: 17px; height: 17px; border-radius: 4px; border: 2px solid rgba(255,255,255,0.2);
  background: transparent; cursor: pointer; flex-shrink: 0; margin-top: 3px;
  appearance: none; -webkit-appearance: none; position: relative; transition: all var(--tr);
}
.todo-cb:checked { background: var(--gold); border-color: var(--gold); }
.todo-cb:checked::after {
  content: '✓'; position: absolute; top: -2px; left: 1px;
  font-size: 11px; color: #000; font-weight: 800;
}
.todo-text { flex: 1; font-size: 0.875rem; }
.todo-meta { display: flex; align-items: center; gap: 5px; flex-shrink: 0; }
.todo-del {
  background: none; border: none; color: var(--text-3); cursor: pointer;
  padding: 1px 4px; font-size: 12px; transition: color var(--tr);
}
.todo-del:hover { color: var(--red-light); }

/* =============================================
   Stock Layout
   ============================================= */
.stock-layout {
  display: grid; grid-template-columns: 272px 1fr; gap: 16px;
  align-items: start;
}
.stock-list-panel {
  background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-m);
  overflow: hidden; position: sticky; top: 0; max-height: calc(100vh - 80px);
  display: flex; flex-direction: column;
}
.stock-list-hd {
  padding: 12px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.stock-list-filters {
  display: flex; gap: 5px; flex-wrap: wrap; padding: 8px 12px;
  border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.filter-btn {
  padding: 3px 9px; border-radius: 14px; font-size: 0.68rem; font-weight: 600;
  cursor: pointer; border: 1px solid var(--border); background: transparent;
  color: var(--text-2); transition: all var(--tr);
}
.filter-btn.active { background: var(--gold-dim); border-color: rgba(245,166,35,0.35); color: var(--gold-light); }
.filter-btn:hover { border-color: var(--border-hov); color: var(--text-1); }
.stock-list-body { overflow-y: auto; flex: 1; }
.stock-item {
  display: flex; align-items: center; gap: 9px; padding: 10px 14px;
  cursor: pointer; border-bottom: 1px solid var(--border); transition: background var(--tr);
}
.stock-item:hover { background: var(--bg-3); }
.stock-item.active { background: rgba(245,166,35,0.07); border-left: 2px solid var(--gold); }
.stock-ticker { font-size: 0.85rem; font-weight: 700; color: var(--gold-light); width: 58px; flex-shrink: 0; }
.stock-name-sm { font-size: 0.77rem; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }

/* Stock Detail */
.stock-detail-panel {
  background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-m);
  overflow: hidden;
}
.stock-detail-hd {
  padding: 20px; border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, rgba(245,166,35,0.06), transparent);
}
.stock-ticker-lg { font-size: 1.6rem; font-weight: 800; color: var(--gold-light); }
.stock-name-lg { font-size: 1rem; color: var(--text-2); margin-top: 2px; }

/* Tabs */
.tab-bar {
  display: flex; gap: 0; border-bottom: 1px solid var(--border);
  background: var(--bg-1); padding: 0 20px;
}
.tab {
  padding: 12px 18px; font-size: 0.82rem; font-weight: 600; cursor: pointer;
  border-bottom: 2px solid transparent; color: var(--text-2); transition: all var(--tr);
  background: none; border-top: none; border-left: none; border-right: none;
}
.tab:hover { color: var(--text-1); }
.tab.active { color: var(--gold-light); border-bottom-color: var(--gold); }
.tab-content { padding: 20px; }

/* =============================================
   Timeline
   ============================================= */
.timeline { position: relative; padding-left: 28px; }
.timeline::before {
  content: ''; position: absolute; left: 9px; top: 0; bottom: 0;
  width: 2px; background: var(--border);
}
.timeline-item { position: relative; margin-bottom: 18px; }
.timeline-item::before {
  content: ''; position: absolute; left: -25px; top: 8px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--gold); border: 2px solid var(--bg-2);
}
.timeline-date { font-size: 0.7rem; color: var(--text-3); margin-bottom: 5px; }
.tl-card {
  background: var(--bg-3); border: 1px solid var(--border);
  border-radius: var(--radius-m); padding: 13px;
}
.tl-type-label { font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
.tl-title { font-size: 0.875rem; font-weight: 600; color: var(--text-1); margin-bottom: 4px; }
.tl-content { font-size: 0.8rem; color: var(--text-2); line-height: 1.5; }

/* =============================================
   Learning Week Cards
   ============================================= */
.wk-card {
  background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-m);
  margin-bottom: 10px; overflow: hidden; transition: border-color var(--tr);
}
.wk-card:hover { border-color: var(--border-hov); }
.wk-card.wk-done  { border-color: rgba(16,185,129,0.3); }
.wk-card.wk-prog  { border-color: rgba(245,166,35,0.3); }
.wk-hd {
  display: flex; align-items: center; gap: 13px; padding: 14px 18px;
  cursor: pointer; user-select: none;
}
.wk-hd:hover { background: rgba(255,255,255,0.02); }
.wk-num {
  width: 34px; height: 34px; border-radius: var(--radius-s);
  background: var(--bg-0); display: flex; align-items: center; justify-content: center;
  font-size: 0.78rem; font-weight: 700; color: var(--text-2); flex-shrink: 0;
}
.wk-num.done  { background: rgba(16,185,129,0.15); color: var(--green-light); }
.wk-num.prog  { background: rgba(245,166,35,0.15); color: var(--gold-light); }
.wk-title-grp { flex: 1; min-width: 0; }
.wk-title { font-size: 0.92rem; font-weight: 600; }
.wk-obj { font-size: 0.75rem; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wk-chevron { color: var(--text-3); font-size: 0.75rem; transition: transform var(--tr); flex-shrink: 0; }
.wk-card.expanded .wk-chevron { transform: rotate(90deg); }
.wk-body {
  display: none; padding: 18px; border-top: 1px solid var(--border);
  background: var(--bg-1); animation: pageFade 0.2s ease;
}
.wk-card.expanded .wk-body { display: block; }
.wk-concepts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 18px; }
.wk-section h5 {
  font-size: 0.72rem; font-weight: 700; color: var(--gold-light);
  text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px;
}
.wk-list li {
  font-size: 0.81rem; color: var(--text-2); padding: 2px 0 2px 14px; position: relative;
}
.wk-list li::before { content: '•'; position: absolute; left: 4px; color: var(--gold); }

/* =============================================
   Investment Memo
   ============================================= */
.memo-box {
  background: var(--bg-0); border: 1px solid rgba(245,166,35,0.2);
  border-radius: var(--radius-m); padding: 18px;
}
.memo-row { display: flex; gap: 10px; margin-bottom: 9px; }
.memo-label { font-size: 0.75rem; font-weight: 700; color: var(--text-3); width: 110px; flex-shrink: 0; text-transform: uppercase; letter-spacing: 0.3px; padding-top: 1px; }
.memo-value { font-size: 0.85rem; color: var(--text-2); flex: 1; line-height: 1.5; }
.memo-value.highlight { color: var(--gold-light); font-weight: 600; }

/* =============================================
   Checklist
   ============================================= */
.q-item {
  background: var(--bg-3); border: 1px solid var(--border);
  border-radius: var(--radius-m); padding: 13px; margin-bottom: 8px;
}
.q-num { font-size: 0.68rem; font-weight: 700; color: var(--gold); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
.q-text { font-size: 0.875rem; font-weight: 600; margin-bottom: 8px; }

/* =============================================
   Speaking Practice
   ============================================= */
.speak-prompt {
  font-size: 0.82rem; color: var(--text-2); font-style: italic; margin-bottom: 6px;
}
.speak-row { margin-bottom: 14px; }
.speak-prefix { font-size: 0.82rem; color: var(--gold-light); font-weight: 500; margin-bottom: 5px; }

/* =============================================
   Reading Records
   ============================================= */
.reading-card {
  background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-m);
  margin-bottom: 10px; overflow: hidden; transition: border-color var(--tr);
}
.reading-card.done-card { border-color: rgba(16,185,129,0.25); }
.reading-hd {
  display: flex; align-items: center; gap: 12px; padding: 14px 18px;
  cursor: pointer;
}
.reading-hd:hover { background: rgba(255,255,255,0.02); }
.reading-chevron { color: var(--text-3); font-size: 0.75rem; transition: transform var(--tr); margin-left: auto; flex-shrink: 0; }
.reading-card.expanded .reading-chevron { transform: rotate(90deg); }
.reading-body { display: none; padding: 18px; border-top: 1px solid var(--border); }
.reading-card.expanded .reading-body { display: block; }
.reading-section-title {
  font-size: 0.72rem; font-weight: 700; color: var(--gold-light);
  text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px;
}

/* =============================================
   Report Cards
   ============================================= */
.report-card {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius-m); margin-bottom: 10px; overflow: hidden;
}
.report-hd {
  display: flex; align-items: center; gap: 12px; padding: 14px 18px; cursor: pointer;
}
.report-hd:hover { background: rgba(255,255,255,0.02); }
.report-chevron { color: var(--text-3); font-size: 0.75rem; transition: transform var(--tr); margin-left: auto; }
.report-card.expanded .report-chevron { transform: rotate(90deg); }
.report-body { display: none; padding: 18px; border-top: 1px solid var(--border); }
.report-card.expanded .report-body { display: block; }

/* =============================================
   FAB
   ============================================= */
#fab-container {
  position: fixed; bottom: 28px; right: 28px; z-index: 200;
  display: flex; flex-direction: column; align-items: flex-end; gap: 8px;
}
#fab-btn {
  width: 54px; height: 54px; border-radius: 50%;
  background: linear-gradient(135deg, var(--gold), #c87b0f);
  color: #000; font-size: 22px; font-weight: 300; border: none; cursor: pointer;
  box-shadow: 0 6px 22px rgba(245,166,35,0.5); transition: all var(--tr);
  display: flex; align-items: center; justify-content: center;
}
#fab-btn:hover { transform: scale(1.08); box-shadow: 0 8px 28px rgba(245,166,35,0.6); }
#fab-btn.open #fab-icon { transform: rotate(45deg); }
#fab-icon { transition: transform var(--tr); line-height: 1; }
.fab-hidden { display: none !important; }
#fab-menu { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; animation: fabIn 0.18s ease; }
@keyframes fabIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.fab-item {
  background: var(--bg-2); border: 1px solid var(--border); color: var(--text-1);
  font-size: 0.82rem; font-weight: 500; padding: 8px 16px; border-radius: 20px;
  cursor: pointer; white-space: nowrap; transition: all var(--tr); box-shadow: var(--shadow-m);
}
.fab-item:hover { background: var(--gold); color: #000; border-color: var(--gold); transform: translateX(-3px); }

/* =============================================
   Modal
   ============================================= */
#modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.72); z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  padding: 20px; backdrop-filter: blur(3px); animation: overlayIn 0.18s ease;
}
#modal-overlay.hidden { display: none; }
@keyframes overlayIn { from { opacity: 0; } to { opacity: 1; } }
#modal-box {
  background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-m);
  width: 100%; max-width: 620px; max-height: 88vh; overflow-y: auto;
  box-shadow: var(--shadow-l); animation: modalIn 0.22s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.94) translateY(16px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
#modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--bg-2); z-index: 1; border-radius: var(--radius-m) var(--radius-m) 0 0;
}
#modal-title { font-size: 1.05rem; font-weight: 700; }
#modal-close {
  background: none; border: none; color: var(--text-2); font-size: 1.1rem;
  cursor: pointer; padding: 4px 7px; border-radius: var(--radius-s); transition: color var(--tr);
}
#modal-close:hover { color: var(--text-1); }
#modal-body { padding: 22px; }
#modal-footer {
  padding: 12px 22px 20px; display: flex; gap: 8px; justify-content: flex-end;
  border-top: 1px solid var(--border);
}

/* =============================================
   Toasts
   ============================================= */
#toast-container {
  position: fixed; bottom: 28px; left: 28px; z-index: 2000;
  display: flex; flex-direction: column; gap: 7px; pointer-events: none;
}
.toast {
  background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-m);
  padding: 11px 18px; font-size: 0.84rem; color: var(--text-1);
  box-shadow: var(--shadow-l); display: flex; align-items: center; gap: 8px;
  pointer-events: auto; animation: toastIn 0.25s ease; max-width: 320px;
}
.toast.t-success { border-color: rgba(16,185,129,0.4); }
.toast.t-error   { border-color: rgba(239,68,68,0.4); }
.toast.t-warn    { border-color: rgba(245,166,35,0.4); }
@keyframes toastIn { from { opacity: 0; transform: translateX(-16px); } to { opacity: 1; transform: none; } }

/* =============================================
   Search Bar
   ============================================= */
.search-wrap {
  display: flex; align-items: center; gap: 8px; background: var(--bg-0);
  border: 1px solid var(--border); border-radius: var(--radius-m); padding: 0 12px;
  transition: border-color var(--tr);
}
.search-wrap:focus-within { border-color: var(--gold); }
.search-wrap input {
  flex: 1; background: none; border: none; color: var(--text-1);
  font-size: 0.875rem; padding: 9px 0; outline: none;
}
.search-wrap input::placeholder { color: var(--text-3); }

/* =============================================
   Empty State
   ============================================= */
.empty { text-align: center; padding: 44px 20px; }
.empty-icon { font-size: 2.5rem; margin-bottom: 12px; opacity: 0.45; }
.empty-title { font-size: 0.95rem; font-weight: 600; margin-bottom: 6px; }
.empty-desc { font-size: 0.8rem; color: var(--text-3); }

/* =============================================
   Divider
   ============================================= */
.divider { height: 1px; background: var(--border); margin: 16px 0; }
hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

/* =============================================
   Utilities
   ============================================= */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.gap-xs { gap: 5px; }
.gap-sm { gap: 9px; }
.gap-md { gap: 14px; }
.gap-lg { gap: 20px; }
.flex-1 { flex: 1; }
.flex-shrink-0 { flex-shrink: 0; }
.min-w-0 { min-width: 0; }
.w-full { width: 100%; }
.mt-sm { margin-top: 8px; }
.mt-md { margin-top: 14px; }
.mt-lg { margin-top: 20px; }
.mb-sm { margin-bottom: 8px; }
.mb-md { margin-bottom: 14px; }
.mb-lg { margin-bottom: 20px; }
.p-md { padding: 14px; }
.text-1 { color: var(--text-1); }
.text-2 { color: var(--text-2); }
.text-3 { color: var(--text-3); }
.text-gold { color: var(--gold-light); }
.text-green { color: var(--green-light); }
.text-red { color: var(--red-light); }
.text-blue { color: var(--gold-light); }
.text-purple { color: var(--gold-light); }
.text-sm { font-size: 0.82rem; }
.text-xs { font-size: 0.72rem; }
.text-lg { font-size: 1.05rem; }
.text-xl { font-size: 1.2rem; }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.font-medium { font-weight: 500; }
.hidden { display: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wrap { flex-wrap: wrap; }
.text-center { text-align: center; }
.rounded { border-radius: var(--radius-m); }
.rounded-lg { border-radius: var(--radius-m); }
.bg-3 { background: var(--bg-3); }
.border-t { border-top: 1px solid var(--border); }
.cursor-pointer { cursor: pointer; }
.opacity-50 { opacity: 0.5; }

/* =============================================
   Responsive
   ============================================= */
@media (max-width: 1100px) {
  .g4 { grid-template-columns: repeat(2,1fr); }
  .dash-grid { grid-template-columns: 1fr; }
  .dash-right { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
}
@media (max-width: 900px) {
  .wk-concepts-grid { grid-template-columns: 1fr; }
  .g3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 768px) {
  #sidebar-toggle { display: flex; }
  #sidebar { position: fixed; left: 0; top: 0; height: 100%; transform: translateX(-100%); z-index: 100; }
  #sidebar.open { transform: translateX(0); }
  #page-content { padding: 16px; padding-top: 58px; }
  .stock-layout { grid-template-columns: 1fr; }
  .g2, .g3 { grid-template-columns: 1fr; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .dash-right { grid-template-columns: 1fr; }
  #fab-container { bottom: 20px; right: 20px; }
  .g4 { grid-template-columns: repeat(2,1fr); }
}
@media (max-width: 480px) {
  .g4 { grid-template-columns: 1fr 1fr; }
  .page-title { font-size: 1.3rem; }
}

/* =============================================
   Calendar Page & Daily Detail CSS
   ============================================= */
.cal-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.cal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-2);
  border: 1px solid var(--border);
  padding: 14px 20px;
  border-radius: var(--radius-m);
}
.cal-month-nav {
  display: flex;
  align-items: center;
  gap: 12px;
}
.cal-month-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-1);
  min-width: 140px;
  text-align: center;
}
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 10px;
}
.cal-grid-header {
  text-align: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase;
  padding: 5px 0;
  letter-spacing: 1px;
}
.cal-day-cell {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  min-height: 100px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  cursor: pointer;
  transition: all var(--tr);
  position: relative;
}
.cal-day-cell:hover {
  border-color: var(--gold);
  transform: translateY(-2px);
}
.cal-day-cell.other-month {
  opacity: 0.35;
  background: rgba(255,255,255,0.01);
}
.cal-day-cell.today {
  border: 2px solid var(--gold);
  background: rgba(245,166,35,0.04);
}
.cal-day-num {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-2);
}
.cal-day-cell.today .cal-day-num {
  color: var(--gold-light);
}
.cal-day-indicators {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: auto;
}
.cal-ind-study {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.68rem;
  color: var(--green-light);
  font-weight: 600;
}
.cal-ind-study::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  display: inline-block;
}
.cal-ind-notes {
  background: rgba(60,105,250,0.15);
  color: var(--gold-light);
  border: 1px solid rgba(60,105,250,0.3);
  font-size: 0.65rem;
  padding: 1px 5px;
  border-radius: 4px;
  width: max-content;
  font-weight: 600;
}
.cal-ind-tasks {
  background: rgba(255,255,255,0.05);
  color: var(--text-2);
  border: 1px solid var(--border);
  font-size: 0.65rem;
  padding: 1px 5px;
  border-radius: 4px;
  width: max-content;
  font-weight: 600;
}

.cal-layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 20px;
  align-items: start;
}
@media (max-width: 1024px) {
  .cal-layout {
    grid-template-columns: 1fr;
  }
}

.cal-day-cell.selected {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 2px rgba(79, 142, 247, 0.3);
  background: rgba(79, 142, 247, 0.03);
}

.cal-cell-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

.cal-cell-points {
  font-size: 0.72rem;
  color: var(--gold-light);
  font-weight: 700;
}

.cal-mini-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin-top: auto;
  min-height: 18px;
}

.cal-mini-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 1px 4px;
  font-size: 0.65rem;
  font-weight: 700;
  border-radius: 3px;
  line-height: 1.1;
}
.cal-mini-badge-blue { background: rgba(245,166,35,0.15); color: var(--gold-light); border: 1px solid rgba(245,166,35,0.3); }
.cal-mini-badge-green { background: rgba(16,185,129,0.15); color: var(--green-light); border: 1px solid rgba(16,185,129,0.3); }
.cal-mini-badge-purple { background: rgba(245,166,35,0.15); color: var(--gold-light); border: 1px solid rgba(245,166,35,0.3); }
.cal-mini-badge-orange { background: rgba(249,115,22,0.15); color: #fdba74; border: 1px solid rgba(249,115,22,0.3); }
.cal-mini-badge-cyan { background: rgba(139,157,181,0.15); color: var(--text-2); border: 1px solid rgba(139,157,181,0.3); }
.cal-mini-badge-teal { background: rgba(20,184,166,0.15); color: #2dd4bf; border: 1px solid rgba(20,184,166,0.3); }
.cal-mini-badge-gold { background: rgba(245,166,35,0.15); color: var(--gold-light); border: 1px solid rgba(245,166,35,0.3); }
.cal-mini-badge-pink { background: rgba(236,72,153,0.15); color: #f472b6; border: 1px solid rgba(236,72,153,0.3); }
.cal-mini-badge-red { background: rgba(239,68,68,0.15); color: var(--red-light); border: 1px solid rgba(239,68,68,0.3); }

/* Daily Detail Sub-view styles */
.dd-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
  animation: pageFade 0.2s ease;
}
.dd-back-btn {
  width: max-content;
}
.dd-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 20px;
}
@media (max-width: 992px) {
  .dd-grid {
    grid-template-columns: 1fr;
  }
}
.dd-section {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.dd-section-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-1);
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}

/* Learning Notes Page styles */
.notes-filter-bar {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  padding: 16px 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}
.notes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 18px;
  margin-top: 18px;
}
@media (max-width: 480px) {
  .notes-grid {
    grid-template-columns: 1fr;
  }
}
.note-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  cursor: pointer;
  transition: all var(--tr);
}
.note-card:hover {
  border-color: var(--border-hov);
  transform: translateY(-2px);
  box-shadow: var(--shadow-m);
}
.note-card-hd {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}
.note-card-topic {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-1);
  line-height: 1.4;
}
.note-card-date {
  font-size: 0.72rem;
  color: var(--text-3);
}
.note-card-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.note-card-summary {
  font-size: 0.82rem;
  color: var(--text-2);
  background: var(--bg-0);
  border-radius: var(--radius-s);
  padding: 8px 12px;
  border-left: 3px solid var(--gold);
}
.note-card-companies {
  font-size: 0.78rem;
  color: var(--text-3);
  display: flex;
  align-items: center;
  gap: 4px;
}
.note-card-companies strong {
  color: var(--gold-light);
}

/* Detail Form Section Styles */
.form-section-header {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--gold-light);
  border-bottom: 1px dashed var(--border);
  padding-bottom: 4px;
  margin-top: 14px;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.form-section-header:first-child {
  margin-top: 0;
}

/* =============================================
   Life OS Custom Added Styles
   ============================================= */

/* Accordion */
.accordion-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  margin-bottom: 12px;
  overflow: hidden;
  background: var(--bg-2);
}
.accordion-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  cursor: pointer;
  font-weight: 600;
  user-select: none;
  background: rgba(255,255,255,0.01);
  transition: background var(--tr);
}
.accordion-header:hover {
  background: rgba(255,255,255,0.03);
}
.accordion-header.active {
  border-bottom: 1px solid var(--border);
  background: rgba(245,166,35,0.03);
}
.accordion-header .chevron {
  transition: transform var(--tr);
}
.accordion-header.active .chevron {
  transform: rotate(90deg);
}
.accordion-body {
  padding: 18px;
  display: none;
  background: var(--bg-1);
}
.accordion-body.show {
  display: block;
}

/* Habit Check-In */
.habit-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
}
.habit-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px 12px;
  border-radius: var(--radius-m);
  border: 1px solid var(--border);
  background: var(--bg-2);
  color: var(--text-2);
  cursor: pointer;
  transition: all var(--tr);
  text-align: center;
  gap: 6px;
  position: relative;
}
.habit-btn:hover {
  border-color: var(--border-hov);
  transform: translateY(-2px);
}
.habit-btn.completed {
  background: linear-gradient(135deg, rgba(16,185,129,0.15), rgba(16,185,129,0.03));
  border-color: var(--green);
  color: var(--green-light);
}
.habit-btn.completed .habit-icon {
  transform: scale(1.15);
}
.habit-points-badge {
  font-size: 0.65rem;
  padding: 2px 6px;
  border-radius: 10px;
  background: var(--bg-0);
  border: 1px solid var(--border);
  font-weight: 700;
}
.habit-btn.completed .habit-points-badge {
  border-color: rgba(16,185,129,0.3);
  background: rgba(16,185,129,0.2);
  color: #fff;
}

/* Tasks with Priorities */
.task-item-card {
  border-left: 4px solid var(--text-3);
  padding-left: 12px;
}
.task-priority-high { border-left-color: var(--red); }
.task-priority-medium { border-left-color: var(--gold); }
.task-priority-low { border-left-color: var(--gold); }

.task-overdue-tag {
  color: var(--red-light);
  font-weight: 700;
  font-size: 0.72rem;
  background: rgba(239,68,68,0.1);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid rgba(239,68,68,0.2);
}

/* Prose (Markdown styling) */
.prose {
  color: #d1d5db;
  line-height: 1.7;
}
.prose h1, .prose h2, .prose h3, .prose h4 {
  color: var(--text-1);
  margin-top: 1.5em;
  margin-bottom: 0.5em;
  font-weight: 700;
}
.prose h1 { font-size: 1.4rem; border-bottom: 1px solid var(--border); padding-bottom: 6px; }
.prose h2 { font-size: 1.2rem; }
.prose h3 { font-size: 1.05rem; }
.prose p { margin-bottom: 1em; }
.prose ul, .prose ol {
  margin-left: 1.5em;
  margin-bottom: 1em;
  list-style: initial;
}
.prose li { margin-bottom: 0.25em; }
.prose code {
  background: var(--bg-0);
  padding: 2px 5px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.85em;
  color: var(--gold-light);
}
.prose pre {
  background: var(--bg-0);
  padding: 14px;
  border-radius: var(--radius-m);
  overflow-x: auto;
  margin-bottom: 1em;
  border: 1px solid var(--border);
}
.prose pre code {
  background: none;
  padding: 0;
  color: inherit;
}
.prose blockquote {
  border-left: 4px solid var(--gold);
  padding-left: 14px;
  color: var(--text-2);
  font-style: italic;
  margin-bottom: 1em;
}
.prose a {
  color: var(--gold-light);
  text-decoration: underline;
}

/* Charts */
.chart-box {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  padding: 20px;
  height: 320px;
  position: relative;
}

/* Reward item card */
.reward-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
  transition: all var(--tr);
}
.reward-card.available {
  border-color: rgba(245,166,35,0.4);
  background: rgba(245,166,35,0.02);
}
.reward-card.redeemed {
  opacity: 0.5;
  border-color: rgba(16,185,129,0.3);
  background: rgba(16,185,129,0.01);
}

/* =============================================
   💰 Finance Module Custom CSS
   ============================================= */
.finance-tabs {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 22px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.finance-tab-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-2);
  padding: 8px 16px;
  border-radius: var(--radius-m);
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--tr);
}
.finance-tab-btn:hover {
  background: var(--bg-3);
  color: var(--text-1);
}
.finance-tab-btn.active {
  background: var(--bg-3);
  color: var(--gold-light);
  border-color: rgba(245,166,35,0.25);
  box-shadow: var(--shadow-s);
}

.finance-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}
.finance-kpi-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  padding: 16px;
  position: relative;
  transition: border-color var(--tr);
}
.finance-kpi-card:hover {
  border-color: var(--border-hov);
}
.finance-kpi-title {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}
.finance-kpi-value {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text-1);
  line-height: 1.2;
}
.finance-kpi-sub {
  font-size: 0.72rem;
  color: var(--text-3);
  margin-top: 4px;
}

.finance-charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-bottom: 22px;
}
@media (max-width: 900px) {
  .finance-charts-grid {
    grid-template-columns: 1fr;
  }
}

.finance-table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  background: var(--bg-2);
  margin-bottom: 22px;
}
.finance-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.84rem;
}
.finance-table th {
  background: var(--bg-3);
  padding: 12px 16px;
  font-weight: 700;
  color: var(--text-2);
  border-bottom: 1px solid var(--border);
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.5px;
}
.finance-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-1);
}
.finance-table tr:last-child td {
  border-bottom: none;
}
.finance-table tr:hover td {
  background: rgba(255,255,255,0.01);
}

.finance-nested-detail {
  background: var(--bg-0);
  padding: 16px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.finance-detail-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--gold-light);
  margin-bottom: 8px;
}

.grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}

/* =============================================
   Goals & Subtasks Checklist Enhancements
   ============================================= */
.goals-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px;
  margin-bottom: 20px;
}
@media (max-width: 768px) {
  .goals-grid {
    grid-template-columns: 1fr;
  }
}

.goal-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
  margin-bottom: 12px;
}

.subtask-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
  margin-bottom: 10px;
  padding-left: 2px;
}

.subtask-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  padding: 2px 0;
  transition: opacity var(--tr);
}

.subtask-item.completed {
  opacity: 0.5;
}

.subtask-item.completed .subtask-text {
  text-decoration: line-through;
  color: var(--text-2);
}

.subtask-text {
  flex: 1;
  color: var(--text-1);
}

.subtask-weight-badge {
  font-size: 0.68rem;
  color: var(--text-3);
  margin-left: 4px;
}

.subtasks-warning {
  padding: 8px 12px;
  background: rgba(245,166,35,0.08);
  border: 1px dashed rgba(245,166,35,0.3);
  border-radius: var(--radius-m);
  color: var(--gold-light);
  font-size: 0.75rem;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.subtask-editor-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 250px;
  overflow-y: auto;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  background: var(--bg-0);
  margin-bottom: 12px;
}

.subtask-editor-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px;
  background: var(--bg-2);
  border-radius: var(--radius-s);
  border: 1px solid var(--border);
}

.subtask-editor-row input[type="text"] {
  flex: 1;
  font-size: 0.8rem;
  padding: 4px 8px;
}

.subtask-editor-row input[type="number"] {
  width: 60px;
  font-size: 0.8rem;
  padding: 4px;
  text-align: center;
}

.goal-card-item {
  background: var(--bg-3);
  border-radius: var(--radius-m);
  padding: 12px;
  border: 1px solid var(--border);
  transition: all var(--tr);
  cursor: pointer;
  margin-bottom: 10px;
}
.goal-card-item:hover {
  border-color: var(--border-hov);
  transform: translateY(-1px);
}

.goal-title-link {
  font-weight: 700;
  color: var(--text-1);
  font-size: 0.88rem;
  transition: color var(--tr);
}
.goal-title-link:hover {
  color: var(--gold-light);
}

.progress-mode-selector {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
}
.slider-container {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  padding: 8px 12px;
  background: var(--bg-0);
  border-radius: var(--radius-m);
  border: 1px solid var(--border);
}
.slider-container input[type="range"] {
  flex: 1;
  cursor: pointer;
}

/* =============================================
   DAILY CHECK-IN (模組A)
   ============================================= */
.checkin-card { border-color: rgba(16,185,129,0.2); }
.checkin-card-compact {
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 10px 0 14px;
}
.checkin-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}
.checkin-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.checkin-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-1);
}
.checkin-seg {
  display: flex;
  gap: 4px;
  background: var(--bg-0);
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  padding: 3px;
}
.checkin-opt {
  border: none;
  background: transparent;
  color: var(--text-3);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: var(--radius-s);
  cursor: pointer;
  transition: all var(--tr);
}
.checkin-opt:hover { color: var(--text-1); }
.checkin-opt.is-full {
  background: linear-gradient(135deg, rgba(16,185,129,0.25), rgba(16,185,129,0.08));
  color: var(--green-light);
}
.checkin-opt.is-min {
  background: rgba(245,166,35,0.18);
  color: var(--gold-light);
}
.checkin-opt.is-none {
  background: rgba(255,255,255,0.06);
  color: var(--text-2);
}
.checkin-mood-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.mood-picker { display: flex; gap: 4px; }
.mood-btn {
  border: 1px solid var(--border);
  background: var(--bg-0);
  border-radius: var(--radius-s);
  font-size: 1rem;
  line-height: 1;
  padding: 5px 7px;
  cursor: pointer;
  opacity: 0.5;
  transition: all var(--tr);
}
.mood-btn:hover { opacity: 0.8; }
.mood-btn.active {
  opacity: 1;
  border-color: var(--gold);
  background: var(--gold-dim);
  transform: scale(1.1);
}

/* Calendar heatmap intensity (die map 隱喻：完成度越高越亮) */
.cal-day-cell.heat-1 { background: rgba(16,185,129,0.06); }
.cal-day-cell.heat-2 { background: rgba(16,185,129,0.13); border-color: rgba(16,185,129,0.25); }
.cal-day-cell.heat-3 { background: rgba(16,185,129,0.22); border-color: rgba(16,185,129,0.4); }



/* Phase 2 visual system */
body { font-size: 14px; font-weight: 400; background: var(--bg-1); }
#sidebar { background: var(--bg-1); }
.page-title { font-size: 20px; font-weight: 700; }
.card, .chart-box, .finance-kpi-card, .reward-card { background: var(--bg-2); border-radius: var(--radius-m); }
.card-title, .form-section-header { font-size: 15px; font-weight: 600; }
.page-desc, .text-xs, .finance-kpi-sub { font-size: 12px; font-weight: 400; }
.finance-kpi-value, .weekly-number strong { font-size: 24px; font-weight: 700; }
.btn, input, textarea, select, .form-input, .form-select, .form-textarea, .nav-link, .btn-sidebar-action { border-radius: var(--radius-s); }
input:focus, textarea:focus, select:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.nav-icon, #modal-close svg, #fab-icon svg { width: 24px; height: 24px; display: block; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.nav-icon { display: inline-flex; align-items: center; justify-content: center; }
#modal-close { display: inline-flex; align-items: center; justify-content: center; }
#fab-btn { box-shadow: var(--shadow-m); background: var(--gold); }
#fab-btn:hover { box-shadow: var(--shadow-l); }
.btn-primary { box-shadow: var(--shadow-s); }
.btn-primary:hover { box-shadow: var(--shadow-m); }
.weekly-number { background: var(--bg-3); border-radius: var(--radius-s); padding: 14px; display: flex; flex-direction: column; gap: 2px; }
.weekly-number span { color: var(--text-2); font-size: 12px; }
.text-blue, .text-purple, .text-cyan { color: var(--gold) !important; }
.badge-blue, .badge-purple, .badge-cyan { color: var(--gold-light); background: var(--gold-dim); border-color: rgba(245,166,35,.25); }
.cal-mini-badge { background: var(--bg-3) !important; border-color: var(--border) !important; color: var(--text-2) !important; }
.cal-mini-badge-green, .cal-mini-badge-red { color: inherit !important; }

/* =============================================
   Modern financial themes
   ============================================= */
:root,
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg-0: #090c12;
  --bg-1: #0c1017;
  --bg-2: #121823;
  --bg-3: #192231;
  --border: rgba(180, 195, 218, 0.11);
  --border-hov: rgba(223, 183, 105, 0.34);
  --gold: #d7a84e;
  --gold-light: #ebc778;
  --gold-dim: rgba(215, 168, 78, 0.13);
  --green: #2eaa79;
  --green-light: #52c596;
  --red: #d75d65;
  --red-light: #eb7b82;
  --text-1: #edf1f7;
  --text-2: #9ca9ba;
  --text-3: #657286;
  --sidebar-w: 232px;
  --shadow-s: 0 1px 2px rgba(0,0,0,.22);
  --shadow-m: 0 8px 24px rgba(0,0,0,.2);
  --shadow-l: 0 16px 40px rgba(0,0,0,.24);
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg-0: #e8edf3;
  --bg-1: #f4f6f9;
  --bg-2: #ffffff;
  --bg-3: #edf1f6;
  --border: rgba(31, 43, 59, 0.12);
  --border-hov: rgba(155, 109, 28, 0.38);
  --gold: #a87318;
  --gold-light: #895b0c;
  --gold-dim: rgba(168, 115, 24, 0.11);
  --green: #167a58;
  --green-light: #126647;
  --red: #b43c46;
  --red-light: #a92e39;
  --text-1: #182230;
  --text-2: #536174;
  --text-3: #7a8797;
  --shadow-s: 0 1px 2px rgba(28,39,53,.08);
  --shadow-m: 0 8px 24px rgba(28,39,53,.09);
  --shadow-l: 0 16px 40px rgba(28,39,53,.12);
}

body, #main, #sidebar, .card, .chart-box, .finance-kpi-card, .reward-card,
.weekly-number, input, textarea, select, button {
  transition: background-color .2s ease, border-color .2s ease, color .2s ease, box-shadow .2s ease;
}

#page-content { max-width: 1240px; padding: 30px 34px 48px; }
#sidebar { border-right-color: var(--border); }
.sidebar-logo { padding: 20px 18px; }
.logo-icon {
  width: 34px; height: 34px; border-radius: 8px; font-size: 16px;
  background: var(--gold); color: #11151b; box-shadow: none;
}
.logo-title { font-size: .94rem; font-weight: 700; }
.nav-section { padding: 18px 10px 8px; }
.nav-section-label { font-size: 10px; letter-spacing: .1em; }
.nav-link { min-height: 42px; padding: 9px 11px; border: 1px solid transparent; }
.nav-link.active { background: var(--gold-dim); border-color: rgba(215,168,78,.28); }
.sidebar-footer { padding: 14px; }

.theme-switch {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px;
  padding: 4px; margin-bottom: 6px; border: 1px solid var(--border);
  border-radius: var(--radius-s); background: var(--bg-0);
}
.theme-choice {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 34px; border: 0; border-radius: 4px; cursor: pointer;
  background: transparent; color: var(--text-3); font-size: 12px; font-weight: 600;
}
.theme-choice svg {
  width: 16px; height: 16px; fill: none; stroke: currentColor;
  stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round;
}
.theme-choice:hover { color: var(--text-1); }
.theme-choice.active { color: var(--gold-light); background: var(--bg-2); box-shadow: var(--shadow-s); }

.page-header { margin-bottom: 24px; }
.page-title { letter-spacing: -.025em; }
.page-desc { margin-top: 3px; }
.card, .chart-box, .finance-kpi-card, .reward-card {
  border-color: var(--border); box-shadow: var(--shadow-s);
}
.card:hover { border-color: var(--border-hov); }
.weekly-numbers { padding: 18px 20px; }
.weekly-numbers .g3 { gap: 0; }
.weekly-number {
  min-height: 88px; justify-content: center; padding: 10px 18px;
  border-right: 1px solid var(--border); border-radius: 0; background: transparent;
}
.weekly-number:last-child { border-right: 0; }
.weekly-number strong { color: var(--gold-light); letter-spacing: -.03em; }
.checkin-card { border-color: var(--border); }
.checkin-row { min-height: 44px; padding: 2px 0; border-bottom: 1px solid var(--border); }
.checkin-row:last-child { border-bottom: 0; }
.checkin-seg { background: var(--bg-0); }
.goals-grid { gap: 14px; }
.goal-card-item { background: transparent; margin-bottom: 7px; }
.finance-kpi-grid { gap: 12px; }
.finance-kpi-card { min-height: 116px; padding: 18px; }
.finance-kpi-value { letter-spacing: -.04em; }
#fab-btn { width: 52px; height: 52px; background: var(--gold); color: #15120c; }

:root[data-theme="light"] #sidebar { background: #eef2f6; }
:root[data-theme="light"] .nav-link.active { border-color: rgba(168,115,24,.28); }
:root[data-theme="light"] .checkin-opt.is-none { background: rgba(31,43,59,.06); }
:root[data-theme="light"] table thead { background: var(--bg-3); }
:root[data-theme="light"] #modal-overlay { background: rgba(20,28,39,.38); }
:root[data-theme="light"] .chart-box canvas { filter: saturate(.9) contrast(.98); }

@media (max-width: 760px) {
  #page-content { padding: 68px 16px 28px; }
  .weekly-number { border-right: 0; border-bottom: 1px solid var(--border); }
  .weekly-number:last-child { border-bottom: 0; }
}

/* =============================================
   Sync 面板
   ============================================= */
.sync-info { font-size: 0.68rem; text-align: center; margin-bottom: 2px; color: var(--text-3); }
.sync-ok   { color: var(--green-light); }
.sync-warn { color: var(--gold-light); }
.sync-err  { color: var(--red-light); }

.sync-step { border: 1px solid var(--border); border-radius: var(--radius-m); margin-bottom: 10px; background: var(--bg-3); }
.sync-step > summary {
  padding: 13px 14px; cursor: pointer; font-size: 0.85rem; font-weight: 600;
  display: flex; align-items: center; gap: 9px; list-style: none;
  border-radius: var(--radius-m); user-select: none;
}
.sync-step > summary::-webkit-details-marker { display: none; }
.sync-step[open] > summary { border-bottom: 1px solid var(--border); border-radius: var(--radius-m) var(--radius-m) 0 0; }
.sync-step-n {
  flex-shrink: 0; width: 22px; height: 22px; border-radius: 50%;
  background: var(--bg-0); border: 1px solid var(--border); color: var(--text-3);
  font-size: 0.72rem; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}
.sync-step-n.done { background: var(--green); border-color: var(--green); color: #04120c; }
.sync-badge {
  margin-left: auto; font-size: 0.65rem; font-weight: 600; padding: 3px 9px;
  border-radius: 12px; background: var(--bg-0); color: var(--text-3); border: 1px solid var(--border);
  max-width: 52%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sync-badge.ok { background: rgba(16,185,129,0.14); color: var(--green-light); border-color: rgba(16,185,129,0.3); }
.sync-step-body { padding: 14px; }
.sync-step-body .form-group:last-of-type { margin-bottom: 12px; }

/* =============================================
   Mobile / PWA
   手機專用層。桌機版樣式完全不受影響——
   以下所有規則都包在 max-width 或 hover 能力查詢裡。
   ============================================= */

:root {
  --tabbar-h: 58px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

/* 底部導覽列:桌機隱藏 */
#mobile-tabbar { display: none; }

/* 觸控裝置沒有滑鼠停留,把 hover 特效關掉,
   否則點完會「卡」在 hover 狀態直到點別處 */
@media (hover: none) {
  .nav-link:hover,
  .btn:hover,
  .fab-item:hover,
  .btn-sidebar-action:hover,
  .finance-table tr:hover td { background: inherit; transform: none; }
  #fab-btn:hover { transform: none; }
  .fab-item:hover { transform: none; }
}

@media (max-width: 768px) {
  /* --- 高度:用 dvh,避免 iOS 網址列收合時底部被切掉 --- */
  #app { height: 100vh; height: 100dvh; }
  body { min-height: 100vh; min-height: 100dvh; }

  /* --- 版面留白:上方讓開選單鈕,下方讓開導覽列與 home indicator --- */
  #page-content {
    padding: 60px 16px calc(var(--tabbar-h) + var(--safe-b) + 24px);
    padding-left: max(16px, var(--safe-l));
    padding-right: max(16px, var(--safe-r));
  }

  /* 任何格線子項都不准撐破容器(修資產頁溢出 9px 的 card) */
  #page-content .card,
  #page-content .g2 > *, #page-content .g3 > *, #page-content .g4 > *,
  #page-content .grid-3 > *, #page-content .dash-grid > *,
  #page-content .goals-grid > *, #page-content .finance-kpi-grid > * {
    min-width: 0;
    max-width: 100%;
  }

  /* --- 底部導覽列 --- */
  #mobile-tabbar {
    display: flex;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 150;
    height: calc(var(--tabbar-h) + var(--safe-b));
    padding-bottom: var(--safe-b);
    background: color-mix(in srgb, var(--bg-2) 92%, transparent);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
  }
  @supports not (background: color-mix(in srgb, red 50%, blue)) {
    #mobile-tabbar { background: var(--bg-2); }
  }
  .tabbar-btn {
    flex: 1 1 0; min-width: 0;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px; padding: 6px 2px;
    background: none; border: 0; cursor: pointer;
    color: var(--text-3); font-size: 0.62rem; font-weight: 600; letter-spacing: 0.2px;
    -webkit-tap-highlight-color: transparent;
    transition: color var(--tr);
  }
  .tabbar-btn svg {
    width: 21px; height: 21px;
    fill: none; stroke: currentColor; stroke-width: 1.8;
    stroke-linecap: round; stroke-linejoin: round;
  }
  .tabbar-btn span { white-space: nowrap; }
  .tabbar-btn.active { color: var(--gold-light); }
  .tabbar-btn:active { opacity: 0.6; }

  /* --- 選單鈕:放大到手指按得到,並避開瀏海 --- */
  #sidebar-toggle {
    top: max(10px, var(--safe-t)); left: max(10px, var(--safe-l));
    min-width: 44px; min-height: 44px;
    align-items: center; justify-content: center;
    -webkit-tap-highlight-color: transparent;
  }
  #sidebar {
    width: min(84vw, 300px); min-width: 0;
    padding-top: var(--safe-t); padding-bottom: var(--safe-b);
  }

  /* --- 點擊區塊:一律至少 44px 高(Apple/Google 建議值) --- */
  .btn,
  .checkin-opt,
  .mood-btn,
  .finance-tab-btn,
  .fab-item,
  .theme-choice,
  .btn-sidebar-action,
  .nav-link,
  #modal-footer button {
    min-height: 44px;
    display: inline-flex; align-items: center; justify-content: center;
  }
  .checkin-opt, .mood-btn { min-width: 44px; }
  #modal-close, #sidebar-toggle { min-width: 44px; min-height: 44px; }
  /* 表格內的小按鈕例外:全放大會讓每列高得誇張 */
  .finance-table .btn { min-height: 34px; padding-top: 4px; padding-bottom: 4px; }

  /* --- 輸入框:字級 <16px 時 iOS Safari 會自動放大整頁 --- */
  input, select, textarea,
  .form-input, .form-select, .form-textarea {
    font-size: 16px;
    min-height: 44px;
  }
  textarea, .form-textarea { min-height: 88px; }

  /* --- 寬表格:給明確的橫向捲動與慣性,並在右緣提示還有內容 --- */
  .finance-table-wrapper {
    position: relative;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    scrollbar-width: thin;
  }
  .finance-table-wrapper::after {
    content: '';
    position: sticky; top: 0; right: 0; float: right;
    width: 24px; height: 100%; margin-left: -24px;
    background: linear-gradient(to right, transparent, var(--bg-2));
    pointer-events: none;
  }
  .finance-table th, .finance-table td {
    padding: 11px 12px;
    white-space: nowrap;
  }

  /* --- FAB:抬到導覽列上方,不要疊在一起 --- */
  #fab-container {
    bottom: calc(var(--tabbar-h) + var(--safe-b) + 16px);
    right: max(16px, var(--safe-r));
  }
  #fab-btn { width: 56px; height: 56px; }

  /* --- Modal:手機改成從底部升起的面板,比置中彈窗好按 --- */
  #modal-overlay { padding: 0; align-items: flex-end; }
  #modal-box {
    width: 100%; max-width: 100%;
    max-height: 88dvh;
    border-radius: var(--radius-m) var(--radius-m) 0 0;
    padding-bottom: var(--safe-b);
    /* 底部面板要用「往上滑」,原本的置中縮放在貼底時看起來會歪 */
    animation: modalSheetIn 0.24s cubic-bezier(0.32, 0.72, 0, 1);
  }
  @keyframes modalSheetIn {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
  }

  /* 側欄開啟時鎖住背景捲動 */
  #sidebar-overlay.visible { touch-action: none; }

  /* --- 本週數字:三個值都很短,橫排剛好 --- */
  /* 原本 .g3 在這個斷點被收成單欄,三個數字上下疊,右邊一大片空白。 */
  .weekly-numbers { padding: 14px 8px; }
  .weekly-numbers .g3 { grid-template-columns: repeat(3, 1fr); gap: 0; }
  .weekly-number {
    min-height: 0; padding: 10px 4px;
    align-items: center; text-align: center;
    border-right: 1px solid var(--border); border-bottom: 0;
  }
  .weekly-number:last-child { border-right: 0; }
  .weekly-number strong { font-size: 20px; }
  .weekly-number span { font-size: 10.5px; line-height: 1.35; }

  /* --- 日曆:格子改成正方形 --- */
  /* 原本 min-height:100px 讓每格變成 41x100 的高瘦矩形,六列就吃掉 600px。
     改成正方形只剩約 44x44,整頁高度少一半以上。
     格子裡的健身標記與積分改到下方「當日詳情」面板看——點某一天就會出現,
     那裡空間夠,不必硬塞進 44px 的方格。 */
  #calendar-view-pane { padding: 8px !important; }
  .cal-grid { gap: 4px; }
  .cal-day-cell {
    min-height: 0;
    aspect-ratio: 1;
    padding: 0;
    gap: 0;
    align-items: center; justify-content: center;
    border-radius: var(--radius-s);
  }
  .cal-day-cell .cal-cell-points,
  .cal-day-cell .cal-mini-badges,
  .cal-day-cell .cal-day-indicators { display: none; }
  .cal-day-cell .cal-cell-header {
    width: 100%; height: 100%;
    display: flex; align-items: center; justify-content: center;
  }
  .cal-day-num { font-size: 0.9rem; }
  .cal-grid-header { font-size: 0.62rem; padding: 2px 0; letter-spacing: 0; }
  /* 當日/選取狀態原本用 2px 邊框,在小方格上會擠掉數字,改用內陰影 */
  .cal-day-cell.today { border-width: 1px; box-shadow: inset 0 0 0 2px var(--gold); }

  /* --- 寬表格改成一列一張卡,不用左右拉 --- */
  .stacked-on-mobile thead { display: none; }
  .stacked-on-mobile, .stacked-on-mobile tbody, .stacked-on-mobile tr, .stacked-on-mobile td { display: block; width: 100%; }
  .stacked-on-mobile tr {
    background: var(--bg-3); border: 1px solid var(--border);
    border-radius: var(--radius-s); padding: 10px 12px; margin-bottom: 8px;
  }
  .stacked-on-mobile td {
    display: flex; align-items: baseline; justify-content: space-between;
    gap: 12px; padding: 3px 0 !important; border: 0 !important;
  }
  .stacked-on-mobile td::before {
    content: attr(data-label);
    color: var(--text-3); font-size: 0.72rem; flex-shrink: 0;
  }
  .stacked-on-mobile td[colspan] { justify-content: center; }
  .stacked-on-mobile td[colspan]::before { content: none; }

  /* 分頁列在窄螢幕要能橫向捲，不然分頁會被裁掉 */
  .tab-bar { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .tab-bar::-webkit-scrollbar { display: none; }
}

/* 圖表沒資料時的說明（取代原本畫在 canvas 上、會被裁掉的文字） */
.chart-box { position: relative; }
.chart-empty {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; padding: 20px; text-align: center;
}
.chart-empty p { color: var(--text-2); font-size: 0.88rem; font-weight: 600; }
.chart-empty .chart-empty-hint { color: var(--text-3); font-size: 0.75rem; font-weight: 400; line-height: 1.6; }
.chart-empty.hidden, canvas.hidden { display: none; }

@media (max-width: 480px) {
  :root { --tabbar-h: 56px; }
  .tabbar-btn { font-size: 0.6rem; }
  .tabbar-btn svg { width: 20px; height: 20px; }
  #page-content { padding-left: max(12px, var(--safe-l)); padding-right: max(12px, var(--safe-r)); }
}

/* 橫躺時螢幕很矮,導覽列改矮一點免得吃掉整個畫面 */
@media (max-width: 900px) and (orientation: landscape) and (max-height: 500px) {
  :root { --tabbar-h: 46px; }
  .tabbar-btn span { display: none; }
}