:root {
	--bg: #f5f6fa;
	--card: #ffffff;
	--text: #14161c;
	--muted: #8a8f9c;
	--line: #eceef3;
	--accent: #4f46e5;
	--accent-soft: #eef0ff;
	--green: #10b981;
	--amber: #f59e0b;
	--amber-soft: #fff6e5;
	--red: #ef4444;
	--red-soft: #fdecec;
	--radius: 18px;
	--shadow: 0 1px 2px rgba(20, 22, 28, 0.04), 0 4px 16px rgba(20, 22, 28, 0.04);
	color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
	:root {
		--bg: #0f1115;
		--card: #181b22;
		--text: #eef0f5;
		--muted: #7d8494;
		--line: #252935;
		--accent: #818cf8;
		--accent-soft: #23264a;
		--amber-soft: #3a2c10;
		--red-soft: #3a1717;
		--shadow: none;
	}
}

* {
	box-sizing: border-box;
	-webkit-tap-highlight-color: transparent;
}

html,
body {
	margin: 0;
	background: var(--bg);
	color: var(--text);
	font:
		15px/1.5 -apple-system,
		BlinkMacSystemFont,
		"SF Pro Text",
		"PingFang SC",
		"Helvetica Neue",
		"Microsoft YaHei",
		sans-serif;
	font-variant-numeric: tabular-nums;
}

[hidden] {
	display: none !important;
}

button,
input {
	font: inherit;
	color: inherit;
}

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

.error {
	color: var(--red);
	font-size: 13px;
	margin: 0;
}

.card {
	background: var(--card);
	border-radius: var(--radius);
	box-shadow: var(--shadow);
}

.btn {
	border: 0;
	border-radius: 12px;
	padding: 10px 16px;
	background: var(--accent-soft);
	color: var(--accent);
	font-weight: 600;
	cursor: pointer;
	transition:
		transform 0.1s,
		opacity 0.2s;
}
.btn:active {
	transform: scale(0.97);
}
.btn:disabled {
	opacity: 0.5;
}
.btn.primary {
	background: var(--accent);
	color: #fff;
}
.btn.block {
	width: 100%;
	padding: 13px;
}

.icon-btn {
	border: 0;
	background: transparent;
	width: 40px;
	height: 40px;
	border-radius: 12px;
	font-size: 22px;
	line-height: 1;
	cursor: pointer;
	color: var(--text);
}
.icon-btn:active {
	background: var(--line);
}

input[type="text"],
input[type="password"],
input[type="time"],
input[type="number"] {
	width: 100%;
	border: 1px solid var(--line);
	background: var(--bg);
	border-radius: 12px;
	padding: 11px 14px;
	outline: none;
	transition: border-color 0.2s;
}
input:focus {
	border-color: var(--accent);
}

/* 登录 */
.login {
	min-height: 100dvh;
	display: grid;
	place-items: center;
	padding: 24px;
}
.login-card {
	width: 100%;
	max-width: 340px;
	display: flex;
	flex-direction: column;
	gap: 12px;
	text-align: center;
}
.login-card h1 {
	margin: 0;
	font-size: 22px;
}
.login-card p {
	margin: 0 0 8px;
}
.logo {
	font-size: 44px;
}

/* 主体 */
.app {
	max-width: 560px;
	margin: 0 auto;
	padding: calc(env(safe-area-inset-top) + 8px) 16px calc(env(safe-area-inset-bottom) + 24px);
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.topbar {
	display: flex;
	align-items: center;
	gap: 4px;
	position: sticky;
	top: 0;
	z-index: 5;
	background: var(--bg);
	padding: 4px 0;
}
.month-label {
	border: 0;
	background: transparent;
	font-size: 17px;
	font-weight: 700;
	padding: 6px 8px;
	cursor: pointer;
}
.logout {
	margin-left: auto;
	border: 0;
	background: transparent;
	font-size: 13px;
	color: var(--muted);
	padding: 8px 4px;
	cursor: pointer;
}

.hero {
	padding: 22px 20px 18px;
	background: linear-gradient(135deg, #4f46e5, #7c3aed);
	color: #fff;
	box-shadow: 0 8px 24px rgba(79, 70, 229, 0.25);
}
.hero-label {
	font-size: 13px;
	opacity: 0.85;
}
.hero-value {
	font-size: 52px;
	font-weight: 750;
	letter-spacing: -1.5px;
	line-height: 1.1;
	margin: 4px 0 8px;
}
.hero-value small {
	font-size: 20px;
	font-weight: 600;
	margin-left: 4px;
	opacity: 0.8;
	letter-spacing: 0;
}
.formula {
	font-size: 12.5px;
	opacity: 0.85;
}

.today {
	padding: 16px 18px;
}
.today-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
}
.today-label {
	font-size: 13px;
	color: var(--muted);
}
.today-status {
	font-size: 22px;
	font-weight: 700;
}
.today-detail {
	margin-top: 6px;
	font-size: 13px;
	color: var(--muted);
}
.today-detail b {
	color: var(--text);
	font-weight: 600;
}

.stats {
	display: grid;
	grid-template-columns: repeat(2, 1fr);
	gap: 12px;
}
.stat {
	padding: 14px 16px;
}
.stat-value {
	font-size: 20px;
	font-weight: 700;
}
.stat-label {
	font-size: 12px;
	color: var(--muted);
}

.days {
	padding: 6px 0;
}
.days-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 10px 18px 6px;
}
.days-head h2 {
	margin: 0;
	font-size: 15px;
}
.toggle-rest {
	font-size: 12px;
	color: var(--muted);
	display: flex;
	align-items: center;
	gap: 4px;
}

