body {
    font-family: "Segoe UI", Tahoma, Arial, sans-serif;
    margin: 0;
    padding: 0;
    background: #f0f4f8;
    color: #2d3748;
}

.container {
    max-width: 1600px;
    margin: 0 auto;
    background: white;
    min-height: 100vh;
}

.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 40px 30px;
    text-align: center;
    position: relative;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.header h1 {
    margin: 0 0 10px 0;
    font-size: 2.5rem;
    font-weight: 700;
}

.header p {
    margin: 0;
    font-size: 1.1rem;
    opacity: 0.9;
}

.content {
    padding: 30px;
}

.main-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 24px;
    align-items: start;
    direction: ltr;
}

@media (max-width: 1200px) {
    .main-layout {
        grid-template-columns: 1fr;
    }
}

.viewer-section {
    height: fit-content;
}

.right-panel {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.viewer-container {
    background: #f7fafc;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.viewer-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px 20px;
    font-weight: bold;
    font-size: 1.1rem;
}

#canvas3D {
    width: 100%;
    height: 400px;
    display: block;
    background: linear-gradient(135deg, #e0e7ff 0%, #f3e8ff 100%);
}

.viewer-info {
    padding: 15px 20px;
    background: white;
    border-top: 2px solid #e2e8f0;
}

.viewer-info-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 0.9rem;
    color: #4a5568;
}

.viewer-info-label {
    font-weight: 600;
}

.controls-section {
    overflow-y: auto;
    max-height: calc(100vh - 180px);
}

.panel {
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    overflow: hidden;
    background: #fff;
}

.models-panel {
    margin-bottom: 20px;
}

.models-panel .panel-body {
    padding: 10px;
}

.panel-header {
    background: #f7fafc;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
}

.panel-title {
    font-weight: 700;
    color: #2d3748;
}

.panel-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.panel-count {
    background: #667eea;
    color: white;
    padding: 2px 10px;
    border-radius: 16px;
    font-size: 0.8rem;
}

.panel .chevron {
    transition: transform 0.2s ease;
}

.panel.collapsed .chevron {
    transform: rotate(-90deg);
}

.panel-body {
    padding: 14px;
}

.panel.collapsed .panel-body {
    display: none;
}

.models-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 8px;
    margin-bottom: 0;
    max-height: 200px;
    overflow-y: auto;
}

.model-card {
    border: 2px solid #e2e8f0;
    border-radius: 6px;
    padding: 8px;
    transition: all 0.3s ease;
    cursor: pointer;
    text-align: center;
}

.model-card:hover {
    border-color: #667eea;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
    transform: translateY(-2px);
}

.model-card.active {
    border-color: #667eea;
    background: #f7fafc;
}

.model-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    margin-bottom: 0;
}

.model-title {
    font-size: 0.85rem;
    font-weight: bold;
    color: #2d3748;
}

.model-variation {
    background: #667eea;
    color: white;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 0.7rem;
}

.model-description {
    display: none;
}

.model-stats {
    display: none;
}

.stat {
    display: flex;
    align-items: center;
    gap: 5px;
}

.mesh-details {
    margin-top: 30px;
    border-top: 2px solid #e2e8f0;
    padding-top: 30px;
}

.mesh-details h2 {
    font-size: 1.8rem;
    color: #2d3748;
    margin-bottom: 20px;
}

.mesh-groups {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.mesh-group {
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
}

.mesh-group-header {
    background: #f7fafc;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.mesh-group-header .chevron {
    transition: transform 0.2s ease;
}

.mesh-group.collapsed .mesh-group-header .chevron {
    transform: rotate(-90deg);
}

.mesh-group-header:hover {
    background: #edf2f7;
}

.mesh-group-title {
    font-weight: bold;
    font-size: 1.1rem;
    color: #2d3748;
}

.mesh-group-count {
    background: #667eea;
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
}

.mesh-list {
    padding: 14px 16px 16px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 12px;
}

.mesh-group.collapsed .mesh-list {
    display: none;
}

.mesh-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: #f7fafc;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.mesh-item:hover {
    background: #edf2f7;
}

.mesh-info {
    flex: 1;
}

.mesh-name {
    font-weight: 600;
    color: #2d3748;
    font-size: 0.95rem;
}

.mesh-label {
    color: #718096;
    font-size: 0.85rem;
    margin-top: 2px;
}

.mesh-toggle {
    position: relative;
    width: 50px;
    height: 26px;
}

.mesh-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #cbd5e0;
    transition: 0.4s;
    border-radius: 26px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.4s;
    border-radius: 50%;
}

.mesh-toggle input:checked + .toggle-slider {
    background-color: #667eea;
}

.mesh-toggle input:checked + .toggle-slider:before {
    transform: translateX(24px);
}

.loading {
    text-align: center;
    padding: 50px;
    font-size: 1.2rem;
    color: #718096;
}

.error {
    background: #fed7d7;
    color: #c53030;
    padding: 15px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover {
    background: #5568d3;
    transform: translateY(-1px);
}

.btn-save {
    position: fixed;
    bottom: 30px;
    right: 30px;
    padding: 15px 30px;
    font-size: 1.1rem;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid #667eea;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

/* Login Modal Styles */
.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(4px);
}

.modal.show {
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: white;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    max-width: 400px;
    width: 90%;
}

.modal-header {
    text-align: center;
    margin-bottom: 30px;
}

.modal-header h2 {
    color: #2d3748;
    font-size: 1.8rem;
    margin-bottom: 10px;
}

.modal-header p {
    color: #718096;
    font-size: 0.95rem;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    color: #2d3748;
    font-weight: 600;
    margin-bottom: 8px;
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 2px solid #e2e8f0;
    border-radius: 6px;
    font-size: 1rem;
    transition: border-color 0.2s;
}

.form-group input:focus {
    outline: none;
    border-color: #667eea;
}

.btn-login {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s;
}

.btn-login:hover {
    transform: translateY(-2px);
}

.btn-login:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.logout-btn {
    position: absolute;
    top: 20px;
    left: 20px;
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.logout-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Back button style to match edit-order page */
.back-btn {
    position: absolute;
    top: 20px;
    right: 20px; /* keep same placement as previous logout for visual consistency */
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #fff;
    padding: 10px 20px;
    border-radius: 8px;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: background 0.3s;
}

.back-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}