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

:root {
    --bg-color: var(--tg-theme-bg-color, #ffffff);
    --text-color: var(--tg-theme-text-color, #000000);
    --hint-color: var(--tg-theme-hint-color, #999999);
    --link-color: var(--tg-theme-link-color, #2481cc);
    --button-color: var(--tg-theme-button-color, #2481cc);
    --button-text: var(--tg-theme-button-text-color, #ffffff);
    --secondary-bg: var(--tg-theme-secondary-bg-color, #f0f0f0);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-color);
    color: var(--text-color);
    min-height: 100vh;
    padding-bottom: 20px;
}

#app {
    max-width: 500px;
    margin: 0 auto;
}

/* Header - moved to bottom with logo styles */

.header-balance {
    font-size: 18px;
    font-weight: 600;
    text-align: center;
}

.balance-label {
    color: var(--hint-color);
    margin-right: 8px;
}

/* Screens */
.screen {
    display: none;
    padding: 0 16px;
    animation: fadeIn 0.2s ease;
}

.screen.active {
    display: block;
}

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

.screen-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.screen-header h2 {
    font-size: 20px;
    flex: 1;
}

.back-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: var(--secondary-bg);
    border-radius: 12px;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Menu Grid */
.menu-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    padding: 16px 0;
}

.menu-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 24px 16px;
    background: var(--secondary-bg);
    border: none;
    border-radius: 16px;
    cursor: pointer;
    transition: transform 0.15s, background 0.15s;
}

.menu-btn:active {
    transform: scale(0.97);
    background: var(--hint-color);
}

.menu-btn.full-width {
    grid-column: span 2;
    flex-direction: row;
    padding: 16px 24px;
}

.menu-btn.secondary {
    background: transparent;
    border: 2px solid var(--secondary-bg);
}

.menu-icon {
    font-size: 32px;
}

.menu-text {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-color);
}

/* Search */
.search-box {
    margin-bottom: 16px;
}

.search-box input {
    width: 100%;
    padding: 12px 16px;
    border: none;
    background: var(--secondary-bg);
    border-radius: 12px;
    font-size: 16px;
    color: var(--text-color);
    outline: none;
}

.search-box input::placeholder {
    color: var(--hint-color);
}

/* Items List */
.items-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.list-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--secondary-bg);
    border-radius: 12px;
    cursor: pointer;
    transition: transform 0.15s;
    border: none;
    width: 100%;
    text-align: left;
}

.list-item:active {
    transform: scale(0.98);
}

.list-item-icon {
    font-size: 24px;
    width: 32px;
    text-align: center;
}

.list-item-content {
    flex: 1;
}

.list-item-title {
    font-size: 16px;
    font-weight: 500;
}

.list-item-subtitle {
    font-size: 13px;
    color: var(--hint-color);
    margin-top: 2px;
}

.list-item-badge {
    background: var(--button-color);
    color: var(--button-text);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
}

.list-item-arrow {
    color: var(--hint-color);
    font-size: 18px;
}

/* Selection Summary */
.selection-summary {
    background: var(--secondary-bg);
    padding: 16px;
    border-radius: 12px;
    margin-bottom: 16px;
}

.selection-summary p {
    margin: 4px 0;
    font-size: 14px;
}

.selection-summary strong {
    color: var(--button-color);
}

/* Confirm Details */
.confirm-details {
    background: var(--secondary-bg);
    padding: 20px;
    border-radius: 16px;
    margin-bottom: 20px;
}

.confirm-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid rgba(128,128,128,0.2);
}

.confirm-row:last-child {
    border-bottom: none;
}

.confirm-row.total {
    font-size: 18px;
    font-weight: 600;
    margin-top: 8px;
    padding-top: 16px;
}

.confirm-label {
    color: var(--hint-color);
}

.confirm-value {
    font-weight: 500;
}

.confirm-value.price {
    color: var(--button-color);
}

/* Buy Button */
.buy-btn {
    width: 100%;
    padding: 16px;
    background: var(--button-color);
    color: var(--button-text);
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s;
}

.buy-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.buy-btn:active:not(:disabled) {
    opacity: 0.8;
}

/* Success */
.success-content {
    text-align: center;
    padding: 40px 16px;
}

.success-icon {
    font-size: 64px;
    margin-bottom: 16px;
}

.success-content h2 {
    margin-bottom: 24px;
}

.proxy-details {
    background: var(--secondary-bg);
    padding: 16px;
    border-radius: 12px;
    margin-bottom: 24px;
    text-align: left;
}

.proxy-details .detail-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 14px;
}

