* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: rgb(26, 32, 38);
    color: #ffffff;
    line-height: 1.4;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.container {
    max-width: 520px;
    margin: 0 auto;
    background: rgb(26, 32, 38);
    padding: 0 20px;
    flex: 1;
}

/* Header */
header {
    background: rgba(33, 42, 51, .9);
    border-bottom: 1px solid rgb(50, 56, 62);
    padding: 0;
    margin-bottom: 22px;
    width: 100%;
    height: 56px;
}

header .container {
    background: transparent;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    gap: 0;
}

/* Fragment Logo */
.fragment-logo {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: #ffffff;
    height: 24px;
    margin: 0;
    border: 0;
    padding: 0;
}

.logo-icon {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}

.header-text {
    width: 101px;
    height: 24px;
}

/* Header Wallet Section */
.header-wallet {
    display: flex;
    align-items: center;
    gap: 10px;
}

.wallet-connect-btn {
    background: transparent;
    color: #4db2ff;
    border: 1.5px solid #4db2ff;
    border-radius: 20px;
    padding: 6px 16px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.wallet-connect-btn:hover {
    background: rgba(77, 178, 255, 0.1);
}

.wallet-address {
    background: rgba(36, 139, 218, 0.1);
    color: #4db2ff;
    border: 1.5px solid #4db2ff;
    border-radius: 20px;
    padding: 6px 12px;
    font-size: 12px;
    font-family: 'Courier New', monospace;
    font-weight: 600;
}

/* Deal Section - ИСПРАВЛЕННАЯ ВЕРСИЯ */
.deal-section {
    margin-bottom: 20px;
}

.section-title {
    font-size: 15px;
    font-weight: 600;
    color: #ffffff;
    margin-bottom: 11px;
    text-align: left;
}

.deal-table {
    background: rgb(33, 42, 51);
    border-radius: 10px;
    border: 1px solid rgb(40, 46, 52);
    overflow: hidden;
    width: 100%;
}

.deal-row {
    display: flex;
}

.deal-cell {
    flex: 1;
    padding: 11px;
    text-align: center;
    border-right: 1px solid rgb(40, 46, 52);
}

.deal-cell:last-child {
    border-right: none;
}

.deal-header .deal-cell {
    background: #293440;
    color: #888;
    font-size: 13px;
    font-weight: 500;
    border-bottom: 1px solid rgb(33, 42, 51);
}

.deal-values .deal-cell {
    background: rgb(33, 42, 51);
    padding: 15px 11px;
}

.deal-ton {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 700;
    color: #ffffff;
    margin-bottom: 3px;
}

.deal-usd {
    font-size: 13px;
    color: #666;
}

/* TON Icon */
.ton-icon {
    width: 19px;
    height: 24px;
    display: inline-block;
    vertical-align: middle;
    margin-right: 6px;
}

/* User Section */
.user-section {
    background: rgb(33, 42, 51);
    border-radius: 10px;
    border: 1px solid rgb(40, 46, 52);
    overflow: hidden;
    margin-bottom: 17px;
}

.user-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    border-bottom: 1px solid rgb(40, 46, 52);
    min-height: 44px;
}

.user-item:last-child {
    border-bottom: none;
}

.user-label {
    font-size: 14px;
    color: #ffffff;
    font-weight: 500;
}

.user-value {
    font-size: 13px;
    color: #888;
    font-family: 'Courier New', monospace;
    text-align: right;
    max-width: 60%;
    word-break: break-all;
}

/* Action Buttons */
.action-section {
    margin-bottom: 17px;
}

