/* STASHFLOW BRAND SYSTEM — Brand Bible v1.0
   Deep Forest #00271D | Stashflow Green #003D2B | Emerald #126B4B
   Antique Cream #F4E8B9 | Stash Gold #C99A30 | Ink #17231E | Mist #E9EFEA */

:root {
	--deep-forest: #00271D;
	--stash-green: #003D2B;
	--emerald: #126B4B;
	--cream: #F4E8B9;
	--gold: #C99A30;
	--ink: #17231E;
	--mist: #E9EFEA;
	--cream-dim: rgba(244, 232, 185, 0.62);
	--cream-faint: rgba(244, 232, 185, 0.38);
	--emerald-line: rgba(18, 107, 75, 0.55);
	--emerald-soft: rgba(18, 107, 75, 0.3);
	--serif: Georgia, "Times New Roman", serif;
	--sans: Aptos, "Segoe UI", Arial, sans-serif;
	--mono: Consolas, "Courier New", monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
	font-family: var(--sans);
	background: var(--deep-forest);
	color: var(--cream);
}

/* ============ SHELL / SIDEBAR ============ */
.shell { display: flex; min-height: 100vh; }

.sidebar {
	width: 232px;
	flex: 0 0 232px;
	background: var(--stash-green);
	border-right: 1px solid var(--emerald-line);
	display: flex;
	flex-direction: column;
	padding: 18px 14px;
	position: sticky;
	top: 0;
	height: 100vh;
}

.side-brand { display: flex; align-items: center; gap: 10px; padding: 2px 6px 18px; }
.brand-logo { height: 44px; width: 44px; display: block; }
.wordmark {
	font-family: var(--serif);
	font-size: 17px;
	font-weight: 700;
	letter-spacing: 2px;
	color: var(--cream);
}
.tagline { font-family: var(--serif); font-style: italic; font-size: 10px; color: var(--cream-dim); }

.side-nav { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; flex: 1; }
.side-nav a {
	display: flex;
	align-items: center;
	gap: 11px;
	color: var(--cream-dim);
	text-decoration: none;
	font-size: 14px;
	font-weight: 600;
	padding: 10px 12px;
	border-radius: 9px;
	border: 1px solid transparent;
}
.side-nav a svg { width: 17px; height: 17px; fill: currentColor; opacity: 0.85; }
.side-nav a:hover { color: var(--cream); background: rgba(18, 107, 75, 0.25); }
.side-nav a.active {
	color: var(--gold);
	background: rgba(201, 154, 48, 0.1);
	border-color: rgba(201, 154, 48, 0.45);
}

.side-actions { display: flex; flex-direction: column; gap: 8px; padding-top: 14px; border-top: 1px solid var(--emerald-soft); }
.side-actions button { width: 100%; margin: 0; }

.main-col { flex: 1; min-width: 0; }
main { max-width: 1180px; margin: 0 auto; padding: 26px 28px 80px; }

.view.hidden { display: none; }

h2 {
	font-family: var(--serif);
	font-size: 15px;
	margin-bottom: 14px;
	color: var(--gold);
	text-transform: uppercase;
	letter-spacing: 1.6px;
	font-weight: 700;
}

.hint { font-family: var(--sans); font-size: 11px; color: var(--cream-faint); text-transform: none; letter-spacing: 0; font-weight: 400; }

section { margin-bottom: 44px; }

button {
	background: var(--emerald);
	color: var(--cream);
	border: 1px solid transparent;
	border-radius: 8px;
	padding: 9px 16px;
	font-family: var(--sans);
	font-size: 13px;
	font-weight: 600;
	cursor: pointer;
}
button.secondary { background: transparent; color: var(--cream-dim); border-color: var(--emerald-line); }
button:hover { filter: brightness(1.15); }
button:disabled { opacity: 0.55; cursor: wait; }

