:root {
	color-scheme: light;
	--bg: #eee7ea;
	--surface: #fbf8f9;
	--fg: #26151d;
	--muted: #6b5560;
	--accent: #5b2340;
	--brass: #b8862b;
	--night: #2a1720;
	--border: #dccfd5;
	--danger: #a3261c;
	--ok: #2e6b46;
	--radius: 14px;
	--space: 1rem;
	--font: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, sans-serif;
	--display: "Reem Kufi", "IBM Plex Sans Arabic", serif;
}

* {
	box-sizing: border-box;
}

body {
	margin: 0;
	background: var(--bg);
	color: var(--fg);
	font-family: var(--font);
	line-height: 1.55;
	-webkit-font-smoothing: antialiased;
}

.shell {
	max-width: 42rem;
	margin: 0 auto;
	padding: 1.25rem var(--space) calc(96px + env(safe-area-inset-bottom));
}

h1,
h2 {
	font-family: var(--display);
	font-weight: 600;
	line-height: 1.25;
}

h1 {
	margin: 0;
	font-size: clamp(1.6rem, 4vw, 2.25rem);
}

h2 {
	margin: 0;
	font-size: 1.15rem;
}

.lede {
	margin: 0 0 0.75rem;
	font-size: 1.05rem;
}

.hint {
	margin: 0;
	color: var(--muted);
}

.btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.5rem;
	min-height: 44px;
	padding: 0.55rem 1rem;
	border: 1px solid transparent;
	border-radius: 10px;
	background: var(--accent);
	color: #fff;
	font: inherit;
	font-weight: 600;
	cursor: pointer;
	transition: transform 0.12s ease;
}

.btn:active {
	transform: scale(0.97);
}

.btn:disabled {
	opacity: 0.6;
	cursor: default;
}

.btn-big {
	width: 100%;
	min-height: 52px;
	font-size: 1.05rem;
}

.btn-secondary {
	background: transparent;
	color: var(--fg);
	border-color: var(--border);
}

.card {
	padding: 1.25rem;
	border: 1px solid var(--border);
	border-radius: var(--radius);
	background: var(--surface);
}

.input,
.select,
.textarea {
	width: 100%;
	min-height: 48px;
	padding: 0.6rem 0.8rem;
	border: 1px solid var(--border);
	border-radius: 10px;
	background: #fff;
	color: var(--fg);
	font: inherit;
	font-size: 16px;
}

.textarea {
	resize: vertical;
}

.field {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: 0.35rem;
}

.field > label {
	font-size: 0.875rem;
	color: var(--muted);
}

/*
 * 390px-safe, like .grid below. A grid with no column list gets one implicit
 * auto column, and an auto column is never narrower than its widest item's
 * min-content width. One nowrap scrolling strip (days, time slots) anywhere
 * inside an item therefore widened the whole column past the screen: the page
 * scrolled sideways instead of the strip scrolling on its own. minmax(0, 1fr)
 * caps the column at the container; the min-width rule keeps a child from
 * bringing the same floor back if an app redefines the columns. :where() adds
 * no specificity, so a min-width the app sets on a child still wins.
 */
.stack {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: var(--space);
}

:where(.field, .stack, .list) > * {
	min-width: 0;
}

.row {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	flex-wrap: wrap;
}

/*
 * 390px-safe. An unclamped minmax track overflows a 390px viewport once the
 * shell padding is subtracted, and nothing in the pipeline ever looked at a
 * phone-width layout, so every generated app inherited the horizontal scroll.
 * min() clamps the track to the container instead.
 */
.grid {
	display: grid;
	gap: var(--space);
	grid-template-columns: repeat(auto-fit, minmax(min(15rem, 100%), 1fr));
}

.list {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: 0.5rem;
	margin: 0;
	padding: 0;
	list-style: none;
}

.list-item {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.75rem;
	flex-wrap: wrap;
	padding: 0.7rem 0.85rem;
	border: 1px solid var(--border);
	border-radius: var(--radius);
}

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

.table th,
.table td {
	padding: 0.6rem 0.5rem;
	text-align: start;
	border-bottom: 1px solid var(--border);
}

.table th {
	font-size: 0.8125rem;
	color: var(--muted);
	font-weight: 600;
}

.empty {
	padding: calc(var(--space) * 2);
	text-align: center;
	color: var(--muted);
}

.empty-title {
	margin: 0 0 0.25rem;
	color: var(--fg);
	font-weight: 600;
}

/* Loading. Every fetch has one; without a primitive each app invented its own. */
.loading {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 0.6rem;
	padding: calc(var(--space) * 1.5);
	color: var(--muted);
}

.spinner {
	flex: none;
	width: 1.15rem;
	height: 1.15rem;
	border: 2px solid var(--border);
	border-top-color: var(--accent);
	border-radius: 50%;
	animation: fab-spin 0.7s linear infinite;
}

@keyframes fab-spin {
	to {
		transform: rotate(360deg);
	}
}

