:root {
	--blue: #1f3864;
	--mid: #2e5d9e;
	--line: #d0d8e4;
	--bg: #f6f8fb;
	--card: #fff;
	--text: #1f2937;
	--muted: #64748b
}

* {
	box-sizing: border-box
}

body {
	font-family: Arial, sans-serif;
	margin: 0;
	background: var(--bg);
	color: var(--text)
}

a {
	color: inherit
}

.layout {
	display: grid;
	grid-template-columns: 230px 1fr;
	min-height: 100vh
}

.side {
	background: var(--blue);
	color: #fff;
	padding: 18px
}

.brand {
	font-size: 20px;
	font-weight: 700;
	margin-bottom: 22px
}

.nav a {
	display: block;
	padding: 10px 12px;
	border-radius: 8px;
	text-decoration: none;
	margin: 3px 0
}

.nav a:hover,
.nav a.active {
	background: rgba(255, 255, 255, .14)
}

main {
	padding: 22px 28px
}

.card {
	background: var(--card);
	border: 1px solid #e5e7eb;
	border-radius: 12px;
	padding: 16px;
	margin-bottom: 16px;
	box-shadow: 0 1px 2px rgba(0, 0, 0, .04)
}

.grid {
	display: grid;
	gap: 12px
}

.grid4 {
	grid-template-columns: repeat(4, minmax(0, 1fr))
}

.grid3 {
	grid-template-columns: repeat(3, minmax(0, 1fr))
}

.metric {
	font-size: 28px;
	font-weight: 700;
	color: var(--blue)
}

.muted {
	color: var(--muted);
	font-size: 13px
}

.row {
	display: flex;
	gap: 10px;
	align-items: end;
	flex-wrap: wrap
}

.field {
	display: flex;
	flex-direction: column;
	gap: 5px
}

.field label {
	font-size: 12px;
	font-weight: 700;
	color: #475569
}

input,
select,
textarea {
	border: 1px solid #cbd5e1;
	border-radius: 8px;
	padding: 8px;
	background: #fff;
	min-height: 36px
}

button,
.btn {
	border: 0;
	border-radius: 8px;
	padding: 9px 12px;
	background: var(--blue);
	color: #fff;
	text-decoration: none;
	cursor: pointer;
	display: inline-block
}

.btn.secondary,
button.secondary {
	background: #64748b
}

.btn.danger,
button.danger {
	background: #b91c1c
}

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

th {
	background: var(--blue);
	color: #fff;
	text-align: left;
	padding: 8px;
	border: 1px solid #8ea9c1
}

td {
	padding: 2px 8px;
	border-bottom: 1px solid #e5e7eb
}

tr:nth-child(even) td {
	background: #f8fafc
}

.price {
	text-align: right;
	font-weight: 700
}

.pill {
	display: inline-block;
	background: #e7f0fb;
	color: #1f3864;
	border-radius: 999px;
	padding: 2px 8px;
	font-size: 12px
}

.actions {
	white-space: nowrap
}

.notice {
	padding: 10px 12px;
	border-radius: 8px;
	background: #e0f2fe;
	color: #075985;
	margin-bottom: 12px
}

.error {
	background: #fee2e2;
	color: #991b1b
}

.tabs {
	display: flex;
	gap: 8px;
	margin-bottom: 12px
}

.tabs a {
	padding: 8px 12px;
	background: #e2e8f0;
	border-radius: 8px;
	text-decoration: none
}

.tabs a.active {
	background: var(--blue);
	color: #fff
}

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

	.side {
		position: static
	}

	.grid4,
	.grid3 {
		grid-template-columns: 1fr
	}
}

.price,
th.price,
td.price {
	text-align: right;
	font-variant-numeric: tabular-nums;
}

.money-input {
	text-align: right;
	font-variant-numeric: tabular-nums;
}

.actions {
	width: 1%;
	white-space: nowrap;
	text-align: center;
}

.inline {
	display: inline;
	margin: 0;
}

.icon-btn {
	width: 22px;
	height: 22px;
	min-height: 22px;
	padding: 0;
	border-radius: 6px;
	line-height: 1;
	font-size: 13px;
	vertical-align: middle;
}

