:root {
	--bg: #faf8f5;
	--surface: #ffffff;
	--text: #22201d;
	--muted: #6b655d;
	--accent: #9a4a2c;
	--border: #e3ded6;
	--error: #a3262a;
	color-scheme: light;
}

@media (prefers-color-scheme: dark) {
	:root {
		--bg: #1a1917;
		--surface: #242220;
		--text: #eeeae4;
		--muted: #a59d92;
		--accent: #e08a62;
		--border: #3a3733;
		--error: #f07a72;
		color-scheme: dark;
	}
}

* {
	box-sizing: border-box;
}

/* The hidden attribute always wins over display rules below. */
[hidden] {
	display: none !important;
}

body {
	margin: 0;
	background: var(--bg);
	color: var(--text);
	font: 16px/1.5 system-ui, -apple-system, 'Segoe UI', sans-serif;
}

main {
	max-width: 40rem;
	margin: 0 auto;
	padding: 3rem 1rem;
}

h1 {
	font-size: 1.75rem;
	line-height: 1.2;
	margin: 0 0 0.5rem;
}

h2 {
	font-size: 1.2rem;
	margin: 0 0 0.75rem;
}

.muted {
	color: var(--muted);
}

a {
	color: var(--accent);
}

.card {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: 8px;
	padding: 1.25rem;
	margin: 1.5rem 0;
}

label {
	display: block;
	font-weight: 600;
	margin-bottom: 0.25rem;
}

input:not([type='checkbox']):not([type='radio']),
select,
textarea {
	width: 100%;
	font: inherit;
	padding: 0.6rem 0.75rem;
	border: 1px solid var(--border);
	border-radius: 6px;
	background: var(--bg);
	color: var(--text);
}

button {
	font: inherit;
	font-weight: 600;
	padding: 0.6rem 1.1rem;
	margin-top: 0.75rem;
	border: 0;
	border-radius: 6px;
	background: var(--accent);
	color: #fff;
	cursor: pointer;
}

button.secondary {
	background: transparent;
	color: var(--accent);
	border: 1px solid var(--border);
}

.error {
	color: var(--error);
}

ul.plain {
	list-style: none;
	padding: 0;
	margin: 0;
}

ul.plain li {
	padding: 0.5rem 0;
	border-bottom: 1px solid var(--border);
}

main.wide {
	max-width: 72rem;
}

h2 {
	margin-top: 2rem;
}

.mono {
	font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
	letter-spacing: 0.02em;
}

label {
	margin-top: 0.75rem;
}

.row {
	display: flex;
	gap: 0.75rem;
	flex-wrap: wrap;
}

.row > div {
	flex: 1 1 8rem;
}

a.button,
label.button {
	display: inline-block;
	font-weight: 600;
	padding: 0.6rem 1.1rem;
	border-radius: 6px;
	background: var(--accent);
	color: #fff;
	text-decoration: none;
	cursor: pointer;
	margin: 0;
}

label.button.secondary {
	background: transparent;
	color: var(--accent);
	border: 1px solid var(--border);
}

.notice,
.notice-inline {
	color: var(--muted);
}

.notice-inline {
	margin-left: 0.75rem;
}

/* Studio header */
.studio-nav {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 1rem;
	padding: 0.75rem 1rem;
	border-bottom: 1px solid var(--border);
	background: var(--surface);
}

.studio-nav a {
	text-decoration: none;
}

.studio-name {
	font-weight: 700;
	color: var(--text);
}

.studio-nav nav {
	display: flex;
	gap: 1.25rem;
}

/* Dashboard */
.stats {
	display: flex;
	gap: 1rem;
	flex-wrap: wrap;
}

.stat {
	display: flex;
	flex-direction: column;
	min-width: 10rem;
	margin: 0.5rem 0;
}

.stat-value {
	font-size: 1.75rem;
	font-weight: 700;
}

/* Works grid */
.work-grid {
	list-style: none;
	padding: 0;
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr));
	gap: 1rem;
}

.work-grid a {
	display: flex;
	flex-direction: column;
	gap: 0.25rem;
	color: var(--text);
	text-decoration: none;
}

.work-grid img,
.no-image {
	width: 100%;
	aspect-ratio: 1;
	object-fit: contain;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: 6px;
}

