/* regmgr UI in the iic tool design (iic-ui-design, reference: iso2p-web app.css).
   Colours, fonts and radius come from tokens.css; components never use raw hex. */

/* ══ base ══════════════════════════════════════════════════════════════════ */

* {
	box-sizing: border-box;
}

html,
body {
	margin: 0;
	min-height: 100%;
	background: var(--bg);
	color: var(--fg);
	font-family: var(--font-body);
	font-size: 14px;
	line-height: 1.45;
	-webkit-font-smoothing: antialiased;
}

a {
	color: inherit;
	text-decoration: underline;
	text-decoration-color: var(--border-control);
	text-underline-offset: 3px;
}

a:hover {
	text-decoration-color: var(--accent-line);
}

:focus-visible {
	outline: 2px solid var(--accent-line);
	outline-offset: 2px;
}

h1 {
	font: 700 17px/1.3 var(--font-display);
	margin: 0;
}

h2 {
	font: 700 16px/1.3 var(--font-display);
	text-transform: uppercase;
	letter-spacing: 0.06em;
	margin: 0;
}

code,
.mono {
	font-family: var(--mono);
	font-size: 12px;
	font-variant-numeric: tabular-nums;
}

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

.dim {
	color: var(--fg-dim);
}

.caption {
	font-size: 12px;
	color: var(--fg-muted);
}

/* ══ header ════════════════════════════════════════════════════════════════ */

body > header {
	display: flex;
	align-items: center;
	gap: 20px;
	padding: 10px 20px;
	background: var(--bg);
	border-bottom: 1px solid var(--border);
	flex-wrap: wrap;
}

.ident {
	display: flex;
	align-items: center;
	gap: 14px;
	text-decoration: none;
}

.logo {
	display: block;
	width: 36px;
	height: 28px;
	background: var(--fg);
	mask: url('/static/iic-logo.svg') center / contain no-repeat;
}

.ident .name {
	padding-left: 14px;
	border-left: 1px solid var(--border-control);
	line-height: 1.15;
}

.ident .name strong {
	display: block;
	font: 700 17px/1.2 var(--font-display);
}

nav {
	display: flex;
	gap: 22px;
	flex: 1;
	flex-wrap: wrap;
}

nav a {
	font: 700 11px/1 var(--font-display);
	letter-spacing: 0.14em;
	text-transform: uppercase;
	text-decoration: none;
	color: var(--fg-muted);
	padding: 6px 0 5px;
	border-bottom: 2px solid transparent;
}

nav a:hover,
nav a[aria-current] {
	color: var(--fg);
}

nav a[aria-current] {
	border-bottom-color: var(--accent-line);
}

.session {
	display: flex;
	align-items: center;
	gap: 12px;
	font-size: 12px;
	color: var(--fg-muted);
}

/* ══ page ══════════════════════════════════════════════════════════════════ */

main {
	max-width: 80rem;
	margin: 0 auto;
	padding: 24px;
	display: flex;
	flex-direction: column;
	gap: 32px;
}

section {
	display: flex;
	flex-direction: column;
	gap: 12px;
}

/* Flex children may shrink below their content, so wide lists scroll inside. */
main > *,
section > * {
	min-width: 0;
}

/* A section title, its one-line hint on the same baseline, actions at the right. */
.section-head {
	display: flex;
	align-items: baseline;
	gap: 16px;
	flex-wrap: wrap;
}

.section-head .hint {
	flex: 1;
	min-width: 16rem;
	font-size: 12px;
	color: var(--fg-muted);
}

.section-head .actions {
	display: flex;
	gap: 8px;
	margin-left: auto;
	align-self: center;
}

.back {
	font-size: 13px;
	color: var(--fg-muted);
}

/* Title line of a single item: name as written, its state, its machine string. */
.item-head {
	display: flex;
	align-items: center;
	gap: 16px;
	flex-wrap: wrap;
}

.facts {
	display: grid;
	grid-template-columns: max-content 1fr;
	gap: 6px 24px;
	margin: 0;
	font-size: 13px;
}