.icon-btn.secondary {
	background: #64748b;
}

.icon-btn.danger {
	background: #b91c1c;
}

.modal-backdrop {
	position: fixed;
	inset: 0;
	background: rgba(15, 23, 42, .55);
	display: flex;
	align-items: flex-start;
	justify-content: center;
	padding: 55px 20px;
	z-index: 1000;
	overflow: auto;
}

.modal-card {
	width: min(980px, 100%);
	background: #fff;
	border-radius: 14px;
	border: 1px solid #e5e7eb;
	padding: 18px;
	box-shadow: 0 18px 45px rgba(0, 0, 0, .22);
}

.modal-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	margin-bottom: 14px;
}

.modal-head h2 {
	margin: 0;
}

.section-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	margin-top: 4px;
}

.section-head h3 {
	margin: 0;
	font-size: 16px;
}

.btn.small,
button.small {
	padding: 6px 9px;
	min-height: 30px;
	font-size: 12px;
}

.parts-list {
	display: grid;
	gap: 8px;
}

.part-row {
	display: grid;
	grid-template-columns: minmax(280px, 1fr) 120px 34px;
	gap: 10px;
	align-items: end;
}

.part-delete {
	margin-bottom: 1px;
}

@media(max-width:700px) {
	.part-row {
		grid-template-columns: 1fr;
	}

	.part-delete {
		width: 100%;
	}
}

.parts-table {
	width: 100%;
	margin-top: 8px;
	margin-bottom: 12px;
}

.parts-table select,
.parts-table input {
	width: 100%;
}

.parts-table .qty-col {
	width: 120px;
	text-align: right;
}

.parts-table .actions {
	width: 80px;
	text-align: center;
}

.parts-table td {
	vertical-align: middle;
}

.parts-table .money-input {
	text-align: right;
}

.section-head.top {
	margin-bottom: 12px;
}

.section-head.top h2 {
	margin: 0;
}

.device-parts-table {
	table-layout: fixed;
}

.device-parts-table th,
.device-parts-table td {
	padding: 8px;
}

.device-parts-table select {
	display: block;
	width: 100%;
}

.device-parts-table .qty-col {
	width: 120px;
}

.device-parts-table .actions {
	width: 84px;
}

.modal-card.wide {
	width: min(1120px, 100%);
}

.button {
	display: inline-block;
	background: #1f3f68;
	color: #fff;
	padding: 9px 14px;
	border-radius: 8px;
	text-decoration: none;
}

.stack {
	display: grid;
	gap: 12px;
}

.errors {
	color: #b91c1c;
}

.small {
	font-size: 0.9rem;
}

.grow {
	flex: 1;
	min-width: 260px;
}

.component-form {
	display: grid;
	gap: 14px;
}

.form-section {
	display: grid;
	grid-template-columns: 150px 110px 170px 130px 150px minmax(260px, 1fr);
	gap: 12px;
	align-items: end;
}

.spreadsheet-field {
	grid-column: 1 / 4;
}

.desc-field {
	grid-column: 4 / -1;
}

