/* Bookingsys Hub app. Ink-green on cool paper; status colours behave like ledger stamps. */

:root {
	--paper: #edf1f0;
	--surface: #ffffff;
	--ink: #15302d;
	--ink-2: #4f625f;
	--line: #d3dcda;
	--line-strong: #b5c3c0;
	--rail: #15302d;
	--rail-ink: #e4ecea;
	--rail-muted: #8ea5a1;
	--rail-hover: #1f3e3a;
	--accent: #2343c9;
	--accent-ink: #ffffff;
	--accent-soft: #e5e9fb;
	--paid: #1f7a4d;
	--due: #9a6210;
	--overdue: #b8322a;
	--void: #74817e;
	--shadow: 0 1px 0 rgba(21, 48, 45, .06), 0 8px 24px -12px rgba(21, 48, 45, .18);
	--r-s: 6px;
	--r-m: 10px;
	--font: "Schibsted Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
	color-scheme: light;
}

@media (prefers-color-scheme: dark) {
	:root {
		--paper: #0e1918;
		--surface: #152321;
		--ink: #e3ecea;
		--ink-2: #9aaeaa;
		--line: #243c38;
		--line-strong: #35534e;
		--rail: #091211;
		--rail-ink: #dfe9e7;
		--rail-muted: #7f9893;
		--rail-hover: #142624;
		--accent: #8aa0ff;
		--accent-ink: #0e1918;
		--accent-soft: #1b2650;
		--paid: #5cc48e;
		--due: #e2aa4c;
		--overdue: #f07b6f;
		--void: #8a9895;
		--shadow: 0 1px 0 rgba(0, 0, 0, .3), 0 10px 28px -14px rgba(0, 0, 0, .6);
		color-scheme: dark;
	}
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
	margin: 0;
	background: var(--paper);
	color: var(--ink);
	font: 400 15px/1.5 var(--font);
}
/* Fixed-width figures only where amounts line up in columns; elsewhere they look typewritten. */
.ledger .num { font-variant-numeric: tabular-nums; }
a { color: var(--accent); text-underline-offset: 2px; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
p { margin: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--ink-2); }
.small { font-size: .875rem; }
.booting { padding: 48px; color: var(--ink-2); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- buttons and fields ---------- */

.btn {
	display: inline-flex; align-items: center; justify-content: center; gap: 6px;
	min-height: 38px; padding: 0 14px;
	border: 1px solid var(--line-strong); border-radius: var(--r-s);
	background: var(--surface); color: var(--ink);
	font: 500 .9375rem/1 var(--font); text-decoration: none; cursor: pointer;
}
.btn:hover { border-color: var(--ink-2); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.08); border-color: var(--accent); }
.btn-quiet { border-color: transparent; background: none; color: var(--ink-2); padding: 0 8px; }
.btn-quiet:hover { color: var(--ink); border-color: transparent; }
.btn-small { min-height: 30px; padding: 0 10px; font-size: .875rem; }
.btn-block { width: 100%; }

