@import url("fontawesome-all.min.css");
@import url("https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Playfair+Display:wght@700&display=swap");

:root {
	--ink: #292729;
	--muted: #746f72;
	--paper: #fffdfb;
	--canvas: #f5f1ed;
	--line: #ded7d2;
	--rose: #a94057;
	--rose-dark: #7f2f42;
	--sage: #4f7669;
	--warning: #a7582d;
}

* {
	box-sizing: border-box;
}

html,
body {
	margin: 0;
	min-height: 100%;
	overflow-x: hidden;
}

body {
	background-color: var(--canvas);
	background-image: linear-gradient(rgba(169, 64, 87, 0.035) 1px, transparent 1px), linear-gradient(90deg, rgba(169, 64, 87, 0.035) 1px, transparent 1px);
	background-size: 24px 24px;
	color: var(--ink);
	font-family: "DM Sans", sans-serif;
	font-size: 16px;
	line-height: 1.5;
}

a {
	color: inherit;
	text-decoration: none;
}

button,
input,
select {
	font: inherit;
}

.site-header {
	background: var(--paper);
	border-bottom: 1px solid var(--line);
}

.brand {
	padding: 28px 24px 20px;
	text-align: center;
}

.brand a {
	color: var(--ink);
	font-family: "Playfair Display", serif;
	font-size: clamp(1.75rem, 4vw, 2.65rem);
}

.brand p {
	color: var(--muted);
	font-size: 0.8rem;
	letter-spacing: 0.16em;
	margin: 4px 0 0;
	text-transform: uppercase;
}

.main-nav {
	display: grid;
	grid-template-columns: repeat(4, minmax(0, 1fr));
	margin: 0 auto;
	max-width: 920px;
}

.main-nav a {
	align-items: center;
	border-bottom: 3px solid transparent;
	color: var(--muted);
	display: flex;
	flex-direction: column;
	font-size: 0.78rem;
	font-weight: 700;
	gap: 6px;
	justify-content: center;
	min-height: 78px;
	padding: 10px 6px;
	text-align: center;
}

.main-nav a::before {
	font-family: "Font Awesome 5 Free";
	font-size: 1.2rem;
	font-weight: 900;
}

.main-nav a:hover,
.main-nav a[aria-current="page"] {
	border-color: var(--rose);
	color: var(--rose-dark);
}

.page {
	margin: 0 auto;
	max-width: 1180px;
	padding: 46px 24px 64px;
}

.page-heading {
	align-items: end;
	display: flex;
	gap: 24px;
	justify-content: space-between;
	margin-bottom: 26px;
}

.eyebrow {
	color: var(--rose);
	font-size: 0.75rem;
	font-weight: 700;
	letter-spacing: 0.14em;
	margin: 0 0 4px;
	text-transform: uppercase;
}

h1,
h2 {
	font-family: "Playfair Display", serif;
	line-height: 1.15;
	margin: 0;
}

h1 {
	font-size: clamp(2rem, 5vw, 3.25rem);
}

h2 {
	font-size: 1.35rem;
}

.page-heading > p {
	color: var(--muted);
	margin: 0;
	max-width: 460px;
	text-align: right;
}

.period-control {
	display: flex;
	flex-direction: column;
	gap: 6px;
	min-width: 210px;
}

.period-control select {
	background-color: var(--paper);
	cursor: pointer;
}

.stats {
	display: grid;
	gap: 14px;
	grid-template-columns: repeat(3, 1fr);
	margin-bottom: 22px;
}

.stat,
.panel {
	background: var(--paper);
	border: 1px solid var(--line);
	border-radius: 8px;
}

.stat {
	padding: 18px 20px;
}

.stat span {
	color: var(--muted);
	display: block;
	font-size: 0.76rem;
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
}

.stat strong {
	display: block;
	font-size: 1.65rem;
	margin-top: 5px;
}

.dashboard-grid {
	display: grid;
	gap: 18px;
	grid-template-columns: repeat(3, minmax(0, 1fr));
}

.summary-card {
	background: var(--paper);
	border: 1px solid var(--line);
	border-radius: 8px;
	display: flex;
	flex-direction: column;
	gap: 28px;
	min-height: 310px;
	padding: 28px;
	transition: border-color 160ms ease, transform 160ms ease;
}

.summary-card:hover {
	border-color: var(--rose);
	transform: translateY(-3px);
}

