:root {
	--bg: #f4f6f8;
	--panel: #ffffff;
	--text: #1d2433;
	--muted: #697386;
	--line: #d9dee7;
	--blue: #2f6fed;
	--green: #13a88a;
	--red: #d92d20;
	--soft-blue: #edf4ff;
	--soft-green: #eaf8f4;
	--soft-red: #fff0ee;
	--radius: 8px;
	font-family: Arial, Helvetica, sans-serif;
	color: var(--text);
	background: var(--bg);
}

* {
	box-sizing: border-box;
}

body {
	margin: 0;
	background: var(--bg);
}

button,
input,
select,
textarea {
	font: inherit;
}

button:disabled {
	cursor: wait;
	opacity: 0.75;
}

.hidden {
	display: none !important;
}

.page-shell {
	width: min(1320px, calc(100vw - 32px));
	margin: 0 auto;
	padding: 20px 0 32px;
}

.topbar {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 16px;
	margin-bottom: 14px;
}

.topbar h1 {
	margin: 4px 0 6px;
	font-size: 28px;
	line-height: 1.15;
}

.eyebrow {
	margin: 0;
	color: var(--green);
	font-weight: 700;
	text-transform: uppercase;
	font-size: 12px;
	letter-spacing: 0;
}

.muted {
	margin: 0;
	color: var(--muted);
	font-size: 14px;
	line-height: 1.45;
}

.topbar-actions {
	display: flex;
	gap: 8px;
	align-items: center;
	flex-shrink: 0;
}
.primary-button,
.secondary-button,
.danger-button,
.icon-button {
	border-radius: var(--radius);
	min-height: 40px;
	cursor: pointer;
	font-weight: 700;
	transition: transform 0.16s ease, background-color 0.16s ease, border-color 0.16s ease;
}

.primary-button {
	border: 1px solid var(--blue);
	background: var(--blue);
	color: #ffffff;
	padding: 0 16px;
}

.secondary-button {
	border: 1px solid var(--line);
	background: #ffffff;
	color: var(--text);
	padding: 0 14px;
}

.danger-button {
	border: 1px solid var(--red);
	background: #ffffff;
	color: var(--red);
	padding: 0 12px;
}

.icon-button {
	width: 40px;
	min-width: 40px;
	height: 40px;
	padding: 0;
	border: 1px solid var(--blue);
	background: var(--blue);
	color: #ffffff;
	font-size: 18px;
	line-height: 1;
	display: inline-flex;
	align-items: center;
	justify-content: center;
}

.primary-button:hover,
.icon-button:hover {
	background: #245cc6;
}

.secondary-button:hover {
	border-color: var(--blue);
	color: var(--blue);
}

.danger-button:hover {
	background: var(--soft-red);
}

.is-saving {
	animation: pulseButton 0.8s ease-in-out infinite alternate;
}

.full-width {
	width: 100%;
}

.panel {
	background: var(--panel);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	overflow: hidden;
}

.panel-header {
	display: flex;
	justify-content: space-between;
	gap: 12px;
	padding: 14px 16px;
	border-bottom: 1px solid var(--line);
}

.panel h2 {
	margin: 0 0 5px;
	font-size: 18px;
	line-height: 1.25;
}

.panel h3 {
	margin: 0;
	font-size: 16px;
	line-height: 1.25;
}

.chart-panel {
	position: static;
	top: auto;
	z-index: auto;
	margin-top: 14px;
	margin-bottom: 14px;
	box-shadow: none;
}

.chart-header {
	align-items: flex-start;
}

.legend {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	align-items: center;
	color: var(--muted);
	font-size: 13px;
}

.legend span {
	display: inline-flex;
	gap: 6px;
	align-items: center;
}

.legend-dot {
	width: 10px;
	height: 10px;
	border-radius: 50%;
	display: inline-block;
}

.chart-controls {
	display: grid;
	grid-template-columns: 150px 150px 170px minmax(300px, 360px);
	gap: 10px;
	align-items: end;
	padding: 12px 16px;
	border-bottom: 1px solid var(--line);
	background: #fbfcfe;
}
.compact-field,
.field {
	display: grid;
	gap: 6px;
}

.compact-field span,
.field span {
	font-size: 12px;
	font-weight: 700;
	color: #30384a;
}

.compact-field input,
.compact-field select,
.compact-field textarea,
.field input,
.field select,
.field textarea {
	width: 100%;
	border: 1px solid var(--line);
	border-radius: var(--radius);
	padding: 9px 10px;
	background: #ffffff;
	color: var(--text);
}

.compact-field textarea,
.field textarea {
	min-height: 82px;
	resize: vertical;
}

.compact-field input:focus,
.compact-field select:focus,
.compact-field textarea:focus,
.field input:focus,
.field select:focus,
.field textarea:focus {
	outline: 2px solid rgba(47, 111, 237, 0.2);
	border-color: var(--blue);
}

.compact-field input[readonly] {
	background: #f1f4f8;
	color: var(--muted);
}
.zoom-field b {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 58px;
	color: var(--blue);
	font-size: 14px;
}

