:root {
	--brand-grad-start: #6B9BD1;
	--brand-grad-end: #4F78B0;
	--primary-blue: #6B9BD1;
	--secondary-blue: #A8C5E3;
	--accent-red: #E8A5A5;
	--light-red: #F5D4D4;
	--pure-white: #FFFFFF;
	--off-white: #F8F9FA;
	--light-gray: #E8ECEF;
	--text-dark: #1F2937;
	--text-medium: #4B5563;
	--text-light: #9CA3AF;
	--border: #E5E7EB;
	--shadow-sm: rgba(0, 0, 0, 0.06);
	--shadow-md: rgba(0, 0, 0, 0.12);
	--success: #10B981;
	--warning: #F59E0B;
	--danger: #EF4444;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
	font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
	background: linear-gradient(180deg, #f6f8fc 0%, #ffffff 100%);
	color: var(--text-dark);
	line-height: 1.6;
	min-height: 100vh;
	font-size: 15px;
}

/* Header */
.header {
	background: linear-gradient(90deg, var(--brand-grad-start), var(--brand-grad-end));
	color: #fff;
	padding: 1.25rem 0;
	position: sticky;
	top: 0;
	z-index: 100;
	box-shadow: 0 6px 18px var(--shadow-sm);
	border-bottom: 1px solid rgba(255,255,255,0.12);
}

.container { max-width: 1200px; margin: 0 auto; padding: 0 24px; }
.header .container { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 1rem; }

.logo { display: flex; align-items: center; gap: 12px; }
.logo i { font-size: 1.75rem; color: #fff; filter: drop-shadow(0 2px 6px rgba(0,0,0,.2)); }
.logo h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.1); }

.header-controls { display: flex; align-items: center; gap: 0.75rem; }

#themeSelector {
	padding: 8px 14px; border: 1px solid rgba(255,255,255,0.4); border-radius: 8px; background: rgba(255,255,255,0.15);
	color: #fff; font-size: 0.9rem; cursor: pointer; transition: all 0.2s ease; backdrop-filter: blur(4px);
}
#themeSelector:focus { outline: none; border-color: #fff; box-shadow: 0 0 0 3px rgba(255,255,255,.25); }

.admin-btn, .action-btn {
	background: rgba(255,255,255,0.18); color: #fff; border: 1px solid rgba(255,255,255,0.35);
	padding: 9px 16px; border-radius: 8px; cursor: pointer; font-weight: 600; font-size: 0.9rem;
	transition: all .2s ease; display: inline-flex; align-items: center; gap: 8px; backdrop-filter: blur(4px);
}
.admin-btn:hover, .action-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(0,0,0,.15); }

/* Main */
.main { padding: 2rem 0; }

/* Panel */
.add-order-section, .orders-section {
	background: var(--pure-white); border-radius: 14px; padding: 2rem; margin-bottom: 2rem;
	box-shadow: 0 12px 30px rgba(0,0,0,.06); border: 1px solid var(--border);
}
.add-order-section h2, .orders-section h2 { color: var(--text-dark); margin-bottom: 1.25rem; font-weight: 700; font-size: 1.4rem; letter-spacing: -0.01em; }

/* Form */
.order-form { display: flex; flex-direction: column; gap: 1.25rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-group { display: flex; flex-direction: column; gap: 0.5rem; }
.form-group label { font-weight: 600; color: var(--text-medium); font-size: 0.9rem; }
.form-group input, .form-group select, .form-group textarea {
	padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; font-size: 0.95rem; transition: all 0.2s ease;
	background: #fff; color: var(--text-dark); box-shadow: 0 2px 8px rgba(0,0,0,.03) inset;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
	outline: none; border-color: var(--primary-blue); box-shadow: 0 0 0 4px rgba(107,155,209,.18);
}
.form-group textarea { resize: vertical; min-height: 90px; }
.submit-btn {
	background: linear-gradient(90deg, var(--brand-grad-start), var(--brand-grad-end)); color: #fff; border: none; padding: 12px 24px; border-radius: 10px;
	font-size: 0.95rem; font-weight: 700; cursor: pointer; transition: all 0.2s ease; display: inline-flex; align-items: center; gap: 8px;
}
.submit-btn:hover { transform: translateY(-1px); box-shadow: 0 10px 18px rgba(79,120,176,.28); }

/* Orders */
.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.25rem; flex-wrap: wrap; gap: 1rem; }
.filter-controls { display: flex; align-items: center; gap: 0.75rem; }
.filter-controls input, .filter-controls select {
	padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: #fff;
	cursor: pointer; font-size: 0.9rem; color: var(--text-dark); transition: all 0.2s ease;
}
.filter-controls input:focus, .filter-controls select:focus { outline: none; border-color: var(--primary-blue); box-shadow: 0 0 0 3px rgba(107,155,209,.15); }

