:root {
    --bg-primary: #0f0f1a;
    --bg-secondary: #1a1a2e;
    --bg-tertiary: #16213e;
    --bg-input: #1e1e35;
    --bg-sidebar: #1a1a2e;
    --bg-sidebar-hover: #252542;
    --bg-sidebar-active: #4a9eff;
    --text-primary: #e8e8f0;
    --text-secondary: #a0a0b8;
    --text-muted: #6c6c8a;
    --border-color: #2a2a45;
    --accent-blue: #4a9eff;
    --accent-green: #22c55e;
    --accent-red: #ef4444;
    --accent-yellow: #eab308;
    --accent-purple: #a855f7;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.4);
}

body.light-mode {
    --bg-primary: #f5f7fa;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f0f2f5;
    --bg-input: #ffffff;
    --bg-sidebar: #1f2937;
    --bg-sidebar-hover: #374151;
    --bg-sidebar-active: #3b82f6;
    --text-primary: #1a1a2e;
    --text-secondary: #4b5563;
    --text-muted: #9ca3af;
    --border-color: #e5e7eb;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.1);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.6;
    overflow: hidden;
}

.hidden {
    display: none !important;
}

.layout {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

.sidebar {
    width: 220px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 20px 16px;
    border-bottom: 1px solid var(--border-color);
}

.logo {
    font-size: 18px;
    font-weight: 600;
    color: var(--accent-blue);
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo-sub {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
    margin-left: 4px;
}

.sidebar-menu {
    flex: 1;
    padding: 12px 8px;
    overflow-y: auto;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    margin-bottom: 4px;
    border-radius: 6px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s;
    font-size: 14px;
}

.menu-item:hover {
    background: var(--bg-sidebar-hover);
    color: var(--text-primary);
}

.menu-item.active {
    background: var(--accent-blue);
    color: white;
}

.menu-icon {
    font-size: 16px;
    width: 20px;
    text-align: center;
}

.menu-text {
    flex: 1;
}

.menu-group {
    margin-bottom: 4px;
}

.menu-group-title {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: 6px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s;
    font-size: 14px;
    font-weight: 500;
}

.menu-group-title:hover {
    background: var(--bg-sidebar-hover);
    color: var(--text-primary);
}

.menu-arrow {
    font-size: 10px;
    color: var(--text-muted);
    transition: transform 0.2s;
}

.menu-group-items {
    margin-top: 2px;
}

.menu-sub-item {
    padding-left: 46px !important;
    font-size: 13px !important;
}

.menu-add-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 14px 8px 46px;
    margin-top: 4px;
    border-radius: 6px;
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.2s;
    font-size: 13px;
    border: 1px dashed transparent;
}

.menu-add-item:hover {
    color: var(--accent-blue);
    border-color: var(--accent-blue);
    background: rgba(74, 158, 255, 0.05);
}

.menu-item-wrap {
    position: relative;
}

.menu-item-actions {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    display: none;
    gap: 2px;
}

.menu-item-wrap:hover .menu-item-actions {
    display: flex;
}

.menu-item-action {
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--bg-sidebar-hover);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 12px;
    line-height: 1;
}

.menu-item-action:hover {
    background: var(--accent-blue);
    color: white;
}

.sidebar-bottom-actions {
    padding: 8px 8px 0 8px;
    border-top: 1px solid var(--border-color);
}

.sidebar-bottom-actions .menu-add-item {
    margin-top: 0;
    margin-bottom: 4px;
    padding-left: 14px;
    padding-right: 14px;
}

.menu-add-function {
    padding-left: 46px !important;
    font-size: 13px !important;
    opacity: 0.7;
}

.menu-add-function:hover {
    opacity: 1;
}

.function-library-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.function-library-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: all 0.2s;
}

.function-library-item:hover {
    border-color: var(--accent-blue);
    background: rgba(74, 158, 255, 0.05);
}

.function-library-item .func-icon {
    font-size: 24px;
    width: 40px;
    text-align: center;
}

.function-library-item .func-info {
    flex: 1;
}

.function-library-item .func-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.function-library-item .func-desc {
    font-size: 12px;
    color: var(--text-secondary);
}

.function-library-item .func-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.function-library-item .func-action-edit {
    font-size: 14px;
    cursor: pointer;
    padding: 4px;
    opacity: 0.6;
}

.function-library-item:hover .func-action-edit {
    opacity: 1;
}

.function-library-item .func-action-add {
    padding: 6px 14px;
    border-radius: 6px;
    background: var(--accent-blue);
    color: white;
    font-size: 13px;
    font-weight: 500;
}

