:root {
	--bg: #f6f4f1;
	--panel: #ffffff;
	--text: #171717;
	--muted: #6b7280;
	--line: #e8e4df;
	--accent: #0d9488;
	--accent-soft: #ecfdf8;
	--danger: #dc2626;
	--warn: #d97706;
	--ok: #059669;
	--shadow: 0 18px 50px rgba(17, 17, 17, 0.08);
	--radius: 16px;
	--safe-top: env(safe-area-inset-top, 0px);
	--safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; background: var(--bg); color: var(--text); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: var(--accent); text-decoration: none; }

.shell { max-width: 1180px; margin: 0 auto; padding: 28px 20px 48px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.panel-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	margin-bottom: 12px;
}
.panel-head h2 { margin: 0; }
.brand h1 { margin: 0; font-size: 1.35rem; letter-spacing: -0.02em; }
.brand p { margin: 4px 0 0; color: var(--muted); font-size: 0.92rem; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }

.btn {
	border: 1px solid var(--line);
	background: var(--panel);
	color: var(--text);
	padding: 10px 14px;
	border-radius: 12px;
	transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
	touch-action: manipulation;
	-webkit-tap-highlight-color: transparent;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 8px 20px rgba(0,0,0,.05); }
.btn:active { transform: translateY(0); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); border-color: #fecaca; background: #fff5f5; }

