:root {
	--primary: #1B6B4A;
	--primary-dark: #14503A;
	--primary-light: #28996B;
	--primary-bg: rgba(27, 107, 74, 0.08);
	--accent: #D4A843;
	--accent-light: #F0D68A;

	--text: #1C2B23;
	--text-secondary: #3A4F42;
	--text-muted: #6B7F73;
	--text-light: #8FA398;

	--bg: #F0F3F1;
	--bg-white: #FFFFFF;
	--bg-hover: #E8EDE9;
	--bg-zebra: #F5F8F6;
	--bg-card: #FFFFFF;

	--border: #B8C7BE;
	--border-light: #D4DDD8;

	--success: #1B8A50;
	--warning: #C48B1A;
	--danger: #C43333;
	--info: #2B7A9B;

	--radius: 8px;
	--radius-lg: 12px;
	--shadow: 0 1px 4px rgba(0,0,0,0.06), 0 2px 8px rgba(0,0,0,0.04);
	--shadow-lg: 0 4px 20px rgba(0,0,0,0.10);

	--font: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
	font-family: var(--font);
	font-size: 14px;
	line-height: 1.4;
	color: var(--text);
	background: var(--bg);
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 1.4rem; font-weight: 700; }
h2 { font-size: 1.2rem; font-weight: 600; }
h3 { font-size: 1rem; font-weight: 600; }

/* Layout */
.app-shell {
	display: grid;
	grid-template-columns: 220px 1fr;
	min-height: 100vh;
}

.sidebar {
	background: var(--primary-dark);
	color: #fff;
	padding: 20px 0;
	display: flex;
	flex-direction: column;
}

.sidebar-brand {
	padding: 0 16px 20px;
	border-bottom: 1px solid rgba(255,255,255,0.1);
	margin-bottom: 12px;
}

.sidebar-brand h1 {
	font-size: 1.1rem;
	color: #fff;
	letter-spacing: 0.5px;
}

.sidebar-brand small {
	font-size: 11px;
	color: rgba(255,255,255,0.5);
	display: block;
	margin-top: 2px;
}

.sidebar-nav { flex: 1; }

.sidebar-nav a {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 10px 16px;
	color: rgba(255,255,255,0.7);
	font-size: 13px;
	font-weight: 500;
	transition: all 0.15s ease;
}

.sidebar-nav a:hover {
	background: rgba(255,255,255,0.08);
	color: #fff;
	text-decoration: none;
}

.sidebar-nav a.active {
	background: rgba(255,255,255,0.12);
	color: #fff;
	border-left: 3px solid var(--accent);
	padding-left: 13px;
}

.sidebar-nav a svg { opacity: 0.7; flex-shrink: 0; }
.sidebar-nav a.active svg { opacity: 1; }

.sidebar-footer {
	padding: 12px 16px;
	border-top: 1px solid rgba(255,255,255,0.1);
	margin-top: auto;
}

.sidebar-footer .user-info {
	font-size: 12px;
	color: rgba(255,255,255,0.6);
}

.sidebar-footer .user-info strong {
	color: rgba(255,255,255,0.9);
	display: block;
}

.main-content {
	padding: 24px;
	max-width: 1400px;
}

.page-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 20px;
}

/* Cards */
.card {
	background: var(--bg-white);
	border: 1px solid var(--border-light);
	border-radius: var(--radius-lg);
	box-shadow: var(--shadow);
}

.card-header {
	padding: 14px 16px;
	border-bottom: 1px solid var(--border-light);
	display: flex;
	align-items: center;
	justify-content: space-between;
}

.card-body { padding: 16px; }

/* Forms */
.form-group { margin-bottom: 12px; }

.form-group label {
	display: block;
	font-size: 12px;
	font-weight: 600;
	color: var(--text-secondary);
	margin-bottom: 4px;
	text-transform: uppercase;
	letter-spacing: 0.3px;
}

.form-group input,
.form-group select,
.form-group textarea {
	width: 100%;
	height: 32px;
	padding: 0 10px;
	font-family: var(--font);
	font-size: 14px;
	border: 1px solid var(--border);
	border-radius: var(--radius);
	background: var(--bg-white);
	color: var(--text);
	transition: border-color 0.15s ease;
}

.form-group textarea {
	height: auto;
	min-height: 60px;
	padding: 8px 10px;
	resize: vertical;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
	outline: none;
	border-color: var(--primary);
	box-shadow: 0 0 0 3px var(--primary-bg);
}

.form-row {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 12px;
}

.form-row-3 {
	display: grid;
	grid-template-columns: 1fr 1fr 1fr;
	gap: 12px;
}

.password-wrap {
	position: relative;
}

.password-wrap input { padding-right: 36px; }

.pw-toggle {
	position: absolute;
	right: 6px;
	top: 50%;
	transform: translateY(-50%);
	background: none;
	border: none;
	cursor: pointer;
	color: var(--text-muted);
	padding: 4px;
	display: flex;
	align-items: center;
}

.pw-toggle:hover { color: var(--text); }

