body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 20px;
    background-color: #f4f4f4;
    color: #333;
}

.page {
    position: relative; /* 确保子元素的绝对定位是相对于此元素 */
    max-width: 1200px;
    margin: 0 auto;
    background-color: #fff;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.hidden {
    display: none;
}

#user-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fill, 180px); /* 每行最多5个按钮，每个按钮固定宽度180px */
    gap: 15px;
    margin-top: 30px;
    max-width: 960px; /* 5个按钮 * 180px (最小宽度) + 4个间距 * 15px */
    margin-left: auto;
    margin-right: auto;
    justify-content: center; /* 按钮不足一行时居中 */
}

#user-buttons button {
    width: 100%; /* Make buttons take full width of their grid cell */
    padding: 12px 0; /* Adjust padding for vertical centering */
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 18px;
    transition: background-color 0.3s ease;
    text-align: center;
}

#user-buttons button:hover {
    background-color: #0056b3;
}

.header {
    text-align: center;
    margin-bottom: 40px;
    padding-bottom: 20px;
    border-bottom: 1px solid #eee;
}

.header h1 {
    color: #007bff;
    margin-bottom: 10px;
}

.header p {
    font-size: 1.1em;
    color: #666;
}

.card-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 25px;
}

.card {
    background-color: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
}

.card h2 {
    margin-top: 0;
    color: #333;
    font-size: 1.4em;
    margin-bottom: 10px;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
}

.instance-id {
    color: #888; /* 不明显的灰色 */
    font-size: 0.9em;
}

.back-button {
    position: absolute; /* 绝对定位 */
    top: 20px; /* 距离顶部20px */
    left: 20px; /* 距离左侧20px */
    background-color: #6c757d; /* 灰色背景 */
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9em;
    z-index: 10; /* 确保按钮在其他内容之上 */
    transition: background-color 0.3s ease;
}

.back-button:hover {
    background-color: #5a6268;
}

#version-info {
    position: fixed;
    bottom: 10px;
    right: 10px;
    font-size: 0.8em;
    color: #999;
}

.card-content {
    flex-grow: 1;
}

.country-options {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-top: 15px;
    margin-bottom: 20px;
}

.country-option {
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    text-align: center;
    cursor: pointer;
    background-color: #e9e9e9;
    transition: all 0.2s ease;
    font-size: 0.9em;
}

.country-option.selected {
    background-color: #28a745;
    color: white;
    border-color: #28a745;
}

.country-option:hover:not(.selected) {
    background-color: #dcdcdc;
}

.send-section {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: auto; /* Pushes the section to the bottom of the card */
    padding-top: 15px;
    border-top: 1px solid #eee;
}

.send-button {
    padding: 10px 20px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1em;
    transition: background-color 0.3s ease;
}

.send-button:hover {
    background-color: #0056b3;
}

.send-button.disabled {
    background-color: #cccccc;
    cursor: not-allowed;
}

.status-message {
    margin-left: 15px;
    font-weight: bold;
    display: flex;
    align-items: center;
    color: #555;
    min-width: 150px; /* Ensure space for messages */
}

.status-message.success {
    color: #28a745;
}

.status-message.failed {
    color: #dc3545;
}

.spinner {
    border: 4px solid rgba(0, 0, 0, 0.1);
    border-left-color: #007bff;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    animation: spin 1s linear infinite;
    display: inline-block;
    margin-right: 8px;
    vertical-align: middle;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .card-container {
        grid-template-columns: 1fr;
    }
    .page {
        padding: 20px;
    }
    .country-options {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .country-options {
        grid-template-columns: 1fr;
    }
    #user-buttons {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    }
}
