:root {
	color-scheme: light;

	--page: #f9f9f9;
	--surface: #ffffff;
	--text: #191919;
	--text-secondary: #666666;
	--border: #dcdcdc;
	--stripe: #f6f7f7;
	--link: #1757ac;
	--primary: #1757ac;
	--primary-text: #ffffff;
	--danger: #b32d2e;
	--good-text: #006c10;
	--bad-text: #b32d2e;

	/* Chart ink */
	--grid: #e7e7e7;
	--axis: #c2c2c2;

	/* Years: one hue, darker toward the present. seq-0 is the current year. */
	--seq-0: #0e3d7e;
	--seq-1: #1757ac;
	--seq-2: #2370cd;
	--seq-3: #338ced;
	--seq-4: #519ced;
	--seq-5: #6aabf1;
	--seq-6: #84b9f3;

	/* Unrelated series. */
	--cat-1: #257de0;
	--cat-2: #f47230;
}

@media (prefers-color-scheme: dark) {
	:root {
		color-scheme: dark;

		--page: #0b0b0b;
		--surface: #191919;
		--text: #efefef;
		--text-secondary: #9c9c9c;
		--border: #3a3a3a;
		--stripe: #202020;
		--link: #84b9f3;
		--primary: #257de0;
		--primary-text: #ffffff;
		--danger: #eb6263;
		--good-text: #53c556;
		--bad-text: #eb6263;

		--grid: #303030;
		--axis: #474747;

		/* On a dark surface the present is the lightest step. */
		--seq-0: #b6d5f8;
		--seq-1: #84b9f3;
		--seq-2: #519ced;
		--seq-3: #257de0;
		--seq-4: #2370cd;
		--seq-5: #1b64be;
		--seq-6: #1757ac;

		--cat-1: #338ced;
		--cat-2: #e76624;
	}
}

* {
	box-sizing: border-box;
}

body {
	margin: 0;
	background: var(--page);
	color: var(--text);
	font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
	line-height: 1.5;
}

a {
	color: var(--link);
}

h1 {
	font-size: 1.5rem;
	font-weight: 500;
	margin: 0 0 1rem;
}

h2 {
	font-size: 1.2rem;
	margin: 2rem 0 0.5rem;
}

h3 {
	font-size: 1.05rem;
	margin: 0 0 0.75rem;
}

.hardware {
	margin: -0.5rem 0 1rem;
	color: var(--text-secondary);
}

.site-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 1rem;
	padding: 0.6rem 1rem;
	background: var(--surface);
	border-bottom: 1px solid var(--border);
}

.brand {
	font-weight: 700;
	text-decoration: none;
	color: var(--text);
}

.logout {
	display: flex;
	gap: 0.75rem;
	align-items: center;
	color: var(--text-secondary);
}

main {
	max-width: 70rem;
	margin: 0 auto;
	padding: 1.5rem 1rem 4rem;
}

.auth {
	max-width: 40rem;
	margin: 2rem auto;
}

/* Notices */

.notice {
	margin: 0 0 1rem;
	padding: 0.6rem 0.9rem;
	background: var(--surface);
	border: 1px solid var(--border);
	border-left-width: 4px;
}

.notice p {
	margin: 0;
}

.move-reading {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	align-items: center;
	margin-top: 0.5rem;
}

