/* IOU. One family (IBM Plex Sans), one action colour, status as the only other
   colour on the page. Sections are separated by rules, not stacked in cards. */

:root {
	--paper: #f4f3ef;
	--surface: #ffffff;
	--ink: #1c2024;
	--muted: #6b7178;
	--rule: #dcdad3;
	--rule-soft: #ebe9e3;
	--graphite: #23282c;
	--graphite-text: #c9cdd2;
	--accent: #1d4ed8;
	--accent-ink: #ffffff;
	--danger: #b42318;
	--focus: #93c5fd;
	--pill: #e8e6df;
	--pill-ink: #3b4148;
	--sidebar: 224px;
}

* { box-sizing: border-box; }

html { font-size: 14px; }

body {
	margin: 0;
	background: var(--paper);
	color: var(--ink);
	font-family: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
	line-height: 1.5;
	font-variant-numeric: tabular-nums;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 22px; font-weight: 600; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 15px; font-weight: 600; margin: 0 0 10px; }
h2 a { font-weight: 400; margin-left: 8px; }
h2.later { margin-top: 18px; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }
.num { text-align: right; }
.push { margin-left: auto; }
.sep::before { content: "\00a0\00b7\00a0"; }

/* ---- shell ------------------------------------------------------------- */

body.app { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }

