/* datagrid.css — spreadsheet-style data entry for PSSR */

.dg-toolbar {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	justify-content: center;
	margin: 0.5em 0;
}

.dg-wrap {
	max-height: 26em;
	overflow: auto;
	border: 1px solid #9aa7b8;
	background: #fff;
	outline: none;
	position: relative;
	text-align: left;
}
.dg-wrap:focus,
.dg-wrap:focus-within {
	box-shadow: 0 0 0 2px rgba(0, 33, 74, 0.35);
}

table.datagrid {
	border-collapse: separate;
	border-spacing: 0;
	width: 100%;
	table-layout: fixed;
	margin: 0;
	font-family: 'Noto Mono', monospace;
	font-size: 14px;
	user-select: none;
	-webkit-user-select: none;
}

.datagrid th,
.datagrid td {
	border: 0;
	border-right: 1px solid #d5dbe3;
	border-bottom: 1px solid #d5dbe3;
	padding: 0 6px;
	height: 1.9em;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	text-align: left;
	color: #111;
}

/* Header: sticky, holds the existing #group1 / #group2 / #modvar inputs */
.datagrid thead th {
	position: sticky;
	top: 0;
	z-index: 3;
	background: #00214A;
	color: #fff;
	padding: 4px;
}
.datagrid thead input {
	width: 100%;
	box-sizing: border-box;
	margin: 0;
	font-weight: bold;
	text-align: left;
}
.datagrid .dg-corner {
	width: 3.5em;
	text-align: center;
	left: 0;
	z-index: 4;
}

/* Row numbers: sticky left */
.datagrid .dg-rownum {
	position: sticky;
	left: 0;
	z-index: 1;
	background: #eef1f5;
	color: #556;
	font-weight: normal;
	text-align: right;
	cursor: pointer;
}

/* Footer: n per column, sticky bottom */
.datagrid tfoot th,
.datagrid tfoot td {
	position: sticky;
	bottom: 0;
	z-index: 2;
	background: #eef1f5;
	font-weight: bold;
	border-top: 1px solid #9aa7b8;
}
.datagrid tfoot th { left: 0; z-index: 4; text-align: right; }

/* Cells */
.datagrid td {
	cursor: cell;
	background: #fff;
	scroll-margin: 2.4em 0 2.2em 3.5em;   /* keep revealed cells clear of sticky header/footer/row numbers */
}
.datagrid tbody tr:nth-child(even) td { background: #f8f9fb; }
.datagrid tbody td.sel { background: #dbe7f7; }
.datagrid tbody td.active { box-shadow: inset 0 0 0 2px #00214A; }
.datagrid td.editing { padding: 0; overflow: visible; }

.dg-editor {
	width: 100%;
	height: 100%;
	min-height: 1.9em;
	box-sizing: border-box;
	margin: 0;
	padding: 0 4px;
	border: 2px solid #00214A;
	outline: none;
	font: inherit;
	background: #fff;
}

/* Moderator column hidden unless "Show Moderating Variable" is checked */
.datagrid:not(.show-mod) .mod { display: none; }

.dg-status {
	font-size: 12px;
	color: #555;
	text-align: left;
	margin: 0.3em 0 0.8em;
	min-height: 1.3em;
}

.dg-options {
	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
	gap: 1em;
	text-align: left;
}
.dg-options .dg-depvar { flex: 1 1 18em; max-width: 26em; }
.dg-options .dg-depvar input[type=text] { width: 100%; box-sizing: border-box; }

.dg-help {
	font-size: 12px;
	color: #555;
	text-align: left;
}