label { display: block; font-weight: 500; font-size: .875rem; margin: 14px 0 6px; }
label.check { display: flex; align-items: center; gap: 8px; font-weight: 400; }
input[type="text"], input[type="password"], input[type="email"], input[type="date"], input[type="month"], select, textarea {
	width: 100%; min-height: 40px; padding: 8px 10px;
	border: 1px solid var(--line-strong); border-radius: var(--r-s);
	background: var(--surface); color: var(--ink);
	font: 400 .9375rem/1.4 var(--font);
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
.hint { margin-top: 4px; font-size: .8125rem; color: var(--ink-2); }
.alert { margin: 14px 0 0; padding: 10px 12px; border-left: 3px solid var(--overdue); background: color-mix(in srgb, var(--overdue) 10%, transparent); color: var(--ink); border-radius: 0 var(--r-s) var(--r-s) 0; }

/* ---------- status stamps ---------- */

.stamp {
	display: inline-block; padding: 1px 8px;
	border: 1.5px solid currentColor; border-radius: 4px;
	font-size: .8125rem; font-weight: 600; line-height: 1.5; white-space: nowrap;
}
.stamp.paid, .stamp.connected { color: var(--paid); }
.stamp.due, .stamp.pending { color: var(--due); }
.stamp.overdue, .stamp.disabled { color: var(--overdue); }
.stamp.overdue { transform: rotate(-2deg); }
.stamp.void { color: var(--void); }

/* ---------- sign-in ---------- */

.login { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); }
.login-single { grid-template-columns: 1fr; }
.login-month {
	background: var(--rail); color: var(--rail-ink);
	display: flex; flex-direction: column; justify-content: center;
	padding: clamp(32px, 6vw, 88px);
}
.month-name { font-size: clamp(1.75rem, 3.4vw, 2.75rem); font-weight: 600; letter-spacing: -.02em; margin-bottom: 28px; }
.month-grid {
	list-style: none; margin: 0; padding: 0;
	display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px;
	background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .08);
	max-width: 560px;
}
.month-grid li {
	aspect-ratio: 1 / .82; padding: 8px 10px;
	background: var(--rail); font-size: .9375rem;
}
.month-grid .dow { aspect-ratio: auto; padding: 8px 10px; color: var(--rail-muted); font-size: .8125rem; }
.month-grid .past { color: var(--rail-muted); }
.month-grid .today { background: var(--accent); color: #fff; font-weight: 700; }
.login-panel { display: flex; align-items: center; justify-content: center; padding: 32px 20px; }
.login-form { width: 100%; max-width: 360px; }
.wordmark { font-size: 1.75rem; font-weight: 700; letter-spacing: -.02em; margin-bottom: 6px; }
.login-form .btn-block { margin-top: 22px; min-height: 44px; }
.login-form .small { margin-top: 16px; }

@media (max-width: 760px) {
	.login { grid-template-columns: 1fr; }
	.login-month { display: none; }
}

/* ---------- app frame ---------- */

.frame { min-height: 100vh; display: grid; grid-template-columns: 236px minmax(0, 1fr); }
.rail {
	background: var(--rail); color: var(--rail-ink);
	padding: 24px 14px; display: flex; flex-direction: column; gap: 4px;
	position: sticky; top: 0; height: 100vh;
}
.rail .wordmark { font-size: 1.25rem; padding: 0 10px 22px; }
.rail a.nav {
	display: block; padding: 9px 10px; border-radius: var(--r-s);
	color: var(--rail-ink); text-decoration: none; font-weight: 500;
}
.rail a.nav:hover { background: var(--rail-hover); }
.rail a.nav[aria-current="page"] { background: var(--rail-hover); box-shadow: inset 3px 0 0 var(--accent); }
.rail .who { margin-top: auto; padding: 14px 10px 0; border-top: 1px solid rgba(255, 255, 255, .1); color: var(--rail-muted); font-size: .875rem; }
.rail .who a { color: var(--rail-ink); }

.main { padding: clamp(20px, 4vw, 44px); max-width: 1120px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head h1 { font-size: 1.75rem; font-weight: 700; letter-spacing: -.015em; }
.back { display: inline-block; margin-bottom: 10px; color: var(--ink-2); text-decoration: none; font-size: .875rem; }
.back:hover { color: var(--ink); }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m); box-shadow: var(--shadow); }
.panel-pad { padding: 20px 22px; }
.section { margin-top: 32px; }
.section > h2 { font-size: 1.0625rem; font-weight: 600; margin-bottom: 12px; }
.empty { padding: 28px 22px; color: var(--ink-2); }
.empty .btn { margin-top: 12px; }

@media (max-width: 820px) {
	.frame { grid-template-columns: 1fr; }
	.rail { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 12px; gap: 2px; }
	.rail .wordmark { padding: 0 8px 0 4px; margin-right: auto; }
	.rail .who { margin: 0; padding: 0 0 0 8px; border: 0; }
	.rail .who span { display: none; }
}

/* ---------- overview ---------- */

