/* ButeTec portal. Compact operations UI: flat surfaces, hairline rules, tabular figures. */
/* ButeTec brand: #9B005C with black, white and greys. */
:root {
	--bg: #f4f4f4; --surface: #ffffff; --sunk: #efefef; --ink: #141414; --muted: #666666;
	--line: #dedede; --line-strong: #bdbdbd; --accent: #9B005C; --accent-ink: #ffffff; --link: #9B005C;
	--side: #ffffff; --side-ink: #2a2a2a; --side-muted: #7a7a7a; --side-on: #9B005C; --side-strong: #000000;
	--side-line: #e4e4e4; --side-hover: #f4f4f4; --side-active: #f7ecf2;
	--ok: #2c7a3b; --warn: #a86a09; --bad: #b3261e; --off: #8f8f8f; --row-hover: #f8f8f8;
	color-scheme: light;
}
@media (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) {
		--bg: #0f0f10; --surface: #18181a; --sunk: #131314; --ink: #e8e8e8; --muted: #9a9a9a;
	--line: #2a2a2c; --line-strong: #404044; --accent: #9B005C; --accent-ink: #ffffff; --link: #e070ad;
	--side: #0a0a0b; --side-ink: #d0d0d0; --side-muted: #7d7d7d; --side-on: #9B005C; --side-strong: #ffffff;
	--side-line: #232325; --side-hover: #161617; --side-active: #1e0f17;
	--ok: #5cbf6d; --warn: #e0a43a; --bad: #ef6b60; --off: #757575; --row-hover: #1f1f21;
		color-scheme: dark;
	}
}
:root[data-theme="dark"] {
	--bg: #0f0f10; --surface: #18181a; --sunk: #131314; --ink: #e8e8e8; --muted: #9a9a9a;
	--line: #2a2a2c; --line-strong: #404044; --accent: #9B005C; --accent-ink: #ffffff; --link: #e070ad;
	--side: #0a0a0b; --side-ink: #d0d0d0; --side-muted: #7d7d7d; --side-on: #9B005C; --side-strong: #ffffff;
	--side-line: #232325; --side-hover: #161617; --side-active: #1e0f17;
	--ok: #5cbf6d; --warn: #e0a43a; --bad: #ef6b60; --off: #757575; --row-hover: #1f1f21;
	color-scheme: dark;
}

/* the supplied logos: light version on light theme, dark version on dark theme */
.logo-dark { display: none; }
@media (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) .logo-light { display: none; }
	:root:not([data-theme="light"]) .logo-dark { display: block; }
}
:root[data-theme="dark"] .logo-light { display: none; }
:root[data-theme="dark"] .logo-dark { display: block; }

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
	background: var(--bg); color: var(--ink);
	font: 13px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	-webkit-font-smoothing: antialiased;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
.num, td.n, .mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-variant-numeric: tabular-nums; font-size: 12.5px; }

.shell { display: grid; grid-template-columns: 208px 1fr; min-height: 100vh; }

/* sidebar */
.side { border-right: 1px solid var(--side-line); background: var(--side); color: var(--side-ink); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 14px 16px 10px; border-bottom: 1px solid var(--side-line); }
.brand:hover { text-decoration: none; }
.brand img { width: 118px; height: auto; }
.brand small { font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--side-muted); }
.side nav { padding: 6px 0 12px; flex: 1; }
.nav-group { font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; color: var(--side-muted); padding: 14px 16px 4px; }
.side nav a { display: block; padding: 5px 16px 5px 13px; color: var(--side-ink); border-left: 3px solid transparent; }
.side nav a:hover { background: var(--side-hover); text-decoration: none; color: var(--side-strong); }
.side nav a.on { border-left-color: var(--side-on); color: var(--side-strong); background: var(--side-active); font-weight: 600; }
.side-foot { padding: 10px 16px 14px; border-top: 1px solid var(--side-line); font-size: 11.5px; display: flex; flex-direction: column; gap: 4px; color: var(--side-muted); }
.side-foot a { color: var(--side-ink); }

/* top bar */
main { min-width: 0; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 20px; height: 48px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 2; }
.top h1 { font-size: 15px; margin: 0; font-weight: 650; }
.top-right { display: flex; align-items: center; gap: 12px; font-size: 12.5px; }
.switch { display: flex; align-items: center; gap: 6px; }
.switch label { color: var(--muted); }
select, input[type=search], input[type=text], input[type=date] {
	font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong);
	border-radius: 3px; padding: 3px 6px; height: 27px;
}
.cust { font-weight: 600; }
.who { color: var(--muted); }
button.theme, .btn, button.btn {
	font: inherit; font-size: 12.5px; cursor: pointer; color: var(--ink); background: var(--surface);
	border: 1px solid var(--line-strong); border-radius: 3px; padding: 3px 9px; line-height: 19px; display: inline-block;
}
.btn:hover, button.theme:hover { text-decoration: none; border-color: var(--accent); }
.btn-p, button.btn-p { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.out { color: var(--muted); }


.content { padding: 16px 20px 40px; max-width: 1400px; }

/* section heading */
.sec { display: flex; align-items: baseline; gap: 10px; margin: 18px 0 6px; }
.sec:first-child { margin-top: 0; }
.sec h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; margin: 0; color: var(--muted); font-weight: 650; }
.sec .note { color: var(--muted); font-size: 12px; }
.sec .acts { margin-left: auto; display: flex; gap: 6px; }