.spreadsheet-cell {
	max-width: 260px;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.pricing-mode-row {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 14px;
}

.mode-card,
.optional-card {
	border: 1px solid #dbe3ef;
	border-radius: 10px;
	padding: 12px;
	margin: 0;
	background: #f3f4f6;
}

.mode-card {
	background: #fbfdff;
}

.mode-card legend,
.optional-card legend {
	font-weight: 700;
	color: var(--blue);
	padding: 0 6px;
}

.mode-grid {
	display: grid;
	grid-template-columns: 150px minmax(220px, 1fr) 120px;
	gap: 12px;
	align-items: end;
}

.mode-note {
	margin: 0;
	align-self: center;
	grid-column: 2 / 4;
}

.compact-number input,
.small-number input {
	max-width: 130px;
}

.bottom-grid {
	display: grid;
	grid-template-columns: 290px minmax(220px, 1fr) minmax(220px, 1fr) 150px;
	gap: 12px;
	align-items: end;
}

.round-grid {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 10px;
}

.big-check {
	min-height: 36px;
	font-size: 15px;
	font-weight: 700;
}

.big-check input {
	width: 18px;
	height: 18px;
}

.save-field button {
	width: 100%;
}

[hidden] {
	display: none !important;
}

@media(max-width:1000px) {

	.form-section,
	.bottom-grid,
	.pricing-mode-row,
	.mode-grid,
	.round-grid {
		grid-template-columns: 1fr;
	}

	.mode-note {
		grid-column: auto;
	}
}

.radio-row {
	display: flex;
	gap: 10px;
	align-items: center;
	min-height: 36px;
}

.radio-row label {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	font-size: 13px;
	font-weight: 600;
	color: #334155;
}

.radio-row input {
	min-height: auto;
}


.cost-source-card {
	margin: 12px 0;
	background: #f3f4f6;
	border: 1px solid #d1d5db;
	border-radius: 10px;
	padding: 12px;
}

.cost-source-card legend {
	font-weight: 700;
	color: #374151;
	padding: 0 6px;
}

.cost-source-grid {
	display: grid;
	grid-template-columns: minmax(160px, 220px) minmax(360px, 1fr);
	gap: 12px;
	align-items: end;
}

.cost-source-grid input {
	width: 100%;
}

@media (max-width: 800px) {
	.cost-source-grid {
		grid-template-columns: 1fr;
	}
}

.page-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 14px;
	margin-bottom: 14px;
}

.page-head h1 {
	margin: 0;
}

.add-button {
	width: 38px;
	height: 38px;
	min-height: 38px;
	border-radius: 5px;
	padding: 0;
	font-size: 24px;
	line-height: 1;
	font-weight: 700;
}

.live-filter {
	position: sticky;
	top: 0;
	z-index: 5;
}

.filter-action-row {
	display: flex;
	align-items: flex-start;
	gap: 10px;
	margin-bottom: 16px;
}

.filter-panel {
	flex: 1 1 auto;
	margin-bottom: 0;
}

.add-button-outside {
	flex: 0 0 auto;
	margin-top: 0;
}

@media(max-width:700px) {
	.filter-action-row {
		align-items: stretch;
	}
}

.check-grid {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 8px 14px;
	max-height: 360px;
	overflow: auto;
}

.check-grid label,
.check-row label {
	display: flex;
	align-items: center;
	gap: 7px;
	font-size: 13px;
}

.check-grid input,
.check-row input {
	min-height: auto;
}

.check-row {
	display: flex;
	flex-wrap: wrap;
	gap: 10px 18px;
}

.sku-check-grid .muted {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

@media(max-width:800px) {
	.check-grid {
		grid-template-columns: 1fr;
	}
}

.output-card {
	margin-top: 16px;
}

.pricing-output-window {
	min-height: 160px;
	border: 1px solid #d0d0d0;
	background: #fff;
	padding: 16px;
	overflow: auto;
}

.space-between {
	justify-content: space-between;
}

.align-center {
	align-items: center;
}

.align-end {
	align-items: flex-end;
}

.field.compact {
	max-width: 160px;
}

.sku-entry-table input {
	width: 100%;
}

.section-title {
	margin: 0;
}

/* Pricing table editor refinements */
.compact-card {
	padding: 14px 16px 16px;
}

.stacked-checks {
	flex-direction: column;
	align-items: flex-start;
	gap: 8px;
}

.sku-entry-table {
	border-collapse: collapse;
}

.sku-entry-table th,
.sku-entry-table td {
	padding: 4px 8px;
}

.sku-entry-table input {
	min-height: 30px;
	padding: 5px 8px;
}

.sku-entry-table .icon-btn {
	min-width: 24px;
	height: 24px;
	padding: 0;
}

.sku-entry-table td.actions {
	white-space: nowrap;
}

.sales-sku-field {
	grid-column: 1 / 4;
}

.sku-entry-table td {
	padding: 0;
}

.sku-entry-table th {
	padding: 4px 8px;
}

.sku-entry-table input {
	min-height: 28px;
	padding: 3px 6px;
}

.sku-entry-table .icon-btn {
	height: 24px;
}

.sku-entry-table .adder-check {
	width: auto;
	min-height: 0;
}

.pricing-currency-label {
	font-size: 22px;
	font-weight: 700;
	margin-left: 18px;
}