.facts dt {
	color: var(--fg-dim);
}

.facts dd {
	margin: 0;
	min-width: 0;
	word-break: break-all;
}

/* ══ problem strip ═════════════════════════════════════════════════════════ */

.problems {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 12px 24px;
	margin: -24px -24px 0;
	background: var(--bg-sunken);
	border-bottom: 1px solid var(--border);
	flex-wrap: wrap;
}

.problems .cause {
	font-size: 16px;
}

.problems .more {
	font-size: 12px;
	color: var(--fg-muted);
}

.problems form {
	margin-left: auto;
}

/* ══ buttons ═══════════════════════════════════════════════════════════════ */

button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	font: inherit;
	font-size: 13px;
	color: var(--fg);
	background: transparent;
	border: 1px solid var(--border-control);
	border-radius: var(--radius);
	padding: 4px 10px;
	min-height: 28px;
	cursor: pointer;
	white-space: nowrap;
	transition:
		border-color 0.12s,
		background-color 0.12s;
}

button:hover:not(:disabled) {
	border-color: var(--fg);
}

button:disabled {
	opacity: 0.45;
	cursor: default;
}

button.primary {
	color: var(--fg-on-fill);
	background: var(--accent);
	border-color: var(--accent);
	font: 700 11px/1.6 var(--font-display);
	letter-spacing: 0.1em;
	text-transform: uppercase;
	padding: 4px 12px;
}

button.danger {
	color: var(--danger);
}

button.danger:hover:not(:disabled) {
	border-color: var(--danger);
}

/* Filled actions exist only inside a confirmation dialog. */
button.fill-danger {
	color: var(--fg-on-fill);
	background: var(--danger);
	border-color: var(--danger);
}

button.fill-accent {
	color: var(--fg-on-fill);
	background: var(--accent);
	border-color: var(--accent);
}

button.ghost {
	border-color: transparent;
	color: var(--fg-muted);
	padding: 4px 6px;
}

button.ghost.danger:hover:not(:disabled) {
	color: var(--danger);
	border-color: transparent;
}

button.ghost svg {
	width: 14px;
	height: 14px;
	fill: none;
	stroke: currentColor;
	stroke-width: 1.5;
}

button.link {
	border: none;
	background: none;
	padding: 0;
	min-height: 0;
	color: inherit;
	font-size: inherit;
	text-decoration: underline;
	text-decoration-color: var(--border-control);
	text-underline-offset: 3px;
}

button.link:hover:not(:disabled) {
	text-decoration-color: var(--accent-line);
}

button.link.danger {
	color: var(--danger);
}

.htmx-request button {
	opacity: 0.6;
}

/* ══ fields ════════════════════════════════════════════════════════════════ */

input:not([type='checkbox']):not([type='hidden']),
select {
	font: inherit;
	font-size: 13px;
	color: var(--fg);
	background: var(--bg-raised);
	border: 1px solid var(--field-border);
	border-radius: var(--radius);
	padding: 4px 8px;
	min-height: 28px;
	min-width: 0;
}

input:focus,
select:focus {
	outline: none;
	border-color: var(--accent-line);
}

::placeholder {
	color: var(--fg-muted);
}

input[type='checkbox'] {
	accent-color: var(--iic-yellow);
	width: 14px;
	height: 14px;
	margin: 0;
}

label.tick {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	font-size: 13px;
}

/* ══ row lists ═════════════════════════════════════════════════════════════ */

.list {
	position: relative; /* keeps absolutely positioned (visually hidden) text inside the scroll box */
	background: var(--bg-sunken);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	overflow-x: auto;
}

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

.list th {
	font: 700 11px/1.8 var(--font-display);
	letter-spacing: 0.12em;
	text-transform: uppercase;
	color: var(--fg-dim);
	text-align: left;
	padding: 8px 16px;
	border-bottom: 1px solid var(--border);
	white-space: nowrap;
}

.list td {
	padding: 10px 16px;
	border-top: 1px solid var(--border-subtle);
	vertical-align: middle;
}

