:root {
	--bg: #0a0d07;
	--panel: #fffdf8;
	--line: #b8cc72;
	--head: #101409;
	--text: #1e1a14;
	--muted: #5f6648;
	--accent: #a7ff16;
	--accent-dark: #5ba800;
	--danger: #9f251f;
	--warn: #9d751d;
	--table-alt: #f8f3ea;
	--input: #fff;
	--shadow: rgba(0, 0, 0, 0.22);
	font-family: Arial, Helvetica, sans-serif;
	color: var(--text);
	background: var(--bg);
}

* {
	box-sizing: border-box;
}

body {
	margin: 0;
	min-width: 320px;
	overflow-x: hidden;
	background:
		radial-gradient(circle at 18% 0%, rgba(167, 255, 22, 0.14), transparent 30%),
		var(--bg);
}

.topbar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	padding: 14px 18px;
	border-top: 3px solid #a7ff16;
	border-bottom: 1px solid rgba(167, 255, 22, 0.36);
	background:
		linear-gradient(90deg, rgba(167, 255, 22, 0.16), transparent 42%),
		var(--head);
	color: #f4f7e8;
}

.topbar-title {
	display: flex;
	align-items: center;
	gap: 14px;
	min-width: 0;
}

.brand-mini {
	display: inline-grid;
	grid-template-columns: 42px auto;
	align-items: center;
	gap: 10px;
	color: #f4f7e8;
	font-weight: 800;
	text-decoration: none;
}

.brand-mini span {
	display: grid;
	place-items: center;
	width: 42px;
	height: 42px;
	border: 1px solid #ddff72;
	border-radius: 8px;
	background: linear-gradient(135deg, #a7ff16, #d7ff66);
	color: #081003;
	box-shadow: 0 0 28px rgba(167, 255, 22, 0.34);
}

.brand-mini strong {
	display: none;
}

h1,
h2,
h3,
p {
	margin: 0;
}

h1 {
	font-size: 22px;
	line-height: 1.2;
}

h2 {
	font-size: 16px;
}

h3 {
	font-size: 14px;
	margin-bottom: 8px;
}

.topbar p {
	margin-top: 6px;
	color: #b8c09c;
	font-size: 13px;
}

.topbar .brand-line {
	margin: 0 0 5px;
	color: #a7ff16;
	font-size: 12px;
	font-weight: 800;
	text-transform: uppercase;
}

.top-actions,
.panel-head,
.button-slot {
	display: flex;
	align-items: center;
	gap: 8px;
}

.top-actions {
	flex-wrap: wrap;
	justify-content: flex-end;
}

.language-select {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	color: #b8c09c;
	font-size: 12px;
	font-weight: 800;
}

.language-select select {
	width: auto;
	min-height: 30px;
	border-color: #74644e;
	background: #f8f1e4;
	color: #16120d;
	font-weight: 700;
}

button {
	min-height: 30px;
	padding: 5px 12px;
	border: 1px solid #74644e;
	border-radius: 3px;
	background: #f8f1e4;
	color: #16120d;
	font-weight: 700;
	cursor: pointer;
}

.nav-home {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 30px;
	padding: 5px 12px;
	border: 1px solid #74644e;
	border-radius: 3px;
	background: #f8f1e4;
	color: #16120d;
	font-weight: 700;
	text-decoration: none;
}

button:hover {
	background: #efe3d0;
}

.nav-home:hover {
	background: #efe3d0;
}

button.primary,
button#syncBtn {
	border-color: var(--accent-dark);
	background: var(--accent);
	color: #071003;
}

button.primary:hover,
button#syncBtn:hover {
	background: var(--accent-dark);
	color: #fff;
}

.page {
	display: grid;
	grid-template-columns: minmax(380px, 0.43fr) minmax(560px, 0.57fr);
	gap: 10px;
	max-width: 1440px;
	margin: 0 auto;
	padding: 16px;
}

.panel {
	padding: 14px;
	border: 1px solid var(--line);
	border-radius: 8px;
	background: var(--panel);
	box-shadow: 0 10px 28px var(--shadow);
}

.wide-panel,
.sync-panel {
	grid-column: 1 / -1;
}

.panel-head {
	align-items: flex-start;
	flex-wrap: wrap;
	justify-content: space-between;
	margin-bottom: 10px;
}

.status,
.hint {
	color: var(--muted);
	font-size: 12px;
}

.status.is-ok {
	color: #4b8f00;
	font-weight: 700;
}

.status.is-warn {
	color: var(--warn);
	font-weight: 700;
}

.status.is-error {
	color: var(--danger);
	font-weight: 700;
}

.form-grid,
.levels-grid {
	display: grid;
	gap: 8px;
}

