html,
body {
	min-height: 100%;
}

*,
*::before,
*::after {
	box-sizing: border-box;
}

body {
	margin: 0;
	background: #eef2f5;
	color: #172026;
	font-family: "Segoe UI", Arial, sans-serif;
	font-size: 15px;
}

button,
input,
select {
	max-width: 100%;
}

.app-shell {
	width: min(1180px, calc(100% - 28px));
	margin: 0 auto;
	padding: 24px 0;
}

.topbar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	margin-bottom: 18px;
	padding: 18px 20px;
	background: #ffffff;
	border: 1px solid #dce3e8;
	border-radius: 8px;
	box-shadow: 0 10px 24px rgba(22, 32, 38, 0.08);
}

.system-label,
.section-kicker {
	display: block;
	color: #637381;
	font-size: 12px;
	font-weight: 700;
	letter-spacing: 0;
	text-transform: uppercase;
}

.topbar h1,
.panel-box h2 {
	margin: 2px 0 0;
	font-weight: 700;
	letter-spacing: 0;
}

.topbar h1 {
	font-size: 25px;
	line-height: 1.18;
}

.topbar h1 strong {
	color: #009f43;
	font-weight: 800;
}

.topbar-clock {
	min-width: 158px;
	text-align: right;
	color: #637381;
}

.topbar-clock strong {
	display: block;
	color: #0b3b3c;
	font-size: 25px;
	line-height: 1.1;
}

.layout {
	display: grid;
	grid-template-columns: minmax(320px, 0.9fr) minmax(340px, 1.1fr);
	gap: 18px;
	align-items: start;
}

.panel-box {
	background: #ffffff;
	border: 1px solid #dce3e8;
	border-radius: 8px;
	box-shadow: 0 10px 24px rgba(22, 32, 38, 0.08);
}

.panel-box-heading {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 14px;
	padding: 18px 18px 14px;
	border-bottom: 1px solid #e8edf1;
}

.panel-box-heading.compact {
	padding-bottom: 12px;
}

.panel-box h2 {
	font-size: 19px;
}

.panel-box h2 i {
	color: #11786f;
}

.scanner-panel {
	min-height: auto;
}

.camera-select {
	width: 230px;
	max-width: 45%;
	height: 36px;
	border-radius: 6px;
}

.scanner-frame {
	position: relative;
	width: min(100% - 36px, 420px);
	margin: 18px auto;
	overflow: hidden;
	background: #101820;
	border: 1px solid #111820;
	border-radius: 8px;
	aspect-ratio: 4 / 3;
	min-height: 0;
	max-height: 315px;
}

#preview {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.scanner-line {
	position: absolute;
	z-index: 2;
	left: 5%;
	right: 5%;
	top: 18%;
	height: 2px;
	background: #19c37d;
	box-shadow: 0 0 14px rgba(25, 195, 125, 0.9);
	animation: scanLine 2.8s linear infinite;
}

@keyframes scanLine {
	0% {
		transform: translateY(0);
	}

	50% {
		transform: translateY(260px);
	}

	100% {
		transform: translateY(0);
	}
}

.camera-status {
	width: min(100% - 36px, 420px);
	margin: 0 auto 18px;
	padding: 10px 12px;
	background: #f6f8fa;
	border: 1px solid #dce3e8;
	border-radius: 6px;
	color: #52616b;
}

.side-stack {
	display: grid;
	gap: 18px;
}

.control-panel {
	padding-bottom: 18px;
}

.mode-toggle {
	display: grid;
	grid-template-columns: 1fr 1fr;
	width: calc(100% - 36px);
	margin: 18px;
}

.mode-toggle .btn {
	height: 42px;
	border-color: #cfd8df;
	font-weight: 700;
	white-space: normal;
}

.mode-toggle .btn.active {
	color: #ffffff;
	background: #11786f;
	border-color: #11786f;
	box-shadow: none;
}

.mode-toggle .btn.auto-ready {
	background: #1f76d2;
	border-color: #1f76d2;
}

.mode-toggle .btn.auto-disabled {
	color: #83919c;
	background: #eef2f5;
}

.auto-mode-info {
	width: calc(100% - 36px);
	margin: -8px 18px 16px;
	padding: 8px 10px;
	background: #f6f8fa;
	border: 1px solid #dce3e8;
	border-radius: 6px;
	color: #52616b;
	font-size: 13px;
	line-height: 1.35;
}

#formDni {
	margin: 0 18px;
}

#formDni label {
	display: block;
	margin-bottom: 7px;
	color: #52616b;
	font-weight: 700;
}

#txtDni,
#btnRegistrarDni {
	height: 46px;
}

#txtDni {
	min-width: 0;
}

#btnRegistrarDni {
	min-width: 58px;
	background: #185b9d;
	border-color: #185b9d;
}