.summary { font-size: clamp(1.5rem, 3.2vw, 2.25rem); font-weight: 500; letter-spacing: -.02em; line-height: 1.25; max-width: 30ch; }
.summary strong { font-weight: 700; }
.summary .late { color: var(--overdue); font-weight: 700; }
.issue { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 18px 24px; align-items: end; }
.issue .fields { display: flex; gap: 12px; flex-wrap: wrap; }
.issue .fields > div { min-width: 170px; }
.issue .fields label { margin-top: 0; }
.progress { font-size: .9375rem; }
.progress strong { font-weight: 700; }
@media (max-width: 640px) { .issue { grid-template-columns: 1fr; } }

/* ---------- ledgers ---------- */

.table-wrap { overflow-x: auto; }
table.ledger { width: 100%; border-collapse: collapse; }
.ledger th {
	text-align: left; font-size: .8125rem; font-weight: 500; color: var(--ink-2);
	padding: 12px 16px; border-bottom: 1px solid var(--line);
}
.ledger td { padding: 13px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.ledger tr:last-child td { border-bottom: 0; }
.ledger .num { text-align: right; white-space: nowrap; }
.ledger .actions { text-align: right; white-space: nowrap; }
.ledger .actions .btn + .btn { margin-left: 6px; }
.ledger tbody tr.link { cursor: pointer; }
.ledger tbody tr.link:hover td { background: color-mix(in srgb, var(--accent) 4%, transparent); }
.ledger .row-title { all: unset; cursor: pointer; font-weight: 600; color: var(--ink); }
.ledger .row-title:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ledger .sub { display: block; font-size: .8125rem; color: var(--ink-2); }
.ledger .owed { font-weight: 700; }
.ledger .owed.late { color: var(--overdue); }

@media (max-width: 680px) {
	.ledger thead { display: none; }
	.ledger, .ledger tbody, .ledger tr, .ledger td { display: block; }
	.ledger tr { padding: 12px 16px; border-bottom: 1px solid var(--line); }
	.ledger tr:last-child { border-bottom: 0; }
	.ledger td { padding: 2px 0; border: 0; }
	.ledger td[data-label]::before { content: attr(data-label) ": "; color: var(--ink-2); font-size: .8125rem; }
	.ledger .num, .ledger .actions { text-align: left; }
	.ledger .actions { padding-top: 10px; }
}

/* ---------- client details ---------- */

.client-head .meta { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-top: 8px; color: var(--ink-2); }
.client-head .buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 18px 24px; margin: 0; }
.facts dt { font-size: .8125rem; color: var(--ink-2); }
.facts dd { margin: 2px 0 0; font-weight: 500; }
.facts .wide { grid-column: 1 / -1; }
.facts .wide dd { font-weight: 400; white-space: pre-line; max-width: 70ch; }
.balance-bar { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 12px; }
.balance-bar .amount { font-size: 1.375rem; font-weight: 700; letter-spacing: -.01em; }
.balance-bar .amount.late { color: var(--overdue); }

/* ---------- dialogs and toasts ---------- */

dialog {
	width: min(520px, calc(100vw - 32px)); padding: 0;
	border: 1px solid var(--line); border-radius: var(--r-m);
	background: var(--surface); color: var(--ink); box-shadow: 0 24px 64px -20px rgba(0, 0, 0, .45);
}
dialog::backdrop { background: rgba(9, 18, 17, .45); }
dialog form, dialog .dialog-body { padding: 22px; }
dialog h2 { font-size: 1.25rem; font-weight: 700; }
dialog .row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
dialog .foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; }
@media (max-width: 480px) { dialog .row { grid-template-columns: 1fr; } }

.code-box { margin-top: 14px; padding: 12px; border: 1px dashed var(--line-strong); border-radius: var(--r-s); word-break: break-all; font-size: .875rem; background: var(--paper); }
.steps { margin: 14px 0 0; padding-left: 20px; }
.steps li { margin: 4px 0; }

