* {
	box-sizing: border-box;
	margin: 0;
	padding: 0;
	-webkit-tap-highlight-color: transparent
}

:root {
	--bg: #0a0a0f;
	--bg2: #111118;
	--bg3: #18181f;
	--bg4: #1e1e27;
	--border: rgba(255, 255, 255, 0.06);
	--border2: rgba(255, 255, 255, 0.1);
	--ink: #f0f0f8;
	--ink2: #9090a8;
	--ink3: #5d5d74;
	--green: #00d4a0;
	--green-dim: rgba(0, 212, 160, 0.12);
	--red: #ff5f6d;
	--red-dim: rgba(255, 95, 109, 0.12);
	--accent: #7c6fff;
	--accent-dim: rgba(124, 111, 255, 0.15);
	--accent2: #a78bfa;
	--gold: #f5c842;
	--gold-dim: rgba(245, 200, 66, 0.15);
	--r: 16px;
	--r2: 12px;
	--ease: cubic-bezier(0.4, 0, 0.2, 1);
	--side-w: 252px;
	--top-h: 60px;
}

html,
body {
	height: 100%;
	background: var(--bg);
}

body {
	font-family: 'DM Sans', system-ui, sans-serif;
	font-size: 14px;
	color: var(--ink);
	overscroll-behavior: none;
}

button,
input,
select {
	font: inherit;
	color: inherit
}

button {
	cursor: pointer;
	background: none;
	border: none
}

a {
	color: inherit;
	text-decoration: none
}

.hidden {
	display: none !important
}

.muted {
	color: var(--ink2)
}

.mono {
	font-family: 'DM Mono', monospace
}

.pos {
	color: var(--green)
}

.neg {
	color: var(--red)
}

.zero {
	color: var(--ink2)
}

/* Role-based visibility (the server enforces the same rules) */
body:not(.role-admin) .need-admin {
	display: none !important
}

/* ── Boot / login ───────────────────────────────────────────────────────── */
.boot {
	position: fixed;
	inset: 0;
	display: grid;
	place-items: center
}

.spinner {
	width: 28px;
	height: 28px;
	border-radius: 50%;
	border: 3px solid var(--border2);
	border-top-color: var(--accent);
	animation: spin .8s linear infinite
}

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

.login {
	min-height: 100dvh;
	display: grid;
	place-items: center;
	padding: 24px 16px;
	background: radial-gradient(1200px 600px at 50% -10%, rgba(124, 111, 255, .18), transparent 60%), var(--bg)
}

.login-card {
	width: 100%;
	max-width: 380px;
	background: var(--bg2);
	border: 1px solid var(--border2);
	border-radius: 20px;
	padding: 28px 24px;
	box-shadow: 0 20px 60px rgba(0, 0, 0, .45)
}

.login-sub {
	color: var(--ink2);
	margin: 6px 0 22px
}

.brand {
	display: flex;
	align-items: center;
	gap: 10px;
	font-weight: 700;
	font-size: 18px;
	letter-spacing: -.2px
}

.brand-lg {
	font-size: 24px
}

.brand-mark {
	width: 34px;
	height: 34px;
	border-radius: 10px;
	display: grid;
	place-items: center;
	background: linear-gradient(135deg, var(--accent), #5b4fe0);
	color: #fff;
	font-size: 18px
}

.pw-wrap {
	position: relative
}

.pw-wrap input {
	padding-right: 44px
}

.pw-eye {
	position: absolute;
	right: 4px;
	top: 50%;
	transform: translateY(-50%);
	width: 36px;
	height: 36px;
	color: var(--ink2);
	font-size: 18px
}

/* ── Forms & buttons ───────────────────────────────────────────────────── */
.fg {
	margin-bottom: 14px
}

.fg label {
	display: block;
	font-size: 12px;
	font-weight: 600;
	color: var(--ink2);
	margin-bottom: 6px
}

input,
select {
	width: 100%;
	background: var(--bg3);
	border: 1px solid var(--border2);
	border-radius: 10px;
	padding: 11px 12px;
	font-size: 15px;
	outline: none;
	transition: border-color .15s
}

input:focus,
select:focus {
	border-color: var(--accent)
}

input[type=date],
input[type=datetime-local] {
	color-scheme: dark
}

select {
	appearance: none;
	background-image: linear-gradient(45deg, transparent 50%, var(--ink2) 50%), linear-gradient(135deg, var(--ink2) 50%, transparent 50%);
	background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%;
	background-size: 5px 5px;
	background-repeat: no-repeat;
	padding-right: 32px
}

.check {
	display: flex;
	align-items: center;
	gap: 8px;
	margin-bottom: 14px;
	color: var(--ink2)
}

.check input {
	width: 18px;
	height: 18px;
	accent-color: var(--accent)
}

.row2 {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 10px
}

.hint {
	display: block;
	margin-top: 6px;
	font-size: 12px;
	color: var(--ink3)
}

.form-err {
	background: var(--red-dim);
	color: var(--red);
	border-radius: 10px;
	padding: 10px 12px;
	font-size: 13px;
	margin-bottom: 14px
}

.btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	padding: 10px 16px;
	border-radius: 10px;
	background: var(--bg3);
	border: 1px solid var(--border2);
	font-weight: 600;
	font-size: 14px;
	white-space: nowrap;
	transition: background .15s, transform .1s
}