.result-box {
	display: flex;
	gap: 12px;
	align-items: flex-start;
	margin: 18px 18px 0;
	padding: 14px;
	border-radius: 8px;
	border: 1px solid #dce3e8;
	background: #f6f8fa;
}

.result-box strong {
	display: block;
	margin-bottom: 2px;
}

.result-box p {
	margin: 0;
	color: #52616b;
	line-height: 1.35;
	overflow-wrap: anywhere;
}

.result-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 34px;
	height: 34px;
	flex: 0 0 34px;
	border-radius: 50%;
	background: #dce3e8;
	color: #52616b;
}

.result-box.success {
	background: #edf8f2;
	border-color: #a8dec1;
}

.result-box.success .result-icon {
	background: #19a463;
	color: #ffffff;
}

.result-box.warning {
	background: #fff8e8;
	border-color: #ecd08a;
}

.result-box.warning .result-icon {
	background: #b7791f;
	color: #ffffff;
}

.result-box.error {
	background: #fff1f0;
	border-color: #f0aaa5;
}

.result-box.error .result-icon {
	background: #c43d32;
	color: #ffffff;
}

.metrics-panel {
	display: grid;
	grid-template-columns: repeat(2, 1fr);
	gap: 0;
	overflow: hidden;
}

.metric-item {
	padding: 16px;
	border-right: 1px solid #e8edf1;
	border-bottom: 1px solid #e8edf1;
}

.metric-item:nth-child(2n) {
	border-right: 0;
}

.metric-item:nth-last-child(-n + 2) {
	border-bottom: 0;
}

.metric-item span {
	display: block;
	color: #637381;
	font-size: 13px;
	font-weight: 700;
}

.metric-item strong {
	display: block;
	margin-top: 3px;
	font-size: 30px;
	line-height: 1;
}

.accent-green {
	border-left: 4px solid #19a463;
}

.accent-amber {
	border-left: 4px solid #c0841a;
}

.accent-red {
	border-left: 4px solid #d14b42;
}

.accent-blue {
	border-left: 4px solid #2d6cdf;
}

.latest-panel {
	grid-column: 1 / -1;
}

.latest-panel .table-responsive {
	max-height: 470px;
	margin-bottom: 0;
	overflow: auto;
	border: 1px solid #9cccf2;
	border-top: 0;
}

.latest-panel .btn {
	width: 40px;
	height: 36px;
}

.latest-table {
	table-layout: fixed;
	margin-bottom: 0;
	background: #ffffff;
	border-collapse: collapse;
	font-size: 14px;
}

