/**
 * CCD Order App Mode — layout shell (mobile + desktop).
 */

html,
body.ccd-order-app-shell-body {
	margin: 0;
	padding: 0;
	min-height: 100%;
	background: #f5f6f8;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	-webkit-font-smoothing: antialiased;
}

body.ccd-order-app-shell-body {
	overflow-x: hidden;
}

#ccd-app.ccd-app-layout {
	min-height: 100vh;
	min-height: 100dvh;
	display: flex;
	flex-direction: row;
	background: #f5f6f8;
	color: #111827;
	max-width: 480px;
	margin: 0 auto;
	position: relative;
	box-sizing: border-box;
}

.ccd-app-column {
	flex: 1 1 auto;
	min-width: 0;
	display: flex;
	flex-direction: column;
	min-height: 100vh;
	min-height: 100dvh;
	position: relative;
}

/* ── Header / Top bar ─────────────────────────────────────────── */

.ccd-app-topbar {
	position: sticky;
	top: 0;
	z-index: 50;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 12px 16px;
	padding-top: calc(12px + env(safe-area-inset-top, 0px));
	background: #2563eb;
	color: #fff;
	box-shadow: 0 2px 12px rgba(37, 99, 235, 0.35);
}

.ccd-app-topbar__menu {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	border: 0;
	border-radius: 10px;
	background: rgba(255, 255, 255, 0.18);
	color: #fff;
	font-size: 20px;
	cursor: pointer;
	flex-shrink: 0;
}

.ccd-app-topbar__brand {
	display: flex;
	flex-direction: column;
	gap: 2px;
	min-width: 0;
	flex: 1 1 auto;
}

.ccd-app-topbar__name {
	font-size: 17px;
	font-weight: 700;
	letter-spacing: 0.01em;
	line-height: 1.2;
}

.ccd-app-topbar__user {
	font-size: 12px;
	opacity: 0.9;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	max-width: 220px;
}

.ccd-app-topbar__logout {
	flex-shrink: 0;
	color: #fff;
	text-decoration: none;
	font-size: 13px;
	font-weight: 600;
	padding: 8px 12px;
	border-radius: 999px;
	background: rgba(255, 255, 255, 0.18);
}

.ccd-app-topbar__logout:hover,
.ccd-app-topbar__logout:focus {
	background: rgba(255, 255, 255, 0.28);
	color: #fff;
}

/* ── Sidebar ──────────────────────────────────────────────────── */

.ccd-app-sidebar {
	position: fixed;
	top: 0;
	left: 0;
	z-index: 80;
	width: min(280px, 86vw);
	height: 100%;
	background: #0f172a;
	color: #e2e8f0;
	transform: translateX(-105%);
	transition: transform 0.2s ease;
	padding: calc(16px + env(safe-area-inset-top, 0px)) 12px 24px;
	box-sizing: border-box;
	overflow-y: auto;
}

body.ccd-sidebar-open .ccd-app-sidebar {
	transform: translateX(0);
}

.ccd-app-sidebar-backdrop {
	position: fixed;
	inset: 0;
	z-index: 70;
	background: rgba(15, 23, 42, 0.45);
}

.ccd-app-sidebar__head {
	padding: 8px 12px 20px;
	border-bottom: 1px solid #1e293b;
	margin-bottom: 12px;
}

.ccd-app-sidebar__title {
	display: block;
	font-size: 18px;
	font-weight: 700;
	color: #f8fafc;
}

.ccd-app-sidebar__user {
	display: block;
	margin-top: 4px;
	font-size: 13px;
	color: #94a3b8;
}

