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

:root {
    --primary-color: #f38020;
    --primary-dark: #e06d00;
    --secondary-color: #0051c3;
    --success-color: #16a34a;
    --danger-color: #dc2626;
    --warning-color: #d97706;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --border-radius: 8px;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    min-height: 100vh;
    color: var(--gray-900);
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

header {
    text-align: center;
    margin-bottom: 30px;
}

header h1 {
    color: white;
    font-size: 2.5rem;
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
    margin-bottom: 8px;
}

.subtitle {
    color: rgba(255, 255, 255, 0.9);
    font-size: 1.1rem;
    font-weight: 400;
}

.card {
    background: white;
    border-radius: 12px;
    padding: 25px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--gray-200);
}

.card.warning {
    border-left: 4px solid var(--warning-color);
    background: #fef3c7;
}

.cors-notice {
    margin-bottom: 20px;
}

.cors-notice h3 {
    color: var(--warning-color);
    margin-bottom: 12px;
}

.cors-notice ul {
    margin: 12px 0;
    padding-left: 20px;
}

.cors-notice li {
    margin-bottom: 8px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.section-header h2 {
    color: var(--gray-800);
    font-weight: 600;
    font-size: 1.5rem;
}

.header-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--gray-700);
}

.input-with-help input {
    width: 100%;
}

.help-text {
    font-size: 0.875rem;
    color: var(--gray-500);
    margin-top: 6px;
}

.help-text a {
    color: var(--secondary-color);
    text-decoration: none;
}

.help-text a:hover {
    text-decoration: underline;
}

.form-group input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--gray-300);
    border-radius: var(--border-radius);
    font-size: 14px;
    transition: all 0.2s ease;
    background: white;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(243, 128, 32, 0.1);
}

.form-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: var(--border-radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    white-space: nowrap;
}

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

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

.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

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

.btn-success:hover:not(:disabled) {
    background: #15803d;
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

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

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

.btn-secondary {
    background: var(--gray-500);
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background: var(--gray-600);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.btn-small {
    padding: 8px 16px;
    font-size: 12px;
}

.link-btn {
    background: none;
    border: none;
    color: var(--secondary-color);
    cursor: pointer;
    text-decoration: underline;
    font-size: inherit;
    padding: 0;
}

.link-btn:hover {
    color: var(--primary-color);
}

.status {
    margin-top: 15px;
    padding: 12px 16px;
    border-radius: var(--border-radius);
    font-size: 14px;
    font-weight: 500;
}

.status.success {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.status.error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.status.info {
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

.tunnel-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 20px;
    margin-bottom: 25px;
    padding: 20px;
    background: var(--gray-50);
    border-radius: var(--border-radius);
}

.stat-item {
    text-align: center;
}

.stat-number {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 4px;
}

.stat-label {
    font-size: 0.875rem;
    color: var(--gray-600);
    font-weight: 500;
}

.tunnel-list {
    min-height: 200px;
}

.tunnel-item {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius);
    padding: 20px;
    margin-bottom: 15px;
    transition: all 0.2s ease;
}

.tunnel-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
    border-color: var(--gray-300);
}

.tunnel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 10px;
}

.tunnel-name {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--gray-800);
}

.tunnel-status {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.tunnel-status.active {
    background: #dcfce7;
    color: #166534;
}

.tunnel-status.inactive {
    background: #fef2f2;
    color: #991b1b;
}

.tunnel-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.tunnel-info-item {
    display: flex;
    flex-direction: column;
}

.tunnel-info-label {
    font-size: 0.75rem;
    color: var(--gray-500);
    margin-bottom: 4px;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.05em;
}

.tunnel-info-value {
    font-size: 0.875rem;
    color: var(--gray-800);
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
    word-break: break-all;
}

.tunnel-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.loading {
    text-align: center;
    padding: 60px 20px;
    color: var(--gray-500);
    font-style: italic;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--gray-500);
}

.empty-state h3 {
    margin-bottom: 12px;
    color: var(--gray-700);
    font-size: 1.25rem;
}

.empty-state p {
    font-size: 0.875rem;
}

