:root {
	--bg: #eef3f0;
	--surface: #ffffff;
	--surface-soft: #f7faf8;
	--ink: #18231f;
	--muted: #66736e;
	--line: #d8e1dd;
	--brand: #176a55;
	--brand-strong: #0f4f41;
	--blue: #1d5f8f;
	--amber: #a86100;
	--red: #b42318;
	--green-soft: #e4f5ed;
	--blue-soft: #e5f0fb;
	--amber-soft: #fff4df;
	--red-soft: #fde8e5;
	--shadow: 0 16px 40px rgba(20, 37, 31, 0.08);
	--radius: 8px;
}

* {
	box-sizing: border-box;
}

html {
	background: var(--bg);
	color: var(--ink);
	font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
	font-size: 16px;
}

body {
	margin: 0;
	min-height: 100vh;
}

button,
input,
select,
textarea {
	font: inherit;
}

button {
	cursor: pointer;
}

svg {
	fill: none;
	stroke: currentColor;
	stroke-linecap: round;
	stroke-linejoin: round;
	stroke-width: 2;
}

.svg-sprite {
	display: none;
}

.app-shell {
	margin: 0 auto;
	max-width: 1440px;
	min-height: 100vh;
	padding: 18px;
}

.topbar {
	align-items: center;
	display: flex;
	gap: 16px;
	justify-content: space-between;
	margin-bottom: 14px;
}

.brand-lockup {
	align-items: center;
	display: flex;
	gap: 12px;
	min-width: 0;
}

.brand-mark {
	align-items: center;
	background: var(--brand);
	border-radius: var(--radius);
	color: #fff;
	display: inline-flex;
	height: 44px;
	justify-content: center;
	width: 44px;
}

.brand-mark svg {
	height: 24px;
	width: 24px;
}

.brand-lockup h1 {
	font-size: 22px;
	line-height: 1.2;
	margin: 0;
}

.brand-lockup p,
.muted {
	color: var(--muted);
	margin: 3px 0 0;
}