.ccd-app-sidebar__nav {
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.ccd-app-sidebar__item {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 12px 14px;
	border-radius: 12px;
	color: #cbd5e1;
	text-decoration: none;
	font-weight: 600;
	font-size: 15px;
}

.ccd-app-sidebar__item.is-active,
.ccd-app-sidebar__item:hover {
	background: #1e293b;
	color: #fff;
}

.ccd-app-sidebar__icon {
	width: 24px;
	text-align: center;
}

/* ── Main ─────────────────────────────────────────────────────── */

.ccd-app-main {
	flex: 1 1 auto;
	padding: 16px 16px 108px;
	box-sizing: border-box;
	width: 100%;
}

.ccd-app-main .wrap,
.ccd-app-main .ccd-order-app-shell {
	margin: 0;
	padding: 0;
	max-width: none;
}

.ccd-app-main .ccd-page-header h1 {
	font-size: 22px;
	margin: 0 0 4px;
}

.ccd-app-main .ccd-dashboard-hello {
	margin: 0 0 16px;
	color: #6b7280;
	font-size: 14px;
}

.ccd-app-main .ccd-dashboard-stats {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 12px;
	margin-bottom: 16px;
}

.ccd-app-main .ccd-stat-card {
	background: #fff;
	border-radius: 16px;
	padding: 14px 12px;
	box-shadow: 0 4px 16px rgba(15, 23, 42, 0.08);
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.ccd-app-main .ccd-stat-value {
	font-size: 22px;
	font-weight: 700;
	line-height: 1.1;
}

.ccd-app-main .ccd-dashboard-actions {
	display: grid;
	grid-template-columns: 1fr;
	gap: 12px;
}

.ccd-app-main .ccd-dash-action {
	display: grid;
	grid-template-columns: auto 1fr;
	grid-template-rows: auto auto;
	column-gap: 12px;
	row-gap: 2px;
	align-items: center;
	text-decoration: none;
	color: inherit;
	background: #fff;
	border-radius: 16px;
	padding: 16px;
	box-shadow: 0 4px 16px rgba(15, 23, 42, 0.08);
}

.ccd-app-main .ccd-dash-action__icon {
	grid-row: 1 / span 2;
	width: 44px;
	height: 44px;
	border-radius: 12px;
	display: flex;
	align-items: center;
	justify-content: center;
	background: #eff6ff;
	font-size: 22px;
}

.ccd-app-main .ccd-dash-action--primary .ccd-dash-action__icon {
	background: #2563eb;
	color: #fff;
}

.ccd-app-main .ccd-dash-action__title {
	font-weight: 700;
	font-size: 16px;
}

.ccd-app-main .ccd-dash-action__hint {
	font-size: 13px;
	color: #6b7280;
}

/* ── Bottom navigation ────────────────────────────────────────── */

.ccd-app-bottomnav {
	position: fixed;
	left: 50%;
	transform: translateX(-50%);
	bottom: 0;
	width: 100%;
	max-width: 480px;
	z-index: 60;
	display: grid;
	grid-template-columns: repeat(5, 1fr);
	align-items: end;
	gap: 0;
	padding: 8px 6px calc(8px + env(safe-area-inset-bottom, 0px));
	background: rgba(255, 255, 255, 0.96);
	backdrop-filter: blur(12px);
	-webkit-backdrop-filter: blur(12px);
	border-top: 1px solid #e5e7eb;
	box-shadow: 0 -8px 24px rgba(15, 23, 42, 0.08);
	box-sizing: border-box;
}

.ccd-app-bottomnav__item {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 2px;
	min-height: 52px;
	padding: 6px 2px;
	text-decoration: none;
	color: #6b7280;
	font-size: 11px;
	font-weight: 600;
	border-radius: 12px;
	border: 0;
	background: transparent;
	cursor: pointer;
	font-family: inherit;
	-webkit-tap-highlight-color: transparent;
}

.ccd-app-bottomnav__item.is-active {
	color: #2563eb;
}

.ccd-app-bottomnav__icon {
	font-size: 18px;
	line-height: 1;
}

.ccd-app-bottomnav__label {
	line-height: 1.2;
}

.ccd-app-bottomnav__item--fab {
	position: relative;
	top: -10px;
}

.ccd-app-bottomnav__item--fab .ccd-app-bottomnav__icon {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 48px;
	height: 48px;
	border-radius: 50%;
	background: #2563eb;
	color: #fff;
	font-size: 26px;
	font-weight: 500;
	box-shadow: 0 8px 20px rgba(37, 99, 235, 0.4);
}

.ccd-app-bottomnav__item--fab .ccd-app-bottomnav__label {
	color: #2563eb;
}

/* ── More sheet ───────────────────────────────────────────────── */

.ccd-app-more {
	position: fixed;
	inset: 0;
	z-index: 90;
	background: rgba(15, 23, 42, 0.4);
	display: flex;
	align-items: flex-end;
	justify-content: center;
}

.ccd-app-more[hidden] {
	display: none !important;
}

.ccd-app-more__sheet {
	width: 100%;
	max-width: 480px;
	background: #fff;
	border-radius: 20px 20px 0 0;
	padding: 12px 12px calc(16px + env(safe-area-inset-bottom, 0px));
	box-shadow: 0 -12px 32px rgba(15, 23, 42, 0.18);
}

.ccd-app-more__item {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 14px 12px;
	border-radius: 12px;
	text-decoration: none;
	color: #111827;
	font-weight: 600;
	font-size: 15px;
}

.ccd-app-more__item:hover,
.ccd-app-more__item:active {
	background: #f3f4f6;
}

.ccd-app-more__icon {
	width: 28px;
	text-align: center;
}

/* ── Desktop / tablet enhancement ─────────────────────────────── */

@media (min-width: 481px) {
	#ccd-app.ccd-app-layout {
		box-shadow: 0 0 0 1px #e5e7eb, 0 24px 48px rgba(15, 23, 42, 0.08);
		min-height: 100vh;
	}
}

@media (min-width: 900px) {
	body.ccd-order-app-shell-body {
		background: #e5e7eb;
	}

	#ccd-app.ccd-app-layout {
		max-width: 1100px;
		margin: 24px auto;
		min-height: calc(100vh - 48px);
		border-radius: 20px;
		overflow: hidden;
		background: #f5f6f8;
	}

	.ccd-app-topbar__menu {
		display: none;
	}

	.ccd-app-sidebar {
		position: relative;
		transform: none;
		width: 240px;
		flex: 0 0 240px;
		height: auto;
		min-height: 100%;
		border-radius: 0;
	}

	.ccd-app-sidebar-backdrop {
		display: none !important;
	}

	.ccd-app-bottomnav,
	.ccd-app-more {
		display: none !important;
	}

	.ccd-app-main {
		padding: 24px 28px 32px;
	}

	.ccd-app-main .ccd-dashboard-actions {
		grid-template-columns: repeat(2, 1fr);
	}
}