.latest-table thead th {
	position: sticky;
	z-index: 3;
	top: 0;
	padding: 5px 7px;
	background: linear-gradient(#f8fbff, #dbeeff);
	border: 1px solid #9cccf2;
	border-top: 0;
	color: #172026;
	font-size: 14px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0;
}

.latest-table thead th:nth-child(2) {
	background: linear-gradient(#ffe9d4, #ffd0a0);
}

.latest-table tbody td {
	padding: 4px 7px !important;
	border: 1px solid #a7d3f6;
	color: #0f1f2d;
	line-height: 1.2;
	vertical-align: middle;
}

.latest-table td,
.latest-table th {
	overflow-wrap: anywhere;
}

.latest-table tbody tr:nth-child(odd) td {
	background: #d9fbfb;
}

.latest-table tbody tr:nth-child(even) td {
	background: #ffffff;
}

.latest-table tbody tr:hover td,
.latest-table tbody tr.is-selected td {
	background: #72d9ed;
	color: #ffffff;
}

.col-rownum {
	width: 48px;
}

.col-hour {
	width: 132px;
}

.col-dni {
	width: 96px;
}

.col-student {
	width: auto;
}

.col-grade {
	width: 100px;
}

.col-status {
	width: 78px;
}

.col-level {
	width: 72px;
}

.th-rownum {
	position: relative;
}

.th-rownum::before {
	content: "";
	position: absolute;
	right: 8px;
	bottom: 6px;
	width: 0;
	height: 0;
	border-left: 18px solid transparent;
	border-bottom: 18px solid #4d83b4;
}

.cell-rownum {
	color: #0a476b;
	font-family: Consolas, "Courier New", monospace;
	font-size: 12px;
	text-align: right;
	white-space: nowrap;
}

.cell-hour,
.cell-dni,
.cell-center,
.cell-status {
	text-align: center;
	white-space: nowrap;
}

.cell-student {
	text-align: left;
	white-space: nowrap;
}

.cell-status {
	color: #ffffff !important;
	font-weight: 700;
}

.cell-status.state-f {
	background: #f40008 !important;
}

.cell-status.state-a {
	background: #0b9b4c !important;
}

.cell-status.state-t {
	background: #f2a300 !important;
}

.cell-status.state-j {
	background: #6a5acd !important;
}

.cell-status.state-s {
	background: #1f76d2 !important;
}

.badge-state {
	display: inline-block;
	min-width: 84px;
	padding: 5px 8px;
	border-radius: 999px;
	text-align: center;
	font-size: 12px;
	font-weight: 700;
}

.badge-state.asistio {
	color: #0d5a39;
	background: #dff5e9;
}

.badge-state.tardanza {
	color: #7b4b00;
	background: #fff0c2;
}

.badge-state.salida {
	color: #8f2720;
	background: #ffe1de;
}

.empty-row {
	padding: 24px !important;
	text-align: center;
	color: #637381;
}

.swal2-popup.scae-alert {
	border-radius: 8px;
	font-family: "Segoe UI", Arial, sans-serif;
}

.swal2-popup.scae-toast {
	border-radius: 8px;
	box-shadow: 0 12px 30px rgba(22, 32, 38, 0.18);
	font-family: "Segoe UI", Arial, sans-serif;
}

@media (max-width: 920px) {
	.layout {
		grid-template-columns: 1fr;
	}

	.scanner-panel {
		min-height: auto;
	}

	.scanner-frame,
	.camera-status {
		width: min(100% - 36px, 420px);
	}

	.side-stack {
		grid-template-columns: minmax(0, 1fr) minmax(280px, 0.7fr);
		align-items: start;
	}
}

@media (max-width: 760px) {
	.side-stack {
		grid-template-columns: 1fr;
	}

	.scanner-frame {
		aspect-ratio: 4 / 3;
		max-height: 330px;
	}

	.latest-panel .table-responsive {
		border: 0;
		margin-bottom: 0;
	}

	.latest-table,
	.latest-table thead,
	.latest-table tbody,
	.latest-table th,
	.latest-table td,
	.latest-table tr {
		display: block;
	}

	.latest-table thead {
		position: absolute;
		width: 1px;
		height: 1px;
		overflow: hidden;
		clip: rect(0, 0, 0, 0);
	}

	.latest-table tbody {
		padding: 12px;
	}

	.latest-table tbody tr {
		margin-bottom: 12px;
		padding: 12px;
		background: #ffffff;
		border: 1px solid #dce3e8;
		border-radius: 8px;
	}

	.latest-table tbody tr:last-child {
		margin-bottom: 0;
	}

	.latest-table tbody td {
		display: grid;
		grid-template-columns: 92px minmax(0, 1fr);
		gap: 10px;
		padding: 7px 0 !important;
		border-top: 0 !important;
	}

	.latest-table tbody td::before {
		content: attr(data-label);
		color: #637381;
		font-size: 12px;
		font-weight: 700;
		text-transform: uppercase;
	}

	.latest-table tbody td.empty-row {
		display: block;
	}

	.latest-table tbody td.empty-row::before {
		content: "";
	}
}

@media (max-width: 620px) {
	.app-shell {
		width: calc(100% - 18px);
		padding: 12px 0;
	}

	.topbar,
	.panel-box-heading {
		align-items: flex-start;
		flex-direction: column;
		gap: 10px;
	}

	.topbar-clock {
		width: 100%;
		text-align: left;
	}

	.camera-select {
		width: 100%;
		max-width: 100%;
	}

	.scanner-frame {
		margin: 12px;
		width: calc(100% - 24px);
		max-height: 300px;
	}

	.camera-status {
		width: calc(100% - 24px);
		margin: 0 12px 12px;
	}

	.mode-toggle,
	.auto-mode-info,
	#formDni,
	.result-box {
		width: calc(100% - 24px);
		margin-left: 12px;
		margin-right: 12px;
	}

	.auto-mode-info {
		margin-top: -4px;
	}

	.metrics-panel {
		grid-template-columns: 1fr;
	}

	.metric-item,
	.metric-item:nth-child(2n),
	.metric-item:nth-last-child(-n + 2) {
		border-right: 0;
		border-bottom: 1px solid #e8edf1;
	}

	.metric-item:last-child {
		border-bottom: 0;
	}
}

@media (max-width: 420px) {
	body {
		font-size: 14px;
	}

	.app-shell {
		width: calc(100% - 12px);
		padding: 6px 0;
	}

	.topbar {
		padding: 14px;
	}

	.topbar h1 {
		font-size: 21px;
	}

	.topbar-clock strong {
		font-size: 22px;
	}

	.panel-box-heading {
		padding: 14px;
	}

	.panel-box h2 {
		font-size: 17px;
	}

	.mode-toggle {
		grid-template-columns: 1fr;
	}

	.mode-toggle .btn {
		height: 44px;
		border-radius: 4px !important;
	}

	#formDni .input-group {
		display: grid;
		grid-template-columns: 44px minmax(0, 1fr) 52px;
		width: 100%;
	}

	#formDni .input-group-addon,
	#formDni .input-group-btn,
	#formDni .form-control,
	#btnRegistrarDni {
		display: block;
		width: 100%;
	}

	.latest-table tbody {
		padding: 10px;
	}

	.latest-table tbody td {
		grid-template-columns: 78px minmax(0, 1fr);
		gap: 8px;
	}
}
