:root {
    --primary-color: #4F46E5;
    --primary-hover: #4338CA;
    --bg-color: #F3F4F6;
    --card-bg: #FFFFFF;
    --text-main: #111827;
    --text-muted: #6B7280;
    --border-color: #E5E7EB;
    --error-color: #EF4444;
    --success-color: #10B981;
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --radius-md: 0.5rem;
    --radius-lg: 1rem;
}

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

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-main);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header */
.app-header {
    background-color: var(--card-bg);
    padding: 1.5rem 0;
    box-shadow: var(--shadow-sm);
    text-align: center;
}
.app-header h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}
.app-header p {
    color: var(--text-muted);
    font-size: 0.95rem;
}

/* Main Container */
.container {
    flex: 1;
    width: 100%;
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 1rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* Card */
.card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 2rem;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 2rem;
    padding-bottom: 0.5rem;
    scrollbar-width: none; /* Firefox */
}
.tabs::-webkit-scrollbar {
    display: none; /* Chrome, Safari */
}
.tab-button {
    flex: 1;
    text-align: center;
    background: transparent;
    border: none;
    padding: 0.75rem 0.5rem;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
    white-space: nowrap;
}
.tab-button:hover {
    background-color: #F9FAFB;
    color: var(--text-main);
}
.tab-button.active {
    background-color: var(--primary-color);
    color: white;
}

/* Tab Content */
.tab-content {
    animation: fadeIn 0.3s ease;
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

.tab-content h2 {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
}

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
}
.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    font-size: 0.95rem;
}
.row-flex {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

input[type="text"], input[type="email"], textarea, select {
    width: 100%;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 0.95rem;
    transition: border-color 0.2s;
}

.grid-2 input, .grid-2 textarea, .grid-2 select {
    margin-bottom: 0;
}
input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

/* Buttons */
.btn-primary, .btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}
.btn-primary {
    background-color: var(--primary-color);
    color: white;
}
.btn-primary:hover {
    background-color: var(--primary-hover);
}
.btn-primary:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}
.btn-secondary {
    background-color: #F3F4F6;
    color: var(--text-main);
    border: 1px solid var(--border-color);
}
.btn-secondary:hover {
    background-color: #E5E7EB;
}

.generate-btn {
    width: 100%;
    margin-top: 1rem;
    padding: 1rem;
    font-size: 1.1rem;
}

.icon-btn {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
}

/* Error Box */
.error-box {
    background-color: #FEF2F2;
    border: 1px solid #F87171;
    color: #991B1B;
    padding: 1rem;
    border-radius: var(--radius-md);
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
}

/* Logo Section */
.section-block {
    margin-bottom: 2rem;
    padding: 1.5rem;
    background-color: #F9FAFB;
    border-radius: var(--radius-md);
    border: 1px dashed var(--border-color);
}
.section-block h3 {
    margin-bottom: 1rem;
    font-size: 1.1rem;
}
.upload-btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    background: var(--primary-color);
    color: white;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.9rem;
}
#logoPreviewContainer {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 1rem;
}
#logoImage {
    width: 50px;
    height: 50px;
    object-fit: contain;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: white;
}
.delete-btn {
    background: var(--error-color);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

/* Results Table Section */
.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.batch-actions {
    display: flex;
    gap: 0.5rem;
}
.table-responsive {
    overflow-x: auto;
}
.qr-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}
.qr-table th, .qr-table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
}
.qr-table th {
    background-color: #F9FAFB;
    font-weight: 600;
    color: var(--text-muted);
    position: sticky;
    top: 0;
}
.qr-table tr:hover {
    background-color: #F9FAFB;
}
.url-cell {
    max-width: 300px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-family: monospace;
    font-size: 0.9rem;
}
.url-cell:hover {
    white-space: normal;
    word-break: break-all;
}
.download-group {
    display: flex;
    gap: 0.5rem;
}

/* Footer Stats */
.app-footer {
    background-color: var(--card-bg);
    border-top: 1px solid var(--border-color);
    padding: 2rem 0;
    margin-top: auto;
}
.stats-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
}
.stat-box {
    text-align: center;
    padding: 1rem;
    border-radius: var(--radius-md);
    background: #F9FAFB;
}
.stat-label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.stat-value {
    display: block;
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--primary-color);
}
.skeleton .stat-value {
    color: transparent;
    background: #E5E7EB;
    border-radius: 4px;
    width: 50%;
    height: 2rem;
    margin: 0 auto;
    animation: pulse 1.5s infinite;
}
@keyframes pulse {
    0% { opacity: 0.6; }
    50% { opacity: 1; }
    100% { opacity: 0.6; }
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
}
.modal.show {
    display: flex;
    animation: modalFadeIn 0.3s;
}
@keyframes modalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
.modal-content {
    background-color: var(--card-bg);
    padding: 2rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 90%;
    max-width: 400px;
    text-align: center;
    position: relative;
    transform: scale(0.95);
    transition: transform 0.3s;
}
.modal.show .modal-content {
    transform: scale(1);
}
.close-modal {
    position: absolute;
    top: 1rem;
    right: 1.5rem;
    color: var(--text-muted);
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
}
.close-modal:hover {
    color: var(--text-main);
}
.modal-qr-container {
    margin: 1.5rem 0;
    padding: 1rem;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}
.modal-qr-container img {
    width: 100%;
    height: auto;
    display: block;
}
.modal-url {
    word-break: break-all;
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}
.modal-actions {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Selected badge */
.selected-badge {
    display: inline-flex;
    align-items: center;
    background: var(--primary-color);
    color: white;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.2rem 0.7rem;
    border-radius: 999px;
    white-space: nowrap;
}

/* Pagination */
.pagination-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 1.2rem 1rem 0.5rem;
    flex-wrap: wrap;
}
.page-btn {
    min-width: 36px;
    height: 36px;
    padding: 0 0.6rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: white;
    color: var(--text-color);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.18s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}
.page-btn:hover:not(.disabled):not(.active) {
    background: var(--bg-color);
    border-color: var(--primary-color);
    color: var(--primary-color);
}
.page-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}
.page-btn.disabled {
    opacity: 0.35;
    cursor: not-allowed;
}
.page-dots {
    color: var(--text-muted);
    font-size: 0.95rem;
    padding: 0 0.2rem;
    user-select: none;
}
.page-info {
    margin-left: 0.8rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    white-space: nowrap;
}

/* Responsive */
@media (max-width: 768px) {
    .grid-2 { grid-template-columns: 1fr; }
    .results-header { flex-direction: column; align-items: stretch; }
    .batch-actions { flex-direction: column; }
    .tabs { flex-wrap: wrap; justify-content: flex-start; }
    .tab-button { flex: 1 1 auto; }
    .page-info { display: none; }
}