/* Buttons */
.btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	height: 32px;
	padding: 0 14px;
	font-family: var(--font);
	font-size: 13px;
	font-weight: 600;
	border: 1px solid transparent;
	border-radius: var(--radius);
	cursor: pointer;
	transition: all 0.15s ease;
}

.btn-primary {
	background: var(--primary);
	color: #fff;
}

.btn-primary:hover { background: var(--primary-dark); }

.btn-secondary {
	background: var(--bg);
	color: var(--text-secondary);
	border-color: var(--border);
}

.btn-secondary:hover { background: var(--bg-hover); }

.btn-danger {
	background: var(--danger);
	color: #fff;
}

.btn-danger:hover { background: #a82a2a; }

.btn-sm {
	height: 26px;
	padding: 0 10px;
	font-size: 12px;
}

.btn-full { width: 100%; }

.btn-icon {
	width: 28px;
	height: 28px;
	padding: 0;
	border-radius: 6px;
}

/* Tables */
.table-wrap { overflow-x: auto; }

table.table {
	width: 100%;
	border-collapse: collapse;
}

table.table th,
table.table td {
	padding: 8px 12px;
	text-align: left;
	border-bottom: 1px solid var(--border-light);
	font-size: 13px;
	height: 32px;
}

table.table th {
	font-weight: 600;
	color: var(--text-secondary);
	font-size: 11px;
	text-transform: uppercase;
	letter-spacing: 0.4px;
	background: var(--bg);
}

table.table tbody tr:nth-child(even) { background: var(--bg-zebra); }
table.table tbody tr:hover { background: var(--bg-hover); }
table.table tbody tr.inactive { opacity: 0.5; }

/* Badges */
.badge {
	display: inline-flex;
	align-items: center;
	padding: 2px 8px;
	font-size: 11px;
	font-weight: 600;
	border-radius: 20px;
	letter-spacing: 0.3px;
}

.badge-county {
	background: rgba(43, 122, 155, 0.12);
	color: var(--info);
}

.badge-city {
	background: var(--primary-bg);
	color: var(--primary);
}

.badge-yes {
	background: rgba(27, 138, 80, 0.1);
	color: var(--success);
}

.badge-no {
	background: rgba(196, 51, 51, 0.1);
	color: var(--danger);
}

.badge-active {
	background: rgba(27, 138, 80, 0.1);
	color: var(--success);
}

.badge-inactive {
	background: rgba(196, 51, 51, 0.1);
	color: var(--danger);
}

/* Permit Checklist */
.permit-checklist {
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.checklist-item {
	display: flex;
	flex-direction: column;
	gap: 2px;
	padding: 8px 12px;
	background: var(--bg);
	border-radius: var(--radius);
	border-left: 3px solid var(--primary);
}

.checklist-label {
	font-size: 11px;
	font-weight: 600;
	color: var(--text-muted);
	text-transform: uppercase;
	letter-spacing: 0.3px;
}

.checklist-value {
	font-size: 14px;
	color: var(--text);
}

.checklist-value a { color: var(--primary); font-weight: 500; }

/* Text helpers */
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 12px; }
.text-center { text-align: center; }

/* AHJ Detail Card */
.ahj-detail-card {
	display: flex;
	flex-direction: column;
	gap: 16px;
}

.ahj-meta {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
	gap: 10px;
}

.ahj-meta-item {
	padding: 10px 12px;
	background: var(--bg);
	border-radius: var(--radius);
}

.ahj-meta-label {
	font-size: 11px;
	font-weight: 600;
	color: var(--text-muted);
	text-transform: uppercase;
	letter-spacing: 0.3px;
}

.ahj-meta-value {
	font-size: 14px;
	margin-top: 2px;
}

/* Lookup layout */
.lookup-layout {
	display: grid;
	grid-template-columns: 320px 1fr;
	gap: 20px;
	align-items: start;
}

.ahj-list-item {
	padding: 10px 14px;
	cursor: pointer;
	border-bottom: 1px solid var(--border-light);
	transition: background 0.1s ease;
	display: flex;
	align-items: center;
	justify-content: space-between;
}

.ahj-list-item:hover { background: var(--bg-hover); }
.ahj-list-item.selected { background: var(--primary-bg); border-left: 3px solid var(--primary); }

.ahj-list-item .ahj-item-name {
	font-weight: 500;
	font-size: 13px;
}

.ahj-list-item .ahj-item-type {
	font-size: 11px;
}

/* NOC Calculator */
.noc-calc {
	display: flex;
	gap: 10px;
	align-items: end;
	padding: 12px;
	background: var(--bg);
	border-radius: var(--radius);
	margin-top: 8px;
}

.noc-calc .form-group { margin-bottom: 0; flex: 1; }

.noc-result {
	padding: 10px 14px;
	border-radius: var(--radius);
	font-weight: 600;
	font-size: 13px;
	margin-top: 8px;
}

.noc-result.required {
	background: rgba(196, 139, 26, 0.12);
	color: var(--warning);
	border: 1px solid rgba(196, 139, 26, 0.3);
}

.noc-result.not-required {
	background: rgba(27, 138, 80, 0.1);
	color: var(--success);
	border: 1px solid rgba(27, 138, 80, 0.2);
}

/* Empty state */
.empty-state {
	text-align: center;
	padding: 48px 20px;
	color: var(--text-muted);
}

.empty-state svg { margin-bottom: 12px; opacity: 0.4; }
.empty-state h3 { margin-bottom: 4px; color: var(--text-secondary); }
.empty-state p { font-size: 13px; }

/* Modal */
.modal-overlay {
	position: fixed;
	inset: 0;
	background: rgba(0,0,0,0.5);
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 1000;
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.2s ease;
}

.modal-overlay.open {
	opacity: 1;
	pointer-events: auto;
}

.modal {
	background: var(--bg-white);
	border-radius: var(--radius-lg);
	box-shadow: var(--shadow-lg);
	width: 90%;
	max-width: 640px;
	max-height: 85vh;
	overflow-y: auto;
}

.modal-header {
	padding: 14px 16px;
	border-bottom: 1px solid var(--border-light);
	display: flex;
	align-items: center;
	justify-content: space-between;
}

.modal-header h2 { font-size: 1.1rem; }

.modal-close {
	background: none;
	border: none;
	cursor: pointer;
	color: var(--text-muted);
	font-size: 20px;
	line-height: 1;
	padding: 4px;
}

.modal-close:hover { color: var(--text); }

.modal-body { padding: 16px; }

.modal-footer {
	padding: 12px 16px;
	border-top: 1px solid var(--border-light);
	display: flex;
	gap: 8px;
	justify-content: flex-end;
}

/* Toggle switch */
.toggle {
	position: relative;
	display: inline-block;
	width: 36px;
	height: 20px;
	cursor: pointer;
}

.toggle input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
	position: absolute;
	inset: 0;
	background: var(--border);
	border-radius: 20px;
	transition: background 0.2s ease;
}