.no-image {
	display: grid;
	place-items: center;
	color: var(--muted);
	font-size: 0.85rem;
}

.work-title {
	color: var(--muted);
	font-size: 0.9rem;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.pager {
	display: flex;
	gap: 1.5rem;
}

/* Capture station: big targets for a phone on a copy stand */
.big-button {
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 7rem;
	margin: 1rem 0;
	border-radius: 12px;
	background: var(--accent);
	color: #fff;
	font-size: 1.4rem;
	font-weight: 700;
	text-align: center;
	cursor: pointer;
}

.capture.busy .big-button,
.capture.busy label.button {
	opacity: 0.5;
	pointer-events: none;
}

.status {
	min-height: 1.5em;
}

progress {
	width: 100%;
}

.result .artwork-id {
	font-size: 2.5rem;
	font-weight: 700;
	margin: 0 0 0.5rem;
}

.result img {
	max-width: 12rem;
	border-radius: 6px;
	border: 1px solid var(--border);
}

.result [data-result-link] {
	margin-left: 1rem;
}

/* Work page */
.work-layout {
	display: grid;
	grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
	gap: 2rem;
	align-items: start;
}

@media (max-width: 760px) {
	.work-layout {
		grid-template-columns: 1fr;
	}
}

.image-list {
	list-style: none;
	padding: 0;
	margin: 0;
	display: grid;
	gap: 1rem;
}

.image-list img {
	width: 100%;
	border-radius: 6px;
	border: 1px solid var(--border);
	background: var(--surface);
}

.work-form {
	margin-top: 0;
}

details.danger {
	margin-top: 1rem;
}

details.danger summary {
	color: var(--error);
	cursor: pointer;
}

.danger-button {
	background: var(--error);
}

fieldset.dimensions {
	border: 1px solid var(--border);
	border-radius: 6px;
	margin: 1rem 0 0;
	padding: 0.25rem 0.75rem 0.75rem;
}

fieldset.dimensions legend {
	font-weight: 600;
	padding: 0 0.25rem;
}

fieldset.dimensions .row > div {
	flex: 1 1 4rem;
}

/* Live camera on the capture station */
button.big-button {
	width: 100%;
	border: 0;
	font-family: inherit;
}

.camera video {
	display: block;
	width: 100%;
	max-height: 60vh;
	object-fit: contain;
	background: #000;
	border-radius: 12px;
	transition: opacity 0.15s;
}

.camera.flash video {
	opacity: 0.2;
}

.camera .big-button {
	margin-top: 0.75rem;
}

.camera-controls {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.75rem;
}

.camera-controls select {
	flex: 1 1 12rem;
	width: auto;
}

.camera-controls button {
	margin-top: 0;
}

/* Labels */
.ok {
	color: #2f7a3a;
	font-weight: 600;
}

@media (prefers-color-scheme: dark) {
	.ok {
		color: #7cc98a;
	}
}

button.link-button {
	background: none;
	color: var(--accent);
	padding: 0;
	margin-top: 0.25rem;
	font-weight: 400;
	text-decoration: underline;
}

ol.hint {
	padding-left: 1.25rem;
}

ol.hint li {
	margin: 0.35rem 0;
}

label.choice {
	display: block;
	font-weight: 400;
	margin: 0.35rem 0;
}

.label-queue {
	list-style: none;
	padding: 0;
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(7rem, 1fr));
	gap: 0.75rem;
}

.label-queue li {
	display: flex;
	flex-direction: column;
	font-size: 0.85rem;
}

.label-queue img,
.label-queue .no-image {
	width: 100%;
	aspect-ratio: 1;
	object-fit: contain;
	border: 1px solid var(--border);
	border-radius: 6px;
	background: var(--surface);
}

/* First-unused-label picker: a miniature 4 × 5 sheet */
.sheet-picker {
	border: 0;
	padding: 0;
	margin: 0;
}

.sheet-picker legend {
	font-weight: 600;
	margin-bottom: 0.5rem;
}

.sheet-grid {
	display: grid;
	grid-template-columns: repeat(4, 3.25rem);
	gap: 0.3rem;
	padding: 0.5rem;
	border: 1px solid var(--border);
	border-radius: 6px;
	width: max-content;
	background: var(--bg);
}

