/* Design language borrowed from the OCA / Aitrading.in dashboard:
   deep navy canvas, indigo primary, glass cards, Inter + Outfit type. */
:root {
  color-scheme: dark;

  --primary:        #6366f1;
  --primary-dark:   #4f46e5;
  --primary-light:  #818cf8;
  --primary-glow:   rgba(99, 102, 241, 0.4);
  --primary-soft:   rgba(99, 102, 241, 0.15);
  --accent-purple:  #c084fc;

  --bg-dark:        #0f172a;
  --card-bg:        rgba(255, 255, 255, 0.05);
  --glass:          rgba(255, 255, 255, 0.03);
  --glass-border:   rgba(255, 255, 255, 0.1);
  --input-bg:       rgba(0, 0, 0, 0.2);

  --text-main:      #f8fafc;
  --text-dim:       #94a3b8;

  --success:        #22c55e;
  --danger:         #ef4444;
  --warning:        #f59e0b;
  --serious-c:      #fb923c;

  /* Legacy token names still referenced by templates */
  --surface-1:      var(--card-bg);
  --page-plane:     var(--bg-dark);
  --text-primary:   var(--text-main);
  --text-secondary: #cbd5e1;
  --text-muted:     var(--text-dim);
  --gridline:       rgba(255, 255, 255, 0.06);
  --baseline:       rgba(255, 255, 255, 0.18);
  --border:         var(--glass-border);
  --series-1:       #6f7bf7;  /* validated pair: dark surface, CVD ΔE 22 */
  --series-2:       #12a473;
  --good:           var(--success);
  --critical:       #f87171;
  --card-shadow:    0 10px 30px rgba(0, 0, 0, 0.2);

  --font-body:      'Inter', system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display:   'Outfit', 'Inter', system-ui, sans-serif;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html { background-color: var(--bg-dark); }

body {
  margin: 0;
  font-family: var(--font-body);
  background-color: var(--bg-dark);
  background-image:
    radial-gradient(circle at top right, rgba(99, 102, 241, 0.15), transparent 45%),
    radial-gradient(circle at bottom left, rgba(168, 85, 247, 0.1), transparent 45%);
  background-attachment: fixed;
  color: var(--text-main);
  min-height: 100vh;
  padding-bottom: 3rem;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary-light); }

.wrap {
  max-width: 1120px;
  margin: 0 auto;
  padding: 1rem 1rem 2rem;
}

/* ---------- Small pill buttons ---------- */
.clear-all-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--glass-border);
  color: var(--text-dim);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s;
}
.clear-all-btn:hover {
  color: var(--critical);
  border-color: rgba(239, 68, 68, 0.4);
  background: rgba(239, 68, 68, 0.1);
}

#clear-all-btn {
  color: var(--critical);
  border-color: rgba(239, 68, 68, 0.3);
  background: rgba(239, 68, 68, 0.08);
}
#clear-all-btn:hover {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

.clear-all-row {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 1rem;
}

/* ---------- Modal & auth card ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.7);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 100;
}
.modal-overlay[hidden] { display: none; }

.modal-box {
  background: rgba(30, 41, 59, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  padding: 1.75rem;
  width: 100%;
  max-width: 360px;
  animation: fadeIn 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.modal-box h3 {
  margin: 0 0 0.4rem;
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-main);
}

.modal-box p {
  margin: 0 0 1rem;
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--text-dim);
}

/* Auth pages (login / signup / connect) */
.auth-wrap {
  max-width: 440px;
  padding-top: clamp(2rem, 8vh, 5rem);
}
.auth-wrap.wide { max-width: 480px; }

.auth-card {
  max-width: none;
  padding: 2.5rem;
  border-radius: 32px;
  background: rgba(255, 255, 255, 0.03);
}

.auth-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  margin-bottom: 1.75rem;
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.auth-brand {
  flex-direction: column;
  gap: 0.85rem;
}
.auth-brand .brand-logo {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  box-shadow: 0 0 30px var(--primary-glow);
}
.auth-brand .brand-text {
  background: linear-gradient(135deg, #fff 0%, #c7d2fe 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.auth-card h3 { text-align: center; }
.auth-card > p { text-align: center; }

@media (max-width: 480px) {
  .auth-card { padding: 1.75rem 1.25rem; border-radius: 24px; }
}

/* ---------- Form fields ---------- */
.modal-input {
  width: 100%;
  font-size: 0.95rem;
  padding: 0.85rem 1.1rem;
  border-radius: 14px;
  border: 1px solid var(--glass-border);
  background: var(--input-bg);
  color: var(--text-main);
  font-family: inherit;
  transition: all 0.25s;
}
.modal-input::placeholder { color: rgba(148, 163, 184, 0.6); }
.modal-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.25);
  background: rgba(0, 0, 0, 0.3);
}
select.modal-input { cursor: pointer; }
select option { background: var(--bg-dark); color: var(--text-main); }

.field-hint {
  font-size: 0.78rem;
  color: var(--text-dim);
  line-height: 1.45;
  margin: 0.35rem 0 0.9rem 0.35rem;
}

.code-box {
  text-align: center;
  font-weight: 700;
  letter-spacing: 0.1em;
  flex: 1;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  color: var(--primary-light);
}

.modal-error {
  font-size: 0.8rem;
  color: var(--critical);
  min-height: 1.2em;
  margin-top: 0.5rem;
}
.modal-error:not(:empty) {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: 12px;
  padding: 0.6rem 0.8rem;
  margin-bottom: 1rem;
  text-align: center;
}
form > .modal-btn.block { margin-top: 0.75rem; }

.alert-success {
  background: rgba(34, 197, 94, 0.1);
  color: #4ade80;
  border: 1px solid rgba(34, 197, 94, 0.2);
  border-radius: 14px;
  padding: 0.75rem 1rem;
  font-size: 0.88rem;
  margin-bottom: 1.25rem;
}

/* Selectable option cards (template picker) */
.option-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin-bottom: 1rem;
}
.option-card {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  font-size: 0.85rem;
  line-height: 1.45;
  color: var(--text-dim);
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  padding: 0.8rem 0.95rem;
  cursor: pointer;
  transition: all 0.2s;
}
.option-card:hover { border-color: rgba(99, 102, 241, 0.4); }
.option-card:has(input:checked) {
  background: var(--primary-soft);
  border-color: rgba(99, 102, 241, 0.5);
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.15);
}
.option-card input { margin-top: 0.2rem; accent-color: var(--primary); }
.option-card strong { color: var(--text-main); font-weight: 600; }

/* ---------- Buttons ---------- */
.modal-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1rem;
}

.modal-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  padding: 0.65rem 1.2rem;
  font-size: 0.88rem;
  font-weight: 600;
  font-family: inherit;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid var(--glass-border);
  transition: all 0.25s;
  white-space: nowrap;
}
.modal-btn.secondary {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-dim);
}
.modal-btn.secondary:hover {
  color: var(--text-main);
  border-color: rgba(255, 255, 255, 0.25);
}
.modal-btn.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 4px 12px var(--primary-glow);
}
.modal-btn.primary:hover {
  background: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px var(--primary-glow);
}
.modal-btn.primary:active { transform: translateY(0); }
.modal-btn.danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.35);
}
.modal-btn.danger:hover { filter: brightness(1.1); transform: translateY(-2px); }
.modal-btn.block { width: 100%; padding: 0.9rem; font-size: 0.95rem; border-radius: 14px; }

.auth-footer {
  text-align: center;
  margin-top: 1.5rem;
  font-size: 0.88rem;
  color: var(--text-dim);
}
.auth-footer a {
  color: var(--primary-light);
  font-weight: 600;
  text-decoration: none;
}
.auth-footer a:hover { color: #a5b4fc; }

/* ---------- Score cards ---------- */
.score-row {
  display: flex;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.score-card {
  position: relative;
  overflow: hidden;
  background: var(--card-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 24px;
  box-shadow: var(--card-shadow);
  padding: 1.4rem 1.5rem 1.4rem 1.75rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 1rem;
  flex: 1 1 300px;
  transition: transform 0.3s ease;
}
.score-card:hover { transform: translateY(-4px); }
.score-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--primary);
}
.score-card:has(.status-pill.good)::before     { background: var(--success); }
.score-card:has(.status-pill.warning)::before  { background: var(--warning); }
.score-card:has(.status-pill.serious)::before  { background: var(--serious-c); }
.score-card:has(.status-pill.critical)::before { background: var(--danger); }

.score-card .date-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  margin-bottom: 0.35rem;
}

.score-card .score-value {
  font-family: var(--font-display);
  font-size: 2.6rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
}

.score-card .score-frac {
  font-size: 0.88rem;
  color: var(--text-dim);
  margin-top: 0.25rem;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  border: 1px solid transparent;
}
.status-pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 8px currentColor;
}
.status-pill.good     { color: #4ade80; background: rgba(34, 197, 94, 0.1);  border-color: rgba(34, 197, 94, 0.25); }
.status-pill.warning  { color: #fbbf24; background: rgba(245, 158, 11, 0.1); border-color: rgba(245, 158, 11, 0.25); }
.status-pill.serious  { color: #fb923c; background: rgba(249, 115, 22, 0.1); border-color: rgba(249, 115, 22, 0.25); }
.status-pill.critical { color: #f87171; background: rgba(239, 68, 68, 0.1);  border-color: rgba(239, 68, 68, 0.25); }

/* ---------- Habit lists ---------- */
section.group {
  margin-bottom: 1.75rem;
}

section.group h2,
.notes-card h2,
.chart-card h2 {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-dim);
  margin: 0 0 0.75rem 4px;
}

.habit-list {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--card-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: var(--card-shadow);
}

.habit-item {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.85rem 1.15rem;
  border-bottom: 1px solid var(--gridline);
  cursor: pointer;
  user-select: none;
  transition: background 0.2s;
}
.habit-item:last-child { border-bottom: none; }
.habit-item:hover { background: rgba(99, 102, 241, 0.08); }

.habit-item input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: var(--primary);
  flex-shrink: 0;
  cursor: pointer;
}

.habit-item .time-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--primary-light);
  background: var(--primary-soft);
  border-radius: 8px;
  padding: 0.2rem 0.5rem;
  min-width: 4.6rem;
  text-align: center;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.habit-item .habit-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.habit-item .habit-text {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-main);
  transition: color 0.15s, text-decoration-color 0.15s;
}

.habit-item .habit-detail {
  font-size: 0.76rem;
  color: var(--text-dim);
  line-height: 1.35;
}

.habit-item.checked { background: rgba(34, 197, 94, 0.04); }
.habit-item.checked .habit-text {
  color: var(--text-dim);
  text-decoration: line-through;
  text-decoration-color: rgba(148, 163, 184, 0.6);
}
.habit-item.checked .habit-detail,
.habit-item.checked .time-label { opacity: 0.55; }

.habit-item.readonly { cursor: default; }
.habit-item.readonly:hover { background: none; }
.habit-item.readonly.checked:hover { background: rgba(34, 197, 94, 0.04); }

.sub-list-wrap {
  border-bottom: 1px solid var(--gridline);
}
.sub-list-wrap:last-child { border-bottom: none; }

.sub-list {
  list-style: none;
  margin: 0;
  padding: 0;
  background: rgba(0, 0, 0, 0.12);
}

.habit-item.sub-item {
  padding: 0.55rem 1.15rem 0.55rem 2.75rem;
  border-bottom: 1px solid var(--gridline);
  position: relative;
}
.habit-item.sub-item:last-child { border-bottom: none; }
.habit-item.sub-item::before {
  content: "";
  position: absolute;
  left: 1.7rem;
  top: 0;
  bottom: 0;
  width: 2px;
  background: linear-gradient(180deg, rgba(99, 102, 241, 0.5), rgba(168, 85, 247, 0.3));
}
.habit-item.sub-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
}
.habit-item.sub-item .habit-text {
  font-size: 0.86rem;
  font-weight: 400;
  color: var(--text-secondary);
}
.habit-item.sub-item.checked .habit-text {
  color: var(--text-dim);
}

/* ---------- Notes & generic cards ---------- */
.notes-card {
  background: var(--card-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 24px;
  padding: 1.5rem;
  box-shadow: var(--card-shadow);
}
.notes-card + .notes-card { margin-top: 1.25rem; }
.notes-card h2 { margin-left: 0; }

.card-text {
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--text-secondary);
  margin: 0 0 0.5rem;
}
.card-text strong { color: var(--text-main); }

.notes-card textarea {
  width: 100%;
  min-height: 6rem;
  resize: vertical;
  font-family: inherit;
  font-size: 0.92rem;
  line-height: 1.5;
  padding: 0.85rem 1rem;
  border-radius: 14px;
  border: 1px solid var(--glass-border);
  background: var(--input-bg);
  color: var(--text-main);
  transition: all 0.25s;
}
.notes-card textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.25);
}

