/*
 * MessFlow front end: rider app, customer portal and sign-in boxes.
 * Every rule is scoped to .mfx so the active theme is not affected, and the
 * theme cannot easily break the rider app.
 */

.mfx {
	--mfx-brand: #065f46;
	--mfx-text: #111827;
	--mfx-muted: #4b5563;
	--mfx-bg: #f3f4f6;
	--mfx-surface: #ffffff;
	--mfx-border: #e5e7eb;
	--mfx-ok: #15803d;
	--mfx-ok-bg: #dcfce7;
	--mfx-warn: #92400e;
	--mfx-warn-bg: #fef3c7;
	--mfx-danger: #b91c1c;
	--mfx-danger-bg: #fee2e2;
	--mfx-busy-bg: #e0f2fe;
	--mfx-busy: #075985;
	--mfx-radius: 14px;

	box-sizing: border-box;
	max-width: 640px;
	margin: 0 auto;
	color: var(--mfx-text);
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", Arial, sans-serif;
	font-size: 16px;
	line-height: 1.45;
	-webkit-text-size-adjust: 100%;
}
.mfx *, .mfx *::before, .mfx *::after { box-sizing: border-box; }
.mfx p { margin: 0 0 6px; }
.mfx a { color: var(--mfx-brand); }
.mfx button { font: inherit; }
.mfx :focus-visible { outline: 3px solid color-mix(in srgb, var(--mfx-brand) 45%, transparent); outline-offset: 2px; }

.mfx-muted { color: var(--mfx-muted); }
.mfx-small { font-size: 13px; }
.mfx-strong { font-weight: 650; }
.mfx-warn { color: var(--mfx-warn); }
.mfx-error { color: var(--mfx-danger); font-weight: 600; }
.mfx-h3 { margin: 18px 0 8px; font-size: 17px; }
.mfx-kicker { margin: 0; color: var(--mfx-muted); font-size: 12px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; }
.mfx-title { margin: 0; font-size: 22px; line-height: 1.2; }
.mfx-loading, .mfx-empty { padding: 28px 16px; text-align: center; color: var(--mfx-muted); }
.mfx-empty--ok { color: var(--mfx-ok); font-weight: 650; }
.mfx-noscroll { overflow: hidden; }

/* Header */
.mfx-head { display: flex; align-items: center; gap: 12px; padding: 14px 4px 10px; }
.mfx-head__text { flex: 1; min-width: 0; }
.mfx-head__tools { display: flex; align-items: center; gap: 6px; }
.mfx-logo { width: 40px; height: 40px; border-radius: 10px; object-fit: cover; }
.mfx-icon-btn {
	display: inline-grid; place-items: center;
	width: 44px; height: 44px;
	border: 1px solid var(--mfx-border); border-radius: 12px;
	background: var(--mfx-surface); color: var(--mfx-text);
	font-size: 18px; text-decoration: none; cursor: pointer;
}

