:root {
    --bg-dark: #0f172a;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --success-color: #10b981;
    --error-color: #ef4444;
    --warning-color: #f59e0b;
    --accent-gradient: linear-gradient(135deg, #3b82f6, #8b5cf6);
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    display: flex;
    justify-content: center;
    padding: 2rem;
}

/* Dynamic Background Spheres */
.app-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    overflow: hidden;
}

.gradient-sphere {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.5;
    animation: float 20s infinite ease-in-out alternate;
}

.sphere-1 {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(59,130,246,0.8) 0%, rgba(59,130,246,0) 70%);
    top: -100px;
    left: -100px;
    animation-delay: 0s;
}

.sphere-2 {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(139,92,246,0.6) 0%, rgba(139,92,246,0) 70%);
    bottom: -150px;
    right: -100px;
    animation-delay: -5s;
}

.sphere-3 {
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(16,185,129,0.4) 0%, rgba(16,185,129,0) 70%);
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation-delay: -10s;
}

@keyframes float {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(50px, 30px) scale(1.1); }
}

/* Typography & Layout */
.container {
    width: 100%;
    max-width: 900px;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    z-index: 1;
}

.header {
    text-align: left;
    margin-bottom: 2rem;
}

.logo-title {
    font-family: 'Outfit', sans-serif;
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: -0.05em;
    margin-bottom: 0.5rem;
}

.logo-title span {
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* Glass Panels */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    box-shadow: var(--glass-shadow);
    padding: 2rem;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

/* Config Bar */
.config-bar {
    margin-bottom: 2rem;
}

.input-group label {
    display: block;
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.input-group input {
    width: 100%;
    max-width: 300px;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    padding: 0.75rem 1rem;
    border-radius: 12px;
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    transition: all 0.2s ease;
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.3);
}

/* Drop Zone */
.drop-zone {
    border: 2px dashed rgba(255, 255, 255, 0.2);
    border-radius: 16px;
    padding: 3rem 2rem;
    text-align: center;
    background: rgba(15, 23, 42, 0.3);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.drop-zone:hover {
    border-color: rgba(255, 255, 255, 0.4);
    background: rgba(15, 23, 42, 0.5);
}

.drop-zone.active {
    border-color: var(--primary-color);
    background: rgba(59, 130, 246, 0.1);
    transform: scale(1.02);
}

.drop-zone-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    pointer-events: none;
}

.upload-icon {
    color: var(--primary-color);
    background: rgba(59, 130, 246, 0.1);
    padding: 1.5rem;
    border-radius: 50%;
    margin-bottom: 0.5rem;
    transition: transform 0.3s ease;
}

.drop-zone:hover .upload-icon {
    transform: translateY(-5px);
}

.drop-zone h3 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.5rem;
    font-weight: 600;
}

.drop-zone p {
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.hidden-input {
    display: none;
}

.primary-btn {
    background: var(--accent-gradient);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 999px;
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.4);
    pointer-events: auto;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.6);
}

.primary-btn:active {
    transform: translateY(0);
}

/* Upload Progress List */
.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.panel-header h2 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.25rem;
}

.badge {
    background: rgba(255, 255, 255, 0.1);
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 500;
}

.file-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.file-item {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    animation: slideIn 0.3s ease forwards;
}

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

.file-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.file-name {
    font-weight: 500;
    max-width: 60%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-status {
    font-size: 0.85rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.status-pending { color: var(--text-secondary); }
.status-uploading { color: var(--primary-color); }
.status-success { color: var(--success-color); }
.status-error { color: var(--error-color); }

.progress-track {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 999px;
    overflow: hidden;
    position: relative;
}

.progress-bar {
    height: 100%;
    width: 0%;
    background: var(--accent-gradient);
    border-radius: 999px;
    transition: width 0.3s ease;
}

.progress-bar.striped {
    background-image: linear-gradient(
        45deg,
        rgba(255,255,255,0.15) 25%,
        transparent 25%,
        transparent 50%,
        rgba(255,255,255,0.15) 50%,
        rgba(255,255,255,0.15) 75%,
        transparent 75%,
        transparent
    );
    background-size: 1rem 1rem;
    animation: stripemove 1s linear infinite;
}

@keyframes stripemove {
    0% { background-position: 1rem 0; }
    100% { background-position: 0 0; }
}

/* R2 Details Pill */
.r2-details {
    margin-top: 0.5rem;
    font-size: 0.8rem;
    background: rgba(16, 185, 129, 0.1);
    color: var(--success-color);
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    word-break: break-all;
    font-family: monospace;
}

/* Tabs */
.tabs-container {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 1rem;
}

.tab-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-family: 'Outfit', sans-serif;
    font-size: 1.25rem;
    font-weight: 600;
    cursor: pointer;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.tab-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.tab-btn.active {
    color: var(--primary-color);
    background: rgba(59, 130, 246, 0.1);
    box-shadow: inset 0 -3px 0 var(--primary-color);
}

/* Explorer View */
.explorer-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.secondary-btn {
    background: rgba(255, 255, 255, 0.1);
    box-shadow: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    box-shadow: none;
}

.status-msg {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.table-container {
    width: 100%;
    overflow-x: auto;
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
}

.r2-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.9rem;
}

.r2-table th {
    padding: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(15, 23, 42, 0.6);
}

.r2-table td {
    padding: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    white-space: nowrap;
}

.r2-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.05);
}

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

.table-empty {
    text-align: center;
    color: var(--text-secondary);
    padding: 3rem !important;
    font-style: italic;
}