.btn:hover {
	background: var(--bg4)
}

.btn:active {
	transform: scale(.98)
}

.btn.primary {
	background: var(--accent);
	border-color: var(--accent);
	color: #fff
}

.btn.primary:hover {
	background: #6c5ff0
}

.btn.danger {
	color: var(--red);
	border-color: rgba(255, 95, 109, .3)
}

.btn.block {
	width: 100%;
	padding: 12px
}

.btn:disabled {
	opacity: .6;
	pointer-events: none
}

.btn i {
	font-size: 17px
}

.ibtn {
	width: 38px;
	height: 38px;
	border-radius: 10px;
	display: inline-grid;
	place-items: center;
	color: var(--ink2);
	font-size: 19px;
	flex-shrink: 0;
	transition: background .15s, color .15s
}

.ibtn:hover {
	background: var(--bg3);
	color: var(--ink)
}

.ibtn.red:hover {
	color: var(--red)
}

/* ── App shell ─────────────────────────────────────────────────────────── */
.app {
	min-height: 100dvh
}

.sidebar {
	position: fixed;
	top: 0;
	bottom: 0;
	left: 0;
	width: var(--side-w);
	background: var(--bg2);
	border-right: 1px solid var(--border);
	display: flex;
	flex-direction: column;
	padding: 18px 14px;
	z-index: 40;
	transition: transform .25s var(--ease)
}

.sidebar .brand {
	padding: 4px 8px 18px
}

.nav {
	display: flex;
	flex-direction: column;
	gap: 2px
}

.nav-item {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 10px 10px;
	border-radius: 10px;
	color: var(--ink2);
	font-weight: 500;
	text-align: left;
	width: 100%
}

.nav-item i {
	font-size: 19px
}

.nav-item:hover {
	background: var(--bg3);
	color: var(--ink)
}

.nav-item.active {
	background: var(--accent-dim);
	color: var(--accent2)
}

.side-section {
	margin-top: 22px;
	flex: 1;
	overflow-y: auto;
	min-height: 0
}

.side-label {
	font-size: 11px;
	text-transform: uppercase;
	letter-spacing: .08em;
	color: var(--ink3);
	font-weight: 600;
	padding: 0 10px 8px
}

.side-acc {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 8px;
	padding: 8px 10px;
	border-radius: 10px;
	width: 100%;
	text-align: left;
	color: var(--ink2)
}

.side-acc:hover {
	background: var(--bg3)
}

.side-acc.active {
	background: var(--bg3);
	color: var(--ink)
}

.side-acc .mono {
	font-size: 12px
}

.side-foot {
	border-top: 1px solid var(--border);
	padding-top: 12px;
	margin-top: 12px
}

.me-chip {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 8px 4px 0 8px
}

.me-txt {
	flex: 1;
	min-width: 0;
	font-weight: 600;
	font-size: 13px
}

.me-txt div {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap
}

.me-txt .muted {
	font-weight: 400;
	font-size: 12px;
	text-transform: capitalize
}

.scrim {
	display: none
}

.main {
	margin-left: var(--side-w);
	min-height: 100dvh;
	display: flex;
	flex-direction: column
}

.topbar {
	position: sticky;
	top: 0;
	z-index: 20;
	height: var(--top-h);
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 0 24px;
	background: rgba(10, 10, 15, .85);
	backdrop-filter: blur(12px);
	-webkit-backdrop-filter: blur(12px);
	border-bottom: 1px solid var(--border)
}