.day-list {
	list-style: none;
	margin: 0;
	padding: 0;
}
.day {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 12px 18px;
	border-top: 1px solid var(--line);
	cursor: pointer;
}
.day:active {
	background: var(--bg);
}
.day.dim {
	opacity: 0.45;
}
.day-date {
	width: 46px;
	flex-shrink: 0;
	text-align: center;
}
.day-date .d {
	font-size: 18px;
	font-weight: 700;
	line-height: 1.1;
}
.day-date .w {
	font-size: 11px;
	color: var(--muted);
}
.day.today .day-date .d {
	color: var(--accent);
}
.day-main {
	flex: 1;
	min-width: 0;
}
.day-times {
	font-weight: 500;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
.day-tags {
	display: flex;
	gap: 6px;
	flex-wrap: wrap;
	margin-top: 2px;
}
.tag {
	font-size: 11px;
	padding: 1px 7px;
	border-radius: 6px;
	background: var(--line);
	color: var(--muted);
}
.tag.red {
	background: var(--red-soft);
	color: var(--red);
}
.tag.amber {
	background: var(--amber-soft);
	color: var(--amber);
}
.tag.accent {
	background: var(--accent-soft);
	color: var(--accent);
}
.day-hours {
	font-weight: 700;
	font-size: 16px;
	text-align: right;
	min-width: 56px;
}
.day-hours.zero {
	color: var(--red);
}
.day-hours small {
	font-size: 11px;
	color: var(--muted);
	font-weight: 500;
	margin-left: 1px;
}

.footer {
	text-align: center;
	font-size: 12px;
	padding: 8px 0;
}

/* 底部面板 */
.sheet-backdrop {
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, 0.35);
	z-index: 20;
	animation: fade 0.2s;
}
.sheet {
	position: fixed;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 21;
	max-width: 560px;
	margin: 0 auto;
	max-height: 88dvh;
	overflow-y: auto;
	background: var(--card);
	border-radius: 22px 22px 0 0;
	padding: 8px 20px calc(env(safe-area-inset-bottom) + 20px);
	animation: slide-up 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.sheet-grip {
	width: 36px;
	height: 5px;
	border-radius: 3px;
	background: var(--line);
	margin: 0 auto 10px;
}
.sheet-head {
	display: flex;
	justify-content: space-between;
	align-items: flex-start;
}
.sheet-head h3 {
	margin: 0;
	font-size: 18px;
}
.sheet-head .muted {
	font-size: 13px;
}
.sheet-section {
	margin-top: 18px;
	display: flex;
	flex-direction: column;
	gap: 10px;
}
.section-title {
	font-size: 13px;
	font-weight: 600;
	color: var(--muted);
}
.punch-list {
	list-style: none;
	margin: 0;
	padding: 0;
	border: 1px solid var(--line);
	border-radius: 14px;
	overflow: hidden;
}
.punch-list:empty::before {
	content: "暂无打卡";
	display: block;
	padding: 12px 14px;
	color: var(--muted);
	font-size: 14px;
}
.punch-list li {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 8px 8px 8px 14px;
}
.punch-list li + li {
	border-top: 1px solid var(--line);
}
.punch-list .t {
	font-weight: 600;
	font-size: 16px;
}
.punch-list .meta {
	flex: 1;
	font-size: 12px;
	color: var(--muted);
}
.punch-list .del {
	font-size: 16px;
	color: var(--muted);
}
.inline-form {
	display: flex;
	gap: 8px;
}
.inline-form input {
	flex: 1;
}

.leave-row {
	display: flex;
	align-items: center;
	gap: 12px;
}
.stepper {
	display: flex;
	align-items: center;
	border: 1px solid var(--line);
	border-radius: 12px;
	overflow: hidden;
}
.stepper button {
	border: 0;
	background: var(--bg);
	width: 40px;
	height: 42px;
	font-size: 18px;
	cursor: pointer;
}
.stepper input {
	width: 64px;
	border: 0;
	border-radius: 0;
	text-align: center;
	background: transparent;
	-moz-appearance: textfield;
	appearance: textfield;
}
.stepper input::-webkit-inner-spin-button,
.stepper input::-webkit-outer-spin-button {
	-webkit-appearance: none;
}
.chips {
	display: flex;
	gap: 8px;
}
.chip {
	flex: 1;
	border: 1px solid var(--line);
	background: transparent;
	border-radius: 10px;
	padding: 7px 0;
	font-size: 13px;
	cursor: pointer;
}
.chip.active {
	border-color: var(--accent);
	background: var(--accent-soft);
	color: var(--accent);
	font-weight: 600;
}
.switch-row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 4px 0;
}
.switch {
	appearance: none;
	width: 46px;
	height: 28px;
	border-radius: 14px;
	background: var(--line);
	position: relative;
	cursor: pointer;
	transition: background 0.2s;
	flex-shrink: 0;
}
.switch::after {
	content: "";
	position: absolute;
	top: 3px;
	left: 3px;
	width: 22px;
	height: 22px;
	border-radius: 50%;
	background: #fff;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
	transition: transform 0.2s;
}
.switch:checked {
	background: var(--accent);
}
.switch:checked::after {
	transform: translateX(18px);
}

.toast {
	position: fixed;
	left: 50%;
	bottom: calc(env(safe-area-inset-bottom) + 28px);
	transform: translateX(-50%);
	background: rgba(20, 22, 28, 0.9);
	color: #fff;
	padding: 10px 18px;
	border-radius: 12px;
	font-size: 14px;
	z-index: 30;
	animation: fade 0.2s;
	max-width: calc(100% - 48px);
}

@keyframes fade {
	from {
		opacity: 0;
	}
}
@keyframes slide-up {
	from {
		transform: translateY(100%);
	}
}
