:root {
	--bg: #f6f7f9;
	--surface: #ffffff;
	--border: #d9dde3;
	--text: #1a2330;
	--muted: #6b7588;
	--accent: #1f3b73;
	--accent-band: #2a4f9e;
	--row-alt: #f8fafc;
	--stage-closed: #1f8a4c;
	--stage-active: #117a99;
	--stage-invoiced: #5d3fb3;
	--stage-proposal: #b7791f;
	--stage-opportunity: #2563eb;
	--stage-lost: #c0392b;
	--stage-dead: #6b7280;
	--status-paid: #1f8a4c;
	--status-partpaid: #b7791f;
	--status-invoiced: #5d3fb3;
	--status-notinvoiced: #6b7280;
}

* { box-sizing: border-box; }
.logout-form { margin-left: auto; }
.logout-btn {
	background: none;
	border: 1px solid rgba(255,255,255,.4);
	color: #fff;
	padding: 4px 12px;
	border-radius: 4px;
	font: inherit;
	font-size: 12px;
	cursor: pointer;
	opacity: .8;
}
.logout-btn:hover { opacity: 1; }
body {
	margin: 0;
	background: var(--bg);
	color: var(--text);
	font: 14px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
header {
	background: var(--accent);
	color: #fff;
	padding: 14px 24px;
}
header h1 { margin: 0; font-size: 18px; font-weight: 600; letter-spacing: 0.2px; }
header .muted { color: #b9c5dc; font-weight: 400; }
main { padding: 18px 24px 32px; }

.summary {
	display: flex;
	gap: 14px;
	flex-wrap: wrap;
	margin-bottom: 14px;
}
.card {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: 8px;
	padding: 12px 16px;
	min-width: 180px;
}
.card-label { font-size: 11px; text-transform: uppercase; color: var(--muted); letter-spacing: 0.4px; }
.card-value { font-size: 22px; font-weight: 600; margin-top: 4px; font-variant-numeric: tabular-nums; }
.card-value.small { font-size: 14px; font-weight: 400; }
.card.meta { background: transparent; border: 1px dashed var(--border); }
.card.actual { border-left: 3px solid var(--stage-invoiced); }

.funnel {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: 8px;
	padding: 14px 16px 12px;
	margin: 0 0 14px 0;
}
.funnel figcaption { font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.funnel-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.funnel-stage {
	border-radius: 8px;
	padding: 7px 16px;
	color: #fff;
	text-align: center;
	font-size: 13px;
	font-weight: 600;
}
.funnel-stage.stage-opportunity { background: var(--stage-opportunity); }
.funnel-stage.stage-proposal    { background: var(--stage-proposal); }
.funnel-stage.stage-active      { background: var(--stage-active); }
.funnel-stage.stage-invoiced    { background: var(--stage-invoiced); }
.funnel-stage.stage-closed      { background: var(--stage-closed); }
.funnel-stage .funnel-count { display: block; font-size: 11px; font-weight: 400; opacity: .85; margin-top: 1px; }
.funnel-arrow {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 2px;
	min-width: 80px;
	font-size: 12px;
	font-variant-numeric: tabular-nums;
}
.funnel-pct { font-weight: 600; }
.funnel-shaft { width: 100%; border-top: 2px solid var(--border); position: relative; }
.funnel-shaft::after {
	content: "";
	position: absolute;
	right: -1px;
	top: -5px;
	border: 4px solid transparent;
	border-left-color: var(--border);
}
.funnel-days { font-size: 11px; color: var(--muted); }

.profit-chart {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: 8px;
	padding: 14px 16px 10px;
	margin: 0 0 14px 0;
}
.profit-chart figcaption {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 16px;
	font-size: 12px;
	color: var(--muted);
	margin-bottom: 6px;
	flex-wrap: wrap;
}
.profit-chart .threshold { display: inline-flex; gap: 7px; align-items: center; }
.profit-chart .threshold label { white-space: nowrap; }
.profit-chart .threshold input[type="range"] { width: 110px; cursor: pointer; vertical-align: middle; }
.profit-chart .threshold output { font-variant-numeric: tabular-nums; min-width: 2.4em; }
.profit-chart .legend { display: inline-flex; gap: 14px; align-items: center; }
.profit-chart .legend-item {
	background: none; border: none; padding: 0; margin: 0;
	font: inherit; color: inherit; cursor: pointer;
	display: inline-flex; align-items: center;
	transition: opacity .15s;
}
.profit-chart .legend-item:hover { opacity: .7; }
.profit-chart .legend-item.inactive { opacity: .35; text-decoration: line-through; }
.profit-chart .swatch {
	display: inline-block;
	width: 12px; height: 12px;
	border-radius: 2px;
	margin-right: 5px;
	vertical-align: -2px;
}
.profit-chart .swatch-certain     { background: #1a2330; }
.profit-chart .swatch-likely      { background: #8a92a3; }
.profit-chart .swatch-speculative { background: #d5dae3; }

.profit-chart svg { width: 100%; height: auto; display: block; }
.profit-chart .seg-certain     { fill: #1a2330; }
.profit-chart .seg-likely      { fill: #8a92a3; }
.profit-chart .seg-speculative { fill: #d5dae3; }
.profit-chart .grid  { stroke: #eef1f5; stroke-width: 1; }
.profit-chart .axis  { stroke: var(--border); stroke-width: 1; }
.profit-chart .axis-label { fill: var(--muted); font: 10px -apple-system, "Segoe UI", Roboto, sans-serif; }
.profit-chart .axis-label.current { fill: var(--stage-lost); font-weight: 700; }
.profit-chart .bar-total  { fill: var(--text); font: 10px -apple-system, "Segoe UI", Roboto, sans-serif; font-variant-numeric: tabular-nums; }

.scroll-x { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; }
table.forecast {
	border-collapse: collapse;
	width: 100%;
	font-size: 13px;
	font-variant-numeric: tabular-nums;
}
.forecast thead th {
	position: sticky;
	top: 0;
	background: var(--accent-band);
	color: #fff;
	font-weight: 600;
	text-align: left;
	padding: 8px 10px;
	border-bottom: 1px solid var(--accent);
	white-space: nowrap;
}
.forecast thead .totals th {
	background: #e9eef7;
	color: var(--accent);
	font-weight: 700;
	border-bottom: 2px solid var(--accent);
}
.forecast th.num, .forecast td.num { text-align: right; }
.forecast th.month, .forecast td.month { min-width: 88px; }
.forecast th.wide, .forecast td.wide { min-width: 260px; }
.forecast tbody td {
	padding: 6px 10px;
	border-bottom: 1px solid #eef1f5;
	white-space: nowrap;
}
.forecast tbody tr:nth-child(even) td { background: var(--row-alt); }
.forecast tbody tr:hover td { background: #eef4fd; }
.forecast tbody tr.stage-dead td, .forecast tbody tr.stage-lost td {
	color: #8a92a3;
	text-decoration: line-through;
	text-decoration-color: #c3cad6;
}
/* Rows whose WL band is toggled off in the chart legend. */
.forecast tbody tr.row-inactive td { color: #b6bcc8; }
.forecast tbody tr.row-inactive .stage-badge,
.forecast tbody tr.row-inactive .svc,
.forecast tbody tr.row-inactive a { opacity: .45; }

.totals-label { text-align: right !important; }

.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12px; }

.stage-badge {
	display: inline-block;
	padding: 2px 8px;
	border-radius: 999px;
	font-size: 11px;
	font-weight: 600;
	color: #fff;
	background: var(--stage-opportunity);
}
.stage-badge.stage-closed    { background: var(--stage-closed); }
.stage-badge.stage-active    { background: var(--stage-active); }
.stage-badge.stage-invoiced  { background: var(--stage-invoiced); }
.stage-badge.stage-proposal  { background: var(--stage-proposal); }
.stage-badge.stage-opportunity { background: var(--stage-opportunity); }
.stage-badge.stage-lost      { background: var(--stage-lost); }
.stage-badge.stage-dead      { background: var(--stage-dead); }

.status-badge {
	display: inline-block;
	padding: 2px 8px;
	border-radius: 999px;
	font-size: 11px;
	font-weight: 600;
	color: #fff;
	background: var(--status-notinvoiced);
	white-space: nowrap;
}
.status-badge.status-paid        { background: var(--status-paid); }
.status-badge.status-partpaid    { background: var(--status-partpaid); }
.status-badge.status-invoiced    { background: var(--status-invoiced); }
.status-badge.status-notinvoiced { background: var(--status-notinvoiced); }

.svc {
	display: inline-block;
	padding: 1px 6px;
	border-radius: 4px;
	font-size: 11px;
	font-weight: 600;
	background: #e2e8f0;
	color: #334155;
}

.login {
	max-width: 320px;
	margin: 80px auto;
	background: var(--surface);
	padding: 24px;
	border: 1px solid var(--border);
	border-radius: 8px;
}
.login label { display: block; margin-bottom: 12px; font-size: 12px; color: var(--muted); }
.login input {
	width: 100%;
	padding: 8px 10px;
	font-size: 14px;
	border: 1px solid var(--border);
	border-radius: 6px;
	margin-top: 4px;
}
.login button {
	background: var(--accent);
	color: #fff;
	border: 0;
	padding: 8px 16px;
	border-radius: 6px;
	cursor: pointer;
}
.login .error { color: var(--stage-lost); font-size: 12px; margin: 8px 0 0; }

/* --- top nav + web-traffic page --- */
.topnav {
	display: flex;
	align-items: center;
	gap: 18px;
	background: var(--accent);
	color: #fff;
	padding: 12px 24px;
}
.topnav a { color: #cdd8ee; text-decoration: none; font-size: 14px; }
.topnav a:hover { color: #fff; }
.topnav .brand { font-weight: 600; color: #fff; margin-right: 8px; }
.page-title { font-size: 18px; margin: 4px 0 16px; }
.notice {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: 8px;
	padding: 16px;
	color: var(--muted);
}
.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.chart-card {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: 8px;
	padding: 12px;
	margin: 0;
}
.chart-card.wide { grid-column: 1 / -1; }
.chart-card svg { width: 100%; height: auto; display: block; }

/* --- /web date-range presets --- */
.range-pills { display: flex; gap: 6px; margin: 0 0 16px; }
.range-pills .pill {
	padding: 4px 14px;
	border: 1px solid var(--border);
	border-radius: 999px;
	background: var(--surface);
	color: var(--muted);
	text-decoration: none;
	font-size: 13px;
}
.range-pills .pill:hover { color: var(--text); }
.range-pills .pill.active {
	background: var(--accent);
	border-color: var(--accent);
	color: #fff;
}

/* --- actual outgoings (Xero) on the profit chart --- */
.profit-chart .seg-outgoings { fill: #e34948; }
.profit-chart .swatch-outgoings { background: #e34948; }
/* Drawings top the red stack in a lighter step of the same hue; the pair
   passes the dataviz CVD/lightness checks on the white surface. */
.profit-chart .seg-drawings { fill: #f0908f; }
.profit-chart .swatch-drawings { background: #f0908f; }
.profit-chart .legend-note { display: inline-flex; align-items: center; }