.sheet-grid .cell {
	margin: 0;
	position: relative;
}

.sheet-grid input {
	position: absolute;
	opacity: 0;
	inset: 0;
	width: 100%;
	height: 100%;
	cursor: pointer;
}

.sheet-grid span {
	display: grid;
	place-items: center;
	height: 3.25rem;
	border: 1px solid var(--border);
	border-radius: 4px;
	background: var(--surface);
	font-weight: 600;
}

.sheet-grid input:checked + span {
	background: var(--accent);
	color: #fff;
	border-color: var(--accent);
}

.sheet-grid input:focus-visible + span {
	outline: 2px solid var(--accent);
	outline-offset: 2px;
}

/* Reconcile grid: same layout as the printed sheet */
ol.reconcile {
	list-style: none;
	padding: 0;
	display: grid;
	grid-template-columns: repeat(4, minmax(0, 1fr));
	gap: 0.75rem;
}

ol.reconcile .cell {
	position: relative;
	display: flex;
	flex-direction: column;
	gap: 0.15rem;
	padding: 0.6rem;
	border: 1px solid var(--border);
	border-radius: 8px;
	background: var(--surface);
	font-size: 0.9rem;
	min-width: 0;
}

ol.reconcile .cell.empty {
	background: transparent;
	border-style: dashed;
	justify-content: center;
	min-height: 6rem;
}

ol.reconcile .cell.attached {
	border-color: #2f7a3a;
}

ol.reconcile .cell.spoiled {
	opacity: 0.55;
}

ol.reconcile .pos {
	position: absolute;
	top: 0.35rem;
	right: 0.5rem;
	font-size: 0.75rem;
	color: var(--muted);
	font-weight: 600;
}

ol.reconcile img,
ol.reconcile .no-image {
	width: 100%;
	aspect-ratio: 1;
	object-fit: contain;
	border-radius: 4px;
	background: var(--bg);
}

ol.reconcile .id {
	font-weight: 700;
	font-size: 1rem;
}

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

.cell-actions {
	display: flex;
	align-items: baseline;
	gap: 0.75rem;
	flex-wrap: wrap;
}

.cell-actions button {
	margin-top: 0.4rem;
	padding: 0.35rem 0.8rem;
}

@media (max-width: 700px) {
	ol.reconcile {
		grid-template-columns: 1fr;
	}

	ol.reconcile .cell {
		display: grid;
		grid-template-columns: 4.5rem 1fr;
		column-gap: 0.75rem;
	}

	ol.reconcile .cell > a {
		grid-row: span 6;
	}

	ol.reconcile .cell.empty {
		display: flex;
		min-height: 0;
	}
}

.label-box p {
	margin: 0.4rem 0;
}

.place-tile {
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	background: repeating-linear-gradient(45deg, var(--surface), var(--surface) 8px, var(--bg) 8px, var(--bg) 16px);
}

/* Locations */
.loc-tree {
	list-style: none;
	padding: 0;
}

.loc-tree li {
	padding: 0.4rem 0;
	border-bottom: 1px solid var(--border);
	display: flex;
	gap: 0.6rem;
	align-items: baseline;
	flex-wrap: wrap;
}

.loc-tree .d1 { padding-left: 1.25rem; }
.loc-tree .d2 { padding-left: 2.5rem; }
.loc-tree .d3 { padding-left: 3.75rem; }
.loc-tree .d4 { padding-left: 5rem; }
.loc-tree .d5,
.loc-tree .d6 { padding-left: 6.25rem; }

.capture-location {
	margin-bottom: 0.5rem;
}

.history li {
	font-size: 0.9rem;
}

.label-box details {
	margin-top: 0.5rem;
}

.label-box details form {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	align-items: center;
}

.label-box details select,
.label-box details input {
	flex: 1 1 10rem;
	width: auto;
}

.notice-card p {
	margin: 0.25rem 0;
}

/* Desk: works list */
.row > div.grow,
.row > div.wide-field {
	flex: 3 1 16rem;
}

.small {
	font-size: 0.8rem;
}

.filters {
	margin-top: 0.5rem;
}

.filters .row > div {
	flex: 1 1 10rem;
}

.list-summary {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	flex-wrap: wrap;
}

.work-grid li {
	position: relative;
}