.notice-success { border-left-color: var(--good-text); }
.notice-error { border-left-color: var(--danger); }
.notice-warning { border-left-color: #d28e05; }

/* Tabs */

.tabs {
	margin-bottom: 1.5rem;
}

.tabs nav {
	display: flex;
	flex-wrap: wrap;
	gap: 0.25rem;
	border-bottom: 1px solid var(--border);
}

.tabs nav a {
	padding: 0.4rem 0.8rem;
	margin-bottom: -1px;
	border: 1px solid var(--border);
	background: var(--stripe);
	color: var(--text-secondary);
	font-weight: 600;
	text-decoration: none;
}

.tabs nav a.active {
	background: var(--surface);
	border-bottom-color: var(--surface);
	color: var(--text);
}

.panel {
	padding: 1rem;
	background: var(--surface);
	border: 1px solid var(--border);
	border-top: 0;
	overflow-x: auto;
}

/* Forms */

.field {
	display: grid;
	grid-template-columns: 14rem 1fr;
	gap: 0.25rem 1rem;
	margin-bottom: 1rem;
}

.field > label,
.field > .label {
	font-weight: 600;
}

.field > :not(label):not(.label) {
	grid-column: 2;
}

@media (max-width: 40rem) {
	.field {
		grid-template-columns: 1fr;
	}

	.field > :not(label):not(.label) {
		grid-column: 1;
	}
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
select,
textarea {
	font: inherit;
	padding: 0.3rem 0.5rem;
	max-width: 100%;
	width: 20rem;
	color: var(--text);
	background: var(--surface);
	border: 1px solid var(--axis);
	border-radius: 4px;
}

select[multiple] {
	min-height: 8rem;
}

.description {
	margin: 0.25rem 0 0;
	color: var(--text-secondary);
	font-size: 0.9rem;
}

.radio {
	display: block;
	font-weight: 400;
}

button {
	font: inherit;
	padding: 0.35rem 0.9rem;
	color: var(--link);
	background: var(--surface);
	border: 1px solid var(--link);
	border-radius: 4px;
	cursor: pointer;
}

button.primary {
	color: var(--primary-text);
	background: var(--primary);
	border-color: var(--primary);
}

button.danger {
	color: var(--danger);
	border-color: var(--danger);
}

button.link {
	padding: 0;
	border: 0;
	background: none;
	text-decoration: underline;
}

hr {
	border: 0;
	border-top: 1px solid var(--border);
	margin: 1.5rem 0;
}

/* Tables */

.table-wrap {
	overflow-x: auto;
	background: var(--surface);
	border: 1px solid var(--border);
}

table {
	width: 100%;
	border-collapse: collapse;
}

th,
td {
	padding: 0.5rem 0.75rem;
	text-align: left;
	vertical-align: middle;
}

th {
	font-weight: 500;
	border-bottom: 1px solid var(--border);
}

td.number,
th.number {
	font-variant-numeric: tabular-nums;
}

td.date,
td button {
	white-space: nowrap;
}

tbody tr:nth-child(odd) {
	background: var(--stripe);
}

/* Separates parent meters from the meters below them. */
tbody tr.group-start td {
	border-top: 2px solid var(--axis);
}

.badge {
	display: inline-block;
	margin-left: 0.4rem;
	padding: 0 0.4rem;
	border: 1px solid var(--axis);
	border-radius: 999px;
	color: var(--text-secondary);
	font-size: 0.8rem;
	white-space: nowrap;
	cursor: help;
}

.badge.alert {
	border-color: #d28e05;
	color: var(--text);
}

.leaks ul {
	margin: 0.25rem 0 0;
	padding-left: 1.25rem;
}

.leaks p + p {
	margin-top: 0.4rem;
}

.row-actions {
	white-space: nowrap;
}

.row-actions form {
	display: inline-block;
	margin-left: 0.5rem;
}

.panel.standalone {
	border-top: 1px solid var(--border);
}

.less,
.more {
	margin-left: 0.5ex;
	white-space: nowrap;
	text-decoration: underline dotted;
	cursor: help;
}

.less { color: var(--good-text); }
.more { color: var(--bad-text); }

.pagination {
	display: flex;
	flex-wrap: wrap;
	gap: 0.75rem;
	align-items: center;
	margin: 0.75rem 0;
	color: var(--text-secondary);
}

.empty {
	color: var(--text-secondary);
}

/* Charts */

.chart {
	margin: 0;
}

.chart figcaption {
	font-weight: 600;
	margin-bottom: 0.5rem;
}

.chart-frame {
	position: relative;
}

.chart svg {
	display: block;
	width: 100%;
	height: auto;
	overflow: visible;
}

.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .axis { stroke: var(--axis); stroke-width: 1; }
.chart .crosshair { stroke: var(--axis); stroke-width: 1; }

/* The `hidden` attribute only hides HTML elements by default, not SVG ones. */
.chart [hidden] { display: none; }

.chart .tick {
	fill: var(--text-secondary);
	font-size: 12px;
	font-variant-numeric: tabular-nums;
}

.chart .end-label {
	fill: var(--text);
	font-size: 12px;
	font-weight: 600;
}

.chart .line {
	fill: none;
	stroke-width: 2;
	stroke-linejoin: round;
	stroke-linecap: round;
}

.chart .line.emphasized {
	stroke-width: 3;
}

.seq-0 { --series: var(--seq-0); }
.seq-1 { --series: var(--seq-1); }
.seq-2 { --series: var(--seq-2); }
.seq-3 { --series: var(--seq-3); }
.seq-4 { --series: var(--seq-4); }
.seq-5 { --series: var(--seq-5); }
.seq-6 { --series: var(--seq-6); }
.cat-1 { --series: var(--cat-1); }
.cat-2 { --series: var(--cat-2); }

.chart .line { stroke: var(--series); }
.chart .dot { fill: var(--series); }

.key {
	display: inline-block;
	width: 1rem;
	height: 0;
	border-top: 3px solid var(--series);
	vertical-align: middle;
	margin-right: 0.4rem;
}

.legend {
	display: flex;
	flex-wrap: wrap;
	gap: 0.25rem 1.25rem;
	justify-content: center;
	list-style: none;
	margin: 0.5rem 0 0;
	padding: 0;
	color: var(--text-secondary);
	font-size: 0.9rem;
}

.chart-tooltip {
	position: absolute;
	pointer-events: none;
	padding: 0.4rem 0.6rem;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: 4px;
	box-shadow: 0 2px 8px rgb(0 0 0 / 15%);
	font-size: 0.85rem;
	white-space: nowrap;
}

.chart-tooltip-heading {
	color: var(--text-secondary);
	margin-bottom: 0.15rem;
}

.chart-tooltip-row span:last-child {
	color: var(--text-secondary);
	margin-left: 0.4rem;
}

.balance-form {
	display: flex;
	flex-wrap: wrap;
	gap: 0.75rem 1.25rem;
	align-items: end;
}

.balance-form label {
	font-weight: 600;
}

.balance-form input {
	display: block;
	width: 11rem;
	font-weight: 400;
}

table.balance tr.part td:first-child {
	padding-left: 2rem;
}

table.balance tr.total td {
	font-weight: 600;
	border-bottom: 1px solid var(--border);
}

table.balance tbody tr {
	background: none;
}

h3:not(:first-child) {
	margin-top: 1.5rem;
}

.year-filter {
	display: flex;
	flex-wrap: wrap;
	gap: 0.4rem 1rem;
	align-items: center;
	margin-bottom: 1rem;
}

.year-filter label {
	white-space: nowrap;
}

/* Reading rounds: built for a phone held in one hand. */

.button-link {
	display: inline-block;
	padding: 0.35rem 0.9rem;
	color: var(--primary-text);
	background: var(--primary);
	border-radius: 4px;
	text-decoration: none;
}

.route-order input {
	width: 5rem;
}

.round {
	max-width: 34rem;
	margin: 0 auto;
}

.round-progress {
	position: sticky;
	top: 0;
	z-index: 1;
	display: flex;
	flex-wrap: wrap;
	gap: 0.25rem 1rem;
	justify-content: space-between;
	margin: 0 -1rem 1rem;
	padding: 0.6rem 1rem;
	background: var(--surface);
	border-bottom: 1px solid var(--border);
}

.round-date {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	align-items: center;
	margin-bottom: 1rem;
}

.round-date input {
	width: auto;
}

.stop {
	margin-bottom: 1rem;
	padding: 1rem;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: 6px;

	/* Leaves room for the sticky progress bar when a link jumps here. */
	scroll-margin-top: 4rem;
}

.stop h2 {
	margin: 0 0 0.5rem;
}

.stop p {
	margin: 0.25rem 0;
}

.stop .hardware {
	margin: 0 0 0.5rem;
}

.stop.done {
	border-left: 4px solid var(--good-text);
}

.stop-number {
	display: inline-block;
	min-width: 1.6em;
	padding: 0 0.3em;
	border-radius: 999px;
	background: var(--stripe);
	border: 1px solid var(--border);
	color: var(--text-secondary);
	font-size: 0.9em;
	text-align: center;
}

.stop label {
	display: block;
	margin-top: 0.75rem;
	font-weight: 600;
}

.stop-entry {
	display: flex;
	gap: 0.5rem;
}

/* 16px or larger stops phones from zooming in when the field is tapped. */
.stop-entry input {
	flex: 1;
	width: auto;
	min-width: 0;
	padding: 0.6rem;
	font-size: 1.25rem;
}

.stop-entry button {
	padding: 0.6rem 1.25rem;
	font-size: 1.1rem;
}

/* Reports and statements */

.page-links {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem 1.25rem;
	align-items: center;
}

table.report th,
table.report td {
	padding: 0.4rem 0.5rem;
	white-space: nowrap;
}

table.report tr.total td {
	font-weight: 600;
	border-top: 2px solid var(--axis);
}

.statement {
	max-width: 44rem;
	margin: 1.5rem 0;
	padding: 1.5rem;
	background: var(--surface);
	border: 1px solid var(--border);
}

.statement header h2 {
	margin-top: 0;
}

.statement-system {
	margin: 0;
	color: var(--text-secondary);
}

.statement-usage {
	font-size: 1.15rem;
}

.statement table {
	width: auto;
	margin-bottom: 0.5rem;
}

.statement th,
.statement td {
	padding: 0.3rem 0.75rem 0.3rem 0;
}

/* On paper: just the report, in black on white, one statement to a page. */
@media print {
	:root {
		color-scheme: light;
		--page: #fff;
		--surface: #fff;
		--text: #000;
		--text-secondary: #333;
		--link: #000;
		--stripe: #fff;
	}

	.site-header,
	.no-print,
	.notice-success {
		display: none;
	}

	main {
		max-width: none;
		padding: 0;
	}

	a {
		text-decoration: none;
	}

	.table-wrap {
		overflow: visible;
		border: 0;
	}

	table.report {
		font-size: 0.75rem;
	}

	.statement {
		max-width: none;
		margin: 0;
		padding: 0;
		border: 0;
		break-after: page;
	}
}
