/* THE WINDOW — the title and the menu, the section panel down the left side, the tabs, the active tab's view, the
   messages, the status line: the height of the screen, the view taking what is left. A narrow window is one column,
   the sections a strip under the title. */

html, body {
	margin: 0;
	height: 100%;
	background: var(--oes-window-bg);
	color: var(--oes-text);
	font-family: var(--oes-font-ui);
}

#client {
	height: 100dvh;
}

.client-window {
	display: grid;
	grid-template-columns: auto minmax(0, 1fr);
	grid-template-rows: auto auto auto 1fr auto auto;
	grid-template-areas:
		"header   header"
		"toolbar  toolbar"
		"sections tabs"
		"sections views"
		"sections messages"
		"status   status";
	height: 100%;
	min-width: 0;
}

.client-window > header { grid-area: header; }
.client-window > .toolbar { grid-area: toolbar; }
.client-window > .sections { grid-area: sections; }
.client-window > .tabs { grid-area: tabs; }
.client-window > .views { grid-area: views; }
.client-window > .messages { grid-area: messages; }
.client-window > .status { grid-area: status; }

.client-window header {
	display: flex;
	align-items: center;
	gap: 1rem;
	padding: 0 1rem;
	background: var(--oes-panel-bg);
	border-bottom: 1px solid var(--oes-border);
	min-width: 0;
}

/* The platform's mark beside the application's name. */
.client-window header .logo {
	flex: 0 0 auto;
	width: 20px;
	height: 20px;
	margin-right: -0.5rem;
}