/* ── MODULE 8: Front Order List (mobile-first cards) ──────────── */

.ccd-orders-page__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	margin-bottom: 14px;
}

.ccd-orders-page__title {
	margin: 0;
	font-size: 1.25rem;
	font-weight: 800;
	letter-spacing: 0.04em;
	text-transform: uppercase;
}

.ccd-orders-page__search {
	display: flex;
	gap: 8px;
	margin-bottom: 12px;
	padding: 10px;
	background: #fff;
	border: 1px solid #e5e7eb;
	border-radius: 12px;
}

.ccd-orders-page__search input[type="search"] {
	flex: 1 1 auto;
	min-width: 0;
	border: 1px solid #d1d5db;
	border-radius: 10px;
	padding: 10px 12px;
	font-size: 1rem;
}

.ccd-orders-filters {
	display: flex;
	gap: 8px;
	overflow-x: auto;
	padding-bottom: 4px;
	margin-bottom: 14px;
	-webkit-overflow-scrolling: touch;
}

.ccd-orders-filters__tab {
	flex: 0 0 auto;
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 8px 12px;
	border-radius: 999px;
	border: 1px solid #e5e7eb;
	background: #fff;
	color: #374151;
	text-decoration: none;
	font-size: 0.875rem;
	font-weight: 600;
	white-space: nowrap;
}

.ccd-orders-filters__tab.is-active {
	background: #2563eb;
	border-color: #2563eb;
	color: #fff;
}

.ccd-orders-filters__count {
	font-size: 0.75rem;
	opacity: 0.85;
}

.ccd-orders-page__error {
	margin-bottom: 12px;
	padding: 12px 14px;
	border-radius: 10px;
	background: #fef2f2;
	border: 1px solid #fecaca;
	color: #b91c1c;
}

.ccd-orders-page__empty {
	text-align: center;
	padding: 48px 20px;
	background: #fff;
	border: 1px dashed #d1d5db;
	border-radius: 14px;
}

.ccd-orders-page__empty-icon {
	font-size: 2.5rem;
	line-height: 1;
	margin-bottom: 10px;
}

.ccd-orders-page__empty p {
	margin: 0 0 16px;
	font-size: 1.05rem;
	color: #4b5563;
}