/* ============ PANELS / TABS ============ */
.panel {
	background: var(--stash-green);
	border: 1px solid var(--emerald-line);
	border-radius: 14px;
	padding: 18px 20px;
	margin-bottom: 22px;
}
.panel-title {
	font-family: var(--serif);
	font-size: 16px;
	font-weight: 700;
	margin-bottom: 12px;
	display: flex;
	align-items: center;
	gap: 10px;
}

.tabs { display: flex; gap: 6px; margin-bottom: 18px; border-bottom: 1px solid var(--emerald-soft); }
.tab {
	background: transparent;
	border: 0;
	border-bottom: 2px solid transparent;
	border-radius: 0;
	color: var(--cream-dim);
	padding: 8px 14px 10px;
	font-size: 14px;
	font-weight: 700;
}
.tab.active { color: var(--gold); border-bottom-color: var(--gold); }
.tab:hover { filter: none; color: var(--cream); }
.tab-badge {
	background: var(--gold);
	color: var(--deep-forest);
	border-radius: 999px;
	font-size: 11px;
	font-weight: 700;
	padding: 1px 7px;
	margin-left: 4px;
}
.tab-badge:empty, .tab-badge.hidden { display: none; }
.rtab.hidden { display: none; }

/* ============ CONTROLS ============ */
.ctl, select.ctl, input.ctl {
	background: var(--deep-forest);
	border: 1px solid var(--emerald-line);
	border-radius: 8px;
	color: var(--cream);
	font-family: var(--sans);
	font-size: 13px;
	padding: 8px 10px;
}
.ctl:focus { outline: none; border-color: var(--gold); }
input.ctl[type="date"] { color-scheme: dark; }

.filter-bar {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	align-items: center;
	margin-bottom: 14px;
}
.filter-bar .spacer { flex: 1; }
.filter-label { font-size: 11px; color: var(--cream-faint); text-transform: uppercase; letter-spacing: 1px; }

/* COLUMN CHOOSER DROPDOWN */
.dropdown { position: relative; }
.dropdown-menu {
	position: absolute;
	right: 0;
	top: calc(100% + 6px);
	background: var(--deep-forest);
	border: 1px solid var(--emerald-line);
	border-radius: 10px;
	padding: 10px 12px;
	z-index: 30;
	min-width: 170px;
	box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}
.dropdown-menu label {
	display: flex;
	align-items: center;
	gap: 8px;
	font-size: 13px;
	color: var(--cream-dim);
	padding: 5px 2px;
	cursor: pointer;
}
.dropdown-menu label:hover { color: var(--cream); }
.dropdown-menu input[type="checkbox"] { accent-color: var(--gold); }

/* ============ REPORT CONTROLS / DONUT ============ */
.report-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 8px; }
.range-nav { display: flex; align-items: center; gap: 6px; }
.range-arrow {
	background: var(--deep-forest);
	border: 1px solid var(--emerald-line);
	color: var(--cream-dim);
	border-radius: 8px;
	width: 34px;
	height: 34px;
	font-size: 18px;
	line-height: 1;
	padding: 0;
}
.range-arrow:disabled { opacity: 0.35; cursor: default; }
.range-label {
	font-family: var(--serif);
	font-size: 18px;
	font-weight: 700;
	min-width: 240px;
	text-align: center;
}

.spend-report {
	display: grid;
	grid-template-columns: 320px 1fr;
	gap: 34px;
	align-items: center;
	padding: 10px 4px;
}
.donut-wrap { display: flex; justify-content: center; }
#rp-donut svg { display: block; }
.donut-seg { cursor: pointer; transition: opacity 0.15s; }
.donut-seg.dim { opacity: 0.25; }
.donut-center-total { font-family: var(--serif); font-weight: 700; fill: var(--cream); }
.donut-center-label { fill: var(--cream-faint); font-family: var(--sans); }