.zoom-field small {
	color: var(--muted);
	font-size: 11px;
	line-height: 1.25;
}

.zoom-controls {
	display: grid;
	grid-template-columns: 38px 58px 38px auto;
	gap: 6px;
	align-items: center;
	justify-content: start;
}
.zoom-button {
	min-height: 38px;
	padding: 0;
	font-size: 18px;
	line-height: 1;
}
.reset-button {
	width: 92px;
	min-height: 38px;
	padding: 0 12px;
	justify-self: start;
}
.chart-wrap {
	padding: 12px 16px 14px;
	overflow: auto;
	max-height: 52vh;
}

canvas {
	background: #ffffff;
	border: 1px solid #eef1f5;
	border-radius: var(--radius);
	display: block;
}

.summary-grid {
	display: grid;
	grid-template-columns: repeat(5, minmax(0, 1fr));
	gap: 12px;
	margin-bottom: 14px;
}
.screen-tabs {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin: 0 0 14px;
	padding: 8px;
	background: var(--panel);
	border: 1px solid var(--line);
	border-radius: var(--radius);
}

.tab-button {
	border: 1px solid transparent;
	background: transparent;
	color: var(--muted);
	border-radius: var(--radius);
	min-height: 38px;
	padding: 0 14px;
	cursor: pointer;
	font-weight: 700;
	transition: background-color 0.16s ease, color 0.16s ease, border-color 0.16s ease;
}

.tab-button:hover {
	background: var(--soft-blue);
	color: var(--blue);
}

.tab-button.is-active {
	background: var(--blue);
	color: #ffffff;
	border-color: var(--blue);
}

.screen {
	display: none;
}
.overview-grid {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 14px;
	align-items: start;
}

.overview-card-wide {
	grid-column: span 2;
}

.overview-card-body {
	display: grid;
	gap: 10px;
	padding: 14px 16px 16px;
}

.overview-row {
	display: grid;
	gap: 4px;
	padding-bottom: 10px;
	border-bottom: 1px solid #eef1f5;
}

.overview-row:last-child {
	padding-bottom: 0;
	border-bottom: 0;
}

.overview-row span {
	color: var(--muted);
	font-size: 12px;
	font-weight: 700;
}

.overview-row strong {
	color: var(--text);
	font-size: 14px;
	line-height: 1.45;
	font-weight: 600;
	white-space: pre-wrap;
	overflow-wrap: anywhere;
}
.screen.is-active {
	display: block;
}
.metric {
	background: var(--panel);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	padding: 13px;
	min-height: 78px;
}

.metric span {
	display: block;
	color: var(--muted);
	font-size: 12px;
	margin-bottom: 8px;
}

.metric strong {
	display: block;
	font-size: 21px;
	line-height: 1.2;
	overflow-wrap: anywhere;
}

.deals-panel,
.manual-panel,
.admin-panel {
	display: flex;
	flex-direction: column;
}

.table-wrap {
	overflow: auto;
	padding: 0 16px 16px;
}
.deals-table-wrap {
	max-height: none;
}

table {
	width: 100%;
	border-collapse: collapse;
	font-size: 14px;
}

th,
td {
	padding: 12px 10px;
	text-align: left;
	border-bottom: 1px solid #eef1f5;
	vertical-align: top;
}

th {
	position: sticky;
	top: 0;
	z-index: 2;
	background: #ffffff;
	color: var(--muted);
	font-size: 12px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0;
}

.row-id {
	display: block;
	color: var(--muted);
	font-size: 12px;
	margin-top: 3px;
}

.money-cell {
	text-align: right;
	white-space: nowrap;
}

.empty-cell {
	text-align: center;
	color: var(--muted);
	padding: 28px 10px;
}

.deal-row {
	border-left: 4px solid transparent;
}

