:root {
	--bg: #f5f1e8;
	--panel: rgba(255, 252, 245, 0.92);
	--panel-strong: #fffaf2;
	--line: rgba(116, 89, 56, 0.14);
	--text: #2e2418;
	--muted: #7b6853;
	--brand: #14532d;
	--danger: #9f1239;
	--shadow: 0 20px 50px rgba(78, 59, 35, 0.08);
}

* {
	box-sizing: border-box;
}

body {
	margin: 0;
	font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
	color: var(--text);
	background:
		radial-gradient(circle at top left, rgba(20, 83, 45, 0.10), transparent 28%),
		radial-gradient(circle at top right, rgba(159, 18, 57, 0.08), transparent 20%),
		linear-gradient(180deg, #fbf7ef 0%, #f1eadf 100%);
	min-height: 100vh;
}

button,
input,
select {
	font: inherit;
}

.page-shell {
	max-width: 1320px;
	margin: 0 auto;
	padding: 32px 24px 80px;
}

.hero {
	display: flex;
	justify-content: space-between;
	gap: 24px;
	padding: 28px 32px;
	margin-bottom: 20px;
	border: 1px solid var(--line);
	border-radius: 28px;
	background: linear-gradient(135deg, rgba(255, 251, 244, 0.96), rgba(245, 239, 226, 0.84));
	box-shadow: var(--shadow);
}

.eyebrow {
	margin: 0 0 8px;
	font-size: 13px;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	color: var(--brand);
}

.hero h1,
.section-head h2,
.drawer-head h3 {
	margin: 0;
	font-family: Georgia, "Songti SC", serif;
	font-weight: 700;
}

.hero h1 {
	font-size: clamp(32px, 5vw, 52px);
}

.hero-copy,
.section-head p,
.empty {
	color: var(--muted);
}

.hero-badge {
	display: flex;
	flex-wrap: wrap;
	align-content: flex-start;
	gap: 12px;
	max-width: 360px;
}

.hero-side {
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	gap: 14px;
}

.hero-badge span,
.status-chip,
.chip {
	padding: 10px 14px;
	border-radius: 999px;
	background: rgba(20, 83, 45, 0.08);
	color: var(--brand);
	font-size: 14px;
}

.stats-grid,
.upstream-grid {
	display: grid;
	gap: 16px;
}

.stats-grid {
	grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
	margin-bottom: 20px;
}

.stat-card,
.card,
.upstream-card,
.drawer {
	border: 1px solid var(--line);
	border-radius: 24px;
	background: var(--panel);
	box-shadow: var(--shadow);
}

.stat-card {
	padding: 18px 20px;
}

.stat-card span {
	display: block;
	color: var(--muted);
	margin-bottom: 8px;
}

.stat-card strong {
	font-size: 28px;
}

.card {
	padding: 24px;
	margin-bottom: 20px;
}

.section-head,
.dialog-head,
.drawer-head,
.relay-row,
.meta-grid {
	display: flex;
}

.section-head,
.dialog-head,
.drawer-head {
	justify-content: space-between;
	align-items: center;
	gap: 16px;
	margin-bottom: 20px;
}

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

.form-grid,
.filter-row,
.dialog-form,
.detail-grid {
	display: grid;
	gap: 16px;
}

.form-grid {
	grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
	align-items: end;
}

.filter-row {
	grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
	margin-bottom: 18px;
}

.dialog-form {
	min-width: min(560px, 92vw);
}

label {
	display: grid;
	gap: 8px;
	color: var(--muted);
	font-size: 14px;
}

label input,
label select {
	padding: 13px 14px;
	border-radius: 14px;
	border: 1px solid rgba(116, 89, 56, 0.18);
	background: rgba(255, 255, 255, 0.88);
	color: var(--text);
}

label input:focus,
label select:focus {
	outline: 2px solid rgba(20, 83, 45, 0.18);
	border-color: rgba(20, 83, 45, 0.42);
}

.form-actions {
	display: flex;
	align-items: end;
}

button {
	padding: 12px 18px;
	border-radius: 14px;
	border: 1px solid transparent;
	background: rgba(20, 83, 45, 0.08);
	color: var(--brand);
	cursor: pointer;
	transition: transform 0.15s ease, box-shadow 0.15s ease;
}

button:hover {
	transform: translateY(-1px);
	box-shadow: 0 10px 18px rgba(20, 83, 45, 0.10);
}

button:disabled {
	cursor: not-allowed;
	opacity: 0.55;
	transform: none;
	box-shadow: none;
}

button.primary {
	background: linear-gradient(135deg, #14532d, #2f855a);
	color: #fff;
}

button.danger {
	background: rgba(159, 18, 57, 0.10);
	color: var(--danger);
}

button.ghost {
	background: transparent;
	border-color: rgba(116, 89, 56, 0.16);
	color: var(--muted);
}

.upstream-grid {
	grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.upstream-card {
	padding: 20px;
	display: grid;
	gap: 14px;
}

.upstream-card h3 {
	margin: 0;
	font-size: 22px;
}

.relay-row {
	justify-content: space-between;
	align-items: center;
	gap: 12px;
	padding: 12px 14px;
	border-radius: 16px;
	background: rgba(20, 83, 45, 0.05);
}

.relay-row code,
.pre-block code {
	white-space: pre-wrap;
	word-break: break-all;
}

.upstream-actions {
	display: flex;
	gap: 10px;
	flex-wrap: wrap;
}

.table-wrap {
	overflow-x: auto;
	border: 1px solid var(--line);
	border-radius: 18px;
}

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

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

tbody tr {
	cursor: pointer;
}

tbody tr:hover {
	background: rgba(20, 83, 45, 0.05);
}

.status-chip.ok {
	background: rgba(20, 83, 45, 0.10);
	color: var(--brand);
}

.status-chip.error {
	background: rgba(159, 18, 57, 0.10);
	color: var(--danger);
}

.pagination {
	display: flex;
	justify-content: flex-end;
	align-items: center;
	gap: 12px;
	margin-top: 16px;
}

dialog {
	border: none;
	border-radius: 24px;
	padding: 0;
	background: transparent;
}

dialog::backdrop {
	background: rgba(31, 22, 14, 0.45);
	backdrop-filter: blur(6px);
}

.dialog-form {
	padding: 24px;
	border-radius: 24px;
	background: var(--panel-strong);
	box-shadow: var(--shadow);
}

.checkbox-row {
	display: flex;
	align-items: center;
	gap: 12px;
}

.drawer {
	position: fixed;
	top: 18px;
	right: 18px;
	bottom: 18px;
	width: min(540px, calc(100vw - 36px));
	padding: 22px;
	transform: translateX(calc(100% + 30px));
	transition: transform 0.22s ease;
	z-index: 20;
}

.drawer.open {
	transform: translateX(0);
}

.drawer-body {
	height: calc(100% - 90px);
	overflow: auto;
	padding-right: 4px;
}

.detail-grid {
	grid-template-columns: 1fr;
}

.meta-grid {
	flex-wrap: wrap;
	gap: 10px;
	margin-bottom: 16px;
}

.chip {
	background: rgba(116, 89, 56, 0.08);
	color: var(--text);
}

.pre-block {
	padding: 14px;
	border-radius: 16px;
	background: #1f1a15;
	color: #f7ecd9;
	overflow: auto;
}

.pre-block h4 {
	margin-top: 0;
}

.toast {
	position: fixed;
	left: 50%;
	bottom: 26px;
	transform: translate(-50%, 20px);
	padding: 12px 18px;
	border-radius: 999px;
	background: rgba(31, 22, 14, 0.92);
	color: #fff;
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.2s ease, transform 0.2s ease;
	z-index: 30;
}

.toast.show {
	opacity: 1;
	transform: translate(-50%, 0);
}

.wide {
	grid-column: span 2;
}

[hidden] {
	display: none !important;
}

.login-page {
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 24px;
}

.login-shell {
	width: min(460px, 100%);
}

.login-card {
	padding: 28px;
	border: 1px solid var(--line);
	border-radius: 28px;
	background: linear-gradient(180deg, rgba(255, 251, 244, 0.96), rgba(245, 239, 226, 0.92));
	box-shadow: var(--shadow);
}

.login-card h1 {
	margin: 0;
	font-family: Georgia, "Songti SC", serif;
	font-size: clamp(30px, 5vw, 40px);
}

.login-copy {
	margin: 12px 0 0;
	color: var(--muted);
	line-height: 1.7;
}

.login-form {
	display: grid;
	gap: 16px;
	margin-top: 24px;
}

.login-tip {
	margin: 0;
	padding: 12px 14px;
	border-radius: 16px;
	background: rgba(20, 83, 45, 0.08);
	color: var(--brand);
	line-height: 1.6;
}

.login-error {
	min-height: 1.4em;
	margin: 0;
	color: var(--danger);
}

@media (max-width: 960px) {
	.hero {
		flex-direction: column;
	}

	.hero-side {
		align-items: flex-start;
	}

	.wide {
		grid-column: span 1;
	}
}