.toggle-slider::before {
	content: '';
	position: absolute;
	width: 16px;
	height: 16px;
	left: 2px;
	top: 2px;
	background: #fff;
	border-radius: 50%;
	transition: transform 0.2s ease;
}

.toggle input:checked + .toggle-slider {
	background: var(--primary);
}

.toggle input:checked + .toggle-slider::before {
	transform: translateX(16px);
}

/* Login page */
.login-page {
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 100vh;
	background: linear-gradient(145deg, #0D3B26 0%, #1B6B4A 50%, #14503A 100%);
}

.login-container { width: 100%; max-width: 380px; padding: 20px; }

.login-card {
	background: var(--bg-white);
	border-radius: var(--radius-lg);
	box-shadow: var(--shadow-lg);
	overflow: hidden;
}

.login-header {
	padding: 28px 24px 20px;
	text-align: center;
	background: var(--bg);
	border-bottom: 1px solid var(--border-light);
}

.login-header h1 {
	color: var(--primary);
	font-size: 1.5rem;
	letter-spacing: 1px;
}

.login-header p {
	color: var(--text-muted);
	font-size: 12px;
	margin-top: 4px;
	text-transform: uppercase;
	letter-spacing: 1.5px;
}

.login-card form { padding: 24px; }

.error-msg {
	background: rgba(196, 51, 51, 0.08);
	color: var(--danger);
	border: 1px solid rgba(196, 51, 51, 0.2);
	border-radius: var(--radius);
	padding: 8px 12px;
	font-size: 13px;
	margin-bottom: 12px;
}

.success-msg {
	background: rgba(27, 138, 80, 0.08);
	color: var(--success);
	border: 1px solid rgba(27, 138, 80, 0.2);
	border-radius: var(--radius);
	padding: 8px 12px;
	font-size: 13px;
	margin-bottom: 12px;
}

/* Toast */
.toast {
	position: fixed;
	bottom: 20px;
	right: 20px;
	padding: 10px 16px;
	border-radius: var(--radius);
	font-size: 13px;
	font-weight: 500;
	box-shadow: var(--shadow-lg);
	z-index: 2000;
	transform: translateY(80px);
	opacity: 0;
	transition: all 0.3s ease;
}

.toast.show {
	transform: translateY(0);
	opacity: 1;
}

.toast-success { background: var(--success); color: #fff; }
.toast-error { background: var(--danger); color: #fff; }

/* Print */
@media print {
	.sidebar, .page-header, .noc-calc, .btn, .no-print { display: none !important; }
	.app-shell { display: block; }
	.main-content { padding: 0; max-width: 100%; }
	.card { border: none; box-shadow: none; }
	.checklist-item { border-left-color: #333; }
	body { background: #fff; }
}

/* Responsive */
@media (max-width: 900px) {
	.app-shell { grid-template-columns: 1fr; }
	.sidebar {
		position: fixed;
		left: -260px;
		top: 0;
		bottom: 0;
		width: 220px;
		z-index: 500;
		transition: left 0.25s ease;
	}
	.sidebar.open { left: 0; }
	.lookup-layout { grid-template-columns: 1fr; }
	.form-row { grid-template-columns: 1fr; }
	.form-row-3 { grid-template-columns: 1fr; }
}