.topbar h1 {
	font-size: 18px;
	font-weight: 700;
	flex: 1;
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap
}

.topbar-right {
	display: flex;
	align-items: center;
	gap: 4px
}

.menu-btn,
.back-btn,
.topbar-logout {
	display: none
}

.sync {
	color: var(--ink3);
	font-size: 18px;
	padding: 0 6px;
	display: inline-flex
}

.sync.busy {
	color: var(--accent2)
}

.sync.err {
	color: var(--red)
}

.view {
	padding: 20px 24px 40px;
	flex: 1
}

/* ── Ledger view ───────────────────────────────────────────────────────── */
.filters {
	display: flex;
	gap: 12px;
	align-items: center;
	justify-content: space-between;
	flex-wrap: wrap;
	margin-bottom: 16px
}

.chips {
	display: flex;
	gap: 6px;
	overflow-x: auto;
	scrollbar-width: none;
	min-width: 0;
	flex: 1
}

.chips::-webkit-scrollbar {
	display: none
}

.chip {
	padding: 7px 13px;
	border-radius: 999px;
	background: var(--bg2);
	border: 1px solid var(--border2);
	color: var(--ink2);
	font-size: 13px;
	font-weight: 500;
	white-space: nowrap;
	display: inline-flex;
	align-items: center;
	gap: 6px
}

.chip:hover {
	color: var(--ink)
}

.chip.active {
	background: var(--accent-dim);
	border-color: rgba(124, 111, 255, .4);
	color: var(--accent2)
}

.period {
	display: flex;
	gap: 8px;
	align-items: center;
	flex-wrap: wrap
}

.period select {
	width: auto;
	min-width: 170px;
	padding-top: 8px;
	padding-bottom: 8px;
	font-size: 14px
}

.range {
	display: flex;
	gap: 6px;
	align-items: center
}

.range input {
	width: 150px;
	padding: 7px 10px;
	font-size: 14px
}

.summary {
	display: grid;
	grid-template-columns: 1.4fr repeat(4, 1fr);
	gap: 12px;
	margin-bottom: 18px
}

.stat {
	background: var(--bg2);
	border: 1px solid var(--border);
	border-radius: var(--r);
	padding: 14px 16px;
	min-width: 0
}

.stat-l {
	font-size: 12px;
	color: var(--ink2);
	font-weight: 500;
	margin-bottom: 6px;
	display: flex;
	align-items: center;
	gap: 6px
}

.stat-v {
	font-family: 'DM Mono', monospace;
	font-size: 18px;
	font-weight: 500;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap
}

.stat.hero {
	background: linear-gradient(135deg, rgba(124, 111, 255, .22), rgba(124, 111, 255, .05)), var(--bg2);
	border-color: rgba(124, 111, 255, .25)
}

.stat.hero .stat-v {
	font-size: 24px
}

.split {
	display: grid;
	grid-template-columns: minmax(300px, 340px) 1fr;
	gap: 16px;
	align-items: start
}

.list-pane,
.detail-pane {
	background: var(--bg2);
	border: 1px solid var(--border);
	border-radius: var(--r);
	min-width: 0
}

.list-pane {
	position: sticky;
	top: calc(var(--top-h) + 16px);
	max-height: calc(100dvh - var(--top-h) - 32px);
	display: flex;
	flex-direction: column
}

.list-tools {
	display: flex;
	gap: 8px;
	padding: 12px;
	border-bottom: 1px solid var(--border)
}

.search {
	position: relative;
	flex: 1;
	min-width: 0
}

.search i {
	position: absolute;
	left: 11px;
	top: 50%;
	transform: translateY(-50%);
	color: var(--ink3);
	font-size: 16px
}

.search input {
	padding: 9px 10px 9px 34px;
	font-size: 14px
}

.list-tools select {
	width: auto;
	padding: 9px 30px 9px 10px;
	font-size: 14px
}

.add-cust span {
	display: none
}

.add-cust {
	padding: 9px 11px
}

.clist {
	overflow-y: auto;
	flex: 1;
	padding: 6px
}

.crow {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 10px;
	border-radius: 12px;
	width: 100%;
	text-align: left;
	transition: background .12s
}

.crow:hover {
	background: var(--bg3)
}

.crow.active {
	background: var(--accent-dim)
}