.function-library-item:hover .func-action-add {
    background: var(--accent-blue-hover);
}

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.footer-status {
    text-align: center;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-primary);
}

.top-header {
    height: 56px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    flex-shrink: 0;
}

.breadcrumb {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-primary);
}

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

.content-area {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.module-panel {
    height: 100%;
}

.panel-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.table-container {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table thead {
    background: var(--bg-tertiary);
}

.data-table th {
    padding: 12px 14px;
    text-align: left;
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 13px;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.data-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

.data-table tbody tr:hover {
    background: var(--bg-tertiary);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.name-cell {
    font-weight: 500;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.url-cell {
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 12px;
    color: var(--text-secondary);
}

.method-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    font-family: 'Consolas', monospace;
}

.method-get {
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
}

.method-post {
    background: rgba(74, 158, 255, 0.15);
    color: #4a9eff;
}

.method-put {
    background: rgba(234, 179, 8, 0.15);
    color: #eab308;
}

.method-delete {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.method-patch {
    background: rgba(168, 85, 247, 0.15);
    color: #a855f7;
}

.method-head {
    background: rgba(107, 114, 128, 0.15);
    color: #6b7280;
}

.method-options {
    background: rgba(236, 72, 153, 0.15);
    color: #ec4899;
}

.status-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.status-success {
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
}

.status-failed {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.status-running {
    background: rgba(74, 158, 255, 0.15);
    color: #4a9eff;
    animation: pulse-badge 1.5s infinite;
}

.status-pending {
    background: rgba(234, 179, 8, 0.15);
    color: #eab308;
}

.status-default {
    background: rgba(107, 114, 128, 0.15);
    color: #6b7280;
}

@keyframes pulse-badge {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.server-status {
    font-size: 13px;
    padding: 4px 12px;
    border-radius: 12px;
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
    font-weight: 500;
}

.server-status.status-running {
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
}

.server-status.status-stopped {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.server-status.status-restarting {
    background: rgba(234, 179, 8, 0.15);
    color: #eab308;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.action-buttons {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.action-btn {
    padding: 4px 10px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.action-btn:hover {
    border-color: var(--accent-blue);
    color: var(--accent-blue);
}

.action-btn.action-execute {
    border-color: rgba(34, 197, 94, 0.3);
    color: #22c55e;
}

.action-btn.action-execute:hover {
    background: rgba(34, 197, 94, 0.1);
    border-color: #22c55e;
}

.action-btn.action-stop {
    border-color: rgba(239, 68, 68, 0.3);
    color: #ef4444;
}

.action-btn.action-stop:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: #ef4444;
}

.action-btn.action-history {
    border-color: rgba(168, 85, 247, 0.3);
    color: #a855f7;
}

.action-btn.action-history:hover {
    background: rgba(168, 85, 247, 0.1);
    border-color: #a855f7;
}

.action-btn.action-edit {
    border-color: rgba(74, 158, 255, 0.3);
    color: #4a9eff;
}

.action-btn.action-edit:hover {
    background: rgba(74, 158, 255, 0.1);
    border-color: #4a9eff;
}

.action-btn.action-delete {
    border-color: rgba(239, 68, 68, 0.3);
    color: #ef4444;
}

.action-btn.action-delete:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: #ef4444;
}

.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.btn-sm {
    padding: 6px 14px;
    font-size: 13px;
}

.btn-full {
    width: 100%;
}

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

.btn-primary:hover {
    background: #3b8ee6;
}

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

.btn-secondary:hover {
    border-color: var(--accent-blue);
    color: var(--accent-blue);
}

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

.btn-danger:hover {
    background: #dc2626;
}

.btn-warning {
    background: var(--accent-yellow);
    color: #1a1a2e;
}

.btn-warning:hover {
    background: #facc15;
}

.theme-toggle-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
    width: 100%;
    text-align: left;
}

.theme-toggle-btn:hover {
    border-color: var(--accent-blue);
    color: var(--accent-blue);
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    width: 90%;
    max-width: 560px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
}

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

.modal-small {
    max-width: 420px;
}

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

.modal-header h2 {
    font-size: 16px;
    font-weight: 600;
}

.close-btn {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1;
    padding: 0 4px;
    transition: color 0.2s;
}

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

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

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

.form-label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

.form-label-row label {
    margin-bottom: 0;
}

.form-tip {
    padding: 10px 12px;
    background: rgba(74, 158, 255, 0.1);
    border: 1px solid rgba(74, 158, 255, 0.2);
    border-radius: 6px;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.btn-link {
    background: none;
    border: none;
    color: var(--accent-blue);
    cursor: pointer;
    font-size: 13px;
    padding: 0;
}

.btn-link:hover {
    text-decoration: underline;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
}

.required {
    color: var(--accent-red);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-secondary);
    user-select: none;
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.checkbox-label span {
    color: var(--text-primary);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    background: var(--bg-input);
    color: var(--text-primary);
    outline: none;
    transition: all 0.2s;
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(74, 158, 255, 0.15);
}

.form-group textarea {
    resize: vertical;
    min-height: 60px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 13px;
}

.form-row {
    display: flex;
    gap: 14px;
}

.cos-body-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 8px;
}

.cos-body-tab {
    flex: 1;
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
}

.cos-body-tab:hover {
    border-color: var(--accent-blue);
    color: var(--accent-blue);
}

.cos-body-tab.active {
    background: var(--accent-blue);
    color: white;
    border-color: var(--accent-blue);
}

.cos-file-info {
    font-size: 12px;
    color: var(--text-muted);
}

.execute-info {
    padding: 16px;
    background: var(--bg-sidebar-hover);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

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

.empty-icon {
    font-size: 40px;
    margin-bottom: 12px;
}

.empty-state p {
    font-size: 14px;
}

.history-list {
    max-height: 400px;
    overflow-y: auto;
}

.history-item {
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.history-item:hover {
    border-color: var(--accent-blue);
    background: var(--bg-tertiary);
}

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

.history-time {
    font-size: 12px;
    color: var(--text-muted);
}

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

.history-status-code {
    font-family: 'Consolas', monospace;
    font-size: 12px;
    color: var(--text-secondary);
    background: var(--bg-tertiary);
    padding: 2px 8px;
    border-radius: 4px;
}

.history-duration {
    font-size: 12px;
    color: var(--text-muted);
}

.history-arrow {
    color: var(--text-muted);
}

.result-summary {
    padding: 14px;
    background: var(--bg-tertiary);
    border-radius: 6px;
    margin-bottom: 16px;
}

.summary-row {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
    gap: 8px;
}

.summary-row:last-child {
    margin-bottom: 0;
}

.summary-label {
    color: var(--text-muted);
    font-size: 13px;
    min-width: 70px;
}

.result-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 14px;
    border-bottom: 1px solid var(--border-color);
}

.tab-btn {
    padding: 8px 16px;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 13px;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: all 0.2s;
}

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

.tab-btn.active {
    color: var(--accent-blue);
    border-bottom-color: var(--accent-blue);
}

.result-content {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 14px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 13px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 400px;
    overflow-y: auto;
    color: var(--text-secondary);
}

.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column-reverse;
    gap: 10px;
}

.toast {
    padding: 12px 20px;
    border-radius: 6px;
    color: white;
    font-size: 14px;
    box-shadow: var(--shadow-lg);
    transform: translateX(120%);
    transition: transform 0.3s ease;
    min-width: 200px;
}

.toast.show {
    transform: translateX(0);
}

.toast-success {
    background: #22c55e;
}

.toast-error {
    background: #ef4444;
}

.toast-info {
    background: var(--accent-blue);
}

::-webkit-scrollbar {
    width: 8px;
    height: 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);
}

.sidebar-menu::-webkit-scrollbar {
    width: 4px;
}

.sidebar-menu::-webkit-scrollbar-thumb {
    border-radius: 2px;
}

.library-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.library-card {
    padding: 20px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-tertiary);
    transition: all 0.2s;
}

.library-card:hover {
    border-color: var(--accent-blue);
    background: rgba(74, 158, 255, 0.05);
}

.library-card-icon {
    font-size: 32px;
    margin-bottom: 12px;
}

.library-card-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.library-card-desc {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 12px;
    line-height: 1.5;
}

.library-card-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.library-card-action {
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.library-card-action-edit {
    background: var(--bg-input);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.library-card-action-edit:hover {
    border-color: var(--accent-blue);
    color: var(--accent-blue);
}

.library-card-action-add {
    background: var(--accent-blue);
    color: white;
    border: none;
}

.library-card-action-add:hover {
    background: #3b8ee6;
}

.proxy-request-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.request-item {
    padding: 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: default;
    transition: all 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-tertiary);
}

.request-item:hover {
    border-color: var(--accent-blue);
    background: rgba(74, 158, 255, 0.05);
}

.request-info {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

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

.request-meta {
    display: flex;
    gap: 16px;
    font-size: 12px;
    color: var(--text-secondary);
    flex-wrap: wrap;
}

.request-meta span {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.request-status {
    margin-right: 16px;
}

.request-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
