:root {
    /* Dark Theme Colors */
    --bg-primary: #0A0A0A;
    --bg-secondary: #1A1A1A;
    --bg-card: #1E1E1E;
    --bg-card-hover: #252525;
    
    --text-primary: #FFFFFF;
    --text-secondary: #B0B0B0;
    --text-muted: #808080;
    
    --accent-primary: #9333EA;
    --accent-secondary: #A855F7;
    --accent-hover: #7E22CE;
    
    --border-color: #2A2A2A;
    --border-focus: #9333EA;
    
    --success: #10B981;
    --warning: #F59E0B;
    --danger: #EF4444;
    --info: #3B82F6;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
}

.light-theme {
    /* Light Theme Colors */
    --bg-primary: #F8F9FA;
    --bg-secondary: #FFFFFF;
    --bg-card: #FFFFFF;
    --bg-card-hover: #F8F9FA;
    
    --text-primary: #1A1A1A;
    --text-secondary: #4B5563;
    --text-muted: #9CA3AF;
    
    --accent-primary: #9333EA;
    --accent-secondary: #A855F7;
    --accent-hover: #7E22CE;
    
    --border-color: #E5E7EB;
    --border-focus: #9333EA;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica', 'Arial', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    max-width: 768px;
    margin: 0 auto;
    padding: 16px;
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding: 12px 0;
}

/* Start Message Banner */
.start-message-banner {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 20px;
    font-size: 12px;
    line-height: 1.6;
    color: var(--text-secondary);
}

.start-message-banner p {
    margin: 0;
    white-space: pre-line;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 600;
    font-size: 18px;
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 20px;
}

.theme-toggle {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    width: 40px;
    height: 40px;
    border-radius: 10px;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.theme-toggle:hover {
    background: var(--bg-card-hover);
    transform: scale(1.05);
}

/* Typography */
.page-title {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 24px;
    color: var(--text-primary);
}

.card-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
}

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 16px;
    transition: all 0.2s ease;
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.card-header .card-title {
    margin-bottom: 0;
}

/* Profile Card */
.profile-card {
    background: linear-gradient(135deg, var(--bg-card) 0%, var(--bg-secondary) 100%);
}

.profile-header {
    display: flex;
    gap: 16px;
    margin-bottom: 20px;
}

/* Avatar Upload */
input[type="file"].input-field {
    cursor: pointer;
}

input[type="file"].input-field::-webkit-file-upload-button {
    background: var(--accent-primary);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
    font-size: 14px;
    margin-right: 12px;
}

input[type="file"].input-field::-webkit-file-upload-button:hover {
    background: var(--accent-hover);
}

/* Business Avatar Display */
.profile-avatar-container {
    width: 120px;
    height: 120px;
    background: var(--bg-secondary);
    border: 3px solid var(--border-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 14px;
    flex-shrink: 0;
    overflow: hidden;
}

.profile-avatar-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.profile-info h2 {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 8px;
}

.profile-info p {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.5;
}

.profile-contacts {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 20px;
}

.contact-item {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 14px;
}

.contact-icon {
    font-size: 16px;
    width: 20px;
}

.contact-item a {
    color: var(--accent-primary);
    text-decoration: none;
}

.contact-item a:hover {
    text-decoration: underline;
}

.profile-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

/* Form Elements */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.input-field,
.textarea-field,
.select-input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 15px;
    transition: all 0.2s ease;
    font-family: inherit;
}

.input-field:focus,
.textarea-field:focus,
.select-input:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(147, 51, 234, 0.1);
}

.textarea-field {
    min-height: 120px;
    resize: vertical;
}

.select-input {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L6 6L11 1' stroke='%23808080' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    padding-right: 40px;
}

.form-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 24px;
}

/* Buttons */
.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    white-space: nowrap;
}

.btn-icon {
    font-size: 14px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: white;
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--accent-hover), var(--accent-primary));
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-card-hover);
    border-color: var(--accent-primary);
}

.btn-outline {
    background: transparent;
    color: var(--accent-primary);
    border: 1px solid var(--accent-primary);
}

