/* ===== Reset & Base ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --bg: #F2F2F7;
  --bg-card: #FFFFFF;
  --text: #1C1C1E;
  --text-2: #3C3C43;
  --text-3: #8E8E93;
  --sep: rgba(60,60,67,0.12);
  --shadow: rgba(0,0,0,0.07);
  --radius: 16px;

  --c-home:     #007AFF;
  --c-brain:    #5856D6;
  --c-finance:  #34C759;
  --c-crossfit: #FF9500;
  --c-family:   #FF2D55;

  --nav-h: 56px;
  --header-h: 56px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;
  font-size: 16px;
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 430px;
  margin: 0 auto;
  position: relative;
  overflow: hidden;
}

/* ===== Header ===== */
#app-header {
  background: rgba(242,242,247,0.9);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--sep);
  padding-top: var(--safe-top);
  position: relative;
  z-index: 100;
  flex-shrink: 0;
}

.header-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 20px;
  height: var(--header-h);
}

#header-title {
  font-size: 19px;
  font-weight: 700;
  color: var(--text);
}

#header-date {
  font-size: 12px;
  color: var(--text-3);
  text-align: left;
  direction: rtl;
}

/* ===== Main ===== */
#app-main {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

.page {
  padding: 16px 16px calc(var(--nav-h) + var(--safe-bottom) + 80px);
  min-height: 100%;
  animation: fadeUp 0.22s ease-out;
}

.page.hidden { display: none; }

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

/* ===== Cards ===== */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: 0 1px 4px var(--shadow);
}

.card-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-3);
  margin-bottom: 10px;
}

/* ===== Section header ===== */
.sec-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.sec-title {
  font-size: 22px;
  font-weight: 700;
}

/* ===== Greeting ===== */
.greeting {
  padding: 4px 0 18px;
}

.greeting-name {
  font-size: 26px;
  font-weight: 700;
  line-height: 1.2;
}

.greeting-sub {
  font-size: 14px;
  color: var(--text-3);
  margin-top: 3px;
}