.legend {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(215px, 1fr));
	gap: 4px 14px;
	align-content: center;
}
.legend-item {
	display: grid;
	grid-template-columns: 12px 22px 1fr;
	gap: 8px;
	align-items: start;
	padding: 8px 10px;
	border-radius: 10px;
	border: 1px solid transparent;
	cursor: pointer;
}
.legend-item:hover { background: rgba(18, 107, 75, 0.25); }
.legend-item.selected { background: rgba(201, 154, 48, 0.1); border-color: rgba(201, 154, 48, 0.45); }
.legend-item.dim { opacity: 0.4; }
.legend-dot { width: 11px; height: 11px; border-radius: 50%; margin-top: 4px; }
.legend-icon { font-size: 15px; line-height: 1.3; }
.legend-name { font-size: 13px; font-weight: 600; color: var(--cream); }
.legend-amt { font-size: 13px; color: var(--cream-dim); font-variant-numeric: tabular-nums; }

.cat-chip {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	background: rgba(201, 154, 48, 0.12);
	border: 1px solid var(--gold);
	color: var(--gold);
	border-radius: 999px;
	padding: 3px 11px;
	font-size: 12px;
	font-weight: 600;
	font-family: var(--sans);
}
.cat-chip .x { cursor: pointer; font-weight: 700; }

/* ============ STATS / CARDS (DASHBOARD) ============ */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.stat {
	background: var(--stash-green);
	border: 1px solid var(--emerald-line);
	border-radius: 12px;
	padding: 16px 18px;
}
.stat-label { font-size: 11px; color: var(--cream-faint); text-transform: uppercase; letter-spacing: 1.2px; }
.stat-value {
	font-family: var(--serif);
	font-size: 28px;
	font-weight: 700;
	margin-top: 6px;
	font-variant-numeric: tabular-nums;
}
.stat:first-child .stat-value { color: var(--gold); }

.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.card {
	background: var(--stash-green);
	border: 1px solid var(--emerald-line);
	border-radius: 12px;
	padding: 14px 16px;
}
.card .inst { font-size: 11px; color: var(--cream-faint); }
.card .inst, td .mask { font-family: var(--mono); }
.card .name { font-size: 14px; margin: 3px 0 8px; }
.card .bal { font-family: var(--serif); font-size: 19px; font-weight: 700; font-variant-numeric: tabular-nums; }

.acct-group-head {
	display: flex;
	justify-content: space-between;
	align-items: baseline;
	margin: 26px 0 12px;
}
.acct-group-head:first-child { margin-top: 0; }
.acct-group-head .total { font-family: var(--serif); font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ============ TABLES ============ */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
	text-align: left;
	color: var(--cream-faint);
	font-size: 11px;
	text-transform: uppercase;
	letter-spacing: 0.8px;
	padding: 8px 10px;
	border-bottom: 1px solid var(--gold);
	white-space: nowrap;
}
td { padding: 9px 10px; border-bottom: 1px solid rgba(18, 107, 75, 0.3); font-variant-numeric: tabular-nums; }
td.num, th.num { text-align: right; }
tr:hover td { background: rgba(18, 107, 75, 0.14); }