.av {
	width: 40px;
	height: 40px;
	border-radius: 12px;
	display: grid;
	place-items: center;
	font-weight: 700;
	font-size: 14px;
	flex-shrink: 0
}

.av.sm {
	width: 32px;
	height: 32px;
	border-radius: 10px;
	font-size: 12px;
	background: var(--accent-dim);
	color: var(--accent2)
}

.av.lg {
	width: 52px;
	height: 52px;
	border-radius: 15px;
	font-size: 18px
}

.cinfo {
	flex: 1;
	min-width: 0
}

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

.cmeta {
	font-size: 12px;
	color: var(--ink2);
	margin-top: 2px
}

.cbal {
	font-family: 'DM Mono', monospace;
	font-size: 13px;
	font-weight: 500;
	white-space: nowrap
}

.empty {
	text-align: center;
	padding: 48px 20px;
	color: var(--ink2)
}

.empty i {
	font-size: 36px;
	color: var(--ink3);
	display: block;
	margin-bottom: 10px
}

.empty p {
	font-weight: 600;
	color: var(--ink);
	margin-bottom: 4px
}

/* Detail pane */
.dhead {
	padding: 18px 20px;
	border-bottom: 1px solid var(--border);
	display: flex;
	flex-wrap: wrap;
	gap: 16px;
	align-items: center
}

.dwho {
	display: flex;
	gap: 14px;
	align-items: center;
	flex: 1;
	min-width: 220px
}

.dname {
	font-size: 20px;
	font-weight: 700;
	word-break: break-word
}

.dmeta {
	font-size: 13px;
	color: var(--ink2);
	margin-top: 3px;
	display: flex;
	flex-wrap: wrap;
	gap: 4px 12px
}

.dmeta span {
	display: inline-flex;
	align-items: center;
	gap: 4px
}

.dacts {
	display: flex;
	gap: 6px;
	align-items: center
}

.dstats {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 10px;
	padding: 14px 20px;
	border-bottom: 1px solid var(--border)
}

.dstats .stat {
	background: var(--bg3);
	padding: 10px 14px
}

.dstats .stat-v {
	font-size: 16px
}

.dtools {
	display: flex;
	gap: 8px;
	padding: 12px 20px;
	border-bottom: 1px solid var(--border);
	align-items: center;
	flex-wrap: wrap
}

.dtools .search {
	max-width: 320px
}

.seg-mini {
	display: inline-flex;
	background: var(--bg3);
	border: 1px solid var(--border2);
	border-radius: 10px;
	padding: 3px
}

.seg-mini button {
	padding: 5px 10px;
	border-radius: 7px;
	font-size: 13px;
	color: var(--ink2);
	font-weight: 500
}

.seg-mini button.active {
	background: var(--bg4);
	color: var(--ink)
}

.thead,
.trow {
	display: grid;
	grid-template-columns: minmax(0, 1fr) 150px 124px 136px 68px;
	gap: 12px;
	align-items: center;
	padding: 10px 20px
}

.thead {
	font-size: 11px;
	text-transform: uppercase;
	letter-spacing: .06em;
	color: var(--ink3);
	font-weight: 600;
	border-bottom: 1px solid var(--border)
}

.thead .r,
.trow .r {
	text-align: right
}

.tmonth {
	display: flex;
	justify-content: space-between;
	padding: 10px 20px 6px;
	font-size: 12px;
	font-weight: 600;
	color: var(--ink2);
	background: var(--bg2);
	position: sticky;
	top: var(--top-h);
	z-index: 1
}

.trow {
	border-top: 1px solid var(--border);
	transition: background .12s
}

.trow:hover {
	background: rgba(255, 255, 255, .02)
}

.tmain {
	display: flex;
	gap: 10px;
	align-items: center;
	min-width: 0
}

.ticon {
	width: 32px;
	height: 32px;
	border-radius: 10px;
	display: grid;
	place-items: center;
	flex-shrink: 0;
	font-size: 16px
}

.ticon.received {
	background: var(--green-dim);
	color: var(--green)
}

.ticon.given {
	background: var(--red-dim);
	color: var(--red)
}

.tnote {
	min-width: 0
}

.tnote div:first-child {
	font-weight: 500;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap
}

.tby {
	font-size: 11px;
	color: var(--ink3);
	margin-top: 2px;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap
}

.trow.clickable {
	cursor: pointer
}

