/* ═══════════════════════════════════════════════════════════════════
   BUDGET SECTION STYLES
═══════════════════════════════════════════════════════════════════ */
.section-budget {
  overflow-y: auto;
  padding-bottom: 40px;
}

/* ── Toolbar ── */
.budget-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  margin: 18px 18px 16px;
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--shadow);
  flex-wrap: wrap;
}
.budget-toolbar .toolbar-label { font-size: 0.72rem; font-weight: 800; color: var(--muted); letter-spacing: 1px; text-transform: uppercase; }
.budget-toolbar .toolbar-sep { width: 1px; height: 24px; background: var(--border); }
.budget-toolbar .toolbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.budget-week-nav { display: flex; align-items: center; gap: 4px; background: var(--bg-1); border-radius: 999px; padding: 3px; }
.budget-week-nav .week-btn {
  background: transparent; border: none; font-size: 1.1rem; font-weight: 900;
  color: var(--violet-d); cursor: pointer; padding: 4px 10px; border-radius: 999px;
  font-family: inherit;
}
.budget-week-nav .week-btn:hover { background: rgba(167,139,250,0.2); }
.budget-week-nav #budgetWeekLabel {
  font-weight: 800; color: var(--text); font-size: 0.85rem;
  padding: 0 10px; font-variant-numeric: tabular-nums;
}
.budget-toolbar .closed-badge {
  background: linear-gradient(135deg, var(--mint), #42b878);
  color: white; font-size: 0.68rem; font-weight: 800; letter-spacing: 0.5px;
  padding: 3px 10px; border-radius: 999px; text-transform: uppercase;
}

/* .btn-ghost was designed for the dark planner header where white text works.
   The budget toolbar sits on a white surface — override to readable tones. */
.budget-toolbar .btn-ghost {
  background: var(--bg-1);
  color: var(--text2);
  border: 1.5px solid var(--border);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
.budget-toolbar .btn-ghost:hover {
  background: var(--bg-2);
  color: var(--text);
  border-color: var(--violet);
}
.budget-toolbar .btn-ghost[disabled] {
  opacity: 0.5; cursor: not-allowed;
}
.budget-toolbar .btn-ghost[disabled]:hover {
  background: var(--bg-1); color: var(--text2); border-color: var(--border);
}
/* The Edit (re-open) button gets a gentle rose accent so it stands out
   next to the "Manifested" badge when the week is closed. */
.budget-toolbar #budgetReopenBtn {
  background: linear-gradient(135deg, rgba(255,107,157,0.15), rgba(167,139,250,0.15));
  color: var(--pink-d);
  border-color: rgba(255,107,157,0.35);
  font-weight: 800;
}
.budget-toolbar #budgetReopenBtn:hover {
  background: linear-gradient(135deg, rgba(255,107,157,0.28), rgba(167,139,250,0.28));
  color: var(--pink-d);
  border-color: var(--pink);
}

/* ── Dashboard grid ── */
.budget-dashboard {
  display: flex; flex-direction: column; gap: 16px;
  padding: 0 18px;
}

.dash-hero {
  background: var(--surface);
  border-radius: 22px;
  padding: 24px 26px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
  animation: dash-card-in 0.45s ease backwards;
}
.dash-hero-bg {
  position: absolute; inset: 0;
  background:
    radial-gradient(circle at 15% 30%, rgba(255,107,157,0.15) 0%, transparent 50%),
    radial-gradient(circle at 85% 70%, rgba(167,139,250,0.18) 0%, transparent 55%);
  pointer-events: none;
}
.dash-hero-body { position: relative; display: flex; align-items: center; gap: 24px; z-index: 1; }
.dash-hero-ring { flex-shrink: 0; width: 140px; height: 140px; position: relative; }
.dash-hero-ring svg { display: block; }
.dash-hero-ring-center {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; pointer-events: none; text-align: center;
}
.dash-hero-pct {
  font-family: 'Playfair Display', serif;
  font-size: 2rem; font-weight: 700; color: var(--text);
  font-variant-numeric: tabular-nums; line-height: 1;
}
.dash-hero-pct-sub { font-size: 0.7rem; color: var(--muted); font-weight: 700; letter-spacing: 1px; text-transform: uppercase; margin-top: 4px; }
.dash-hero-text { flex: 1; min-width: 0; }
.dash-hero-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.6rem; font-weight: 700; color: var(--text);
  letter-spacing: -0.3px; line-height: 1.15; margin-bottom: 4px;
}
.dash-hero-sub { font-size: 0.9rem; color: var(--text2); font-weight: 500; line-height: 1.4; }

