:root {
    --bg-primary: #0b0f19;
    --bg-card: rgba(17, 24, 39, 0.7);
    --border-color: rgba(255, 255, 255, 0.08);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --accent-color: #8b5cf6;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --loading-color: #64748b;
    --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    --card-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-sans);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* Glowing background */
.glow-bg {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(59, 130, 246, 0.08) 0%, rgba(139, 92, 246, 0.04) 50%, rgba(0, 0, 0, 0) 100%);
    z-index: -1;
    pointer-events: none;
    filter: blur(40px);
}

.app-container {
    max-width: 680px;
    margin: 0 auto;
    padding: 16px;
    padding-bottom: 40px;
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    margin-bottom: 24px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--accent-color) 100%);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 20px;
    color: white;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
}

.brand-text h1 {
    font-size: 20px;
    font-weight: 600;
    line-height: 1.2;
}

.brand-text .subtitle {
    font-size: 12px;
    color: var(--text-secondary);
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    color: var(--text-secondary);
}

.status-dot {
    width: 8px;
    height: 8px;
    background-color: var(--success-color);
    border-radius: 50%;
}

.status-dot.pulsing {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    animation: pulse 1.8s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    }
    70% {
        transform: scale(1);
        box-shadow: 0 0 0 6px rgba(16, 185, 129, 0);
    }
    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    }
}

/* Tabs Navigation */
.app-tabs {
    display: flex;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 4px;
    margin-bottom: 24px;
}

.tab-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 10px;
    font-size: 14px;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.25s ease;
}

.tab-btn svg {
    transition: transform 0.2s ease;
}

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

.tab-btn:hover svg {
    transform: scale(1.1);
}

.tab-btn.active {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Tab panes */
.tab-pane {
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.tab-pane.active {
    display: block;
    opacity: 1;
}

/* Cards */
.section-card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 24px;
    box-shadow: var(--card-shadow);
}

.section-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-primary);
    border-left: 3px solid var(--primary-color);
    padding-left: 10px;
}

/* Metrics Grid */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.metric-card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 16px;
    box-shadow: var(--card-shadow);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 100px;
}

.metric-info {
    display: flex;
    flex-direction: column;
}

.metric-title {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.metric-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
}

.progress-bar-container {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 8px;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color) 0%, var(--accent-color) 100%);
    border-radius: 3px;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Services list */
.services-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.service-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 12px;
    transition: transform 0.2s ease, background-color 0.2s ease;
    flex-wrap: wrap;
    gap: 12px;
}

.service-item:hover {
    background: rgba(255, 255, 255, 0.04);
    transform: translateX(2px);
}

.service-details {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
}

.service-name {
    font-size: 14px;
    font-weight: 500;
}

.service-desc {
    font-size: 11px;
    color: var(--text-secondary);
}

.service-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.status-badge {
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.status-badge.active {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success-color);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.status-badge.inactive {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger-color);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.status-badge.warning {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning-color);
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.status-badge.cooldown {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger-color);
    border: 1px solid rgba(239, 68, 68, 0.25);
}

.status-badge.loading {
    background: rgba(100, 116, 139, 0.1);
    color: var(--loading-color);
    border: 1px solid rgba(100, 116, 139, 0.2);
}

/* Inputs and Buttons */
.premium-btn {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.premium-btn:hover {
    background: rgba(255, 255, 255, 0.09);
    border-color: rgba(255, 255, 255, 0.15);
}

.premium-btn.primary {
    background: var(--primary-color);
    border-color: transparent;
    color: white;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
}

.premium-btn.primary:hover {
    background: var(--primary-hover);
    box-shadow: 0 6px 16px rgba(59, 130, 246, 0.3);
}

.premium-btn.danger {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.2);
    color: #ff6b6b;
}

.premium-btn.danger:hover {
    background: rgba(239, 68, 68, 0.25);
}

.premium-btn.compact {
    padding: 6px 10px;
    font-size: 11px;
    border-radius: 6px;
}

.premium-btn.block {
    display: flex;
    width: 100%;
}

.premium-input {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 10px 14px;
    font-size: 13px;
    border-radius: 8px;
    outline: none;
    transition: all 0.2s ease;
    width: 100%;
}

.premium-input:focus {
    border-color: var(--primary-color);
    background: rgba(255, 255, 255, 0.06);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* Integrations grid */
.integrations-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.integration-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 12px;
    flex-wrap: wrap;
    gap: 12px;
}

