:root {
	color-scheme: light;
	--bg: #eef0f5;
	--surface: #ffffff;
	--ink: #161a33;
	--fg: #161a33;
	--muted: #5b6079;
	--accent: #ff4f5e;
	--accent-ink: #c62a3a;
	--save: #0a8f6a;
	--border: #dfe2ec;
	--danger: #c62a3a;
	--radius: 14px;
	--radius-sm: 8px;
	--space: 1rem;
	--shadow: 0 1px 2px rgba(22, 26, 51, 0.06), 0 8px 24px rgba(22, 26, 51, 0.06);
	--font: "Manrope", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
	--display: "Bricolage Grotesque", "Manrope", ui-sans-serif, system-ui, sans-serif;

	--c0: #ff4f5e;
	--c1: #7c5cff;
	--c2: #1f8fff;
	--c3: #18b8c9;
	--c4: #f59f0b;
	--c5: #0a8f6a;
	--c6: #8a6d52;
	--c7: #8b90a6;
}

* {
	box-sizing: border-box;
}

body {
	margin: 0;
	background: var(--bg);
	color: var(--fg);
	font-family: var(--font);
	font-size: 16px;
	line-height: 1.55;
	-webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
	font-family: var(--display);
	letter-spacing: -0.02em;
	margin: 0;
}

h2 {
	font-size: 1.2rem;
	font-weight: 700;
}

.num {
	font-variant-numeric: tabular-nums;
}

.shell {
	max-width: 42rem;
	margin: 0 auto;
	padding: calc(var(--space) * 1.5) var(--space) calc(var(--space) * 4);
}

.lede {
	margin: 0 0 0.75rem;
	font-size: 1.05rem;
}

.hint {
	margin: 0;
	color: var(--muted);
	font-size: 0.9rem;
}

.quiet {
	padding: 0.25rem 0;
}

/* Buttons */
.btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.4rem;
	min-height: 44px;
	padding: 0.55rem 1rem;
	border: 1px solid transparent;
	border-radius: var(--radius-sm);
	background: var(--ink);
	color: #fff;
	font: inherit;
	font-weight: 700;
	cursor: pointer;
	transition: transform 0.12s ease, background-color 0.15s ease;
}

.btn:hover {
	background: #2a2f52;
}

.btn:active {
	transform: scale(0.97);
}

.btn:disabled {
	opacity: 0.6;
	cursor: default;
}

.btn-secondary {
	background: var(--surface);
	color: var(--fg);
	border-color: var(--border);
}

.btn-secondary:hover {
	background: var(--bg);
}

.btn-ghost {
	background: transparent;
	color: var(--fg);
	border-color: var(--border);
	min-height: 40px;
	padding: 0.4rem 0.85rem;
}

.btn-ghost:hover {
	background: var(--surface);
}

.btn-danger {
	background: transparent;
	color: var(--danger);
	border-color: #f2c4c9;
}

.btn-danger:hover {
	background: #fff1f2;
}

.btn-block {
	width: 100%;
}

.icon-btn {
	display: inline-grid;
	place-items: center;
	width: 44px;
	height: 44px;
	border: 0;
	border-radius: var(--radius-sm);
	background: transparent;
	color: var(--muted);
	cursor: pointer;
}

.icon-btn:hover {
	background: var(--bg);
	color: var(--fg);
}

.link-btn {
	border: 0;
	background: none;
	padding: 0.25rem 0;
	color: var(--accent-ink);
	font: inherit;
	font-weight: 700;
	cursor: pointer;
	text-decoration: underline;
	text-underline-offset: 3px;
}

/* Forms */
.card {
	padding: var(--space);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	background: var(--surface);
}

.input,
.select,
.textarea {
	width: 100%;
	min-height: 44px;
	padding: 0.55rem 0.75rem;
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	background: var(--surface);
	color: var(--fg);
	font: inherit;
}

.input:focus {
	border-color: var(--ink);
}

.field {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: 0.35rem;
	margin-bottom: var(--space);
}

.field > label,
.field > .field-label {
	font-size: 0.875rem;
	font-weight: 600;
	color: var(--muted);
}

.field-pair {
	display: grid;
	grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
	gap: 0.75rem;
}