.mac-left {
	margin-right: auto
}

.badges {
	display: flex;
	gap: 4px;
	flex-wrap: wrap
}

.badge {
	font-size: 11px;
	font-weight: 600;
	padding: 3px 8px;
	border-radius: 6px;
	background: var(--bg3);
	color: var(--ink2);
	white-space: nowrap
}

.badge.mine {
	background: var(--accent-dim);
	color: var(--accent2)
}

.badge.other {
	background: var(--gold-dim);
	color: var(--gold)
}

.tamt {
	font-family: 'DM Mono', monospace;
	font-weight: 500;
	white-space: nowrap
}

.tamt.received {
	color: var(--green)
}

.tamt.given {
	color: var(--red)
}

.tbal {
	font-family: 'DM Mono', monospace;
	font-size: 13px;
	color: var(--ink2);
	white-space: nowrap
}

.tacts {
	display: flex;
	justify-content: flex-end;
	gap: 2px
}

.tacts .ibtn {
	width: 32px;
	height: 32px;
	font-size: 16px
}

/* Rows stack into cards whenever the detail pane is narrow (laptop, tablet, phone). */
.detail-pane {
	container-type: inline-size
}

@container (max-width: 720px) {
	.thead {
		display: none
	}

	.trow {
		grid-template-columns: minmax(0, 1fr) auto auto;
		grid-template-areas: "main amt acts" "meta bal acts";
		gap: 6px 10px;
		padding: 12px 10px 12px 16px
	}

	.trow .tmain {
		grid-area: main
	}

	.trow .tmeta {
		grid-area: meta;
		padding-left: 42px
	}

	.trow .tamt {
		grid-area: amt
	}

	.trow .tbal {
		grid-area: bal;
		font-size: 12px
	}

	.trow .tacts {
		grid-area: acts
	}

	.tmonth {
		padding: 10px 16px 6px
	}
}

.detail-empty {
	padding: 80px 20px
}

/* ── Other pages ───────────────────────────────────────────────────────── */
.page-head {
	display: flex;
	justify-content: space-between;
	align-items: flex-start;
	gap: 16px;
	margin-bottom: 18px;
	flex-wrap: wrap
}

.page-head h2 {
	font-size: 22px;
	margin-bottom: 4px
}

.page-head p {
	max-width: 620px
}

.cards-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
	gap: 12px
}

.cards-grid.two {
	grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
	max-width: 900px
}

.card {
	background: var(--bg2);
	border: 1px solid var(--border);
	border-radius: var(--r);
	padding: 18px
}

.card h3 {
	font-size: 16px;
	margin-bottom: 14px
}

.acc-card {
	display: flex;
	flex-direction: column;
	gap: 10px
}

.acc-top {
	display: flex;
	align-items: center;
	gap: 10px
}

.acc-top i.ti-building-bank {
	width: 38px;
	height: 38px;
	border-radius: 11px;
	display: grid;
	place-items: center;
	background: var(--accent-dim);
	color: var(--accent2);
	font-size: 19px
}

.acc-name {
	font-weight: 700;
	flex: 1;
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis
}

.acc-bal {
	font-family: 'DM Mono', monospace;
	font-size: 20px
}

.kv {
	display: grid;
	grid-template-columns: 110px 1fr;
	gap: 10px;
	font-size: 14px
}

.kv dt {
	color: var(--ink2)
}

.table-card {
	background: var(--bg2);
	border: 1px solid var(--border);
	border-radius: var(--r);
	overflow: hidden
}

.urow {
	display: grid;
	grid-template-columns: minmax(0, 1.5fr) 80px 1.2fr 1fr 84px;
	gap: 12px;
	align-items: center;
	padding: 12px 18px;
	border-top: 1px solid var(--border)
}

.bk {
	display: flex;
	gap: 12px;
	align-items: flex-start;
	padding: 14px 18px;
	border-top: 1px solid var(--border)
}

.bk:first-child {
	border-top: none
}

.bk-main {
	flex: 1;
	min-width: 0;
	display: flex;
	flex-direction: column;
	gap: 3px
}

.bk-when {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	align-items: center;
	font-weight: 600
}

.bk-tag {
	font-size: 11px;
	font-weight: 600;
	padding: 2px 8px;
	border-radius: 99px;
	background: var(--accent-dim);
	color: var(--accent2)
}