.ccd-orders-cards {
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.ccd-order-card {
	display: block;
	padding: 14px 16px;
	background: #fff;
	border: 1px solid #e5e7eb;
	border-radius: 14px;
	text-decoration: none;
	color: inherit;
	box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.ccd-order-card:active {
	transform: scale(0.995);
}

.ccd-order-card__top {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	margin-bottom: 8px;
}

.ccd-order-card__code {
	font-size: 1.05rem;
	letter-spacing: -0.01em;
}

.ccd-order-card__customer {
	margin: 0 0 2px;
	font-weight: 650;
	font-size: 1rem;
}

.ccd-order-card__phone,
.ccd-order-card__date,
.ccd-order-card__creator {
	margin: 0 0 2px;
	font-size: 0.9rem;
	color: #6b7280;
}

.ccd-order-card__total {
	margin: 8px 0 4px;
	font-size: 1.15rem;
	font-weight: 800;
	font-variant-numeric: tabular-nums;
	color: #111827;
}

.ccd-status-badge {
	display: inline-block;
	padding: 4px 10px;
	border-radius: 999px;
	font-size: 0.72rem;
	font-weight: 750;
	letter-spacing: 0.02em;
}

.ccd-status-badge--pending {
	color: #b45309;
	background: #fffbeb;
}

.ccd-status-badge--completed {
	color: #15803d;
	background: #f0fdf4;
}

.ccd-status-badge--cancelled {
	color: #b91c1c;
	background: #fef2f2;
}

.ccd-orders-page__pager {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 12px;
	margin-top: 16px;
}

.ccd-orders-page__pager-meta {
	font-size: 0.875rem;
	color: #6b7280;
}

.ccd-orders-page__actions {
	display: flex;
	align-items: center;
	gap: 8px;
}

.ccd-orders-page.is-refreshing {
	opacity: 0.72;
}

.ccd-page-head {
	margin-bottom: 14px;
}

.ccd-page-head h1 {
	margin: 8px 0 0;
	font-size: 1.25rem;
	font-weight: 800;
}

.ccd-card-block {
	background: #fff;
	border: 1px solid #e5e7eb;
	border-radius: 14px;
	padding: 14px 16px;
	margin-bottom: 12px;
}

.ccd-card-block__title {
	margin: 0 0 12px;
	font-size: 1rem;
	font-weight: 750;
}

.ccd-input,
.ccd-textarea {
	width: 100%;
	border: 1px solid #d1d5db;
	border-radius: 10px;
	padding: 10px 12px;
	font-size: 1rem;
	background: #fff;
}

.ccd-textarea {
	resize: vertical;
}

.ccd-field {
	display: flex;
	flex-direction: column;
	gap: 6px;
	margin-bottom: 12px;
}

.ccd-field > span {
	font-size: 0.875rem;
	color: #4b5563;
	font-weight: 600;
}

.ccd-picker-toolbar {
	display: flex;
	gap: 8px;
	margin-bottom: 8px;
}

.ccd-picker-toolbar .ccd-input {
	flex: 1 1 auto;
}

.ccd-chip-row {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin: 8px 0;
}

.ccd-chip-btn,
.ccd-link-btn {
	border: 1px solid #e5e7eb;
	background: #fff;
	border-radius: 999px;
	padding: 6px 12px;
	font-size: 0.85rem;
	font-weight: 600;
	color: #1f2937;
	cursor: pointer;
	text-decoration: none;
}

.ccd-link-btn {
	border: 0;
	background: transparent;
	color: #2563eb;
	padding: 0;
}

.ccd-picker-results {
	list-style: none;
	margin: 0;
	padding: 0;
}

.ccd-picker-item {
	display: block;
	width: 100%;
	text-align: left;
	border: 0;
	border-bottom: 1px solid #f3f4f6;
	background: transparent;
	padding: 10px 4px;
	cursor: pointer;
}

.ccd-selected-customer {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	padding: 10px 0;
}

.ccd-line-card {
	border: 1px solid #e5e7eb;
	border-radius: 12px;
	padding: 10px 12px;
	margin-bottom: 8px;
}

.ccd-line-card__name {
	font-weight: 650;
	margin-bottom: 8px;
}

.ccd-line-card__row {
	display: flex;
	align-items: center;
	gap: 8px;
	flex-wrap: wrap;
}

.ccd-qty {
	display: inline-flex;
	align-items: center;
	gap: 4px;
}

.ccd-qty__btn {
	width: 32px;
	height: 32px;
	border-radius: 8px;
	border: 1px solid #d1d5db;
	background: #f9fafb;
	font-size: 1.1rem;
	cursor: pointer;
}

.ccd-qty__input,
.ccd-line-price {
	width: 72px;
	border: 1px solid #d1d5db;
	border-radius: 8px;
	padding: 6px 8px;
}

.ccd-summary-row {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 12px;
	padding: 8px 0;
}

.ccd-summary-grand {
	border-top: 1px solid #e5e7eb;
	margin-top: 6px;
	padding-top: 12px;
	font-size: 1.05rem;
}

.ccd-action-bar {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin: 16px 0 24px;
}

.ccd-btn-danger {
	background: #dc2626;
	border-color: #dc2626;
	color: #fff;
}

.ccd-btn-secondary {
	background: #eff6ff;
	border-color: #bfdbfe;
	color: #1d4ed8;
}

.ccd-flash {
	padding: 10px 12px;
	border-radius: 10px;
	margin-bottom: 12px;
	font-size: 0.925rem;
}

.ccd-flash--ok {
	background: #f0fdf4;
	border: 1px solid #bbf7d0;
	color: #166534;
}

.ccd-flash--err {
	background: #fef2f2;
	border: 1px solid #fecaca;
	color: #b91c1c;
}

.ccd-modal[hidden] {
	display: none !important;
}

.ccd-modal {
	position: fixed;
	inset: 0;
	z-index: 80;
}

.ccd-modal__backdrop {
	position: absolute;
	inset: 0;
	background: rgba(15, 23, 42, 0.45);
}

.ccd-modal__panel {
	position: absolute;
	left: 50%;
	top: 12%;
	transform: translateX(-50%);
	width: min(92vw, 420px);
	background: #fff;
	border-radius: 16px;
	padding: 16px;
	box-shadow: 0 20px 40px rgba(15, 23, 42, 0.2);
}

.ccd-detail-lines {
	list-style: none;
	margin: 0 0 12px;
	padding: 0;
}

.ccd-detail-lines li {
	display: grid;
	grid-template-columns: 1fr auto auto;
	gap: 8px;
	padding: 8px 0;
	border-bottom: 1px solid #f3f4f6;
	font-size: 0.9rem;
}

.ccd-inline-form {
	display: inline;
}

.ccd-muted {
	color: #6b7280;
}

/* ── Create Order: sticky footer + line grid (scoped) ─────────── */

.ccd-order-create {
	padding-bottom: 8px;
}

.ccd-order-create__spacer {
	height: 88px;
}

.ccd-order-create__footer {
	position: sticky;
	bottom: 0;
	z-index: 40;
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	padding: 12px 0 calc(12px + env(safe-area-inset-bottom, 0px));
	background: linear-gradient(180deg, rgba(245, 246, 248, 0) 0%, #f5f6f8 28%, #f5f6f8 100%);
}

.ccd-order-create__footer .ccd-btn {
	flex: 1 1 auto;
	min-width: 96px;
	justify-content: center;
}

.ccd-line-card__grid {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 8px 10px;
	align-items: end;
}

.ccd-line-field {
	display: flex;
	flex-direction: column;
	gap: 4px;
	font-size: 0.75rem;
	color: #6b7280;
	font-weight: 600;
}

.ccd-line-field .ccd-qty,
.ccd-line-field .ccd-line-price,
.ccd-line-field .ccd-line-discount {
	width: 100%;
}

.ccd-line-card__total {
	margin-top: 8px;
	font-size: 0.875rem;
	color: #374151;
}

.ccd-line-remove {
	align-self: end;
	justify-self: start;
	padding: 8px 0;
}

@media (min-width: 480px) {
	.ccd-line-card__grid {
		grid-template-columns: minmax(110px, 1.2fr) 1fr 0.8fr auto;
	}
}

@media print {
	.ccd-order-create__footer,
	.ccd-app-sidebar,
	.ccd-app-header,
	.ccd-bottom-nav,
	.no-print {
		display: none !important;
	}

	.ccd-app-main {
		padding: 0 !important;
	}
}