.btn-outline:hover {
    background: rgba(147, 51, 234, 0.1);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #DC2626;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-danger-outline {
    background: transparent;
    color: var(--danger);
    border: 1px solid var(--danger);
    width: 100%;
}

.btn-danger-outline:hover {
    background: rgba(239, 68, 68, 0.1);
}

/* Back Button */
.btn-back {
    width: 30%;
    margin-bottom: 20px;
    font-size: 14px;
    padding: 10px 8px;
}

.button-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
}

.full-width {
    width: 100%;
}

/* Badges & Status */
.badge {
    background: var(--accent-primary);
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
}

.status-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 12px;
}

.status-badge {
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
}

.status-draft {
    background: rgba(168, 85, 247, 0.15);
    color: var(--accent-secondary);
}

.status-active {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
}

.status-expired {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
}

.status-warning {
    background: rgba(245, 158, 11, 0.15); /* --warning with opacity */
    color: var(--warning);
}

.status-waiting-reward,
.status-reward-verification {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
}

/* Offers List */
.offers-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 16px;
}

.offer-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    transition: all 0.2s ease;
    cursor: pointer;
}

.offer-item:hover {
    background: var(--bg-card-hover);
    border-color: var(--accent-primary);
    transform: translateY(4px);
}

.offer-item h3 {
    font-size: 16px;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.offer-item p {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 4px 0;
}

.offer-item .offer-discount {
    color: var(--accent-primary);
    font-weight: 600;
}

/* Coupons */
.coupons-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 16px;
}

.coupon-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    transition: all 0.2s ease;
}

.coupon-card:hover {
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-sm);
}

.coupon-card h3 {
    font-size: 16px;
    margin-bottom: 12px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.coupon-card p {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 6px 0;
    display: flex;
    justify-content: space-between;
}

.coupon-card p strong {
    color: var(--text-primary);
}

.coupon-card .status-activated {
    color: var(--success);
    font-weight: 600;
}

.coupon-card .status-issued {
    color: var(--info);
    font-weight: 600;
}

/* Statistics */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 16px;
    margin-top: 16px;
}

.stat-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    text-align: center;
}

.stat-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--accent-primary);
    margin-bottom: 4px;
}

.stat-label {
    font-size: 13px;
    color: var(--text-secondary);
}

/* Danger Zone */
.danger-zone {
    border-color: rgba(239, 68, 68, 0.3);
    background: rgba(239, 68, 68, 0.05);
}

/* Empty States */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state-text {
    font-size: 16px;
}

/* Responsive Design */
@media (max-width: 640px) {
    .container {
        padding: 12px;
    }

    .page-title {
        font-size: 24px;
        margin-bottom: 20px;
    }

    .card {
        padding: 16px;
        margin-bottom: 12px;
    }

    .profile-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .profile-actions {
        grid-template-columns: 1fr;
    }

    .button-grid {
        grid-template-columns: 1fr;
    }

    .form-actions {
        grid-template-columns: 1fr;
    }

    .stat-value {
        font-size: 28px;
    }
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.card {
    animation: fadeIn 0.3s ease;
}

/* Loading States */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid var(--accent-primary);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Welcome Page */
.welcome-section {
    text-align: center;
}

.welcome-section .button-grid {
    grid-template-columns: 1fr;
    gap: 16px;
    margin-top: 24px;
}

.welcome-section .btn {
    font-size: 16px;
    padding: 16px 24px;
}

/* ===== TRANSACTIONS: unified, coupon-like look & inline action buttons ===== */
.transactions-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 16px;
}

/* карточка транзакции — как купон */
.transactions-list .transaction-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    transition: all 0.18s ease;
    cursor: default; /* чтобы весь блок не вел себя как ссылка/кнопка */
}

.transactions-list .transaction-item:hover {
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-sm);
    transform: translateY(4px);
}

/* Заголовок в карточке: код купона + статус справа */
.transactions-list .transaction-item > h3 {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 0 0 8px 0;
    font-size: 16px;
    color: var(--text-primary);
}