.form-error {
	margin: 0 0 var(--space);
	padding: 0.6rem 0.8rem;
	border-radius: var(--radius-sm);
	background: #fff1f2;
	color: var(--danger);
	font-weight: 600;
	font-size: 0.9rem;
}

.stack {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: var(--space);
}

:where(.field, .stack, .list) > * {
	min-width: 0;
}

.row {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	flex-wrap: wrap;
}

.grid {
	display: grid;
	gap: var(--space);
	grid-template-columns: repeat(auto-fit, minmax(min(15rem, 100%), 1fr));
}

.list {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: 0.5rem;
	margin: 0;
	padding: 0;
	list-style: none;
}

.list-item {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.75rem;
	flex-wrap: wrap;
	padding: 0.7rem 0.85rem;
	border: 1px solid var(--border);
	border-radius: var(--radius);
}

.table {
	width: 100%;
	border-collapse: collapse;
}

.table th,
.table td {
	padding: 0.6rem 0.5rem;
	text-align: left;
	border-bottom: 1px solid var(--border);
}

.empty {
	padding: calc(var(--space) * 2) var(--space);
	text-align: center;
	color: var(--muted);
}

.empty-title {
	margin: 0 0 0.25rem;
	color: var(--fg);
	font-weight: 700;
	font-family: var(--display);
	font-size: 1.1rem;
}

.empty .btn {
	margin-top: var(--space);
}

.loading {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 0.6rem;
	padding: calc(var(--space) * 3);
	color: var(--muted);
}

.spinner {
	flex: none;
	width: 1.15rem;
	height: 1.15rem;
	border: 2px solid var(--border);
	border-top-color: var(--accent);
	border-radius: 50%;
	animation: fab-spin 0.7s linear infinite;
}

@keyframes fab-spin {
	to {
		transform: rotate(360deg);
	}
}

.skeleton {
	display: block;
	height: 1rem;
	border-radius: calc(var(--radius) / 2);
	background: linear-gradient(90deg, var(--border), transparent, var(--border));
	background-size: 200% 100%;
	animation: fab-shimmer 1.2s linear infinite;
}

@keyframes fab-shimmer {
	to {
		background-position: -200% 0;
	}
}

.alert {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.75rem;
	flex-wrap: wrap;
	padding: 0.7rem 0.85rem;
	border: 1px solid var(--border);
	border-left: 3px solid var(--muted);
	border-radius: var(--radius-sm);
	background: var(--surface);
	margin-bottom: var(--space);
}

.alert-error {
	border-left-color: var(--danger);
	color: var(--danger);
}

.badge {
	display: inline-block;
	padding: 0.1rem 0.5rem;
	border: 1px solid var(--border);
	border-radius: 999px;
	font-size: 0.8125rem;
	color: var(--muted);
}

/* Top bar */
.topbar {
	position: sticky;
	top: 0;
	z-index: 10;
	background: rgba(238, 240, 245, 0.88);
	backdrop-filter: blur(10px);
	border-bottom: 1px solid var(--border);
}

.topbar-inner {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.75rem;
	max-width: 72rem;
	margin: 0 auto;
	padding: 0.6rem var(--space);
}

.brand {
	display: inline-flex;
	align-items: center;
	gap: 0.55rem;
	font-family: var(--display);
	font-weight: 800;
	font-size: 1.3rem;
	letter-spacing: -0.03em;
}

.brand-mark {
	display: inline-grid;
	place-items: center;
	width: 36px;
	height: 36px;
	border-radius: 10px;
	background: var(--accent);
	color: #fff;
}

.topbar-actions {
	flex-wrap: nowrap;
	min-width: 0;
}