/* ===== Insights ===== */
.insight-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  margin-bottom: 6px;
  cursor: default;
}
.insight-row:last-child { margin-bottom: 0; }
.insight-neutral  { background: #F2F2F7; }
.insight-good     { background: #34C75912; }
.insight-warning  { background: #FF950015; }
.insight-urgent   { background: #FF3B3012; }
.insight-action   { background: #007AFF10; cursor: pointer; }
.insight-icon     { font-size: 20px; flex-shrink: 0; }
.insight-text     { flex: 1; font-size: 14px; line-height: 1.4; }

/* ===== Stats grid ===== */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: 0 1px 4px var(--shadow);
  cursor: pointer;
  transition: transform 0.15s;
  -webkit-user-select: none;
  user-select: none;
}

.stat-card:active { transform: scale(0.96); }

.stat-icon { font-size: 22px; margin-bottom: 6px; }
.stat-value { font-size: 22px; font-weight: 700; }
.stat-label { font-size: 12px; color: var(--text-3); margin-top: 2px; }

/* ===== Task items ===== */
.task-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--sep);
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}

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

.task-item.done .task-text {
  text-decoration: line-through;
  color: var(--text-3);
}

.task-check {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid #C7C7CC;
  flex-shrink: 0;
  margin-top: 1px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.task-check.checked {
  background: var(--c-home);
  border-color: var(--c-home);
}

.task-check.checked::after {
  content: '';
  width: 5px;
  height: 9px;
  border: 2.5px solid white;
  border-top: none;
  border-right: none;
  transform: rotate(-45deg) translateY(-1px);
}

.task-body { flex: 1; min-width: 0; }
.task-text { font-size: 15px; line-height: 1.4; }
.task-meta { font-size: 12px; color: var(--text-3); margin-top: 2px; }

.task-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  flex-shrink: 0;
  align-self: flex-start;
  margin-top: 2px;
}

.badge-high   { background: #FF3B3018; color: #FF3B30; }
.badge-medium { background: #FF950018; color: #FF9500; }
.badge-low    { background: #34C75918; color: #34C759; }

/* ===== Category tabs ===== */
.cat-tabs {
  display: flex;
  gap: 7px;
  margin-bottom: 14px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
  -webkit-user-select: none;
  user-select: none;
}

.cat-tabs::-webkit-scrollbar { display: none; }

.cat-tab {
  padding: 7px 16px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 500;
  border: none;
  cursor: pointer;
  white-space: nowrap;
  background: var(--bg-card);
  color: var(--text-3);
  transition: all 0.18s;
  font-family: inherit;
  box-shadow: 0 1px 3px var(--shadow);
}

.cat-tab.active {
  background: var(--active-color, var(--c-brain));
  color: white;
}

/* ===== Brain — Things 3 style ===== */
.brain-tabs-wrap {
  overflow-x: auto;
  scrollbar-width: none;
  padding: 10px 16px 0;
}
.brain-tabs-wrap::-webkit-scrollbar { display: none; }

.brain-tabs {
  display: flex;
  gap: 8px;
  width: max-content;
  padding-bottom: 2px;
}

.brain-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 10px 14px;
  border: none;
  border-radius: 16px;
  background: var(--bg-card);
  cursor: pointer;
  min-width: 64px;
  position: relative;
  box-shadow: 0 1px 3px var(--shadow);
  transition: transform .15s;
}
.brain-tab:active { transform: scale(.95); }
.brain-tab.active {
  background: color-mix(in srgb, var(--tab-color, #007AFF) 12%, white);
  box-shadow: 0 0 0 1.5px var(--tab-color, #007AFF);
}
.brain-tab-emoji { font-size: 22px; line-height: 1; }
.brain-tab-label { font-size: 12px; font-weight: 600; color: inherit; }
.brain-tab-count {
  position: absolute;
  top: -5px;
  left: -5px;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
}

.brain-area-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px 10px;
}
.brain-area-title {
  font-size: 22px;
  font-weight: 800;
  line-height: 1.1;
}
.brain-area-sub {
  font-size: 13px;
  color: var(--text-3);
  margin-top: 2px;
}

.brain-list {
  padding: 0 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.brain-task {
  display: flex;
  align-items: flex-start;
  gap: 0;
  background: var(--bg-card);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 1px 4px var(--shadow);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform .12s;
}
.brain-task:active { transform: scale(.98); }
.brain-task.done { opacity: .5; }

.brain-priority-bar {
  width: 4px;
  align-self: stretch;
  flex-shrink: 0;
}

.brain-check {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid #C7C7CC;
  flex-shrink: 0;
  margin: 14px 10px 14px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .2s;
}
.brain-check.checked {
  background: var(--chk, #007AFF);
  border-color: var(--chk, #007AFF);
}

.brain-task-body {
  flex: 1;
  padding: 12px 0 12px 12px;
  min-width: 0;
}
.brain-task-text {
  font-size: 15px;
  font-weight: 500;
  line-height: 1.4;
  word-break: break-word;
}
.brain-task.done .brain-task-text {
  text-decoration: line-through;
  color: var(--text-3);
}
.brain-task-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-3);
}

.brain-task-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 8px 10px 8px 0;
  flex-shrink: 0;
}

.brain-empty {
  text-align: center;
  padding: 48px 20px;
  background: var(--bg-card);
  border-radius: 16px;
  box-shadow: 0 1px 4px var(--shadow);
}

.brain-done-section {
  padding: 0 16px 16px;
}
.brain-done-section summary {
  font-size: 13px;
  color: var(--text-3);
  cursor: pointer;
  padding: 6px 0;
  font-weight: 500;
}

/* Area picker in add modal */
.brain-area-pick-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
}
.brain-area-pick {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 10px 4px 8px;
  border: 1.5px solid var(--sep);
  border-radius: 12px;
  background: var(--bg-card);
  font-size: 12px;
  color: var(--text-2);
  cursor: pointer;
}
.brain-area-pick.sel {
  border-color: var(--c-brain);
  background: #5856D612;
  color: var(--c-brain);
  font-weight: 600;
}

/* ===== Finance (redesigned) ===== */
.fin-month-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0 4px;
}
.fin-month-label {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}
.fin-nav-arrow {
  width: 40px;
  height: 40px;
  border: none;
  background: var(--bg-card);
  border-radius: 50%;
  font-size: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 4px var(--shadow);
  color: var(--c-finance);
  font-weight: 700;
  transition: transform .15s;
}
.fin-nav-arrow:active { transform: scale(.9); }
.fin-nav-arrow:disabled { opacity: .3; cursor: default; }

/* Legacy period bar — keep for compatibility */
.fin-period-bar {
  display: flex;
  gap: 8px;
  padding: 12px 0 0;
}
.fin-period-btn {
  flex: 1;
  padding: 7px;
  border: 1.5px solid var(--sep);
  border-radius: 20px;
  background: var(--bg-card);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
}
.fin-period-btn.active {
  background: var(--c-finance);
  color: #fff;
  border-color: var(--c-finance);
  font-weight: 700;
}

.fin-tab-bar {
  display: flex;
  gap: 6px;
  padding: 10px 0 12px;
}
.fin-tab-btn {
  flex: 1;
  padding: 9px 4px;
  border: none;
  border-radius: 12px;
  background: var(--bg-card);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  box-shadow: 0 1px 3px var(--shadow);
}
.fin-tab-btn.active {
  background: var(--c-finance);
  color: #fff;
  font-weight: 700;
}

.fin-hero {
  text-align: center;
  padding: 16px 20px 20px;
}
.fin-hero-amount {
  font-size: 48px;
  font-weight: 800;
  direction: ltr;
  letter-spacing: -2px;
  color: var(--text);
}
.fin-hero-label {
  font-size: 15px;
  color: var(--text-3);
  margin-top: 2px;
}
.fin-hero-mini {
  display: flex;
  justify-content: center;
  gap: 18px;
  margin-top: 12px;
  font-size: 14px;
}

.fin-circles-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  justify-items: center;
}
.fin-cat-circle {
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.fin-donut-wrap {
  position: relative;
  width: 72px;
  height: 72px;
}
.fin-donut-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 26px;
  line-height: 1;
}
.fin-cat-name {
  font-size: 12px;
  font-weight: 500;
  margin-top: 5px;
  text-align: center;
  color: var(--text-2);
}
.fin-cat-spent {
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  direction: ltr;
  line-height: 1.3;
}
.fin-cat-spent small {
  font-size: 10px;
  font-weight: 400;
  display: block;
  color: var(--text-3);
}

.fin-total-banner {
  margin: 0 16px 12px;
  border-radius: var(--radius);
  padding: 18px 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #fff;
  box-shadow: 0 4px 14px rgba(0,0,0,0.15);
}
.fin-total-label { font-size: 16px; font-weight: 600; }
.fin-total-num   { font-size: 28px; font-weight: 800; direction: ltr; }

/* Transaction row */
.fin-item {
  display: flex;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--sep);
  gap: 12px;
}
.fin-item:last-child { border-bottom: none; }
.fin-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.fin-info { flex: 1; min-width: 0; }
.fin-name { font-size: 15px; font-weight: 500; }
.fin-date { font-size: 12px; color: var(--text-3); margin-top: 2px; }

.amount-expense { color: #FF3B30; }
.amount-income  { color: #34C759; }

/* Category picker in add modal */
.fin-cat-pick-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
  max-height: 210px;
  overflow-y: auto;
}
.fin-cat-pick {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 9px 4px 7px;
  border: 1.5px solid var(--sep);
  border-radius: 12px;
  background: var(--bg-card);
  font-size: 11px;
  color: var(--text-2);
  cursor: pointer;
  transition: border-color .15s;
}
.fin-cat-pick.sel {
  border-color: var(--c-finance);
  background: #34C75912;
  color: var(--c-finance);
  font-weight: 600;
}

/* ===== Leads ===== */
.lead-item {
  display: flex;
  align-items: center;
  padding: 11px 0;
  border-bottom: 1px solid var(--sep);
  gap: 12px;
  cursor: pointer;
}

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

.lead-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--c-crossfit);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
  flex-shrink: 0;
}

.lead-info { flex: 1; min-width: 0; }
.lead-name { font-size: 15px; font-weight: 600; }
.lead-phone { font-size: 13px; color: var(--text-3); direction: ltr; text-align: right; margin-top: 1px; }

.lead-status {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 20px;
  white-space: nowrap;
  flex-shrink: 0;
}

.s-new       { background: #007AFF18; color: #007AFF; }
.s-contacted { background: #FF950018; color: #FF9500; }
.s-trial     { background: #5856D618; color: #5856D6; }
.s-member    { background: #34C75918; color: #34C759; }
.s-lost      { background: #FF3B3018; color: #FF3B30; }

/* ===== Pipeline filter ===== */
.pipeline-bar {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding-bottom: 14px;
  scrollbar-width: none;
}
.pipeline-bar::-webkit-scrollbar { display: none; }

.pipe-btn {
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  border: 1.5px solid var(--sep);
  background: var(--bg-card);
  color: var(--text-3);
  cursor: pointer;
  white-space: nowrap;
  font-family: inherit;
  transition: all 0.15s;
}

.pipe-btn.active {
  background: var(--c-crossfit);
  border-color: var(--c-crossfit);
  color: white;
}

/* ===== Checklist ===== */
.check-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--sep);
}

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

.check-box {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 2px solid #C7C7CC;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.check-box.checked {
  background: var(--c-family);
  border-color: var(--c-family);
}

.check-box.checked::after {
  content: '✓';
  color: white;
  font-size: 13px;
  font-weight: 700;
}

.check-text { font-size: 15px; flex: 1; line-height: 1.3; }
.check-text.done { text-decoration: line-through; color: var(--text-3); }

/* ===== FAB ===== */
#fab {
  position: fixed;
  bottom: calc(var(--nav-h) + var(--safe-bottom) + 14px);
  left: 20px;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--fab-color, var(--c-home));
  color: white;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(0,0,0,0.22);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  transition: transform 0.18s, background 0.3s;
}

#fab:active { transform: scale(0.9); }
#fab svg { width: 24px; height: 24px; }

/* ===== Bottom Nav ===== */
#bottom-nav {
  position: fixed;
  bottom: 0;
  right: 50%;
  transform: translateX(50%);
  width: 100%;
  max-width: 430px;
  background: rgba(242,242,247,0.93);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--sep);
  display: flex;
  height: calc(var(--nav-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  z-index: 300;
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--text-3);
  font-size: 10px;
  font-weight: 500;
  font-family: inherit;
  transition: color 0.18s;
  padding: 6px 0;
}

.nav-item.active { color: var(--c-home); }
.nav-item[data-page="brain"].active    { color: var(--c-brain); }
.nav-item[data-page="finance"].active  { color: var(--c-finance); }
.nav-item[data-page="crossfit"].active { color: var(--c-crossfit); }
.nav-item[data-page="family"].active   { color: var(--c-family); }

.nav-icon { width: 24px; height: 24px; }

/* ===== Modal ===== */
#modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  pointer-events: all;
}