/* Alerts and toast */
.mfx-alert { margin: 8px 0; padding: 12px 14px; border-radius: 12px; background: var(--mfx-busy-bg); color: var(--mfx-busy); font-size: 14px; }
.mfx-alert--warn { background: var(--mfx-warn-bg); color: var(--mfx-warn); }
.mfx-alert--error { background: var(--mfx-danger-bg); color: var(--mfx-danger); }
.mfx-alert .mfx-btn { margin-top: 8px; }
.mfx-select { width: 100%; min-height: 48px; margin-top: 6px; padding: 8px 12px; border: 1px solid var(--mfx-border); border-radius: 10px; font-size: 16px; background: #fff; }
.mfx-toast {
	position: fixed; left: 50%; bottom: 20px; z-index: 99999;
	transform: translateX(-50%);
	max-width: calc(100vw - 32px);
	padding: 12px 18px; border-radius: 12px;
	background: #111827; color: #fff; font-size: 15px;
	box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

/* Tabs */
.mfx-tabs {
	position: sticky; top: 0; z-index: 10;
	display: flex; gap: 6px; overflow-x: auto;
	margin: 0 -4px 10px; padding: 8px 4px;
	background: var(--mfx-bg);
	scrollbar-width: none;
}
.mfx-tabs::-webkit-scrollbar { display: none; }
.mfx-tab {
	display: inline-flex; align-items: center; gap: 6px; flex: none;
	min-height: 44px; padding: 8px 14px;
	border: 1px solid var(--mfx-border); border-radius: 999px;
	background: var(--mfx-surface); color: var(--mfx-text);
	font-weight: 600; font-size: 15px; cursor: pointer;
}
.mfx-tab.is-active { background: var(--mfx-brand); border-color: var(--mfx-brand); color: #fff; }
.mfx-count { min-width: 24px; padding: 1px 7px; border-radius: 999px; background: rgba(0, 0, 0, 0.08); font-size: 13px; text-align: center; }
.mfx-tab.is-active .mfx-count { background: rgba(255, 255, 255, 0.25); }

.mfx-rider { padding: 0 4px 80px; background: var(--mfx-bg); border-radius: var(--mfx-radius); }

/* Summary */
.mfx-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(70px, 1fr)); gap: 8px; margin: 0 0 8px; }
.mfx-stat { padding: 12px; border-radius: 12px; background: var(--mfx-surface); text-align: center; }
.mfx-stat__value { display: block; font-size: 26px; font-weight: 750; line-height: 1.1; font-variant-numeric: tabular-nums; }
.mfx-stat__label { display: block; color: var(--mfx-muted); font-size: 12.5px; font-weight: 600; }
.mfx-progress { grid-column: 1 / -1; height: 10px; border-radius: 999px; background: #e5e7eb; overflow: hidden; }
.mfx-progress__bar { display: block; height: 100%; background: var(--mfx-ok); border-radius: inherit; transition: width 0.3s ease; }

/* Buttons */
.mfx-btn {
	display: inline-flex; align-items: center; justify-content: center; gap: 6px;
	min-height: 48px; padding: 10px 16px;
	border: 1px solid transparent; border-radius: 12px;
	font-weight: 650; font-size: 16px; text-align: center; text-decoration: none; cursor: pointer;
}
.mfx-btn:disabled { opacity: 0.55; cursor: progress; }
.mfx-btn--primary { background: var(--mfx-brand); color: #fff; }
.mfx-btn--secondary { background: var(--mfx-surface); border-color: var(--mfx-brand); color: var(--mfx-brand); }
.mfx-btn--ghost { background: transparent; border-color: var(--mfx-border); color: var(--mfx-text); }
.mfx-btn--danger { background: var(--mfx-surface); border-color: var(--mfx-danger); color: var(--mfx-danger); }
.mfx-btn--small { min-height: 36px; padding: 6px 12px; font-size: 14px; }
.mfx-btn--block { display: flex; width: 100%; margin: 8px 0 0; }
a.mfx-btn--primary, a.mfx-btn--primary:visited { color: #fff; }

/* Route */
.mfx-route { margin: 6px 0 12px; padding: 14px; border-radius: var(--mfx-radius); background: var(--mfx-surface); }
.mfx-cta {
	display: flex; align-items: center; justify-content: center;
	min-height: 64px; padding: 14px 18px;
	border-radius: 14px;
	background: var(--mfx-brand); color: #fff !important;
	font-size: 17px; font-weight: 800; letter-spacing: 0.02em; text-align: center; text-transform: uppercase; text-decoration: none;
	box-shadow: 0 6px 18px color-mix(in srgb, var(--mfx-brand) 35%, transparent);
}
.mfx-cta::before { content: "➤"; margin-right: 10px; font-size: 20px; }
.mfx-route .mfx-small { margin-top: 8px; }
.mfx-more { margin-top: 8px; }
.mfx-more > summary { min-height: 44px; padding: 10px 0; color: var(--mfx-brand); font-weight: 650; cursor: pointer; }
.mfx-tools { display: grid; gap: 8px; margin: 0 0 12px; }

/* Next stop */
.mfx-next { margin: 0 0 12px; padding: 14px; border: 2px solid var(--mfx-brand); border-radius: var(--mfx-radius); background: var(--mfx-surface); }
.mfx-next__name { margin: 2px 0; font-size: 19px; font-weight: 750; }

/* Ordered list */
.mfx-order { margin: 8px 0 12px; padding: 12px 12px 12px 30px; border-radius: 12px; background: var(--mfx-surface); font-size: 14px; }
.mfx-order li { margin: 0 0 4px; }
.mfx-order__kitchen { list-style: none; margin-left: -18px !important; font-weight: 650; color: var(--mfx-brand); }
.mfx-order__stop.is-delivered { color: var(--mfx-ok); }
.mfx-order__stop.is-failed { color: var(--mfx-danger); }

/* Stop cards */
.mfx-stops { margin: 12px 0 0; padding: 0; list-style: none; }
.mfx-stop { margin: 0 0 10px; padding: 14px; border: 1px solid var(--mfx-border); border-left: 6px solid #9ca3af; border-radius: var(--mfx-radius); background: var(--mfx-surface); }
.mfx-stop.is-assigned, .mfx-stop.is-scheduled, .mfx-stop.is-ready { border-left-color: #6b7280; }
.mfx-stop.is-in_transit { border-left-color: var(--mfx-busy); }
.mfx-stop.is-delivered { border-left-color: var(--mfx-ok); opacity: 0.8; }
.mfx-stop.is-failed { border-left-color: var(--mfx-danger); }
.mfx-stop.is-next { border-left-color: var(--mfx-brand); box-shadow: 0 0 0 2px color-mix(in srgb, var(--mfx-brand) 30%, transparent); }
.mfx-stop__top { display: flex; align-items: flex-start; gap: 10px; }
.mfx-stop__num { display: grid; place-items: center; flex: none; width: 36px; height: 36px; border-radius: 50%; background: var(--mfx-brand); color: #fff; font-weight: 800; font-variant-numeric: tabular-nums; }
.mfx-stop.is-delivered .mfx-stop__num { background: var(--mfx-ok); }
.mfx-stop.is-failed .mfx-stop__num { background: var(--mfx-danger); }
.mfx-stop__title { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.mfx-stop__name { font-size: 17px; font-weight: 750; }
.mfx-stop__addr { margin: 8px 0 4px; font-size: 15px; }
.mfx-stop__note { margin: 6px 0; padding: 8px 10px; border-radius: 8px; background: var(--mfx-warn-bg); color: #713f12; font-size: 14px; white-space: pre-line; }
.mfx-stop__links { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 0; }
.mfx-chip {
	display: inline-flex; align-items: center; min-height: 40px; padding: 6px 12px;
	border: 1px solid var(--mfx-border); border-radius: 999px;
	background: var(--mfx-bg); color: var(--mfx-text) !important;
	font-size: 14px; font-weight: 600; text-decoration: none; cursor: pointer;
}
.mfx-stop__actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }

/* Tags */
.mfx-tag { display: inline-block; padding: 2px 9px; border-radius: 999px; background: #e5e7eb; color: #374151; font-size: 12.5px; font-weight: 700; white-space: nowrap; }
.mfx-tag--delivered { background: var(--mfx-ok-bg); color: var(--mfx-ok); }
.mfx-tag--failed { background: var(--mfx-danger-bg); color: var(--mfx-danger); }
.mfx-tag--in_transit, .mfx-tag--assigned { background: var(--mfx-busy-bg); color: var(--mfx-busy); }
.mfx-tag--skipped, .mfx-tag--cancelled { background: #f3f4f6; color: #6b7280; }
.mfx-tag--trial { background: #ede9fe; color: #5b21b6; }
.mfx-tag--qty { background: #fef3c7; color: #78350f; font-weight: 700; }

/* Sheets */
.mfx-sheet { position: fixed; inset: 0; z-index: 99998; display: flex; align-items: flex-end; justify-content: center; background: rgba(17, 24, 39, 0.55); }
.mfx-sheet__panel {
	width: 100%; max-width: 560px; max-height: 92vh; overflow: auto;
	padding: 20px 18px calc(18px + env(safe-area-inset-bottom));
	border-radius: 20px 20px 0 0; background: #fff; color: var(--mfx-text);
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", Arial, sans-serif;
}
.mfx-sheet__title { margin: 0 0 6px; font-size: 19px; }
.mfx-sheet__actions { display: grid; grid-template-columns: 1fr 2fr; gap: 8px; margin-top: 14px; }
.mfx-sheet .mfx-btn { min-height: 52px; padding: 10px 16px; border: 1px solid transparent; border-radius: 12px; font-weight: 650; font-size: 16px; cursor: pointer; }
.mfx-sheet .mfx-btn--primary { background: #065f46; background: var(--mfx-brand, #065f46); color: #fff; }
.mfx-sheet .mfx-btn--ghost { background: #fff; border-color: #e5e7eb; color: #111827; }
.mfx-field { display: block; margin: 12px 0 0; }
.mfx-label { display: block; margin: 0 0 6px; font-weight: 650; font-size: 15px; }
.mfx-field textarea, .mfx-field input[type="file"] { width: 100%; padding: 10px; border: 1px solid #d1d5db; border-radius: 10px; font-size: 16px; }
.mfx-reasons { margin: 12px 0 0; padding: 0; border: 0; }
.mfx-radio { display: flex; align-items: center; gap: 10px; min-height: 48px; margin: 0 0 6px; padding: 8px 12px; border: 1px solid #e5e7eb; border-radius: 12px; cursor: pointer; font-size: 16px; }
.mfx-radio input { width: 22px; height: 22px; }
.mfx-radio:has(input:checked) { border-color: var(--mfx-brand, #065f46); background: #ecfdf5; }

/* History */
.mfx-history { margin: 0; padding: 0; list-style: none; }
.mfx-history li { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin: 0 0 8px; padding: 12px; border-radius: 12px; background: var(--mfx-surface); }
.mfx-history__when { width: 100%; color: var(--mfx-muted); font-size: 13px; }

/* Portal and sign-in */
.mfx-portal, .mfx-login, .mfx-notice { padding: 16px; }
.mfx-card { margin: 0 0 12px; padding: 16px; border: 1px solid var(--mfx-border); border-radius: var(--mfx-radius); background: var(--mfx-surface); }
.mfx-sub { padding: 10px 0; border-bottom: 1px solid var(--mfx-border); }
.mfx-sub:last-child { border-bottom: 0; }
.mfx-list { margin: 0; padding: 0; list-style: none; }
.mfx-list li { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center; margin: 0; padding: 8px 0; border-bottom: 1px solid var(--mfx-border); }
.mfx-list li:last-child { border-bottom: 0; }
.mfx-login { max-width: 420px; text-align: center; }
.mfx-login form { text-align: left; }
.mfx-login label { display: block; font-weight: 600; }
.mfx-login input[type="text"], .mfx-login input[type="password"] { width: 100%; min-height: 48px; padding: 10px 12px; border: 1px solid #d1d5db; border-radius: 10px; font-size: 16px; }
.mfx-login input[type="submit"] { width: 100%; min-height: 50px; border: 0; border-radius: 12px; background: var(--mfx-brand); color: #fff; font-weight: 700; font-size: 16px; cursor: pointer; }
.mfx-login .mfx-logo { width: 56px; height: 56px; margin-bottom: 8px; }
.mfx-notice { border-radius: var(--mfx-radius); background: var(--mfx-warn-bg); color: var(--mfx-warn); }

@media (min-width: 700px) {
	.mfx-tools { grid-template-columns: 1fr 1fr; }
	.mfx-sheet { align-items: center; }
	.mfx-sheet__panel { border-radius: 20px; }
}

@media (prefers-reduced-motion: reduce) {
	.mfx-progress__bar { transition: none; }
}

.mfx [hidden] { display: none !important; }

/* Sheets are attached to <body>, outside .mfx: give them the same basics. */
.mfx-sheet, .mfx-sheet *, .mfx-sheet *::before, .mfx-sheet *::after { box-sizing: border-box; }
.mfx-sheet { --mfx-brand: #065f46; font-size: 16px; line-height: 1.45; }
.mfx-sheet__title { font-weight: 750; }
.mfx-sheet .mfx-muted { color: #4b5563; }
.mfx-sheet .mfx-error { color: #b91c1c; font-weight: 600; }

/* Which of the customer's places today */
.mfx-place { display: inline-block; margin: 8px 0 0; padding: 2px 10px; border-radius: 999px; font-size: 13px; font-weight: 700; background: #e0f2fe; color: #075985; }
.mfx-place--2 { background: #fef3c7; color: #92400e; }

.mf-app .mf-place::before, .mfx-place::before { content: ''; display: inline-block; width: 12px; height: 12px; margin-right: 4px; vertical-align: -1px; background: currentColor; -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2a7 7 0 0 0-7 7c0 5.2 7 13 7 13s7-7.8 7-13a7 7 0 0 0-7-7Zm0 9.5A2.5 2.5 0 1 1 12 6.5a2.5 2.5 0 0 1 0 5Z'/%3E%3C/svg%3E") center / contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2a7 7 0 0 0-7 7c0 5.2 7 13 7 13s7-7.8 7-13a7 7 0 0 0-7-7Zm0 9.5A2.5 2.5 0 1 1 12 6.5a2.5 2.5 0 0 1 0 5Z'/%3E%3C/svg%3E") center / contain no-repeat; }
/* Rider: problem on the way */
.mfx-problem-row { margin: 0 0 12px; }
.mfx-btn--warn { width: 100%; background: #fff; border: 2px solid #dc2626; color: #b91c1c; font-weight: 700; min-height: 48px; }
.mfx-problem { display: grid; gap: 6px; }
.mfx-problem p { margin: 0; }
.mfx-problem__office { font-weight: 600; }
.mfx-problem__office.is-seen { color: #15803d; }
.mfx-problem__actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.mfx-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.mfx-chips legend { width: 100%; }
.mfx-chip { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 6px 12px; border: 1px solid #e5e7eb; border-radius: 999px; cursor: pointer; font-size: 15px; }
.mfx-chip:has(input:checked) { border-color: #dc2626; background: #fef2f2; }

/* Login page (one for customers, riders and staff) */
.mfx-login .mfx-form { display: grid; gap: 6px; margin-top: 12px; }
.mfx-login .mfx-input { width: 100%; min-height: 48px; padding: 10px 12px; border: 1px solid #d1d5db; border-radius: 10px; font-size: 16px; box-sizing: border-box; }
.mfx-login .mfx-label { margin-top: 6px; font-weight: 600; }
.mfx-login .mfx-check { display: flex; gap: 8px; align-items: center; margin: 8px 0 4px; font-weight: 500; }
.mfx-alert--bad { background: #fef2f2; color: #991b1b; border-radius: 10px; padding: 10px 12px; text-align: left; }
.mfx-alert--ok { background: #ecfdf5; color: #065f46; border-radius: 10px; padding: 10px 12px; text-align: left; }

/* Customer dashboard */
.mfx-staffbar { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; margin-bottom: 12px; padding: 10px 14px; border-radius: 12px; background: #fef3c7; color: #92400e; font-size: 14px; }
.mfx-staffbar a { color: #92400e; font-weight: 700; }
.mfx-meal { padding: 12px 0; border-top: 1px solid var(--mfx-border, #e5e7eb); }
.mfx-meal:first-of-type { border-top: 0; padding-top: 4px; }
.mfx-meal__top { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.mfx-steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin: 10px 0 4px; padding: 0; list-style: none; font-size: 12px; color: #6b7280; }
.mfx-steps li { padding-top: 8px; border-top: 4px solid #e5e7eb; }
.mfx-steps li.is-done { border-color: var(--mfx-brand); }
.mfx-steps li.is-now { border-color: var(--mfx-brand); color: var(--mfx-brand); font-weight: 700; }
.mfx-riderline { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; margin-top: 10px; padding: 10px 12px; border-radius: 10px; background: #f9fafb; }
.mfx-riderline a { color: inherit; }
.mfx-riderline__btns { display: flex; gap: 6px; }
.mfx-riderline__btns a.mfx-btn { color: var(--mfx-brand); }
.mfx-riders { display: grid; gap: 6px; margin: 4px 0 8px; }
.mfx-tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 0 0 12px; }
.mfx-tile { display: flex; flex-direction: column; gap: 2px; padding: 14px; border-radius: var(--mfx-radius, 14px); background: var(--mfx-surface, #fff); box-shadow: 0 1px 2px rgba(0,0,0,.05); text-align: center; }
.mfx-tile__value { font-size: 28px; font-weight: 800; color: var(--mfx-brand); line-height: 1.1; }
.mfx-tile__value--small { font-size: 16px; }
.mfx-tile__label { font-size: 13px; color: #6b7280; }
.mfx-days { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 0; padding: 0; list-style: none; }
.mfx-day { display: flex; flex-direction: column; min-width: 88px; padding: 6px 8px; border: 1px solid #e5e7eb; border-radius: 10px; font-size: 12px; }
.mfx-day__d { font-weight: 700; }
.mfx-day__m { color: #6b7280; }
.mfx-day--past { opacity: .5; }
.mfx-day--today { border-color: var(--mfx-brand); background: #ecfdf5; }
.mfx .mfx-signout { white-space: nowrap; text-decoration: none; color: var(--mfx-text); }
.mfx .mfx-head .mfx-icon-btn { text-decoration: none; }