/* stat strip: one ruled band, not cards */
.strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); background: var(--surface); border: 1px solid var(--line); border-radius: 3px; }
.strip > div { padding: 9px 12px 10px; border-right: 1px solid var(--line); min-width: 0; }
.strip > div:last-child { border-right: 0; }
.strip .k { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; white-space: nowrap; }
.strip .v { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-variant-numeric: tabular-nums; font-size: 20px; font-weight: 600; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.strip .v small { font-size: 12px; color: var(--muted); font-weight: 400; }
.strip a.v { display: block; color: var(--ink); }

.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; margin-top: 8px; }
@media (max-width: 1100px) { .cols { grid-template-columns: 1fr; } }

/* tables */
.tbl-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: 3px; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 5px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; vertical-align: middle; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; background: var(--sunk); position: sticky; top: 0; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--row-hover); }
td.wrap { white-space: normal; min-width: 180px; }
td.r, th.r { text-align: right; }
td.dim, .dim { color: var(--muted); }
td.act { text-align: right; }
td.act a + a { margin-left: 10px; }

/* status */
.st { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; }
.st::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.st-ok { color: var(--ok); }
.st-off { color: var(--off); }
.st-warn { color: var(--warn); }
.st-bad { color: var(--bad); }
.tag { display: inline-block; font-size: 11px; padding: 0 6px; border: 1px solid var(--line-strong); border-radius: 2px; color: var(--muted); line-height: 17px; }
.dir-in { color: var(--link); }
.dir-missed { color: var(--bad); font-weight: 600; }

/* filters */
.filters { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin: 0 0 8px; }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 3px; overflow: hidden; }
.seg a { padding: 3px 10px; color: var(--ink); border-right: 1px solid var(--line-strong); background: var(--surface); }
.seg a:last-child { border-right: 0; }
.seg a.on { background: var(--accent); color: var(--accent-ink); }
.seg a:hover { text-decoration: none; }

.empty { background: var(--surface); border: 1px dashed var(--line-strong); padding: 14px; color: var(--muted); border-radius: 3px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 3px; }
.kv > div { padding: 5px 10px; border-bottom: 1px solid var(--line); }
.kv > div:nth-last-child(-n+2) { border-bottom: 0; }
.kv .k { color: var(--muted); }
.hint { color: var(--muted); font-size: 12px; margin: 6px 0 0; }
.pager { display: flex; gap: 8px; align-items: center; margin-top: 8px; color: var(--muted); }
.secret { font-family: ui-monospace, Menlo, monospace; }
.reveal { font-size: 11.5px; margin-left: 6px; cursor: pointer; color: var(--link); background: none; border: 0; padding: 0; }

@media (max-width: 760px) {
	.shell { grid-template-columns: 1fr; }
	.side { position: static; height: auto; }
	.side nav { display: flex; flex-wrap: wrap; }
	.nav-group { display: none; }
	.top { height: auto; flex-wrap: wrap; padding: 8px 12px; }
	.content { padding: 12px; }
}