.client-window h1 {
	flex: 0 1 auto;
	min-width: 3ch;
	margin: 0;
	font-size: 1rem;
	font-weight: 600;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

/* The menu keeps one line and scrolls sideways when the window is narrower than it. */
.client-window .menu {
	display: flex;
	flex: 1 1 auto;
	min-width: 0;
	gap: 0.25rem;
	overflow-x: auto;
	scrollbar-width: none;
}

/* THE SECTION PANEL — the thin client's: a column 200px wide, a section 35px tall, its picture and title from the left,
   lined above and at its sides; the open one white and bold, its face ringed with dots. A section and a link are
   buttons, and Web Awesome's native styles give every button a control's height, centred content and round corners:
   these take them back. */
.sections {
	display: flex;
	flex-direction: column;
	width: 200px;
	overflow-y: auto;
	background: var(--oes-sections-bg);
}

.section {
	display: flex;
	align-items: center;
	justify-content: flex-start;
	flex: 0 0 auto;
	height: auto;
	min-height: max(35px, var(--oes-touch));
	padding: 0 8px;
	border: 1px solid var(--oes-section-border);
	border-bottom: none;
	border-radius: 0;
	background: var(--oes-section-bg);
	color: var(--oes-section-text);
	font: 1rem var(--oes-font-ui);
	text-align: left;
	cursor: pointer;
}

.section .face {
	display: flex;
	align-items: center;
	gap: 3px;
	min-width: 0;
}

.section img {
	flex: 0 0 auto;
	width: 16px;
	height: 16px;
}

.section .title {
	overflow: hidden;
	white-space: nowrap;
	text-overflow: ellipsis;
}

.section[aria-expanded="true"] {
	background: var(--oes-panel-bg);
	color: var(--oes-text);
	font-weight: 700;
}

.section[aria-expanded="true"] .face {
	outline: 1px dotted currentColor;
	outline-offset: 2px;
}

/* A section's page — beside the panel, over the rest of the window, where the script places it; it scrolls both
   ways. The navigation's column, 50px, the actions'. It shows in a moment and goes the same way, as the thin client's
   fades. A closed one keeps the popover's own display: none. */
.section-page {
	position: fixed;
	inset: auto;
	margin: 0;
	box-sizing: border-box;
	padding: 0.25rem 0.5rem;
	overflow: auto;
	border: none;
	border-left: 1px solid var(--oes-section-border);
	background: var(--oes-panel-bg);
	color: var(--oes-section-ink);
	opacity: 0;
	transition: opacity 80ms, overlay 80ms allow-discrete, display 80ms allow-discrete;
}

.section-page:popover-open {
	display: flex;
	align-items: flex-start;
	gap: 50px;
	opacity: 1;
}

@starting-style {
	.section-page:popover-open {
		opacity: 0;
	}
}

.section-page .column {
	display: flex;
	flex-direction: column;
	flex: 0 0 auto;
}

.section-page h3 {
	display: flex;
	align-items: center;
	gap: 5px;
	margin: 5px;
	font-size: 1rem;
	font-weight: 700;
}

.section-page .links {
	display: flex;
	flex-direction: column;
	padding-left: 20px;
}

/* A link is its icon and caption and nothing to the right of them; the caption four points over the window's text. */
.section-page .link {
	display: flex;
	align-items: center;
	justify-content: flex-start;
	gap: 8px;
	width: fit-content;
	height: auto;
	padding: 2px;
	border: none;
	border-radius: 0;
	background: none;
	color: inherit;
	font: 1.0625rem var(--oes-font-ui);
	text-align: left;
	cursor: pointer;
}

.section-page .link:hover span {
	text-decoration: underline;
}

.section-page img {
	width: 16px;
	height: 16px;
}

@media (pointer: coarse) {
	.section-page .link {
		min-height: var(--oes-touch);
	}
}

/* A narrow window: one column — the sections a strip under the title that scrolls sideways, a page's columns one under
   the other. */
@media (max-width: 40rem) {
	.client-window {
		grid-template-columns: minmax(0, 1fr);
		grid-template-rows: auto auto auto auto 1fr auto auto;
		grid-template-areas: "header" "toolbar" "sections" "tabs" "views" "messages" "status";
	}

	.sections {
		flex-direction: row;
		width: auto;
		overflow-x: auto;
		overflow-y: hidden;
		scrollbar-width: none;
	}

	.section {
		max-width: 12rem;
		border-bottom: 1px solid var(--oes-section-border);
		border-right: none;
	}

	.section-page {
		border-left: none;
		border-top: 1px solid var(--oes-section-border);
	}

	.section-page:popover-open {
		flex-direction: column;
		gap: 0.5rem;
	}
}

/* The tabs scroll sideways on their own strip; the page never does. */
.tabs {
	display: flex;
	gap: 2px;
	overflow-x: auto;
	padding: 2px 0.5rem 0;
	border-bottom: 1px solid var(--oes-border);
	scrollbar-width: thin;
}

.tab {
	display: flex;
	align-items: center;
	gap: 0.375rem;
	min-height: var(--oes-touch);
	padding: 0 0.5rem 0 0.75rem;
	border: 1px solid var(--oes-border);
	border-bottom: none;
	border-radius: 6px 6px 0 0;
	background: var(--oes-window-bg);
	white-space: nowrap;
	cursor: pointer;
}

.tab[aria-selected="true"] {
	background: var(--oes-panel-bg);
	box-shadow: inset 0 2px 0 var(--oes-accent);
}

.tab img {
	width: 16px;
	height: 16px;
}

/* A long title is cut short; the whole of it is the tab's tooltip. */
.tab span {
	max-width: 20rem;
	overflow: hidden;
	text-overflow: ellipsis;
}

.tab .close {
	min-width: 1.5em;
	height: auto;
	padding: 0;
	border: none;
	border-radius: 0;
	background: none;
	color: var(--oes-muted);
	font-size: 1rem;
	cursor: pointer;
}

@media (pointer: coarse) {
	.tab .close {
		min-width: var(--oes-touch);
		min-height: var(--oes-touch);
	}
}

.views {
	position: relative;
	overflow: auto;
	min-height: 0;
	background: var(--oes-panel-bg);
}

.view-placeholder {
	padding: 2rem;
	color: var(--oes-muted);
}

/* The assistant window (src/docView/assistant.js), as the thin client's: the transcript over what the person writes. */
.assistant-window {
	display: flex;
	flex-direction: column;
	gap: 4px;
	height: 100%;
	box-sizing: border-box;
	padding: 4px;
	color: var(--oes-form-text);
}

.assistant-transcript {
	flex: 1;
	min-height: 0;
	overflow: auto;
	padding: 4px;
	border: 1px solid var(--oes-border);
	background: var(--oes-form-bg);
}

.assistant-entry {
	margin-bottom: 0.5rem;
	white-space: pre-wrap;
	overflow-wrap: anywhere;
}

.assistant-waiting {
	color: var(--oes-muted);
}

.assistant-waiting:empty {
	display: none;
}

.assistant-input {
	display: flex;
	align-items: flex-end;
	gap: 4px;
}

.assistant-input textarea {
	flex: 1;
	box-sizing: border-box;
	padding: 4px;
	border: 1px solid var(--oes-border);
	background: var(--oes-form-bg);
	color: var(--oes-form-text);
	font: inherit;
	resize: vertical;
}

/* The registration journal (src/docView/auditLog.js), as the thin client's: the filter strip, the tools — a command
   bar with the live refresh on it, at its right —, and the rows as the theme's table (a table control's: the powder header,
   every second row a step off white, the cursor in the highlight). */
.audit-log {
	display: flex;
	flex-direction: column;
	height: 100%;
	box-sizing: border-box;
	padding: 3px;
	color: var(--oes-form-text);
}

.audit-log-filter {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
}

/* A caption beside its field — Web Awesome's own put a label with a field in it on a line of its own, its caption
   bold, the field under it. The journal's filter and a schedule's window draw their fields as the thin client does. */
:is(.audit-log-filter, .job-schedule, .find-dialog) label {
	display: flex;
	align-items: center;
	gap: 3px;
	width: auto;
	margin: 3px;
	color: inherit;
	font-weight: inherit;
	white-space: nowrap;
}

/* The search takes what is left of the line. */
.audit-log-filter label:last-child {
	flex: 1 1 10rem;
}

.audit-log-filter label:last-child input {
	flex: 1 1 auto;
	min-width: 6rem;
}

/* As wide as each holds — Web Awesome's own make a page's inputs as wide as their line. */
:is(.audit-log-filter, .job-schedule, .find-dialog) :is(input:not([type="checkbox"], [type="radio"]), select) {
	box-sizing: border-box;
	width: auto;
	height: 23px;
	margin: 0;
	padding: 0 3px;
	border: 1px solid var(--oes-border);
	border-radius: 0;
	background: var(--oes-table-bg);
	color: var(--oes-table-text);
	font: inherit;
}

.audit-log-tools {
	display: flex;
	align-items: center;
	background-color: var(--oes-window-bg);
	background-image: linear-gradient(to bottom, var(--oes-bar-shine-top), var(--oes-bar-shine-bottom));
	border-bottom: 1px solid var(--oes-border);
}

.audit-log-tools .command-bar {
	flex: 1 1 auto;
	min-width: 0;
	background: none;
	border-bottom: none;
}

.audit-log-tools label {
	display: flex;
	align-items: center;
	gap: 4px;
	padding: 0 0.5rem;
	white-space: nowrap;
}

.audit-log-rows {
	flex: 1 1 auto;
	min-height: 0;
	margin-top: 3px;
	overflow: auto;
	border: 1px solid var(--oes-border);
	background: var(--oes-table-bg);
	outline: none;
}

.audit-log-table {
	table-layout: fixed;
	border-collapse: collapse;
	color: var(--oes-table-text);
}

.audit-log-table th {
	position: sticky;
	top: 0;
	height: 22px;
	padding: 0 4px;
	border-right: 1px solid var(--oes-table-border);
	border-bottom: 1px solid var(--oes-border);
	background: var(--oes-table-header-bg);
	color: var(--oes-table-header-text);
	font-weight: 400;
	text-align: start;
	white-space: nowrap;
}

.audit-log-table td {
	height: 22px;
	padding: 0 4px;
	overflow: hidden;
	border-bottom: 1px solid var(--oes-table-border);
	text-overflow: ellipsis;
	white-space: nowrap;
}

.audit-log-table tbody tr:nth-child(even) {
	background: var(--oes-table-row-alt-bg);
}

.audit-log-table tbody tr.current {
	background: var(--oes-table-row-current-bg);
	color: var(--oes-table-current-text);
}

.audit-log-rows:not(:focus-within) .audit-log-table tbody tr.current {
	background: var(--oes-table-current-idle-bg);
}

/* The start page (src/window/homePage.js): its columns side by side, the cells of each one under the other, each with its
   share of what its parent has; the sashes between them stand out of the panes on the window's colour. */
oes-homepage {
	display: flex;
	box-sizing: border-box;
	height: 100%;
	padding: 3px;
	background: var(--oes-window-bg);
}

.home-column,
.home-cell {
	display: flex;
	flex-direction: column;
	flex: var(--share, 1) 1 0;
	min-width: 0;
	min-height: 0;
}

.home-cell {
	border: 1px solid var(--oes-border);
	border-radius: 4px;
	background: var(--oes-panel-bg);
	overflow: hidden;
}

/* A label, not a title bar: it says what lives here and leaves the height to the form. */
.home-strip {
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	gap: 0.375rem;
	padding: 0.25rem 0.5rem;
	border-bottom: 1px solid var(--oes-border);
	font-weight: 600;
}

.home-strip img {
	width: 16px;
	height: 16px;
}

/* A long title is cut short; the whole of it is its tooltip. */
.home-strip span {
	overflow: hidden;
	white-space: nowrap;
	text-overflow: ellipsis;
}

/* A form on a cell is a desktop's however narrow the cell: it is not folded for a phone while the window is no phone's.
   Under no container of the name the folding rules do not apply. */
.home-cell > oes-clientform {
	container-name: none;
	flex: 1 1 0;
	height: auto;
	min-height: 0;
}

.home-unavailable {
	margin: auto;
	padding: 1rem;
	color: var(--oes-muted);
}

.home-sash {
	flex: 0 0 5px;
	border-radius: 2px;
	touch-action: none;
}

.home-sash.horizontal {
	cursor: col-resize;
}

.home-sash.vertical {
	cursor: row-resize;
}

.home-sash:hover,
.home-sash:active {
	background: var(--oes-section-border);
}

/* A narrow window: the cells one under the other, the page scrolling; each form folded as a tab's, no sash to drag. */
@media (max-width: 40rem) {
	oes-homepage,
	.home-column {
		display: block;
		height: auto;
	}

	.home-cell {
		height: 80dvh;
		margin-bottom: 3px;
	}

	.home-cell > oes-clientform {
		container-name: form;
	}

	.home-sash {
		display: none;
	}
}

/* The messages: their lines scroll under the edge their height is dragged by; the × clears them, and the pane goes. */
.messages {
	position: relative;
	display: flex;
	flex-direction: column;
	max-height: 25dvh;
	border-top: 1px solid var(--oes-border);
	background: var(--oes-panel-bg);
}

.messages .lines {
	flex: 1 1 auto;
	min-height: 0;
	overflow-y: auto;
	padding-right: var(--oes-touch);
}

.messages .grip {
	flex: 0 0 auto;
	height: 6px;
	margin-top: -3px;
	cursor: ns-resize;
	touch-action: none;
}

.messages .clear {
	position: absolute;
	top: 2px;
	right: 0.75rem;
	z-index: 1;
	min-width: var(--oes-touch);
	height: auto;
	padding: 0;
	border: none;
	border-radius: 0;
	background: none;
	color: var(--oes-muted);
	font-size: 1rem;
	cursor: pointer;
}

/* A message, as the thin client's output window has it: in the code's font, its level a mark in the margin — an
   information's blue, a warning's amber, an error's red. */
.message {
	display: flex;
	align-items: baseline;
	gap: 0.5rem;
	padding: 0.125rem 1rem 0.125rem 0.5rem;
	border-bottom: 1px solid var(--oes-window-bg);
	font: 0.8125rem/1.4 ui-monospace, Consolas, "SF Mono", Menlo, monospace;
	white-space: pre-wrap;
	overflow-wrap: anywhere;
}

.message::before {
	content: 'i';
	flex: 0 0 12px;
	height: 12px;
	border-radius: 50%;
	background: var(--oes-message-information);
	color: var(--oes-on-colour);
	font: 700 9px/12px var(--oes-font-ui);
	text-align: center;
	transform: translateY(1px);
}

.message.warning::before {
	content: '!';
	background: var(--oes-message-warning);
}

.message.error::before {
	content: '×';
	background: var(--oes-message-error);
}

.status {
	padding: 0.125rem 1rem;
	font-size: 0.8rem;
	color: var(--oes-muted);
	border-top: 1px solid var(--oes-border);
}

.status:empty {
	display: none;
}

.login {
	display: grid;
	gap: 1rem;
	width: min(22rem, 100% - 2rem);
	margin: 15dvh auto 0;
	padding: 1.5rem;
	background: var(--oes-panel-bg);
	border: 1px solid var(--oes-border);
	border-radius: 8px;
}

.login h1 {
	margin: 0;
	font-size: 1.25rem;
}

.login .refusal {
	margin: 0;
	color: var(--wa-color-danger-fill-loud, #c0392b);
}

.login .refusal:empty {
	display: none;
}

/* The server waited on: a spinner over the window that takes no click — the old client's, after 800 ms. */
.busy {
	position: fixed;
	inset: 0;
	display: grid;
	place-content: center;
	pointer-events: none;
	font-size: 2rem;
	z-index: 9;
}

/* The connection lost: a strip over the top of the window until it is back. */
.offline {
	position: fixed;
	top: 0;
	left: 50%;
	transform: translateX(-50%);
	padding: 0.375rem 1rem;
	border-radius: 0 0 6px 6px;
	background: var(--oes-message-warning);
	color: var(--oes-on-colour);
	font-weight: 600;
	z-index: 9;
}

.ended {
	position: fixed;
	inset: 0;
	display: grid;
	place-content: center;
	gap: 1rem;
	padding: 1rem;
	background: var(--oes-veil);
	text-align: center;
	z-index: 10;
}

/* A question that only its buttons answer — a Yes/No with no Cancel — has no ×. */
/* A dialog is taken by its title (window/dialogMove.js). */
wa-dialog::part(header) {
	cursor: move;
	user-select: none;
	touch-action: none;
}

wa-dialog.answered-only::part(close-button) {
	display: none;
}

/* A dialog's buttons as the thin client's theme draws them (docs/private/ui-palette.md, «the buttons went white»): the
   default one in the terracotta, its caption white; the others white, framed in the border, the powder under the
   mouse. Find's too: a window of its own, not a wa-dialog. */
:is(wa-dialog, .find-dialog) wa-button::part(base) {
	background: var(--oes-panel-bg);
	color: var(--oes-text);
	border: 1px solid var(--oes-border);
}

:is(wa-dialog, .find-dialog) wa-button::part(base):hover {
	background: var(--oes-button-hover-bg);
}

:is(wa-dialog, .find-dialog) wa-button[variant="brand"]::part(base) {
	background: var(--oes-default-button-bg);
	color: var(--oes-default-button-text);
	border-color: var(--oes-default-button-bg);
}

/* One of a list or several (the thin client's ibSingleChoiceDialog, ibMultiChoiceDialog): an item a line, its mark before
   its caption; a long list scrolls inside the dialog. */
.choice-list {
	display: grid;
	gap: 0.125rem;
	max-height: 60dvh;
	overflow: auto;
}

.choice-list label {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	padding: 0.25rem 0.5rem;
	border-radius: var(--wa-border-radius-s, 3px);
	cursor: pointer;
	user-select: none;
}

.choice-list label:hover {
	background: var(--oes-table-row-hover-bg);
}

/* A list whose line pressed is the answer (Questions.generation): its picture and caption. */
.choice-list button {
	display: flex;
	align-items: center;
	justify-content: flex-start;
	gap: 0.5rem;
	padding: 0.25rem 0.5rem;
	border: none;
	border-radius: var(--wa-border-radius-s, 3px);
	background: none;
	color: inherit;
	font: inherit;
	text-align: left;
	cursor: pointer;
}

.choice-list button:hover,
.choice-list button:focus-visible {
	background: var(--oes-table-row-hover-bg);
	outline: none;
}

.choice-list img {
	width: 16px;
	height: 16px;
}

/* A type description edited (Questions.typeSelector, the thin client's type picker): the types offered, a family's
   references under it, a plain heading not ticked; the qualifiers of the type pressed on a line under them. */
.type-selector-dialog {
	--width: 26rem;
}

.type-selector {
	display: grid;
	gap: 0.5rem;
}

.type-members {
	display: grid;
	gap: 0.125rem;
	padding-left: 1.5rem;
}

.type-heading {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	padding: 0.25rem 0.5rem;
}

.type-selector-line {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.375rem;
}

.type-selector-line[hidden] {
	display: none;
}

.type-selector-line input[type='number'] {
	width: 5rem;
}

/* A schedule edited (Questions.schedule, the thin client's ibDialogJobSchedule): its tabs at the window's size, their
   lines of captions and fields, a group framed as a form's Group layout (oes-layout[view="group"]), the checked lists boxed and
   scrolled (ibCheckListBox); the sentence under the tabs. */
.job-schedule-dialog {
	--width: 32rem;
}

.job-schedule {
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
}

.job-schedule-page {
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
	min-height: 18rem;
}

.job-schedule-line {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.375rem;
}

.job-schedule input[type="number"] {
	width: 6rem;
}

:is(.job-schedule, .find-dialog) input:is([type="checkbox"], [type="radio"]) {
	margin: 0;
	accent-color: var(--oes-accent);
}

:is(.job-schedule, .find-dialog) fieldset {
	margin: 0;
	padding: 0.25rem 0.5rem 0.5rem;
	border: 1px solid var(--oes-border);
	border-radius: 6px;
}

:is(.job-schedule, .find-dialog) legend {
	padding: 0 0.25rem;
	font-weight: 600;
}

.job-schedule-list {
	display: flex;
	flex-direction: column;
	height: 9.5rem;
	overflow: auto;
	border: 1px solid var(--oes-border);
	background: var(--oes-table-bg);
	color: var(--oes-table-text);
}

.job-schedule-list label {
	margin: 0;
	padding: 1px 3px;
}

.job-schedule-columns {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 0.375rem;
}

.job-schedule-columns .job-schedule-list {
	height: 14rem;
}

.job-schedule-sentence {
	min-height: 1.25em;
}

/* Find (window/find.js) — not modal, as the thin client's: a window of its own over the top right of the tabs, its
   look a dialog's, its fields the schedule's. */
.find-dialog {
	position: fixed;
	inset: 4.5rem 1.5rem auto auto;
	margin: 0;
	padding: 0;
	min-width: 26rem;
	border: 1px solid var(--oes-border);
	border-radius: 6px;
	background: var(--oes-panel-bg);
	color: var(--oes-text);
	box-shadow: 0 6px 18px var(--oes-shadow-strong);
	z-index: 5;
}

.find-dialog-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 0.375rem 0.5rem 0.375rem 0.75rem;
	font-weight: 600;
}

.find-dialog-header button {
	border: none;
	background: none;
	color: inherit;
	font-size: 1.125rem;
	line-height: 1;
	cursor: pointer;
}

.find-dialog-body {
	display: flex;
	gap: 0.75rem;
	padding: 0 0.75rem 0.75rem;
}

.find-dialog-sought input {
	flex: 1 1 auto;
}

.find-dialog-options {
	display: flex;
	align-items: flex-start;
	gap: 1rem;
	margin-top: 0.375rem;
}

.find-dialog-buttons {
	display: flex;
	flex-direction: column;
	gap: 0.375rem;
}

/* A popup menu the server asks — where the person pressed; a submenu opens in place, indented. */
.popup-menu {
	position: fixed;
	inset: auto;
	margin: 0;
	min-width: 12rem;
	max-height: 80dvh;
	overflow: auto;
	padding: 0.25rem 0;
	background: var(--oes-panel-bg);
	color: var(--oes-text);
	border: 1px solid var(--oes-border);
	border-radius: 6px;
	box-shadow: 0 4px 16px var(--oes-shadow-strong);
	font: 0.875rem var(--oes-font-ui);
}

.popup-menu button,
.popup-menu summary {
	display: block;
	width: 100%;
	min-height: var(--oes-touch);
	padding: 0 0.75rem 0 1.5rem;
	border: none;
	background: none;
	color: inherit;
	font: inherit;
	text-align: left;
	cursor: pointer;
}

.popup-menu summary {
	display: flex;
	align-items: center;
	list-style: none;
}

.popup-menu summary::after {
	content: '▸';
	margin-left: auto;
	color: var(--oes-muted);
}

.popup-menu details[open] > summary::after {
	content: '▾';
}

.popup-menu button:hover:not(:disabled),
.popup-menu summary:hover {
	background: var(--oes-table-row-hover-bg);
}

.popup-menu img {
	width: 16px;
	height: 16px;
	margin-right: 0.375rem;
	vertical-align: middle;
}

.popup-menu button:disabled {
	color: var(--oes-muted);
	cursor: default;
}

/* A table's advanced search: where and what, a label and its field a line each — what, a text or a value of the
   column's type (a settings window's cell); how, a group of four. */
.search-fields {
	display: grid;
	gap: 0.5rem;
	min-width: min(24rem, 80vw);
}

.search-fields > label {
	display: grid;
	grid-template-columns: 9rem 1fr;
	align-items: center;
	font-weight: normal;
}

/* The colour alone, not the background: a <select>'s arrow is the native styles' background image. */
.search-fields :is(select, input[type="text"], input[type="number"], input[type="datetime-local"]) {
	width: 100%;
	box-sizing: border-box;
	height: 1.75rem;
	margin: 0;
	padding: 0 4px;
	border: 1px solid var(--oes-border);
	background-color: var(--oes-table-bg);
	color: var(--oes-editor-text);
	font: inherit;
}

.search-fields select {
	padding-inline-end: 1.75rem;
}

.search-fields fieldset {
	display: grid;
	gap: 0.25rem;
	border: 1px solid var(--oes-border);
}

/* A command's key, at the line's end — as a menu writes it beside the caption. */
.popup-menu .shortcut {
	float: right;
	margin-left: 2rem;
	color: var(--oes-muted);
}

.popup-menu button.checked::before {
	content: '✓';
	margin-left: -1rem;
	width: 1rem;
	display: inline-block;
}

.popup-menu details > :not(summary) {
	padding-left: 2.25rem;
}

/* …a group a line of the menu, not the panel the native styles make of a <details> (a frame, its padding when open, its
   summary pulled out over it — wider than the menu, which then scrolled sideways; the space under it a block of text
   keeps); its arrow the menu's own. */
.popup-menu details,
.popup-menu details[open] {
	margin: 0;
	padding: 0;
	border: none;
	border-radius: 0;
	background: none;
}

/* The summary sits in the <details>' own slot and takes its box from it, not from the page: its width counted without
   its padding, it ran past the menu's edge, the arrow with it. */
.popup-menu details summary,
.popup-menu details[open] summary {
	box-sizing: border-box;
	margin-inline: 0;
	border-radius: 0;
}

.popup-menu details summary::after {
	mask: none;
	background: none;
	width: auto;
	height: auto;
	rotate: none;
}

/* A quick choice — a menu's items dropped under the field pressed, the one the field holds marked. */
.quick-choice {
	min-width: 0;
	max-height: min(80dvh, calc(var(--oes-touch) * 8 + 0.5rem));
}

.quick-choice button {
	padding-left: 0.75rem;
}

.quick-choice button.selected {
	font-weight: 600;
}

.quick-choice button:focus-visible {
	outline: none;
	background: var(--oes-table-row-hover-bg);
}

/* A number's calculator and a date's calendar — dropped under the field pressed, the keys a finger's size. */
.simple-choice {
	position: fixed;
	inset: auto;
	margin: 0;
	padding: 0.5rem;
	background: var(--oes-panel-bg);
	color: var(--oes-text);
	border: 1px solid var(--oes-border);
	border-radius: 6px;
	box-shadow: 0 4px 16px var(--oes-shadow-strong);
	font: 0.875rem var(--oes-font-ui);
}

.simple-choice .calendar {
	display: flex;
	gap: 0.5rem;
	align-items: center;
}

.simple-choice .calendar input {
	min-height: var(--oes-touch);
	font: inherit;
}

.simple-choice .calculator:focus {
	outline: none;
}

.simple-choice .calculator .operation {
	min-height: 1.25em;
	text-align: right;
	color: var(--oes-muted);
}

.simple-choice .calculator .display {
	display: block;
	padding-bottom: 0.5rem;
	text-align: right;
	font-size: 1.5rem;
	font-variant-numeric: tabular-nums;
}

.simple-choice .calculator .keys {
	display: grid;
	grid-template-columns: repeat(4, minmax(3rem, 1fr));
	gap: 0.25rem;
}

.simple-choice .calculator .keys button {
	min-height: var(--oes-touch);
}

.simple-choice .calculator .keys .ok {
	grid-column: span 4;
}

/* All functions: the search over the tree, and the line that says it found nothing. */
.functions wa-input {
	margin-bottom: 0.5rem;
}

.functions .nothing-found {
	margin: 0.5rem 0;
	color: var(--oes-muted);
}

.functions wa-tree-item img {
	width: 16px;
	height: 16px;
	margin-inline-end: 0.375rem;
}

/* Change form (window/formEditor.js, the thin client's ibDialogFormEditor): Up and Down over the controls' tree and the
   property grid side by side, the setting's two buttons and what they did under them. */
.form-editor {
	--width: 44rem;
}

.form-editor-tools,
.form-editor-setting {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.25rem;
}

.form-editor-main {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 0.5rem;
	height: 22rem;
	margin: 0.375rem 0;
}

/* A narrow window: the form's tree over the taken control's properties. */
@media (max-width: 40rem) {
	.form-editor-main {
		grid-template-columns: minmax(0, 1fr);
		grid-template-rows: 12rem minmax(0, 1fr);
		height: 32rem;
	}
}

.form-editor-main wa-tree {
	min-height: 0;
	overflow: auto;
	border: 1px solid var(--oes-border);
	background: var(--oes-table-bg);
	--indent-guide-width: 0;
}

/* Folded and unfolded at once, as the thin client's tree. */
.form-editor-main wa-tree-item {
	--show-duration: 0s;
	--hide-duration: 0s;
}

.form-editor-main wa-tree-item img {
	width: 16px;
	height: 16px;
	margin-inline-end: 0.375rem;
}

.form-editor-main wa-tree-item[selected]::part(label) {
	font-weight: 600;
}

.form-editor-status {
	flex: 1;
	margin-inline-start: 0.25rem;
	color: var(--oes-muted);
}

/* The saved settings' shelf (window/savedSettings.js, the thin client's ibDialogSavedSettings): the names in one column,
   the buttons beside them — the window's own act first, the housekeeping apart under it; the entry restored on open
   bold, the one taken in the highlight. */
.saved-settings {
	--width: 30rem;
}

.saved-settings-body {
	display: grid;
	grid-template-columns: 1fr auto;
	gap: 0.5rem;
	height: 15rem;
}

.saved-settings-list {
	min-height: 0;
	overflow: auto;
	border: 1px solid var(--oes-border);
	background: var(--oes-table-bg);
	color: var(--oes-table-text);
	outline: none;
}

.saved-settings-entry {
	padding: 0.125rem 0.375rem;
	cursor: default;
	user-select: none;
}

.saved-settings-entry.default {
	font-weight: 700;
}

.saved-settings-entry.taken {
	background: var(--oes-table-cell-current-bg);
	color: var(--oes-table-current-text);
}

.saved-settings-list:not(:focus-within) .saved-settings-entry.taken {
	background: var(--oes-table-current-idle-bg);
}

.saved-settings-buttons {
	display: flex;
	flex-direction: column;
	gap: 0.25rem;
}

.saved-settings-buttons .apart {
	margin-bottom: 0.5rem;
}

/* A list's and a report's settings (src/settings, window/listSettings.js and window/composerSettings.js — the thin
   client's ibDialogListSettings, 660×450, and ibDialogComposerSettings): a page each for what is set — the available
   fields beside the lines, the tools over them, ruled as a table; the report's structure on the left of its pages; the
   line, the node and the field taken in the highlight. */
.list-settings {
	--width: 41rem;
}

.composer-settings {
	--width: 62rem;
}

/* A part of a conditional appearance's rule, in a window of its own over the settings (the thin client's: its condition
   in the filter editor, 640×360; its fields; its appearance, the platform's six parameters). */
.condition-window {
	--width: 41rem;
}

.fields-window {
	--width: 32rem;
}

.appearance-window {
	--width: 38rem;
}

.appearance-window .settings-page {
	height: auto;
}

/* A grouping composed before it is added (the thin client's grouping form, 430×220 of fields and their unfolds). */
.grouping-window {
	--width: 41rem;
}

/* A translated text, a box a language (the thin client's translation window: the language's name and code, a box of
   two lines that grows with the window). */
.translate-window {
	--width: 32rem;
}

.translate-languages {
	display: grid;
	grid-template-columns: max-content 1fr;
	gap: 0.375rem 0.5rem;
	align-items: start;
}

.translate-languages label {
	padding-block-start: 0.25rem;
	font-weight: inherit;
}

.translate-languages textarea {
	min-width: 0;
	resize: vertical;
	font: inherit;
}

/* A parameter not ticked keeps its value, not applied — grey, as the thin client's. */
.settings-table tr.unticked .property-cell {
	color: var(--oes-muted);
}

.settings-window wa-tab-panel {
	--padding: 0.5rem 0 0;
}

.settings-page {
	display: grid;
	grid-template-columns: 13rem 1fr;
	gap: 0.5rem;
	height: 20rem;
}

.settings-page-alone {
	grid-template-columns: 1fr;
}

.settings-composer {
	display: grid;
	grid-template-columns: 15rem 1fr;
	gap: 0.75rem;
}

/* A narrow window: one under the other — the report's structure over its pages, a page's fields over its lines. */
@media (max-width: 40rem) {
	.settings-composer {
		grid-template-columns: minmax(0, 1fr);
		grid-template-rows: 11rem auto;
	}

	.settings-page {
		grid-template-columns: minmax(0, 1fr);
		grid-template-rows: 9rem minmax(0, 1fr);
		height: 28rem;
	}

	.settings-page-alone {
		grid-template-rows: minmax(0, 1fr);
	}
}

.settings-structure,
.settings-node-side {
	display: flex;
	flex-direction: column;
	gap: 0.25rem;
	min-width: 0;
}

.settings-structure-list {
	flex: 1;
	min-height: 0;
	overflow: auto;
	border: 1px solid var(--oes-border);
	background: var(--oes-table-bg);
	color: var(--oes-table-text);
}

.settings-header {
	color: var(--oes-muted);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.settings-auto {
	color: var(--oes-muted);
	font-style: italic;
}

/* A group of the selected fields says it is one; its title and placement are cells of their own. */
.settings-group {
	font-weight: 600;
}

/* A line of the selected fields' tree: stepped in by its depth, after the grip it is carried by. */
.settings-tree-line {
	display: flex;
	align-items: center;
	gap: 2px;
	min-width: 0;
}

.settings-tree-line > select {
	flex: 1;
	min-width: 0;
}

.settings-grip {
	flex: none;
	width: 0.75rem;
	color: var(--oes-muted);
	text-align: center;
	cursor: grab;
	user-select: none;
}

/* Where a carried line would land: before a line, after it, into a group. */
.settings-table tr.drop-before td {
	box-shadow: inset 0 2px 0 var(--oes-accent);
}

.settings-table tr.drop-after td {
	box-shadow: inset 0 -2px 0 var(--oes-accent);
}

.settings-table tr.drop-into td {
	background: var(--oes-table-row-hover-bg);
}

.settings-fields,
.settings-editor {
	display: flex;
	flex-direction: column;
	gap: 0.25rem;
	min-width: 0;
	min-height: 0;
}

.settings-pane-title {
	color: var(--oes-muted);
	user-select: none;
}

.settings-field-list,
.settings-table-holder {
	flex: 1;
	min-height: 0;
	overflow: auto;
	border: 1px solid var(--oes-border);
	background: var(--oes-table-bg);
	color: var(--oes-table-text);
}

.settings-field {
	display: flex;
	align-items: center;
	gap: 0.25rem;
	min-height: 20px;
	padding-inline-end: 0.375rem;
	white-space: nowrap;
	cursor: default;
	user-select: none;
}

.settings-field img {
	width: 16px;
	height: 16px;
}

.settings-field-toggle {
	flex: 0 0 auto;
	width: 14px;
	height: 14px;
	padding: 0;
	border: none;
	background: none;
	color: inherit;
	font: inherit;
	line-height: 1;
	cursor: pointer;
}

.settings-field.taken,
.settings-table tr.taken {
	background: var(--oes-table-cell-current-bg);
	color: var(--oes-table-current-text);
}

.settings-table-holder {
	outline: none;
}

/* The thin client's 16×16 toolbar over the lines: flat, a frame under the pointer. A caption is never squeezed under the
   next one — a longer language («Додати групування») takes a second row instead. */
.settings-tools {
	display: flex;
	flex-wrap: wrap;
	gap: 2px;
}

.settings-tools button {
	flex: none;
	white-space: nowrap;
}

.settings-tools button,
:is(.settings-reference, .settings-part) button {
	min-width: 22px;
	height: 22px;
	padding: 0 0.375rem;
	border: 1px solid transparent;
	border-radius: 2px;
	background: none;
	color: inherit;
	font: inherit;
	cursor: pointer;
}

.settings-tools button:hover,
:is(.settings-reference, .settings-part) button:hover {
	border-color: var(--oes-border);
	background: var(--oes-table-header-bg);
}

.settings-table {
	width: 100%;
	table-layout: fixed;
	border-collapse: collapse;
}

.settings-table th {
	position: sticky;
	top: 0;
	padding: 0 0.375rem;
	border-bottom: 1px solid var(--oes-table-border);
	background: var(--oes-table-header-bg);
	color: var(--oes-table-header-text);
	font-weight: 400;
	text-align: start;
	white-space: nowrap;
	/* A caption wider than its column — «Use» in a longer language — is cut as the thin client's header cuts it. */
	overflow: hidden;
	text-overflow: ellipsis;
}

.settings-table td {
	height: 22px;
	padding: 0 2px;
	overflow: hidden;
	border-bottom: 1px solid var(--oes-table-border);
	white-space: nowrap;
}

.settings-table td.use {
	text-align: center;
}

/* The root's and a group's join: beside its word, as wide as it needs. */
.settings-table .settings-join {
	display: flex;
	align-items: center;
	gap: 0.25rem;
}

.settings-table .settings-join select {
	width: auto;
}

.settings-table :is(input[type="text"], input[type="number"], input[type="datetime-local"], select) {
	width: 100%;
	height: 20px;
	padding: 0 2px;
	border: 1px solid transparent;
	background: transparent;
	color: inherit;
	font: inherit;
}

/* As a property's field (.property-cell): the table's ground, the editor's ink. */
.settings-table :is(input, select):focus {
	border-color: var(--oes-border);
	background: var(--oes-table-bg);
	color: var(--oes-editor-text);
	outline: none;
}

.settings-table input[type="checkbox"] {
	accent-color: var(--oes-accent);
}

/* A reference as it reads, and a part of a rule as it reads (a conditional appearance's) — each with its buttons. */
:is(.settings-reference, .settings-part) {
	display: flex;
	align-items: center;
	gap: 2px;
}

:is(.settings-reference, .settings-part) span {
	flex: 1;
	min-width: 6rem;
	overflow: hidden;
	text-overflow: ellipsis;
}

.settings-part span {
	min-width: 0;
	padding-inline-start: 0.25rem;
}

/* …or typed where it stands, the «…» beside it (a selected-fields group's title in every language). */
.settings-part input {
	flex: 1;
	min-width: 0;
}

.settings-part button {
	flex: none;
}

:is(.settings-reference, .settings-part) button {
	min-width: 20px;
	height: 20px;
	padding: 0;
}

/* A property grid (properties/propertyGrid.js, the thin client's ibPropertyGridManager): a line a property — its title
   and its cell halves of it, ruled as a table; the line taken in the highlight; a value changed and not applied bold;
   what the line taken is, under the lines. */
.property-grid {
	display: flex;
	flex-direction: column;
	min-height: 0;
	border: 1px solid var(--oes-border);
	background: var(--oes-table-bg);
	color: var(--oes-table-text);
}

.property-lines {
	flex: 1;
	min-height: 0;
	overflow: auto;
}

.property {
	display: grid;
	grid-template-columns: 1fr 1fr;
	min-height: 22px;
	border-bottom: 1px solid var(--oes-table-border);
}

.property-title {
	align-self: stretch;
	display: flex;
	align-items: center;
	padding: 0 0.375rem;
	overflow: hidden;
	white-space: nowrap;
	text-overflow: ellipsis;
	border-right: 1px solid var(--oes-table-border);
}

.property.taken .property-title {
	background: var(--oes-table-cell-current-bg);
	color: var(--oes-table-current-text);
}

.property.modified {
	font-weight: 600;
}

.property-cell {
	display: flex;
	align-items: center;
	gap: 2px;
	min-width: 0;
	padding: 0 2px;
}

.property-cell :is(input[type="text"], input[type="number"], select) {
	flex: 1;
	min-width: 0;
	height: 20px;
	padding: 0 2px;
	border: 1px solid transparent;
	background: transparent;
	color: inherit;
	font: inherit;
}

/* A field being typed in stands on the table's ground in the editor's ink, as the text editor does — not on paper, which
   is white whatever the theme. */
.property-cell :is(input[type="text"], input[type="number"], select):focus {
	border-color: var(--oes-border);
	background: var(--oes-table-bg);
	color: var(--oes-editor-text);
	outline: none;
}

.property-cell input[type="checkbox"] {
	accent-color: var(--oes-accent);
}

/* A font's choice, under its cell (the thin client's font dialog, in place): the face, the size, how it is drawn. */
.property-cell .font-choice {
	position: fixed;
	inset: auto;
	margin: 0;
	gap: 2px;
	width: 16rem;
	padding: 0.25rem;
	border: 1px solid var(--oes-border);
	background: var(--oes-panel-bg);
	color: var(--oes-text);
	box-shadow: 0 2px 8px var(--oes-shadow);
}

.property-cell .font-choice:popover-open {
	display: flex;
}

.property-cell .font-choice input[type="text"] {
	border-color: var(--oes-border);
}

.property-cell input.font-size {
	flex: 0 0 3.25rem;
	border-color: var(--oes-border);
}

.property-cell input[type="color"] {
	flex: 0 0 auto;
	width: 24px;
	height: 18px;
	padding: 0;
	border: 1px solid var(--oes-border);
	background: none;
}

.property-cell > span {
	flex: 1;
	min-width: 0;
	overflow: hidden;
	white-space: nowrap;
	text-overflow: ellipsis;
}

.property-cell.unset > span,
.property-text {
	color: var(--oes-muted);
}

.property-text {
	align-self: center;
	padding: 0 0.375rem;
}

.property-cell button {
	flex: 0 0 auto;
	width: 20px;
	height: 20px;
	padding: 0;
	border: 1px solid transparent;
	border-radius: 2px;
	background: none;
	color: inherit;
	font: inherit;
	cursor: pointer;
}

.property-cell button:hover:not(:disabled),
.property-cell button[aria-pressed="true"] {
	border-color: var(--oes-border);
	background: var(--oes-table-header-bg);
}

.property-cell button:disabled {
	opacity: 0.4;
	cursor: default;
}

/* By a class of its own, not its title — the title is said in the person's language. */
.property-cell .toggle.bold {
	font-weight: 700;
}

.property-cell .toggle.italic {
	font-style: italic;
}

.property-cell .toggle.underlined {
	text-decoration: underline;
}

.property-category > button {
	display: block;
	width: 100%;
	min-height: 22px;
	padding: 0 0.375rem;
	border: none;
	border-bottom: 1px solid var(--oes-table-border);
	background: var(--oes-table-header-bg);
	color: var(--oes-table-header-text);
	font: inherit;
	font-weight: 600;
	text-align: start;
	cursor: pointer;
}

.property-description {
	flex: 0 0 auto;
	min-height: 4.5rem;
	max-height: 6rem;
	overflow: auto;
	padding: 0.25rem 0.375rem;
	border-top: 1px solid var(--oes-border);
}

.property-description p {
	margin: 0.125rem 0 0;
}

/* Tools → Theme...: the three, one under the other. */
.themes {
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
}

/* About: the program beside the logo, the facts under a line, what the platform is built on under another — the thin
   client's window. */
.about {
	--width: 32rem;
}

.about .head {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	padding-bottom: 0.75rem;
	border-bottom: 1px solid var(--oes-border);
}

.about .logo {
	flex: none;
	width: 48px;
	height: 48px;
}

.about p {
	margin: 0;
}

.about .program {
	font-size: 1.3rem;
	font-weight: 600;
}

.about .purpose {
	margin-top: 0.25rem;
}

.about dl {
	display: grid;
	grid-template-columns: auto 1fr;
	gap: 2px 1rem;
	margin: 0;
	padding: 0.75rem 0;
	border-bottom: 1px solid var(--oes-border);
}

.about dd {
	margin: 0;
	min-width: 0;
	overflow-wrap: anywhere;
}

.about .credits {
	padding-top: 0.75rem;
}

.about .caption {
	font-weight: 600;
}

.about .origins,
.about .licence {
	margin-top: 0.5rem;
}

/* Tools → Options... — the assistant access, as the thin client's page: the setting, Start now beside what is true, then
   what is handed to the assistant — copied whole, so it is shown whole. */
.assistant {
	--width: 34rem;
}

.assistant p {
	margin: 0.5rem 0 0.25rem;
}

.assistant .run {
	display: flex;
	align-items: center;
	gap: 0.5rem;
}

.assistant .state {
	margin: 0;
	color: var(--oes-muted);
	white-space: pre-line;
}

.assistant fieldset {
	margin: 0.5rem 0 0;
	padding: 0.25rem 0.5rem 0.5rem;
	border: 1px solid var(--oes-border);
	border-radius: 4px;
}

.assistant legend {
	padding: 0 0.25rem;
	color: var(--oes-muted);
}

.assistant textarea {
	box-sizing: border-box;
	width: 100%;
	margin-bottom: 0.25rem;
	padding: 0.25rem;
	border: 1px solid var(--oes-border);
	border-radius: 4px;
	background: var(--oes-form-bg);
	color: var(--oes-form-text);
	font-family: ui-monospace, monospace;
	font-size: 0.85rem;
	resize: vertical;
	white-space: pre;
}

.assistant textarea.wrapped {
	white-space: pre-wrap;
	overflow-wrap: anywhere;
}

/* PRINTED — what the active tab shows, or the sheet a script asked to print (question 15), and nothing around it: the
   window's chrome is the screen's. (A sheet on paper: form.css.) */
.print-sheet {
	display: none;
}

@media print {
	html, body, #client {
		height: auto;
		background: #fff;
	}

	.client-window {
		display: block;
		height: auto;
	}

	.client-window > :not(.views),
	.command-bar,
	.popup-menu,
	.simple-choice,
	wa-dialog {
		display: none !important;
	}

	.views,
	oes-spreadsheet .sheet-host {
		overflow: visible;
	}

	body.printing > :not(.print-sheet) {
		display: none !important;
	}

	body.printing > .print-sheet {
		display: block;
	}
}