.summary-icon {
	align-items: center;
	background: #f2e3e6;
	border-radius: 50%;
	color: var(--rose-dark);
	display: flex;
	font-size: 1.2rem;
	height: 48px;
	justify-content: center;
	width: 48px;
}

.stock-summary .summary-icon {
	background: #e3eee9;
	color: var(--sage);
}

.summary-card span {
	color: var(--muted);
	font-size: 0.76rem;
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
}

.summary-card strong {
	display: block;
	font-family: "Playfair Display", serif;
	font-size: clamp(1.75rem, 3vw, 2.4rem);
	line-height: 1.15;
	margin-top: 10px;
}

.summary-card p {
	color: var(--muted);
	font-size: 0.9rem;
	margin: 12px 0 0;
}

.summary-card p b {
	color: var(--ink);
}

.summary-card .summary-link {
	color: var(--rose-dark);
	margin-top: auto;
}

.charts-grid {
	display: grid;
	gap: 18px;
	grid-template-columns: 1fr;
	margin-top: 22px;
}

.charts-grid .chart-panel {
	margin-top: 0;
}

.chart-container {
	height: 360px;
	position: relative;
	width: 100%;
}

.chart-note {
	color: var(--muted);
	font-size: 0.76rem;
	margin: 14px 0 0;
}

.panel {
	margin-bottom: 22px;
	padding: 24px;
}

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

.panel-header p {
	color: var(--muted);
	font-size: 0.88rem;
	margin: 0;
}

.form-grid {
	display: grid;
	gap: 16px;
	grid-template-columns: repeat(4, minmax(0, 1fr));
}

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

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

label {
	font-size: 0.78rem;
	font-weight: 700;
}

input,
select {
	background: #fff;
	border: 1px solid #cfc6c1;
	border-radius: 5px;
	color: var(--ink);
	min-width: 0;
	padding: 11px 12px;
	width: 100%;
}

input:focus,
select:focus {
	border-color: var(--rose);
	box-shadow: 0 0 0 3px rgba(169, 64, 87, 0.12);
	outline: none;
}

.autocomplete-add {
	display: grid;
	gap: 8px;
	grid-template-columns: minmax(0, 1fr) auto;
}

.autocomplete-add .button {
	width: auto;
}

.sale-area {
	margin-bottom: 28px;
}

.sale-builder {
	display: grid;
	gap: 18px;
	grid-template-columns: repeat(2, minmax(0, 1fr));
}

.sale-box {
	background: var(--paper);
	border: 1px solid var(--line);
	border-radius: 8px;
	padding: 24px;
}

.sale-summary-box {
	grid-column: 1 / -1;
}

.sale-box-header {
	align-items: center;
	display: flex;
	gap: 10px;
	margin-bottom: 20px;
}

.sale-box-header > span {
	color: var(--rose);
}

.sale-items {
	border-bottom: 1px solid var(--line);
	border-top: 1px solid var(--line);
}

.sale-item {
	align-items: center;
	border-bottom: 1px solid #e8e2de;
	display: grid;
	gap: 16px;
	grid-template-columns: minmax(0, 1fr) 76px auto 32px;
	padding: 14px 4px;
}

.sale-item:last-child {
	border-bottom: 0;
}

.sale-item-name span,
.sale-item-name small {
	display: block;
}

.sale-item-name small {
	color: var(--muted);
	font-size: 0.76rem;
	margin-top: 2px;
}

.sale-item-quantity {
	gap: 3px;
}

.sale-item-quantity span {
	color: var(--muted);
	font-size: 0.68rem;
}

.sale-item-quantity input {
	padding: 7px 8px;
}

.sale-item button {
	background: transparent;
	border: 0;
	color: var(--rose-dark);
	cursor: pointer;
	font-size: 1.25rem;
}

.sale-empty {
	color: var(--muted);
	margin: 0;
	padding: 20px 4px;
}

.sale-client-row,
.payment-row {
	align-items: center;
	display: flex;
	justify-content: space-between;
}

.sale-client-row {
	background: #f7f3f0;
	border-radius: 5px;
	margin-bottom: 16px;
	padding: 12px 14px;
}

.sale-client-row span,
.payment-preview h3 {
	color: var(--muted);
	font-size: 0.72rem;
	font-weight: 700;
	text-transform: uppercase;
}