.integration-title {
    font-size: 14px;
    font-weight: 500;
}

.integration-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
}

.integration-status-text {
    font-size: 11px;
    color: var(--text-secondary);
}

/* Model selection */
.model-selection-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.model-selection-wrapper label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
}

.select-container {
    position: relative;
    display: inline-block;
}

.premium-select {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 8px 32px 8px 12px;
    font-size: 13px;
    border-radius: 8px;
    outline: none;
    cursor: pointer;
    appearance: none;
    transition: all 0.2s ease;
}

.premium-select:focus {
    border-color: var(--primary-color);
}

.select-container::after {
    content: "▾";
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: var(--text-secondary);
    font-size: 12px;
}

/* Keys Table */
.keys-table-container {
    overflow-x: auto;
    margin-bottom: 24px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.keys-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    text-align: left;
}

.keys-table th {
    background: rgba(255, 255, 255, 0.03);
    padding: 10px 12px;
    font-weight: 500;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
}

.keys-table td {
    padding: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

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

.key-mono {
    font-family: var(--font-mono);
    font-size: 12px;
    color: #e2e8f0;
}

/* Add key form */
.add-key-form {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 12px;
    padding: 16px;
}

.add-key-form h3 {
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 12px;
    color: var(--text-secondary);
}

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

.form-row .premium-input {
    flex: 2;
}

.form-row .select-container {
    flex: 1;
}

.form-row .premium-select {
    width: 100%;
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(8px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.modal-card {
    background: #1e293b;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    width: 90%;
    max-width: 440px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay.open .modal-card {
    transform: scale(1);
}

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

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

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

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

.modal-body {
    padding: 20px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}

.input-group label {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

.form-info {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.4;
    margin-bottom: 16px;
}

.action-spinner {
    text-align: center;
    padding: 12px;
    color: var(--text-secondary);
    font-size: 13px;
}

.action-status {
    padding: 10px;
    border-radius: 8px;
    font-size: 13px;
    margin-top: 12px;
}

.action-status.success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success-color);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.action-status.error {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger-color);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.hidden {
    display: none !important;
}

/* Verification Modal custom styles */
.text-center {
    text-align: center;
}

.verification-instructions {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 16px;
}

.verification-code {
    font-family: var(--font-mono);
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.03);
    border: 1px dashed rgba(255, 255, 255, 0.15);
    padding: 12px;
    border-radius: 10px;
    margin-bottom: 20px;
    letter-spacing: 2px;
}

.verification-subtext {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 12px;
}

.loading-bar-animation {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.05);
    margin-top: 16px;
    position: relative;
    overflow: hidden;
    border-radius: 2px;
}

.loading-bar-animation::before {
    content: "";
    position: absolute;
    height: 100%;
    width: 40%;
    background: var(--primary-color);
    animation: loading-bar-move 1.5s infinite linear;
    border-radius: 2px;
}

@keyframes loading-bar-move {
    0% { left: -40%; }
    50% { left: 40%; }
    100% { left: 100%; }
}

.mt-20 {
    margin-top: 20px;
}

/* Loading animations */
.loading-spinner {
    text-align: center;
    padding: 24px;
    color: var(--text-secondary);
    font-size: 13px;
}

/* Responsive grid changes */
@media(max-width: 600px) {
    .metrics-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .metric-card {
        height: 80px;
    }
    
    .form-row {
        flex-direction: column;
    }

    .service-item, .integration-item {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .service-details, .integration-info {
        flex: none;
        width: 100%;
        min-width: 0;
    }

    .service-item .service-actions, .integration-item .service-actions {
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 100%;
    }

    .keys-table th, .keys-table td {
        padding: 6px 4px;
        font-size: 11px;
    }

    .keys-table .premium-select.compact-select {
        padding: 4px 6px;
        font-size: 11px;
    }

    .key-mono {
        font-size: 10px;
    }
}

/* Drag-and-drop key styles */
tr[draggable="true"] {
    transition: transform 0.2s ease, opacity 0.2s ease;
}

tr.dragging {
    opacity: 0.4;
    background: rgba(59, 130, 246, 0.15) !important;
}

.drag-handle {
    user-select: none;
    font-size: 16px;
    cursor: grab;
    touch-action: none;
}

.drag-handle:active {
    cursor: grabbing;
}

.compact-select {
    padding: 4px 10px;
    font-size: 12px;
    border-radius: 6px;
}