.save-hint {
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-top: 0.5rem;
  min-height: 1em;
}

/* ---------- Tables ---------- */
.table-scroll { overflow-x: auto; }

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
table.data-table th, table.data-table td {
  text-align: left;
  padding: 0.7rem 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  white-space: nowrap;
}
table.data-table th {
  color: var(--text-dim);
  font-weight: 700;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  border-bottom: 1px solid var(--glass-border);
}
table.data-table tbody tr { transition: background 0.2s; }
table.data-table tbody tr:hover { background: rgba(255, 255, 255, 0.03); }
table.data-table tr:last-child td { border-bottom: none; }
table.data-table td.num { font-variant-numeric: tabular-nums; }
table.data-table a { color: var(--primary-light); text-decoration: none; font-weight: 600; }
table.data-table a:hover { color: #a5b4fc; text-decoration: underline; }

.pct-cell { display: flex; align-items: center; gap: 0.6rem; }
.pct-bar-track {
  flex: 1;
  min-width: 60px;
  max-width: 110px;
  height: 6px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}
.pct-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #6366f1, #a855f7);
  border-radius: 10px;
}

/* ---------- Charts ---------- */
.chart-card {
  background: var(--card-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 24px;
  padding: 1.4rem 1.4rem 1rem;
  box-shadow: var(--card-shadow);
  margin-bottom: 1.5rem;
}
.chart-card h2 { margin-left: 0; }

.trend-svg text {
  fill: var(--text-dim);
  font-size: 10px;
  font-family: var(--font-body);
}
.trend-svg .gridline { stroke: var(--gridline); stroke-width: 1; }
.trend-svg .baseline { stroke: var(--baseline); stroke-width: 1; }
.trend-svg .trend-line-checklist { fill: none; stroke: var(--series-1); stroke-width: 2.25; filter: drop-shadow(0 0 4px rgba(111, 123, 247, 0.5)); }
.trend-svg .trend-dot-checklist { fill: var(--series-1); }
.trend-svg .trend-line-nonneg { fill: none; stroke: var(--series-2); stroke-width: 2.25; filter: drop-shadow(0 0 4px rgba(18, 164, 115, 0.4)); }
.trend-svg .trend-dot-nonneg { fill: var(--series-2); }

.chart-legend {
  display: flex;
  gap: 1.25rem;
  margin: 0.25rem 0 0.9rem 2px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}
.chart-legend .legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}
.chart-legend .swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  display: inline-block;
}
.chart-legend .swatch.checklist { background: var(--series-1); }
.chart-legend .swatch.nonneg { background: var(--series-2); }

.tooltip {
  position: absolute;
  pointer-events: none;
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid var(--glass-border);
  color: var(--text-main);
  font-size: 0.75rem;
  padding: 0.4rem 0.65rem;
  border-radius: 8px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
  transform: translate(-50%, -130%);
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.1s;
  z-index: 10;
}

.section-title {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0 0 1.25rem;
}

.empty-state {
  color: var(--text-dim);
  font-size: 0.9rem;
  padding: 1.5rem 1rem;
  text-align: center;
}

@media (max-width: 480px) {
  .score-card { padding: 1.2rem 1.2rem 1.2rem 1.5rem; }
  .score-card .score-value { font-size: 2.1rem; }
  .habit-item { padding: 0.75rem 0.9rem; gap: 0.65rem; }
  .habit-item .time-label { min-width: 3.8rem; font-size: 0.7rem; padding: 0.15rem 0.35rem; }
  .habit-item .habit-text { font-size: 0.88rem; }
  .habit-item.sub-item { padding-left: 2.3rem; }
  .habit-item.sub-item::before { left: 1.35rem; }
  .notes-card, .chart-card { padding: 1.2rem; border-radius: 20px; }
}

/* ---------- Card header ---------- */
.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.8rem;
}
.card-head h2 { margin-bottom: 0 !important; }
.card-link { font-size: 0.8rem; font-weight: 600; color: var(--primary-light); text-decoration: none; }
.card-link:hover { color: #a5b4fc; }
.reminders-card { margin-bottom: 1.75rem; }

/* ---------- Quick add ---------- */
.quickadd {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--input-bg);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 0.35rem 0.35rem 0.35rem 0.9rem;
  transition: all 0.25s;
}
.quickadd:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.2);
}
.quickadd-icon { filter: drop-shadow(0 0 6px rgba(251, 191, 36, 0.5)); }
.quickadd-input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.92rem;
  padding: 0.55rem 0;
}
.quickadd-input::placeholder { color: rgba(148, 163, 184, 0.55); }
.quickadd .modal-btn { padding: 0.55rem 1.1rem; }
.quickadd-status { font-size: 0.82rem; min-height: 0.5rem; margin: 0.5rem 0 0.25rem 0.3rem; color: var(--text-dim); }
.quickadd-status.working::before {
  content: ""; display: inline-block; width: 11px; height: 11px; margin-right: 0.45rem; vertical-align: -1px;
  border-radius: 50%; border: 2px solid rgba(129, 140, 248, 0.3); border-top-color: var(--primary-light);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.quickadd-status.error { color: var(--critical); }
.quickadd-saved {
  display: flex; align-items: center; justify-content: space-between; gap: 0.6rem;
  color: #4ade80; padding: 0.2rem 0;
}

/* ---------- Reminder list ---------- */
.reminder-list { list-style: none; margin: 0.4rem 0 0; padding: 0; }
.reminder-item { border-bottom: 1px solid var(--gridline); }
.reminder-item:last-child { border-bottom: none; }
.reminder-view { display: flex; align-items: center; gap: 0.75rem; padding: 0.7rem 0.2rem; flex-wrap: wrap; }
.reminder-done { width: 18px; height: 18px; accent-color: var(--primary); cursor: pointer; flex-shrink: 0; }
.reminder-time {
  font-size: 0.75rem; font-weight: 700; color: #fbbf24;
  background: rgba(245, 158, 11, 0.12); border-radius: 8px;
  padding: 0.2rem 0.5rem; min-width: 4.8rem; text-align: center; flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}
.reminder-time.all-day { color: var(--primary-light); background: var(--primary-soft); }
.reminder-main { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 0.2rem; }
.reminder-title { font-size: 0.93rem; font-weight: 500; color: var(--text-main); }
.reminder-notes { font-size: 0.76rem; color: var(--text-dim); }
.reminder-item.done .reminder-title { text-decoration: line-through; color: var(--text-dim); }
.reminder-item.done .reminder-time { opacity: 0.5; }
.reminder-empty { padding: 0.9rem 0.2rem 0.3rem; text-align: left; }
.add-manual { margin-top: 0.8rem; color: var(--primary-light); border-style: dashed; border-color: rgba(99, 102, 241, 0.4); background: transparent; }

/* ---------- Checklist focus view ---------- */
.group-head {
  display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
  margin-bottom: 0.75rem; flex-wrap: wrap;
}
.group-head h2 { margin: 0 0 0 4px !important; }
.focus-controls { display: flex; gap: 0.5rem; align-items: center; }
.focus-hidden { display: none !important; }
.focus-tag:empty { display: none; }
.focus-tag {
  margin-left: auto; flex-shrink: 0;
  font-size: 0.64rem; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--text-dim); border: 1px solid var(--glass-border); border-radius: 999px; padding: 0.15rem 0.55rem;
}
.habit-item.focus-now { background: rgba(99, 102, 241, 0.1); box-shadow: inset 3px 0 0 var(--primary); }
.habit-item.focus-now .focus-tag {
  color: #fff; background: var(--primary); border-color: var(--primary);
  box-shadow: 0 0 12px var(--primary-glow);
}
.focus-earlier {
  display: block; width: 100%; margin: 0 0 0.6rem; padding: 0.55rem 0.9rem;
  font-family: inherit; font-size: 0.8rem; font-weight: 600; text-align: left; cursor: pointer;
  color: #fbbf24; background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.25); border-radius: 12px;
}
.focus-earlier:hover { background: rgba(245, 158, 11, 0.14); }

/* ---------- Day navigation (Reminders) ---------- */
.day-nav { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; margin-bottom: 1.25rem; }
.day-nav-center { text-align: center; }
.day-nav .section-title { margin: 0 0 0.35rem; font-size: clamp(1.2rem, 4.5vw, 1.6rem); }
.day-arrow {
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 44px; height: 44px; border-radius: 14px; text-decoration: none;
  font-size: 1.2rem; font-weight: 700; color: var(--text-main);
  background: var(--card-bg); border: 1px solid var(--glass-border); transition: all 0.2s;
}
.day-arrow:hover { border-color: rgba(99, 102, 241, 0.5); background: var(--primary-soft); color: var(--primary-light); }
.today-chip {
  display: inline-block; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--primary-light); background: var(--primary-soft); border: 1px solid rgba(99, 102, 241, 0.35);
  border-radius: 999px; padding: 0.2rem 0.65rem; text-decoration: none;
}
.upcoming-day {
  display: flex; gap: 1rem; padding: 0.75rem 1rem; margin-bottom: 0.5rem; text-decoration: none;
  background: var(--card-bg); border: 1px solid var(--glass-border); border-radius: 14px; transition: all 0.2s;
}
.upcoming-day:hover { border-color: rgba(99, 102, 241, 0.4); }
.upcoming-date { font-size: 0.8rem; font-weight: 700; color: var(--primary-light); min-width: 5.5rem; flex-shrink: 0; }
.upcoming-items { display: flex; flex-direction: column; gap: 0.2rem; font-size: 0.85rem; color: var(--text-secondary); }

@media (max-width: 480px) {
  .reminder-time { min-width: 4.2rem; font-size: 0.7rem; }
  .quickadd-input { font-size: 0.85rem; }
}

/* ======================= Dashboard (Today) ======================= */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.wrap.dash { max-width: 1180px; }

.dash-hero {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  margin: 0.25rem 0 1.4rem;
}
.dash-greeting {
  font-family: var(--font-display); font-size: clamp(1.6rem, 4vw, 2.3rem); font-weight: 800;
  letter-spacing: -0.02em; margin: 0 0 0.25rem;
}
.dash-date { margin: 0; color: var(--text-dim); font-size: 0.95rem; }
#dash-clock { color: var(--text-main); font-weight: 600; font-variant-numeric: tabular-nums; }
.now-chip {
  display: inline-flex; align-items: center; gap: 0.6rem; max-width: 100%;
  padding: 0.6rem 1rem; border-radius: 999px; font-size: 0.88rem; color: var(--text-main);
  background: var(--primary-soft); border: 1px solid rgba(99, 102, 241, 0.4);
  box-shadow: 0 4px 20px rgba(99, 102, 241, 0.2);
}
.now-chip > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.now-label { font-size: 0.66rem; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; color: var(--primary-light); margin-right: 0.2rem; }
.now-dot {
  width: 8px; height: 8px; border-radius: 50%; background: #4ade80; flex-shrink: 0;
  box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.6); animation: pulse 2s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.55); }
  70% { box-shadow: 0 0 0 8px rgba(74, 222, 128, 0); }
  100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0); }
}

/* KPI tiles */
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.kpi {
  position: relative; display: flex; flex-direction: column; gap: 0.3rem; min-width: 0;
  background: var(--card-bg); border: 1px solid var(--glass-border);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-radius: 22px; padding: 1.15rem 1.25rem; box-shadow: var(--card-shadow);
  text-decoration: none; color: inherit; transition: transform 0.25s, border-color 0.25s;
}
.kpi:hover { transform: translateY(-3px); border-color: rgba(129, 140, 248, 0.3); }
.kpi-ring { flex-direction: row; align-items: center; gap: 1rem; }
.kpi-body { display: flex; flex-direction: column; gap: 0.25rem; align-items: flex-start; min-width: 0; }
.kpi-label { font-size: 0.68rem; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-dim); }
.kpi-value {
  font-family: var(--font-display); font-size: 2rem; font-weight: 800; letter-spacing: -0.02em;
  line-height: 1.05; font-variant-numeric: tabular-nums;
}
.kpi-value small { font-size: 0.9rem; font-weight: 600; color: var(--text-dim); margin-left: 0.1rem; }
.kpi-sub { font-size: 0.8rem; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.kpi .status-pill { align-self: flex-start; margin-top: 0.25rem; font-size: 0.68rem; padding: 0.25rem 0.65rem; }
.kpi-link { cursor: pointer; }

.ring { width: 84px; height: 84px; flex-shrink: 0; transform: rotate(-90deg); }
.ring-track { fill: none; stroke: rgba(255, 255, 255, 0.07); stroke-width: 8; }
.ring-fill {
  fill: none; stroke-width: 8; stroke-linecap: round;
  transition: stroke-dashoffset 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  filter: drop-shadow(0 0 5px rgba(111, 123, 247, 0.35));
}

.spark { display: flex; align-items: flex-end; gap: 4px; height: 34px; margin-top: auto; padding-top: 0.4rem; }
.spark-bar { flex: 1; border-radius: 3px 3px 0 0; background: rgba(111, 123, 247, 0.45); min-height: 3px; }
.spark-bar.today { background: var(--series-1); box-shadow: 0 0 8px rgba(111, 123, 247, 0.5); }
.spark-bar.empty { background: rgba(255, 255, 255, 0.07); }

/* Two-column body */
.dash-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 1.25rem; align-items: start; }
.dash-main, .dash-side { display: flex; flex-direction: column; gap: 1.25rem; min-width: 0; }
.panel {
  background: var(--card-bg); border: 1px solid var(--glass-border);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-radius: 24px; padding: 1.2rem 1.3rem; box-shadow: var(--card-shadow); min-width: 0;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; margin-bottom: 0.85rem; flex-wrap: wrap; }