.who {
	display: none;
	color: var(--muted);
	font-size: 0.875rem;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

/* Sample note */
.sample-note {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 0.75rem;
	margin-bottom: var(--space);
	padding: 0.85rem 1rem;
	border-radius: var(--radius);
	background: var(--surface);
	border: 1px dashed #c3c7d6;
}

.sample-note p {
	margin: 0;
	flex: 1 1 18rem;
	font-size: 0.95rem;
}

/* Layout */
.layout {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: var(--space);
}

.col-side {
	min-width: 0;
}

/* Burn hero */
.burn {
	position: relative;
	overflow: hidden;
	padding: 1.5rem 1.25rem 1.25rem;
	border-radius: var(--radius);
	background: var(--ink);
	color: #fff;
}

.burn::after {
	content: "";
	position: absolute;
	right: -40px;
	top: -40px;
	width: 180px;
	height: 180px;
	border-radius: 50%;
	border: 28px solid rgba(255, 79, 94, 0.18);
	pointer-events: none;
}

.burn-label {
	margin: 0;
	font-weight: 600;
	color: #b9bdd6;
}

.burn-amount {
	margin: 0.15rem 0 0.75rem;
	font-family: var(--display);
	font-weight: 800;
	font-size: clamp(3rem, 13vw, 4.75rem);
	line-height: 1;
	letter-spacing: -0.04em;
}

.burn-stats {
	display: flex;
	flex-wrap: wrap;
	gap: 0.35rem 1.25rem;
	color: #b9bdd6;
	font-size: 0.95rem;
}

.burn-stats strong {
	color: #fff;
}

.burn-bar {
	display: flex;
	gap: 3px;
	height: 12px;
	margin: 1.25rem 0 0.85rem;
	border-radius: 6px;
	overflow: hidden;
}

.burn-seg {
	flex-basis: 0;
	min-width: 6px;
	background: var(--dot);
}

.burn-legend {
	display: flex;
	flex-wrap: wrap;
	gap: 0.4rem 1rem;
	margin: 0;
	padding: 0;
	list-style: none;
	font-size: 0.85rem;
	color: #d6d9ea;
}

.burn-legend li {
	display: inline-flex;
	align-items: center;
	gap: 0.4rem;
}

.burn-legend .num {
	color: #fff;
	font-weight: 700;
}

/* Category colors */
.cat-0 { --dot: var(--c0); }
.cat-1 { --dot: var(--c1); }
.cat-2 { --dot: var(--c2); }
.cat-3 { --dot: var(--c3); }
.cat-4 { --dot: var(--c4); }
.cat-5 { --dot: var(--c5); }
.cat-6 { --dot: var(--c6); }
.cat-7 { --dot: var(--c7); }

.dot {
	flex: none;
	width: 10px;
	height: 10px;
	border-radius: 3px;
	background: var(--dot);
}

/* Panels */
.panel {
	padding: 1.1rem;
	border-radius: var(--radius);
	background: var(--surface);
	border: 1px solid var(--border);
}

.panel-head {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 0.75rem;
	margin-bottom: 0.85rem;
}

.with-icon {
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
}

.with-icon svg {
	color: var(--accent);
	flex: none;
}

.tag {
	flex: none;
	padding: 0.2rem 0.6rem;
	border-radius: 6px;
	background: #ffe8ea;
	color: var(--accent-ink);
	font-size: 0.85rem;
	font-weight: 700;
}

/* Alerts */
.alert-list {
	display: grid;
	gap: 0.5rem;
	margin: 0;
	padding: 0;
	list-style: none;
}

.alert-list li {
	display: grid;
	grid-template-columns: auto minmax(0, 1fr) auto;
	align-items: center;
	gap: 0.75rem;
	padding: 0.6rem 0.75rem;
	border-radius: var(--radius-sm);
	background: var(--bg);
}

.alert-day {
	min-width: 4.5rem;
	padding: 0.25rem 0.5rem;
	border-radius: 6px;
	background: var(--surface);
	border: 1px solid var(--border);
	text-align: center;
	font-size: 0.8rem;
	font-weight: 700;
}

.alert-list li.soon .alert-day {
	background: var(--accent);
	border-color: var(--accent);
	color: #fff;
}

.alert-name {
	display: grid;
	font-weight: 700;
	overflow-wrap: anywhere;
}

.alert-name .hint {
	font-weight: 500;
	font-size: 0.8rem;
}

.alert-amt {
	font-weight: 700;
}

/* Chips */
.chips {
	display: flex;
	flex-wrap: wrap;
	gap: 0.45rem;
	margin-bottom: 0.85rem;
}

.chip {
	display: inline-flex;
	align-items: center;
	gap: 0.4rem;
	min-height: 38px;
	padding: 0.35rem 0.85rem;
	border: 1px solid var(--border);
	border-radius: 999px;
	background: var(--surface);
	color: var(--fg);
	font: inherit;
	font-size: 0.875rem;
	font-weight: 600;
	cursor: pointer;
	transition: background-color 0.15s ease;
}

.chip:hover {
	background: var(--bg);
}

.chip.is-on {
	background: var(--ink);
	border-color: var(--ink);
	color: #fff;
}

/* Subscription list */
.sub-list {
	display: grid;
	margin: 0;
	padding: 0;
	list-style: none;
}

.sub-list li + li {
	border-top: 1px solid var(--border);
}

.sub-row {
	display: grid;
	grid-template-columns: auto minmax(0, 1fr) auto;
	align-items: center;
	gap: 0.85rem;
	width: 100%;
	padding: 0.8rem 0.4rem;
	border: 0;
	border-radius: var(--radius-sm);
	background: transparent;
	color: inherit;
	font: inherit;
	text-align: left;
	cursor: pointer;
}

.sub-row:hover {
	background: var(--bg);
}

.sub-row.is-cut {
	opacity: 0.5;
}

.sub-row.is-cut .sub-name {
	text-decoration: line-through;
}

.sub-icon {
	display: grid;
	place-items: center;
	width: 42px;
	height: 42px;
	border-radius: 11px;
	background: var(--dot);
	color: #fff;
	font-family: var(--display);
	font-weight: 800;
	font-size: 1.15rem;
}

.sub-main {
	display: grid;
	min-width: 0;
}

.sub-name {
	font-weight: 700;
	overflow-wrap: anywhere;
}

.sub-meta {
	color: var(--muted);
	font-size: 0.82rem;
}

.sub-price {
	display: grid;
	justify-items: end;
	font-weight: 700;
}

.sub-eq {
	color: var(--muted);
	font-weight: 500;
	font-size: 0.78rem;
}

/* Paused and cancelled */
.sub-row.is-paused .sub-icon,
.sub-row.is-cancelled .sub-icon {
	filter: grayscale(0.85);
	opacity: 0.6;
}

.sub-row.is-paused .sub-price {
	color: var(--muted);
	text-decoration: line-through;
}

.status-tag {
	display: inline-block;
	margin-left: 0.45rem;
	padding: 0.05rem 0.45rem;
	border-radius: 6px;
	background: #fff4d6;
	color: #8a5a00;
	font-size: 0.72rem;
	font-weight: 700;
	vertical-align: 0.1em;
}

.saved-total {
	display: grid;
	padding: 1rem;
	margin-bottom: 0.6rem;
	border-radius: var(--radius-sm);
	background: #e3f6ef;
}

.saved-amount {
	font-family: var(--display);
	font-weight: 800;
	font-size: 2.3rem;
	line-height: 1.1;
	letter-spacing: -0.03em;
	color: var(--save);
}

.saved-line {
	color: var(--save);
}

.sub-list li.cancel-item {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.25rem 0.5rem;
}

.cancel-item .sub-row {
	flex: 1 1 15rem;
	min-width: 0;
}

.restore-btn {
	flex: none;
	min-height: 38px;
	padding: 0.35rem 0.85rem;
	font-size: 0.875rem;
}

.status-seg {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 0.25rem;
	padding: 0.25rem;
	border-radius: var(--radius-sm);
	background: var(--bg);
}

.seg-btn {
	min-height: 40px;
	border: 0;
	border-radius: 6px;
	background: transparent;
	color: var(--muted);
	font: inherit;
	font-size: 0.875rem;
	font-weight: 700;
	cursor: pointer;
}

.seg-btn.is-on {
	background: var(--surface);
	color: var(--ink);
	box-shadow: 0 1px 3px rgba(22, 26, 51, 0.12);
}

.seg-btn.seg-paused.is-on {
	color: #8a5a00;
}

.seg-btn.seg-cancelled.is-on {
	color: var(--danger);
}

/* Simulator */
.sim-result {
	display: grid;
	padding: 1rem;
	margin-bottom: 0.85rem;
	border-radius: var(--radius-sm);
	background: var(--bg);
	transition: background-color 0.2s ease;
}

.sim-result.is-saving {
	background: #e3f6ef;
}

.sim-label {
	font-weight: 600;
	color: var(--muted);
	font-size: 0.875rem;
}

.sim-amount {
	font-family: var(--display);
	font-weight: 800;
	font-size: 2.6rem;
	line-height: 1.1;
	letter-spacing: -0.03em;
}

.sim-result.is-saving .sim-amount {
	color: var(--save);
}

.sim-sub {
	color: var(--muted);
	font-size: 0.875rem;
}

.sim-list {
	display: grid;
	gap: 0.15rem;
	margin: 0;
	padding: 0;
	list-style: none;
}

.sim-row {
	display: grid;
	grid-template-columns: auto minmax(0, 1fr) auto auto;
	align-items: center;
	gap: 0.65rem;
	width: 100%;
	min-height: 48px;
	padding: 0.4rem 0.4rem;
	border: 0;
	border-radius: var(--radius-sm);
	background: transparent;
	color: inherit;
	font: inherit;
	font-size: 0.92rem;
	text-align: left;
	cursor: pointer;
}

.sim-row:hover {
	background: var(--bg);
}

.sim-name {
	font-weight: 600;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.sim-cost {
	color: var(--muted);
	font-size: 0.85rem;
}

.sim-row.is-off .sim-name {
	text-decoration: line-through;
	color: var(--muted);
}

.sim-row.is-off .sim-cost {
	color: var(--save);
	font-weight: 700;
}

.switch {
	position: relative;
	width: 40px;
	height: 24px;
	border-radius: 12px;
	background: var(--ink);
	transition: background-color 0.18s ease;
}

.knob {
	position: absolute;
	top: 3px;
	left: 3px;
	width: 18px;
	height: 18px;
	border-radius: 50%;
	background: #fff;
	transform: translateX(16px);
	transition: transform 0.18s ease;
}

.sim-row.is-off .switch {
	background: #c3c7d6;
}

.sim-row.is-off .knob {
	transform: translateX(0);
}

/* Modal */
.overlay {
	position: fixed;
	inset: 0;
	z-index: 50;
	display: flex;
	align-items: flex-end;
	justify-content: center;
	background: rgba(22, 26, 51, 0.45);
	animation: fade 0.15s ease;
}

.sheet {
	width: 100%;
	max-height: 92vh;
	overflow-y: auto;
	padding: 1rem 1.1rem 1.25rem;
	border-radius: 18px 18px 0 0;
	background: var(--surface);
	box-shadow: var(--shadow);
	animation: rise 0.2s ease;
}

.sheet-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.5rem;
	margin-bottom: 0.75rem;
}

.sheet-head h2 {
	font-size: 1.35rem;
	overflow-wrap: anywhere;
}

.sheet-lede {
	margin-bottom: var(--space);
}

.sheet-actions {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 0.75rem;
}

.modal-preview {
	margin: 0 0 var(--space);
	padding: 0.7rem 0.85rem;
	border-radius: var(--radius-sm);
	background: var(--bg);
	font-size: 0.9rem;
	color: var(--muted);
}

.modal-preview strong {
	color: var(--fg);
}

.switch-line {
	margin: var(--space) 0 0;
	text-align: center;
	color: var(--muted);
	font-size: 0.9rem;
}

@keyframes fade {
	from {
		opacity: 0;
	}
}

@keyframes rise {
	from {
		transform: translateY(24px);
		opacity: 0;
	}
}

@media (min-width: 40rem) {
	.overlay {
		align-items: center;
		padding: 1rem;
	}

	.sheet {
		max-width: 32rem;
		border-radius: 18px;
		padding: 1.25rem 1.5rem 1.5rem;
	}

	.who {
		display: inline;
		max-width: 16rem;
	}
}

@media (min-width: 48rem) {
	.shell {
		max-width: 52rem;
		padding: calc(var(--space) * 2) calc(var(--space) * 1.5) calc(var(--space) * 4);
	}

	.burn {
		padding: 2rem 2rem 1.5rem;
	}
}

@media (min-width: 64rem) {
	.shell {
		max-width: 72rem;
	}

	.layout {
		grid-template-columns: minmax(0, 1fr) 22rem;
		align-items: start;
	}

	.col-side {
		position: sticky;
		top: 5rem;
	}
}

@media (prefers-reduced-motion: reduce) {
	.spinner,
	.skeleton,
	.overlay,
	.sheet {
		animation: none;
	}

	.knob,
	.btn {
		transition: none;
	}
}

:where(a, button, input, select, textarea):focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: 2px;
}
