@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&family=JetBrains+Mono:wght@500&display=swap');

:root {
	color-scheme: dark;
	--bg: #101412;
	--panel: #191f1c;
	--panel-raised: #202824;
	--panel-soft: #151a17;
	--line: rgba(229, 239, 231, .09);
	--line-strong: rgba(229, 239, 231, .16);
	--text: #edf2ed;
	--muted: #9aa89e;
	--mint: #71d6ae;
	--mint-dark: #183d30;
	--coral: #ff9279;
	--gold: #eacb75;
	--blue: #86b9d8;
	--danger: #ff7979;
	--radius: 8px;
	--radius-small: 6px;
	--sidebar-width: 246px;
	--ease-out: cubic-bezier(0.23, 1, 0.32, 1);
	--ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
	--ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);
	font-family: Manrope, sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
	min-height: 100vh;
	margin: 0;
	color: var(--text);
	background: linear-gradient(145deg, rgba(113, 214, 174, .035), transparent 38%),
		radial-gradient(ellipse at 90% 0%, rgba(255, 146, 121, .075), transparent 35%), var(--bg);
	font: 14px/1.55 Manrope, sans-serif;
}
button, input, select, textarea { font: inherit; }
button { color: inherit; }
.hidden { display: none !important; }
.bg-glow { position: fixed; inset: 0; pointer-events: none; opacity: .22; z-index: -1; }

/* Main navigation */
.sidebar {
	position: fixed;
	inset: 0 auto 0 0;
	z-index: 20;
	display: flex;
	flex-direction: column;
	width: var(--sidebar-width);
	padding: 25px 17px 18px;
	background: rgba(21, 26, 23, .94);
	border-right: 1px solid var(--line);
	backdrop-filter: blur(18px);
}
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px; margin-bottom: 38px; }
.logo-mark {
	display: grid;
	width: 42px;
	height: 42px;
	place-items: center;
	border-radius: 13px;
	color: #10251c;
	background: var(--mint);
	font-size: 22px;
	font-weight: 800;
	box-shadow: 0 7px 22px rgba(113, 214, 174, .18);
}
.logo-mark.big { width: 54px; height: 54px; margin: 0 auto 16px; font-size: 27px; }
.brand-name { color: var(--text); font-size: 16px; font-weight: 800; }
.brand-sub { color: var(--muted); font-size: 12px; }
#nav { display: grid; gap: 5px; }
#nav button {
	display: flex;
	align-items: center;
	gap: 13px;
	width: 100%;
	padding: 10px 12px;
	border: 1px solid transparent;
	border-radius: var(--radius-small);
	background: transparent;
	color: var(--muted);
	text-align: left;
	cursor: pointer;
	transition: background .16s ease, color .16s ease, border-color .16s ease;
}
#nav svg, .icon-btn svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
#nav button.active { color: var(--mint); background: rgba(113, 214, 174, .09); border-color: rgba(113, 214, 174, .13); }
.side-foot { margin-top: auto; }
.side-debt { display: grid; gap: 2px; margin-bottom: 14px; padding: 13px 14px; border: 1px solid var(--line); border-radius: 11px; background: var(--panel-soft); }
.side-debt span, .side-debt small { color: var(--muted); font-size: 11px; }
.side-debt b { font-size: 18px; font-variant-numeric: tabular-nums; }
.side-user { display: flex; flex-direction: column; gap: 7px; padding: 0 4px; color: var(--muted); font-size: 11px; overflow-wrap: anywhere; }
.logout-button { align-self: flex-start; border: 0; padding: 3px 0; background: none; color: var(--mint); cursor: pointer; font-size: 12px; }
.topbar { display: none; }