.btn-primary {
    width: 100%;
    padding: 11px;
    background: rgb(36, 139, 218);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 7px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.btn-primary:hover {
    background: rgb(28, 110, 173);
}

.btn-secondary {
    width: 100%;
    padding: 11px;
    background: transparent;
    color: #007bff;
    border: none;
    border-radius: 0;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: color 0.2s;
}

.btn-secondary:hover {
    color: #0056b3;
}

/* KYC Notice */
.kyc-notice {
    background: rgb(36, 139, 218);
    padding: 11px;
    border-radius: 10px;
    margin-bottom: 20px;
    border: 1px solid rgb(40, 46, 52);
}

.kyc-notice p {
    color: #ffffff;
    font-size: 14px;
    line-height: 1.4;
    text-align: center;
}

/* Trade Section */
.trade-section {
    margin-bottom: 20px;
}

.trade-table {
    width: 100%;
    border-collapse: collapse;
    background: rgb(33, 42, 51);
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid rgb(40, 46, 52);
}

.trade-table th {
    background: #293440;
    color: #888;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    padding: 10px 13px;
    text-align: left;
    border-bottom: 1px solid rgb(40, 46, 52);
    white-space: nowrap;
}

.trade-table td {
    padding: 10px 13px;
    color: #ffffff;
    font-size: 14px;
    border-bottom: 1px solid rgb(40, 46, 52);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.trade-table tr:last-child td {
    border-bottom: none;
}

.status-ready {
    color: #00c853;
    font-weight: 600;
}

.recipient {
    font-family: 'Courier New', monospace;
    color: #888;
    font-size: 12px;
}

/* Footer */
footer {
    background: #0000006a;
    width: 100%;
    padding: 14px 0;
    margin-top: auto;
}

.footer-content {
    max-width: 520px;
    margin: 0 auto;
    padding: 0 20px;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 18px;
    flex-wrap: wrap;
}

.footer-links a {
    color: #666;
    text-decoration: none;
    font-size: 13px;
    transition: color 0.2s;
}

.footer-links a:hover {
    color: #888;
}

/* Responsive Design */
@media (max-width: 480px) {
    .container {
        padding: 0 15px;
    }
    
    header .container {
        padding: 0 15px;
    }
    
    .header-text {
        width: 90px;
    }
    
    .wallet-connect-btn {
        padding: 5px 12px;
        font-size: 12px;
    }
    
    .wallet-address {
        padding: 5px 10px;
        font-size: 11px;
    }
}
/* Стили для Telegram Mini App */
@media (max-width: 480px) {
    .container {
        max-width: 100%;
        padding: 0 10px;
    }
    
    /* Фикс для таблицы сделок в мини-апп */
    .deal-table {
        font-size: 14px;
    }
    
    .deal-table th,
    .deal-table td {
        padding: 10px 5px;
    }
    
    .deal-ton {
        font-size: 16px;
        flex-direction: column;
        gap: 2px;
    }
    
    .ton-icon {
        width: 16px;
        height: 20px;
        margin-right: 4px;
    }
    
    .deal-usd {
        font-size: 11px;
    }
    
    /* Фикс для пользовательской секции */
    .user-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
        padding: 10px 12px;
    }
    
    .user-label {
        font-size: 13px;
        margin-right: 0;
    }
    
    .user-value {
        font-size: 12px;
        text-align: left;
        max-width: 100%;
        width: 100%;
    }
    
    /* Фикс для кнопок */
    .btn-primary, .btn-secondary {
        padding: 12px;
        font-size: 15px;
    }
    
    /* Фикс для таблицы торговли */
    .trade-table {
        font-size: 11px;
    }
    
    .trade-table th,
    .trade-table td {
        padding: 8px 4px;
        font-size: 11px;
    }
    
    .recipient {
        font-size: 10px;
    }
    
    /* Фикс для KYC notice */
    .kyc-notice {
        padding: 10px;
        font-size: 12px;
    }
    
    .kyc-notice p {
        font-size: 12px;
        line-height: 1.3;
    }
}

/* Дополнительные фиксы для очень маленьких экранов */
@media (max-width: 360px) {
    .container {
        padding: 0 8px;
    }
    
    .deal-table th,
    .deal-table td {
        padding: 8px 3px;
        font-size: 12px;
    }
    
    .deal-ton {
        font-size: 14px;
    }
    
    .user-item {
        padding: 8px 10px;
    }
    
    .trade-table th,
    .trade-table td {
        padding: 6px 3px;
        font-size: 10px;
    }
}

/* Улучшенная таблица торговли */
.trade-table {
    width: 100%;
    border-collapse: collapse;
    background: rgb(33, 42, 51);
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid rgb(40, 46, 52);
    table-layout: fixed;
}

.trade-table th,
.trade-table td {
    padding: 12px 8px;
    text-align: left;
    border-bottom: 1px solid rgb(40, 46, 52);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.trade-table th {
    background: #293440;
    color: #888;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.trade-table td {
    color: #ffffff;
    font-size: 13px;
}

/* Устанавливаем фиксированные ширины для колонок */
.trade-table th:nth-child(1),
.trade-table td:nth-child(1) {
    width: 25%;
}

.trade-table th:nth-child(2),
.trade-table td:nth-child(2) {
    width: 30%;
}

.trade-table th:nth-child(3),
.trade-table td:nth-child(3) {
    width: 45%;
}

/* Стили только для Telegram Mini App */
body.telegram-mini-app {
    background: #1a2026;
}

body.telegram-mini-app .container {
    padding-bottom: 20px;
}

body.telegram-mini-app .deal-section {
    margin-bottom: 15px;
}

body.telegram-mini-app .user-section {
    margin-bottom: 15px;
}

body.telegram-mini-app .action-section {
    margin-bottom: 15px;
}

body.telegram-mini-app .kyc-notice {
    margin-bottom: 15px;
    font-size: 12px;
}

body.telegram-mini-app .trade-section {
    margin-bottom: 15px;
}