/* 模态框样式 */
.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(5px);
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    animation: modalSlideIn 0.3s ease;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-content.large {
    max-width: 800px;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    padding: 20px 25px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    color: var(--gray-800);
    font-size: 1.25rem;
    font-weight: 600;
}

.close {
    color: var(--gray-400);
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.close:hover {
    color: var(--gray-600);
    background: var(--gray-100);
}

.modal-body {
    padding: 25px;
}

.modal-footer {
    padding: 20px 25px;
    border-top: 1px solid var(--gray-200);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    flex-wrap: wrap;
}

.token-display {
    display: flex;
    gap: 10px;
    align-items: center;
}

.token-display input {
    flex: 1;
    min-width: 0;
}

.readonly-field {
    padding: 12px 16px;
    background: var(--gray-50);
    border: 2px solid var(--gray-200);
    border-radius: var(--border-radius);
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
    font-size: 0.875rem;
    color: var(--gray-700);
    word-break: break-all;
}

.help-content {
    line-height: 1.7;
}

.help-content h4 {
    color: var(--gray-800);
    margin: 20px 0 10px 0;
    font-size: 1.1rem;
}

.help-content h4:first-child {
    margin-top: 0;
}

.help-content ul {
    margin: 10px 0;
    padding-left: 20px;
}

.help-content li {
    margin-bottom: 6px;
}

.help-content pre {
    background: var(--gray-100);
    padding: 12px;
    border-radius: var(--border-radius);
    overflow-x: auto;
    font-size: 0.875rem;
    margin: 10px 0;
}

.help-content code {
    background: var(--gray-100);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.875rem;
}

.help-content a {
    color: var(--secondary-color);
    text-decoration: none;
}

.help-content a:hover {
    text-decoration: underline;
}

/* 页脚 */
footer {
    margin-top: auto;
    padding: 30px 0 20px;
    text-align: center;
}

.footer-content {
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.875rem;
}

.footer-links {
    margin-top: 10px;
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
}

.footer-links a,
.footer-links .link-btn {
    color: rgba(255, 255, 255, 0.9);
    text-decoration: none;
    font-size: 0.875rem;
}

.footer-links a:hover,
.footer-links .link-btn:hover {
    color: white;
    text-decoration: underline;
}

/* 连接详情样式 */
.connections-list {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius);
    padding: 15px;
    background: var(--gray-50);
}

.connection-item {
    padding: 12px;
    margin-bottom: 12px;
    background: white;
    border-radius: var(--border-radius);
    font-size: 0.875rem;
    line-height: 1.5;
    border: 1px solid var(--gray-200);
}

.connection-item:last-child {
    margin-bottom: 0;
}

.tunnel-details .form-group {
    margin-bottom: 20px;
}

.tunnel-details label {
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 8px;
    display: block;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .subtitle {
        font-size: 1rem;
    }
    
    .card {
        padding: 20px;
    }
    
    .section-header {
        flex-direction: column;
        align-items: stretch;
    }
    
    .header-actions {
        justify-content: center;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .tunnel-actions {
        justify-content: center;
    }
    
    .modal-content {
        margin: 10% auto;
        width: 95%;
    }
    
    .tunnel-info {
        grid-template-columns: 1fr;
    }
    
    .tunnel-stats {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
        gap: 15px;
        padding: 15px;
    }
    
    .stat-number {
        font-size: 1.5rem;
    }
    
    .modal-footer {
        flex-direction: column-reverse;
    }
    
    .token-display {
        flex-direction: column;
        align-items: stretch;
    }
    
    .footer-links {
        flex-direction: column;
        gap: 10px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 10px;
    }
    
    header h1 {
        font-size: 1.75rem;
    }
    
    .card {
        padding: 15px;
    }
    
    .tunnel-item {
        padding: 15px;
    }
    
    .tunnel-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .modal-body,
    .modal-header,
    .modal-footer {
        padding: 20px;
    }
}

/* 动画效果 */
.fade-in {
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.slide-up {
    animation: slideUp 0.3s ease;
}

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

/* 滚动条样式 */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--gray-100);
    border-radius: 4px;
}

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

::-webkit-scrollbar-thumb:hover {
    background: var(--gray-400);
}