.list tr:first-child td {
	border-top: none;
}

.list td.lead {
	font-size: 16px;
}

.list td.lead small {
	display: block;
	font-size: 12px;
	color: var(--fg-muted);
}

.list td.row-actions {
	text-align: right;
	white-space: nowrap;
	width: 1%;
}

.list td.row-actions form {
	display: inline-flex;
	margin-left: 4px;
}

/* The last row: the form to add one. */
.list .add {
	display: flex;
	gap: 8px;
	align-items: center;
	flex-wrap: wrap;
	padding: 12px 16px;
	border-top: 1px solid var(--border);
}

.list .add .grow {
	flex: 1;
	min-width: 12rem;
}

.list .add .caption {
	flex-basis: 100%;
}

/* Machine strings in chips, e.g. tags. They keep their case. */
.chips {
	display: flex;
	flex-wrap: wrap;
	gap: 4px;
}

.chip {
	font: 12px/1.6 var(--mono);
	padding: 0 6px;
	border: 1px solid var(--border);
	border-radius: var(--radius);
	color: var(--fg-soft);
}

a.chip {
	text-decoration: none;
}

a.chip:hover {
	border-color: var(--fg);
}

.note {
	font-size: 12px;
	color: var(--fg-muted);
}

.empty {
	padding: 16px;
	margin: 12px 16px;
	border: 1px dashed var(--border-control);
	border-radius: var(--radius);
	color: var(--fg-muted);
}

/* ══ status ════════════════════════════════════════════════════════════════ */

.status {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	white-space: nowrap;
}

.mark {
	flex: none;
}

.mark-ok {
	fill: var(--ok);
}

.mark-warn {
	fill: var(--warn);
}

.mark-error {
	fill: var(--danger);
}

.mark-info circle {
	stroke: var(--fg-muted);
}

.mark-unknown circle {
	stroke: var(--fg-faint);
}

.status-warn {
	color: var(--warn);
}

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

.status-unknown {
	color: var(--fg-faint);
}

/* ══ messages ══════════════════════════════════════════════════════════════ */

.warning,
.error-box {
	font-size: 12px;
	margin: 0;
	padding: 6px 10px;
	border-radius: var(--radius);
	word-break: break-word;
}

.warning {
	color: var(--fg);
	border: 1px solid color-mix(in srgb, var(--warn) 55%, transparent);
	background: color-mix(in srgb, var(--warn) 8%, transparent);
}

.error-box {
	color: var(--danger);
	border: 1px solid color-mix(in srgb, var(--danger) 55%, transparent);
	background: color-mix(in srgb, var(--danger) 8%, transparent);
}

.warning p,
.error-box p {
	margin: 0 0 6px;
}

.warning p:last-child,
.error-box p:last-child {
	margin-bottom: 0;
}

.warning code.secret {
	font-size: 13px;
	color: var(--fg);
	user-select: all;
	word-break: break-all;
}

/* "Details" disclosures under a message; folds are styled on their own. */
details:not(.fold) {
	margin-top: 6px;
	font-size: 12px;
	color: var(--fg-muted);
}

details:not(.fold) summary {
	cursor: pointer;
}

details:not(.fold) code {
	display: block;
	margin-top: 4px;
	white-space: pre-wrap;
	word-break: break-word;
}

.toasts {
	position: fixed;
	right: 16px;
	bottom: 16px;
	z-index: 20;
	display: flex;
	flex-direction: column;
	gap: 8px;
	max-width: min(32rem, calc(100vw - 32px));
}

.toast {
	font-size: 13px;
	padding: 8px 12px;
	border-radius: var(--radius);
	color: var(--fg);
	background: color-mix(in srgb, var(--ok) 10%, var(--bg));
	border: 1px solid color-mix(in srgb, var(--ok) 60%, transparent);
	box-shadow: 0 6px 24px rgb(0 0 0 / 0.35);
	transition: opacity 0.3s;
}

.toast.gone {
	opacity: 0;
}

/* ══ folds ═════════════════════════════════════════════════════════════════ */

