*,
*::before,
*::after {
	box-sizing: border-box;
	margin: 0;
	padding: 0;
}
:root {
	--bg: #0f1117;
	--surface: #1a1d27;
	--border: #2d3148;
	--accent: #f6921e;
	--text: #e2e8f0;
	--muted: #94a3b8;
	--success: #10b981;
	--error: #f87171;
}

/* Tema claro: os MESMOS oito tokens com outros valores.
   Todo o CSS destas páginas passa por eles, logo nada mais muda. O escuro fica acima e continua a
   ser o que se vê sem escolha feita.
   O laranja da marca escurece porque o tom claro sobre fundo claro deixa de se ler — a matiz é a
   mesma. */
:root[data-theme="light"] {
	--bg: #f5f6f8;
	--surface: #ffffff;
	--border: #d7dae3;
	--accent: #c2710a;
	--text: #1a1d27;
	--muted: #5b6577;
	--success: #047857;
	--error: #b91c1c;
}
html {
	/* Reserva o espaço da barra de deslocamento sempre: sem isto a página salta na horizontal
	   quando uma resposta cresce e a barra aparece. */
	scrollbar-gutter: stable;
}
html,
body {
	min-height: 100%;
	background: var(--bg);
	color: var(--text);
	font-family: "Segoe UI", system-ui, sans-serif;
	font-size: 14px;
}
.app {
	width: 100%;
	max-width: 1040px;
	margin: 0 auto;
	padding: 0 20px 60px;
}

/* Header */
header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 16px 0;
	border-bottom: 1px solid var(--border);
	position: sticky;
	top: 0;
	background: var(--bg);
	z-index: 3;
}
h1 {
	font-size: 18px;
	font-weight: 600;
	color: var(--accent);
}
h1 small {
	color: var(--muted);
	font-weight: 400;
	font-size: 13px;
}
.head-controls {
	display: flex;
	align-items: center;
	gap: 10px;
}
.badge {
	font-size: 12px;
	color: var(--muted);
}
.badge b {
	color: var(--text);
}
/* Header active-dataset picker: selecting an option switches immediately (no button). */
.ds-picker {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	font-size: 12px;
	color: var(--muted);
}
.ds-picker select {
	width: auto;
	max-width: 220px;
	padding: 6px 8px;
	font-size: 12px;
}
/* `button.link` ao lado do `a.link`: os controlos do cabeçalho eram todos ligações, e o primeiro
   botão a entrar aqui saía com o aspecto nativo do browser — uma caixa branca no meio de chips
   escuros. O `font: inherit` é o que faltava: um <button> não herda a família da fonte. */
a.link,
button.link,
.icon-btn {
	background: transparent;
	border: 1px solid var(--border);
	color: var(--text);
	font: inherit;
	height: 36px;
	padding: 0 12px;
	border-radius: 6px;
	cursor: pointer;
	font-size: 13px;
	display: inline-flex;
	align-items: center;
	gap: 6px;
	text-decoration: none;
}
a.link:hover,
button.link:hover,
.icon-btn:hover {
	border-color: var(--accent);
}

.panel {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: 10px;
	padding: 18px;
	margin-top: 18px;
}
.panel > h2 {
	font-size: 15px;
	font-weight: 600;
	margin-bottom: 4px;
}
.panel > .hint {
	margin-bottom: 14px;
}
.hint {
	font-size: 12px;
	color: var(--muted);
	line-height: 1.5;
}
.hint a {
	color: var(--accent);
}

.field {
	display: flex;
	flex-direction: column;
	gap: 6px;
	margin-bottom: 12px;
}
label {
	font-size: 12px;
	color: var(--muted);
}
input[type="text"],
input[type="password"],
input[type="number"],
input[type="search"],
textarea,
select {
	width: 100%;
	background: var(--bg);
	border: 1px solid var(--border);
	border-radius: 6px;
	color: var(--text);
	font-family: inherit;
	font-size: 13px;
	padding: 10px 12px;
	outline: none;
}
textarea {
	resize: vertical;
	min-height: 64px;
	line-height: 1.5;
}
input:focus,
textarea:focus,
select:focus {
	border-color: var(--accent);
}
input[type="file"] {
	color: var(--muted);
	font-size: 12px;
	padding: 8px;
}
input[type="file"]::file-selector-button {
	background: transparent;
	border: 1px solid var(--border);
	border-radius: 6px;
	color: var(--text);
	font-family: inherit;
	font-size: 12px;
	padding: 6px 10px;
	margin-right: 10px;
	cursor: pointer;
}
.row {
	display: flex;
	gap: 8px;
	align-items: flex-end;
}
.row > * {
	flex: 1;
}
.grid3 {
	display: grid;
	grid-template-columns: 1fr 1fr 1fr;
	gap: 10px;
}