#modal-overlay.hidden {
  pointer-events: none;
}

#modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.38);
  opacity: 0;
  transition: opacity 0.3s;
}

#modal-overlay:not(.hidden) #modal-backdrop { opacity: 1; }

#modal-sheet {
  background: var(--bg-card);
  border-radius: 24px 24px 0 0;
  padding: 8px 20px calc(20px + var(--safe-bottom));
  max-height: 82vh;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform 0.32s cubic-bezier(0.32,0.72,0,1);
  position: relative;
  z-index: 1;
  max-width: 430px;
  width: 100%;
  margin: 0 auto;
}

#modal-overlay:not(.hidden) #modal-sheet { transform: translateY(0); }

.modal-handle {
  width: 36px;
  height: 4px;
  background: #D1D1D6;
  border-radius: 2px;
  margin: 4px auto 18px;
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 20px;
}

/* ===== Forms ===== */
.form-group { margin-bottom: 14px; }

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

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 13px 14px;
  border-radius: 12px;
  border: 1.5px solid var(--sep);
  background: var(--bg);
  font-size: 16px;
  color: var(--text);
  outline: none;
  font-family: inherit;
  direction: rtl;
  transition: border-color 0.2s;
  -webkit-appearance: none;
  appearance: none;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--c-home);
}

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