.folds {
	border: 1px solid var(--border);
	border-radius: var(--radius);
	background: var(--bg-sunken);
}

.fold {
	margin: 0;
	color: var(--fg);
	font-size: 14px;
}

.fold + .fold {
	border-top: 1px solid var(--border);
}

.fold > summary {
	display: flex;
	align-items: center;
	gap: 10px;
	min-height: 44px;
	padding: 0 16px;
	list-style: none;
	cursor: pointer;
}

.fold > summary::-webkit-details-marker {
	display: none;
}

.fold > summary::before {
	content: '';
	width: 6px;
	height: 6px;
	border-right: 1.5px solid var(--fg-muted);
	border-bottom: 1.5px solid var(--fg-muted);
	transform: rotate(-45deg);
	transition: transform 0.15s;
}

.fold[open] > summary::before {
	transform: rotate(45deg);
}

.fold > summary .title {
	font: 700 13px/1 var(--font-display);
	letter-spacing: 0.1em;
	text-transform: uppercase;
}

.fold > summary .summary {
	margin-left: auto;
	font-size: 12px;
	color: var(--fg-muted);
}

.fold > .body {
	padding: 4px 16px 16px 32px;
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.inline-form {
	display: flex;
	gap: 8px;
	align-items: center;
	flex-wrap: wrap;
}

.inline-form .grow {
	flex: 1;
	min-width: 12rem;
}

/* ══ confirmation dialog ═══════════════════════════════════════════════════ */

dialog.confirm {
	width: min(32rem, calc(100vw - 32px));
	padding: 0;
	color: var(--fg);
	background: var(--bg-raised);
	border: 1px solid var(--border-control);
	border-radius: var(--radius);
	box-shadow: 0 8px 24px rgb(0 0 0 / 0.5);
}

dialog.confirm::backdrop {
	background: var(--scrim);
}

dialog.confirm .inner {
	padding: 20px 24px;
	display: flex;
	flex-direction: column;
	gap: 12px;
}

dialog.confirm .subject {
	font: 14px/1.4 var(--mono);
	word-break: break-all;
	margin: 0;
}

dialog.confirm .body {
	margin: 0;
	color: var(--fg-soft);
}

dialog.confirm .buttons {
	display: flex;
	justify-content: flex-end;
	gap: 8px;
	margin-top: 8px;
}

dialog.confirm .buttons button {
	min-height: 36px;
	padding: 4px 16px;
}

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

.signin {
	width: min(24rem, 100%);
	margin: 10vh auto 0;
	padding: 20px 24px;
	background: var(--bg-raised);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	display: flex;
	flex-direction: column;
	gap: 16px;
}

.signin form {
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.signin label {
	display: flex;
	flex-direction: column;
	gap: 4px;
	font-size: 12px;
	color: var(--fg-muted);
}

.signin button.primary {
	min-height: 36px;
}

/* ══ small screens ═════════════════════════════════════════════════════════ */

@media (max-width: 700px) {
	main {
		padding: 16px;
	}

	.problems {
		margin: -16px -16px 0;
		padding: 12px 16px;
	}

	.section-head .hint {
		display: none;
	}

	nav {
		order: 3;
		flex-basis: 100%;
	}

	.list td.row-actions {
		white-space: normal;
	}
}

@media (pointer: coarse) {
	button {
		min-height: 44px;
	}
}

.visually-hidden {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
}

/* ══ help ══════════════════════════════════════════════════════════════════ */

/* "?" in the info ring; its explanation floats next to it (positioned by app.js,
   since it must escape scrolling lists). */
.help {
	display: inline-flex;
	vertical-align: middle;
	margin-left: 6px;
}

.help-mark {
	width: 16px;
	height: 16px;
	min-height: 0;
	padding: 0;
	border: 1.5px solid var(--fg-muted);
	border-radius: 50%;
	color: var(--fg-muted);
	font: 700 11px/1 var(--font-display);
	letter-spacing: 0;
	text-transform: none;
}

.help-mark:hover:not(:disabled),
.help-mark[aria-expanded='true'] {
	border-color: var(--fg);
	color: var(--fg);
}

.tip {
	display: none;
	position: fixed;
	z-index: 30;
	width: max-content;
	max-width: min(26rem, calc(100vw - 32px));
	padding: 10px 14px;
	background: var(--bg-raised);
	border: 1px solid var(--border-control);
	border-radius: var(--radius);
	box-shadow: 0 8px 24px rgb(0 0 0 / 0.5);
	color: var(--fg-soft);
	font: 400 13px/1.5 var(--font-body);
	letter-spacing: normal;
	text-transform: none;
	text-align: left;
	white-space: normal;
}

.tip.open {
	display: block;
}

.tip p,
.tip ul {
	margin: 0 0 8px;
}

.tip p:last-child,
.tip ul:last-child {
	margin-bottom: 0;
}

.tip ul {
	padding-left: 18px;
}

.tip li + li {
	margin-top: 4px;
}

.tip b {
	color: var(--fg);
	font-weight: 700;
}

@media (pointer: coarse) {
	.help-mark {
		width: 24px;
		height: 24px;
		min-height: 0;
	}
}

/* ══ editing a row in place ════════════════════════════════════════════════ */

.icon-link {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 4px 6px;
	min-height: 28px;
	color: var(--fg-muted);
	border: 1px solid transparent;
	border-radius: var(--radius);
	vertical-align: middle;
}

.icon-link:hover {
	color: var(--fg);
	border-color: var(--border-control);
}

.icon-link svg {
	width: 14px;
	height: 14px;
	fill: none;
	stroke: currentColor;
	stroke-width: 1.5;
}

/* The row being edited is the current one: yellow tint, 2px yellow left edge. */
.list tr.editing td {
	background: var(--current);
	vertical-align: top;
}

.list tr.editing td:first-child {
	box-shadow: inset 2px 0 var(--accent-line);
}

.list tr.editing input,
.list tr.editing select {
	width: 100%;
}

.cell-fields {
	display: flex;
	flex-wrap: wrap;
	gap: 6px 12px;
	align-items: center;
}

.list tr.editing .cell-fields input:not([type='checkbox']),
.list tr.editing .cell-fields select {
	width: auto;
	flex: 1;
	min-width: 8rem;
}

.list tr.editing .error-box {
	margin-bottom: 8px;
}

.list td.row-actions a {
	margin-left: 8px;
	font-size: 13px;
}

.list td.row-actions a.icon-link {
	margin-left: 4px;
}

/* ══ search field with suggestions (combobox) ══════════════════════════════ */

.combo {
	display: flex;
	min-width: 12rem;
}

.combo input {
	flex: 1;
}

/* Floats over the page like a menu; app.js places it under its field. */
.suggestions {
	display: none;
	position: fixed;
	z-index: 25;
	margin: 0;
	padding: 4px 0;
	list-style: none;
	max-height: 18rem;
	overflow-y: auto;
	background: var(--bg-sunken);
	border: 1px solid var(--border-control);
	border-radius: var(--radius);
	box-shadow: 0 4px 18px rgb(0 0 0 / 0.6);
}

.suggestions.open {
	display: block;
}

.suggestions li {
	display: flex;
	align-items: baseline;
	gap: 10px;
	padding: 6px 12px;
	font-size: 13px;
	cursor: pointer;
}

.suggestions li[aria-selected='true'],
.suggestions li[role='option']:hover {
	background: var(--current);
	box-shadow: inset 2px 0 var(--accent-line);
}

.suggestions li.none {
	cursor: default;
	color: var(--fg-muted);
	font-size: 12px;
}

/* ══ repository index ══════════════════════════════════════════════════════ */

.stack {
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.fold.repo > summary {
	min-height: 40px;
}

.fold.repo .repo-name {
	font-size: 13px;
	word-break: break-all;
}

.fold.repo > .body {
	padding-left: 16px;
}

.list th.num,
.list td.num {
	text-align: right;
}