.panel-head h2 {
  margin: 0; font-family: var(--font-display); font-size: 1.05rem; font-weight: 700;
  letter-spacing: -0.01em; text-transform: none; color: var(--text-main);
}
.panel-count { font-size: 0.8rem; font-weight: 700; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.sub-head {
  font-size: 0.66rem; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--text-dim); margin: 1rem 0 0.2rem;
}
.overdue-head { color: #f87171; }

/* Lists inside panels sit flush, no second card */
.habit-list.flush {
  background: rgba(0, 0, 0, 0.14); border-radius: 16px; box-shadow: none;
  backdrop-filter: none; -webkit-backdrop-filter: none;
}
.habit-list.compact .habit-item { padding: 0.65rem 0.9rem; }
.dash .time-label { min-width: 5.4rem; }
.notes-area {
  width: 100%; min-height: 5.5rem; resize: vertical; font-family: inherit; font-size: 0.92rem; line-height: 1.5;
  padding: 0.85rem 1rem; border-radius: 14px; border: 1px solid var(--glass-border);
  background: var(--input-bg); color: var(--text-main); transition: all 0.25s;
}
.notes-area:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.25); }
.panel .save-hint { margin: 0; min-height: 0; }

/* Reminder states */
.reminder-meta { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.overdue-tag {
  font-size: 0.68rem; font-weight: 700; color: #f87171; background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.25); border-radius: 999px; padding: 0.1rem 0.5rem;
}
.reminder-item.overdue .reminder-time { color: #f87171; background: rgba(239, 68, 68, 0.12); }
.reminder-item.overdue.done .overdue-tag { opacity: 0.5; }
.done-group { margin-top: 0.9rem; }
.done-group summary { cursor: pointer; font-size: 0.8rem; font-weight: 600; color: #4ade80; }
.dash-side .quickadd { margin-bottom: 0.1rem; }

/* Week chart */
.week-chart { position: relative; }
.week-svg { width: 100%; height: auto; display: block; overflow: visible; }
.week-svg text { fill: var(--text-dim); font-size: 10px; font-family: var(--font-body); }
.week-svg .wk-today { fill: var(--text-main); font-weight: 700; }
.week-svg .gridline { stroke: var(--gridline); stroke-width: 1; }
.week-svg .baseline { stroke: var(--baseline); stroke-width: 1; }
.week-svg .wk-c { fill: var(--series-1); }
.week-svg .wk-n { fill: var(--series-2); }
.week-svg .wk-none { fill: var(--text-dim); opacity: 0.6; }
.week-svg .wk-hit { cursor: default; }
.week-svg .wk-hit.on { fill: rgba(255, 255, 255, 0.04) !important; }
.week-chart .tooltip { transform: translate(-50%, -110%); }

@media (max-width: 1000px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash-grid { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .kpi-grid { gap: 0.7rem; }
  .kpi { padding: 0.95rem; border-radius: 18px; }
  .kpi-ring { flex-direction: column; align-items: flex-start; gap: 0.6rem; }
  .ring { width: 64px; height: 64px; }
  .kpi-value { font-size: 1.6rem; }
  .panel { padding: 1rem; border-radius: 20px; }
  .dash .time-label { min-width: 4rem; }
  .now-chip { width: 100%; }
}

/* Single column: interleave the two columns so reminders sit right after Now & next. */
@media (max-width: 1000px) {
  .dash-grid { display: flex; flex-direction: column; }
  .dash-main, .dash-side { display: contents; }
  .p-now { order: 1; } .p-rem { order: 2; } .p-nonneg { order: 3; } .p-week { order: 4; } .p-notes { order: 5; }
}
@media (max-width: 520px) {
  /* Give the label the row: the Now/Next tag floats in the corner instead. */
  .dash #checklist-list > .habit-item { position: relative; flex-wrap: wrap; row-gap: 0.35rem; }
  .dash #checklist-list > .habit-item .habit-main { flex: 1 1 100%; padding-left: calc(20px + 0.65rem); }
  .dash #checklist-list > .habit-item .focus-tag { position: absolute; top: 0.7rem; right: 0.8rem; font-size: 0.58rem; }
}

/* Date picker on the Reminders day header: the title opens the native picker. */
.date-jump { margin: 0; }
.date-jump-label { position: relative; display: inline-block; cursor: pointer; border-radius: 12px; padding: 0.1rem 0.6rem; transition: background 0.2s; }
.date-jump-label:hover { background: rgba(255, 255, 255, 0.05); }
.date-jump-icon { font-size: 0.75em; opacity: 0.8; margin-left: 0.2rem; }
.date-jump input[type="date"], .date-jump input[type="month"] {
  position: absolute; inset: 0; width: 100%; height: 100%;
  opacity: 0; cursor: pointer; border: 0; padding: 0; color-scheme: dark;
}
.date-jump input[type="date"]::-webkit-calendar-picker-indicator,
.date-jump input[type="month"]::-webkit-calendar-picker-indicator { position: absolute; inset: 0; width: 100%; height: 100%; cursor: pointer; }
@media (max-width: 520px) {
  .reminder-view .admin-item-actions { flex-basis: 100%; justify-content: flex-end; margin-top: -0.2rem; }
}

/* Dashboard: reminder box as a full-width bar above the stat tiles */
.quickadd-bar { margin-bottom: 1.1rem; }
.quickadd-bar .quickadd {
  padding: 0.45rem 0.45rem 0.45rem 1.1rem; border-radius: 20px;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.14), rgba(168, 85, 247, 0.08)), var(--card-bg);
  border-color: rgba(129, 140, 248, 0.3); box-shadow: 0 8px 26px rgba(79, 70, 229, 0.16);
}
.quickadd-bar .quickadd-input { font-size: 1rem; padding: 0.7rem 0; }
.quickadd-bar .quickadd .modal-btn { padding: 0.75rem 1.4rem; border-radius: 14px; }
.quickadd-bar .quickadd-status:empty { display: none; }
.quickadd-bar .quickadd-status { margin: 0.55rem 0.4rem 0; }

/* Dashboard reminder strip: box on top, coming-up reminders as cards below */
.reminder-strip { margin-bottom: 1.25rem; }
.reminder-strip .quickadd-bar { margin-bottom: 0.9rem; }
.strip-head { display: flex; align-items: baseline; justify-content: space-between; gap: 0.75rem; margin: 0 0.2rem 0.6rem; flex-wrap: wrap; }
.strip-head h2 {
  margin: 0; font-size: 0.7rem; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-dim);
}
.strip-links { display: inline-flex; align-items: baseline; gap: 0.9rem; }
.strip-done { font-size: 0.78rem; font-weight: 600; color: #4ade80; }
.strip-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 0.6rem; align-items: start; }
.strip-part { display: contents; }
.strip-grid .reminder-item {
  background: var(--card-bg); border: 1px solid var(--glass-border); border-radius: 16px;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); transition: border-color 0.2s, transform 0.2s;
}
.strip-grid .reminder-item:last-child { border-bottom: 1px solid var(--glass-border); }
.strip-grid .reminder-item:hover { border-color: rgba(129, 140, 248, 0.35); transform: translateY(-2px); }
.strip-grid .reminder-item.overdue { border-color: rgba(239, 68, 68, 0.35); background: rgba(239, 68, 68, 0.06); }
.strip-grid .reminder-view { padding: 0.6rem 0.75rem; align-items: center; flex-wrap: nowrap; gap: 0.65rem; }
.strip-grid .reminder-title {
  font-size: 0.9rem; font-weight: 600; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.strip-grid .reminder-notes { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.strip-grid .reminder-meta { align-items: center; margin-top: 0.1rem; }
.meta-time { font-size: 0.72rem; font-weight: 800; color: #fbbf24; }
.reminder-item.overdue .meta-time { color: #f87171; }
.reminder-emoji {
  flex: none; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 12px;
  font-size: 1.1rem; line-height: 1; background: rgba(255, 255, 255, 0.06); border: 1px solid var(--glass-border);
}
.reminder-list:not(.strip-part) .reminder-emoji { width: 30px; height: 30px; border-radius: 10px; font-size: 0.95rem; }
.reminder-item.done .reminder-emoji { opacity: 0.5; filter: grayscale(1); }
.strip-grid .reminder-item.overdue .reminder-emoji { background: rgba(239, 68, 68, 0.12); border-color: rgba(239, 68, 68, 0.3); }
.when-tag {
  font-size: 0.66rem; font-weight: 700; color: var(--primary-light); background: var(--primary-soft);
  border-radius: 999px; padding: 0.1rem 0.5rem;
}
.strip-empty {
  grid-column: 1 / -1; margin: 0; padding: 0.9rem 1rem; font-size: 0.85rem; color: var(--text-dim);
  border: 1px dashed var(--glass-border); border-radius: 16px;
}
@media (max-width: 520px) {
  .strip-grid { grid-template-columns: 1fr; gap: 0.5rem; }
}
.strip-grid .reminder-main { overflow: hidden; }
.strip-grid .admin-badge, .strip-grid .overdue-tag { white-space: normal; line-height: 1.35; }

/* ============================ Budget ============================ */
.budget-add {
  display: flex; align-items: center; gap: 0.5rem;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.14), rgba(168, 85, 247, 0.08)), var(--card-bg);
  border: 1px solid rgba(129, 140, 248, 0.3); border-radius: 20px;
  padding: 0.45rem 0.45rem 0.45rem 1.1rem; box-shadow: 0 8px 26px rgba(79, 70, 229, 0.16);
}
.budget-add:focus-within { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.2); }
.budget-add input {
  background: transparent; border: none; outline: none; color: var(--text-main);
  font-family: inherit; font-size: 1rem; padding: 0.7rem 0; min-width: 0;
}
.budget-add input::placeholder { color: rgba(148, 163, 184, 0.55); }
.budget-add-label { flex: 1; }
.budget-add-amount {
  display: inline-flex; align-items: center; gap: 0.25rem; width: 8.5rem; flex-shrink: 0;
  border-left: 1px solid var(--glass-border); padding-left: 0.8rem;
  color: var(--text-dim); font-weight: 600;
}
.budget-add-amount input { width: 100%; font-variant-numeric: tabular-nums; font-weight: 600; }
.budget-add .modal-btn { padding: 0.75rem 1.4rem; border-radius: 14px; }
#budget-add-error:empty { display: none; }
#budget-add-error { margin: 0.6rem 0 0; }

.budget-copy-cta {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  margin-top: 1rem; padding: 0.9rem 1.1rem; border-radius: 16px;
  border: 1px dashed rgba(129, 140, 248, 0.45); background: var(--primary-soft);
  font-size: 0.9rem; color: var(--text-secondary);
}
.budget-copy-cta strong { color: var(--text-main); }

.budget-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 1.1rem; margin-top: 1.1rem; align-items: start; }
.budget-col { transition: border-color 0.2s, box-shadow 0.2s; }
.budget-col.drop-target { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25); }
.budget-col[data-zone="done"] .panel-head h2 { color: #4ade80; }
.budget-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; min-height: 2.5rem; }
.budget-empty { margin: 0.2rem 0 0; font-size: 0.82rem; color: var(--text-dim); }