/* Breadcrumbs */
.breadcrumbs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    font-family: 'Outfit', sans-serif;
    font-size: 1.1rem;
    color: var(--text-secondary);
}

.crumb {
    cursor: pointer;
    transition: color 0.2s ease;
}

.crumb:hover {
    color: var(--primary-color);
    text-decoration: underline;
}

.crumb::after {
    content: '/';
    margin-left: 0.5rem;
    color: rgba(255, 255, 255, 0.2);
    display: inline-block;
    pointer-events: none;
    text-decoration: none;
}

.crumb:last-child {
    color: var(--text-primary);
    font-weight: 600;
    cursor: default;
}

.crumb:last-child:hover {
    text-decoration: none;
}

.crumb:last-child::after {
    display: none;
}

/* Table Enhancements */
.folder-row {
    cursor: pointer;
    background: rgba(59, 130, 246, 0.05);
}

.folder-row:hover {
    background: rgba(59, 130, 246, 0.1) !important;
}

.icon-col {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.action-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.4rem;
    border-radius: 6px;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.action-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error-color);
}

/* Upload Inputs */
.upload-overrides {
    margin-top: 1rem;
    display: flex;
    gap: 1rem;
    padding: 1rem;
    background: rgba(0,0,0,0.2);
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.05);
}

.override-group {
    flex: 1;
}

.override-group label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.override-group input {
    width: 100%;
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    padding: 0.5rem;
    border-radius: 6px;
    font-family: monospace;
    font-size: 0.85rem;
}

.upload-confirm-btn {
    margin-top: 1rem;
    width: 100%;
}

/* Audit View Styles */
#auditView {
    margin-top: 1rem;
}

.audit-split-container {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr; /* 60/40 Split */
    gap: 1.5rem;
    height: 600px;
}

.pane-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.pane-header h3 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.1rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.audit-viewer-pane, .audit-data-pane {
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
}

.model-container-box {
    flex: 1;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

model-viewer {
    width: 100%;
    height: 100%;
    background-color: #111;
}

.audit-data-pane {
    max-height: 600px;
}

.audit-log-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    background: rgba(15, 23, 42, 0.6);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 0.95rem;
    line-height: 1.5;
}

/* Markdown Styles inside Audit Log */
.audit-log-content h1, 
.audit-log-content h2, 
.audit-log-content h3 {
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
    font-family: 'Outfit', sans-serif;
    color: var(--primary-color);
}

.audit-log-content h1:first-child { margin-top: 0; }

.audit-log-content table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
    font-size: 0.85rem;
}

.audit-log-content th, 
.audit-log-content td {
    padding: 0.75rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    text-align: left;
}

.audit-log-content th {
    background: rgba(59, 130, 246, 0.1);
    color: var(--text-primary);
}

.audit-log-content code {
    background: rgba(0, 0, 0, 0.3);
    padding: 0.1rem 0.3rem;
    border-radius: 4px;
    font-family: monospace;
}

.audit-log-content .empty-state {
    display: flex;
    height: 100%;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-style: italic;
    text-align: center;
}

.publish-btn {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
}

.publish-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: var(--text-secondary);
    box-shadow: none;
    transform: none;
}

@media (max-width: 800px) {
    .audit-split-container {
        grid-template-columns: 1fr;
        height: auto;
    }
    .audit-viewer-pane, .audit-data-pane {
        height: 400px;
    }
}

/* Header Connectivity UI */
.header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 2.5rem;
}

.header-connectivity {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: var(--glass-bg);
    padding: 0.5rem 1rem;
    border-radius: 100px;
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(10px);
}

.conn-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
    transition: background 0.3s ease, box-shadow 0.3s ease;
}

.conn-unknown { background: #94a3b8; }
.conn-online { background: var(--success-color); box-shadow: 0 0 8px var(--success-color); }
.conn-offline { background: var(--error-color); box-shadow: 0 0 8px var(--error-color); }

.icon-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: color 0.2s;
}

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

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

.modal-content {
    width: 100%;
    max-width: 450px;
    padding: 2rem;
    animation: slideIn 0.3s ease-out;
}

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

.modal-content h3 { margin-bottom: 0.5rem; font-family: 'Outfit', sans-serif; }
.modal-content p { color: var(--text-secondary); font-size: 0.9rem; margin-bottom: 1.5rem; }
.modal-actions { display: flex; gap: 1rem; margin-top: 1.5rem; }

.test-status {
    margin-top: 1rem;
    font-size: 0.85rem;
    padding: 0.5rem;
    border-radius: 4px;
    display: none;
}

/* Explorer Table Polishing */
.explorer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    gap: 1rem;
}

.explorer-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.status-msg {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.breadcrumb-container {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.crumb {
    color: var(--primary-color);
    cursor: pointer;
    font-weight: 500;
}

.crumb:after {
    content: '/';
    margin-left: 0.5rem;
    color: var(--text-secondary);
}

.crumb:last-child:after { content: ''; }
.crumb:hover { text-decoration: underline; }

.explorer-table-wrapper {
    overflow-x: auto;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    border: 1px solid var(--glass-border);
}

.explorer-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.explorer-table th {
    padding: 1rem;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--glass-border);
}

.explorer-table td {
    padding: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 0.9rem;
}

.folder-row { cursor: pointer; transition: background 0.2s; }
.folder-row:hover { background: rgba(255, 255, 255, 0.05); }

.icon-col { display: flex; align-items: center; gap: 0.75rem; }