.grid2 {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 10px;
}
/* Reveal-on-demand "add a site" sub-form inside the ingest panel. */
.subform {
	border: 1px solid var(--border);
	border-radius: 8px;
	padding: 14px;
	margin-bottom: 12px;
}
.subform.hidden {
	display: none;
}

button.btn {
	background: var(--accent);
	border: none;
	border-radius: 6px;
	color: #fff;
	cursor: pointer;
	font-family: inherit;
	font-size: 13px;
	font-weight: 600;
	padding: 10px 14px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	white-space: nowrap;
}
button.btn.secondary {
	background: transparent;
	border: 1px solid var(--border);
	color: var(--text);
}
button.btn.danger {
	background: transparent;
	border: 1px solid var(--error);
	color: var(--error);
}
button.btn.small {
	padding: 6px 10px;
	font-size: 12px;
	font-weight: 500;
}
button.btn:hover:not(:disabled) {
	opacity: 0.9;
}
button.btn:disabled {
	opacity: 0.45;
	cursor: not-allowed;
}
.spinner {
	width: 13px;
	height: 13px;
	border: 2px solid rgba(255, 255, 255, 0.3);
	border-top-color: #fff;
	border-radius: 50%;
	animation: spin 0.7s linear infinite;
	display: none;
}
@keyframes spin {
	to {
		transform: rotate(360deg);
	}
}
.status-box {
	background: var(--bg);
	border: 1px solid var(--border);
	border-radius: 6px;
	padding: 12px;
	font-size: 12px;
	line-height: 1.5;
	white-space: pre-wrap;
	word-break: break-word;
	max-height: 240px;
	overflow-y: auto;
	margin-top: 12px;
	display: none;
}

/* Documents table */
.docs-toolbar {
	display: flex;
	gap: 8px;
	align-items: center;
	margin-bottom: 12px;
	flex-wrap: wrap;
}
.docs-toolbar .search {
	flex: 1;
	min-width: 180px;
}
.count {
	font-size: 12px;
	color: var(--muted);
	white-space: nowrap;
}
/* A secondary block inside a panel, set off by a divider (e.g. "Recent jobs"). */
.subsection {
	border-top: 1px solid var(--border);
	margin-top: 20px;
	padding-top: 16px;
}
.subhead {
	font-size: 13px;
	font-weight: 600;
	color: var(--text);
}
.docs-toolbar .spacer {
	flex: 1;
}
/* An inline "Show [N]" dropdown that sizes to its content instead of full width. */
.inline-select {
	display: inline-flex;
	align-items: center;
	gap: 6px;
}
.inline-select select {
	width: auto;
	padding: 6px 8px;
	font-size: 12px;
}
.table-wrap {
	overflow-x: auto;
	border: 1px solid var(--border);
	border-radius: 8px;
}
table {
	width: 100%;
	border-collapse: collapse;
	font-size: 13px;
}
th,
td {
	text-align: left;
	padding: 10px 12px;
	border-bottom: 1px solid var(--border);
	white-space: nowrap;
}
th {
	color: var(--muted);
	font-weight: 500;
	font-size: 12px;
	position: sticky;
	top: 0;
	background: var(--surface);
}
tbody tr:hover {
	background: rgba(255, 255, 255, 0.02);
}
td.name {
	white-space: normal;
	word-break: break-all;
	max-width: 380px;
}
.pill {
	font-size: 11px;
	padding: 2px 8px;
	border-radius: 999px;
	border: 1px solid var(--border);
}
.pill.done {
	color: var(--success);
	border-color: var(--success);
}
.pill.fail {
	color: var(--error);
	border-color: var(--error);
}
.pill.run {
	color: var(--accent);
	border-color: var(--accent);
}
.pill.uri {
	color: var(--accent);
	border-color: var(--accent);
}
.pill.file {
	color: var(--muted);
}
a.pill {
	text-decoration: none;
}
a.pill:hover {
	border-color: var(--accent);
}
.actions {
	display: flex;
	gap: 6px;
}
.empty-row {
	text-align: center;
	color: var(--muted);
	padding: 24px;
}

/* Modal */
.overlay {
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, 0.55);
	display: none;
	z-index: 10;
}
.overlay.open {
	display: block;
}
.modal {
	position: fixed;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	width: 440px;
	max-width: 92vw;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: 10px;
	padding: 20px;
	z-index: 11;
	display: none;
}
.modal.open {
	display: block;
}
.modal h3 {
	font-size: 15px;
	margin-bottom: 8px;
}

/* ---- conta autenticada no header ---------------------------------- */
/* Segue o mesmo desenho do a.link/.icon-btn. */
.acct-link {
	background: transparent;
	border: 1px solid var(--border);
	color: var(--text);
	height: 36px;
	padding: 0 12px;
	border-radius: 6px;
	font-size: 13px;
	display: inline-flex;
	align-items: center;
	gap: 6px;
	text-decoration: none;
	white-space: nowrap;
}
.acct-link:hover {
	border-color: var(--accent);
}