.proxy-details .detail-label {
    color: var(--hint-color);
}

.proxy-details code {
    font-family: monospace;
    background: rgba(128,128,128,0.15);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
}

.empty-icon {
    font-size: 64px;
    opacity: 0.5;
}

.empty-state p {
    color: var(--hint-color);
    margin: 16px 0 24px;
}

/* Loading */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Proxy Card */
.proxy-card {
    background: var(--secondary-bg);
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 12px;
}

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

.proxy-card-title {
    font-weight: 600;
    font-size: 16px;
}

.proxy-card-status {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.proxy-card-status.active {
    background: #34c75920;
    color: #34c759;
}

.proxy-card-status.expired {
    background: #ff3b3020;
    color: #ff3b30;
}

.proxy-card-status.refunded {
    background: #ff950020;
    color: #ff9500;
}

.proxy-card-info {
    font-size: 14px;
    color: var(--hint-color);
}

.proxy-card-info code {
    font-family: monospace;
    background: rgba(128,128,128,0.15);
    padding: 2px 6px;
    border-radius: 4px;
}

/* Copy Button */
.copy-btn {
    background: var(--secondary-bg);
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    margin-top: 8px;
}

.copy-btn:active {
    opacity: 0.7;
}

/* Change IP Button */
.change-ip-btn {
    width: 100%;
    padding: 12px;
    margin-top: 16px;
    background: var(--button-color);
    color: var(--button-text);
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
}

.change-ip-btn:disabled {
    opacity: 0.5;
}

/* Header with Logo */
.header {
    padding: 12px 16px;
    background: var(--secondary-bg);
    border-radius: 0 0 16px 16px;
    margin-bottom: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-logo img {
    border-radius: 8px;
}

.header-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-color);
}

/* Hero Section */
.hero-section {
    text-align: center;
    padding: 24px 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 20px;
    margin-bottom: 16px;
    color: #fff;
}

.hero-logo {
    border-radius: 16px;
    margin-bottom: 16px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
}

.hero-title {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 4px;
}

.hero-subtitle {
    font-size: 14px;
    opacity: 0.9;
    margin-bottom: 16px;
}

.hero-badges {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
}

.badge {
    background: rgba(255,255,255,0.2);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    backdrop-filter: blur(10px);
}

/* Primary Button */
.menu-btn.primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
}

.menu-btn.primary .menu-text {
    color: #fff;
}

.menu-btn.primary:active {
    background: linear-gradient(135deg, #5a6fd6 0%, #6a4190 100%);
}

/* Features Section */
.features-section {
    background: var(--secondary-bg);
    border-radius: 16px;
    padding: 20px;
    margin-top: 8px;
}

.features-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    text-align: center;
}

.features-list {
    list-style: none;
}

.features-list li {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    font-size: 14px;
    border-bottom: 1px solid rgba(128,128,128,0.1);
}

.features-list li:last-child {
    border-bottom: none;
}

.feature-icon {
    color: #34c759;
    font-weight: bold;
    font-size: 16px;
}

/* Success Message */
.success-message {
    color: var(--hint-color);
    font-size: 14px;
    margin-bottom: 20px;
}

/* Footer */
.footer {
    text-align: center;
    padding: 24px 16px;
    margin-top: 24px;
    color: var(--hint-color);
    font-size: 12px;
}

/* Responsive adjustments */
@media (max-width: 360px) {
    .hero-title {
        font-size: 20px;
    }
    
    .hero-badges {
        gap: 6px;
    }
    
    .badge {
        font-size: 11px;
        padding: 5px 10px;
    }
}