.work-grid .pick {
	position: absolute;
	top: 0.35rem;
	left: 0.35rem;
	margin: 0;
	z-index: 1;
	background: var(--surface);
	border-radius: 4px;
	padding: 0.15rem 0.3rem;
	box-shadow: 0 0 0 1px var(--border);
}

.work-grid .pick input {
	width: 1.1rem;
	height: 1.1rem;
	margin: 0;
	vertical-align: middle;
}

.bulk-bar .row > div {
	flex: 1 1 12rem;
}

/* Desk: work page */
.queue-nav {
	display: flex;
	flex-wrap: wrap;
	gap: 1rem;
	align-items: baseline;
	margin: 0.5rem 0 1rem;
}

.field-group {
	border: 0;
	border-top: 1px solid var(--border);
	padding: 0.5rem 0 0.75rem;
	margin: 0;
}

.field-group:first-of-type {
	border-top: 0;
	padding-top: 0;
}

.field-group legend {
	font-weight: 700;
	font-size: 0.8rem;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	color: var(--muted);
	padding: 0.75rem 0 0;
}

.field-group .row > div {
	flex: 1 1 6.5rem;
}

.field-group .row > div.flag {
	flex: 0 0 auto;
	display: flex;
	flex-direction: column;
}

.field-group .flag input[type='checkbox'] {
	width: 1.25rem;
	height: 1.25rem;
	margin-top: 0.6rem;
}

.hint {
	display: block;
	font-size: 0.8rem;
	color: var(--muted);
	margin-top: 0.2rem;
}

.save-bar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.75rem;
	position: sticky;
	bottom: 0;
	background: var(--surface);
	padding: 0.5rem 0;
}

.save-bar .hint {
	flex-basis: 100%;
	margin: 0;
}

.conflict {
	border-color: var(--error);
}

.inline-form {
	display: inline;
	margin-left: 0.5rem;
}

.inline-form button {
	padding: 0.2rem 0.6rem;
	margin: 0;
}

input[type='checkbox'],
input[type='radio'] {
	width: auto;
	accent-color: var(--accent);
}

label.choice input {
	margin-right: 0.35rem;
}

details.more-filters > summary,
details.bulk-bar > summary {
	cursor: pointer;
	color: var(--accent);
	margin: 0.5rem 0;
}

details.bulk-bar {
	padding: 0.5rem 1.25rem;
}

details.bulk-bar[open] {
	padding-bottom: 1.25rem;
}

/* ---- masters and uploads (M2b) */

.title-row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	flex-wrap: wrap;
}

.image-list li {
	display: grid;
	gap: 0.35rem;
}

.image-list li.is-master img,
.image-list li.is-master .no-preview {
	border-color: var(--accent);
	border-width: 2px;
}

.image-meta {
	display: flex;
	flex-direction: column;
	gap: 0.1rem;
}

.image-meta .inline-form {
	margin-left: 0;
}

.image-meta button.link-button {
	margin: 0;
	font-size: inherit;
}

.no-preview {
	aspect-ratio: 4 / 3;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 0.25rem;
	border: 1px dashed var(--border);
	border-radius: 6px;
	background: var(--surface);
	color: var(--muted);
}

.drop-zone {
	display: block;
	padding: 1.5rem 1rem;
	border: 2px dashed var(--border);
	border-radius: 8px;
	text-align: center;
	color: var(--muted);
	cursor: pointer;
}

.drop-zone.over {
	border-color: var(--accent);
	color: var(--text);
}

.upload-table {
	width: 100%;
	border-collapse: collapse;
	margin-top: 1rem;
	font-size: 0.95rem;
}

.upload-table th,
.upload-table td {
	text-align: left;
	vertical-align: top;
	padding: 0.5rem 0.4rem;
	border-bottom: 1px solid var(--border);
	overflow-wrap: anywhere;
}

.upload-table select {
	width: auto;
}

.upload-work img {
	float: left;
	width: 48px;
	height: 48px;
	object-fit: cover;
	border-radius: 4px;
	margin-right: 0.5rem;
}

.upload-table tr.skipped {
	opacity: 0.65;
}

.error-text {
	color: var(--error);
}

.ok-text {
	color: var(--accent);
}

@media (max-width: 600px) {
	.upload-work img {
		display: none;
	}
}

/* ---- activity log (M2c) */