.panel {
	background: var(--panel);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	box-shadow: var(--shadow);
	padding: 20px;
}

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(420px, 100%); }
.login-card h1 { margin: 0 0 8px; }
.login-card p { margin: 0 0 20px; color: var(--muted); }
.login-error {
	margin: 0 0 14px;
	padding: 10px 12px;
	border-radius: 10px;
	background: #fef2f2;
	color: #991b1b;
	font-size: 0.88rem;
	line-height: 1.45;
}
.field { display: grid; gap: 8px; margin-bottom: 14px; }
.field label { font-size: 0.88rem; color: var(--muted); }
.field input, .field select, .field textarea {
	width: 100%;
	border: 1px solid var(--line);
	border-radius: 12px;
	padding: 11px 12px;
	background: #fff;
}
.login-card .field input {
	font-size: 16px;
	min-height: 48px;
}
.login-card .btn.primary {
	min-height: 48px;
	font-size: 1rem;
}
.login-card .btn.primary:disabled {
	opacity: 0.7;
	cursor: wait;
}
.field textarea { min-height: 88px; resize: vertical; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { padding: 16px; border-radius: 14px; background: linear-gradient(180deg, #fff, #fbfaf8); border: 1px solid var(--line); }
.stat strong { display: block; font-size: 1.5rem; margin-bottom: 4px; }
.stat span { color: var(--muted); font-size: 0.86rem; }

.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: 0.82rem; }
tr:hover td { background: #faf9f7; }

.badge {
	display: inline-flex; align-items: center; gap: 6px;
	padding: 4px 10px; border-radius: 999px; font-size: 0.78rem; font-weight: 600;
}
.badge.live { background: #ecfdf5; color: var(--ok); }
.badge.beta { background: #eff6ff; color: #2563eb; }
.badge.paused { background: #fff7ed; color: var(--warn); }
.badge.dev { background: #f3f4f6; color: #4b5563; }
.badge.archived { background: #fef2f2; color: var(--danger); }
.badge.update { background: #fff7ed; color: #c2410c; }

.ver-tag {
	display: inline-flex;
	align-items: center;
	padding: 2px 8px;
	border-radius: 999px;
	background: #111827;
	color: #fff;
	font-size: 0.78rem;
	font-weight: 600;
	letter-spacing: 0.02em;
}

.update-banner {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 14px;
	margin-bottom: 16px;
	padding: 14px 16px;
	border-radius: 14px;
	border: 1px solid #fdba74;
	background: linear-gradient(180deg, #fff7ed, #ffedd5);
}

.update-banner.top-banner { margin-bottom: 18px; }
.update-banner strong { display: block; margin-bottom: 4px; }
.update-banner.dirty-banner {
	background: #fffbeb;
	border-color: #fcd34d;
}
.experience-pipeline {
	display: flex;
	align-items: stretch;
	gap: 8px;
	flex-wrap: wrap;
	margin: 0 0 16px;
	padding: 12px;
	border: 1px solid var(--line);
	border-radius: 14px;
	background: #fafaf9;
}
.xp-step {
	flex: 1 1 140px;
	display: flex;
	gap: 10px;
	align-items: flex-start;
	padding: 10px 12px;
	border-radius: 12px;
	border: 1px solid transparent;
	opacity: 0.72;
}
.xp-step.active { opacity: 1; background: #fff; border-color: var(--line); }
.xp-step.active.warn { border-color: #fcd34d; background: #fffbeb; }
.xp-step.active.ok { border-color: #99f6e4; background: #ecfdf8; }
.xp-num {
	width: 22px;
	height: 22px;
	border-radius: 999px;
	display: grid;
	place-items: center;
	font-size: 0.75rem;
	font-weight: 700;
	background: #e7e5e4;
	color: #44403c;
	flex-shrink: 0;
}
.xp-step.active.warn .xp-num { background: #f59e0b; color: #fff; }
.xp-step.active.ok .xp-num { background: var(--accent); color: #fff; }
.xp-step strong { display: block; font-size: 0.92rem; }
.xp-arrow {
	align-self: center;
	color: var(--muted);
	font-size: 1.1rem;
	padding: 0 2px;
}
@media (max-width: 900px) {
	.xp-arrow { display: none; }
}

.decision-panel {
	margin-bottom: 18px;
	padding: 12px 14px;
	border: 1px solid #e7e5e4;
	border-radius: 14px;
	background: #fff;
}

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

.decision-actions label {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	font-size: 0.92rem;
}

.ops-settings {
	display: flex;
	flex-wrap: wrap;
	gap: 12px;
	align-items: end;
	margin: 12px 0 4px;
}

.ops-settings .field { margin: 0; min-width: 180px; }

.ops-meta {
	display: flex;
	flex-wrap: wrap;
	gap: 12px 18px;
	color: var(--muted);
	font-size: 0.86rem;
	margin: 8px 0 4px;
}

.ops-subhead {
	margin: 22px 0 10px;
	font-size: 0.98rem;
}

code {
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	font-size: 0.86em;
	background: #f3f4f6;
	padding: 1px 6px;
	border-radius: 6px;
}

.layout { display: grid; grid-template-columns: 280px 1fr; gap: 18px; }
.side-nav { display: grid; gap: 8px; align-content: start; }
.nav-item {
	text-align: left; padding: 12px 14px; border-radius: 12px; border: 1px solid transparent; background: transparent;
	font: inherit;
	color: inherit;
}
.nav-item.active { background: var(--accent-soft); border-color: #99f6e4; color: #115e59; font-weight: 600; }

.modal-backdrop {
	position: fixed; inset: 0; background: rgba(15, 23, 42, 0.35);
	display: grid; place-items: center; padding: 20px; z-index: 30;
}
.modal { width: min(760px, 100%); max-height: 90vh; overflow: auto; }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; }
.modal-head h2 { margin: 0; font-size: 1.15rem; }

.toast {
	position: fixed; right: 18px; bottom: 18px; background: #111827; color: #fff;
	padding: 12px 14px; border-radius: 12px; box-shadow: var(--shadow); z-index: 40;
}
.toast.error { background: #7f1d1d; }

.hint { color: var(--muted); font-size: 0.86rem; line-height: 1.5; }
.empty { color: var(--muted); padding: 28px 12px; text-align: center; }

.form-check {
	display: flex;
	align-items: center;
	gap: 8px;
	min-height: 44px;
	font-size: 0.92rem;
}

@media (max-width: 900px) {
	.shell {
		padding: calc(16px + var(--safe-top)) 14px calc(24px + var(--safe-bottom));
	}

	.topbar {
		flex-wrap: wrap;
		align-items: flex-start;
		gap: 12px;
		margin-bottom: 18px;
	}

	.brand h1 { font-size: 1.2rem; }
	.brand p { font-size: 0.84rem; line-height: 1.45; }

	.actions {
		width: 100%;
		justify-content: stretch;
	}

	.actions .btn {
		flex: 1 1 auto;
		min-height: 44px;
	}

	.stats {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		gap: 10px;
		margin-bottom: 14px;
	}

	.stat {
		padding: 12px;
	}

	.stat strong {
		font-size: 1.25rem;
	}

	.layout {
		grid-template-columns: 1fr;
		gap: 12px;
	}

	.panel.side-nav {
		display: flex;
		flex-direction: row;
		gap: 8px;
		padding: 10px;
		overflow-x: auto;
		-webkit-overflow-scrolling: touch;
		scrollbar-width: none;
	}

	.panel.side-nav::-webkit-scrollbar {
		display: none;
	}

	.nav-item {
		flex: 1 1 0;
		min-width: 88px;
		text-align: center;
		padding: 10px 12px;
		min-height: 44px;
	}

	.panel {
		padding: 16px;
	}

	.panel-head {
		flex-direction: column;
		align-items: stretch;
	}

	.panel-head .btn {
		width: 100%;
		min-height: 44px;
	}

	.grid-2, .grid-3 {
		grid-template-columns: 1fr;
	}

	.field input,
	.field select,
	.field textarea {
		font-size: 16px;
		min-height: 44px;
	}

	.field textarea {
		min-height: 96px;
	}

	.table-wrap {
		overflow: visible;
	}

	table.responsive-table thead {
		display: none;
	}

	table.responsive-table tbody tr {
		display: block;
		margin-bottom: 12px;
		padding: 12px;
		border: 1px solid var(--line);
		border-radius: 14px;
		background: #fff;
	}

	table.responsive-table tbody tr:hover td {
		background: transparent;
	}

	table.responsive-table tbody td {
		display: flex;
		align-items: center;
		justify-content: space-between;
		gap: 12px;
		padding: 8px 0;
		border-bottom: none;
		text-align: right;
		word-break: break-word;
	}

	table.responsive-table tbody td::before {
		content: attr(data-label);
		font-size: 0.78rem;
		font-weight: 600;
		color: var(--muted);
		text-align: left;
		flex-shrink: 0;
	}

	table.responsive-table tbody td:first-child {
		flex-direction: column;
		align-items: flex-start;
		text-align: left;
		padding-top: 0;
	}

	table.responsive-table tbody td:first-child::before {
		display: none;
	}

	table.responsive-table tbody td:last-child {
		justify-content: flex-end;
		padding-bottom: 0;
	}

	table.responsive-table tbody td:last-child::before {
		display: none;
	}

	table.responsive-table .btn {
		width: 100%;
		min-height: 44px;
	}

	.modal-backdrop {
		align-items: flex-end;
		padding: 0;
	}

	.modal {
		width: 100%;
		max-height: 92dvh;
		border-radius: 16px 16px 0 0;
		padding-bottom: calc(16px + var(--safe-bottom));
	}

	.modal-head {
		position: sticky;
		top: 0;
		background: var(--panel);
		padding-bottom: 8px;
		margin-bottom: 12px;
		z-index: 1;
	}

	.modal-head .btn {
		min-height: 40px;
		flex-shrink: 0;
	}

	.login-wrap {
		padding: calc(20px + var(--safe-top)) 16px calc(20px + var(--safe-bottom));
	}

	.toast {
		left: 16px;
		right: 16px;
		bottom: calc(16px + var(--safe-bottom));
	}
}