.payment-preview {
	border-top: 1px solid var(--line);
	padding: 20px 4px;
}

.payment-preview h3 {
	margin: 0 0 10px;
}

.payment-row {
	border-bottom: 1px solid #eee8e4;
	font-size: 0.86rem;
	padding: 8px 0;
}

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

.sale-total-row {
	align-items: center;
	display: flex;
	justify-content: space-between;
	padding: 22px 4px;
}

.sale-total-row span {
	font-size: 0.78rem;
	font-weight: 700;
	text-transform: uppercase;
}

.sale-total-row strong {
	font-family: "Playfair Display", serif;
	font-size: 2rem;
}

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

.sale-form-actions {
	gap: 8px;
}

.record-form-actions {
	gap: 8px;
}

.record-form-actions .button {
	width: auto;
}

.button.secondary {
	background: #e9e3df;
	color: var(--ink);
}

.table-actions {
	display: flex;
	gap: 6px;
}

.table-action {
	background: transparent;
	border: 1px solid var(--line);
	border-radius: 5px;
	color: var(--rose-dark);
	cursor: pointer;
	font-size: 0.76rem;
	font-weight: 700;
	padding: 6px 9px;
}

.field-message {
	color: var(--warning);
	font-size: 0.78rem;
	font-weight: 700;
	margin: 0;
	min-height: 1.2em;
}

.form-actions {
	align-items: end;
	display: flex;
}

.form-message {
	color: var(--sage);
	font-size: 0.85rem;
	font-weight: 700;
	margin: 14px 0 0;
	min-height: 1.3em;
}

.button {
	background: var(--rose);
	border: 0;
	border-radius: 5px;
	color: #fff;
	cursor: pointer;
	font-weight: 700;
	min-height: 46px;
	padding: 11px 18px;
	width: 100%;
}

.button:hover {
	background: var(--rose-dark);
}

.table-wrap {
	overflow-x: auto;
}

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

th,
td {
	border-bottom: 1px solid #e8e2de;
	padding: 13px 10px;
	text-align: left;
}

th {
	color: var(--muted);
	font-size: 0.72rem;
	letter-spacing: 0.07em;
	text-transform: uppercase;
}

tbody tr:last-child td {
	border-bottom: 0;
}

.badge {
	background: #e3eee9;
	border-radius: 999px;
	color: #315c4d;
	display: inline-block;
	font-size: 0.74rem;
	font-weight: 700;
	padding: 4px 9px;
}

.badge.pending {
	background: #f5e5dc;
	color: var(--warning);
}

.badge.overdue {
	background: #f2dadd;
	color: #8f2e3d;
}

.empty-state {
	color: var(--muted);
	padding: 28px !important;
	text-align: center;
}

.site-footer {
	color: var(--muted);
	font-size: 0.78rem;
	padding: 0 24px 30px;
	text-align: center;
}

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

	.sale-builder {
		grid-template-columns: 1fr;
	}

	.sale-summary-box {
		grid-column: auto;
	}

	.dashboard-grid {
		grid-template-columns: 1fr;
	}

	.summary-card {
		min-height: 250px;
	}

	.page-heading {
		align-items: start;
		flex-direction: column;
		gap: 8px;
	}

	.page-heading > p {
		text-align: left;
	}

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

@media (max-width: 560px) {
	.brand {
		padding: 20px 16px 12px;
	}

	.main-nav a {
		font-size: 0.68rem;
		min-height: 68px;
	}

	.page {
		padding: 30px 16px 48px;
	}

	.stats,
	.form-grid {
		grid-template-columns: 1fr;
	}

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

	.panel {
		padding: 18px 14px;
	}

	.chart-container {
		height: 320px;
	}

	.panel-header {
		align-items: start;
		flex-direction: column;
		gap: 5px;
	}

	table,
	tbody,
	tr,
	td {
		display: block;
	}

	thead {
		display: none;
	}

	tr {
		border-bottom: 1px solid var(--line);
		padding: 10px 0;
	}

	tbody tr:last-child {
		border-bottom: 0;
	}

	td {
		border: 0;
		padding: 5px 8px 5px 44%;
		position: relative;
	}

	td::before {
		color: var(--muted);
		content: attr(data-label);
		font-size: 0.7rem;
		font-weight: 700;
		left: 8px;
		position: absolute;
		text-transform: uppercase;
		top: 7px;
		width: 40%;
	}
}