/* Placeholder for content whose shape is known before its data arrives. */
.skeleton {
	display: block;
	height: 1rem;
	border-radius: calc(var(--radius) / 2);
	background: linear-gradient(90deg, var(--border), transparent, var(--border));
	background-size: 200% 100%;
	animation: fab-shimmer 1.2s linear infinite;
}

@keyframes fab-shimmer {
	to {
		background-position: -200% 0;
	}
}

/* Error strip: a failure the user can see and retry, never a silent no-op. */
.alert {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.75rem;
	flex-wrap: wrap;
	padding: 0.7rem 0.85rem;
	border: 1px solid var(--border);
	border-left: 3px solid var(--muted);
	border-radius: var(--radius);
}

.alert-error {
	border-left-color: var(--danger);
	color: var(--danger);
}

.badge {
	display: inline-block;
	padding: 0.1rem 0.5rem;
	border: 1px solid var(--border);
	border-radius: 999px;
	font-size: 0.8125rem;
	color: var(--muted);
}

/*
 * The scaffold had exactly one @media rule (prefers-color-scheme) and no width
 * breakpoint at all, so the shell was a 42rem column at every size.
 * Mobile-first stays the default; these only widen it.
 */
/* App chrome */
.topbar {
	position: sticky;
	top: 0;
	z-index: 10;
	background: var(--night);
	color: #f6ecef;
	padding-top: env(safe-area-inset-top);
	border-bottom: 2px solid var(--brass);
}

.topbar-inner {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	max-width: 76rem;
	margin: 0 auto;
	padding: 0.7rem var(--space);
}

.brand {
	display: grid;
	line-height: 1.2;
}

.brand-name {
	font-family: var(--display);
	font-size: 1.35rem;
	font-weight: 700;
	color: #f0cf8e;
}

.brand-tag {
	font-size: 0.8rem;
	color: #d6c1c9;
}

.lang-btn {
	min-height: 44px;
	padding: 0 1rem;
	border: 1px solid rgba(240, 207, 142, 0.5);
	border-radius: 10px;
	background: transparent;
	color: #f6ecef;
	font: inherit;
	font-weight: 600;
	cursor: pointer;
}

.tabbar {
	position: fixed;
	inset-inline: 0;
	bottom: 0;
	z-index: 10;
	display: flex;
	justify-content: center;
	background: var(--surface);
	border-top: 1px solid var(--border);
	padding-bottom: max(8px, env(safe-area-inset-bottom));
	box-shadow: 0 -4px 20px rgba(42, 23, 32, 0.06);
}

.tab {
	flex: 1;
	max-width: 10rem;
	min-height: 60px;
	display: grid;
	place-items: center;
	gap: 2px;
	padding: 6px 0 0;
	border: 0;
	background: none;
	color: var(--muted);
	font: inherit;
	font-size: 0.8rem;
	cursor: pointer;
}

.tab:disabled {
	opacity: 0.45;
}

.tab-on {
	color: var(--accent);
	font-weight: 600;
}

.tab-icon {
	position: relative;
	display: inline-flex;
}

.tab-count {
	position: absolute;
	top: -6px;
	inset-inline-end: -10px;
	min-width: 20px;
	height: 20px;
	padding: 0 5px;
	border-radius: 10px;
	background: var(--brass);
	color: #fff;
	font-size: 0.72rem;
	font-weight: 700;
	line-height: 20px;
	text-align: center;
}

/* Shop */
.intro {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	padding: 1.25rem 1.25rem;
	border-radius: var(--radius);
	background: var(--accent);
	color: #f6ecef;
}

.intro h1 {
	color: #f0cf8e;
}

.intro p {
	margin: 0.35rem 0 0;
	color: #ecdde3;
}

.intro-mark {
	flex: none;
	width: 64px;
	height: 64px;
	color: #f0cf8e;
}

.chips {
	display: flex;
	gap: 0.5rem;
	overflow-x: auto;
	padding-bottom: 2px;
	scrollbar-width: none;
}

.chip {
	flex: none;
	min-height: 44px;
	padding: 0 1.1rem;
	border: 1px solid var(--border);
	border-radius: 10px;
	background: var(--surface);
	color: var(--fg);
	font: inherit;
	cursor: pointer;
}

.chip-on {
	background: var(--night);
	border-color: var(--night);
	color: #f0cf8e;
	font-weight: 600;
}

.products {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 0.75rem;
}

.product {
	display: flex;
	flex-direction: column;
	overflow: hidden;
	border: 1px solid var(--border);
	border-radius: var(--radius);
	background: var(--surface);
}

.product-img {
	aspect-ratio: 1;
	background: #4a2a38;
}

.product-img img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.product-body {
	display: flex;
	flex: 1;
	flex-direction: column;
	gap: 0.35rem;
	padding: 0.75rem;
}

.product h2 {
	font-size: 1rem;
}

.product-desc {
	margin: 0;
	font-size: 0.85rem;
	color: var(--muted);
	line-height: 1.45;
}

