body { font-family: Arial, sans-serif; margin: 0; padding: 20px; background: #f3f6fb; }
header { background: #1e88e5; color: #fff; padding: 10px 16px; border-radius: 6px; display: flex; flex-direction: column; align-items: flex-start; gap: 10px; max-width: 1400px; margin-left: auto; margin-right: auto; }
main { background: #fff; padding: 20px; border-radius: 6px; margin-top: 12px; max-width: 1400px; margin-left: auto; margin-right: auto; box-shadow: 0 2px 8px rgba(18,38,63,0.06); }

/* Navbar styles */
.main-nav { margin-top: 4px; display: flex; flex-wrap: wrap; gap: 6px; }
.main-nav a { color: #fff; text-decoration: none; padding: 6px 10px; border-radius: 6px; display: inline-block; background: rgba(255,255,255,0.03); border: 1px solid rgba(255,255,255,0.04); }
.main-nav a:hover { background: rgba(255,255,255,0.08); }
.main-nav a.active { background: rgba(255,255,255,0.22); font-weight: 600; border-color: rgba(255,255,255,0.2); }

/* Small tweaks for header text and nav spacing */
header h1 { margin: 0; font-size: 0; line-height: 0; }
header h1 a { display: inline-flex; align-items: center; }
header h1 img { display: block; height: auto; max-height: 80px; width: auto; object-fit: contain; }
header p { margin-left: 0; margin-top: 4px; }

/* Typography */
h2 { margin-top: 0; color: #163a63; }
h3 { color: #18497f; }

/* Tables */
table { width: 100%; border-collapse: collapse; background: #fff; }
table.form-table { width: auto; }
table.form-table tbody tr { background: none !important; border: none !important; }
table.form-table td { border: none !important; padding: 8px; vertical-align: middle; }
thead th { background: #eef4fb; color: #163a63; text-align: left; }
th, td { border-bottom: 1px solid #e5eaf2; padding: 10px; }
tbody tr:hover { background: #f7fbff; }
tbody tr:nth-child(even) { background: #fafcff; }

/* Forms */
label { display: inline-block; margin: 6px 0; color: #163a63; }
input[type="text"], input[type="password"], input[type="number"], input[type="email"], textarea, select {
  font-size: 14px; line-height: 1.4; padding: 8px 10px; border: 1px solid #cfd8e3; border-radius: 6px; background: #fff; color: #163a63;
}
textarea { width: 100%; }
input[style*="width:80px"] { width: 100px !important; }
.item-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.form-group { margin-bottom: 14px; display: flex; flex-direction: column; }
.form-group label { margin-bottom: 6px; font-weight: 500; }
.form-group input { width: 100%; }

/* Buttons */
button, .btn {
  background: #1976d2; color: #fff; border: 1px solid #166abf; border-radius: 6px; padding: 8px 12px; cursor: pointer; text-decoration: none; display: inline-block; font-size: 14px; font-family: Arial, sans-serif;
}
button:hover, .btn:hover { background: #166abf; }
button:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-secondary { background: #607d8b; border-color: #546e7a; }
.btn-danger { background: #d32f2f; border-color: #b71c1c; }

/* Utility spacing */
.mt-1 { margin-top: 6px; }
.mt-2 { margin-top: 12px; }
.mb-1 { margin-bottom: 6px; }
.mb-2 { margin-bottom: 12px; }

/* Footer */
footer { margin-top: 12px; background: #fff; padding: 16px 20px; border-radius: 6px; max-width: 1400px; margin-left: auto; margin-right: auto; box-shadow: 0 2px 8px rgba(18,38,63,0.06); text-align: center; color: #607d8b; }
footer p { margin: 0; }

/* Responsive tweaks */
@media (max-width: 768px) {
	body { padding: 12px; }
	header { padding: 8px 12px; gap: 8px; }
	header h1 img { max-height: 64px; }
	.main-nav a { padding: 5px 8px; }
	table { display: block; overflow-x: auto; }
}
@media (max-width: 480px) {
	header { padding: 6px 10px; }
	header h1 img { max-height: 56px; }
	.main-nav a { padding: 4px 7px; font-size: 13px; }
}

/* Materials library */
.materials-library-layout {
	display: grid;
	grid-template-columns: minmax(240px, 32%) 1fr;
	gap: 14px;
}

.materials-panel {
	background: #fff;
	border: 1px solid #e0e7f1;
	border-radius: 8px;
	padding: 14px;
}

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

.materials-search-row {
	margin-bottom: 10px;
}

.materials-search-row input {
	width: 100%;
}

.category-tree-list {
	list-style: none;
	margin: 0;
	padding-left: 14px;
}

.category-tree-list > li {
	margin: 4px 0;
}

.category-node-row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	border: 1px solid transparent;
	border-radius: 6px;
	padding: 4px 6px;
}

.category-node-row.active {
	background: #eaf3ff;
	border-color: #b9d6fb;
}

.category-node-select {
	background: none;
	border: 0;
	color: #163a63;
	padding: 0;
	text-align: left;
	cursor: pointer;
	font-size: 14px;
}

.category-node-count {
	color: #607d8b;
}

.library-modal {
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background: rgba(0, 0, 0, 0.45);
	z-index: 1000;
	justify-content: center;
	align-items: center;
}

.library-modal-content {
	background: #fff;
	width: min(680px, 92%);
	max-height: 90vh;
	overflow-y: auto;
	border-radius: 8px;
	padding: 18px;
}

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