.deal-success {
	border-left-color: var(--green);
	background: linear-gradient(90deg, var(--soft-green), #ffffff 22%);
}

.deal-failed {
	border-left-color: var(--red);
	background: linear-gradient(90deg, var(--soft-red), #ffffff 22%);
}

.deal-active {
	border-left-color: var(--blue);
	background: linear-gradient(90deg, var(--soft-blue), #ffffff 22%);
}

.status-pill {
	display: inline-flex;
	align-items: center;
	min-height: 24px;
	border-radius: 999px;
	padding: 3px 9px;
	font-size: 12px;
	font-weight: 700;
}

.status-success {
	background: var(--green);
	color: #ffffff;
}

.status-failed {
	background: var(--red);
	color: #ffffff;
}

.status-active {
	background: var(--blue);
	color: #ffffff;
}

.manual-form {
	padding: 16px;
	display: grid;
	gap: 18px;
}
.field-section {
	border: 1px solid var(--line);
	border-radius: var(--radius);
	background: #ffffff;
	overflow: hidden;
}

.field-section-header {
	padding: 12px 14px;
	border-bottom: 1px solid var(--line);
	background: #fbfcfe;
}

.field-section-header h3 {
	margin: 0;
	font-size: 15px;
	line-height: 1.25;
}

.field-section-grid {
	padding: 14px;
	display: grid;
	grid-template-columns: repeat(6, minmax(0, 1fr));
	gap: 12px;
}

.field-span-2 {
	grid-column: span 2;
}

.field-span-3 {
	grid-column: span 3;
}

.field-span-6 {
	grid-column: span 6;
}
.save-badge {
	align-self: flex-start;
	border: 1px solid var(--green);
	background: var(--soft-green);
	color: #08775f;
	border-radius: 999px;
	padding: 6px 10px;
	font-size: 12px;
	font-weight: 700;
	opacity: 0;
	transform: translateY(-4px);
	pointer-events: none;
	transition: opacity 0.2s ease, transform 0.2s ease;
}

.save-badge.is-visible {
	opacity: 1;
	transform: translateY(0);
	animation: savedPop 0.34s ease;
}

.toast {
	position: fixed;
	right: 20px;
	bottom: 20px;
	z-index: 20;
	border: 1px solid var(--green);
	background: #0f8f75;
	color: #ffffff;
	border-radius: var(--radius);
	padding: 12px 16px;
	font-weight: 700;
	box-shadow: 0 12px 24px rgba(29, 36, 51, 0.18);
	opacity: 0;
	transform: translateY(14px);
	pointer-events: none;
	transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.is-visible {
	opacity: 1;
	transform: translateY(0);
}

.admin-panel {
	margin-top: 14px;
}

.admin-form {
	padding: 16px;
	display: grid;
	gap: 14px;
}

.admin-fields-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
}

.admin-fields {
	display: grid;
	gap: 12px;
}

.admin-field-row {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
	gap: 10px;
	align-items: end;
	border: 1px solid var(--line);
	border-radius: var(--radius);
	padding: 12px;
	background: #fbfcfe;
	min-width: 0;
}
.admin-field-row .options-field {
	grid-column: span 2;
}

.admin-field-row .danger-button {
	justify-self: start;
	min-width: 110px;
}
.check-line {
	display: inline-flex;
	align-items: center;
	gap: 7px;
	min-height: 40px;
	padding: 0 10px;
	border: 1px solid var(--line);
	border-radius: var(--radius);
	background: #ffffff;
	cursor: pointer;
}

.check-line input {
	width: auto;
	margin: 0;
}

.check-line em {
	font-style: normal;
	font-size: 13px;
	color: var(--muted);
}
.options-field textarea {
	min-height: 44px;
}

.install-page {
	background: var(--bg);
}

.install-shell {
	width: min(760px, calc(100vw - 32px));
	margin: 48px auto;
	background: var(--panel);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	padding: 24px;
}

.install-shell h1 {
	margin: 0 0 10px;
	font-size: 28px;
}

.install-status {
	margin-top: 18px;
	padding: 12px 14px;
	border: 1px solid var(--line);
	border-radius: var(--radius);
	background: #f8fafc;
}

.install-code {
	margin-top: 14px;
	max-height: 320px;
	overflow: auto;
	background: #1d2433;
	color: #f8fafc;
	border-radius: var(--radius);
	padding: 14px;
	font-size: 12px;
	line-height: 1.5;
}

@keyframes pulseButton {
	from {
		transform: scale(1);
	}
	to {
		transform: scale(0.985);
	}
}

@keyframes savedPop {
	0% {
		transform: scale(0.92);
	}
	70% {
		transform: scale(1.04);
	}
	100% {
		transform: scale(1);
	}
}

@media (max-width: 1100px) {
	.summary-grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}

	.metric-wide {
		grid-column: span 2;
	}
	.admin-field-row {
		grid-template-columns: 1fr;
	}

	.deals-panel,
	.manual-panel {
		max-height: none;
	}

	.deals-table-wrap {
		max-height: 62vh;
	}
	.overview-grid {
		grid-template-columns: 1fr;
	}

	.overview-card-wide {
		grid-column: auto;
	}

	.field-section-grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}

	.field-span-2,
	.field-span-3,
	.field-span-6 {
		grid-column: span 2;
	}
}

@media (max-width: 760px) {
	.page-shell {
		width: min(100vw - 20px, 720px);
		padding-top: 12px;
	}
	.zoom-controls {
		grid-template-columns: 38px 58px 38px 92px;
	}
	.topbar,
	.chart-header,
	.admin-fields-head {
		display: grid;
	}

	.topbar-actions {
		width: auto;
		display: flex;
		gap: 8px;
	}

	.chart-controls,
	.summary-grid {
		grid-template-columns: 1fr;
	}

	.metric-wide {
		grid-column: auto;
	}

	.chart-panel {
		top: 0;
	}
	.screen-tabs {
		display: grid;
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}

	.tab-button {
		width: 100%;
	}

	.field-section-grid {
		grid-template-columns: 1fr;
	}

	.field-span-2,
	.field-span-3,
	.field-span-6 {
		grid-column: span 1;
	}
}