.budget-item {
  position: relative; overflow: hidden; border-radius: 14px; touch-action: pan-y;
  transition: opacity 0.2s, transform 0.2s;
}
.budget-item.leaving { opacity: 0.4; }
.budget-item.arriving { animation: budget-in 0.35s ease-out; }
@keyframes budget-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.budget-item.dragging { opacity: 0.35; }
.budget-swipe-bg {
  position: absolute; inset: 0; display: flex; align-items: center; padding-left: 1rem;
  background: rgba(34, 197, 94, 0.18); color: #4ade80; font-size: 0.8rem; font-weight: 700;
  opacity: 0; transition: opacity 0.15s, background 0.15s;
}
.budget-item.done .budget-swipe-bg { background: rgba(245, 158, 11, 0.16); color: #fbbf24; }
.budget-item.swiping .budget-swipe-bg { opacity: 1; }
.budget-item.swipe-ready .budget-swipe-bg { background: rgba(34, 197, 94, 0.35); }
.budget-item.done.swipe-ready .budget-swipe-bg { background: rgba(245, 158, 11, 0.32); }
.budget-row {
  position: relative; display: flex; align-items: center; gap: 0.7rem;
  padding: 0.7rem 0.6rem 0.7rem 0.75rem; background: #1b2336;
  border: 1px solid var(--glass-border); border-radius: 14px;
  transition: transform 0.18s ease-out, border-color 0.2s;
  cursor: grab;
}
.budget-item.swiping .budget-row { transition: none; }
.budget-row:hover { border-color: rgba(129, 140, 248, 0.35); }
.budget-check {
  width: 26px; height: 26px; flex-shrink: 0; border-radius: 50%; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  border: 2px solid rgba(148, 163, 184, 0.5); background: transparent; color: transparent;
  font-size: 0.8rem; font-weight: 800; transition: all 0.2s;
}
.budget-check:hover { border-color: #4ade80; color: rgba(74, 222, 128, 0.6); }
.budget-item.done .budget-check { background: var(--success); border-color: var(--success); color: #fff; }
.budget-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.1rem; cursor: pointer; }
.budget-label { font-size: 0.94rem; font-weight: 500; color: var(--text-main); overflow-wrap: anywhere; }
.budget-notes { font-size: 0.75rem; color: var(--text-dim); }
.budget-amount {
  font-family: var(--font-display); font-size: 1rem; font-weight: 700; color: var(--text-main);
  font-variant-numeric: tabular-nums; white-space: nowrap; cursor: pointer;
}
.budget-item.done .budget-label, .budget-item.done .budget-amount { color: var(--text-dim); }
.budget-item.done .budget-label { text-decoration: line-through; text-decoration-color: rgba(148, 163, 184, 0.5); }
.budget-del {
  width: 28px; height: 28px; flex-shrink: 0; border-radius: 8px; border: none; cursor: pointer;
  background: transparent; color: var(--text-dim); font-size: 1.15rem; line-height: 1; opacity: 0.5;
}
.budget-del:hover { opacity: 1; color: var(--critical); background: rgba(239, 68, 68, 0.12); }

.budget-totals {
  margin-top: 1.1rem; padding: 1.2rem 1.3rem; border-radius: 24px;
  background: var(--card-bg); border: 1px solid var(--glass-border);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); box-shadow: var(--card-shadow);
}
.budget-progress { height: 8px; border-radius: 10px; background: rgba(255, 255, 255, 0.07); overflow: hidden; margin-bottom: 1.1rem; }
.budget-progress-fill {
  display: block; height: 100%; border-radius: 10px;
  background: linear-gradient(90deg, #22c55e, #4ade80); transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}
.budget-total-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.budget-total { display: flex; flex-direction: column; gap: 0.25rem; min-width: 0; }
.budget-total-value {
  font-family: var(--font-display); font-size: 1.6rem; font-weight: 800; letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums; overflow-wrap: anywhere;
}
.budget-total.remaining .budget-total-value { color: #fbbf24; }
.budget-total.completed .budget-total-value { color: #4ade80; }
.budget-total.total { text-align: right; align-items: flex-end; }
.budget-total-sub { font-size: 0.78rem; color: var(--text-dim); }
.budget-copy-next { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--glass-border); display: flex; justify-content: flex-end; }
.budget-copy-next .admin-btn { color: var(--primary-light); }

@media (max-width: 720px) {
  .budget-cols { grid-template-columns: 1fr; }
  .budget-total-grid { grid-template-columns: 1fr 1fr; }
  .budget-total.total { grid-column: 1 / -1; text-align: left; align-items: flex-start; border-top: 1px solid var(--glass-border); padding-top: 0.8rem; }
}
@media (max-width: 520px) {
  .budget-add { flex-wrap: wrap; padding: 0.6rem; border-radius: 18px; }
  .budget-add-label { flex: 1 1 100%; padding: 0.4rem 0.4rem; }
  .budget-add-amount { flex: 1; width: auto; border-left: none; padding-left: 0.4rem; border-top: 1px solid var(--glass-border); padding-top: 0.4rem; }
  .budget-total-value { font-size: 1.3rem; }
  .budget-copy-next { justify-content: stretch; }
  .budget-copy-next .admin-btn { width: 100%; }
}

/* Part-payments */
.budget-part { display: flex; flex-direction: column; gap: 0.3rem; margin-top: 0.35rem; }
.budget-part-bar { display: block; height: 5px; border-radius: 6px; background: rgba(255, 255, 255, 0.08); overflow: hidden; max-width: 220px; }
.budget-part-bar > span { display: block; height: 100%; border-radius: 6px; background: linear-gradient(90deg, #22c55e, #4ade80); }
.budget-part-text { font-size: 0.75rem; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.budget-part-text strong { color: #fbbf24; font-weight: 700; }
.budget-over { font-size: 0.72rem; font-weight: 700; color: #f87171; margin-top: 0.2rem; }
.budget-total-sub.over { color: #f87171; font-weight: 600; }
.budget-pay {
  flex-shrink: 0; height: 28px; padding: 0 0.55rem; border-radius: 8px; cursor: pointer;
  font-family: inherit; font-size: 0.75rem; font-weight: 700;
  color: #4ade80; background: rgba(34, 197, 94, 0.1); border: 1px solid rgba(34, 197, 94, 0.3);
  transition: all 0.2s;
}
.budget-pay:hover { background: rgba(34, 197, 94, 0.2); border-color: #4ade80; }
.pay-input {
  width: 100%; border: 1px solid var(--glass-border); border-radius: 14px; background: var(--input-bg);
  padding: 0.3rem 0.9rem; font-size: 1.2rem;
}
.pay-input input {
  background: transparent; border: none; outline: none; color: var(--text-main);
  font-family: var(--font-display); font-size: 1.3rem; font-weight: 700; padding: 0.5rem 0; width: 100%;
}
.pay-input:focus-within { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.25); }
.pay-quick { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-top: 0.6rem; }
.pay-quick .admin-btn { color: #4ade80; }
#pay-form .modal-error:empty { display: none; }

/* Totals now lead the Budget page */
.budget-totals { margin: 0 0 1.1rem; }
.budget-copy-next.bottom { margin-top: 1.1rem; padding-top: 0; border-top: none; }

/* ============================ Notes / To-do ============================ */
/* Shared rich-text look: editor and card previews */
.rich { font-size: 0.96rem; line-height: 1.6; color: var(--text-main); overflow-wrap: anywhere; }
.rich > :first-child { margin-top: 0; }
.rich p, .rich div { margin: 0 0 0.45rem; }
.rich h1, .rich h2, .rich h3 { font-family: var(--font-display); font-weight: 700; letter-spacing: -0.01em; margin: 1rem 0 0.4rem; line-height: 1.25; }
.rich h1 { font-size: 1.45rem; } .rich h2 { font-size: 1.25rem; } .rich h3 { font-size: 1.08rem; }
.rich ul, .rich ol { margin: 0.2rem 0 0.6rem; padding-left: 1.5rem; }
.rich li { margin: 0.15rem 0; }
.rich li::marker { color: var(--primary-light); }
.rich blockquote {
  margin: 0.5rem 0; padding: 0.4rem 0.9rem; border-left: 3px solid var(--primary);
  background: var(--primary-soft); border-radius: 0 10px 10px 0; color: var(--text-secondary);
}
.rich a, .rich .lnk { color: var(--primary-light); text-decoration: underline; text-underline-offset: 2px; }
.rich img { display: block; max-width: 100%; max-height: 460px; width: auto; height: auto; border-radius: 12px; margin: 0.4rem 0; border: 1px solid var(--glass-border); }
.rich hr { border: none; border-top: 1px solid var(--glass-border); margin: 1rem 0; }
.rich code { font-family: ui-monospace, Menlo, monospace; font-size: 0.88em; background: rgba(255,255,255,0.07); padding: 0.1rem 0.35rem; border-radius: 5px; }
.rich pre { background: rgba(0,0,0,0.3); padding: 0.8rem; border-radius: 10px; overflow-x: auto; }

/* Checklists: a drawn box on the left, ticked items struck through */
.rich ul.checklist { list-style: none; padding-left: 0.1rem; }
.rich ul.checklist > li { position: relative; padding-left: 2rem; min-height: 1.6em; }
.rich ul.checklist > li::before {
  content: ""; position: absolute; left: 0.1rem; top: 0.22em; width: 1.15rem; height: 1.15rem;
  border: 2px solid rgba(148, 163, 184, 0.6); border-radius: 6px; background: transparent;
  cursor: pointer; transition: all 0.15s;
}
.rich ul.checklist > li[data-checked="true"]::before {
  background: var(--primary) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.5 8.5l3 3 6-7' fill='none' stroke='white' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 80% no-repeat;
  border-color: var(--primary);
}
.rich ul.checklist > li[data-checked="true"] { color: var(--text-dim); text-decoration: line-through; text-decoration-color: rgba(148, 163, 184, 0.5); }

/* Board */
.notes-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.notes-head .section-title { margin: 0; }
.notes-search {
  flex: 0 1 280px; min-width: 0; font-family: inherit; font-size: 0.9rem; color: var(--text-main);
  background: var(--input-bg); border: 1px solid var(--glass-border); border-radius: 12px; padding: 0.6rem 0.9rem;
}
.notes-search:focus { outline: none; border-color: var(--primary); }
.notes-capture { margin-bottom: 1.4rem; }
.notes-capture input { flex: 1; }
.notes-group-title {
  font-size: 0.7rem; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--text-dim); margin: 0 0 0.7rem 0.2rem;
}
.notes-grid { columns: 3 260px; column-gap: 1rem; margin-bottom: 1.6rem; }
.note-card {
  display: block; break-inside: avoid; margin-bottom: 1rem; overflow: hidden; text-decoration: none; color: inherit;
  background: var(--card-bg); border: 1px solid var(--glass-border); border-radius: 18px;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); box-shadow: var(--card-shadow);
  transition: transform 0.2s, border-color 0.2s;
}
.note-card:hover { transform: translateY(-3px); border-color: rgba(129, 140, 248, 0.4); }
.note-card.pinned { border-color: rgba(129, 140, 248, 0.35); }
.note-card-img { display: block; width: 100%; max-height: 180px; object-fit: cover; border-bottom: 1px solid var(--glass-border); }
.note-card-body { padding: 0.95rem 1.05rem; }
.note-card-title { font-family: var(--font-display); font-size: 1.05rem; font-weight: 700; margin: 0 0 0.4rem; line-height: 1.3; }
.pin-dot { font-size: 0.8em; margin-right: 0.3rem; }
.note-card-preview {
  font-size: 0.86rem; line-height: 1.5; color: var(--text-secondary); max-height: 13rem; overflow: hidden;
  -webkit-mask-image: linear-gradient(180deg, #000 75%, transparent); mask-image: linear-gradient(180deg, #000 75%, transparent);
}
.note-card-preview img { display: none; }
.note-card-preview h1, .note-card-preview h2, .note-card-preview h3 { font-size: 0.95rem; margin: 0.4rem 0 0.2rem; }
.note-card-preview ul.checklist > li::before { width: 0.95rem; height: 0.95rem; }
.note-card-preview ul.checklist > li { padding-left: 1.6rem; }
.note-card-meta { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; margin-top: 0.6rem; }
.note-chip {
  font-size: 0.7rem; font-weight: 700; color: var(--primary-light); background: var(--primary-soft);
  border-radius: 999px; padding: 0.15rem 0.55rem;
}
.note-chip.all-done { color: #4ade80; background: rgba(34, 197, 94, 0.12); }
.note-updated { margin-left: auto; font-size: 0.72rem; color: var(--text-dim); }
.notes-empty { text-align: center; padding: 2.5rem 1rem; color: var(--text-secondary); border: 1px dashed var(--glass-border); border-radius: 20px; }
.notes-empty-icon { font-size: 2.4rem; margin-bottom: 0.5rem; }
.notes-empty code, .field-hint code { background: rgba(255,255,255,0.07); padding: 0.05rem 0.35rem; border-radius: 5px; color: var(--text-main); }
.notes-noresults { color: var(--text-dim); text-align: center; }

/* Editor page */
.note-bar, .note-sheet, .note-actions { max-width: 860px; margin-left: auto; margin-right: auto; }
.note-bar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 0.8rem; }
.note-status { font-size: 0.78rem; color: var(--text-dim); }
.note-status.saved { color: #4ade80; }
.note-status.error { color: var(--critical); }
.note-sheet {
  background: var(--card-bg); border: 1px solid var(--glass-border); border-radius: 24px;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); box-shadow: var(--card-shadow);
  padding: 1.3rem 1.4rem 1.6rem;
}
.note-title {
  width: 100%; border: none; outline: none; background: transparent; color: var(--text-main);
  font-family: var(--font-display); font-size: 1.7rem; font-weight: 800; letter-spacing: -0.02em; padding: 0.2rem 0 0.6rem;
}
.note-title::placeholder { color: rgba(148, 163, 184, 0.45); }
.note-toolbar {
  position: sticky; top: 0.75rem; z-index: 20;
  display: flex; align-items: center; gap: 0.2rem; flex-wrap: wrap;
  margin: 0 -0.4rem 1rem; padding: 0.35rem; border-radius: 14px;
  background: rgba(15, 23, 42, 0.92); border: 1px solid var(--glass-border);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.note-toolbar button {
  min-width: 36px; height: 36px; padding: 0 0.5rem; border-radius: 10px; border: 1px solid transparent;
  background: transparent; color: var(--text-secondary); font-family: inherit; font-size: 0.95rem; cursor: pointer;
  transition: all 0.15s;
}
.note-toolbar button:hover { background: rgba(255, 255, 255, 0.07); color: var(--text-main); }
.note-toolbar button.on { background: var(--primary-soft); border-color: rgba(99, 102, 241, 0.45); color: var(--primary-light); }
.tb-sep { width: 1px; height: 22px; background: var(--glass-border); margin: 0 0.25rem; }
.note-editor { min-height: 45vh; outline: none; caret-color: var(--primary-light); }
.note-editor:empty::before { content: attr(data-placeholder); color: rgba(148, 163, 184, 0.5); pointer-events: none; }
.note-actions { display: flex; justify-content: space-between; gap: 0.6rem; margin-top: 1rem; }
.link-open {
  position: absolute; z-index: 60; font-size: 0.78rem; font-weight: 700; text-decoration: none;
  color: #fff; background: var(--primary); padding: 0.35rem 0.7rem; border-radius: 999px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

@media (max-width: 860px) {
  .note-toolbar { top: 0.5rem; }
}
@media (max-width: 520px) {
  .note-sheet { padding: 1rem 1rem 1.3rem; border-radius: 20px; }
  .note-title { font-size: 1.4rem; }
  .note-toolbar { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -0.3rem 0.9rem; }
  .note-toolbar::-webkit-scrollbar { display: none; }
  .note-toolbar button { flex-shrink: 0; }
  .notes-search { flex: 1 1 100%; }
  .notes-capture .quickadd-icon { display: none; }
}

/* Dashboard: finished items step aside */
.done-hidden { display: none !important; }
.panel-head h2 .panel-count { margin-left: 0.35rem; font-family: var(--font-body); }
.done-toggle { color: #4ade80; }
.done-toggle.on { color: var(--text-dim); }
.panel-empty {
  margin: 0 0 0.6rem; padding: 0.85rem 1rem; border-radius: 14px; font-size: 0.88rem;
  color: #4ade80; background: rgba(34, 197, 94, 0.08); border: 1px solid rgba(34, 197, 94, 0.25);
}
/* An empty list box shouldn't draw an empty frame */
.habit-list.flush:not(:has(> li:not(.done-hidden):not(.focus-hidden))) { display: none; }
.kpi-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 1000px) { .kpi-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 720px) { .kpi-grid.three { grid-template-columns: 1fr 1fr; } .kpi-grid.three > :last-child { grid-column: 1 / -1; } }

/* Stats page */
.stats-kpis { margin-bottom: 1.25rem; }
.stats-week { margin-bottom: 1.5rem; }
.stats-kpis .kpi-sub { white-space: normal; }
.stats-kpis .ring { width: 72px; height: 72px; }

/* ===================== Item status (done / partly / missed / not today) ===================== */
.habit-item .mark {
  width: 24px; height: 24px; flex-shrink: 0; padding: 0; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%; border: 2px solid rgba(148, 163, 184, 0.55); background: transparent;
  color: #fff; font-size: 0.8rem; font-weight: 800; line-height: 1; transition: all 0.15s;
}
.habit-item.sub-item .mark { width: 20px; height: 20px; font-size: 0.7rem; }
.habit-item .mark:hover { border-color: var(--primary-light); }
.mark-icon::before { content: ""; }
.habit-item.st-done .mark { background: var(--success); border-color: var(--success); }
.habit-item.st-done .mark-icon::before { content: "✓"; }
.habit-item.st-partial .mark { border-color: #f59e0b; background: linear-gradient(90deg, #f59e0b 50%, transparent 50%); }
.habit-item.st-missed .mark { background: rgba(239, 68, 68, 0.9); border-color: #ef4444; }
.habit-item.st-missed .mark-icon::before { content: "✗"; }
.habit-item.st-excused .mark { border-color: rgba(148, 163, 184, 0.7); color: var(--text-dim); }
.habit-item.st-excused .mark-icon::before { content: "⊘"; font-size: 0.95rem; }

.habit-item.st-partial .habit-text { color: #fbbf24; }
.habit-item.st-missed .habit-text { color: #fca5a5; }
.habit-item.st-excused .habit-text { color: var(--text-dim); font-style: italic; }
.habit-item.st-missed, .habit-item.st-excused, .habit-item.st-partial { background: rgba(255, 255, 255, 0.015); }
.habit-reason { font-size: 0.74rem; color: #f87171; line-height: 1.3; }
.readonly-mark { cursor: default; }

.mark-more {
  flex-shrink: 0; width: 30px; height: 30px; border-radius: 9px; border: 1px solid transparent; cursor: pointer;
  background: transparent; color: var(--text-dim); font-size: 1.1rem; line-height: 1; letter-spacing: 1px;
  margin-left: auto; transition: all 0.15s;
}
.mark-more:hover { background: rgba(255, 255, 255, 0.06); color: var(--text-main); border-color: var(--glass-border); }
.habit-item .focus-tag + .mark-more, .habit-item .mark-more + .focus-tag { margin-left: 0.3rem; }
.habit-item .focus-tag { margin-left: 0.3rem; }
.habit-item:has(.mark-more) .focus-tag { order: 5; }

.mark-menu {
  position: absolute; z-index: 80; width: 230px; padding: 0.4rem;
  background: rgba(15, 23, 42, 0.98); border: 1px solid var(--glass-border); border-radius: 16px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.55); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  display: flex; flex-direction: column; gap: 0.15rem; animation: fadeIn 0.15s ease-out;
}
.mark-menu[hidden] { display: none; }
.mark-menu button[data-set] {
  display: flex; align-items: center; gap: 0.65rem; width: 100%; text-align: left; cursor: pointer;
  padding: 0.6rem 0.7rem; border-radius: 10px; border: 1px solid transparent; background: transparent;
  font-family: inherit; font-size: 0.9rem; font-weight: 500; color: var(--text-main);
}
.mark-menu button[data-set]:hover { background: rgba(255, 255, 255, 0.06); }
.mark-menu button[data-set].on { background: var(--primary-soft); border-color: rgba(99, 102, 241, 0.4); }
.mm-icon {
  width: 22px; height: 22px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  font-size: 0.75rem; font-weight: 800; flex-shrink: 0;
}
.mm-done .mm-icon { background: var(--success); color: #fff; }
.mm-partial .mm-icon { background: linear-gradient(90deg, #f59e0b 50%, transparent 50%); border: 2px solid #f59e0b; color: transparent; }
.mm-missed .mm-icon { background: #ef4444; color: #fff; }
.mm-excused .mm-icon { border: 2px solid rgba(148, 163, 184, 0.7); color: var(--text-dim); font-size: 0.9rem; }
.mark-menu .mm-clear { color: var(--text-dim); font-size: 0.82rem; justify-content: center; border-top: 1px solid var(--glass-border); border-radius: 0 0 10px 10px; margin-top: 0.2rem; }
.mm-reason { display: flex; gap: 0.35rem; padding: 0.2rem 0.2rem 0.4rem; }
.mm-reason[hidden] { display: none; }
.mm-reason input {
  flex: 1; min-width: 0; font-family: inherit; font-size: 0.85rem; color: var(--text-main);
  background: var(--input-bg); border: 1px solid var(--glass-border); border-radius: 10px; padding: 0.5rem 0.6rem;
}
.mm-reason input:focus { outline: none; border-color: var(--primary); }
.mm-reason .modal-btn { padding: 0.45rem 0.75rem; font-size: 0.8rem; }

/* Stats: how items were marked */
.mk { display: inline-flex; align-items: center; gap: 0.2rem; font-size: 0.74rem; font-weight: 700; padding: 0.1rem 0.45rem; border-radius: 999px; white-space: nowrap; }
.mk.done { color: #4ade80; background: rgba(34, 197, 94, 0.1); }
.mk.partial { color: #fbbf24; background: rgba(245, 158, 11, 0.1); }
.mk.missed { color: #f87171; background: rgba(239, 68, 68, 0.1); }
.mk.excused { color: var(--text-dim); background: rgba(255, 255, 255, 0.05); }
.mk.unmarked { color: var(--text-dim); background: transparent; border: 1px dashed rgba(148, 163, 184, 0.35); }
.mark-mix { display: flex; gap: 0.3rem; flex-wrap: wrap; }
.mark-legend { display: flex; gap: 0.35rem; flex-wrap: wrap; }
.stats-missed { margin-bottom: 1.5rem; }
.missed-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.9rem; }
.missed-top { display: flex; align-items: center; justify-content: space-between; gap: 0.8rem; flex-wrap: wrap; }
.missed-label { font-weight: 600; font-size: 0.93rem; }
.missed-counts { display: flex; align-items: center; gap: 0.3rem; flex-wrap: wrap; }
.missed-of { font-size: 0.74rem; color: var(--text-dim); margin-left: 0.2rem; }
.missed-bar { display: flex; height: 6px; border-radius: 6px; overflow: hidden; background: rgba(255, 255, 255, 0.06); margin: 0.45rem 0 0.2rem; gap: 2px; }
.missed-bar .seg { display: block; height: 100%; }
.missed-bar .seg.missed { background: #ef4444; }
.missed-bar .seg.unmarked { background: repeating-linear-gradient(45deg, rgba(148,163,184,0.55) 0 3px, transparent 3px 6px); }
.missed-bar .seg.partial { background: #f59e0b; }
.missed-bar .seg.excused { background: rgba(148, 163, 184, 0.35); }
.missed-reasons { list-style: none; margin: 0.35rem 0 0; padding: 0; display: flex; flex-direction: column; gap: 0.2rem; }
.missed-reasons li { font-size: 0.8rem; color: var(--text-secondary); }
.reason-date { font-size: 0.7rem; color: var(--text-dim); margin-right: 0.35rem; font-variant-numeric: tabular-nums; }
@media (max-width: 520px) {
  .dash #checklist-list > .habit-item .habit-main { padding-right: 2.2rem; }
  .dash #checklist-list > .habit-item .mark-more { position: absolute; right: 0.45rem; bottom: 0.45rem; }
  .dash #checklist-list > .habit-item .shop-btn { position: absolute; right: 2.6rem; bottom: 0.55rem; margin: 0; }
  .dash #checklist-list > .habit-item:has(.shop-btn) .habit-main { padding-right: 4.2rem; }
}
.via-model { color: var(--text-dim); font-size: 0.74rem; }

/* ============ In-page confirmations, notices and panels (no popups) ============ */
.inline-host { list-style: none; margin: 0; padding: 0; border: none !important; background: none !important; }
.inline-confirm {
  display: flex; align-items: center; justify-content: space-between; gap: 0.6rem 1rem; flex-wrap: wrap;
  margin: 0.5rem 0; padding: 0.7rem 0.9rem; border-radius: 14px;
  background: var(--primary-soft); border: 1px solid rgba(99, 102, 241, 0.45);
  animation: fadeIn 0.18s ease-out; font-size: 0.88rem; color: var(--text-main);
}
.inline-confirm.danger { background: rgba(239, 68, 68, 0.1); border-color: rgba(239, 68, 68, 0.4); }
.inline-confirm-text { flex: 1 1 220px; line-height: 1.4; }
.inline-confirm-actions { display: inline-flex; gap: 0.45rem; margin-left: auto; }
.inline-confirm .modal-btn { padding: 0.45rem 0.9rem; font-size: 0.82rem; }
.inline-notice {
  margin: 0.45rem 0; padding: 0.55rem 0.85rem; border-radius: 12px; font-size: 0.84rem;
  animation: fadeIn 0.18s ease-out;
}
.inline-notice.error { color: #fca5a5; background: rgba(239, 68, 68, 0.1); border: 1px solid rgba(239, 68, 68, 0.3); }
.inline-notice.ok { color: #4ade80; background: rgba(34, 197, 94, 0.1); border: 1px solid rgba(34, 197, 94, 0.3); }

/* Forms that used to be dialogs now open inline under what you tapped */
.inline-panel { margin: 0.5rem 0 0.8rem; animation: fadeIn 0.18s ease-out; }
.inline-panel[hidden] { display: none; }
.inline-panel > .modal-box {
  max-width: none; width: 100%; animation: none; padding: 1rem 1.1rem; border-radius: 16px;
  background: rgba(15, 23, 42, 0.6); border: 1px solid rgba(99, 102, 241, 0.4); box-shadow: none;
  backdrop-filter: none; -webkit-backdrop-filter: none;
}
.inline-panel > .modal-box h3 { font-size: 1rem; margin-bottom: 0.6rem; }

/* Item status options: a row of chips under the item */
.mark-menu.inline {
  position: static; width: auto; margin: 0.15rem 0.6rem 0.6rem; padding: 0.45rem;
  flex-direction: row; flex-wrap: wrap; gap: 0.35rem; border-radius: 14px;
  background: rgba(15, 23, 42, 0.7); box-shadow: none; backdrop-filter: none; -webkit-backdrop-filter: none;
}
.mark-menu.inline button[data-set] { width: auto; flex: 0 0 auto; padding: 0.45rem 0.75rem; font-size: 0.84rem; border: 1px solid var(--glass-border); }
.mark-menu.inline .mm-reason { flex: 1 1 100%; order: 10; padding: 0.15rem 0 0; }
.mark-menu.inline .mm-clear { border-top: none; margin-top: 0; border-radius: 10px; }

/* Note editor: "Open site ↗" sits at the end of the sticky toolbar */
.note-link-open {
  margin-left: auto; flex-shrink: 0; font-size: 0.78rem; font-weight: 700; text-decoration: none; white-space: nowrap;
  color: #fff; background: var(--primary); padding: 0.4rem 0.75rem; border-radius: 999px;
  max-width: 220px; overflow: hidden; text-overflow: ellipsis;
}
.note-link-open[hidden] { display: none; }
.reminder-item.strip-leaving { opacity: 0; transform: scale(0.97); transition: opacity 0.25s, transform 0.25s; }

/* To-do quick capture (AI writes title + details) */
.capture {
  margin-bottom: 0.5rem; padding: 0.8rem 0.8rem 0.6rem; border-radius: 20px;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.14), rgba(168, 85, 247, 0.08)), var(--card-bg);
  border: 1px solid rgba(129, 140, 248, 0.3); box-shadow: 0 8px 26px rgba(79, 70, 229, 0.16);
}
.capture:focus-within { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.2); }
.capture textarea {
  width: 100%; min-height: 4.5rem; resize: none; border: none; outline: none; background: transparent;
  color: var(--text-main); font-family: inherit; font-size: 0.98rem; line-height: 1.55; padding: 0.3rem 0.4rem;
}
.capture textarea::placeholder { color: rgba(148, 163, 184, 0.6); }
.capture-actions { display: flex; align-items: center; justify-content: flex-end; gap: 0.5rem; flex-wrap: wrap; padding-top: 0.4rem; border-top: 1px solid var(--glass-border); }
.capture-hint { margin-right: auto; font-size: 0.74rem; color: var(--text-dim); }
.capture-status:empty { display: none; }
.capture-status { font-size: 0.84rem; margin: 0.55rem 0.3rem 0.1rem; color: var(--text-dim); }
.capture-status.working::before {
  content: ""; display: inline-block; width: 11px; height: 11px; margin-right: 0.45rem; vertical-align: -1px;
  border-radius: 50%; border: 2px solid rgba(129, 140, 248, 0.3); border-top-color: var(--primary-light);
  animation: spin 0.8s linear infinite;
}
.capture-status.error { color: #fca5a5; }
.capture-blank { margin: 0 0 1.4rem 0.3rem; }
.as-link { background: none; border: none; padding: 0; cursor: pointer; font-family: inherit; }
.note-provider { font-size: 0.72rem; color: var(--primary-light); margin-left: 0.6rem; }
@media (max-width: 520px) { .capture-hint { display: none; } .capture-actions .modal-btn { flex: 1; } }
.note-toolbar .tb-ai { color: #fff; background: linear-gradient(135deg, #6366f1, #a855f7); border-color: transparent; font-weight: 600; font-size: 0.82rem; padding: 0 0.75rem; }
.note-toolbar .tb-ai:hover { filter: brightness(1.1); color: #fff; background: linear-gradient(135deg, #6366f1, #a855f7); }
.note-toolbar .tb-ai.busy { opacity: 0.6; cursor: progress; }
.organise-done { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; margin: -0.4rem 0 0.9rem; }
.rich strong { color: #fff; font-weight: 700; }
.rich ul.checklist > li[data-checked="true"] strong { color: inherit; }

/* ============================ Bookings (owner) ============================ */
.bk-tz { font-size: 0.8rem; color: var(--text-dim); }
.bk-share { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; align-items: center; margin-bottom: 1.25rem;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.14), rgba(168, 85, 247, 0.08)), var(--card-bg); border-color: rgba(129, 140, 248, 0.3); }
.bk-share-main { flex: 1 1 340px; min-width: 0; }
.bk-link { display: inline-block; margin: 0.25rem 0 0.2rem; font-size: 1.05rem; font-weight: 700; color: var(--primary-light); word-break: break-all; }
.bk-share-actions { display: flex; flex-direction: column; gap: 0.6rem; align-items: flex-end; }
.bk-switch { display: inline-flex; align-items: center; gap: 0.45rem; font-size: 0.85rem; color: var(--text-secondary); cursor: pointer; }
.bk-switch input { width: 18px; height: 18px; accent-color: var(--primary); }
.panel + .panel, .panel + form.panel, form.panel + .panel, details.panel { margin-top: 1.25rem; }
.bk-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.6rem; }
.bk-item { display: flex; gap: 0.9rem; align-items: flex-start; padding: 0.8rem 0.9rem; border: 1px solid var(--glass-border); border-radius: 14px; background: rgba(0,0,0,0.14); flex-wrap: wrap; }
.bk-item.cancelled { opacity: 0.55; }
.bk-when { flex: 0 0 200px; font-size: 0.86rem; color: var(--primary-light); }
.bk-main { flex: 1 1 280px; min-width: 0; }
.bk-title { font-weight: 600; }
.bk-meta { font-size: 0.78rem; color: var(--text-dim); margin-top: 0.15rem; word-break: break-word; }
.bk-meta a { color: var(--primary-light); }
.bk-agenda { margin: 0.4rem 0 0; padding-left: 1.1rem; font-size: 0.85rem; color: var(--text-secondary); }
.bk-prep, .bk-notes { font-size: 0.8rem; color: var(--text-dim); margin-top: 0.3rem; }
.bk-hours { display: flex; flex-direction: column; gap: 0.45rem; }
.bk-day { display: flex; align-items: center; gap: 0.8rem; flex-wrap: wrap; padding: 0.5rem 0; border-bottom: 1px solid var(--gridline); }
.bk-day-name { width: 3rem; font-weight: 700; font-size: 0.88rem; }
.bk-windows { flex: 1; display: flex; flex-wrap: wrap; gap: 0.45rem; align-items: center; }
.bk-window { display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.2rem 0.3rem 0.2rem 0.45rem; border: 1px solid var(--glass-border); border-radius: 10px; background: var(--input-bg); color: var(--text-dim); }
.bk-window input, .bk-type input, .bk-type-add input {
  font-family: inherit; font-size: 0.86rem; color: var(--text-main); background: transparent; border: none; outline: none; color-scheme: dark;
}
.bk-off { font-size: 0.82rem; color: var(--text-dim); font-style: italic; }
.bk-x { border: none; background: transparent; color: var(--text-dim); font-size: 1.05rem; cursor: pointer; padding: 0 0.25rem; }
.bk-x:hover { color: var(--critical); }
.bk-types { list-style: none; margin: 0 0 0.7rem; padding: 0; display: flex; flex-direction: column; gap: 0.45rem; }
.bk-type, .bk-type-add { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.bk-type .t-name, .bk-type-add input[name=name] { flex: 1 1 220px; padding: 0.55rem 0.7rem; border: 1px solid var(--glass-border); border-radius: 10px; background: var(--input-bg); }
.bk-type-add input[type=date] { padding: 0.5rem 0.7rem; border: 1px solid var(--glass-border); border-radius: 10px; background: var(--input-bg); }
.bk-dur { display: inline-flex; align-items: center; gap: 0.3rem; font-size: 0.82rem; color: var(--text-dim); }
.bk-dur input { width: 4.2rem; padding: 0.55rem 0.5rem; border: 1px solid var(--glass-border) !important; border-radius: 10px; background: var(--input-bg) !important; }
.bk-blocks { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.7rem; }
.bk-block { display: inline-flex; align-items: center; gap: 0.2rem; font-size: 0.8rem; padding: 0.2rem 0.3rem 0.2rem 0.6rem; border-radius: 999px; background: rgba(239, 68, 68, 0.1); color: #fca5a5; }
.bk-past summary { cursor: pointer; font-weight: 600; color: var(--text-secondary); margin-bottom: 0.7rem; }

/* ============================ Public booking page ============================ */
.book-wrap { max-width: 760px; padding-top: 2rem; }
.book-head { display: flex; gap: 1rem; align-items: center; margin-bottom: 1.2rem; }
.book-logo { width: 52px; height: 52px; border-radius: 14px; }
.book-title { font-family: var(--font-display); font-size: clamp(1.4rem, 4vw, 1.9rem); font-weight: 800; letter-spacing: -0.02em; margin: 0; }
.book-intro { margin: 0.35rem 0 0; color: var(--text-secondary); font-size: 0.95rem; line-height: 1.5; }
.book-panel { padding: 1.3rem; }
.book-step + .book-step { margin-top: 1.4rem; padding-top: 1.2rem; border-top: 1px solid var(--glass-border); }
.book-step .kpi-label { margin-bottom: 0.6rem; }
.book-step-head { display: flex; align-items: center; justify-content: space-between; gap: 0.8rem; flex-wrap: wrap; }
.book-step-head .kpi-label { margin: 0; }
.book-types { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.book-type {
  display: flex; flex-direction: column; align-items: flex-start; gap: 0.1rem; padding: 0.7rem 1rem; cursor: pointer;
  border-radius: 14px; border: 1px solid var(--glass-border); background: rgba(255,255,255,0.03); color: var(--text-main); font-family: inherit;
}
.book-type span { font-size: 0.78rem; color: var(--text-dim); }
.book-type.on { border-color: var(--primary); background: var(--primary-soft); box-shadow: 0 4px 15px rgba(99,102,241,0.2); }
.book-tz { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.82rem; color: var(--text-dim); }
.book-tz select { max-width: 220px; font-family: inherit; font-size: 0.82rem; color: var(--text-main); background: var(--input-bg); border: 1px solid var(--glass-border); border-radius: 10px; padding: 0.4rem 0.5rem; }
.book-days { display: flex; gap: 0.45rem; overflow-x: auto; padding: 0.7rem 0 0.4rem; scrollbar-width: thin; }
.book-day {
  flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; gap: 0.1rem; min-width: 70px; padding: 0.55rem 0.6rem; cursor: pointer;
  border-radius: 14px; border: 1px solid var(--glass-border); background: rgba(255,255,255,0.03); color: var(--text-main); font-family: inherit;
}
.book-day span { font-size: 0.72rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.06em; }
.book-day strong { font-size: 0.95rem; }
.book-day em { font-style: normal; font-size: 0.68rem; color: #4ade80; }
.book-day.on { border-color: var(--primary); background: var(--primary-soft); }
.book-times { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 0.45rem; margin-top: 0.6rem; }
.book-time {
  padding: 0.65rem 0.4rem; border-radius: 12px; cursor: pointer; font-family: inherit; font-size: 0.9rem; font-weight: 600;
  border: 1px solid rgba(99,102,241,0.45); background: transparent; color: var(--primary-light);
}
.book-time:hover { background: var(--primary-soft); }
.book-time.on { background: var(--primary); color: #fff; border-color: var(--primary); }
.book-loading { font-size: 0.88rem; color: var(--text-dim); padding: 0.4rem 0; }
.book-chosen { margin-bottom: 0.8rem; padding: 0.6rem 0.8rem; border-radius: 12px; background: var(--primary-soft); color: var(--text-main); font-weight: 600; font-size: 0.9rem; }
.book-form textarea { font-family: inherit; font-size: 0.88rem; color: var(--text-main); background: var(--input-bg); border: 1px solid var(--glass-border); border-radius: 10px; padding: 0.55rem 0.7rem; resize: vertical; text-transform: none; letter-spacing: normal; }
.book-form .modal-btn.block { margin-top: 0.6rem; }
.hp { position: absolute !important; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.book-foot { text-align: center; font-size: 0.78rem; color: var(--text-dim); margin-top: 1rem; }
.book-foot a { color: var(--primary-light); }
.book-done { text-align: center; padding: 2rem 1.4rem; }
.book-done-icon { width: 58px; height: 58px; margin: 0 auto 0.9rem; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem; font-weight: 800; color: #fff; background: var(--success); box-shadow: 0 0 24px rgba(34,197,94,0.4); }
.book-done-icon.cancelled { background: rgba(148,163,184,0.4); box-shadow: none; }
.book-done-card { margin: 1.2rem auto; max-width: 440px; padding: 1rem 1.2rem; border-radius: 16px; border: 1px solid var(--glass-border); background: rgba(0,0,0,0.18); text-align: left; }
.book-done-type { font-size: 0.75rem; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-dim); }
.book-done-when { font-family: var(--font-display); font-size: 1.15rem; font-weight: 700; margin: 0.3rem 0 0.15rem; }
.book-done-tz, .book-done-who { font-size: 0.82rem; color: var(--text-dim); }
.book-done-notes { font-size: 0.85rem; color: var(--text-secondary); margin-top: 0.5rem; }
.book-done-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: center; }

/* ================================== Mail ================================== */
.nav-badge { display: inline-block; min-width: 1.15rem; padding: 0 0.32rem; margin-left: 0.2rem; border-radius: 999px; font-size: 0.66rem; font-weight: 800; line-height: 1.15rem; text-align: center; color: #fff; background: #ef4444; }
.mail-bar { display: flex; justify-content: space-between; align-items: center; gap: 0.8rem; flex-wrap: wrap; margin-bottom: 0.8rem; font-size: 0.85rem; color: var(--text-dim); }
.mail-actions { display: flex; gap: 0.4rem; }
.mail-err { color: #fca5a5; font-size: 0.85rem; }
.mail-empty { text-align: center; padding: 2.2rem 1rem; }
.mail-list-panel { padding: 0.4rem; }
.mail-list { list-style: none; margin: 0; padding: 0; }
.mail-row { display: grid; grid-template-columns: 190px minmax(0, 1fr) auto; gap: 0.9rem; align-items: baseline; padding: 0.7rem 0.8rem; border-radius: 12px; text-decoration: none; color: var(--text-dim); font-size: 0.88rem; }
.mail-row:hover { background: rgba(255,255,255,0.04); }
.mail-row.unread { color: var(--text-main); }
.mail-row.unread .mail-from, .mail-row.unread .mail-subject strong { font-weight: 700; color: #fff; }
.mail-row .mail-subject strong { font-weight: 500; }
.mail-from, .mail-subject { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-snippet { color: var(--text-dim); font-weight: 400; }
.mail-when { font-size: 0.76rem; color: var(--text-dim); white-space: nowrap; }
.mail-pager { display: flex; justify-content: space-between; padding: 0.6rem; }
.mail-view { padding: 1.3rem; }
.mail-view-subject { font-family: var(--font-display); font-size: 1.4rem; font-weight: 700; margin: 0 0 0.7rem; }
.mail-view-meta { font-size: 0.88rem; margin-bottom: 0.8rem; }
.mail-view-addr, .mail-view-sub { color: var(--text-dim); font-size: 0.8rem; }
.mail-attach, .mail-images { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; font-size: 0.82rem; color: var(--text-secondary); padding: 0.5rem 0.7rem; border-radius: 10px; background: rgba(255,255,255,0.04); margin-bottom: 0.7rem; }
.mail-frame { width: 100%; min-height: 200px; border: none; border-radius: 12px; background: #fff; display: block; }
.mail-view-foot { margin-top: 0.9rem; }
.mail-mini { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.3rem; }
.mail-mini-row { display: flex; flex-direction: column; gap: 0.1rem; padding: 0.6rem 0.75rem; border-radius: 12px; text-decoration: none; color: inherit; background: rgba(0,0,0,0.14); border: 1px solid transparent; }
.mail-mini-row:hover { border-color: rgba(129,140,248,0.35); }
.mail-mini-top { display: flex; justify-content: space-between; gap: 0.6rem; font-size: 0.86rem; }
.mail-mini-top strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-mini-subject { font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-mini .mail-snippet { font-size: 0.76rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gmail-steps { margin: 0 0 0.9rem 1.1rem; padding: 0; line-height: 1.6; }
@media (max-width: 640px) {
  .mail-row { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "from when" "subj subj"; row-gap: 0.15rem; }
  .mail-from { grid-area: from; } .mail-when { grid-area: when; } .mail-subject { grid-area: subj; }
  .bk-when { flex-basis: 100%; }
  .bk-share-actions { align-items: stretch; width: 100%; }
}


/* ===================== App navigation: sidebar / tab bar ===================== */
:root { --side-w: 244px; --side-w-mini: 76px; }
.brand-logo { width: 30px; height: 30px; flex-shrink: 0; border-radius: 8px; box-shadow: 0 0 14px var(--primary-glow); }
.brand-text {
  font-family: var(--font-display); font-size: 1.08rem; font-weight: 800; letter-spacing: -0.02em; white-space: nowrap;
  background: linear-gradient(135deg, #818cf8 0%, #c084fc 100%); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.nav-icon { width: 20px; height: 20px; flex-shrink: 0; }

body:has(.sidebar) { padding-left: var(--side-w); }
.sidebar {
  position: fixed; top: 0; bottom: 0; left: 0; z-index: 60; width: var(--side-w);
  display: flex; flex-direction: column; gap: 1rem; padding: 1.1rem 0.85rem 1rem; overflow-y: auto;
  background: rgba(9, 13, 28, 0.82); border-right: 1px solid var(--glass-border);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
}
.side-brand { display: flex; align-items: center; gap: 0.6rem; text-decoration: none; padding: 0.2rem 0.45rem 0.6rem; }
.side-nav { display: flex; flex-direction: column; gap: 1rem; }
.side-group { display: flex; flex-direction: column; gap: 0.15rem; }
.side-heading { font-size: 0.64rem; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-dim); opacity: 0.8; padding: 0 0.75rem 0.35rem; }
.side-link {
  position: relative; display: flex; align-items: center; gap: 0.75rem; padding: 0.6rem 0.75rem; border-radius: 12px;
  color: var(--text-dim); text-decoration: none; font-size: 0.9rem; font-weight: 600; transition: background 0.15s, color 0.15s;
}
.side-link:hover { color: var(--text-main); background: rgba(255, 255, 255, 0.05); }
.side-link.active { color: #fff; background: linear-gradient(135deg, rgba(99, 102, 241, 0.3), rgba(168, 85, 247, 0.18)); box-shadow: inset 0 0 0 1px rgba(129, 140, 248, 0.35); }
.side-link.active .nav-icon { color: var(--primary-light); }
.side-link.active::before { content: ""; position: absolute; left: -0.85rem; top: 22%; bottom: 22%; width: 3px; border-radius: 0 3px 3px 0; background: var(--primary-light); }
.side-badge { margin-left: auto; min-width: 1.25rem; padding: 0 0.35rem; border-radius: 999px; font-size: 0.68rem; font-weight: 800; line-height: 1.25rem; text-align: center; color: #fff; background: #ef4444; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 0.5rem; padding-top: 0.8rem; border-top: 1px solid var(--glass-border); }
.side-user { display: flex; align-items: center; gap: 0.6rem; padding: 0.5rem 0.4rem 0.2rem 0.55rem; }
.side-avatar {
  width: 34px; height: 34px; flex-shrink: 0; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  font-weight: 800; color: #fff; background: linear-gradient(135deg, #6366f1, #a855f7);
}
.side-user-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.side-user-text strong { font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-user-text small { font-size: 0.72rem; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-logout { margin-left: auto; display: flex; }
.side-logout button { display: inline-flex; padding: 0.45rem; border-radius: 10px; border: 1px solid transparent; background: transparent; color: var(--text-dim); cursor: pointer; }
.side-logout button:hover { color: var(--critical); background: rgba(239, 68, 68, 0.1); }
.mobile-head, .tabbar { display: none; }
.wrap { padding-top: 1.4rem; }

/* Small laptops / tablets: icon-only rail */
@media (max-width: 1180px) and (min-width: 861px) {
  body:has(.sidebar) { padding-left: var(--side-w-mini); }
  .sidebar { width: var(--side-w-mini); padding: 1rem 0.7rem; align-items: stretch; }
  .sidebar .side-label { display: none; }
  .side-brand { justify-content: center; padding: 0.2rem 0 0.6rem; }
  .side-link { justify-content: center; padding: 0.7rem 0; }
  .side-link.active::before { left: -0.7rem; }
  .side-group + .side-group { padding-top: 0.8rem; border-top: 1px solid var(--glass-border); }
  .side-badge { position: absolute; top: 0.25rem; right: 0.35rem; margin: 0; min-width: 1rem; line-height: 1rem; font-size: 0.6rem; }
  .side-user { flex-direction: column; padding: 0.3rem 0; gap: 0.4rem; }
  .side-logout { margin: 0; }
}

/* Phones: slim header + bottom tab bar */
@media (max-width: 860px) {
  body:has(.sidebar) { padding-left: 0; padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
  .sidebar { display: none; }
  .wrap { padding-top: 0.6rem; }
  .mobile-head { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; padding: 0.3rem 0.1rem 0.9rem; }
  .mobile-head .side-brand { padding: 0; }
  .mobile-settings { display: inline-flex; padding: 0.5rem; border-radius: 12px; color: var(--text-dim); border: 1px solid var(--glass-border); background: rgba(255, 255, 255, 0.03); }
  .mobile-settings.active { color: var(--primary-light); background: var(--primary-soft); border-color: rgba(99, 102, 241, 0.4); }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
    padding: 0.35rem 0.4rem calc(0.35rem + env(safe-area-inset-bottom));
    background: rgba(9, 13, 28, 0.92); border-top: 1px solid var(--glass-border);
    backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  }
  .tab { display: flex; flex-direction: column; align-items: center; gap: 0.2rem; padding: 0.4rem 0.2rem; border-radius: 12px; color: var(--text-dim); text-decoration: none; font-size: 0.68rem; font-weight: 600; }
  .tab.active { color: var(--primary-light); }
  .tab.active .tab-icon { background: var(--primary-soft); }
  .tab-icon { position: relative; display: inline-flex; padding: 0.25rem 0.9rem; border-radius: 999px; transition: background 0.15s; }
  .tab-dot { position: absolute; top: -0.2rem; right: 0.3rem; min-width: 1rem; padding: 0 0.25rem; border-radius: 999px; font-size: 0.58rem; font-weight: 800; line-height: 1rem; text-align: center; color: #fff; background: #ef4444; }
}
@media (max-width: 360px) { .mobile-head .brand-text { display: none; } }

/* "More" page (phones) */
.more-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 0.7rem; }
.more-tile {
  display: flex; flex-direction: column; gap: 0.25rem; padding: 1rem; border-radius: 18px; text-decoration: none; color: var(--text-main);
  background: var(--card-bg); border: 1px solid var(--glass-border); transition: border-color 0.15s, transform 0.15s;
}
.more-tile:hover { border-color: rgba(129, 140, 248, 0.4); transform: translateY(-2px); }
.more-emoji { font-size: 1.5rem; }
.more-tile small { color: var(--text-dim); font-size: 0.78rem; line-height: 1.35; }
.more-logout { margin-top: 1.2rem; }

/* Dashboard: Meetings (bookings today & tomorrow) */
.meetings { margin-bottom: 1.1rem; }
.meeting-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 0.7rem; }
.meeting-card {
  display: flex; flex-direction: column; gap: 0.25rem; padding: 0.85rem 1rem; border-radius: 16px; text-decoration: none; color: inherit;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.16), rgba(168, 85, 247, 0.08)), var(--card-bg);
  border: 1px solid rgba(129, 140, 248, 0.35); transition: transform 0.15s, border-color 0.15s;
}
.meeting-card:hover { transform: translateY(-2px); border-color: var(--primary-light); }
.meeting-card.live { border-color: #4ade80; box-shadow: 0 0 0 1px rgba(74, 222, 128, 0.4); }
.meeting-when { font-size: 0.8rem; color: var(--primary-light); }
.meeting-now { margin-left: 0.3rem; font-size: 0.66rem; font-weight: 800; text-transform: uppercase; color: #052e16; background: #4ade80; border-radius: 999px; padding: 0.05rem 0.45rem; }
.meeting-title { font-weight: 600; font-size: 0.95rem; }
.meeting-who, .meeting-agenda { font-size: 0.78rem; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Dashboard header: Now + next meeting + next reminder */
.hero-chips { display: flex; flex-direction: column; align-items: flex-end; gap: 0.45rem; max-width: 100%; }
.hero-chip {
  display: inline-flex; align-items: center; gap: 0.5rem; max-width: 100%; padding: 0.45rem 0.9rem; border-radius: 999px;
  font-size: 0.84rem; color: var(--text-main); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  background: rgba(255, 255, 255, 0.04); border: 1px solid var(--glass-border);
}
.hero-chip:hover { border-color: rgba(129, 140, 248, 0.45); }
.hero-chip.meet { border-color: rgba(129, 140, 248, 0.4); }
.hero-chip.rem { border-color: rgba(245, 158, 11, 0.35); }
.hero-chip.rem .now-label { color: #fbbf24; }
@media (max-width: 860px) { .hero-chips { align-items: stretch; width: 100%; } .hero-chip { justify-content: flex-start; } }

/* Mail: permissions banner, tabs, stars, toolbar, reply, compose */
.mail-upgrade { display: flex; align-items: center; justify-content: space-between; gap: 0.8rem; flex-wrap: wrap; margin-bottom: 0.9rem;
  padding: 0.8rem 1rem; border-radius: 14px; background: var(--primary-soft); border: 1px solid rgba(99, 102, 241, 0.4); font-size: 0.88rem; }
.mail-tabs { display: flex; gap: 0.35rem; flex-wrap: wrap; margin-bottom: 0.7rem; }
.mail-tab { padding: 0.4rem 0.85rem; border-radius: 999px; font-size: 0.82rem; font-weight: 600; text-decoration: none; color: var(--text-dim); border: 1px solid var(--glass-border); }
.mail-tab.on { color: var(--primary-light); background: var(--primary-soft); border-color: rgba(99, 102, 241, 0.45); }
.mail-li { display: flex; align-items: center; gap: 0.1rem; border-radius: 12px; }
.mail-li .mail-row { flex: 1; min-width: 0; }
.mail-li.is-important { background: rgba(245, 158, 11, 0.05); }
.mail-li.is-starred { background: rgba(250, 204, 21, 0.06); }
.mail-star { flex-shrink: 0; width: 34px; height: 34px; border: none; background: transparent; cursor: pointer; font-size: 1.05rem; color: rgba(148, 163, 184, 0.45); border-radius: 10px; }
.mail-star:hover { color: #facc15; background: rgba(255, 255, 255, 0.04); }
.mail-star.on { color: #facc15; }
.mail-imp { margin-right: 0.3rem; font-size: 0.8em; }
/* Mail search bar + multi-select */
.mail-searchbar { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.8rem; padding: 0.35rem 0.4rem 0.35rem 0.9rem;
  border-radius: 14px; background: var(--glass-bg, rgba(30, 41, 59, 0.6)); border: 1px solid var(--glass-border); }
.mail-searchbar:focus-within { border-color: rgba(99, 102, 241, 0.6); box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15); }
.mail-searchbar svg { width: 18px; height: 18px; flex-shrink: 0; color: var(--text-dim); }
.mail-searchbar input[type="search"] { flex: 1; min-width: 0; border: none; background: transparent; color: var(--text-main); font: inherit; font-size: 0.92rem; padding: 0.45rem 0.2rem; outline: none; }
.mail-searchbar .modal-btn { padding: 0.45rem 1rem; font-size: 0.85rem; }
.mail-search-note { margin: -0.3rem 0 0.7rem; font-size: 0.82rem; color: var(--text-dim); }
.mail-bulk { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; flex-wrap: wrap; min-height: 38px; padding: 0.2rem 0.6rem 0.4rem; border-bottom: 1px solid var(--glass-border); margin-bottom: 0.2rem; }
.mail-check-all { display: inline-flex; align-items: center; gap: 0.5rem; font-size: 0.82rem; color: var(--text-dim); cursor: pointer; }
.mail-bulk-actions { display: inline-flex; gap: 0.35rem; flex-wrap: wrap; }
.mail-check, .mail-check-all input { width: 17px; height: 17px; accent-color: #6366f1; cursor: pointer; flex-shrink: 0; }
.mail-li .mail-check { margin: 0 0.15rem 0 0.6rem; }
.mail-li.is-selected { background: rgba(99, 102, 241, 0.12); }
@media (max-width: 640px) {
  .mail-searchbar .modal-btn { display: none; }
  .mail-bulk-actions .admin-btn { padding: 0.35rem 0.6rem; }
}
.mail-compose-btn { padding: 0.45rem 0.9rem; font-size: 0.82rem; }
.mail-toolbar { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 1rem; padding-bottom: 0.9rem; border-bottom: 1px solid var(--glass-border); }
.mail-toolbar .mv-star.on { color: #facc15; border-color: rgba(250, 204, 21, 0.45); }
.mail-reply, .compose { display: flex; flex-direction: column; gap: 0.6rem; }
.mail-reply { margin: 0 0 1rem; padding: 0.9rem; border-radius: 14px; border: 1px solid rgba(99, 102, 241, 0.4); background: rgba(15, 23, 42, 0.6); }
.mail-reply-head { font-size: 0.84rem; color: var(--text-secondary); }
.mail-reply textarea, .compose textarea, .compose input {
  width: 100%; font-family: inherit; font-size: 0.92rem; color: var(--text-main); background: var(--input-bg);
  border: 1px solid var(--glass-border); border-radius: 12px; padding: 0.65rem 0.8rem; resize: vertical;
}
.mail-reply textarea:focus, .compose textarea:focus, .compose input:focus { outline: none; border-color: var(--primary); }
.compose-row { display: grid; grid-template-columns: 70px 1fr; align-items: center; gap: 0.6rem; }
.compose-row label { font-size: 0.78rem; font-weight: 700; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.08em; }
.compose-from { font-size: 0.9rem; color: var(--text-secondary); }
.compose-contacts { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; }
.compose-contacts .kpi-label { margin-right: 0.3rem; }
.compose-chip { font-family: inherit; font-size: 0.78rem; padding: 0.3rem 0.7rem; border-radius: 999px; cursor: pointer; color: var(--primary-light); background: var(--primary-soft); border: 1px solid rgba(99, 102, 241, 0.35); }

/* Contacts */
.contact-form { margin-bottom: 1.2rem; }
.contact-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.3rem; }
.contact-list li { display: flex; align-items: center; gap: 0.5rem; }
.contact-row { flex: 1; min-width: 0; display: flex; align-items: center; gap: 0.75rem; padding: 0.6rem 0.7rem; border-radius: 12px; text-decoration: none; color: inherit; }
.contact-row:hover { background: rgba(255, 255, 255, 0.04); }
.contact-main { display: flex; flex-direction: column; min-width: 0; }
.contact-main small { color: var(--text-dim); font-size: 0.78rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.contact-head { display: flex; gap: 1rem; align-items: flex-start; margin-bottom: 1rem; }
.contact-avatar { width: 54px; height: 54px; font-size: 1.4rem; }
.contact-sub { color: var(--text-dim); font-size: 0.88rem; margin-top: 0.2rem; word-break: break-word; }
.contact-sub a { color: var(--primary-light); }
#contact-edit { margin-top: 1rem; }
@media (max-width: 520px) { .compose-row { grid-template-columns: 1fr; gap: 0.25rem; } }

/* Shopping suggestions (Amazon affiliate links): a warm round button at the
   end of a row; hovering (or keyboard focus) slides the product name out. */
.shop-btn {
  flex: none; align-self: center; display: inline-flex; align-items: center; gap: 0;
  height: 30px; min-width: 30px; padding: 0 7px; border-radius: 999px; text-decoration: none;
  background: linear-gradient(135deg, #fbbf24, #f97316); color: #fff;
  box-shadow: 0 2px 10px rgba(249, 115, 22, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.35);
  transition: transform 0.15s, box-shadow 0.15s, gap 0.2s;
}
.shop-ico { display: inline-grid; place-items: center; width: 16px; height: 16px; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.25)); }
.shop-ico svg { width: 16px; height: 16px; }
.shop-label {
  max-width: 0; overflow: hidden; white-space: nowrap; font-size: 0.74rem; font-weight: 800; text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);
  transition: max-width 0.25s ease;
}
.shop-btn:hover, .shop-btn:focus-visible {
  transform: translateY(-1px) scale(1.04); gap: 0.35rem;
  box-shadow: 0 4px 16px rgba(249, 115, 22, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}
.shop-btn:hover .shop-label, .shop-btn:focus-visible .shop-label { max-width: 11rem; }
.shop-btn[data-shop-rule^="gift"] {
  background: linear-gradient(135deg, #f472b6, #a855f7); color: #fff;
  box-shadow: 0 2px 10px rgba(217, 70, 239, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}
@keyframes shop-pop { 0%, 100% { transform: none; } 50% { transform: scale(1.12); } }
.shop-btn .shop-ico { display: inline-block; animation: shop-pop 2.6s ease-in-out 1s 2; }
@media (prefers-reduced-motion: reduce) { .shop-btn .shop-ico { animation: none; } .shop-label { transition: none; } }
.habit-item.checked .shop-btn, .reminder-item.done .shop-btn, .budget-item.done .shop-btn { display: none; }
.shop-toggle { display: flex; align-items: center; gap: 0.5rem; margin: 0.25rem 0 0.75rem; font-size: 0.9rem; }
/* In task rows the cart sits at the right edge, just before ⋯. */
.habit-item .shop-btn { margin-left: auto; margin-right: 0.15rem; }
.habit-item .shop-btn + .mark-more { margin-left: 0; }
.strip-grid .shop-btn { margin-left: auto; }

/* Dashboard: birthdays & anniversaries in the next 10 days, with a gift link */
.celebrations { margin-bottom: 1.25rem; transition: opacity 0.25s, transform 0.25s; }
.celebrations.leaving, .celebration.leaving { opacity: 0; transform: translateY(-4px); }
.celebration-pause {
  background: none; border: none; color: var(--text-dim); font-size: 0.78rem; font-weight: 600; cursor: pointer; padding: 0.2rem 0.4rem;
}
.celebration-pause:hover { color: var(--text-main); text-decoration: underline; }
.celebration-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 0.75rem; }
.celebration {
  position: relative; display: grid; grid-template-columns: 42px minmax(0, 1fr) 26px; align-items: center;
  grid-template-areas: "emoji main x" "emoji shop shop"; gap: 0.55rem 0.8rem; padding: 0.85rem 0.9rem 0.85rem 1rem;
  border-radius: 18px; border: 1px solid rgba(244, 114, 182, 0.35);
  background: linear-gradient(135deg, rgba(244, 114, 182, 0.14), rgba(168, 85, 247, 0.12) 60%, rgba(251, 191, 36, 0.1));
  transition: opacity 0.25s, transform 0.25s;
}
.celebration.is-today { border-color: rgba(251, 191, 36, 0.6); box-shadow: 0 0 0 1px rgba(251, 191, 36, 0.25), 0 6px 24px rgba(244, 114, 182, 0.2); }
.celebration-emoji {
  grid-area: emoji; align-self: start; display: grid; place-items: center; width: 42px; height: 42px; border-radius: 14px;
  font-size: 1.35rem; background: rgba(255, 255, 255, 0.08);
}
.celebration-main { grid-area: main; min-width: 0; display: flex; flex-direction: column; gap: 0.15rem; }
.celebration-main strong { font-size: 0.95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.celebration-main small { font-size: 0.76rem; font-weight: 700; color: #f9a8d4; }
.celebration-shop {
  grid-area: shop; justify-self: start; display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.5rem 0.85rem; border-radius: 999px;
  font-size: 0.8rem; font-weight: 800; color: #fff; text-decoration: none; white-space: nowrap;
  background: linear-gradient(135deg, #f472b6, #a855f7);
  box-shadow: 0 3px 14px rgba(217, 70, 239, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.3);
  transition: transform 0.15s, box-shadow 0.15s;
}
.celebration-shop .shop-ico svg { width: 15px; height: 15px; }
.celebration-shop:hover { transform: translateY(-1px) scale(1.03); box-shadow: 0 6px 20px rgba(217, 70, 239, 0.55); }
.celebration-dismiss {
  grid-area: x; align-self: start; width: 26px; height: 26px; border-radius: 50%; border: none; cursor: pointer;
  background: rgba(255, 255, 255, 0.06); color: var(--text-dim); font-size: 1rem; line-height: 1;
}
.celebration-dismiss:hover { background: rgba(255, 255, 255, 0.14); color: var(--text-main); }
@media (max-width: 520px) {
  .celebration-list { grid-template-columns: 1fr; }
}