.bk-tag.warn {
	background: var(--red-dim);
	color: var(--red)
}

.bk details {
	font-size: 13px;
	margin-top: 4px
}

.bk summary {
	cursor: pointer;
	color: var(--ink2)
}

.bk ul {
	list-style: none;
	margin: 8px 0 2px;
	padding: 0;
	display: grid;
	gap: 4px
}

.bk li {
	display: flex;
	justify-content: space-between;
	gap: 12px;
	padding: 6px 10px;
	border-radius: 8px;
	background: var(--bg3, rgba(255, 255, 255, .03))
}

.bk li span:last-child {
	color: var(--ink2);
	white-space: nowrap
}

.urow.head {
	border-top: none;
	font-size: 11px;
	text-transform: uppercase;
	letter-spacing: .06em;
	color: var(--ink3);
	font-weight: 600
}

.uwho {
	display: flex;
	gap: 10px;
	align-items: center;
	min-width: 0
}

.uwho div {
	min-width: 0
}

.uwho b {
	display: block;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap
}

.role {
	text-transform: capitalize
}

.uacts {
	display: flex;
	gap: 4px;
	justify-content: flex-end
}

.modal-p {
	font-size: 13px;
	line-height: 1.5;
	margin-bottom: 14px
}

.status-off {
	color: var(--red)
}

/* ── FAB, modals, toast ────────────────────────────────────────────────── */
.fab {
	display: none
}

.ov {
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, .6);
	backdrop-filter: blur(4px);
	-webkit-backdrop-filter: blur(4px);
	z-index: 100;
	display: grid;
	place-items: center;
	padding: 16px;
	animation: fade .15s ease
}

@keyframes fade {
	from {
		opacity: 0
	}
}

@keyframes up {
	from {
		transform: translateY(16px);
		opacity: 0
	}
}

.modal {
	width: 100%;
	max-width: 460px;
	max-height: calc(100dvh - 32px);
	overflow-y: auto;
	background: var(--bg2);
	border: 1px solid var(--border2);
	border-radius: 20px;
	padding: 20px;
	animation: up .2s var(--ease)
}

.mh {
	display: flex;
	align-items: center;
	gap: 10px;
	font-size: 17px;
	font-weight: 700;
	margin-bottom: 18px
}

.mh>i {
	color: var(--accent2);
	font-size: 20px
}

.mh .mt {
	flex: 1
}

.mac {
	display: flex;
	gap: 8px;
	justify-content: flex-end;
	margin-top: 6px
}

.seg {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 8px;
	margin-bottom: 14px
}

.seg button {
	padding: 11px;
	border-radius: 10px;
	border: 1px solid var(--border2);
	background: var(--bg3);
	color: var(--ink2);
	font-weight: 600;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 6px
}

.seg .seg-r.on {
	background: var(--green-dim);
	color: var(--green);
	border-color: rgba(0, 212, 160, .35)
}

.seg .seg-g.on {
	background: var(--red-dim);
	color: var(--red);
	border-color: rgba(255, 95, 109, .35)
}

.seg .seg-m.on {
	background: var(--accent-dim);
	color: var(--accent2);
	border-color: rgba(124, 111, 255, .4)
}

.seg .seg-o.on {
	background: var(--gold-dim);
	color: var(--gold);
	border-color: rgba(245, 200, 66, .4)
}

.toast {
	position: fixed;
	left: 50%;
	bottom: 24px;
	transform: translate(-50%, 20px);
	background: var(--bg4);
	border: 1px solid var(--border2);
	padding: 10px 16px;
	border-radius: 12px;
	font-weight: 500;
	opacity: 0;
	pointer-events: none;
	transition: all .2s var(--ease);
	z-index: 200;
	max-width: calc(100vw - 32px)
}

.toast.show {
	opacity: 1;
	transform: translate(-50%, 0)
}

.toast.err {
	color: var(--red);
	border-color: rgba(255, 95, 109, .35)
}

/* ── Responsive ────────────────────────────────────────────────────────── */

/* Laptop: tighter table */
@media (max-width: 1280px) {
	.summary {
		grid-template-columns: repeat(3, 1fr)
	}

	.summary .hero {
		grid-column: span 3
	}

}