.sidebar {
	background: var(--graphite);
	color: var(--graphite-text);
	display: flex;
	flex-direction: column;
	padding: 20px 16px;
	position: sticky;
	top: 0;
	height: 100vh;
}
.sidebar .brand { margin-bottom: 18px; }
.sidebar .brand a { color: #fff; font-weight: 600; font-size: 18px; letter-spacing: 0.08em; }
.sidebar .brand span { display: block; font-size: 12px; color: var(--graphite-text); margin-top: 2px; }
.sidebar .find input {
	width: 100%;
	background: #2e3438;
	border: 1px solid #3a4146;
	color: #fff;
	border-radius: 6px;
	padding: 8px 10px;
	font: inherit;
}
.sidebar .find input::placeholder { color: #8d949b; }
.sidebar nav { display: flex; flex-direction: column; margin-top: 18px; gap: 2px; }
.sidebar nav a {
	color: var(--graphite-text);
	padding: 7px 10px;
	border-radius: 6px;
}
.sidebar nav a:hover { background: #2e3438; text-decoration: none; color: #fff; }
.sidebar nav a[aria-current="page"] { background: #fff; color: var(--ink); font-weight: 500; }
.sidebar .who { margin-top: auto; font-size: 13px; }
.sidebar .who span { display: block; color: #fff; }
.sidebar .who small { display: block; color: var(--graphite-text); font-size: 12px; }
.sidebar .who form { margin-top: 6px; }
.sidebar .who .link { color: var(--graphite-text); padding: 0; }

main { padding: 28px 36px 40px; max-width: 1140px; min-width: 0; }
body.gate main { max-width: 440px; margin: 48px auto; padding: 0 16px; }
footer { margin-top: 48px; color: var(--muted); font-size: 12px; }

section { padding: 18px 0; border-top: 1px solid var(--rule); }
section:first-of-type, .columns section:first-child { border-top: 0; padding-top: 0; }
.columns { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 0 40px; }
.columns > div > section:first-child { border-top: 0; padding-top: 0; }

.page-head { display: flex; align-items: baseline; gap: 16px; margin-bottom: 18px; }
.page-head .actions, .toolbar { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.toolbar { margin: 0 0 22px; }
.filter { margin: -8px 0 12px; }
.empty { color: var(--muted); padding: 14px 0; }

/* ---- the record header ------------------------------------------------- */

.record-head {
	display: grid;
	grid-template-columns: auto 1fr auto;
	gap: 0 24px;
	align-items: center;
	margin-bottom: 14px;
}
.stamp { display: flex; flex-direction: column; line-height: 1; }
.stamp .kind { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.stamp .number { font-size: 34px; font-weight: 600; letter-spacing: 0.04em; }
.record-head .titles h1 { font-size: 20px; }
.record-head .titles p { margin: 2px 0 0; }
.record-head .status { display: flex; flex-direction: column; gap: 4px; }
.record-head .status label { font-size: 12px; color: var(--muted); }
.record-head .status select { font-weight: 500; min-width: 220px; }

/* ---- tables ------------------------------------------------------------ */

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; padding: 0 10px 6px 0; border-bottom: 1px solid var(--rule); }
td { padding: 8px 10px 8px 0; border-bottom: 1px solid var(--rule-soft); vertical-align: top; }
th.num, td.num { text-align: right; }
th.tick, td.tick { width: 70px; text-align: center; padding-right: 0; }
tbody tr:last-child td { border-bottom: 0; }
table.list td a { color: inherit; }
table.list td a:hover { color: var(--accent); }
tfoot td { border-bottom: 0; padding: 4px 10px 4px 0; text-align: right; color: var(--muted); }
tfoot tr.total td { color: var(--ink); font-weight: 600; border-top: 1px solid var(--rule); padding-top: 8px; }
tfoot tr:first-child td { padding-top: 10px; }

.pill {
	display: inline-block;
	padding: 2px 9px;
	border-radius: 999px;
	background: var(--pill);
	color: var(--pill-ink);
	font-size: 12px;
	font-weight: 500;
	white-space: nowrap;
}

.sites { list-style: none; margin: 0; padding: 0; }
.sites li { padding: 4px 0; }

.facts { display: grid; grid-template-columns: 110px 1fr; gap: 6px 12px; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; white-space: pre-line; }

.history { list-style: none; margin: 0; padding: 0; }
.history li { display: grid; grid-template-columns: 130px 1fr; gap: 10px; padding: 5px 0; font-size: 13px; }
.history .when { color: var(--muted); }

.accept { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.accept label { display: flex; align-items: center; gap: 8px; margin: 0; }
.accept input { width: auto; }
.prose { white-space: pre-line; margin: 0; }

/* ---- forms ------------------------------------------------------------- */

label { display: block; margin-bottom: 12px; font-size: 13px; color: var(--muted); }
label input, label select, label textarea { display: block; margin-top: 4px; width: 100%; }
input, select, textarea {
	font: inherit;
	color: var(--ink);
	background: var(--surface);
	border: 1px solid var(--rule);
	border-radius: 6px;
	padding: 7px 9px;
	max-width: 100%;
}
input[type=checkbox] { width: auto; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible {
	outline: 2px solid var(--focus);
	outline-offset: 1px;
}
.hint { display: block; font-size: 12px; color: var(--muted); margin-top: 4px; }

.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 24px; }
.grid .wide { grid-column: 1 / -1; }
.narrow { max-width: 520px; }
.record-form textarea { width: 100%; }
table.rows td { padding: 4px 8px 4px 0; border-bottom: 0; }
table.rows input, table.rows select { width: 100%; }
table.rows .qty { width: 64px; text-align: right; }
table.rows .amount { width: 120px; text-align: right; }
table.rows th.num { text-align: right; }
table.rows + button { margin-top: 8px; }

form.inline { display: flex; flex-wrap: wrap; gap: 0 12px; align-items: end; margin-top: 12px; }
form.inline label { flex: 1 1 140px; }
form.inline button { margin-bottom: 12px; }
form.search { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; }
form.search input { flex: 1; }

.actions { display: flex; align-items: center; gap: 14px; }
form .actions { margin-top: 8px; }

button, .button {
	display: inline-block;
	font: inherit;
	font-weight: 500;
	background: var(--accent);
	color: var(--accent-ink);
	border: 1px solid transparent;
	border-radius: 6px;
	padding: 7px 14px;
	cursor: pointer;
	line-height: 1.4;
}
.button:hover { text-decoration: none; filter: brightness(1.08); }
button.secondary, .button.secondary { background: var(--surface); color: var(--ink); border-color: var(--rule); }
button.small, .button.small { padding: 4px 10px; font-size: 13px; }
button.link { background: none; border: 0; color: var(--accent); padding: 0; font-weight: 400; }
button.link.danger { color: var(--danger); }
button:disabled { opacity: .5; cursor: progress; }
form:has(> button.link) { display: inline; }

.flash { padding: 9px 12px; border-radius: 6px; background: #e6efff; color: #1e3a8a; margin: 0 0 16px; }
.flash.error { background: #fde8e6; color: var(--danger); }

/* ---- the sign-in pages ------------------------------------------------- */

body.gate .panel { background: var(--surface); border: 1px solid var(--rule); border-radius: 10px; padding: 24px; }
body.gate h2 { font-size: 20px; margin-bottom: 14px; }
.lede { color: var(--muted); margin: 0 0 16px; }

@media (max-width: 800px) {
	body.app { grid-template-columns: 1fr; }
	.sidebar { position: static; height: auto; }
	main { padding: 20px 16px; }
	.columns, .grid { grid-template-columns: 1fr; }
	.record-head { grid-template-columns: 1fr; gap: 10px; }
	.history li { grid-template-columns: 1fr; gap: 0; }
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---- settings tabs ----------------------------------------------------- */

nav.tabs { display: flex; gap: 4px; margin-left: 24px; }
nav.tabs a { padding: 4px 10px; border-radius: 6px; color: var(--muted); }
nav.tabs a[aria-current="page"] { background: var(--surface); color: var(--ink); border: 1px solid var(--rule); }
select.small { width: auto; padding: 4px 8px; font-size: 13px; }
.or { text-align: center; color: var(--muted); margin: 12px 0; }
.button.wide { display: block; text-align: center; }
code { font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: 12px; background: var(--rule-soft); padding: 1px 5px; border-radius: 4px; }
.pill.final { background: #dcefe3; color: #14532d; }
.tick { color: #14532d; }
.doc-actions { margin-top: 12px; flex-wrap: wrap; }
form.upload { display: flex; gap: 8px; align-items: center; }
form.upload input[type=file] { max-width: 220px; }
form.upload select { width: auto; }
td.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.attach { list-style: none; margin: 0 0 10px; padding: 0; }
.attach li { padding: 4px 0; }
label.check { display: flex; align-items: center; gap: 8px; color: var(--ink); margin: 0; }
label.check input { margin: 0; }
.compose textarea { width: 100%; }