.product-foot {
	display: grid;
	gap: 0.5rem;
	margin-top: auto;
	padding-top: 0.35rem;
}

.price {
	font-weight: 700;
	font-variant-numeric: tabular-nums;
	color: var(--accent);
}

.stepper {
	display: inline-flex;
	align-items: center;
	justify-content: space-between;
	border: 1px solid var(--border);
	border-radius: 10px;
	background: #fff;
}

.step-btn {
	width: 44px;
	height: 44px;
	border: 0;
	background: none;
	color: var(--accent);
	font-size: 1.3rem;
	font-weight: 600;
	cursor: pointer;
}

.step-qty {
	min-width: 1.8rem;
	text-align: center;
	font-weight: 700;
	font-variant-numeric: tabular-nums;
}

/* Basket */
.basket-layout {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: 1.25rem;
	align-items: start;
}

.line {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	padding: 0.6rem;
	border: 1px solid var(--border);
	border-radius: var(--radius);
	background: var(--surface);
}

.line-img {
	width: 56px;
	height: 56px;
	flex: none;
	border-radius: 10px;
	object-fit: cover;
	background: #4a2a38;
}

.line-info {
	display: grid;
	flex: 1;
	min-width: 0;
	gap: 2px;
}

.total-row {
	display: flex;
	justify-content: space-between;
	align-items: baseline;
	padding: 0.75rem 0.25rem;
	border-top: 1px dashed var(--border);
	font-size: 1.1rem;
	font-variant-numeric: tabular-nums;
}

.segmented {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 0.5rem;
	margin: 0;
	padding: 0;
	border: 0;
}

.segmented legend {
	margin-bottom: 0.35rem;
	font-size: 0.875rem;
	color: var(--muted);
}

.seg {
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 48px;
	padding: 0 0.5rem;
	border: 1px solid var(--border);
	border-radius: 10px;
	background: #fff;
	text-align: center;
	cursor: pointer;
}

.seg input {
	position: absolute;
	opacity: 0;
	pointer-events: none;
}

.seg:focus-within {
	outline: 2px solid var(--accent);
	outline-offset: 2px;
}

.seg-on {
	border-color: var(--accent);
	background: var(--accent);
	color: #fff;
	font-weight: 600;
}

.pay-meta {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: center;
	gap: 0.5rem;
	text-align: center;
}

.badge-test {
	border-color: var(--brass);
	color: #7a5612;
	background: #fbf1dc;
}

.badge-paid {
	border-color: var(--ok);
	color: var(--ok);
}

.badge-pending {
	border-color: var(--brass);
	color: #7a5612;
}

/* Status */
.status {
	text-align: center;
	justify-items: center;
	padding: 2rem 1.25rem;
	scroll-margin-top: 90px;
}

.status h1 {
	scroll-margin-top: 90px;
}

.status .list,
.status .total-row {
	width: 100%;
	text-align: start;
}

.status-icon {
	display: grid;
	place-items: center;
	width: 56px;
	height: 56px;
	border-radius: 50%;
}

.status-ok {
	background: #e3efe7;
	color: var(--ok);
}

.spinner-lg {
	width: 2.2rem;
	height: 2.2rem;
	border-width: 3px;
}

/* Owner */
.narrow {
	max-width: 26rem;
	margin: 0 auto;
	width: 100%;
}

.orders {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: 0.75rem;
}

.order {
	display: grid;
	gap: 0.4rem;
}

.order-items {
	margin: 0;
	padding-inline-start: 1.1rem;
}

.order-contact {
	display: grid;
	gap: 0.2rem;
	font-size: 0.95rem;
}

.order-contact a {
	color: var(--accent);
	justify-self: start;
	min-height: 32px;
	display: inline-flex;
	align-items: center;
}

.order p {
	margin: 0;
}

/* Helpers */
.muted {
	color: var(--muted);
}

.small {
	font-size: 0.85rem;
}

.center {
	display: flex;
	justify-content: center;
	flex-wrap: wrap;
	gap: 0.5rem;
}

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

@media (min-width: 48rem) {
	.shell {
		max-width: 76rem;
		padding: 1.75rem 1.5rem 120px;
	}

	.intro {
		padding: 2rem 2.25rem;
	}

	.intro h1 {
		font-size: 2.6rem;
	}

	.intro-mark {
		width: 96px;
		height: 96px;
	}

	.products {
		grid-template-columns: repeat(3, minmax(0, 1fr));
		gap: 1.25rem;
	}

	.product-foot {
		grid-template-columns: auto auto;
		justify-content: space-between;
		align-items: center;
	}

	.basket-layout {
		grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
		gap: 2rem;
	}

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

	.status {
		max-width: 34rem;
		margin: 0 auto;
	}
}

@media (min-width: 64rem) {
	.products {
		grid-template-columns: repeat(4, minmax(0, 1fr));
	}

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

@media (prefers-reduced-motion: reduce) {
	.spinner,
	.skeleton {
		animation: none;
	}
}

:where(a, button, input, select, textarea):focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: 2px;
}
