/* Billing Panel — the whole look of the panel lives in this one file. */

:root {
	--ink:        #1c2128;
	--ink-soft:   #57606a;
	--ink-faint:  #8b949e;
	--line:       #d8dee4;
	--line-soft:  #eaeef2;
	--page:       #f6f8fa;
	--card:       #ffffff;

	--brand:      #1f4e8c;
	--brand-dark: #163a69;
	--brand-soft: #eaf1fa;

	--ok:         #1a7f45;
	--ok-soft:    #e6f4ec;
	--warn:       #8a5700;
	--warn-soft:  #fdf3dd;
	--bad:        #b42318;
	--bad-soft:   #fdeceb;
	--info:       #1f4e8c;
	--info-soft:  #eaf1fa;

	--radius:     6px;
	--shadow:     0 1px 2px rgba(27, 31, 36, .07);
	--mono:       ui-monospace, "Cascadia Mono", "Consolas", monospace;
}

* { box-sizing: border-box; }

html, body {
	margin: 0;
	padding: 0;
}

body {
	font: 14px/1.5 -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	color: var(--ink);
	background: var(--page);
	-webkit-font-smoothing: antialiased;
}

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

h1, h2, h3 { margin: 0 0 .5rem; font-weight: 600; line-height: 1.3; }
h1 { font-size: 20px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }

p { margin: 0 0 .75rem; }

code, .mono, .num { font-family: var(--mono); font-size: 13px; }

/* ---------- layout ---------- */

.shell { display: flex; min-height: 100vh; }

.side {
	width: 220px;
	flex: 0 0 220px;
	background: #11253f;
	color: #c9d6e5;
	display: flex;
	flex-direction: column;
}

.side-brand {
	padding: 16px 18px;
	font-weight: 600;
	font-size: 15px;
	color: #fff;
	border-bottom: 1px solid rgba(255, 255, 255, .09);
}
.side-brand small {
	display: block;
	font-weight: 400;
	font-size: 11px;
	color: #7f93ad;
	margin-top: 2px;
}

.side nav { padding: 10px 0; flex: 1; overflow-y: auto; }

.side-group {
	padding: 14px 18px 5px;
	font-size: 10px;
	letter-spacing: .08em;
	text-transform: uppercase;
	color: #6c819c;
}