.form-row { display: flex; gap: 10px; }
.form-row .form-group { flex: 1; }

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.chip {
  padding: 7px 16px;
  border-radius: 20px;
  border: 1.5px solid var(--sep);
  background: transparent;
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
  color: var(--text-2);
  transition: all 0.15s;
}

.chip.sel {
  background: var(--chip-color, var(--c-home));
  border-color: var(--chip-color, var(--c-home));
  color: white;
}

/* ===== Buttons ===== */
.btn-primary {
  width: 100%;
  padding: 15px;
  border-radius: 14px;
  border: none;
  background: var(--btn-color, var(--c-home));
  color: white;
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.18s;
  margin-top: 4px;
}

.btn-primary:active { opacity: 0.82; }

.btn-secondary {
  width: 100%;
  padding: 13px;
  border-radius: 14px;
  border: 1.5px solid var(--sep);
  background: transparent;
  color: var(--text-2);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
  margin-top: 4px;
}
.btn-secondary:active { background: var(--bg); }

/* ===== Icon buttons ===== */
.icon-btn {
  background: var(--bg);
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-3);
  font-size: 20px;
  line-height: 1;
  transition: background 0.15s;
}

.icon-btn:active { background: var(--sep); }

/* ===== Empty state ===== */
.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-3);
}