.history ol.log {
	list-style: none;
	padding: 0;
	margin: 0.75rem 0 0;
	display: grid;
	gap: 0.6rem;
}

.log-lines {
	margin: 0;
	padding-left: 1.1rem;
}

.log-table {
	width: 100%;
	border-collapse: collapse;
}

.log-table th,
.log-table td {
	text-align: left;
	vertical-align: top;
	padding: 0.5rem 0.4rem;
	border-bottom: 1px solid var(--border);
	overflow-wrap: anywhere;
}

.nowrap {
	white-space: nowrap;
}

@media (max-width: 700px) {
	.log-table thead {
		display: none;
	}
	.log-table tr {
		display: grid;
		padding: 0.5rem 0;
		border-bottom: 1px solid var(--border);
	}
	.log-table td {
		border: 0;
		padding: 0.1rem 0;
	}
}

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

.map-table select {
	min-width: 12rem;
}

input[type='color'] {
	width: 4.5rem;
	height: 2.6rem;
	padding: 0.2rem;
	cursor: pointer;
}

/* ---- inquiries (M3b) */

.inquiry-list {
	list-style: none;
	padding: 0;
	margin: 0.75rem 0 0;
	display: grid;
	gap: 1rem;
}

.inquiry.is-new {
	border-left: 4px solid var(--accent);
}

.inquiry-head {
	display: flex;
	flex-wrap: wrap;
	gap: 0.25rem 0.75rem;
	align-items: baseline;
	margin-top: 0;
}

.inquiry-message {
	white-space: normal;
	overflow-wrap: anywhere;
}

.tabs {
	display: flex;
	gap: 1.25rem;
	margin-bottom: 1rem;
}

.tabs a[aria-current='page'] {
	font-weight: 600;
	text-decoration-thickness: 2px;
}

/* ---- domains (M3c) */

.domain h2 {
	margin: 0;
	font-size: 1.15rem;
	overflow-wrap: anywhere;
}

.domain .row form {
	margin: 0;
}

.dns-records td {
	user-select: all;
}

.dns-records th,
.dns-records td:first-child {
	overflow-wrap: normal;
	white-space: nowrap;
}

/* ---- loans, consignments, exhibitions (M4b) */

ul.placed,
ul.exhibited {
	list-style: none;
	padding: 0;
	margin: 0.5rem 0 1rem;
	display: grid;
	gap: 0.6rem;
}

ul.exhibited li {
	display: grid;
	grid-template-columns: 56px 1fr;
	gap: 0.75rem;
	align-items: center;
}

ul.exhibited img,
ul.exhibited .no-image {
	width: 56px;
	height: 56px;
	object-fit: cover;
	border-radius: 4px;
	font-size: 0.6rem;
}

.exhibited-row {
	display: flex;
	flex-wrap: wrap;
	gap: 0.4rem 0.75rem;
	align-items: center;
}

.exhibited-row input:not([type='checkbox']) {
	width: auto;
	padding: 0.25rem 0.4rem;
}

.exhibited-row button {
	padding: 0.25rem 0.7rem;
	margin: 0;
}

/* ---- products and orders (M4c) */

ul.variants {
	list-style: none;
	padding: 0;
	margin: 0;
	display: grid;
	gap: 1rem;
}

.order-lines {
	width: 100%;
	border-collapse: collapse;
	margin: 0.75rem 0;
}

.order-lines td,
.order-lines th {
	text-align: left;
	padding: 0.25rem 0.4rem 0.25rem 0;
	font-weight: 400;
}

.order-lines select {
	width: 100%;
}

.order-lines input {
	width: auto;
}

/* ---- members (M5a) */

.visually-hidden {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
}

.member-list {
	list-style: none;
	padding: 0;
	margin: 0 0 1rem;
	display: grid;
	gap: 0.75rem;
}

.member-list form {
	margin: 0;
}

.role-help {
	margin: 0.5rem 0;
	padding-left: 1.1rem;
}

/* ---- platform admin (M5b) */

.admin-nav {
	display: flex;
	flex-wrap: wrap;
	gap: 0.4rem 1.1rem;
	margin-bottom: 1rem;
	font-size: 0.95rem;
}

.log-table th {
	overflow-wrap: normal;
	white-space: nowrap;
}