.side a {
	display: block;
	padding: 7px 18px;
	color: #c9d6e5;
	font-size: 13px;
	border-left: 3px solid transparent;
}
.side a:hover { background: rgba(255, 255, 255, .05); color: #fff; text-decoration: none; }
.side a.on {
	background: rgba(255, 255, 255, .08);
	border-left-color: #6ea8ff;
	color: #fff;
	font-weight: 500;
}

.side-foot {
	padding: 12px 18px;
	border-top: 1px solid rgba(255, 255, 255, .09);
	font-size: 12px;
}
.side-foot .who { color: #fff; font-weight: 500; }
.side-foot .role { color: #7f93ad; font-size: 11px; }
.side-foot a { padding: 6px 0 0; border: 0; color: #9fb4cd; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
	background: var(--card);
	border-bottom: 1px solid var(--line);
	padding: 12px 22px;
	display: flex;
	align-items: center;
	gap: 14px;
}
.topbar h1 { margin: 0; }
.topbar .spacer { flex: 1; }

.content { padding: 22px; flex: 1; }
.content > :last-child { margin-bottom: 0; }

/* ---------- cards ---------- */

.card {
	background: var(--card);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	box-shadow: var(--shadow);
	margin-bottom: 18px;
}
.card-head {
	padding: 12px 16px;
	border-bottom: 1px solid var(--line-soft);
	display: flex;
	align-items: center;
	gap: 12px;
}
.card-head h2, .card-head h3 { margin: 0; }
.card-head .spacer { flex: 1; }
.card-body { padding: 16px; }
.card-body > :last-child { margin-bottom: 0; }
.card-foot {
	padding: 12px 16px;
	border-top: 1px solid var(--line-soft);
	background: #fbfcfd;
	border-radius: 0 0 var(--radius) var(--radius);
	display: flex;
	gap: 8px;
	align-items: center;
}

/* ---------- grid ---------- */

.row { display: flex; flex-wrap: wrap; gap: 18px; }
.row > * { flex: 1 1 0; min-width: 220px; }
.row.tight { gap: 12px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat {
	background: var(--card);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	padding: 14px 16px;
	box-shadow: var(--shadow);
}
.stat .label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-faint); }
.stat .value { font-size: 22px; font-weight: 600; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .hint { font-size: 12px; color: var(--ink-soft); margin-top: 2px; }
.stat.bad .value { color: var(--bad); }
.stat.warn .value { color: var(--warn); }
.stat.ok .value { color: var(--ok); }

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

table.list { width: 100%; border-collapse: collapse; }
table.list th, table.list td {
	padding: 9px 12px;
	text-align: left;
	border-bottom: 1px solid var(--line-soft);
	vertical-align: top;
}
table.list th {
	font-size: 11px;
	text-transform: uppercase;
	letter-spacing: .05em;
	color: var(--ink-soft);
	background: #fbfcfd;
	font-weight: 600;
	white-space: nowrap;
}
table.list tbody tr:hover { background: #fbfcfd; }
table.list tbody tr:last-child td { border-bottom: 0; }
table.list td.right, table.list th.right { text-align: right; }
table.list td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
table.list td.tight, table.list th.tight { white-space: nowrap; }
table.list tfoot td {
	font-weight: 600;
	background: #fbfcfd;
	border-top: 2px solid var(--line);
	border-bottom: 0;
}

.scroll-x { overflow-x: auto; }

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

.field { margin-bottom: 14px; }
.field label {
	display: block;
	font-size: 12px;
	font-weight: 600;
	color: var(--ink);
	margin-bottom: 4px;
}
.field .help { font-size: 12px; color: var(--ink-soft); margin-top: 4px; }
.field .help-before { font-size: 12px; color: var(--ink-soft); margin: -2px 0 5px; }

input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=month], input[type=search], select, textarea {
	width: 100%;
	padding: 7px 10px;
	font: inherit;
	color: var(--ink);
	background: #fff;
	border: 1px solid var(--line);
	border-radius: var(--radius);
}
input:focus, select:focus, textarea:focus {
	outline: 0;
	border-color: var(--brand);
	box-shadow: 0 0 0 3px var(--brand-soft);
}
input[readonly], input:disabled, select:disabled, textarea[readonly] {
	background: var(--page);
	color: var(--ink-soft);
}
textarea { min-height: 76px; resize: vertical; }
input.money, input.num { font-family: var(--mono); text-align: right; }

.check { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 10px; }
.check input { margin-top: 3px; }
.check label { font-weight: 400; font-size: 13px; margin: 0; }

fieldset {
	border: 1px solid var(--line);
	border-radius: var(--radius);
	padding: 14px 16px;
	margin: 0 0 18px;
}
legend { font-size: 12px; font-weight: 600; padding: 0 6px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .05em; }

.filters {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	align-items: flex-end;
}
.filters .field { margin: 0; min-width: 130px; }

/* ---------- buttons ---------- */

.btn {
	display: inline-block;
	padding: 7px 14px;
	font: inherit;
	font-weight: 500;
	line-height: 1.4;
	color: var(--ink);
	background: #fff;
	border: 1px solid var(--line);
	border-radius: var(--radius);
	cursor: pointer;
	text-decoration: none;
	white-space: nowrap;
}
.btn:hover { background: var(--page); text-decoration: none; }
.btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }

.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }

.btn-danger { background: #fff; border-color: #e9b8b4; color: var(--bad); }
.btn-danger:hover { background: var(--bad-soft); }

.btn-small { padding: 4px 9px; font-size: 12px; }
.btn[disabled], .btn.off { opacity: .5; pointer-events: none; }

.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- messages ---------- */

.msg {
	padding: 11px 14px;
	border-radius: var(--radius);
	border: 1px solid;
	margin-bottom: 16px;
	font-size: 13px;
}
.msg-ok   { background: var(--ok-soft);   border-color: #b7dfc6; color: #11542f; }
.msg-warn { background: var(--warn-soft); border-color: #ecd9a4; color: #6b4400; }
.msg-bad  { background: var(--bad-soft);  border-color: #efc0bc; color: #8c1b12; }
.msg-info { background: var(--info-soft); border-color: #bdd4ee; color: #16365f; }
.msg p:last-child { margin-bottom: 0; }
.msg ul { margin: .4rem 0 0; padding-left: 1.2rem; }

/* ---------- pills ---------- */

.pill {
	display: inline-block;
	padding: 2px 8px;
	border-radius: 999px;
	font-size: 11px;
	font-weight: 600;
	line-height: 1.6;
	white-space: nowrap;
}
.pill-ok   { background: var(--ok-soft);   color: #11542f; }
.pill-warn { background: var(--warn-soft); color: #6b4400; }
.pill-bad  { background: var(--bad-soft);  color: #8c1b12; }
.pill-info { background: var(--info-soft); color: #16365f; }
.pill-mute { background: var(--line-soft); color: var(--ink-soft); }

/* ---------- misc ---------- */

.muted { color: var(--ink-soft); }
.faint { color: var(--ink-faint); }
.small { font-size: 12px; }
.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.mt0 { margin-top: 0; }
.mb0 { margin-bottom: 0; }

.empty {
	padding: 40px 20px;
	text-align: center;
	color: var(--ink-soft);
}
.empty h3 { color: var(--ink); }
.empty p { max-width: 420px; margin: 0 auto .9rem; }

.crumb { font-size: 12px; color: var(--ink-soft); margin-bottom: 10px; }
.crumb a { color: var(--ink-soft); }

.pager { display: flex; gap: 6px; align-items: center; padding: 12px 16px; border-top: 1px solid var(--line-soft); }
.pager .spacer { flex: 1; }

.secret-box {
	font-family: var(--mono);
	font-size: 13px;
	background: #11253f;
	color: #cfe2ff;
	padding: 11px 13px;
	border-radius: var(--radius);
	word-break: break-all;
	user-select: all;
}

dl.facts { margin: 0; display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; }
dl.facts dt { font-size: 12px; color: var(--ink-soft); }
dl.facts dd { margin: 0; }

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

.signin-page {
	min-height: 100vh;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 20px;
	background: #11253f;
}
.signin {
	width: 100%;
	max-width: 360px;
	background: var(--card);
	border-radius: 8px;
	padding: 26px;
	box-shadow: 0 10px 30px rgba(0, 0, 0, .25);
}
.signin h1 { text-align: center; margin-bottom: 4px; }
.signin .sub { text-align: center; color: var(--ink-soft); font-size: 13px; margin-bottom: 20px; }

/* ---------- setup / migrate page ---------- */

.plain-page { max-width: 880px; margin: 0 auto; padding: 30px 20px 60px; }
.plain-page .logo { font-size: 13px; color: var(--ink-faint); margin-bottom: 18px; }

.check-list { list-style: none; margin: 0; padding: 0; }
.check-list li {
	padding: 7px 0;
	border-bottom: 1px solid var(--line-soft);
	display: flex;
	gap: 10px;
	font-size: 13px;
}
.check-list li:last-child { border-bottom: 0; }
.check-list .what { flex: 1; }
.check-list .tbl { font-family: var(--mono); font-size: 12px; color: var(--brand); min-width: 150px; }

/* ---------- print ---------- */

@media print {
	.side, .topbar, .no-print, .card-foot { display: none !important; }
	body { background: #fff; }
	.content { padding: 0; }
	.card { border: 0; box-shadow: none; margin: 0; }
}

/* ---------- narrow screens ---------- */

@media (max-width: 860px) {
	.shell { flex-direction: column; }
	.side { width: auto; flex: none; }
	.side nav { display: flex; flex-wrap: wrap; padding: 6px; }
	.side-group { display: none; }
	.side a { border-left: 0; border-radius: var(--radius); padding: 6px 11px; }
	.side a.on { border-left: 0; }
	.content { padding: 14px; }
	.topbar { padding: 11px 14px; }
}