/* Текстовые строки внутри карточки */
.transactions-list .transaction-item p {
    margin: 6px 0;
    color: var(--text-secondary);
    font-size: 14px;
}

/* компактная метка статуса */
.transactions-list .transaction-item .status-badge {
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
}

/* Контейнер кнопок — inline и одинаковой ширины */
.transactions-list .transaction-item .transaction-buttons {
    display: flex;
    gap: 10px;
    margin-top: 12px;
}

.transactions-list .transaction-item .pending-message {
    color: var(--accent-primary);
    font-weight: 600;
    margin: 18px 0;
    font-size: 14px;
}

/* Базовый стиль кнопок внутри транзакции:
   прозрачный фон (чтобы казалось как часть карточки),
   рамка и текст — по значению действия */
.transactions-list .transaction-item .transaction-buttons .btn {
    flex: 1 1 0;
    min-width: 0;
    padding: 10px 12px;
    font-size: 14px;
    border-radius: 8px;
    background: transparent;
    box-shadow: none;
}

/* Завершить — зелёная рамка и текст */
.transactions-list .transaction-item .transaction-buttons .btn-success-outline {
    color: var(--success);
    border: 1.5px solid var(--success);
    background: rgba(16,185,129,0.03);
}

/* Отклонить — красная рамка и текст */
.transactions-list .transaction-item .transaction-buttons .btn-cancel-outline {
    color: var(--danger);
    border: 1.5px solid var(--danger);
    background: rgba(239,68,68,0.03);
}

/* Hover эффекты */
.transactions-list .transaction-item .transaction-buttons .btn-success-outline:hover {
    background: rgba(16,185,129,0.08);
}
.transactions-list .transaction-item .transaction-buttons .btn-cancel-outline:hover {
    background: rgba(239,68,68,0.08);
}

.transactions-list .transaction-item .transaction-buttons .btn-warning-outline {
    color: var(--text-primary);
    border: 1.5px solid var(--warning);
    background: rgba(245,158,11,0.03);
}

.transactions-list .transaction-item .transaction-buttons .btn-warning-outline:hover {
    background: rgba(245,158,11,0.08);
}

/* На мобильных узких экранах — кнопки стекать вертикально */
@media (max-width: 420px) {
    .transactions-list .transaction-item .transaction-buttons {
        flex-direction: column;
    }
}

/* Partners List (styled similarly to transactions-list and offers-list) */
.partners-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 16px;
}

/* Partner Item (coupon-like card, similar to transaction-item) */
.partners-list .partner-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px;
    transition: all 0.18s ease;
    cursor: default;
    margin-bottom: 8px; /* Add spacing like other lists */
}

.partners-list .partner-item:hover {
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-sm);
    transform: translateY(4px);
}

/* Header in partner item: Name + optional elements */
.partners-list .partner-item > h3 {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 0 0 8px 0;
    font-size: 16px;
    color: var(--text-primary);
}

/* Username link (hyperlink to chat) */
.partners-list .partner-item .username-link {
    color: var(--info);
    text-decoration: none;
    font-size: 16px;
}

.partners-list .partner-item .username-link:hover {
    text-decoration: underline;
}

.partners-list .partner-item .partner-header {
    display: flex;
    justify-content: space-between;
    align-items: center; /* Align stats vertically centered with name */
    gap: 12px;
}

.partners-list .partner-item .partner-header .name-section {
    flex: 1;
    margin-bottom: 0; /* Remove any extra margin */
}

.partners-list .partner-item .partner-stats {
    display: flex;
    flex-direction: column;
    gap: 4px; /* Tighter gap for compactness */
}

.partners-list .partner-item .partner-stats .stat-item {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 6px;
    text-align: center;
    min-width: 50px;
}

.partners-list .partner-item .partner-stats .stat-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--accent-primary);
    margin-bottom: 1px;
}

.partners-list .partner-item .partner-stats .stat-label {
    font-size: 10px;
    color: var(--text-secondary);
}