/* Dark theme enhancements */
@media (prefers-color-scheme: dark) {
    .hero-section {
        background: linear-gradient(135deg, #4a5568 0%, #2d3748 100%);
    }
    
    .badge {
        background: rgba(255,255,255,0.15);
    }
}

/* Copyable elements */
.copyable {
    cursor: pointer;
    transition: background 0.2s;
    border-radius: 6px;
    padding: 6px 8px;
    margin: -6px -8px;
}

.copyable:active {
    background: rgba(128,128,128,0.2);
}

.copy-icon {
    opacity: 0.5;
    font-size: 14px;
    margin-left: 8px;
}

.copyable:hover .copy-icon {
    opacity: 1;
}

.copy-hint {
    text-align: center;
    font-size: 12px;
    color: var(--hint-color);
    margin-top: 12px;
    opacity: 0.7;
}

/* Proxy card improvements */
.proxy-row {
    display: flex;
    align-items: center;
    padding: 4px 0;
    font-size: 13px;
}

.proxy-label {
    color: var(--hint-color);
    min-width: 65px;
    font-size: 12px;
}

.proxy-row code {
    flex: 1;
    font-family: monospace;
    font-size: 12px;
    word-break: break-all;
}

.proxy-card-info {
    font-size: 14px;
    color: var(--hint-color);
}

.proxy-card-info p {
    margin-bottom: 8px;
}

/* Detail row in success screen */
.detail-row {
    display: flex;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid rgba(128,128,128,0.15);
}

.detail-row:last-of-type {
    border-bottom: none;
}

.detail-label {
    color: var(--hint-color);
    min-width: 70px;
    font-size: 13px;
}

.detail-row code {
    flex: 1;
    font-family: monospace;
    font-size: 13px;
    word-break: break-all;
}
/* Proxy PID */
.proxy-pid {
    display: block;
    font-size: 11px;
    color: var(--tg-theme-hint-color, #999);
    font-weight: normal;
    margin-bottom: 2px;
}

/* Proxy card actions */
.proxy-card-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.proxy-card-actions .change-ip-btn,
.proxy-card-actions .extend-btn {
    flex: 1;
    width: auto;
    margin-top: 0;
    padding: 10px 12px;
    font-size: 13px;
}

.extend-btn {
    background: var(--tg-theme-secondary-bg-color, #f5f5f5);
    color: var(--tg-theme-text-color, #333);
    border: none;
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.extend-btn:hover {
    background: var(--tg-theme-button-color, #3390ec);
    color: var(--tg-theme-button-text-color, #fff);
}

/* Extend modal */
.extend-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.extend-modal-content {
    background: var(--tg-theme-bg-color, #fff);
    border-radius: 16px;
    padding: 24px;
    width: 100%;
    max-width: 320px;
    text-align: center;
}

.extend-modal-content h3 {
    margin: 0 0 8px;
    color: var(--tg-theme-text-color, #333);
}

.extend-modal-content p {
    margin: 0 0 16px;
    color: var(--tg-theme-hint-color, #999);
}

.extend-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.extend-option {
    background: var(--tg-theme-button-color, #3390ec);
    color: var(--tg-theme-button-text-color, #fff);
    border: none;
    padding: 14px 20px;
    border-radius: 10px;
    font-size: 15px;
    cursor: pointer;
    transition: all 0.2s;
}

.extend-option:hover {
    opacity: 0.9;
    transform: scale(1.02);
}

.extend-cancel {
    background: transparent;
    color: var(--tg-theme-hint-color, #999);
    border: none;
    padding: 12px 20px;
    font-size: 14px;
    cursor: pointer;
}

/* Equipment button */
.equip-btn {
    background: var(--tg-theme-secondary-bg-color, #f5f5f5);
    color: var(--tg-theme-text-color, #333);
    border: none;
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 44px;
}

.equip-btn:hover {
    background: var(--tg-theme-button-color, #3390ec);
    color: var(--tg-theme-button-text-color, #fff);
}

/* Equipment modal form */
.equip-modal {
    max-width: 340px;
}

.equip-form {
    text-align: left;
    margin-bottom: 16px;
}

.equip-form label {
    display: block;
    font-size: 13px;
    color: var(--tg-theme-hint-color, #999);
    margin-bottom: 4px;
    margin-top: 12px;
}

.equip-form label:first-child {
    margin-top: 0;
}

.equip-form select {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--tg-theme-secondary-bg-color, #ddd);
    border-radius: 10px;
    background: var(--tg-theme-bg-color, #fff);
    color: var(--tg-theme-text-color, #333);
    font-size: 14px;
    appearance: none;
    cursor: pointer;
}

.equip-form select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.equip-submit {
    width: 100%;
    margin-bottom: 8px;
}

/* Refund button */
.refund-btn {
    background: #ffebee;
    color: #c62828;
    border: none;
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 44px;
}

.refund-btn:hover {
    background: #ffcdd2;
}

/* Refund modal info */
.refund-info {
    text-align: left;
    background: var(--tg-theme-secondary-bg-color, #f5f5f5);
    padding: 12px;
    border-radius: 10px;
    margin: 12px 0;
}

.refund-info p {
    margin: 6px 0;
    font-size: 14px;
}

.refund-amount {
    font-size: 16px !important;
    color: var(--tg-theme-button-color, #3390ec);
}

.refund-warning {
    font-size: 12px;
    color: #f57c00;
    margin: 12px 0;
}

.refund-confirm {
    background: #c62828 !important;
    color: #fff !important;
}

.refund-confirm:hover {
    background: #b71c1c !important;
}