.toast {
	position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
	padding: 10px 16px; border-radius: var(--r-s);
	background: var(--ink); color: var(--paper); font-weight: 500; box-shadow: var(--shadow);
	z-index: 50;
}
.toast.error { background: var(--overdue); color: #fff; }

@media (prefers-reduced-motion: no-preference) {
	dialog[open] { animation: rise .16s ease-out; }
	@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
}

/* ---------- owner logins ---------- */

.section-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 4px; }
.section-head h2 { font-size: 1.0625rem; font-weight: 600; }
.btn-quiet.danger { color: var(--overdue); }
.hub-log { padding: 12px 16px; border-top: 1px solid var(--line); font-size: .875rem; }
.hub-log summary { cursor: pointer; color: var(--ink-2); }
.hub-log ul { margin: 10px 0 0; padding-left: 18px; }
.hub-log li { margin: 3px 0; }

/* ---------- access, attention, activity ---------- */

:root { --chart: #2343c9; }
@media (prefers-color-scheme: dark) { :root { --chart: #7088ee; } }

.stamp.active { color: var(--paid); }
.stamp.warning { color: var(--due); }
.stamp.suspended { color: var(--overdue); transform: rotate(-2deg); }
.nav-count { margin-left: 8px; padding: 0 7px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-size: .75rem; font-weight: 700; }
.activity-line { margin-top: 10px; font-size: 1.0625rem; color: var(--ink-2); }
.activity-line strong { color: var(--ink); }
.attention { list-style: none; margin: 0; padding: 6px 0; }
.attention li { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 18px; border-bottom: 1px solid var(--line); }
.attention li:last-child { border-bottom: 0; }
.access { display: flex; justify-content: space-between; align-items: center; gap: 14px 24px; flex-wrap: wrap; }
.access.warning { border-left: 4px solid var(--due); }
.access.suspended { border-left: 4px solid var(--overdue); }
.access .buttons, .reply-foot { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; }
.reply-foot { justify-content: space-between; margin-top: 4px; }
.reply-foot > div { min-width: 220px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--r-m); overflow: hidden; }
.tile { background: var(--surface); padding: 14px 16px; }
.tile-value { font-size: 1.5rem; font-weight: 700; letter-spacing: -.01em; margin: 2px 0; font-variant-numeric: tabular-nums; }

.chart { margin: 12px 0 0; }
.chart figcaption { font-weight: 600; margin-bottom: 14px; }
.bars { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 2px; height: 180px; align-items: end; border-bottom: 1px solid var(--line-strong); }
.bar-col { position: relative; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; outline: none; }
.bar { width: min(44px, 70%); background: var(--chart); border-radius: 4px 4px 0 0; }
.bar-val { font-size: .8125rem; font-weight: 600; margin-bottom: 4px; min-height: 1.2em; font-variant-numeric: tabular-nums; }
.bar-x { position: absolute; bottom: -24px; font-size: .8125rem; color: var(--ink-2); }
.bars + * { margin-top: 30px; }
.chart .bars { margin-bottom: 26px; }
.bar-col:hover .bar, .bar-col:focus-visible .bar { filter: brightness(1.15); }
.bar-col:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); border-radius: 4px; }
.bar-col:hover::after, .bar-col:focus-visible::after {
	content: attr(data-tip); position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%);
	padding: 6px 10px; border-radius: var(--r-s); background: var(--ink); color: var(--paper);
	font-size: .8125rem; white-space: nowrap; z-index: 5; pointer-events: none;
}
.bar-col:first-child:hover::after, .bar-col:first-child:focus-visible::after { left: 0; transform: none; }
.bar-col:last-child:hover::after, .bar-col:last-child:focus-visible::after { left: auto; right: 0; transform: none; }

/* ---------- support thread ---------- */

.ledger tr.unread td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.ledger .sub.new { color: var(--accent); font-weight: 600; }
.thread { list-style: none; margin: 0 0 18px; padding: 0; display: grid; gap: 12px; }
.msg { max-width: min(680px, 90%); padding: 12px 16px; border-radius: var(--r-m); border: 1px solid var(--line); background: var(--surface); }
.msg.mine { justify-self: end; background: var(--accent-soft); border-color: transparent; }
.msg-meta { font-size: .875rem; margin-bottom: 4px; }
.msg-body { white-space: pre-line; overflow-wrap: anywhere; }
@media (max-width: 640px) { .msg { max-width: 100%; } }
