:root {
	--bg: #f5f6f8;
	--surface: #ffffff;
	--border: #d9dde3;
	--text: #1f2933;
	--muted: #6b7280;
	--link: #0b5cab;
	--on-bg: #d7f2df;
	--on-text: #14532d;
	--off-bg: #e5e7eb;
	--off-text: #374151;
	--empty-bg: #fdecc8;
	--empty-text: #7a4b00;
	--filled-bg: #dbeafe;
	--filled-text: #1e3a8a;
	--highlight-bg: #fff6c2;
	--highlight-border: #e0b400;
	--error-bg: #fde2e2;
	--error-text: #9b1c1c;
}

* {
	box-sizing: border-box;
}

html {
	/* 跳轉到錨點時,避免被 sticky 的頂部列蓋住 */
	scroll-padding-top: 80px;
}

[hidden] {
	display: none !important;
}

body {
	margin: 0;
	background: var(--bg);
	color: var(--text);
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
	font-size: 14px;
	line-height: 1.5;
}

.topbar {
	position: sticky;
	top: 0;
	z-index: 1;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px 24px;
	padding: 12px 24px;
	background: var(--surface);
	border-bottom: 1px solid var(--border);
}

.controls {
	display: flex;
	flex-wrap: wrap;
	gap: 12px 20px;
}

.field {
	display: flex;
	align-items: center;
	gap: 8px;
}

.field label {
	font-weight: 600;
}

select {
	min-width: 160px;
	padding: 6px 8px;
	border: 1px solid var(--border);
	border-radius: 4px;
	background: var(--surface);
	color: var(--text);
	font: inherit;
}

button {
	padding: 6px 16px;
	border: 1px solid var(--link);
	border-radius: 4px;
	background: var(--link);
	color: #ffffff;
	font: inherit;
	cursor: pointer;
}

select:disabled {
	color: var(--muted);
	background: var(--bg);
}

.meta {
	margin: 0;
	color: var(--muted);
}

main {
	max-width: 1200px;
	margin: 0 auto;
	padding: 16px 24px 48px;
}

h2 {
	margin: 24px 0 12px;
	font-size: 18px;
}

h3 {
	margin: 16px 0 8px;
	font-size: 15px;
}

.message {
	margin: 16px 0 0;
}

.message:empty {
	display: none;
}

.message.error {
	padding: 12px 16px;
	border-radius: 4px;
	background: var(--error-bg);
	color: var(--error-text);
	font-weight: 600;
}

.cards {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
	gap: 12px;
}

.card {
	padding: 10px 12px;
	border: 1px solid var(--border);
	border-radius: 6px;
	background: var(--surface);
	min-width: 0;
}

.card-title {
	margin: 0 0 4px;
	color: var(--muted);
	font-size: 12px;
	font-weight: 600;
	word-break: break-all;
}

.card-body {
	word-break: break-word;
}

.chips {
	display: flex;
	flex-wrap: wrap;
	gap: 4px;
}

.chip {
	padding: 1px 8px;
	border-radius: 10px;
	background: var(--bg);
	border: 1px solid var(--border);
	font-size: 12px;
}

.policy {
	padding: 12px 16px;
	border: 1px solid var(--border);
	border-radius: 6px;
	background: var(--surface);
	white-space: pre-wrap;
	word-break: break-word;
}

.policy-empty {
	margin: 0;
	padding: 12px 16px;
	border: 1px solid var(--border);
	border-radius: 6px;
	background: var(--surface);
	color: var(--muted);
}

.table-wrap {
	overflow-x: auto;
	border: 1px solid var(--border);
	border-radius: 6px;
	background: var(--surface);
}

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

th,
td {
	padding: 6px 12px;
	border-bottom: 1px solid var(--border);
	text-align: left;
	vertical-align: top;
}

thead th {
	background: var(--bg);
	white-space: nowrap;
}

tbody:last-child tr:last-child td {
	border-bottom: 0;
}

/* 從卡片連結跳轉過來時,highlight 該欄位群組 */
tbody:target td {
	background: var(--highlight-bg);
	box-shadow: inset 0 1px 0 var(--highlight-border), inset 0 -1px 0 var(--highlight-border);
}

tbody:target td:first-child {
	box-shadow: inset 3px 0 0 var(--highlight-border), inset 0 1px 0 var(--highlight-border),
		inset 0 -1px 0 var(--highlight-border);
}

.section-row th {
	background: var(--bg);
	font-size: 13px;
}

.path {
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	font-size: 12px;
	word-break: break-all;
}

.type {
	color: var(--muted);
	white-space: nowrap;
}

.value {
	word-break: break-word;
}

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

a.link {
	color: var(--link);
}

.badge {
	display: inline-block;
	padding: 1px 8px;
	border-radius: 10px;
	font-size: 12px;
	font-weight: 600;
	white-space: nowrap;
}

.badge.on {
	background: var(--on-bg);
	color: var(--on-text);
}

.badge.off {
	background: var(--off-bg);
	color: var(--off-text);
}

.badge.empty {
	background: var(--empty-bg);
	color: var(--empty-text);
}

.badge.filled {
	background: var(--filled-bg);
	color: var(--filled-text);
}
