:root {
	--bg: #f5f7fa;
	--card: #ffffff;
	--border: #e3e8ef;
	--text: #1f2933;
	--muted: #6b7785;
	--primary: #2f6fed;
	--primary-dark: #2159c8;
	--danger: #d64545;
	--success-bg: #e6f7ed;
	--success-fg: #1a7f4b;
	--error-bg: #fdecec;
	--error-fg: #b33232;
	--info-bg: #eef3fe;
	--info-fg: #2f6fed;
	--radius: 10px;
}

* { box-sizing: border-box; }

body {
	margin: 0;
	background: var(--bg);
	color: var(--text);
	font: 15px/1.6 -apple-system, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
	min-height: 100vh;
	display: flex;
	flex-direction: column;
}

.container { width: min(1080px, calc(100% - 32px)); margin: 0 auto; }
.main { flex: 1; padding: 28px 0 48px; }

/* 头部 */
.site-header {
	background: var(--card);
	border-bottom: 1px solid var(--border);
}
.header-inner {
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-wrap: wrap;
	gap: 8px;
	padding: 14px 0;
}
.brand {
	font-weight: 700;
	font-size: 18px;
	color: var(--text);
	text-decoration: none;
}
.brand::before { content: "🃏 "; }

.main-nav { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.main-nav a { color: var(--muted); text-decoration: none; font-size: 14px; }
.main-nav a:hover { color: var(--primary); }

/* 卡片与标题 */
.card {
	background: var(--card);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	padding: 24px 28px;
	margin-bottom: 24px;
}
.card.narrow { max-width: 480px; margin: 32px auto; }
h1 { font-size: 22px; margin: 0 0 14px; }
h2 { font-size: 17px; margin: 0 0 10px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }

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

.meta-box {
	background: var(--bg);
	border: 1px solid var(--border);
	border-radius: 8px;
	padding: 10px 14px;
	margin: 10px 0 14px;
}
.meta-box p { margin: 2px 0; }

/* 表单 */
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 14px; }
.form-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
	gap: 14px;
}
input, select {
	font: inherit;
	padding: 9px 12px;
	border: 1px solid var(--border);
	border-radius: 8px;
	background: #fff;
	color: var(--text);
	width: 100%;
}
input:focus, select:focus {
	outline: 2px solid color-mix(in srgb, var(--primary) 35%, transparent);
	border-color: var(--primary);
}
.hint { font-weight: 400; color: var(--muted); font-size: 12px; }

/* 按钮 */
.btn {
	display: inline-block;
	padding: 8px 16px;
	border: 1px solid var(--border);
	border-radius: 8px;
	background: #fff;
	color: var(--text);
	font: inherit;
	text-decoration: none;
	cursor: pointer;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-ghost { background: transparent; }
.btn-danger { color: var(--danger); }
.btn-danger:hover { border-color: var(--danger); }
.btn-small { padding: 4px 10px; font-size: 13px; }
.btn.disabled { opacity: 0.5; pointer-events: none; }
.btn-copy {
	border: 1px solid var(--border);
	background: var(--bg);
	border-radius: 6px;
	font-size: 12px;
	padding: 2px 8px;
	cursor: pointer;
	color: var(--muted);
}
.btn-copy:hover { color: var(--primary); border-color: var(--primary); }
.btn-link {
	background: none;
	border: none;
	color: var(--muted);
	font: inherit;
	font-size: 14px;
	cursor: pointer;
	padding: 0;
}
.btn-link:hover { color: var(--danger); }
.inline-form { display: inline; }

/* 表格 */
.table {
	width: 100%;
	border-collapse: collapse;
	background: var(--card);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	overflow: hidden;
}
.table th, .table td {
	padding: 10px 12px;
	border-bottom: 1px solid var(--border);
	text-align: left;
	vertical-align: middle;
	font-size: 14px;
}
.table th { background: var(--bg); color: var(--muted); font-weight: 600; white-space: nowrap; }
.table tr:last-child td { border-bottom: none; }
.table .empty { text-align: center; color: var(--muted); padding: 28px; }
.actions { white-space: nowrap; }
.actions .inline-form { margin-right: 6px; }
.link-cell { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.code-text {
	font-family: "Cascadia Mono", Consolas, "JetBrains Mono", monospace;
	letter-spacing: 0.5px;
	background: var(--bg);
	padding: 2px 6px;
	border-radius: 4px;
}

/* 徽章 */
.badge {
	display: inline-block;
	font-size: 12px;
	padding: 2px 10px;
	border-radius: 999px;
}
.badge-active { background: var(--success-bg); color: var(--success-fg); }
.badge-disabled { background: var(--error-bg); color: var(--error-fg); }
.badge-warn { background: #fdf3e0; color: #9a6b1f; }
.checkbox-line { display: flex; align-items: center; gap: 8px; font-weight: 400; font-size: 14px; }
/* hidden 属性会被上面的 display:flex 覆盖，需要显式恢复隐藏语义 */
.checkbox-line[hidden] { display: none; }
.org-warn { color: var(--error-fg); font-weight: 600; }

/* 滑块开关（基于隐藏的 checkbox + 纯 CSS 绘制） */
.switch-line { display: flex; align-items: center; gap: 8px; font-weight: 400; font-size: 14px; cursor: pointer; }
.switch-line[hidden] { display: none; }
.switch-line input[type="checkbox"] { position: absolute; opacity: 0; width: 0; height: 0; }
.switch {
	width: 36px;
	height: 20px;
	background: var(--border);
	border-radius: 999px;
	position: relative;
	transition: background 0.15s;
	flex: none;
}
.switch::after {
	content: "";
	position: absolute;
	top: 2px;
	left: 2px;
	width: 16px;
	height: 16px;
	background: #fff;
	border-radius: 50%;
	transition: left 0.15s;
	box-shadow: 0 1px 2px rgb(0 0 0 / 20%);
}
.switch-line input:checked + .switch { background: var(--primary); }
.switch-line input:checked + .switch::after { left: 18px; }
.switch-line input:focus-visible + .switch { outline: 2px solid color-mix(in srgb, var(--primary) 45%, transparent); }

/* 提示条 */
.flash {
	border-radius: 8px;
	padding: 10px 14px;
	margin-bottom: 16px;
	font-size: 14px;
}
.flash-success { background: var(--success-bg); color: var(--success-fg); }
.flash-error { background: var(--error-bg); color: var(--error-fg); }
.flash-info { background: var(--info-bg); color: var(--info-fg); }

/* 统计卡片 */
.stat-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
	gap: 14px;
}
.stat-card {
	background: var(--card);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	padding: 18px;
	text-align: center;
}
.stat-num { font-size: 28px; font-weight: 700; color: var(--primary); }
.stat-label { color: var(--muted); font-size: 13px; margin-top: 4px; }

/* 筛选与分页 */
.filter-bar { display: flex; gap: 10px; margin-bottom: 14px; }
.filter-bar select, .filter-bar input { width: auto; }
.filter-bar input[type="text"] { min-width: 220px; }
.pager { display: flex; align-items: center; gap: 14px; justify-content: center; margin: 20px 0; }
.pager-info { color: var(--muted); font-size: 14px; }

/* 行布局 */
.row { display: flex; gap: 10px; flex-wrap: wrap; margin: 12px 0; align-items: center; }

/* 底部 */
.site-footer {
	border-top: 1px solid var(--border);
	padding: 14px 0;
	color: var(--muted);
	font-size: 13px;
	background: var(--card);
}

@media (max-width: 640px) {
	.table { display: block; overflow-x: auto; }
	.card.narrow { margin: 12px auto; }
}