.sync-grid {
	grid-template-columns: minmax(160px, 1fr) minmax(190px, 1fr) minmax(120px, 0.7fr) auto;
	align-items: end;
}

.levels-grid {
	grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
}

.building-grid {
	grid-template-columns: repeat(4, minmax(110px, 1fr));
	max-width: 640px;
}

.bonus-grid {
	align-items: end;
	grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
}

label {
	display: flex;
	flex-direction: column;
	gap: 4px;
	min-width: 0;
	color: var(--muted);
	font-size: 12px;
	font-weight: 700;
}

.check-label {
	align-items: center;
	flex-direction: row;
	gap: 8px;
	min-height: 30px;
	padding-top: 0;
}

.check-label input {
	flex: 0 0 auto;
	width: auto;
	min-height: auto;
}

.check-label span {
	line-height: 1.15;
	overflow-wrap: anywhere;
}

input,
select,
textarea {
	width: 100%;
	min-width: 0;
	min-height: 30px;
	padding: 5px 7px;
	border: 1px solid var(--line);
	border-radius: 3px;
	background: var(--input);
	color: var(--text);
	font: inherit;
}

input:focus,
select:focus,
textarea:focus {
	outline: 2px solid rgba(47, 116, 93, 0.25);
	border-color: var(--accent);
}

input[type='number'] {
	text-align: right;
}

.sync-panel .hint {
	margin-top: 8px;
}

.table-wrap {
	width: 100%;
	overflow: auto;
	border: 1px solid #ddd2bf;
	border-radius: 6px;
	-webkit-overflow-scrolling: touch;
}

table {
	width: 100%;
	min-width: 760px;
	border-collapse: collapse;
	background: #fff;
	font-size: 13px;
}

th,
td {
	padding: 7px 8px;
	border-bottom: 1px solid #dfd4c2;
	text-align: left;
	vertical-align: middle;
	white-space: nowrap;
}

th {
	background: var(--head);
	font-weight: 700;
}

tbody tr:nth-child(even) td {
	background: var(--table-alt);
}

td.num,
th.num {
	text-align: right;
}

.unit-input {
	width: 100px;
}

.summary-grid {
	display: grid;
	grid-template-columns: repeat(4, minmax(140px, 1fr));
	gap: 8px;
	margin-bottom: 12px;
}

.summary-grid > div {
	padding: 10px;
	border: 1px solid #ddd2bf;
	border-radius: 6px;
	background: #faf7f1;
}

.summary-grid strong {
	display: block;
	font-size: 18px;
	line-height: 1.15;
}

.summary-grid span {
	display: block;
	margin-top: 4px;
	color: var(--muted);
	font-size: 12px;
}

.results-grid {
	display: grid;
	grid-template-columns: minmax(360px, 0.85fr) minmax(520px, 1.15fr);
	gap: 12px;
}

.result-block {
	min-width: 0;
}

.muted-cell {
	color: var(--muted);
}

.warn-cell {
	color: var(--warn);
	font-weight: 700;
}

.empty-row td {
	color: var(--muted);
	text-align: center;
}

@media (max-width: 1100px) {
	.page,
	.results-grid {
		grid-template-columns: 1fr;
	}

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

	.building-grid {
		max-width: none;
	}
}

@media (max-width: 700px) {
	.topbar {
		align-items: stretch;
		flex-direction: column;
	}

	.topbar-title {
		align-items: flex-start;
	}

	h1 {
		font-size: 19px;
	}

	.top-actions {
		justify-content: flex-start;
	}

	.sync-grid,
	.levels-grid,
	.summary-grid {
		grid-template-columns: 1fr;
	}

	.button-slot {
		align-items: stretch;
	}

	.button-slot button,
	.top-actions button,
	.top-actions a,
	.language-select,
	.language-select select {
		width: 100%;
	}

	.page {
		gap: 10px;
		padding: 10px;
	}

	.panel {
		padding: 12px;
		border-radius: 7px;
	}

	.panel-head {
		gap: 6px;
	}

	.status,
	.hint {
		width: 100%;
	}

	.table-wrap {
		max-width: calc(100vw - 20px);
	}

	table {
		min-width: 720px;
		font-size: 12px;
	}

	th,
	td {
		padding: 6px;
	}

	.unit-input {
		width: 84px;
	}

	.summary-grid strong {
		font-size: 16px;
	}
}

@media (max-width: 440px) {
	.brand-mini {
		grid-template-columns: 36px auto;
	}

	.brand-mini span {
		width: 36px;
		height: 36px;
	}

	.topbar {
		padding: 12px;
	}

	.topbar p {
		font-size: 12px;
	}

	h1 {
		font-size: 18px;
	}
}
