/* Giao diện dùng chung cho mọi khu vực - sửa ở đây là cả 3 nơi đổi theo */
/* ===== RESET & BASE ===== */
        *, *::before, *::after {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        html {
            height: 100%;
        }

        :root {
            /* cạnh thiệp: lấy theo chiều cao màn hình, chặn lại theo bề ngang còn trống */
            --card-size: min(calc(100dvh - 68px), calc(100vw - 440px), 848px);
        }

        body {
            font-family: 'Be Vietnam Pro', sans-serif;
            background: linear-gradient(135deg, #070D1A 0%, #0F1B33 30%, #14274E 60%, #1A3365 100%);
            color: #E2E8F0;
            height: 100%;
            overflow: hidden;          /* mọi thứ gói gọn trong 1 màn hình */
        }

        /* ===== NỀN TRANG TRÍ ===== */
        body::before {
            content: '';
            position: fixed;
            top: -50%;
            left: -50%;
            width: 200%;
            height: 200%;
            background: radial-gradient(circle at 20% 30%, rgba(255, 215, 0, 0.03) 0%, transparent 50%),
                        radial-gradient(circle at 80% 70%, rgba(200, 164, 92, 0.04) 0%, transparent 50%),
                        radial-gradient(circle at 50% 50%, rgba(59, 130, 246, 0.02) 0%, transparent 60%);
            pointer-events: none;
            z-index: 0;
        }

        /* ===== CONTAINER ===== */
        .container {
            position: relative;
            z-index: 1;
            max-width: 1280px;
            height: 100%;
            margin: 0 auto;
            padding: 12px 24px 8px;
            display: flex;
            flex-direction: column;
        }

        /* ===== LAYOUT CHÍNH ===== */
        .content {
            flex: 1;
            min-height: 0;             /* cho phép 2 cột co lại vừa màn hình */
            display: grid;
            grid-template-columns: 360px var(--card-size);
            grid-template-rows: auto 1fr;   /* hàng 1: tiêu đề preview, hàng 2: nội dung */
            column-gap: 24px;
            justify-content: center;        /* cả cụm nằm giữa màn hình */
            align-items: stretch;
        }

        /* Cột trái tự thu nhỏ vừa chiều cao màn hình (xem fitControls trong JS).
           overflow-y chỉ là lưới an toàn cho trình duyệt không hỗ trợ zoom. */
        .controls-panel {
            grid-column: 1;
            grid-row: 2;               /* thẳng hàng với mép trên của thiệp */
            min-height: 0;
            overflow-y: auto;
            scrollbar-width: thin;
            scrollbar-color: rgba(255,255,255,0.15) transparent;
        }

        .controls-inner {
            transform-origin: top left;
        }

        /* bỏ lề đáy thẻ cuối để chiều cao đo được khớp đúng, không dư ra thanh cuộn */
        .controls-inner .step-card:last-child {
            margin-bottom: 0;
        }

        .controls-panel::-webkit-scrollbar { width: 6px; }
        .controls-panel::-webkit-scrollbar-thumb {
            background: rgba(255,255,255,0.15);
            border-radius: 3px;
        }

        /* ===== CARD CHUNG ===== */
        .step-card {
            background: linear-gradient(145deg, rgba(255,255,255,0.06), rgba(255,255,255,0.02));
            backdrop-filter: blur(20px);
            -webkit-backdrop-filter: blur(20px);
            border: 1px solid rgba(255,255,255,0.08);
            border-radius: 14px;
            padding: 14px 16px;
            margin-bottom: 10px;
            transition: all 0.3s ease;
        }

        .step-card:hover {
            border-color: rgba(255, 215, 0, 0.15);
            box-shadow: 0 4px 24px rgba(0,0,0,0.2);
        }

        .step-header {
            display: flex;
            align-items: center;
            gap: 10px;
            margin-bottom: 10px;
        }

        .step-number {
            display: flex;
            align-items: center;
            justify-content: center;
            width: 26px;
            height: 26px;
            border-radius: 50%;
            background: linear-gradient(135deg, #FFD700, #C8A45C);
            color: #0A1628;
            font-weight: 800;
            font-size: 14px;
            flex-shrink: 0;
        }

        .step-header h2 {
            font-size: 16px;
            font-weight: 700;
            color: #F1F5F9;
        }

        /* ===== CHỌN HẠNG VÉ ===== */
        .ticket-options {
            display: grid;
            grid-template-columns: repeat(3, 1fr);
            gap: 10px;
        }

        .ticket-btn {
            position: relative;
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 4px;
            padding: 9px 6px;
            border: 2px solid transparent;
            border-radius: 12px;
            cursor: pointer;
            font-family: 'Be Vietnam Pro', sans-serif;
            font-weight: 700;
            font-size: 13px;
            letter-spacing: 1px;
            transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
            overflow: hidden;
        }

        .ticket-btn::before {
            content: '';
            position: absolute;
            inset: 0;
            border-radius: 10px;
            opacity: 0;
            transition: opacity 0.3s ease;
        }

        .ticket-btn.general {
            background: linear-gradient(145deg, rgba(148,163,184,0.15), rgba(148,163,184,0.05));
            color: #CBD5E1;
        }
        .ticket-btn.general::before {
            background: linear-gradient(145deg, rgba(148,163,184,0.25), rgba(148,163,184,0.1));
        }

        .ticket-btn.vip {
            background: linear-gradient(145deg, rgba(255,215,0,0.12), rgba(200,164,92,0.06));
            color: #FFD700;
        }
        .ticket-btn.vip::before {
            background: linear-gradient(145deg, rgba(255,215,0,0.25), rgba(200,164,92,0.12));
        }

        .ticket-btn.vvip {
            background: linear-gradient(145deg, rgba(168,85,247,0.15), rgba(139,92,246,0.06));
            color: #C084FC;
        }
        .ticket-btn.vvip::before {
            background: linear-gradient(145deg, rgba(168,85,247,0.25), rgba(139,92,246,0.12));
        }

        .ticket-btn:hover::before {
            opacity: 1;
        }

        .ticket-btn:hover {
            transform: translateY(-2px);
        }

        .ticket-btn.active {
            transform: translateY(-2px);
        }

        .ticket-btn.active.general {
            border-color: #94A3B8;
            box-shadow: 0 0 20px rgba(148,163,184,0.2), inset 0 0 20px rgba(148,163,184,0.05);
        }
        .ticket-btn.active.vip {
            border-color: #FFD700;
            box-shadow: 0 0 20px rgba(255,215,0,0.25), inset 0 0 20px rgba(255,215,0,0.05);
        }
        .ticket-btn.active.vvip {
            border-color: #A855F7;
            box-shadow: 0 0 20px rgba(168,85,247,0.25), inset 0 0 20px rgba(168,85,247,0.05);
        }

        .ticket-icon {
            font-size: 24px;
        }

        .ticket-check {
            position: absolute;
            top: 6px;
            right: 6px;
            width: 18px;
            height: 18px;
            border-radius: 50%;
            background: #22C55E;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 10px;
            color: white;
            transform: scale(0);
            transition: transform 0.2s ease;
        }

        .ticket-btn.active .ticket-check {
            transform: scale(1);
        }

        /* ===== NHẬP TÊN ===== */
        .name-input-wrapper {
            position: relative;
        }

        .name-input {
            width: 100%;
            padding: 10px 14px;
            background: rgba(255,255,255,0.06);
            border: 1px solid rgba(255,255,255,0.12);
            border-radius: 10px;
            color: #F1F5F9;
            font-family: 'Be Vietnam Pro', sans-serif;
            font-size: 15px;
            font-weight: 600;
            outline: none;
            transition: all 0.3s ease;
            letter-spacing: 0.5px;
        }

        .name-input::placeholder {
            color: #64748B;
            font-weight: 400;
        }

        .name-input:focus {
            border-color: #FFD700;
            box-shadow: 0 0 0 3px rgba(255,215,0,0.1);
            background: rgba(255,255,255,0.08);
        }

        .name-hint {
            font-size: 12px;
            color: #64748B;
            margin-top: 6px;
        }

        /* ===== UPLOAD ẢNH ===== */
        .upload-zone {
            border: 2px dashed rgba(255,255,255,0.15);
            border-radius: 12px;
            padding: 16px;
            text-align: center;
            cursor: pointer;
            transition: all 0.3s ease;
            background: rgba(255,255,255,0.02);
        }

        .upload-zone:hover,
        .upload-zone.dragover {
            border-color: rgba(255, 215, 0, 0.4);
            background: rgba(255, 215, 0, 0.04);
        }

        .upload-icon {
            width: 38px;
            height: 38px;
            margin: 0 auto 8px;
            opacity: 0.5;
        }

        .upload-icon svg {
            width: 100%;
            height: 100%;
            fill: none;
            stroke: #94A3B8;
            stroke-width: 1.5;
        }

        .upload-text {
            font-size: 14px;
            color: #94A3B8;
            margin-bottom: 4px;
        }

        .upload-text-small {
            font-size: 12px;
            color: #64748B;
        }

        .upload-text-btn {
            color: #FFD700;
            font-weight: 600;
            text-decoration: underline;
            text-underline-offset: 2px;
        }

        /* Trạng thái đã upload */
        .uploaded-info {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 9px 12px;
            background: rgba(34,197,94,0.08);
            border: 1px solid rgba(34,197,94,0.2);
            border-radius: 10px;
        }

        .uploaded-info .file-icon {
            font-size: 20px;
        }

        .uploaded-info .file-name {
            flex: 1;
            font-size: 13px;
            color: #86EFAC;
            font-weight: 500;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .uploaded-info button {
            background: none;
            border: none;
            cursor: pointer;
            font-family: 'Be Vietnam Pro', sans-serif;
            font-size: 12px;
            font-weight: 600;
            padding: 4px 10px;
            border-radius: 6px;
            transition: all 0.2s ease;
        }

        .btn-change-photo {
            color: #FFD700;
            background: rgba(255,215,0,0.1) !important;
        }
        .btn-change-photo:hover {
            background: rgba(255,215,0,0.2) !important;
        }

        .btn-remove-photo {
            color: #F87171;
            background: rgba(248,113,113,0.1) !important;
        }
        .btn-remove-photo:hover {
            background: rgba(248,113,113,0.2) !important;
        }

        /* ===== ĐIỀU CHỈNH ẢNH ===== */
        .adjust-controls {
            margin-top: 10px;
            padding: 11px 12px;
            background: rgba(255,255,255,0.04);
            border-radius: 10px;
            border: 1px solid rgba(255,255,255,0.06);
        }

        .adjust-label {
            font-size: 12px;
            font-weight: 600;
            color: #94A3B8;
            text-transform: uppercase;
            letter-spacing: 1px;
            margin-bottom: 8px;
        }

        .zoom-row {
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .zoom-btn {
            width: 28px;
            height: 28px;
            border-radius: 8px;
            border: 1px solid rgba(255,255,255,0.15);
            background: rgba(255,255,255,0.06);
            color: #E2E8F0;
            font-size: 18px;
            font-weight: 600;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all 0.2s ease;
            font-family: 'Be Vietnam Pro', sans-serif;
        }

        .zoom-btn:hover {
            background: rgba(255,215,0,0.15);
            border-color: rgba(255,215,0,0.3);
            color: #FFD700;
        }

        .zoom-btn:active {
            transform: scale(0.92);
        }

        /* Thanh trượt zoom */
        .zoom-slider {
            flex: 1;
            -webkit-appearance: none;
            appearance: none;
            height: 6px;
            background: rgba(255,255,255,0.1);
            border-radius: 3px;
            outline: none;
            cursor: pointer;
        }

        .zoom-slider::-webkit-slider-thumb {
            -webkit-appearance: none;
            width: 20px;
            height: 20px;
            border-radius: 50%;
            background: linear-gradient(135deg, #FFD700, #C8A45C);
            cursor: pointer;
            box-shadow: 0 2px 8px rgba(255,215,0,0.3);
            transition: box-shadow 0.2s ease;
        }

        .zoom-slider::-webkit-slider-thumb:hover {
            box-shadow: 0 2px 16px rgba(255,215,0,0.5);
        }

        .zoom-slider::-moz-range-thumb {
            width: 20px;
            height: 20px;
            border-radius: 50%;
            background: linear-gradient(135deg, #FFD700, #C8A45C);
            cursor: pointer;
            border: none;
            box-shadow: 0 2px 8px rgba(255,215,0,0.3);
        }

        .zoom-value {
            font-size: 13px;
            font-weight: 700;
            color: #FFD700;
            min-width: 42px;
            text-align: right;
        }

        .adjust-tip {
            display: flex;
            align-items: center;
            gap: 6px;
            margin-top: 8px;
            padding: 7px 10px;
            background: rgba(59,130,246,0.08);
            border-radius: 8px;
            font-size: 12px;
            color: #93C5FD;
        }

        .adjust-tip .tip-icon {
            font-size: 14px;
            flex-shrink: 0;
        }

        .btn-reset {
            display: inline-flex;
            align-items: center;
            gap: 6px;
            margin-top: 8px;
            padding: 7px 12px;
            background: rgba(255,255,255,0.06);
            border: 1px solid rgba(255,255,255,0.1);
            border-radius: 8px;
            color: #94A3B8;
            font-family: 'Be Vietnam Pro', sans-serif;
            font-size: 12px;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.2s ease;
        }

        .btn-reset:hover {
            background: rgba(255,255,255,0.1);
            color: #E2E8F0;
        }

        /* ===== NÚT HÀNH ĐỘNG ===== */
        .action-buttons {
            display: flex;
        }

        .btn-action {
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 6px;
            flex: 1;
            padding: 11px 8px;
            border: none;
            border-radius: 12px;
            font-family: 'Be Vietnam Pro', sans-serif;
            font-size: 13px;
            white-space: nowrap;
            font-weight: 700;
            cursor: pointer;
            transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
            letter-spacing: 0.3px;
        }

        .btn-download {
            background: linear-gradient(135deg, #FFD700, #F59E0B);
            color: #0A1628;
            box-shadow: 0 4px 20px rgba(255,215,0,0.25);
        }

        .btn-download:hover {
            transform: translateY(-2px);
            box-shadow: 0 8px 30px rgba(255,215,0,0.35);
        }

        .btn-download:active {
            transform: translateY(0);
        }

        .btn-icon {
            font-size: 15px;
        }

        /* ===== PREVIEW PANEL ===== */
        .preview-panel {
            grid-column: 2;
            grid-row: 2;
            min-height: 0;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: flex-start;
        }

        .preview-title {
            grid-column: 2;
            grid-row: 1;
            font-size: 14px;
            font-weight: 700;
            color: #F1F5F9;
            margin-bottom: 8px;
            text-align: center;
        }

        /* Cạnh thiệp = chiều cao còn trống của màn hình, không vượt bề ngang cột
           -> luôn thấy trọn thiệp ở zoom 100%, không phải cuộn */
        .canvas-container {
            position: relative;
            width: 100%;
            aspect-ratio: 1 / 1;
            background: rgba(0,0,0,0.3);
            border-radius: 16px;
            overflow: hidden;
            border: 1px solid rgba(255,255,255,0.08);
            box-shadow: 0 8px 40px rgba(0,0,0,0.4);
        }

        #canvas {
            display: block;
            width: 100%;
            height: auto;
            cursor: default;
        }

        #canvas.can-drag {
            cursor: grab;
        }

        #canvas.dragging {
            cursor: grabbing;
        }

        /* Lớp phủ loading */
        .canvas-loading {
            position: absolute;
            inset: 0;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            gap: 16px;
            background: rgba(10, 22, 40, 0.9);
            border-radius: 16px;
            z-index: 10;
            transition: opacity 0.4s ease;
        }

        .canvas-loading.hidden {
            opacity: 0;
            pointer-events: none;
        }

        .spinner {
            width: 40px;
            height: 40px;
            border: 3px solid rgba(255,215,0,0.2);
            border-top-color: #FFD700;
            border-radius: 50%;
            animation: spin 0.8s linear infinite;
        }

        @keyframes spin {
            to { transform: rotate(360deg); }
        }

        .canvas-loading p {
            font-size: 14px;
            color: #94A3B8;
        }

        /* Điều khiển zoom dưới preview */
        .preview-controls {
            margin-top: 16px;
            opacity: 0;
            max-height: 0;
            overflow: hidden;
            transition: all 0.4s ease;
        }

        .preview-controls.visible {
            opacity: 1;
            max-height: 200px;
        }

        /* ===== FOOTER ===== */
        .footer {
            text-align: center;
            padding: 0;
            font-size: 11px;
            color: #475569;
            flex-shrink: 0;
        }

        .footer a {
            color: #FFD700;
            text-decoration: none;
        }

        /* ===== THÔNG BÁO TOAST ===== */
        .toast {
            position: fixed;
            bottom: 30px;
            left: 50%;
            transform: translateX(-50%) translateY(100px);
            padding: 12px 24px;
            background: rgba(34, 197, 94, 0.9);
            backdrop-filter: blur(10px);
            border-radius: 12px;
            color: #FFFFFF;
            font-size: 14px;
            font-weight: 600;
            z-index: 1000;
            opacity: 0;
            transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
            pointer-events: none;
            box-shadow: 0 8px 32px rgba(0,0,0,0.3);
        }

        .toast.show {
            opacity: 1;
            transform: translateX(-50%) translateY(0);
        }

        /* ===== RESPONSIVE ===== */
        @media (max-width: 860px) {
            html, body {
                height: auto;
                overflow: visible;
            }

            .container {
                height: auto;
                display: block;
                padding: 12px 16px 32px;
            }

            /* xếp dọc: thiệp trước, bảng điều khiển sau
               (phải xoá luôn vị trí hàng/cột đã đặt cho bản máy tính) */
            .content {
                grid-template-columns: 1fr;
                grid-template-rows: none;
            }

            .preview-title,
            .preview-panel,
            .controls-panel {
                grid-column: 1;
                grid-row: auto;
            }

            .preview-title  { order: 1; margin-bottom: 8px; }
            .preview-panel  { order: 2; margin-bottom: 16px; }
            .controls-panel { order: 3; overflow: visible; padding-right: 0; }

            .canvas-container {
                width: 100%;
            }

            .footer {
                padding: 24px 0 8px;
            }

            .step-card {
                padding: 16px;
                margin-bottom: 12px;
            }

            .ticket-options {
                gap: 8px;
            }

            .action-buttons {
                flex-direction: row;
            }

            .btn-action {
                flex: 1;
                padding: 12px 16px;
                font-size: 14px;
            }
        }

        @media (max-width: 480px) {
            .action-buttons {
                flex-direction: column;
            }
        }

        /* ===== ANIMATION TINH TẾ ===== */
        .step-card {
            animation: fadeInUp 0.5s ease forwards;
            opacity: 0;
        }

        .step-card:nth-child(1) { animation-delay: 0.1s; }
        .step-card:nth-child(2) { animation-delay: 0.2s; }
        .step-card:nth-child(3) { animation-delay: 0.3s; }
        .step-card:nth-child(4) { animation-delay: 0.4s; }

        @keyframes fadeInUp {
            from {
                opacity: 0;
                transform: translateY(20px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }

        .preview-panel {
            animation: fadeInUp 0.5s ease 0.2s forwards;
            opacity: 0;
        }
