/* ==========================================================
   Kutumb Samaj Management — Design System
   Palette: deep teal (trust/community) + marigold (festival warmth)
   Type: Manrope (headings) + Inter (body)
   ========================================================== */

:root {
	--bg: #FAFAF8;
	--surface: #FFFFFF;
	--surface-sunk: #F1F4F2;
	--ink: #1B211F;
	--ink-muted: #62716C;
	--border: #E3E8E5;

	--primary: #1F4B43;
	--primary-dark: #143530;
	--primary-tint: #E6EEEC;

	--accent: #D98E04;
	--accent-tint: #FBEFD7;

	--credit: #2E7D32;
	--credit-tint: #E7F4E8;
	--debit: #B3261E;
	--debit-tint: #FBEAE9;

	--radius-sm: 6px;
	--radius-md: 10px;
	--radius-lg: 16px;

	--shadow: 0 1px 2px rgba(27,33,31,0.06), 0 1px 1px rgba(27,33,31,0.04);
}

:root[data-theme="dark"] {
	--bg: #10201C;
	--surface: #172823;
	--surface-sunk: #1E322C;
	--ink: #EAF2EF;
	--ink-muted: #93A8A1;
	--border: #2A3F38;

	--primary: #3C8A79;
	--primary-dark: #0D1E1A;
	--primary-tint: #1E3A33;

	--accent: #E8A733;
	--accent-tint: #3A2D14;

	--credit: #5FBF6C;
	--credit-tint: #1B3320;
	--debit: #EF7A70;
	--debit-tint: #3A1E1B;

	--shadow: 0 4px 14px rgba(0,0,0,0.4);
}
:root[data-theme="dark"] .sidebar { background: #0B1815; }
:root[data-theme="dark"] .login-wrap { background: linear-gradient(160deg, #0B1815 0%, #143530 55%, #1E4A40 100%); }
:root[data-theme="dark"] input, :root[data-theme="dark"] select, :root[data-theme="dark"] textarea {
	background: var(--surface-sunk); color: var(--ink);
}
:root[data-theme="dark"] .directory-photo-placeholder { border-color: var(--primary); }

* { box-sizing: border-box; }

body, .sidebar, .card, .stat-card, .topbar, input, select, textarea, .directory-card {
	transition: background-color .2s ease, color .2s ease, border-color .2s ease;
}

html, body {
	margin: 0;
	padding: 0;
	background: var(--bg);
	color: var(--ink);
	font-family: 'Inter', 'Noto Sans Gujarati', -apple-system, BlinkMacSystemFont, sans-serif;
	font-size: 15px;
	line-height: 1.55;
	-webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, .brand, .stat-value, .btn, .nav-label {
	font-family: 'Manrope', 'Noto Sans Gujarati', 'Inter', sans-serif;
}

h1, h2, h3 { color: var(--ink); font-weight: 700; margin: 0 0 6px; letter-spacing: -0.01em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.02rem; }
p { margin: 0 0 10px; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- App shell ---------- */
.app-shell {
	display: grid;
	grid-template-columns: 240px 1fr;
	min-height: 100vh;
}

.sidebar {
	background: var(--primary-dark);
	color: #EFF5F3;
	padding: 20px 14px 90px;
	position: sticky;
	top: 0;
	height: 100vh;
	overflow-y: auto;
}

.brand {
	display: flex;
	align-items: center;
	gap: 10px;
	color: #fff;
	font-weight: 800;
	font-size: 1.1rem;
	padding: 6px 10px 22px;
	border-bottom: 1px solid rgba(255,255,255,0.12);
	margin-bottom: 14px;
}
.brand .mark {
	width: 34px; height: 34px;
	background: var(--accent);
	border-radius: 9px;
	display: flex; align-items: center; justify-content: center;
	color: var(--primary-dark);
	font-weight: 800;
	flex-shrink: 0;
}

.role-badge {
	display: inline-block;
	font-size: 0.7rem;
	font-weight: 700;
	letter-spacing: 0.02em;
	padding: 3px 9px;
	border-radius: 20px;
	background: rgba(217,142,4,0.22);
	color: #F6CE6E;
	margin: 0 10px 16px;
}

.nav-group { margin-bottom: 4px; }
.nav-link {
	display: flex;
	align-items: center;
	gap: 11px;
	padding: 10px 12px;
	border-radius: var(--radius-sm);
	color: #C9D8D3;
	font-size: 0.92rem;
	font-weight: 600;
	margin-bottom: 2px;
}
.nav-link:hover { background: rgba(255,255,255,0.06); text-decoration: none; color: #fff; }
.nav-link.active { background: var(--accent); color: var(--primary-dark); }
.nav-link .ic { width: 18px; text-align: center; opacity: 0.9; }

.main {
	min-width: 0;
	display: flex;
	flex-direction: column;
}

.topbar {
	background: var(--surface);
	border-bottom: 1px solid var(--border);
	padding: 14px 24px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	position: sticky;
	top: 0;
	z-index: 10;
}
.topbar .who { font-size: 0.88rem; color: var(--ink-muted); }
.topbar .who strong { color: var(--ink); }
.menu-toggle { display: none; background: none; border: none; font-size: 1.4rem; cursor: pointer; color: var(--primary); }

.content { padding: 22px 24px 90px; flex: 1; }

.page-head {
	display: flex;
	align-items: flex-end;
	justify-content: space-between;
	flex-wrap: wrap;
	gap: 10px;
	margin-bottom: 18px;
}
.page-head p.subtitle { color: var(--ink-muted); margin: 0; font-size: 0.92rem; }

/* ---------- Buttons ---------- */
.btn {
	display: inline-flex;
	align-items: center;
	gap: 7px;
	border: 1px solid transparent;
	border-radius: var(--radius-sm);
	padding: 9px 16px;
	font-weight: 700;
	font-size: 0.88rem;
	cursor: pointer;
	background: var(--primary);
	color: #fff;
	text-decoration: none;
	transition: transform .05s ease, opacity .15s ease;
}
.btn:hover { opacity: 0.92; text-decoration: none; color: #fff; }
.btn:active { transform: scale(0.98); }
.btn-accent { background: var(--accent); color: var(--primary-dark); }
.btn-outline { background: transparent; color: var(--primary); border-color: var(--primary); }
.btn-outline:hover { background: var(--primary-tint); color: var(--primary); }
.btn-danger { background: var(--debit); }
.btn-sm { padding: 6px 11px; font-size: 0.8rem; }
.btn-block { width: 100%; justify-content: center; }

/* ---------- Cards & stats ---------- */
.card {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius-md);
	padding: 18px;
	box-shadow: var(--shadow);
}
.card + .card { margin-top: 16px; }

.stat-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
	gap: 14px;
	margin-bottom: 20px;
}
.stat-card {
	background: var(--surface);
	border: 1px solid var(--border);
	border-left: 4px solid var(--primary);
	border-radius: var(--radius-md);
	padding: 16px 18px;
	box-shadow: var(--shadow);
}
.stat-card.accent { border-left-color: var(--accent); }
.stat-card.credit { border-left-color: var(--credit); }
.stat-card.debit { border-left-color: var(--debit); }
.stat-label { font-size: 0.78rem; color: var(--ink-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; margin-bottom: 6px; }
.stat-value { font-size: 1.6rem; font-weight: 800; color: var(--ink); }
.stat-value.credit { color: var(--credit); }
.stat-value.debit { color: var(--debit); }

.two-col {
	display: grid;
	grid-template-columns: 1.4fr 1fr;
	gap: 16px;
}
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.data {
	width: 100%;
	border-collapse: collapse;
	font-size: 0.9rem;
}
table.data th {
	text-align: left;
	font-size: 0.75rem;
	text-transform: uppercase;
	letter-spacing: 0.03em;
	color: var(--ink-muted);
	font-weight: 700;
	padding: 10px 12px;
	border-bottom: 2px solid var(--border);
	white-space: nowrap;
}
table.data td {
	padding: 11px 12px;
	border-bottom: 1px solid var(--border);
	vertical-align: middle;
}
table.data tr:last-child td { border-bottom: none; }
table.data tr:hover td { background: var(--surface-sunk); }

.avatar-chip {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	font-weight: 600;
}
.avatar-circle {
	width: 30px; height: 30px;
	border-radius: 50%;
	background: var(--primary-tint);
	color: var(--primary);
	display: flex; align-items: center; justify-content: center;
	font-weight: 800;
	font-size: 0.8rem;
	flex-shrink: 0;
}

/* ---------- Badges / pills ---------- */
.pill {
	display: inline-block;
	padding: 3px 11px;
	border-radius: 20px;
	font-size: 0.75rem;
	font-weight: 700;
}
.pill-active, .pill-credit, .pill-paid { background: var(--credit-tint); color: var(--credit); }
.pill-inactive, .pill-debit, .pill-pending { background: var(--debit-tint); color: var(--debit); }
.pill-neutral { background: var(--surface-sunk); color: var(--ink-muted); }
.pill-accent { background: var(--accent-tint); color: #8A5A02; }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
@media (max-width: 700px) { .form-grid { grid-template-columns: 1fr; } }
.form-group { margin-bottom: 14px; display: flex; flex-direction: column; gap: 6px; }
.form-group.full { grid-column: 1 / -1; }
label { font-size: 0.83rem; font-weight: 700; color: var(--ink); }
label .opt { font-weight: 500; color: var(--ink-muted); }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=tel],
input[type=month], input[type=file], select, textarea {
	border: 1.5px solid var(--border);
	border-radius: var(--radius-sm);
	padding: 10px 12px;
	font-size: 0.92rem;
	font-family: inherit;
	background: var(--surface);
	color: var(--ink);
	width: 100%;
}
input:focus, select:focus, textarea:focus {
	outline: none;
	border-color: var(--primary);
	box-shadow: 0 0 0 3px var(--primary-tint);
}
textarea { resize: vertical; min-height: 80px; }
.radio-row { display: flex; gap: 18px; flex-wrap: wrap; padding: 8px 0; }
.radio-opt { display: flex; align-items: center; gap: 7px; font-weight: 600; cursor: pointer; }
.radio-opt input { width: auto; }

/* ---------- Alerts ---------- */
.alert {
	padding: 12px 16px;
	border-radius: var(--radius-sm);
	margin-bottom: 16px;
	font-size: 0.9rem;
	font-weight: 600;
	border: 1px solid transparent;
}
.alert-success { background: var(--credit-tint); color: #1E5C22; border-color: #BFE2C2; }
.alert-error { background: var(--debit-tint); color: #8C1E17; border-color: #EFC0BC; }

/* ---------- Empty state ---------- */
.empty-state {
	text-align: center;
	padding: 40px 20px;
	color: var(--ink-muted);
}
.empty-state .ic { font-size: 2.2rem; margin-bottom: 10px; }

/* ---------- Login page ---------- */
.login-wrap {
	min-height: 100vh;
	display: flex;
	align-items: center;
	justify-content: center;
	background: linear-gradient(160deg, var(--primary-dark) 0%, var(--primary) 55%, #2A5F55 100%);
	padding: 20px;
}
.login-card {
	background: var(--surface);
	border-radius: var(--radius-lg);
	padding: 36px 32px;
	width: 100%;
	max-width: 400px;
	box-shadow: 0 20px 50px rgba(0,0,0,0.25);
}
.login-brand {
	display: flex;
	flex-direction: column;
	align-items: center;
	text-align: center;
	margin-bottom: 22px;
}
.login-brand .mark {
	width: 52px; height: 52px;
	border-radius: 14px;
	background: var(--accent);
	color: var(--primary-dark);
	display: flex; align-items: center; justify-content: center;
	font-weight: 800;
	font-size: 1.4rem;
	margin-bottom: 12px;
}
.login-brand h1 { font-size: 1.25rem; margin-bottom: 2px; }
.login-brand p { color: var(--ink-muted); font-size: 0.85rem; margin: 0; }

.segmented {
	display: flex;
	background: var(--surface-sunk);
	border-radius: var(--radius-sm);
	padding: 3px;
	margin-bottom: 18px;
}
.segmented label {
	flex: 1;
	text-align: center;
	padding: 8px 4px;
	border-radius: 5px;
	font-size: 0.78rem;
	cursor: pointer;
	color: var(--ink-muted);
	font-weight: 700;
}
.segmented input { display: none; }
.segmented input:checked + span { display: block; }
.segmented .seg-opt { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; }

/* ---------- Misc ---------- */
.muted { color: var(--ink-muted); }
.mt-0 { margin-top: 0; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.screenshot-thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); }
.tag-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.filter-chip {
	padding: 6px 13px;
	border-radius: 20px;
	background: var(--surface-sunk);
	color: var(--ink-muted);
	font-size: 0.8rem;
	font-weight: 700;
	border: 1px solid var(--border);
}
.filter-chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ---------- Modal (plain CSS, no JS framework needed) ---------- */
.sidebar-scrim {
	display: none; /* excluded from grid flow entirely until opened on mobile */
	position: fixed;
	inset: 0;
	background: rgba(0,0,0,0.4);
	z-index: 80;
}
.modal-overlay {
	display: none;
	position: fixed; inset: 0;
	background: rgba(20,26,24,0.55);
	z-index: 100;
	align-items: center;
	justify-content: center;
	padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal-box {
	background: var(--surface);
	border-radius: var(--radius-lg);
	width: 100%;
	max-width: 480px;
	max-height: 90vh;
	overflow-y: auto;
	padding: 24px;
}
.modal-close { float: right; background: none; border: none; font-size: 1.3rem; cursor: pointer; color: var(--ink-muted); }

/* ---------- Bottom nav (mobile, PWA feel) ---------- */
.bottom-nav {
	display: none;
	position: fixed;
	bottom: 0; left: 0; right: 0;
	background: var(--surface);
	border-top: 1px solid var(--border);
	padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
	z-index: 50;
	box-shadow: 0 -2px 10px rgba(0,0,0,0.06);
}
.bottom-nav-inner { display: flex; justify-content: space-around; }
.bottom-nav a {
	display: flex; flex-direction: column; align-items: center; gap: 3px;
	color: var(--ink-muted);
	font-size: 0.66rem;
	font-weight: 700;
	padding: 4px 8px;
}
.bottom-nav a.active { color: var(--primary); }
.bottom-nav a .ic { font-size: 1.15rem; }

/* ---------- Birthday popup ---------- */
.bday-overlay {
	display: none;
	position: fixed; inset: 0;
	background: rgba(20,26,24,0.6);
	z-index: 200;
	align-items: center;
	justify-content: center;
	padding: 20px;
}
.bday-overlay.open { display: flex; }
.bday-box {
	background: linear-gradient(160deg, var(--surface) 0%, var(--accent-tint) 100%);
	border-radius: 20px;
	width: 100%;
	max-width: 380px;
	padding: 32px 26px 26px;
	text-align: center;
	position: relative;
	box-shadow: 0 24px 60px rgba(0,0,0,0.3);
	animation: bdayPop .35s cubic-bezier(.2,1.4,.4,1);
}
@keyframes bdayPop {
	0% { transform: scale(.85); opacity: 0; }
	100% { transform: scale(1); opacity: 1; }
}
.bday-emoji { font-size: 3rem; margin-bottom: 6px; }
.bday-box h2 { font-size: 1.4rem; margin: 4px 0 6px; color: var(--primary-dark); }
.bday-names { font-weight: 800; color: var(--accent); font-size: 1.1rem; margin: 4px 0 12px; }
.bday-close {
	margin-top: 14px;
	background: var(--primary);
	color: #fff;
	border: none;
	border-radius: 10px;
	padding: 10px 28px;
	font-weight: 700;
	font-family: 'Manrope', 'Noto Sans Gujarati', sans-serif;
	cursor: pointer;
}
.bday-close:hover { opacity: .9; }

/* ---------- Member Directory ---------- */
.directory-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
	gap: 16px;
}
.directory-card {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius-lg);
	padding: 20px 16px;
	text-align: center;
	transition: transform .15s ease, box-shadow .15s ease;
}
.directory-card:hover { transform: translateY(-3px); box-shadow: 0 10px 24px rgba(0,0,0,0.08); }
.directory-photo {
	width: 74px; height: 74px;
	border-radius: 50%;
	margin: 0 auto 12px;
	object-fit: cover;
	border: 3px solid var(--primary-tint);
	display: block;
}
.directory-photo-placeholder {
	width: 74px; height: 74px;
	border-radius: 50%;
	margin: 0 auto 12px;
	background: linear-gradient(135deg, var(--primary-tint), var(--accent-tint));
	color: var(--primary);
	display: flex; align-items: center; justify-content: center;
	font-weight: 800;
	font-size: 1.5rem;
	border: 3px solid var(--primary-tint);
}
.directory-name { font-weight: 800; font-family: 'Manrope','Noto Sans Gujarati',sans-serif; margin-bottom: 2px; }
.directory-relation { color: var(--ink-muted); font-size: 0.8rem; margin-bottom: 12px; }
.directory-actions { display: flex; gap: 8px; }
.directory-actions .btn { flex: 1; justify-content: center; padding: 7px 10px; font-size: 0.78rem; }

/* ---------- Notice board / rich cards ---------- */
.notice-preview { padding: 10px 0; border-bottom: 1px solid var(--border); }
.notice-preview:last-child { border-bottom: none; }

/* ---------- Theme toggle ---------- */
.theme-toggle-btn {
	background: none;
	border: 1px solid var(--border);
	border-radius: 50%;
	width: 34px; height: 34px;
	display: flex; align-items: center; justify-content: center;
	cursor: pointer;
	font-size: 1rem;
	color: var(--ink);
	flex-shrink: 0;
}
.theme-toggle-btn:hover { background: var(--surface-sunk); }

/* ---------- Activity timeline ---------- */
.timeline { position: relative; }
.timeline-day {
	font-family: 'Manrope','Noto Sans Gujarati',sans-serif;
	font-weight: 800;
	font-size: 0.78rem;
	color: var(--ink-muted);
	text-transform: uppercase;
	letter-spacing: 0.04em;
	margin: 16px 0 8px;
}
.timeline-day:first-child { margin-top: 0; }
.timeline-item {
	display: flex;
	gap: 12px;
	padding: 10px 0;
	border-bottom: 1px solid var(--border);
}
.timeline-item:last-child { border-bottom: none; }
.timeline-icon {
	width: 34px; height: 34px;
	border-radius: 50%;
	background: var(--primary-tint);
	color: var(--primary);
	display: flex; align-items: center; justify-content: center;
	font-size: 0.95rem;
	flex-shrink: 0;
}

/* ---------- Global search modal ---------- */
.search-overlay {
	display: none;
	position: fixed; inset: 0;
	background: rgba(20,26,24,0.55);
	z-index: 300;
	align-items: flex-start;
	justify-content: center;
	padding: 12vh 16px 16px;
}
.search-overlay.open { display: flex; }
.search-box {
	background: var(--surface);
	border-radius: var(--radius-lg);
	width: 100%;
	max-width: 560px;
	box-shadow: 0 24px 60px rgba(0,0,0,0.3);
	overflow: hidden;
}
.search-input-wrap { padding: 14px 16px; border-bottom: 1px solid var(--border); }
.search-input-wrap input {
	border: none !important;
	box-shadow: none !important;
	font-size: 1.05rem;
	padding: 6px 4px;
	background: transparent !important;
}
.search-results { max-height: 50vh; overflow-y: auto; }
.search-result {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 10px;
	padding: 12px 16px;
	border-bottom: 1px solid var(--border);
	color: var(--ink);
	text-decoration: none;
}
.search-result:hover { background: var(--surface-sunk); text-decoration: none; }
.search-result:last-child { border-bottom: none; }
.search-hint { padding: 18px 16px; color: var(--ink-muted); font-size: 0.9rem; text-align: center; }
.search-toggle-btn {
	background: var(--surface-sunk);
	border: 1px solid var(--border);
	border-radius: 20px;
	padding: 6px 14px;
	cursor: pointer;
	color: var(--ink-muted);
	font-size: 0.85rem;
	display: flex; align-items: center; gap: 8px;
}
.search-toggle-btn:hover { border-color: var(--primary); }
.search-toggle-btn kbd {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: 4px;
	padding: 1px 6px;
	font-size: 0.7rem;
}

/* ---------- Toast notifications ---------- */
.toast-container {
	position: fixed;
	top: 18px; right: 18px;
	z-index: 500;
	display: flex;
	flex-direction: column;
	gap: 10px;
	max-width: 340px;
}
.toast {
	background: var(--surface);
	border-left: 4px solid var(--credit);
	border-radius: var(--radius-md);
	padding: 14px 16px;
	box-shadow: 0 10px 30px rgba(0,0,0,0.18);
	font-size: 0.9rem;
	font-weight: 600;
	color: var(--ink);
	animation: toastIn .3s ease;
	display: flex; gap: 10px; align-items: flex-start;
}
.toast.error { border-left-color: var(--debit); }
.toast.hide { opacity: 0; transform: translateX(20px); transition: all .3s ease; }
@keyframes toastIn {
	from { opacity: 0; transform: translateX(30px); }
	to { opacity: 1; transform: translateX(0); }
}
@media (max-width: 880px) { .toast-container { left: 14px; right: 14px; max-width: none; top: 12px; } .hide-mobile { display: none; } .search-toggle-btn kbd { display: none; } }

/* ---------- White-label brand ---------- */
.brand-logo {
	height: 34px; width: 34px;
	object-fit: contain;
	background: #fff;
	border-radius: 9px;
	padding: 2px;
	flex-shrink: 0;
}
.brand-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Subscription banner ---------- */
.license-banner {
	background: var(--accent-tint);
	border: 1px solid var(--accent);
	color: var(--ink);
	border-radius: var(--radius-md);
	padding: 12px 16px;
	margin-bottom: 16px;
	font-weight: 600;
	font-size: 0.9rem;
}

/* ---------- Onboarding checklist ---------- */
.onboarding-card { margin-bottom: 20px; border: 1px solid var(--primary); }
.progress { height: 8px; background: var(--surface-sunk); border-radius: 8px; overflow: hidden; margin: 6px 0 14px; }
.progress-bar { height: 100%; background: linear-gradient(90deg, var(--primary), var(--accent)); border-radius: 8px; transition: width .4s ease; }
.checklist { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 8px; }
.check-item {
	display: flex; align-items: center; gap: 10px;
	padding: 10px 12px;
	border: 1px solid var(--border);
	border-radius: var(--radius-md);
	color: var(--ink);
	font-weight: 600;
	font-size: 0.88rem;
	text-decoration: none;
}
.check-item:hover { border-color: var(--primary); text-decoration: none; }
.check-item.done { color: var(--ink-muted); text-decoration: line-through; background: var(--surface-sunk); }
.check-box {
	width: 22px; height: 22px; border-radius: 50%;
	border: 2px solid var(--border);
	display: flex; align-items: center; justify-content: center;
	font-size: 0.8rem; color: #fff; flex-shrink: 0;
}
.check-item.done .check-box { background: var(--credit); border-color: var(--credit); }

/* ---------- Responsive ---------- */
@media (max-width: 880px) {
	.app-shell { grid-template-columns: 1fr; }
	.sidebar {
		position: fixed; left: 0; top: 0; bottom: 0; width: 250px;
		transform: translateX(-100%);
		transition: transform .2s ease;
		z-index: 90;
	}
	.sidebar.open { transform: translateX(0); }
	.menu-toggle { display: inline-flex; }
	.content { padding: 16px 14px 90px; }
	.topbar { padding: 12px 14px; }
	.bottom-nav { display: block; }
	.sidebar-scrim.open { display: block; }
}

/* ==========================================================
   v4 — Family tree
   ========================================================== */
.seg-toggle { display: inline-flex; border: 1px solid var(--border); border-radius: 20px; overflow: hidden; background: var(--surface); }
.seg-toggle button { border: none; background: none; padding: 7px 14px; font-weight: 700; font-size: 0.8rem; color: var(--ink-muted); cursor: pointer; font-family: inherit; }
.seg-toggle button.on { background: var(--primary); color: #fff; }

.tree-scroll { overflow-x: auto; padding-bottom: 10px; -webkit-overflow-scrolling: touch; }
.tree { display: inline-block; min-width: 100%; text-align: center; }
.tree ul { display: flex; justify-content: center; padding: 20px 0 0; margin: 0; position: relative; }
.tree li { list-style: none; text-align: center; position: relative; padding: 20px 8px 0; }
.tree li::before, .tree li::after { content: ''; position: absolute; top: 0; right: 50%; width: 50%; height: 20px; border-top: 2px solid var(--border); }
.tree li::after { right: auto; left: 50%; border-left: 2px solid var(--border); }
.tree li:only-child::before, .tree li:only-child::after { display: none; }
.tree li:only-child { padding-top: 0; }
.tree li:first-child::before, .tree li:last-child::after { border: 0 none; }
.tree li:last-child::before { border-right: 2px solid var(--border); border-radius: 0 8px 0 0; }
.tree li:first-child::after { border-radius: 8px 0 0 0; }
.tree ul ul::before { content: ''; position: absolute; top: 0; left: 50%; height: 20px; border-left: 2px solid var(--border); }
.tree > ul { padding-top: 0; }
.tree > ul > li { padding-top: 0; }
.tree > ul > li::before, .tree > ul > li::after { display: none; }

.tree-couple { display: inline-flex; align-items: center; gap: 4px; vertical-align: top; }
.tree-link { color: var(--debit); font-size: 0.95rem; }

.tp {
	display: flex; flex-direction: column; align-items: center; gap: 6px;
	background: var(--surface); border: 1.5px solid var(--border); border-top: 4px solid var(--primary);
	border-radius: 14px; padding: 10px 12px; min-width: 112px; max-width: 150px; box-shadow: var(--shadow);
}
.tp-m { border-top-color: #3B82C4; }
.tp-f { border-top-color: #D6568F; }
.tp-off { opacity: .6; border-style: dashed; }
.tp-late { background: var(--surface-sunk); }
.tp-img { width: 46px; height: 46px; border-radius: 50%; object-fit: cover; border: 2px solid var(--primary-tint); flex-shrink: 0; }
.tp-ph { display: flex; align-items: center; justify-content: center; background: var(--primary-tint); color: var(--primary); font-weight: 800; }
.tp-body { display: flex; flex-direction: column; align-items: center; gap: 1px; min-width: 0; }
.tp-name { font-weight: 800; font-size: 0.84rem; line-height: 1.25; color: var(--ink); word-break: break-word; font-family: 'Manrope','Noto Sans Gujarati',sans-serif; }
a.tp-name:hover { color: var(--primary); }
.tp-sub { font-size: 0.7rem; color: var(--ink-muted); }
.tp-tag { font-size: 0.62rem; font-weight: 700; background: var(--accent-tint); color: #8A5A02; border-radius: 10px; padding: 1px 7px; margin-top: 2px; }
.tp-tag-off { background: var(--debit-tint); color: var(--debit); }
.tp-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.tp-actions a { font-size: 0.66rem; font-weight: 700; padding: 2px 7px; border-radius: 10px; background: var(--primary-tint); color: var(--primary); }
.tp-actions a:hover { text-decoration: none; background: var(--primary); color: #fff; }
.tree-unplaced { display: flex; flex-wrap: wrap; gap: 10px; }

/* list (indented) view — best on phones */
.tree.tree-list { display: block; text-align: left; }
.tree.tree-list ul { display: block; padding: 0 0 0 18px; margin-left: 14px; border-left: 2px solid var(--border); }
.tree.tree-list > ul { padding-left: 0; margin-left: 0; border-left: none; }
.tree.tree-list ul ul::before { display: none; }
.tree.tree-list li { text-align: left; padding: 10px 0 0; }
.tree.tree-list li::before, .tree.tree-list li::after { display: none; }
.tree.tree-list .tree-couple { flex-wrap: wrap; justify-content: flex-start; }
.tree.tree-list .tp { flex-direction: row; max-width: none; min-width: 0; text-align: left; padding: 8px 12px 8px 10px; }
.tree.tree-list .tp-body { align-items: flex-start; }
.tree.tree-list .tp-name { text-align: left; }

/* ---------- collection plans screen ---------- */
.plan-tools { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.plan-tools select, .plan-tools input { width: auto; min-width: 150px; flex: 1; max-width: 240px; }
tr.row-off td { opacity: .6; }
.switch { position: relative; display: inline-block; width: 46px; height: 26px; cursor: pointer; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch-ui { position: absolute; inset: 0; background: var(--border); border-radius: 26px; transition: background .2s; }
.switch-ui::before { content: ''; position: absolute; left: 3px; top: 3px; width: 20px; height: 20px; background: #fff; border-radius: 50%; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.switch input:checked + .switch-ui { background: var(--credit); }
.switch input:checked + .switch-ui::before { transform: translateX(20px); }
.tree-fields { background: var(--primary-tint); padding: 14px; border-radius: 10px; }

/* ==========================================================
   v4 — Mobile = app feel (tables become cards, sheets, big taps)
   ========================================================== */
@media (max-width: 880px) {
	.table-wrap { overflow: visible; }
	table.data, table.data tbody, table.data tr, table.data td { display: block; width: 100%; }
	table.data thead { display: none; }
	table.data tr {
		background: var(--surface);
		border: 1px solid var(--border);
		border-radius: 14px;
		padding: 6px 14px;
		margin-bottom: 10px;
		box-shadow: var(--shadow);
	}
	table.data tr:hover td { background: transparent; }
	table.data td {
		display: flex; align-items: center; justify-content: space-between; gap: 14px;
		padding: 9px 0; border-bottom: 1px dashed var(--border);
		text-align: right; word-break: break-word;
	}
	table.data tr td:last-child { border-bottom: none; }
	table.data td::before {
		content: attr(data-label);
		flex-shrink: 0; max-width: 42%;
		font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
		color: var(--ink-muted); text-align: left;
	}
	/* first cell = card title */
	table.data td:first-child {
		justify-content: flex-start; text-align: left;
		font-weight: 800; font-size: 1rem; padding: 10px 0;
		border-bottom: 1px solid var(--border);
	}
	table.data td:first-child::before { display: none; }
	/* action cells: full-width button row */
	table.data td.td-actions, table.data td[data-label=""] {
		flex-wrap: wrap; justify-content: flex-start; gap: 8px; padding: 10px 0 8px;
	}
	table.data td.td-actions::before, table.data td[data-label=""]::before { display: none; }
	table.data td.td-actions .btn { flex: 1 1 auto; justify-content: center; padding: 9px 12px; }
	table.data td .avatar-chip { text-align: left; }
	table.data td input[type=number] { max-width: 120px !important; text-align: right; }

	/* page header stacks, buttons fill width */
	.page-head { flex-direction: column; align-items: stretch; }
	.page-head > div[style*="display:flex"], .page-head > form { width: 100%; }
	.page-head > div[style*="display:flex"] .btn { flex: 1; justify-content: center; }
	h1 { font-size: 1.3rem; }
	.stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
	.stat-value { font-size: 1.25rem; }
	.card { padding: 14px; border-radius: 14px; }

	/* inputs: 16px stops iOS zoom; taller tap targets */
	input[type=text], input[type=password], input[type=number], input[type=date], input[type=tel],
	input[type=month], input[type=file], select, textarea { font-size: 16px; padding: 12px; }
	.btn { padding: 11px 16px; }
	.btn-sm { padding: 9px 12px; font-size: 0.82rem; }

	/* modals become bottom sheets */
	.modal-overlay { align-items: flex-end; padding: 0; }
	.modal-box { max-width: none; border-radius: 22px 22px 0 0; max-height: 92vh; padding: 20px 18px calc(24px + env(safe-area-inset-bottom)); animation: sheetUp .25s ease; }
	@keyframes sheetUp { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }

	.search-overlay { padding: 8px; }
	.plan-tools select, .plan-tools input { max-width: none; min-width: 100%; }
	.tp-actions a { padding: 5px 10px; }
	.directory-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
}

/* tree list view: couple stacked, actions under the name (cleaner on phones) */
.tree.tree-list .tree-couple { flex-direction: column; align-items: flex-start; gap: 0; }
.tree.tree-list .tree-link { margin: 1px 0 1px 22px; line-height: 1; font-size: 0.85rem; }
.tree.tree-list .tp { flex-wrap: wrap; width: 100%; max-width: 360px; }
.tree.tree-list .tp-body { flex: 1; min-width: 90px; }
.tree.tree-list .tp-actions { width: 100%; justify-content: flex-start; padding-left: 56px; margin-top: -2px; }

/* ---------- Today popup (meeting / festival / event) ---------- */
.today-overlay { display: none; position: fixed; top: 0; right: 0; bottom: 0; left: 0; background: rgba(20,26,24,0.6); z-index: 210; align-items: center; justify-content: center; padding: 16px; }
.today-overlay.open { display: flex; }
.today-box { background: var(--surface); border-radius: 20px; width: 100%; max-width: 400px; max-height: 88vh; overflow-y: auto; padding: 24px 20px 20px; box-shadow: 0 24px 60px rgba(0,0,0,.3); animation: bdayPop .3s ease; }
.today-head { text-align: center; margin-bottom: 12px; }
.today-emoji { font-size: 2.4rem; }
.today-head h2 { margin: 2px 0; }
.today-list { display: flex; flex-direction: column; gap: 10px; }
.today-item { display: flex; gap: 12px; padding: 12px; border: 1px solid var(--border); border-left: 4px solid var(--primary); border-radius: 12px; background: var(--surface-sunk); }
.today-festival { border-left-color: var(--accent); }
.today-event { border-left-color: #D6568F; }
.today-ic { font-size: 1.5rem; }
.today-name { font-weight: 800; font-family: 'Manrope','Noto Sans Gujarati',sans-serif; margin: 3px 0; overflow-wrap: anywhere; }
.today-body { min-width: 0; flex: 1; }
.today-meta { font-size: 0.82rem; }
.today-note { font-size: 0.8rem; overflow-wrap: anywhere; }
.today-ic { flex: 0 0 auto; }

/* ---------- Amount management: easy mode ---------- */
.quick-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.qa-btn { display: flex; align-items: center; gap: 14px; text-align: left; border: none; cursor: pointer; border-radius: 16px; padding: 18px; color: #fff; font-family: inherit; box-shadow: var(--shadow); }
.qa-btn strong { display: block; font-size: 1.05rem; font-family: 'Manrope','Noto Sans Gujarati',sans-serif; }
.qa-btn small { display: block; opacity: .85; font-size: .78rem; margin-top: 2px; }
.qa-in { background: linear-gradient(135deg, #2E7D32, #43A047); }
.qa-out { background: linear-gradient(135deg, #B3261E, #D2453C); }
.qa-ic { width: 42px; height: 42px; border-radius: 50%; background: rgba(255,255,255,.22); display: flex; align-items: center; justify-content: center; font-size: 1.2rem; flex-shrink: 0; }
.qa-btn:active { transform: scale(.98); }
.seg-toggle a { display: inline-block; padding: 7px 14px; font-weight: 700; font-size: .8rem; color: var(--ink-muted); text-decoration: none; }
.seg-toggle a.on { background: var(--primary); color: #fff; }
.amount-hint { font-size: .8rem; color: var(--credit); font-weight: 600; }
.more-opts { margin-bottom: 14px; border: 1px dashed var(--border); border-radius: 10px; padding: 8px 12px; }
.more-opts summary { cursor: pointer; font-weight: 700; font-size: .85rem; color: var(--primary); }
.more-opts[open] summary { margin-bottom: 10px; }
@media (max-width: 880px) { .quick-actions { grid-template-columns: 1fr; } .qa-btn { padding: 16px; } }

@media (max-width: 880px) { .stat-grid-3 > .stat-card:first-child { grid-column: 1 / -1; } }

/* ---------- Work cards (reject with reason / reassign with comment) ---------- */
.work-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; align-items: start; }
.work-card { margin-bottom: 14px; border-left: 4px solid var(--accent); }
.work-grid .work-card { margin-bottom: 0; }
.work-card.work-rejected { border-left-color: var(--debit); }
.work-card.work-completed { border-left-color: var(--credit); }
.work-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.work-title { margin: 0 0 4px; font-size: 1.05rem; word-break: break-word; }
.work-desc { margin: 0 0 10px; font-size: 0.88rem; }
.work-note { background: var(--accent-tint); border-radius: var(--radius-md); padding: 10px 13px; margin: 10px 0; font-size: 0.88rem; }
.work-note p { margin: 4px 0 0; word-break: break-word; }
.work-note small { display: block; margin-top: 4px; opacity: .75; }
.work-note-bad { background: var(--debit-tint); color: var(--debit); }
.work-note-bad p { color: var(--ink); }
.work-reassign { margin: 10px 0 4px; }
.work-reassign > summary, .work-hist > summary { cursor: pointer; list-style: none; }
.work-reassign > summary::-webkit-details-marker, .work-hist > summary::-webkit-details-marker { display: none; }
.work-reassign[open] > summary { margin-bottom: 12px; }
.work-reassign form { background: var(--surface-sunk); border-radius: var(--radius-md); padding: 14px; }
.work-hist { margin-top: 10px; font-size: 0.85rem; }
.work-hist > summary { color: var(--primary); font-weight: 700; }
.wh { list-style: none; margin: 10px 0 0; padding: 0 0 0 4px; border-left: 2px solid var(--border); }
.wh li { display: flex; gap: 10px; padding: 0 0 12px 10px; position: relative; }
.wh .wi { flex: 0 0 auto; }
.wh small { display: block; color: var(--ink-muted); font-size: 0.74rem; }
.wh p { margin: 3px 0 0; color: var(--ink-muted); font-style: italic; word-break: break-word; }
.work-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.works-layout { align-items: start; }
@media (max-width: 880px) {
	.work-grid { grid-template-columns: 1fr; }
	.work-actions .btn { flex: 1; justify-content: center; text-align: center; }
	.work-reassign > summary { display: block; text-align: center; }
}

/* ---------- Website settings: tabs, switches, rows ---------- */
.tabs-wrap { position: sticky; top: 0; z-index: 15; background: var(--bg); margin: 0 -2px 16px; padding: 6px 2px; }
.tabs { display: flex; gap: 8px; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; padding: 2px; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 7px; padding: 10px 16px; border-radius: 999px; border: 1.5px solid var(--border); background: var(--surface); color: var(--ink-muted); font: inherit; font-weight: 700; font-size: 0.88rem; cursor: pointer; white-space: nowrap; min-height: 44px; }
.tab:hover { border-color: var(--primary); color: var(--primary); }
.tab.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.tab-panel { display: none; max-width: 820px; }
.tab-panel.active { display: block; }
.tab-panel .card { margin-bottom: 16px; }
.tab-panel .card > h3 { margin: 0 0 12px; }
.hint { font-size: 0.78rem; color: var(--ink-muted); display: block; margin-top: 2px; word-break: break-word; }
.small { font-size: 0.8rem; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 13px 0; border-top: 1px solid var(--border); }
.switch-row:first-of-type { border-top: 0; }
.switch-row.big { background: var(--primary-tint); border: 0; border-radius: var(--radius-md); padding: 14px 16px; margin-bottom: 14px; }
.sw-text { display: flex; align-items: center; gap: 10px; min-width: 0; line-height: 1.35; }
.sw-ic { font-size: 1.25rem; }
.switch { position: relative; flex: 0 0 auto; width: 50px; height: 28px; display: inline-block; }
.switch input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 2; }
.slider { position: absolute; inset: 0; border-radius: 999px; background: #c5cecb; transition: background .2s; }
.slider::before { content: ''; position: absolute; left: 3px; top: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .2s; }
.switch input:checked + .slider { background: var(--primary); }
.switch input:checked + .slider::before { transform: translateX(22px); }
.switch input:focus-visible + .slider { box-shadow: 0 0 0 3px var(--primary-tint); }
.info-box { display: flex; gap: 12px; align-items: flex-start; background: var(--accent-tint); border-radius: var(--radius-md); padding: 12px 14px; margin-bottom: 14px; font-size: 0.86rem; }
.info-box > span { font-size: 1.3rem; line-height: 1.2; }
.info-box p { margin: 3px 0 0; color: var(--ink-muted); }
.info-box a { color: var(--primary); font-weight: 700; }
.info-box.soft { background: var(--primary-tint); align-items: center; }
.info-box.soft p { margin: 0; color: var(--ink); }
.swatches { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.sw { width: 38px; height: 38px; border-radius: 50%; border: 3px solid var(--surface); box-shadow: 0 0 0 2px var(--border); cursor: pointer; padding: 0; }
.sw.on { box-shadow: 0 0 0 3px var(--ink); }
.swatches input[type=color] { width: 46px; height: 38px; padding: 2px; border-radius: 10px; border: 1.5px solid var(--border); background: var(--surface); cursor: pointer; }
.hero-prev { margin-top: 10px; }
.hero-prev img { max-width: 260px; width: 100%; border-radius: var(--radius-md); display: block; margin-bottom: 8px; }
.rep { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.rep-list { display: flex; flex-direction: column; gap: 10px; }
.rep-row { display: grid; grid-template-columns: minmax(110px, 0.8fr) 1.6fr 38px; gap: 8px; align-items: center; }
.rep.narrow .rep-row { grid-template-columns: 92px 1fr 38px; }
.rep-x { width: 38px; height: 38px; border-radius: 50%; border: 0; background: var(--debit-tint); color: var(--debit); font-size: 1.3rem; cursor: pointer; line-height: 1; }
.rep-add { align-self: flex-start; }
.save-bar { position: sticky; bottom: 0; z-index: 14; display: flex; justify-content: space-between; align-items: center; gap: 12px; background: var(--surface); border-top: 1px solid var(--border); box-shadow: 0 -6px 18px rgba(0,0,0,.06); padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px)); margin: 8px -2px 20px; border-radius: var(--radius-md); max-width: 820px; }
.gal-admin { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-top: 18px; }
.gal-item { border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; background: var(--surface); display: flex; flex-direction: column; }
.gal-item img { width: 100%; height: 110px; object-fit: cover; display: block; }
.gal-item .cap { padding: 6px 8px; min-height: 30px; word-break: break-word; }
.gal-item .btn { border-radius: 0; justify-content: center; text-align: center; }
@media (max-width: 880px) {
	.tabs-wrap { top: 0; }
	.tab { padding: 10px 14px; }
	.rep-row { grid-template-columns: 1fr 38px; }
	.rep-row input:nth-child(1) { grid-column: 1 / 2; }
	.rep-row input:nth-child(2) { grid-column: 1 / 2; }
	.rep-row .rep-x { grid-column: 2 / 3; grid-row: 1 / 3; align-self: center; }
	.rep.narrow .rep-row { grid-template-columns: 1fr 38px; }
	.save-bar { bottom: calc(62px + env(safe-area-inset-bottom, 0px)); margin: 8px -4px 20px; border-radius: var(--radius-md) var(--radius-md) 0 0; flex-direction: column; align-items: stretch; text-align: center; }
	.save-bar .btn { width: 100%; justify-content: center; }
}

/* ---------- Safety net for phones: grid children may shrink, nothing pushes the page sideways ---------- */
.two-col > *, .stat-grid > *, .form-grid > *, .work-grid > * { min-width: 0; }
.card, .table-wrap { max-width: 100%; }
img, video { max-width: 100%; height: auto; }
.card h1, .card h2, .card h3, td, .page-head h1 { overflow-wrap: anywhere; }
@media (max-width: 880px) { .table-wrap { overflow-x: auto; } }
@media (max-width: 400px) {
	.directory-grid { grid-template-columns: 1fr !important; }
	canvas { max-width: 100% !important; }
	.work-grid { grid-template-columns: 1fr; }
	.checklist { grid-template-columns: 1fr; }
}
@media (max-width: 360px) { .stat-grid, .stat-grid-3 { grid-template-columns: 1fr 1fr; } }