/* ── Stat strip ── */
.dash-stats {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px;
  animation: dash-card-in 0.5s ease 0.08s backwards;
}
.dash-stat {
  background: var(--surface);
  border-radius: 18px; padding: 16px 18px;
  box-shadow: var(--shadow);
}
.dash-stat-label {
  font-size: 0.66rem; font-weight: 800; color: var(--muted);
  letter-spacing: 1.1px; text-transform: uppercase; margin-bottom: 6px;
}
.dash-stat-value {
  font-family: 'Playfair Display', serif;
  font-size: 1.5rem; font-weight: 700; color: var(--text);
  font-variant-numeric: tabular-nums; line-height: 1.1;
}
.dash-stat-sub { font-size: 0.72rem; color: var(--text2); font-weight: 600; margin-top: 3px; }
.dash-stat.positive .dash-stat-value { color: var(--mint-d); }
.dash-stat.negative .dash-stat-value { color: #c44040; }
@media (max-width: 600px) {
  .dash-stats { grid-template-columns: 1fr; }
}

/* ── Ring-cards (Planned / Actual / Net) ── */
.dash-hero-textonly .dash-hero-body { display: none; }  /* legacy; new hero uses no body ring */
.dash-hero-textonly .dash-hero-text {
  position: relative; z-index: 1;
}
.dash-stats-rings .dash-stat-ring {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
}
.dash-stat-ring-wrap {
  position: relative;
  width: 92px;
  height: 92px;
  flex-shrink: 0;
}
.dash-stat-ring-wrap svg { display: block; }
.dash-stat-ring-center {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  pointer-events: none; text-align: center;
}
.dash-stat-ring-value {
  font-family: 'Playfair Display', serif;
  font-size: 1.05rem; font-weight: 700; color: var(--text);
  font-variant-numeric: tabular-nums; line-height: 1.05;
}
.dash-stat-ring-sub {
  font-size: 0.56rem; font-weight: 800; color: var(--muted);
  letter-spacing: 0.9px; text-transform: uppercase; margin-top: 3px;
}
.dash-stat-ring-body { min-width: 0; }
.dash-stat-ring-title {
  font-size: 0.66rem; font-weight: 800; color: var(--muted);
  letter-spacing: 1.1px; text-transform: uppercase; margin-bottom: 8px;
}
.dash-stat-ring-inout {
  display: grid; grid-template-columns: 1fr; gap: 4px;
}
.dash-stat-ring-inout > div {
  display: flex; justify-content: space-between; gap: 8px;
  font-size: 0.82rem; font-variant-numeric: tabular-nums;
}
.dash-stat-ring-inout .inout-label {
  font-weight: 700; color: var(--muted);
  font-size: 0.72rem;
}
.dash-stat-ring-inout .inout-value {
  font-weight: 800; color: var(--text);
}
.dash-stat-ring.positive .dash-stat-ring-value { color: var(--mint-d); }
.dash-stat-ring.negative .dash-stat-ring-value { color: #c44040; }

/* Card accent = matching palette tint */
.dash-stat-ring[data-tone="lavender"] { background: linear-gradient(135deg, rgba(236,220,248,0.35), var(--surface) 55%); }
.dash-stat-ring[data-tone="good"]     { background: linear-gradient(135deg, rgba(96,211,148,0.12), var(--surface) 55%); }
.dash-stat-ring[data-tone="warn"]     { background: linear-gradient(135deg, rgba(255,209,102,0.15), var(--surface) 55%); }
.dash-stat-ring[data-tone="over"]     { background: linear-gradient(135deg, rgba(196,64,64,0.10), var(--surface) 55%); }
.dash-stat-ring[data-tone="empty"]    { background: linear-gradient(135deg, rgba(167,139,250,0.12), var(--surface) 55%); }
.dash-stat-ring[data-tone="rose"]     { background: linear-gradient(135deg, rgba(252,212,220,0.45), var(--surface) 55%); }

@media (max-width: 700px) {
  .dash-stats-rings { grid-template-columns: 1fr; }
  .dash-stats-rings .dash-stat-ring { padding: 12px 14px; }
}

/* ── Two-ring layout (hero savings-goal rings) ── */
.dash-stats.dash-stats-rings-2 {
  grid-template-columns: 1fr 1fr;
  max-width: 720px;
  margin-left: auto; margin-right: auto;
}

/* Ring cards are now <button> — remove button chrome, keep tap affordance */
button.dash-stat-ring {
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  padding: 14px 16px;
  width: 100%;
}
button.dash-stat-ring.dash-stat-ring-clickable {
  transition: transform 0.15s ease;
}
button.dash-stat-ring.dash-stat-ring-clickable:hover {
  transform: translateY(-1px);
}
button.dash-stat-ring:focus-visible {
  outline: 2px solid var(--violet, #8b7dd8);
  outline-offset: 4px;
  border-radius: 14px;
}
@media (prefers-reduced-motion: reduce) {
  button.dash-stat-ring.dash-stat-ring-clickable:hover { transform: none !important; }
}

@media (max-width: 600px) {
  .dash-stats.dash-stats-rings-2 {
    grid-template-columns: 1fr;
    max-width: none;
  }
}

/* ── Category cards ── */
.dash-categories {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
}
.cat-card {
  background: var(--surface);
  border-radius: 18px; padding: 16px 18px;
  box-shadow: var(--shadow);
  cursor: pointer; border: none; font-family: inherit;
  text-align: left; position: relative; overflow: hidden;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  animation: dash-card-in 0.5s ease backwards;
}
.cat-card:hover { transform: translateY(-2px); box-shadow: 0 12px 28px rgba(167,139,250,0.18); }
.cat-card[disabled] { cursor: not-allowed; opacity: 0.72; }
.cat-card[disabled]:hover { transform: none; box-shadow: var(--shadow); }
.cat-card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.cat-card-swatch { width: 12px; height: 12px; border-radius: 50%; border: 2.5px solid; flex-shrink: 0; }
.cat-card-name { font-weight: 800; color: var(--text); font-size: 0.95rem; flex: 1; }
.cat-card-kind-badge {
  font-size: 0.62rem; font-weight: 800; letter-spacing: 0.8px;
  text-transform: uppercase; padding: 2px 8px; border-radius: 999px;
}
.cat-card-kind-badge.income { background: rgba(96,211,148,0.18); color: var(--mint-d); }
.cat-card-kind-badge.expense { background: rgba(167,139,250,0.18); color: var(--violet-d); }

.cat-card-amounts {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 6px;
  font-variant-numeric: tabular-nums;
}
.cat-card-amount { font-size: 1.1rem; font-weight: 800; color: var(--text); }
.cat-card-amount-label { font-size: 0.66rem; font-weight: 800; color: var(--muted); letter-spacing: 0.8px; text-transform: uppercase; }
.cat-card-amount.planned { color: var(--text2); }
.cat-card-progress {
  height: 6px; background: var(--bg-2); border-radius: 999px; margin-top: 12px; overflow: hidden;
}
.cat-card-progress-fill {
  height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--mint) 0%, #42b878 100%);
  transition: width 0.6s ease;
}
.cat-card-progress-fill.warn { background: linear-gradient(90deg, var(--sun), var(--sun-d)); }
.cat-card-progress-fill.over { background: linear-gradient(90deg, #f0a0a0, #c44040); }

.cat-card-empty {
  font-size: 0.78rem; color: var(--muted); font-style: italic; margin-top: 6px;
}

@keyframes dash-card-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Status dot in the toolbar ── */
.budget-toolbar .status-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--mint);
  transition: background 0.2s;
}
.budget-toolbar .status-dot.saving { background: var(--sun); }
.budget-toolbar .status-dot.error  { background: #c44040; }
.budget-toolbar .status-text { font-size: 0.72rem; font-weight: 700; color: var(--muted); }

/* ── Empty/loading states ── */
.budget-empty {
  text-align: center; padding: 40px 20px; color: var(--muted);
}
.budget-empty-emoji { font-size: 2rem; margin-bottom: 10px; }
.budget-empty-title { font-family: 'Playfair Display', serif; font-size: 1.2rem; color: var(--text); margin-bottom: 4px; }
.budget-empty-sub { font-size: 0.85rem; font-style: italic; }

/* ── Mobile ── */
@media (max-width: 700px) {
  .budget-toolbar { padding: 10px 12px; gap: 6px; margin: 12px 12px 12px; }
  .budget-toolbar .btn-label { display: none; }
  .budget-dashboard { padding: 0 12px; gap: 12px; }
  .dash-hero { padding: 18px 18px; }
  .dash-hero-body { flex-direction: column; align-items: flex-start; gap: 16px; }
  .dash-hero-ring { align-self: center; }
  .dash-hero-title { font-size: 1.3rem; }
}

/* ═══════════════════════════════════════════════════════════════════
   LINE-ITEM DRAWER
═══════════════════════════════════════════════════════════════════ */
.drawer-backdrop {
  position: fixed; inset: 0;
  background: rgba(43, 24, 64, 0.35);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  z-index: 500;
  animation: drawer-fade-in 0.22s ease;
}
@keyframes drawer-fade-in { from { opacity: 0; } to { opacity: 1; } }

.li-drawer {
  position: fixed;
  top: env(safe-area-inset-top);
  right: 0;
  bottom: env(safe-area-inset-bottom);
  width: min(420px, 92vw);
  background: var(--surface);
  box-shadow: -12px 0 40px rgba(167, 139, 250, 0.28);
  z-index: 501;
  display: flex; flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.22, 0.61, 0.36, 1);
}
.li-drawer.open { transform: translateX(0); }
.li-drawer-head {
  padding: calc(18px + env(safe-area-inset-top)) 20px 14px;
  border-bottom: 1px solid var(--border2);
  display: flex; align-items: flex-start; gap: 12px;
}
.li-drawer-title-wrap { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.li-drawer-swatch { width: 32px; height: 32px; border-radius: 50%; border: 3px solid; flex-shrink: 0; }
.li-drawer-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.35rem; font-weight: 700; color: var(--text);
  margin: 0;
}
.li-drawer-sub { font-size: 0.78rem; color: var(--muted); font-weight: 600; margin: 2px 0 0; }
.li-drawer-close {
  background: transparent; border: none; font-size: 1.3rem; cursor: pointer;
  color: var(--text2); padding: 4px 8px; border-radius: 8px; font-family: inherit;
}
.li-drawer-close:hover { background: var(--bg-1); color: var(--text); }

.li-drawer-summary {
  padding: 14px 20px; display: flex; gap: 20px;
  background: linear-gradient(135deg, rgba(167, 139, 250, 0.08), rgba(255, 107, 157, 0.06));
}
.li-sum-block { flex: 1; }
.li-sum-label { font-size: 0.64rem; font-weight: 800; color: var(--muted); letter-spacing: 0.8px; text-transform: uppercase; }
.li-sum-value {
  font-family: 'Playfair Display', serif;
  font-size: 1.25rem; font-weight: 700; color: var(--text);
  font-variant-numeric: tabular-nums;
}
.li-sum-value.over { color: #c44040; }
.li-sum-value.good { color: var(--mint-d); }

.li-drawer-list {
  flex: 1; overflow-y: auto;
  padding: 8px 12px 20px;
  display: flex; flex-direction: column; gap: 6px;
}
.li-row {
  display: grid; grid-template-columns: 1fr auto auto;
  gap: 10px; align-items: center;
  padding: 8px 10px;
  background: var(--bg-1); border-radius: 12px;
  transition: background 0.15s;
}
.li-row:hover { background: var(--bg-2); }
.li-row-label {
  background: transparent; border: none; padding: 2px 4px;
  font-family: inherit; font-size: 0.92rem; color: var(--text);
  font-weight: 600; min-width: 0;
}
.li-row-label:focus { outline: 2px solid var(--violet); border-radius: 4px; }
.li-row-amount {
  background: transparent; border: none; padding: 2px 4px;
  font-family: inherit; font-weight: 800; font-size: 0.95rem;
  color: var(--text); text-align: right; width: 80px;
  font-variant-numeric: tabular-nums;
}
.li-row-amount:focus { outline: 2px solid var(--violet); border-radius: 4px; }
.li-row-del {
  background: transparent; border: none; color: var(--muted);
  font-size: 1rem; cursor: pointer; padding: 4px 6px; border-radius: 8px;
  font-family: inherit;
}
.li-row-del:hover { background: #ffe0e0; color: #c44040; }
.li-row-split-badge {
  grid-column: 1 / -1;
  font-size: 0.66rem; font-weight: 800; color: var(--violet-d);
  letter-spacing: 0.5px; text-transform: uppercase;
  padding: 0 4px; cursor: pointer;
  background: transparent; border: none; text-align: left;
  font-family: inherit;
}
.li-row-split-badge.off { color: var(--muted); font-weight: 700; }

.li-row[data-readonly="1"] .li-row-label,
.li-row[data-readonly="1"] .li-row-amount { pointer-events: none; }
.li-row[data-readonly="1"] .li-row-del { display: none; }

.li-empty {
  padding: 40px 20px; text-align: center; color: var(--muted);
  font-style: italic; font-size: 0.9rem;
}

.li-drawer-add {
  padding: 14px 16px;
  padding-bottom: calc(14px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border2);
  background: var(--bg-1);
  display: grid;
  grid-template-columns: 1fr 110px auto;
  gap: 8px; align-items: center;
}
.li-input {
  padding: 10px 12px; border-radius: 10px;
  border: 1.5px solid var(--border);
  background: white; font-family: inherit; font-size: 0.9rem;
  color: var(--text); min-width: 0;
}
.li-input:focus { outline: 2px solid var(--violet); border-color: transparent; }
.li-input-amount { text-align: right; font-variant-numeric: tabular-nums; font-weight: 800; }
.li-split-toggle {
  grid-column: 1 / -1;
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 0.8rem; color: var(--text2); font-weight: 700; cursor: pointer;
  padding: 4px 0;
}
.li-drawer-add[data-readonly="1"] { opacity: 0.5; pointer-events: none; }

@media (max-width: 500px) {
  .li-drawer-add { grid-template-columns: 1fr 90px auto; padding: 10px 12px; }
  .li-input-amount { width: 90px; }
}

/* Phase D — drawer as full-width bottom sheet on phones */
@media (max-width: 600px) {
  .li-drawer {
    width: 100%;
    max-width: 100vw;
    top: 0;
    border-radius: 22px 22px 0 0;
    padding-top: env(safe-area-inset-top);
  }
  .li-drawer-head {
    padding: calc(18px + env(safe-area-inset-top)) 16px 12px;
  }
  .li-drawer-title { font-size: 1.15rem; }
  .li-drawer-sub { font-size: 0.72rem; }
  .li-drawer-summary { padding: 12px 16px; gap: 14px; }
  .li-sum-value { font-size: 1.1rem; }
  .li-drawer-add {
    grid-template-columns: 1fr 90px 40px;
    padding: 10px 12px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
    gap: 6px;
  }
  .li-input-amount { width: 90px; }
}

/* Phase D — manifest-summary grid stays 2-col on tight screens */
@media (max-width: 500px) {
  .manifest-summary-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .manifest-summary-item { padding: 10px; }
  .manifest-summary-value { font-size: 1rem; }
}

/* ═══════════════════════════════════════════════════════════════════
   TEMPLATE EDITOR (Phase 15)
═══════════════════════════════════════════════════════════════════ */
.modal-xwide { width: min(760px, 96vw); }

.tmpl-toolbar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 0; border-bottom: 1px dashed var(--border);
  margin-bottom: 12px;
}
.tmpl-week-toggle { margin-left: auto; display: inline-flex; gap: 4px; background: var(--bg-1); padding: 3px; border-radius: 999px; align-items: center; }
.tmpl-week-label { font-size: 0.72rem; color: var(--muted); font-weight: 800; padding: 0 10px; }
.tmpl-week-btn {
  background: transparent; border: none; padding: 6px 12px;
  font-weight: 800; font-size: 0.78rem; color: var(--text2);
  border-radius: 999px; cursor: pointer; font-family: inherit;
}
.tmpl-week-btn.active { background: white; color: var(--pink-d); box-shadow: 0 2px 6px rgba(0,0,0,0.08); }

.tmpl-rows {
  max-height: 52vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 6px;
  padding: 4px 2px;
}
.tmpl-row {
  display: grid; grid-template-columns: 14px 1fr 110px 120px;
  gap: 10px; align-items: center;
  padding: 10px 14px; background: var(--bg-1); border-radius: 12px;
}
.tmpl-row-swatch { width: 10px; height: 10px; border-radius: 50%; border: 2px solid; }
.tmpl-row-name { font-weight: 700; color: var(--text); font-size: 0.9rem; }
.tmpl-row-name small { display: block; font-size: 0.66rem; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.7px; margin-top: 2px; }
.tmpl-row-input {
  padding: 8px 10px; border-radius: 8px;
  border: 1.5px solid var(--border); background: white;
  font-family: inherit; font-size: 0.9rem; text-align: right; font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.tmpl-row-input:focus { outline: 2px solid var(--violet); border-color: transparent; }
.tmpl-row-suggest {
  display: flex; align-items: center; gap: 6px;
  font-size: 0.72rem; color: var(--muted); font-weight: 700;
  justify-content: flex-end;
}
.tmpl-row-suggest.has-change { color: var(--violet-d); cursor: pointer; }
.tmpl-row-suggest.has-change:hover .tmpl-row-suggest-badge {
  background: rgba(167,139,250,0.35);
}
.tmpl-row-suggest-badge {
  background: rgba(167,139,250,0.18); color: var(--violet-d);
  padding: 2px 8px; border-radius: 999px; font-weight: 800;
  font-size: 0.64rem; letter-spacing: 0.5px; text-transform: uppercase;
  transition: background 0.15s;
}

.tmpl-summary {
  padding: 14px 18px; background: var(--bg-2); border-radius: 12px;
  margin-top: 16px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px;
}
.tmpl-sum-label { font-size: 0.66rem; font-weight: 800; color: var(--muted); letter-spacing: 0.8px; text-transform: uppercase; }
.tmpl-sum-value {
  font-family: 'Playfair Display', serif;
  font-size: 1.35rem; font-weight: 700; color: var(--text);
  font-variant-numeric: tabular-nums;
}
.tmpl-sum-value.positive { color: var(--mint-d); }
.tmpl-sum-value.negative { color: #c44040; }

@media (max-width: 600px) {
  .tmpl-row { grid-template-columns: 14px 1fr 90px; }
  .tmpl-row-suggest { grid-column: 1 / -1; justify-content: flex-start; padding-top: 4px; padding-left: 24px; }
  .tmpl-summary { grid-template-columns: 1fr; gap: 8px; }
}

/* Override inherited .btn-ghost white-on-white for modal-body template toolbar */
.tmpl-toolbar .btn-ghost {
  background: var(--bg-1);
  color: var(--text2);
  border: 1.5px solid var(--border);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
.tmpl-toolbar .btn-ghost:hover { background: var(--bg-2); color: var(--text); border-color: var(--violet); }

/* ═══════════════════════════════════════════════════════════════════
   CATEGORIES MANAGER (Phase 16)
═══════════════════════════════════════════════════════════════════ */
.cat-mgr-toolbar { padding: 10px 0 14px; }
.cat-mgr-list {
  max-height: 50vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 8px;
}
.cat-mgr-row {
  display: grid; grid-template-columns: 14px 1fr 80px auto auto auto;
  gap: 10px; align-items: center;
  padding: 10px 14px; background: var(--bg-1); border-radius: 12px;
}
.cat-mgr-row.archived { opacity: 0.6; }
.cat-mgr-row-swatch { width: 12px; height: 12px; border-radius: 50%; border: 2.5px solid; }
.cat-mgr-name { font-weight: 700; color: var(--text); font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-mgr-name small { color: var(--muted); font-weight: 600; font-size: 0.72rem; }
.cat-mgr-kind {
  font-size: 0.66rem; font-weight: 800; color: var(--muted);
  letter-spacing: 0.8px; text-transform: uppercase;
}
.cat-mgr-icon-btn {
  background: transparent; border: none; cursor: pointer; padding: 6px 10px;
  border-radius: 8px; color: var(--text2); font-size: 0.9rem;
  font-family: inherit;
}
.cat-mgr-icon-btn:hover { background: white; color: var(--violet-d); }
.cat-mgr-icon-btn.danger:hover { background: #ffe0e0; color: #c44040; }

.cat-mgr-form {
  display: grid; grid-template-columns: 1fr 140px auto;
  gap: 8px; align-items: center;
  padding: 14px 16px; background: var(--bg-2); border-radius: 12px; margin-bottom: 12px;
}
.cat-mgr-form-label {
  grid-column: 1 / -1;
  font-size: 0.72rem; font-weight: 800; color: var(--muted);
  letter-spacing: 0.6px; text-transform: uppercase;
}
.cat-mgr-form-input {
  padding: 9px 12px; border-radius: 8px; border: 1.5px solid var(--border);
  background: white; font-family: inherit; font-size: 0.9rem; color: var(--text);
}
.cat-mgr-form-input:focus { outline: 2px solid var(--violet); border-color: transparent; }
.cat-mgr-form-kind {
  padding: 9px 12px; border-radius: 8px; border: 1.5px solid var(--border);
  background: white; font-family: inherit; font-size: 0.85rem; font-weight: 700;
  color: var(--text);
}
.cat-mgr-form-kind:focus { outline: 2px solid var(--violet); border-color: transparent; }
.cat-mgr-form-swatches {
  grid-column: 1 / -1;
  display: grid; grid-template-columns: repeat(10, 1fr); gap: 6px;
  padding: 4px 0;
}
.cat-mgr-form-swatch {
  aspect-ratio: 1; border-radius: 8px; cursor: pointer;
  border: 2.5px solid transparent;
  transition: transform 0.12s;
}
.cat-mgr-form-swatch:hover { transform: scale(1.1); }
.cat-mgr-form-swatch.selected {
  border-color: var(--text);
  transform: scale(1.08);
}
.cat-mgr-form-actions {
  grid-column: 1 / -1;
  display: flex; gap: 8px; justify-content: flex-end;
  padding-top: 4px;
}

@media (max-width: 540px) {
  .cat-mgr-row { grid-template-columns: 14px 1fr auto; gap: 8px; }
  .cat-mgr-kind { display: none; }
  .cat-mgr-form { grid-template-columns: 1fr; }
  .cat-mgr-form-swatches { grid-template-columns: repeat(8, 1fr); }
}

/* ═══════════════════════════════════════════════════════════════════
   MANIFEST RITUAL (Phase 17)
═══════════════════════════════════════════════════════════════════ */
.manifest-btn {
  width: 100%;
  padding: 20px 24px;
  background: linear-gradient(135deg, #ff6b9d 0%, #a78bfa 55%, #60d394 100%);
  background-size: 180% 180%;
  animation: manifest-shimmer 8s ease infinite;
  color: white;
  border: none;
  border-radius: 22px;
  display: flex; align-items: center; justify-content: center; gap: 14px;
  font-family: inherit; font-size: 1.1rem; font-weight: 800;
  letter-spacing: 0.3px; cursor: pointer;
  box-shadow: 0 12px 32px rgba(255, 107, 157, 0.35);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.manifest-btn:hover { transform: translateY(-2px); box-shadow: 0 18px 44px rgba(167, 139, 250, 0.45); }
.manifest-btn:active { transform: translateY(0); }
.manifest-btn .manifest-emoji { font-size: 1.4rem; }
.manifest-btn .manifest-btn-arrow { font-size: 1.2rem; opacity: 0.88; }

@keyframes manifest-shimmer {
  0%, 100% { background-position: 0% 50%; }
  50%      { background-position: 100% 50%; }
}

.manifest-block {
  padding: 20px 22px;
  background: var(--surface);
  border-radius: 20px;
  box-shadow: var(--shadow);
  border: 2px solid rgba(96, 211, 148, 0.35);
}
.manifest-block-head { display: flex; align-items: center; gap: 14px; margin-bottom: 8px; }
.manifest-block-head .manifest-emoji { font-size: 1.8rem; }
.manifest-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.25rem; font-weight: 700; color: var(--text);
}
.manifest-sub { font-size: 0.8rem; color: var(--text2); font-weight: 500; margin-top: 2px; }
.manifest-reflection {
  margin: 14px 0;
  padding: 14px 16px;
  font-family: 'Playfair Display', serif;
  font-style: italic; font-size: 0.95rem; color: var(--text2);
  background: var(--bg-1); border-radius: 12px;
  border-left: 3px solid var(--violet);
  line-height: 1.5;
}
.manifest-unbtn {
  background: var(--bg-1);
  color: var(--text2);
  border: 1.5px solid var(--border);
  padding: 10px 18px;
  border-radius: 10px;
  font-family: inherit; font-weight: 700; font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s;
}
.manifest-unbtn:hover { background: var(--bg-2); color: var(--text); border-color: var(--violet); }

.manifest-modal-hero {
  display: flex; align-items: center; gap: 20px;
  padding: 8px 0 20px; border-bottom: 1px dashed var(--border);
  margin-bottom: 20px;
}
.manifest-modal-ring { flex-shrink: 0; width: 110px; height: 110px; }
.manifest-modal-stats { flex: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.manifest-modal-stat-label { font-size: 0.66rem; font-weight: 800; color: var(--muted); letter-spacing: 0.8px; text-transform: uppercase; }
.manifest-modal-stat-value {
  font-family: 'Playfair Display', serif;
  font-size: 1.2rem; font-weight: 700; color: var(--text);
  font-variant-numeric: tabular-nums;
}
.manifest-modal-stat-value.positive { color: var(--mint-d); }
.manifest-modal-stat-value.negative { color: #c44040; }

.manifest-note {
  padding: 12px 14px; background: var(--bg-2); border-radius: 12px;
  font-size: 0.82rem; color: var(--text2); margin-top: 10px; line-height: 1.5;
}

/* ═══════════════════════════════════════════════════════════════════
   HERO RINGS — upgraded layout + fixed tones + celebration
═══════════════════════════════════════════════════════════════════ */

/* Full-row 2-column hero rings on desktop. Taller than category cards
   to signify hero-level importance. Stack full-width on mobile. */
.dash-stats.dash-stats-rings-2 {
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  max-width: none;          /* override prior spec's 720px cap */
  margin: 0;
}

/* Hero-sized card — bigger ring on left, title/pill/rows on right */
.hero-ring {
  min-height: 290px;
  padding: 26px 28px;
  display: grid;
  grid-template-columns: minmax(220px, 38%) 1fr;
  align-items: center;
  gap: 26px;
  border-radius: 24px;
  background: var(--surface);
  position: relative;
  overflow: hidden;
  box-shadow: 0 6px 18px rgba(167, 139, 250, 0.08);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.hero-ring:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 30px rgba(167, 139, 250, 0.16);
}

/* Ring wrap: large circle holding the segmented SVG + centered amount */
.hero-ring .dash-stat-ring-wrap {
  width: 220px;
  height: 220px;
  max-width: 100%;
  aspect-ratio: 1 / 1;
}
.hero-ring .dash-stat-ring-wrap svg {
  width: 100%;
  height: 100%;
  display: block;
}
.hero-ring .dash-stat-ring-value {
  font-size: 1.9rem;
  font-weight: 700;
  line-height: 1.1;
}
.hero-ring .dash-stat-ring-sub {
  font-size: 0.72rem;
  margin-top: 6px;
  color: var(--muted);
  letter-spacing: 0.02em;
}

/* Right column — title (biggest serif), tier pill, money rows */
.hero-ring .dash-stat-ring-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.hero-ring .dash-stat-ring-title {
  font-family: var(--font-serif, "Playfair Display", "Times New Roman", serif);
  font-size: 1.55rem;
  font-weight: 600;
  line-height: 1.15;
  margin-bottom: 2px;
  color: var(--ink);
}
.hero-ring-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  align-self: flex-start;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(167, 139, 250, 0.10);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: 0.01em;
}
.hero-ring-status-emoji {
  font-size: 0.95rem;
  line-height: 1;
}
.hero-ring-actual .hero-ring-status {
  background: rgba(156, 175, 94, 0.14);
}
.hero-ring .dash-stat-ring-inout {
  margin-top: 2px;
}
.hero-ring .dash-stat-ring-inout > div {
  font-size: 1rem;
  padding: 4px 0;
}
.hero-ring .dash-stat-ring-inout .inout-label {
  font-size: 0.76rem;
}

/* Gentle tone-tint backgrounds, richer than the pre-spec default */
.hero-ring-planned {
  background: linear-gradient(135deg,
    rgba(236, 220, 248, 0.55) 0%,
    rgba(255, 255, 255, 0.85) 70%);
}
.hero-ring-actual {
  background: linear-gradient(135deg,
    rgba(232, 238, 216, 0.55) 0%,
    rgba(255, 255, 255, 0.85) 70%);
}

/* "Empty" state — no goal or net ≤ 0 → slightly muted look */
.hero-ring-empty,
.hero-ring-below-zero {
  opacity: 0.94;
}
.hero-ring-below-zero .dash-stat-ring-value {
  color: #c44040;
}

/* Overflow state on Planned (past 100%) — darker shadow hint */
.hero-ring-planned.hero-ring-over {
  box-shadow: 0 8px 22px rgba(125, 85, 201, 0.22);
}

/* ═══════════════════════════════════════════════════════════════════
   CELEBRATION — Actual ring ≥ 100%
═══════════════════════════════════════════════════════════════════ */
.hero-ring-celebrating {
  /* Gradient border via inset box-shadow + accent ring */
  box-shadow:
    0 0 0 3px #fff inset,
    0 0 0 6px #ffd700 inset,
    0 0 0 8px #ff6b9d inset,
    0 12px 36px rgba(255, 193, 7, 0.28);
  position: relative;
  animation: hero-celebrate-glow 4.5s ease-in-out infinite;
}

/* Corner emoji decorations — absolutely positioned, subtle */
.hero-ring-celebrating::before {
  content: "🌟 ✨";
  position: absolute;
  top: 10px; left: 14px;
  font-size: 1rem;
  letter-spacing: 2px;
  pointer-events: none;
  z-index: 2;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.08));
  animation: hero-sparkle 3.2s ease-in-out infinite;
}
.hero-ring-celebrating::after {
  content: "🌙 🌺";
  position: absolute;
  bottom: 10px; right: 14px;
  font-size: 1rem;
  letter-spacing: 2px;
  pointer-events: none;
  z-index: 2;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.08));
  animation: hero-sparkle 3.2s ease-in-out infinite 1.6s;
}

@keyframes hero-sparkle {
  0%, 100% { opacity: 0.88; transform: translateY(0); }
  50%      { opacity: 1;    transform: translateY(-2px); }
}

@keyframes hero-celebrate-glow {
  0%, 100% {
    box-shadow:
      0 0 0 3px #fff inset,
      0 0 0 6px #ffd700 inset,
      0 0 0 8px #ff6b9d inset,
      0 12px 36px rgba(255, 193, 7, 0.28);
  }
  50% {
    box-shadow:
      0 0 0 3px #fff inset,
      0 0 0 6px #ffb84d inset,
      0 0 0 8px #ff85b4 inset,
      0 16px 44px rgba(255, 107, 157, 0.35);
  }
}

/* Reduced-motion respect — static look, no animation */
@media (prefers-reduced-motion: reduce) {
  .hero-ring,
  .hero-ring-celebrating,
  .hero-ring-celebrating::before,
  .hero-ring-celebrating::after {
    animation: none !important;
    transition: none !important;
  }
}

/* ═══════════════════════════════════════════════════════════════════
   MOBILE — ≤720px: stack ring above body; ≤420px: tighter still
═══════════════════════════════════════════════════════════════════ */
@media (max-width: 720px) {
  .dash-stats.dash-stats-rings-2 {
    grid-template-columns: 1fr;
    gap: 14px;
  }
  .hero-ring {
    min-height: 260px;
    padding: 22px 22px;
    grid-template-columns: 1fr;
    gap: 16px;
    justify-items: center;
    text-align: center;
  }
  .hero-ring .dash-stat-ring-wrap {
    width: 180px;
    height: 180px;
    justify-self: center;
  }
  .hero-ring .dash-stat-ring-value {
    font-size: 1.6rem;
  }
  .hero-ring .dash-stat-ring-title {
    font-size: 1.35rem;
    text-align: center;
  }
  .hero-ring .dash-stat-ring-body {
    align-items: center;
  }
  .hero-ring-status {
    align-self: center;
  }
  .hero-ring .dash-stat-ring-inout {
    width: 100%;
    max-width: 280px;
  }
  .hero-ring .dash-stat-ring-inout > div {
    justify-content: space-between;
  }
  .hero-ring-celebrating::before,
  .hero-ring-celebrating::after {
    font-size: 0.85rem;
  }
}

@media (max-width: 420px) {
  .hero-ring {
    min-height: 230px;
    padding: 18px 16px;
    gap: 12px;
    border-radius: 20px;
  }
  .hero-ring .dash-stat-ring-wrap {
    width: 150px;
    height: 150px;
  }
  .hero-ring .dash-stat-ring-value {
    font-size: 1.4rem;
  }
  .hero-ring .dash-stat-ring-sub {
    font-size: 0.68rem;
  }
  .hero-ring .dash-stat-ring-title {
    font-size: 1.2rem;
  }
  .hero-ring-status {
    font-size: 0.72rem;
    padding: 4px 10px;
  }
  .hero-ring .dash-stat-ring-inout > div {
    font-size: 0.9rem;
  }
}

/* ═══════════════════════════════════════════════════════════════════
   QUICK ADD — Toolbar button + modal + rows
═══════════════════════════════════════════════════════════════════ */

/* Colorful primary toolbar button that stands out among ghosts */
.btn-quick-add {
  background: linear-gradient(135deg, #ff85b4 0%, #a78bfa 55%, #ffd166 100%);
  color: white !important;
  font-weight: 800;
  box-shadow: 0 4px 14px rgba(255, 133, 180, 0.28);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.btn-quick-add:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 22px rgba(255, 133, 180, 0.36);
}
.btn-quick-add:focus-visible {
  outline: 2px solid var(--violet-d, #7d55c9);
  outline-offset: 3px;
}

/* Modal shell — wider than default for the stacked rows */
.quick-add-modal {
  width: min(720px, 96vw);
  max-height: min(90vh, 900px);
  display: flex;
  flex-direction: column;
}
.quick-add-body {
  overflow-y: auto;
  padding: 18px 22px;
  flex: 1 1 auto;
}

/* Week banner — tells her which week entries will land in */
.quick-add-week-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: linear-gradient(135deg, rgba(255, 133, 180, 0.09), rgba(167, 139, 250, 0.09));
  border-radius: 14px;
  margin-bottom: 16px;
  font-size: 0.92rem;
  color: var(--text, #3a2e4e);
}
.quick-add-week-icon { font-size: 1.1rem; }
.quick-add-week-text strong {
  font-weight: 800;
  color: var(--violet-d, #7d55c9);
  margin-left: 6px;
}

/* Stacked rows */
.quick-add-rows {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}
.quick-add-row {
  background: var(--bg-1, #faf7ff);
  border-radius: 14px;
  padding: 12px 14px;
  transition: box-shadow 0.18s ease;
}
.quick-add-row-fields {
  display: grid;
  grid-template-columns: 2fr 1.3fr 1.8fr 40px;
  gap: 10px;
  align-items: center;
}
.quick-add-row-label,
.quick-add-row-amount,
.quick-add-row-category {
  padding: 10px 12px;
  background: white;
  border: 1.5px solid var(--border, #e8e0f5);
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.94rem;
  min-height: 44px;
}
.quick-add-row-label:focus,
.quick-add-row-amount:focus,
.quick-add-row-category:focus {
  outline: none;
  border-color: var(--violet, #8b7dd8);
  box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.18);
}
.quick-add-row-amount-wrap {
  display: flex;
  align-items: center;
  background: white;
  border: 1.5px solid var(--border, #e8e0f5);
  border-radius: 10px;
  padding: 0 10px;
  min-height: 44px;
}
.quick-add-row-amount-wrap:focus-within {
  border-color: var(--violet, #8b7dd8);
  box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.18);
}
.quick-add-row-amount-prefix {
  color: var(--muted, #8a8299);
  font-weight: 700;
  padding-right: 4px;
}
.quick-add-row-amount-wrap .quick-add-row-amount {
  border: none;
  padding: 10px 0;
  flex: 1;
  background: none;
  box-shadow: none !important;
}
.quick-add-row-category {
  appearance: auto;
}
.quick-add-row-delete {
  background: none;
  border: none;
  font-size: 1rem;
  color: var(--muted, #8a8299);
  cursor: pointer;
  width: 40px;
  height: 44px;
  border-radius: 10px;
  transition: background 0.15s ease, color 0.15s ease;
}
.quick-add-row-delete:hover:not(:disabled) {
  background: rgba(255, 100, 100, 0.08);
  color: #c44040;
}
.quick-add-row-delete:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.quick-add-row-split {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 0 0;
  font-size: 0.82rem;
  color: var(--muted, #8a8299);
}
.quick-add-row-split input {
  margin: 0;
  width: 16px; height: 16px;
  accent-color: var(--violet, #8b7dd8);
}

/* Error state on a row */
.quick-add-row-error {
  box-shadow: 0 0 0 2px #e89090 inset;
}
.quick-add-row-err-msg {
  color: #c44040;
  font-size: 0.78rem;
  margin-top: 6px;
  font-weight: 600;
}

/* "+ Add another" button */
.quick-add-addrow-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  padding: 10px 16px;
  min-height: 44px;
}

/* Flush button (primary) */
.btn-quick-add-flush {
  background: linear-gradient(135deg, #ff85b4 0%, #a78bfa 55%, #ffd166 100%);
  color: white !important;
  font-weight: 800;
  min-height: 44px;
}
.btn-quick-add-flush:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

/* ═══════════════════════════════════════════════════════════════════
   QUICK ADD MOBILE — ≤720px: bottom sheet; ≤420px: tighter reflow
═══════════════════════════════════════════════════════════════════ */
@media (max-width: 720px) {
  .quick-add-modal {
    width: 100vw;
    max-width: 100vw;
    height: auto;
    max-height: 92vh;
    border-radius: 22px 22px 0 0;
    margin: 0;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .modal-overlay#quickAddModal.open .quick-add-modal {
    animation: quick-add-slide-up 0.28s cubic-bezier(0.22, 1, 0.36, 1);
  }
  .quick-add-row-fields {
    grid-template-columns: 1fr 90px 40px;
    grid-template-areas:
      "label label label"
      "amount category delete";
    gap: 8px;
  }
  .quick-add-row-label        { grid-area: label; }
  .quick-add-row-amount-wrap  { grid-area: amount; }
  .quick-add-row-category     { grid-area: category; }
  .quick-add-row-delete       { grid-area: delete; }
  .quick-add-body { padding: 16px 18px; }
  .quick-add-week-banner { font-size: 0.88rem; padding: 10px 14px; }
}

@media (max-width: 420px) {
  .quick-add-row-fields {
    grid-template-columns: 1fr 80px 36px;
    gap: 6px;
  }
  .quick-add-row-label,
  .quick-add-row-amount,
  .quick-add-row-category {
    font-size: 0.9rem;
    padding: 10px 10px;
  }
}

@keyframes quick-add-slide-up {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .modal-overlay#quickAddModal.open .quick-add-modal {
    animation: none;
  }
}