.empty-icon { font-size: 44px; margin-bottom: 12px; }
.empty-text { font-size: 15px; }

/* ===== Delete swipe ===== */
.del-btn {
  background: none;
  border: none;
  color: #FF3B30;
  cursor: pointer;
  font-size: 18px;
  padding: 4px 6px;
  flex-shrink: 0;
  opacity: 0.7;
}

/* ===== Progress bar (crossfit monthly) ===== */
.progress-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.progress-label { font-size: 13px; color: var(--text-2); flex: 1; }
.progress-val { font-size: 13px; font-weight: 600; color: var(--text-3); }

.progress-bar {
  height: 6px;
  background: var(--sep);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 12px;
}

.progress-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--c-crossfit);
  transition: width 0.5s ease;
}

/* ===== Divider ===== */
.divider {
  height: 1px;
  background: var(--sep);
  margin: 12px 0;
}

/* ===== Cloud Setup Steps ===== */
.setup-step {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.step-num {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--c-home);
  color: white;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}

.step-text {
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-2);
}

.step-text code {
  background: var(--bg);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 12px;
  font-family: monospace;
}

/* ===== Notification status ===== */
.notif-status {
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  text-align: center;
  margin-bottom: 12px;
}

.notif-status.on  { background: #34C75918; color: #34C759; }
.notif-status.off { background: #FF3B3018; color: #FF3B30; }

/* ===== Update banner ===== */
#update-banner {
  position: fixed;
  top: calc(var(--header-h) + var(--safe-top) + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: #1C1C1E;
  color: #fff;
  padding: 10px 16px;
  border-radius: 20px;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 400;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  white-space: nowrap;
  animation: slideDown .3s ease-out;
}
#update-banner button {
  background: var(--c-home);
  color: #fff;
  border: none;
  padding: 6px 14px;
  border-radius: 14px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}
@keyframes slideDown {
  from { opacity: 0; transform: translateX(-50%) translateY(-12px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* ===== Scrollbar hidden ===== */
::-webkit-scrollbar { width: 0; height: 0; }

/* ===== Action mini buttons ===== */
.action-mini {
  background: var(--bg);
  border: none;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 16px;
  line-height: 30px;
  text-align: center;
  flex-shrink: 0;
  transition: background 0.15s;
  padding: 0;
}
.action-mini:active { background: var(--sep); }

/* ===== Pay button ===== */
.pay-btn {
  background: none;
  border: none;
  color: var(--c-crossfit);
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  padding: 0;
}

/* ===== Category count badge ===== */
.cat-count {
  display: inline-block;
  min-width: 18px;
  height: 18px;
  background: rgba(255,255,255,0.3);
  border-radius: 9px;
  font-size: 11px;
  line-height: 18px;
  text-align: center;
  padding: 0 4px;
  margin-right: 4px;
  vertical-align: middle;
}

.cat-tab:not(.active) .cat-count {
  background: var(--sep);
  color: var(--text-3);
}

/* ===== Calm Tool ===== */
.calm-home-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  background: linear-gradient(135deg, #5856D6 0%, #007AFF 100%);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 14px;
  cursor: pointer;
  text-align: right;
  box-shadow: 0 4px 16px rgba(88,86,214,0.35);
  transition: transform .15s, box-shadow .15s;
  font-family: inherit;
}
.calm-home-btn:active { transform: scale(.97); box-shadow: 0 2px 8px rgba(88,86,214,.25); }
.calm-home-btn > div { flex: 1; }

.calm-intensity-row {
  display: flex;
  gap: 5px;
  justify-content: center;
}
.calm-int-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--sep);
  background: var(--bg);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  color: var(--text-2);
  transition: all .15s;
}
.calm-int-btn.sel {
  background: var(--ic, #007AFF);
  border-color: var(--ic, #007AFF);
  color: #fff;
  transform: scale(1.15);
}

.calm-tools-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.calm-tool-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 16px 8px 12px;
  background: var(--bg);
  border: 1.5px solid var(--sep);
  border-radius: 14px;
  cursor: pointer;
  font-family: inherit;
  transition: all .15s;
}
.calm-tool-card:active { transform: scale(.96); background: var(--sep); }
.calm-tool-name { font-size: 13px; font-weight: 700; color: var(--text); }
.calm-tool-desc { font-size: 11px; color: var(--text-3); }

/* Breathing circle */
.calm-breath-wrap {
  position: relative;
  width: 200px;
  height: 200px;
  margin: 0 auto 8px;
}
.calm-breath-circle {
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--bc, #007AFF) 15%, transparent);
  border: 3px solid var(--bc, #007AFF);
  transform: scale(0.85);
  transition: transform 4s ease-in-out;
}
.calm-breath-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

/* Grounding checks */
.calm-ground-checks {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin: 4px 0;
}
.calm-ground-check {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px solid var(--sep);
  background: var(--bg);
  font-size: 22px;
  cursor: pointer;
  transition: all .2s;
}
.calm-ground-check.done {
  background: #34C759;
  border-color: #34C759;
  font-size: 20px;
}
.calm-ground-check.done::after { content: '✓'; color: white; font-size: 22px; font-weight: 700; }
.calm-ground-check.done { font-size: 0; }

/* ===== Arbox Card ===== */
.arbox-card { border: 1.5px solid rgba(255,149,0,0.2); }

.arbox-stats {
  display: flex;
  gap: 0;
  text-align: center;
}

.arbox-stat {
  flex: 1;
  border-left: 1px solid var(--sep);
  padding: 8px 0;
}
.arbox-stat:last-child { border-left: none; }

.arbox-stat span {
  display: block;
  font-size: 22px;
  font-weight: 700;
  color: var(--c-crossfit);
}

.arbox-stat small {
  font-size: 11px;
  color: var(--text-3);
}

.arbox-btn {
  flex: 1;
  padding: 10px;
  border-radius: 10px;
  border: none;
  background: var(--c-crossfit);
  color: white;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.15s;
}

.arbox-btn:active { opacity: 0.82; }

.arbox-btn.secondary {
  background: rgba(255,149,0,0.12);
  color: var(--c-crossfit);
}