.top-actions,
.toolbar,
.button-row {
	align-items: center;
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.app-tabs {
	background: var(--surface);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	display: grid;
	gap: 4px;
	grid-template-columns: repeat(5, minmax(0, 1fr));
	margin-bottom: 18px;
	padding: 4px;
	position: sticky;
	top: 0;
	z-index: 5;
}

.tab-button {
	align-items: center;
	background: transparent;
	border: 0;
	border-radius: 6px;
	color: var(--muted);
	display: inline-flex;
	gap: 8px;
	justify-content: center;
	min-height: 42px;
	padding: 8px 10px;
}

.tab-button svg {
	height: 18px;
	width: 18px;
}

.tab-button.active {
	background: var(--brand);
	color: #fff;
}

.view {
	display: none;
}

.view.active {
	display: block;
}

.view-head {
	align-items: flex-start;
	display: flex;
	gap: 16px;
	justify-content: space-between;
	margin-bottom: 14px;
}

.view-head h2 {
	font-size: 24px;
	line-height: 1.2;
	margin: 0;
}

.panel {
	background: var(--surface);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	box-shadow: var(--shadow);
	margin-bottom: 16px;
	padding: 14px;
}

.panel h3 {
	font-size: 16px;
	margin: 0 0 12px;
}

.panel-toolbar {
	align-items: center;
	display: flex;
	gap: 10px;
	justify-content: space-between;
	margin-bottom: 12px;
}

.toolbar-button,
.icon-button {
	align-items: center;
	border: 1px solid var(--line);
	border-radius: 6px;
	display: inline-flex;
	font-weight: 700;
	gap: 7px;
	justify-content: center;
	min-height: 38px;
	white-space: nowrap;
}

.toolbar-button {
	background: #fff;
	color: var(--ink);
	padding: 8px 12px;
}

.toolbar-button svg,
.icon-button svg {
	height: 17px;
	width: 17px;
}

.toolbar-button.primary,
.toolbar-button.active {
	background: var(--brand);
	border-color: var(--brand);
	color: #fff;
}

.toolbar-button.ghost {
	background: var(--surface-soft);
}

.toolbar-button.compact {
	min-height: 36px;
	padding: 7px 10px;
}

.icon-button {
	background: #fff;
	color: var(--ink);
	height: 38px;
	padding: 0;
	width: 38px;
}

.file-button input {
	display: none;
}

.field {
	display: grid;
	gap: 6px;
}

.field span {
	color: var(--muted);
	font-size: 12px;
	font-weight: 800;
	text-transform: uppercase;
}

.field input,
.field select,
.search-box input,
textarea {
	background: #fff;
	border: 1px solid var(--line);
	border-radius: 6px;
	color: var(--ink);
	min-height: 38px;
	padding: 8px 10px;
	width: 100%;
}

.compact-field {
	min-width: 160px;
}

.search-box {
	align-items: center;
	background: #fff;
	border: 1px solid var(--line);
	border-radius: 6px;
	display: flex;
	flex: 1 1 260px;
	gap: 8px;
	min-height: 40px;
	padding: 0 10px;
}

.search-box svg {
	color: var(--muted);
	height: 17px;
	width: 17px;
}

.search-box input {
	border: 0;
	min-height: 38px;
	outline: 0;
	padding: 0;
}

.toggle-row {
	align-items: center;
	display: inline-flex;
	gap: 8px;
}

.toggle-row input {
	accent-color: var(--brand);
	height: 18px;
	width: 18px;
}

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

.stat-card {
	background: var(--surface);
	border: 1px solid var(--line);
	border-left: 4px solid var(--brand);
	border-radius: var(--radius);
	min-height: 82px;
	padding: 12px;
}

.stat-card strong {
	display: block;
	font-size: 23px;
	line-height: 1.1;
}

.stat-card span {
	color: var(--muted);
	display: block;
	font-size: 13px;
	margin-top: 6px;
}

.table-wrap {
	overflow-x: auto;
}

.data-table {
	border-collapse: collapse;
	min-width: 850px;
	width: 100%;
}

.data-table th,
.data-table td {
	border-bottom: 1px solid var(--line);
	padding: 10px;
	text-align: left;
	vertical-align: middle;
}

.data-table th {
	background: var(--surface-soft);
	color: var(--muted);
	font-size: 12px;
	text-transform: uppercase;
}

.data-table tr:last-child td {
	border-bottom: 0;
}

.employee-cell {
	min-width: 210px;
}

.employee-title {
	display: flex;
	flex-direction: column;
	gap: 3px;
}

.employee-title strong {
	font-size: 15px;
}

.employee-title span {
	color: var(--muted);
	font-size: 12px;
}

.status-group {
	display: grid;
	gap: 5px;
	grid-template-columns: repeat(4, 38px);
}

.status-pill {
	background: #fff;
	border: 1px solid var(--line);
	border-radius: 6px;
	font-size: 12px;
	font-weight: 900;
	height: 34px;
	padding: 0;
}

.status-pill.active[data-status="present"] {
	background: var(--green-soft);
	border-color: #7bc6a2;
	color: #0f5f36;
}

.status-pill.active[data-status="absent"] {
	background: var(--red-soft);
	border-color: #f0a59e;
	color: var(--red);
}

.status-pill.active[data-status="half"] {
	background: var(--amber-soft);
	border-color: #edc36e;
	color: var(--amber);
}

.status-pill.active[data-status="leave"] {
	background: var(--blue-soft);
	border-color: #91bce2;
	color: var(--blue);
}

.time-pair,
.number-pair {
	display: grid;
	gap: 6px;
	grid-template-columns: repeat(2, minmax(86px, 1fr));
	min-width: 190px;
}

.time-pair input,
.number-pair input,
.note-input {
	border: 1px solid var(--line);
	border-radius: 6px;
	min-height: 34px;
	padding: 6px 8px;
	width: 100%;
}

.note-input {
	min-width: 160px;
}

.source-badge {
	background: var(--surface-soft);
	border: 1px solid var(--line);
	border-radius: 999px;
	color: var(--muted);
	display: inline-flex;
	font-size: 12px;
	font-weight: 800;
	padding: 4px 8px;
}

.source-badge.device {
	background: var(--blue-soft);
	color: var(--blue);
}

.employee-grid {
	display: grid;
	gap: 12px;
	grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.employee-card {
	background: var(--surface-soft);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	display: grid;
	gap: 12px;
	padding: 12px;
}

.employee-card-head {
	align-items: flex-start;
	display: flex;
	gap: 10px;
	justify-content: space-between;
}

.employee-card h3 {
	font-size: 17px;
	margin: 0 0 3px;
}

.badge {
	border: 1px solid var(--line);
	border-radius: 999px;
	display: inline-flex;
	font-size: 12px;
	font-weight: 800;
	padding: 3px 8px;
}

.badge.active {
	background: var(--green-soft);
	color: #0f5f36;
}

.badge.inactive {
	background: #eef0f0;
	color: var(--muted);
}

.meta-list {
	display: grid;
	gap: 6px;
	grid-template-columns: repeat(2, minmax(0, 1fr));
}

.meta-list span {
	color: var(--muted);
	font-size: 12px;
}

.meta-list strong {
	display: block;
	font-size: 14px;
	margin-top: 2px;
	overflow-wrap: anywhere;
}

.card-actions {
	display: flex;
	gap: 8px;
	justify-content: flex-end;
}

.report-filters {
	justify-content: flex-start;
}

.payment-form {
	align-items: end;
	display: grid;
	gap: 12px;
	grid-template-columns: 150px minmax(180px, 1fr) 170px 150px 140px minmax(180px, 1fr) auto;
}

.payment-note-field {
	min-width: 180px;
}

.payment-type-badge {
	border: 1px solid var(--line);
	border-radius: 999px;
	display: inline-flex;
	font-size: 12px;
	font-weight: 800;
	padding: 4px 8px;
}

.payment-type-badge.advance,
.payment-type-badge.deduction {
	background: var(--amber-soft);
	color: var(--amber);
}

.payment-type-badge.salary_payment,
.payment-type-badge.balance_payment {
	background: var(--green-soft);
	color: #0f5f36;
}

.payment-type-badge.bonus {
	background: var(--blue-soft);
	color: var(--blue);
}

.device-layout {
	display: grid;
	gap: 16px;
	grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
}

.token-box,
.payload-box {
	background: #14231f;
	border-radius: 6px;
	color: #d7f5e9;
	font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
	font-size: 13px;
	line-height: 1.5;
	margin-bottom: 12px;
	overflow-x: auto;
	padding: 12px;
	white-space: pre;
}

.device-fields {
	display: grid;
	gap: 10px;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	margin-bottom: 12px;
}

textarea {
	font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
	line-height: 1.5;
	resize: vertical;
}

.empty-state {
	align-items: center;
	background: var(--surface-soft);
	border: 1px dashed #adc0b8;
	border-radius: var(--radius);
	display: grid;
	gap: 8px;
	justify-items: center;
	margin-top: 12px;
	padding: 24px;
	text-align: center;
}

.empty-state span {
	color: var(--muted);
}

dialog {
	border: 0;
	border-radius: var(--radius);
	box-shadow: 0 24px 80px rgba(16, 27, 24, 0.26);
	max-width: 720px;
	padding: 0;
	width: calc(100% - 24px);
}

.ledger-dialog {
	max-width: 820px;
}

dialog::backdrop {
	background: rgba(15, 28, 24, 0.42);
}

.employee-form,
.export-dialog {
	background: var(--surface);
	padding: 16px;
}

.dialog-head,
.dialog-actions {
	align-items: center;
	display: flex;
	gap: 12px;
	justify-content: space-between;
}

.dialog-head {
	border-bottom: 1px solid var(--line);
	margin: -16px -16px 16px;
	padding: 14px 16px;
}

.dialog-head h2 {
	font-size: 20px;
	margin: 0;
}

.export-dialog textarea {
	margin-top: 12px;
	min-height: 260px;
}

.ledger-view {
	background: var(--surface);
	max-height: min(92vh, 900px);
	overflow: hidden;
	padding: 0;
}

.ledger-head {
	align-items: center;
	border-bottom: 1px solid var(--line);
	display: grid;
	gap: 12px;
	grid-template-columns: 42px minmax(0, 1fr) auto;
	padding: 14px;
}

.ledger-head h2 {
	font-size: 22px;
	margin: 0;
}

.ledger-toolbar {
	align-items: end;
	background: var(--surface-soft);
	display: flex;
	gap: 12px;
	justify-content: space-between;
	padding: 12px 14px;
}

.ledger-stats {
	grid-template-columns: repeat(4, minmax(0, 1fr));
	margin: 0;
	padding: 14px;
}

.ledger-report-button {
	align-items: center;
	background: var(--blue-soft);
	border: 0;
	color: var(--blue);
	display: flex;
	font-size: 18px;
	font-weight: 900;
	gap: 10px;
	justify-content: center;
	min-height: 58px;
	width: 100%;
}

.ledger-report-button svg {
	height: 22px;
	width: 22px;
}

.ledger-table-wrap {
	max-height: 52vh;
	overflow: auto;
}

.ledger-table {
	min-width: 680px;
}

.ledger-date {
	color: var(--ink);
	display: grid;
	font-size: 18px;
	font-weight: 900;
	justify-items: center;
	line-height: 1.15;
	min-width: 70px;
}

.ledger-date span {
	color: var(--muted);
	font-size: 14px;
	font-weight: 700;
	margin-top: 4px;
}

.ledger-attendance-actions {
	align-items: center;
	display: flex;
	flex-wrap: wrap;
	gap: 7px;
	min-width: 250px;
}

.ledger-status-button,
.ledger-ot-button {
	background: #fff;
	border: 1px solid var(--line);
	border-radius: 8px;
	font-size: 15px;
	font-weight: 900;
	height: 42px;
	min-width: 42px;
	padding: 0 10px;
}

.ledger-status-button.active[data-status="present"] {
	background: var(--green-soft);
	border-color: #70bd9c;
	color: #0f5f36;
}

.ledger-status-button.active[data-status="absent"] {
	background: var(--red-soft);
	border-color: #ec8e86;
	color: var(--red);
}

.ledger-status-button.active[data-status="half"] {
	background: var(--amber-soft);
	border-color: #dfb14f;
	color: var(--amber);
}

.ledger-status-button.active[data-status="leave"] {
	background: var(--blue-soft);
	border-color: #88b8df;
	color: var(--blue);
}

.ledger-ot-button.active {
	background: #f5e9f7;
	border-color: #9d61a8;
	color: #6d3477;
}

.ledger-money-note {
	display: grid;
	gap: 7px;
	grid-template-columns: 120px minmax(180px, 1fr);
}

.ledger-money-note input {
	border: 1px solid var(--line);
	border-radius: 6px;
	min-height: 38px;
	padding: 7px 9px;
	width: 100%;
}

.form-grid {
	display: grid;
	gap: 12px;
	grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-toggle {
	align-self: end;
	min-height: 38px;
}

.dialog-actions {
	border-top: 1px solid var(--line);
	margin: 16px -16px -16px;
	padding: 14px 16px;
}

.toast {
	background: #14231f;
	border-radius: 6px;
	bottom: 18px;
	box-shadow: var(--shadow);
	color: #fff;
	left: 50%;
	max-width: min(420px, calc(100% - 24px));
	opacity: 0;
	padding: 11px 14px;
	pointer-events: none;
	position: fixed;
	transform: translate(-50%, 12px);
	transition: opacity 160ms ease, transform 160ms ease;
	z-index: 20;
}

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

.sr-only {
	clip: rect(0 0 0 0);
	border: 0;
	height: 1px;
	margin: -1px;
	overflow: hidden;
	padding: 0;
	position: absolute;
	white-space: nowrap;
	width: 1px;
}

@media (max-width: 1100px) {
	.stat-grid {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}

	.device-layout {
		grid-template-columns: 1fr;
	}

	.payment-form {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

@media (max-width: 760px) {
	.app-shell {
		padding: 12px;
	}

	.topbar,
	.view-head,
	.panel-toolbar {
		align-items: stretch;
		flex-direction: column;
	}

	.top-actions,
	.toolbar,
	.button-row {
		justify-content: flex-start;
	}

	.app-tabs {
		bottom: 0;
		margin-bottom: 12px;
		position: sticky;
		top: auto;
	}

	.tab-button {
		flex-direction: column;
		font-size: 12px;
		gap: 3px;
		min-height: 54px;
	}

	.stat-grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}

	.form-grid,
	.device-fields,
	.payment-form {
		grid-template-columns: 1fr;
	}

	.ledger-dialog {
		height: 100vh;
		max-height: 100vh;
		max-width: 100vw;
		width: 100vw;
	}

	.ledger-view {
		max-height: 100vh;
	}

	.ledger-toolbar {
		align-items: stretch;
		flex-direction: column;
	}

	.ledger-stats {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}

	.ledger-table {
		min-width: 560px;
	}

	.ledger-money-note {
		grid-template-columns: 100px minmax(160px, 1fr);
	}

	.compact-field,
	.search-box {
		min-width: 0;
		width: 100%;
	}
}

@media (max-width: 430px) {
	.brand-lockup h1 {
		font-size: 19px;
	}

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