/* Pages app additions */
[hidden] { display: none !important; }
button.out { background: none; border: 0; padding: 0; font: inherit; color: var(--muted); cursor: pointer; }
button.out:hover { color: var(--ink); }
.switch span { color: var(--muted); }
.content.loading { opacity: .55; }
.login { min-height: 100vh; display: grid; place-items: center; background: var(--bg); }
.login form { width: 320px; background: var(--surface); border: 1px solid var(--line); border-radius: 3px; padding: 22px 22px 16px; display: flex; flex-direction: column; gap: 12px; }
.login label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.login input { font: inherit; font-size: 14px; color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 3px; padding: 6px 8px; }
.login input:focus, select:focus, input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.login .btn { padding: 6px; font-size: 14px; }
.login-brand { display: flex; flex-direction: column; align-items: center; gap: 4px; margin-bottom: 6px; }
.login-brand img { width: 170px; height: auto; }
.login-brand small { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.login-error { color: var(--bad); margin: 0; min-height: 1em; font-size: 12.5px; }
.login .hint { margin: 0; }
td .n, td.n { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.strip .v.sm { font-size: 15px; }
.strip .v.bad { color: var(--bad); }
.st.big { font-size: 14px; }

/* editing */
.btn-sm { padding: 1px 8px; font-size: 12px; }
dialog#editor { border: 1px solid var(--line-strong); border-radius: 3px; padding: 0; background: var(--surface); color: var(--ink); width: min(460px, 92vw); }
dialog#editor::backdrop { background: rgba(0, 0, 0, .45); }
.editor { display: flex; flex-direction: column; gap: 10px; padding: 16px 18px; }
.editor h3 { margin: 0 0 4px; font-size: 14px; }
.editor label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); }
.editor label.chk { flex-direction: row; align-items: center; gap: 7px; color: var(--ink); font-size: 13px; }
.editor input[type=text], .editor input[type=password], .editor select { font: inherit; font-size: 13px; color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 3px; padding: 5px 7px; height: auto; }
.editor fieldset { border: 1px solid var(--line); border-radius: 3px; margin: 0; padding: 6px 10px 8px; }
.editor legend { font-size: 12px; color: var(--muted); padding: 0 4px; }
.editor .checks { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; max-height: 220px; overflow-y: auto; }
.editor-msg { color: var(--bad); margin: 0; min-height: 1em; font-size: 12.5px; }
.editor-acts { display: flex; justify-content: flex-end; gap: 8px; }
.secret-once { font-size: 15px; padding: 8px; background: var(--sunk); border: 1px solid var(--line); user-select: all; }
.toast { position: fixed; right: 16px; bottom: 16px; background: var(--ink); color: var(--surface); padding: 8px 14px; border-radius: 3px; font-size: 13px; z-index: 10; }

.editor .keys { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; }
.editor label.key { flex-direction: row; align-items: center; gap: 6px; }
.editor label.key span { font-family: ui-monospace, Menlo, monospace; font-weight: 700; color: var(--ink); width: 14px; text-align: center; }
.editor label.key select { flex: 1; min-width: 0; }
dialog#editor { width: min(560px, 94vw); }
button[disabled] { opacity: .5; cursor: not-allowed; }

.editor img.qr { width: 180px; height: 180px; image-rendering: pixelated; background: #fff; padding: 6px; align-self: flex-start; }

.editor.wide { width: auto; }
dialog#editor:has(.editor.wide) { width: min(820px, 96vw); }
.editor .sub { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-top: 6px; }
.editor .player audio { width: 100%; }
.editor ol.flow { margin: 0; padding-left: 20px; max-height: 180px; overflow-y: auto; font-size: 12px; }
.editor .perms { max-height: 52vh; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.editor .perms fieldset { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 12px; }
.editor .perms label.chk { font-size: 12px; }
.btn-danger, button.btn-danger { background: var(--bad); border-color: var(--bad); color: #fff; font-weight: 600; }
td.act .btn-sm + .btn-sm { margin-left: 4px; }

.guides { display: flex; flex-direction: column; gap: 4px; }
details.guide { background: var(--surface); border: 1px solid var(--line); border-radius: 3px; }
details.guide summary { padding: 7px 12px; cursor: pointer; font-weight: 600; }
details.guide .guide-body { padding: 0 14px 10px; }
details.guide .guide-body li { margin: 3px 0; }
.editor textarea { font: inherit; font-size: 13px; color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 3px; padding: 6px 8px; resize: vertical; }
.editor .thread { white-space: pre-wrap; max-height: 260px; overflow-y: auto; background: var(--sunk); border: 1px solid var(--line); padding: 8px; font-size: 12.5px; }

#public-box .signup { width: min(560px, 94vw); background: var(--surface); border: 1px solid var(--line); border-radius: 3px; padding: 20px 22px; display: flex; flex-direction: column; gap: 10px; margin: 20px 0; }
.signup h2 { font-size: 16px; margin: 4px 0; }
.signup label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); }
.signup label.chk { flex-direction: row; align-items: flex-start; gap: 8px; color: var(--ink); font-size: 13px; }
.signup input, .signup select { font: inherit; font-size: 14px; color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 3px; padding: 6px 8px; }
.signup fieldset { border: 1px solid var(--line); border-radius: 3px; display: flex; flex-direction: column; gap: 8px; padding: 8px 12px 12px; margin: 0; }
.signup legend { font-weight: 600; color: var(--ink); padding: 0 4px; }
.signup .row3 { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 8px; }
.signup .plan span { line-height: 1.4; }
.login { align-content: start; overflow-y: auto; }
.qr { width: 180px; height: 180px; image-rendering: pixelated; background: #fff; padding: 6px; }

.editor .row3 { display: grid; grid-template-columns: 1.4fr 0.8fr 1.4fr; gap: 8px; }

td .player audio { height: 28px; vertical-align: middle; margin-right: 6px; }

body.invoice { background: #fff; color: #000; }
.inv { max-width: 760px; margin: 24px auto; padding: 0 16px; }
.inv h1 { font-size: 20px; margin: 12px 0; }
.inv-logo { width: 110px; }
.inv table { border: 1px solid #ccc; }
.inv th { background: #f2f2f2; color: #333; position: static; }
@media print { .inv { margin: 0; } }