/* Tablet: sidebar becomes a drawer */
@media (max-width: 1023px) {
	.sidebar {
		transform: translateX(-100%);
		box-shadow: 20px 0 60px rgba(0, 0, 0, .5)
	}

	body.side-open .sidebar {
		transform: none
	}

	body.side-open .scrim {
		display: block;
		position: fixed;
		inset: 0;
		background: rgba(0, 0, 0, .5);
		z-index: 30
	}

	.main {
		margin-left: 0
	}

	.menu-btn {
		display: inline-grid
	}

	.topbar {
		padding: 0 12px
	}

	.view {
		padding: 16px 16px 40px
	}

	.split {
		grid-template-columns: minmax(260px, 320px) 1fr
	}


	.tmonth {
		padding: 10px 16px 6px
	}

	.dhead,
	.dstats,
	.dtools {
		padding-left: 16px;
		padding-right: 16px
	}

	.urow {
		grid-template-columns: minmax(0, 1fr) auto 84px
	}

	.urow .u-hide {
		display: none
	}
}

/* Phone: one pane at a time, like the original app */
@media (max-width: 767px) {
	:root {
		--top-h: 56px
	}

	.topbar-logout {
		display: inline-grid
	}

	.summary {
		grid-template-columns: 1fr 1fr;
		gap: 8px
	}

	.summary .hero {
		grid-column: span 2
	}

	.stat {
		padding: 12px 14px
	}

	.stat-v {
		font-size: 16px
	}

	.stat.hero .stat-v {
		font-size: 26px
	}

	.filters {
		flex-direction: column;
		align-items: stretch;
		gap: 10px;
		margin-bottom: 12px
	}

	.period select {
		flex: 1
	}

	.range {
		width: 100%
	}

	.range input {
		flex: 1;
		width: auto;
		min-width: 0
	}

	.split {
		display: block
	}

	.list-pane {
		position: static;
		max-height: none;
		background: none;
		border: none
	}

	.list-tools {
		padding: 0 0 10px;
		border: none
	}

	.add-cust {
		display: none !important
	}

	.clist {
		padding: 0;
		background: var(--bg2);
		border: 1px solid var(--border);
		border-radius: var(--r)
	}

	.detail-pane {
		display: none;
		border: none;
		background: none
	}

	body.show-detail .detail-pane {
		display: block
	}

	body.show-detail .list-pane,
	body.show-detail .summary,
	body.show-detail .filters {
		display: none
	}

	body.show-detail .back-btn {
		display: inline-grid
	}

	body.show-detail .menu-btn {
		display: none
	}

	.dhead {
		padding: 4px 0 16px;
		border: none
	}

	.dstats {
		padding: 0 0 12px;
		border: none;
		gap: 8px;
		grid-template-columns: 1fr 1fr
	}

	.dstats .stat:first-child {
		grid-column: span 2
	}

	.dstats .stat {
		background: var(--bg2);
		padding: 10px 12px
	}

	.dstats .stat-v {
		font-size: 14px
	}

	.dtools {
		padding: 0 0 12px;
		border: none
	}

	.dtools .search {
		max-width: none;
		flex-basis: 100%
	}

	.dlist {
		background: var(--bg2);
		border: 1px solid var(--border);
		border-radius: var(--r);
		overflow: clip
	}

	.dacts .btn span {
		display: none
	}

	/* Tap a row to edit it; delete lives in the edit form. */
	.trow {
		grid-template-columns: minmax(0, 1fr) auto;
		grid-template-areas: "main amt" "meta bal";
		padding: 12px 14px
	}

	.trow .tacts {
		display: none
	}

	.trow .tmeta {
		padding-left: 0
	}

	.tmonth {
		top: var(--top-h)
	}

	.fab {
		display: grid;
		place-items: center;
		position: fixed;
		right: 18px;
		bottom: calc(18px + env(safe-area-inset-bottom));
		width: 56px;
		height: 56px;
		border-radius: 18px;
		background: var(--accent);
		color: #fff;
		font-size: 26px;
		box-shadow: 0 10px 30px rgba(124, 111, 255, .45);
		z-index: 25
	}

	.view {
		padding-bottom: 96px
	}

	.ov {
		place-items: end center;
		padding: 0
	}

	.modal {
		max-width: none;
		border-radius: 20px 20px 0 0;
		padding-bottom: calc(20px + env(safe-area-inset-bottom));
		max-height: 92dvh
	}

	.row2 {
		grid-template-columns: 1fr
	}

	.toast {
		bottom: calc(88px + env(safe-area-inset-bottom))
	}
}