/* Cards */
.orders-container { display: grid; gap: 1.25rem; }
.order-card {
	background: #fff; border: 1px solid var(--border);
	border-radius: 14px; padding: 1.25rem; transition: all 0.2s ease; animation: fadeIn .3s ease-out;
	box-shadow: 0 8px 22px rgba(0,0,0,.06);
}
.order-card:hover { box-shadow: 0 12px 28px rgba(0,0,0,.12); border-color: #dfe5ee; }
.order-card.overdue { border-left: 4px solid var(--danger); background: #fff7f7; }

.order-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 1rem; flex-wrap: wrap; gap: 1rem; }
.order-info h3 { color: var(--text-dark); font-weight: 700; margin-bottom: 0.25rem; font-size: 1.15rem; letter-spacing: -0.01em; }
.order-info .order-id {
	font-size: 0.84rem; color: var(--text-light); font-weight: 600; background: #f3f6fb;
	padding: 4px 10px; border-radius: 999px; display: inline-block; border: 1px solid #e7edf7;
}
.order-status { padding: 6px 12px; border-radius: 999px; font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .3px; }
.status-pending { background: #fff3e1; color: #b45309; border: 1px solid #fde7c4; }
.status-in-progress { background: #e9f2ff; color: #1d4ed8; border: 1px solid #d7e6ff; }
.status-ready { background: #e9fbf3; color: #047857; border: 1px solid #c8f1df; }

/* Progress */
.order-progress { margin: 0.75rem 0 1rem; }
.progress-labels { display: flex; justify-content: space-between; margin-bottom: 0.5rem; font-size: 0.75rem; color: var(--text-light); font-weight: 600; }
.progress-bar-container { background: var(--light-gray); height: 8px; border-radius: 999px; overflow: hidden; }
.progress-bar-fill { height: 100%; background: linear-gradient(90deg, var(--brand-grad-start), var(--brand-grad-end)); transition: width .3s ease; }

/* Details */
.order-details {
	display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0.75rem; margin-bottom: 0.75rem; padding: 0.75rem;
	background: #fbfcfe; border-radius: 10px; border: 1px dashed #e5ecf7;
}
.detail-item { display: flex; flex-direction: column; gap: 0.25rem; }
.detail-label { font-size: 0.72rem; color: var(--text-light); font-weight: 700; text-transform: uppercase; letter-spacing: .5px; }
.detail-value { font-weight: 600; color: var(--text-dark); font-size: 0.95rem; }

.text-danger { color: var(--danger) !important; font-weight: 700; }

/* Notes */
.order-notes { background: #fff7f2; padding: 0.85rem; border-radius: 10px; border-left: 4px solid #f8c596; margin-bottom: 0.75rem; color: var(--text-medium); font-size: 0.92rem; }

/* Actions */
.order-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; padding-top: 0.75rem; border-top: 1px solid var(--border); }
.action-btn {
	padding: 9px 14px; border: 1px solid #e6ebf5; border-radius: 10px; font-size: 0.85rem; font-weight: 700; cursor: pointer; transition: all 0.2s ease; display: inline-flex; align-items: center; gap: 8px; color: #1f2937; background: #fff;
}
.action-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 14px rgba(0,0,0,.08); }
.whatsapp-btn { background: #25D366; color: #fff; border-color: #22c55e; }
.whatsapp-btn:hover { background: #20BA5A; }

/* Photos */
.photo-preview-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 8px; }
.photo-preview-grid img { width: 100%; height: 90px; object-fit: cover; border-radius: 10px; border: 1px solid #e8edf7; box-shadow: 0 4px 10px rgba(0,0,0,.05); }
.order-card-photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); gap: 6px; margin-top: 8px; }
.order-card-photos img { width: 100%; height: 70px; object-fit: cover; border-radius: 8px; border: 1px solid #e8edf7; }

/* Modal */
.modal { display: none; position: fixed; z-index: 1000; left: 0; top: 0; width: 100%; height: 100%; background-color: rgba(17,24,39,.55); backdrop-filter: blur(6px); }
.modal-content { background: #fff; margin: 5% auto; padding: 2rem; border-radius: 14px; width: 90%; max-width: 680px; max-height: 90vh; overflow-y: auto; position: relative; box-shadow: 0 24px 60px rgba(17,24,39,.25); border: 1px solid #eef2f9; }
.close { color: var(--text-light); position: absolute; right: 1.25rem; top: 1.25rem; font-size: 20px; font-weight: 800; cursor: pointer; width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; border-radius: 8px; transition: all .2s; }
.close:hover { background: #f3f6fc; color: var(--danger); }
.modal h2 { color: var(--text-dark); margin-bottom: 1.25rem; font-weight: 800; font-size: 1.4rem; }

/* Admin modal */
#adminModal .modal-content { max-width: 450px; padding: 2.25rem; text-align: center; }

/* Loading */
.loading-spinner { display: none; position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 2000; }

/* Animations */
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.logo-icon { animation: logoPulse 2s ease-in-out infinite; }
@keyframes logoPulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.2); } }

/* Responsive */
@media (max-width: 768px) {
	.form-row { grid-template-columns: 1fr; }
	.order-header { flex-direction: column; align-items: flex-start; }
	.filter-controls { flex-direction: column; width: 100%; }
	.filter-controls input, .filter-controls select { width: 100%; }
}

/* Print control */
.print-area { display: none; }
@media print {
	body * { visibility: hidden !important; }
	.print-area, .print-area * { visibility: visible !important; }
	.print-area { position: absolute; inset: 0; padding: 0; margin: 0; }
}

/* Receipt (A4) */
.receipt {
	width: 210mm;
	padding: 14mm 16mm;
	box-sizing: border-box;
	font-family: 'Inter', Arial, sans-serif;
	color: #111;
}
.receipt .muted { color: #6b7280; font-size: 12px; }
.receipt-header {
	display: grid;
	grid-template-columns: 1fr 180px;
	align-items: center;
	border-bottom: 2px solid #000;
	padding-bottom: 8px;
	margin-bottom: 12px;
}
.brand { display: flex; gap: 10px; align-items: center; }
.brand i { font-size: 26px; color: #111; }
.brand-meta h3 { margin: 0; font-size: 18px; }
.receipt-qr { display: flex; flex-direction: column; align-items: center; }
.qr-caption { font-size: 11px; margin-top: 6px; color: #6b7280; }

.receipt-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.block { margin-top: 10px; }
.block-title { font-weight: 800; margin-bottom: 6px; color: #111827; letter-spacing: .2px; }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 8px; font-size: 13px; padding: 6px 8px; border: 1px dashed #ddd; border-radius: 8px; margin-bottom: 6px; }
.kv span { color: #6b7280; }

.items { width: 100%; border-collapse: collapse; margin-top: 6px; font-size: 13px; }
.items th, .items td { border: 1px solid #e5e7eb; padding: 8px; }
.items thead th { background: #f3f4f6; text-align: left; font-weight: 700; }
.items .num { text-align: right; }
.items tfoot td { font-weight: 700; }
.items tfoot .total td { font-size: 14px; }

.receipt-photos { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 8px; page-break-inside: avoid; }
.receipt-photos img { width: 100%; height: 90px; object-fit: cover; border: 1px solid #d1d5db; border-radius: 6px; }

.sign { margin-top: 12px; display: grid; gap: 4px; text-align: center; }
.sig-line { height: 1px; background: #9ca3af; margin: 8px 0; }

/* Label 80x50mm */
.label {
	width: 80mm;
	height: 50mm;
	padding: 5mm;
	box-sizing: border-box;
	display: grid;
	grid-template-columns: 1fr 40mm;
	gap: 6px;
	font-family: 'Inter', Arial, sans-serif;
}
.label-left { font-size: 12px; display: grid; gap: 4px; }
.label-right { display: grid; grid-template-rows: 1fr auto; align-items: center; justify-items: center; gap: 4px; }
.label-thumb img { width: 38mm; height: 18mm; object-fit: cover; border: 1px solid #d1d5db; border-radius: 3px; }

/* Page size */
@media print { @page { size: A4; margin: 10mm; } }
body.printing-label @media print { @page { size: 80mm 50mm; margin: 0; } }