/* Page structure */
.shell { min-height: 100vh; }
main { max-width: 1440px; min-height: 100vh; margin-left: var(--sidebar-width); padding: 38px clamp(24px, 4.2vw, 66px) 70px; }
.view { animation: appear .14s var(--ease-out) both; }
@keyframes appear { from { opacity: 0; } to { opacity: 1; } }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin: 0 0 23px; }
.page-head h1 { margin: 0; font-size: 27px; line-height: 1.25; font-weight: 800; }
.sub { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.grid2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 17px; }
.card { min-width: 0; margin-bottom: 20px; padding: 21px 0; border: 0; border-top: 1px solid var(--line-strong); border-radius: 0; background: transparent; }
.card h3 { margin: 0 0 14px; color: #c5d0c7; font-size: 14px; font-weight: 700; }
.card-head h3 { margin-bottom: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 17px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.end { justify-content: flex-end; }
.narrow { max-width: 680px; }

/* Debt hero and overview numbers */
.hero { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 24px; min-height: 140px; margin-bottom: 22px; padding: 22px 0 26px; border-bottom: 1px solid var(--line-strong); background: transparent; }
.hero-left, .hero-right { position: relative; z-index: 1; }
.hero-left { display: grid; gap: 5px; }
.eyebrow { color: #c0dfcf; font-size: 11px; font-weight: 700; text-transform: uppercase; }
.hero-value { font-size: 30px; font-weight: 800; line-height: 1.3; overflow-wrap: anywhere; }
.hero-value strong { color: #ffe099; }
.hero-sub { color: rgba(237,242,237,.66); font-size: 11px; }
.hero-right { display: flex; flex-wrap: wrap; gap: 9px; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 0 0 17px; }
.kpi { min-width: 0; padding: 15px 17px; border-left: 2px solid var(--line-strong); background: var(--panel); }
.kpi span { display: block; color: var(--muted); font-size: 11px; font-weight: 600; }
.kpi b { display: block; margin-top: 5px; font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.kpi.v b { color: #9fb3ff; }
.kpi.l b { color: var(--coral); }

/* Inputs and controls */
label { display: flex; min-width: 0; flex-direction: column; gap: 6px; margin: 0 0 14px; color: var(--muted); font-size: 13px; font-weight: 700; }
input, select, textarea { width: 100%; min-width: 0; border: 1px solid var(--line-strong); border-radius: var(--radius-small); outline: none; background: #111613; color: var(--text); transition: border-color .15s ease, box-shadow .15s ease; }
input, select { min-height: 40px; padding: 8px 11px; }
input[type="date"], input[type="month"] { color-scheme: dark; }
textarea { display: block; min-height: 240px; padding: 14px; resize: vertical; font-family: "JetBrains Mono", Consolas, monospace; font-size: 12px; line-height: 1.65; }
input:focus, select:focus, textarea:focus { border-color: var(--mint); box-shadow: 0 0 0 3px rgba(113,214,174,.12); }
.form-grid { display: grid; grid-template-columns: minmax(140px, .8fr) minmax(220px, 2fr) minmax(120px, .75fr); gap: 12px; align-items: end; margin-bottom: 17px; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid label { margin: 0; }
.span2 { grid-column: span 1; }
.compact { width: auto; min-height: 35px; padding: 6px 9px; font-size: 11px; }
.btn, button { min-height: 38px; border: 1px solid var(--line-strong); border-radius: var(--radius-small); background: var(--panel-raised); color: var(--text); font-size: 13px; font-weight: 700; cursor: pointer; transition: transform .16s var(--ease-out), border-color .15s ease, background .15s ease; }
button { padding: 8px 13px; }
button:disabled { cursor: wait; opacity: .55; transform: none; }
button:focus-visible { outline: 2px solid var(--mint); outline-offset: 2px; }
button:active { transform: scale(.97); }
.btn.primary, button.primary { border-color: var(--mint); background: var(--mint); color: #10251c; }
.btn.ghost, button.ghost { background: transparent; }
.btn.glass { border-color: rgba(255,255,255,.22); background: rgba(8,18,13,.18); color: white; }
.btn.small { min-height: 34px; padding: 6px 10px; }
.link-btn, .text-button { min-height: auto; padding: 0; border: 0; background: none; color: var(--mint); font-size: 11px; }
.text-button { text-align: left; }
.icon-btn, .icon-button { display: inline-grid; min-width: 34px; min-height: 34px; place-items: center; padding: 4px; border: 1px solid transparent; background: transparent; color: var(--muted); font-size: 20px; }
.icon-btn { color: var(--text); }
.toggle { display: flex; flex-direction: row; align-items: center; gap: 10px; margin: 0; color: var(--text); font-size: 12px; font-weight: 600; cursor: pointer; }
.toggle input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.switch { position: relative; width: 36px; height: 20px; flex: none; border: 1px solid var(--line-strong); border-radius: 20px; background: var(--panel-raised); transition: background .16s ease; }
.switch::after { position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--muted); content: ''; transition: transform .16s var(--ease-out), background .16s ease; }
.toggle input:checked + .switch { border-color: var(--mint); background: var(--mint-dark); }
.toggle input:checked + .switch::after { transform: translateX(16px); background: var(--mint); }
.toggle input:focus-visible + .switch { outline: 2px solid var(--mint); outline-offset: 3px; }
.seg { display: flex; min-height: 40px; gap: 3px; padding: 3px; border: 1px solid var(--line-strong); border-radius: var(--radius-small); background: #111613; }
.seg button { flex: 1; min-height: 32px; padding: 5px 12px; border: 0; background: transparent; color: var(--muted); }
.seg button.active { background: var(--panel-raised); color: var(--mint); box-shadow: 0 1px 5px rgba(0,0,0,.25); }
.filter-bar { display: flex; flex-wrap: wrap; align-items: end; gap: 11px; }
.filter-bar label { min-width: 130px; margin: 0; }
.filter-bar .toggle { min-height: 40px; }
.or { padding: 0 1px 10px; color: var(--muted); font-size: 11px; }

/* Receipt and item editor */
.items-head, .item-row { display: grid; grid-template-columns: minmax(130px, 2.3fr) minmax(120px, 1.7fr) minmax(88px, .9fr) minmax(88px, .9fr) minmax(100px, 1fr) 34px; gap: 9px; align-items: center; }
.items-head { padding: 0 0 8px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.item-row { padding: 9px 0; border-bottom: 1px solid var(--line); }
.item-row:last-child { border-bottom: 0; }
.item-row .cell { position: relative; min-width: 0; }
.item-row input, .item-row select { min-height: 40px; padding: 7px 8px; font-size: 13px; }
.item-quantity { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; }
.cell[data-label]::before { display: none; content: attr(data-label); color: var(--muted); font-size: 12px; }
#items-wrap.single .items-head span:first-child, #items-wrap.single .item-name-cell { display: none; }
#items-wrap.single .items-head, #items-wrap.single .item-row { grid-template-columns: minmax(150px, 1.7fr) minmax(90px, 1fr) minmax(90px, 1fr) minmax(100px, 1fr) 34px; }
.sticky-summary { position: sticky; bottom: 12px; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 18px; border: 1px solid rgba(113,214,174,.2); border-radius: 8px; background: rgba(25,31,28,.96); backdrop-filter: blur(14px); }
.summary { display: flex; flex-wrap: wrap; align-items: center; gap: 9px 16px; color: var(--muted); font-size: 12px; }
.summary strong { color: var(--text); font-family: "JetBrains Mono", monospace; font-size: 17px; }
.summary em { color: var(--gold); font-style: normal; }
.suggestion-host { position: relative; }
.suggest-menu { position: absolute; z-index: 15; top: calc(100% + 4px); right: 0; left: 0; overflow: hidden; border: 1px solid var(--line-strong); border-radius: 9px; background: #242d28; box-shadow: 0 12px 28px rgba(0,0,0,.36); transform-origin: top; transition: opacity .14s var(--ease-out), transform .14s var(--ease-out); }
@starting-style {
	.suggest-menu { opacity: 0; transform: scale(.98); }
}
.suggest-option { display: block; width: 100%; min-height: 38px; border: 0; border-radius: 0; background: transparent; text-align: left; font-size: 13px; }
.suggest-option.active { background: var(--mint-dark); color: var(--mint); }
.warning { margin-top: 10px; padding: 9px 11px; border: 1px solid rgba(234,203,117,.25); border-radius: 8px; background: rgba(234,203,117,.08); color: var(--gold); font-size: 12px; }

/* Charts, totals, and lists */
.chart-wrap { position: relative; height: 245px; }
.chart-wrap.tall { height: 310px; }
.expense-line { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.expense-line:last-child { border-bottom: 0; }
.expense-line > strong { flex: none; font-variant-numeric: tabular-nums; }
.expense-description { display: flex; min-width: 0; align-items: center; gap: 10px; }
.expense-description > span:last-child { min-width: 0; }
.expense-description b { display: block; font-size: 13px; overflow-wrap: anywhere; }
.expense-description small { display: block; color: var(--muted); font-size: 11px; }
.person-mark { display: inline-grid; width: 25px; height: 25px; flex: none; place-items: center; border-radius: 50%; background: #2c3942; color: var(--blue); font-size: 10px; font-weight: 800; }
.person-mark.L { background: #402b28; color: var(--coral); }
.empty { padding: 25px 8px; color: var(--muted); text-align: center; font-size: 12px; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; white-space: nowrap; font-variant-numeric: tabular-nums; }
th { padding: 9px 10px; border-bottom: 1px solid var(--line-strong); color: var(--muted); text-align: left; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
td { padding: 10px; border-bottom: 1px solid var(--line); }
tbody tr:last-child td { border-bottom: 0; }
.detail-row td { padding: 8px 13px; background: var(--panel-soft); }
.detail-items { display: grid; }
.detail-items > div { display: grid; grid-template-columns: minmax(140px, 2fr) minmax(100px, 1.2fr) minmax(100px, 1fr) minmax(55px, .6fr); gap: 12px; padding: 9px 4px; border-bottom: 1px solid var(--line); font-size: 12px; }
.detail-items > div:last-child { border-bottom: 0; }
.detail-items small, .detail-items s { color: var(--muted); }
.category-list, .top-items { display: grid; gap: 14px; }
.category-stat-head { display: grid; grid-template-columns: 1fr auto 46px; gap: 10px; align-items: center; font-size: 12px; }
.category-stat-head b { font-size: 12px; }
.category-stat-head small { color: var(--muted); text-align: right; }
.meter { height: 4px; margin-top: 7px; overflow: hidden; border-radius: 5px; background: var(--panel-raised); }
.meter i { display: block; height: 100%; border-radius: inherit; }
.top-items > div { display: grid; grid-template-columns: 28px 1fr auto; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.top-items > div:last-child { border-bottom: 0; }
.top-items b { font-size: 12px; }
.rank { color: var(--mint); font-family: "JetBrains Mono", monospace; font-size: 11px; }
.top-name { min-width: 0; font-size: 12px; }
.top-name small { display: block; color: var(--muted); font-size: 11px; }
.top-items + .empty { margin: auto; }
#st-totals { grid-template-columns: repeat(5, minmax(0, 1fr)); }

/* Login gate and notifications */
.gate { display: grid; min-height: 100vh; place-items: center; padding: 22px; background: radial-gradient(ellipse at 50% 15%, rgba(113,214,174,.13), transparent 42%), var(--bg); }
.gate-card { width: min(100%, 410px); padding: 38px; border: 1px solid var(--line-strong); border-radius: 17px; background: var(--panel); text-align: center; box-shadow: 0 24px 80px rgba(0,0,0,.35); }
.gate-card h1 { margin: 0; font-size: 24px; }
.gate-card p { margin: 8px 0 24px; color: var(--muted); font-size: 13px; }
.gate-err { min-height: 18px; color: var(--danger) !important; }
#g-signin { display: flex; justify-content: center; min-height: 42px; }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 60; max-width: min(420px, calc(100vw - 32px)); padding: 12px 16px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--panel-raised); color: var(--text); box-shadow: 0 12px 32px rgba(0,0,0,.35); font-size: 13px; opacity: 0; transform: translateY(12px); pointer-events: none; transition: transform .3s var(--ease-out), opacity .3s var(--ease-out); }
.toast.show { opacity: 1; transform: translateY(0); pointer-events: auto; }
.toast.success { border-color: rgba(113,214,174,.36); }
.toast.error { border-color: rgba(255,121,121,.4); color: #ffd4d4; }

/* Hover is feedback only on devices that actually hover */
@media (hover: hover) and (pointer: fine) {
	#nav button:hover { color: var(--text); background: rgba(255, 255, 255, .04); }
	button:hover { border-color: rgba(113,214,174,.5); }
	.btn.primary:hover, button.primary:hover { background: #8ae2bc; }
	.suggest-option:hover { background: var(--mint-dark); color: var(--mint); }
}

@media (max-width: 1050px) {
	:root { --sidebar-width: 215px; }
	main { padding-right: 24px; padding-left: 24px; }
	.items-head, .item-row { grid-template-columns: minmax(105px, 1.8fr) minmax(100px, 1.5fr) minmax(76px, .8fr) minmax(76px, .8fr) minmax(92px, .9fr) 30px; gap: 6px; }
}
@media (max-width: 780px) {
	.sidebar { transform: translateX(-105%); transition: transform .28s var(--ease-drawer); box-shadow: 15px 0 45px rgba(0,0,0,.3); }
	.sidebar.open { transform: translateX(0); }
	.topbar { position: sticky; top: 0; z-index: 15; display: flex; height: 54px; align-items: center; gap: 10px; padding: 0 14px; border-bottom: 1px solid var(--line); background: rgba(16,20,18,.94); backdrop-filter: blur(12px); }
	.topbar .brand-name { font-size: 14px; }
	main { margin: 0; padding: 23px 17px 48px; }
	.page-head { align-items: flex-start; }
	.page-head h1 { font-size: 23px; }
	.grid2 { grid-template-columns: 1fr; gap: 0; }
	.hero { min-height: 170px; align-items: flex-start; flex-direction: column; justify-content: center; padding: 23px; }
	.hero-right { margin-top: 7px; }
	.kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
	.kpi { padding: 12px 13px; }
	.kpi b { font-size: 17px; }
	.form-grid, .form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
	.form-grid .span2 { grid-column: 1 / -1; }
	.filter-bar { align-items: end; }
	.filter-bar label { flex: 1 1 130px; }
	.items-head { display: none; }
	.item-row, #items-wrap.single .item-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
	.item-name-cell { grid-column: 1 / -1; }
	.cell[data-label]::before { display: block; margin-bottom: 4px; }
	.card-head { flex-wrap: wrap; }
	.card-head .row { flex-wrap: wrap; max-width: 100%; }
	.compact { max-width: 100%; }
	.row { flex-wrap: wrap; }
	.page-head { flex-wrap: wrap; }
	.item-row input, .item-row select { font-size: 16px; }
	.summary, .sticky-summary > .row { width: 100%; }
	.sticky-summary button { flex: 1; white-space: normal; }
	#items-wrap.single .item-name-cell { display: none; }
	.item-row .cell:last-child { justify-self: end; }
	.sticky-summary { position: static; align-items: flex-start; flex-direction: column; }
	#st-totals { grid-template-columns: repeat(2, minmax(0, 1fr)); }
	#st-totals .kpi:last-child { grid-column: span 2; }
	.page-head > .row { width: 100%; flex-wrap: wrap; }
	.page-head > .row input { flex: 1 1 130px; }
}
@media (max-width: 430px) {
	main { padding-right: 12px; padding-left: 12px; }
	.card { padding: 16px 0; }
	.form-grid, .form-grid.two { grid-template-columns: 1fr; }
	.form-grid .span2 { grid-column: auto; }
	.hero-value { font-size: 25px; }
	.chart-wrap { height: 220px; }
	.detail-items > div { grid-template-columns: minmax(100px, 1fr) auto; }
	.detail-items > div > :nth-child(2), .detail-items > div > :nth-child(4) { color: var(--muted); }
	.filter-bar label { flex-basis: 100%; }
	.filter-bar .or { display: none; }
}

@media (prefers-reduced-motion: reduce) {
	/* Gentler, not zero: keep opacity/color feedback, drop movement */
	.view { animation-duration: .01ms; }
	.sidebar, .switch::after, .btn, button, .suggest-menu { transition-duration: .01ms; }
	button:active { transform: none; }
	.toast { transform: none; transition: opacity .15s ease; }
	html { scroll-behavior: auto; }
}