.txn-vendor { font-weight: 600; }
.txn-desc { color: var(--cream-dim); font-size: 12px; }
.txn-acct { color: var(--cream-dim); font-size: 12px; }
.txn-acct .mask { font-family: var(--mono); }
.amount-out { color: var(--cream); }
.amount-in { color: #7fd6a4; }
.pending-tag {
	font-size: 10px;
	text-transform: uppercase;
	letter-spacing: 0.8px;
	color: var(--gold);
	border: 1px solid rgba(201, 154, 48, 0.5);
	border-radius: 999px;
	padding: 1px 7px;
	margin-left: 6px;
}

.cat-pill {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	background: rgba(18, 107, 75, 0.28);
	border: 1px solid var(--emerald-line);
	color: var(--cream);
	border-radius: 999px;
	padding: 3px 10px;
	font-size: 12px;
	font-weight: 600;
	cursor: pointer;
	font-family: var(--sans);
}
.cat-pill:hover { border-color: var(--gold); filter: none; }
.cat-pill .src { font-size: 10px; opacity: 0.65; }
select.cat-edit { max-width: 190px; }

/* ============ ACCOUNT / CATEGORY MANAGEMENT ============ */
.row-inactive td { opacity: 0.42; }
.api-name { font-family: var(--mono); font-size: 12px; color: var(--cream-dim); }
.name-edit {
	background: transparent;
	border: 1px dashed transparent;
	color: var(--cream);
	padding: 3px 8px;
	border-radius: 7px;
	font-size: 13px;
	font-weight: 600;
	text-align: left;
}
.name-edit:hover { border-color: var(--gold); filter: none; }
.name-edit .unset { color: var(--cream-faint); font-weight: 400; font-style: italic; }
.ctl-sm { padding: 5px 8px; font-size: 12px; }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.sys-tag {
	font-size: 10px;
	text-transform: uppercase;
	letter-spacing: 0.8px;
	color: var(--cream-faint);
	border: 1px solid var(--emerald-line);
	border-radius: 999px;
	padding: 1px 7px;
	margin-left: 6px;
}
.del-row.hidden { display: none; }
.del-row td { background: rgba(201, 154, 48, 0.06); }

/* TOGGLE SWITCH */
.switch { position: relative; display: inline-block; width: 38px; height: 21px; cursor: pointer; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
	position: absolute;
	inset: 0;
	background: var(--deep-forest);
	border: 1px solid var(--emerald-line);
	border-radius: 999px;
	transition: background 0.15s;
}
.slider::before {
	content: "";
	position: absolute;
	height: 15px;
	width: 15px;
	left: 2px;
	top: 2px;
	background: var(--cream-faint);
	border-radius: 50%;
	transition: transform 0.15s, background 0.15s;
}
.switch input:checked + .slider { background: var(--emerald); border-color: var(--emerald); }
.switch input:checked + .slider::before { transform: translateX(17px); background: var(--cream); }

/* ============ PAGINATION ============ */
.pager {
	display: flex;
	align-items: center;
	gap: 12px;
	justify-content: flex-end;
	padding-top: 14px;
	font-size: 13px;
	color: var(--cream-dim);
}
.pager button { padding: 6px 12px; }
.pager .count { margin-right: auto; font-variant-numeric: tabular-nums; }

/* ============ MISC (DASHBOARD LEGACY) ============ */
.pos { color: #7fd6a4; }
.neg { color: #e8a08a; }

.bar-row { display: grid; grid-template-columns: 170px 1fr 90px; align-items: center; gap: 10px; margin-bottom: 7px; font-size: 13px; }
.bar-track { background: var(--stash-green); border: 1px solid rgba(18, 107, 75, 0.35); border-radius: 4px; height: 14px; overflow: hidden; }
.bar-fill { background: var(--emerald); height: 100%; border-radius: 3px; }
.bar-val { text-align: right; font-variant-numeric: tabular-nums; color: var(--cream-dim); }

.flag {
	background: rgba(201, 154, 48, 0.12);
	border: 1px solid var(--gold);
	color: var(--gold);
	border-radius: 8px;
	padding: 8px 12px;
	font-size: 13px;
	margin-bottom: 8px;
}

.empty { color: var(--cream-faint); font-size: 13px; padding: 12px 0; }
.subhead { font-size: 12px; color: var(--cream-dim); margin: 18px 0 8px; }
.subhead b { color: var(--cream); font-family: var(--serif); }

@media (max-width: 900px) {
	.spend-report { grid-template-columns: 1fr; }
	.sidebar { width: 64px; flex-basis: 64px; padding: 14px 8px; }
	.side-brand div, .side-nav a span { display: none; }
	.side-nav a { justify-content: center; }
}
