/* Yadav Lab - Professional Styles */

:root {
    --primary: #667eea;
    --primary-dark: #5568d3;
    --secondary: #764ba2;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --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;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    color: var(--gray-900);
    background: var(--gray-50);
    overflow: hidden;
    width: 100%;
    max-width: 100vw;
    position: relative;
}

/* Authentication Screens */
.auth-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.auth-content {
    text-align: center;
    max-width: 500px;
    padding: 40px;
}

.auth-content svg {
    margin-bottom: 32px;
}

.auth-content h1 {
    font-size: 48px;
    font-weight: 700;
    color: white;
    margin-bottom: 12px;
}

/* Animated Gradient Text */
.gradient-text {
    background: linear-gradient(
        90deg,
        #fff 0%,
        #a78bfa 20%,
        #f472b6 40%,
        #60a5fa 60%,
        #34d399 80%,
        #fff 100%
    );
    background-size: 200% auto;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: gradient-shift 3s ease-in-out infinite;
}

.gradient-text-header {
    background: linear-gradient(
        90deg,
        #fff 0%,
        #c4b5fd 25%,
        #f9a8d4 50%,
        #93c5fd 75%,
        #fff 100%
    );
    background-size: 200% auto;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: gradient-shift 4s ease-in-out infinite;
}

@keyframes gradient-shift {
    0% {
        background-position: 0% center;
    }
    50% {
        background-position: 100% center;
    }
    100% {
        background-position: 0% center;
    }
}

.auth-content p {
    font-size: 18px;
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 48px;
}

.auth-input-group {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.auth-input {
    padding: 16px 24px;
    font-size: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.9);
    color: var(--gray-900);
    transition: all 0.2s;
}

.auth-input:focus {
    outline: none;
    border-color: white;
    background: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.auth-error {
    color: #ffcdd2;
    font-size: 14px;
    padding: 12px;
    background: rgba(244, 67, 54, 0.2);
    border-radius: 6px;
}

/* Profile Selection */
.profiles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 24px;
    margin-top: 40px;
    max-width: 800px;
}

.profile-card {
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    padding: 24px 16px;
    cursor: pointer;
    transition: all 0.3s;
    text-align: center;
    position: relative;
}

.profile-card:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.4);
    transform: translateY(-4px);
}

.profile-card:hover .profile-actions {
    opacity: 1;
}

.profile-actions {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s;
}

.profile-action-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: all 0.2s;
    background: rgba(255, 255, 255, 0.9);
}

.profile-action-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.profile-action-btn.edit {
    color: #1976d2;
}

.profile-action-btn.delete {
    color: #d32f2f;
}

.profile-action-btn:active {
    transform: scale(0.95);
}

.profile-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, #64b5f6 0%, #1976d2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    font-weight: bold;
    color: white;
    margin: 0 auto 16px;
}

.profile-name {
    color: white;
    font-size: 16px;
    font-weight: 600;
}

.profile-card.add-profile {
    border-style: dashed;
}

.profile-card.add-profile .profile-avatar {
    background: rgba(255, 255, 255, 0.2);
    font-size: 48px;
}

/* Header */
.app-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    padding: 0 24px;
    height: 64px;
    box-shadow: var(--shadow-md);
    position: relative;
    z-index: 100;
}

.header-content {
    display: flex;
    align-items: center;
    height: 100%;
    gap: 24px;
}

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

.logo-text {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.project-info {
    flex: 1;
    display: flex;
    gap: 16px;
    font-size: 13px;
}

.project-info span {
    background: rgba(255, 255, 255, 0.2);
    padding: 6px 12px;
    border-radius: 6px;
    white-space: nowrap;
}

.header-actions {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-left: auto;
}

.user-welcome {
    color: white;
    font-size: 14px;
    font-weight: 500;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.user-welcome::before {
    content: '👋';
    font-size: 16px;
}

.btn-logout {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    padding: 8px 16px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-logout:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.4);
}

/* Main Container */
.main-container {
    display: flex;
    height: calc(100vh - 64px);
    overflow: hidden;
}

/* Full Width Mode */
.main-content.full-width {
    width: 100%;
    flex: 1;
}

/* Sidebar (hidden in single project mode) */
.sidebar {
    display: none;
    width: 280px;
    background: white;
    border-right: 1px solid var(--gray-200);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-section {
    padding: 20px;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.sidebar-title {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--gray-500);
    letter-spacing: 0.5px;
    margin-bottom: 16px;
}

.project-list {
    flex: 1;
    overflow-y: auto;
    margin-top: 16px;
}

.project-item {
    padding: 12px 16px;
    border-radius: 8px;
    cursor: pointer;
    margin-bottom: 8px;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.project-item:hover {
    background: var(--gray-50);
    border-color: var(--gray-200);
}

.project-item.active {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
}

.project-item-name {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 4px;
}

.project-item-meta {
    font-size: 12px;
    color: var(--gray-500);
}

.project-item.active .project-item-meta {
    color: rgba(255, 255, 255, 0.8);
}

/* Main Content */
.main-content {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Welcome Screen */
.welcome-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    background: white;
}

.welcome-content {
    text-align: center;
    max-width: 400px;
}

.welcome-content h1 {
    font-size: 32px;
    font-weight: 700;
    margin: 24px 0 12px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.welcome-content p {
    color: var(--gray-600);
    margin-bottom: 32px;
}

/* Project View */
.project-view {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* Toolbar */
.toolbar {
    background: white;
    padding: 16px 24px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    gap: 16px;
    justify-content: space-between;
}

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

.filter-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-700);
    margin-left: 8px;
}

.filter-select {
    padding: 8px 12px;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    font-size: 14px;
    background: white;
    color: var(--gray-700);
    cursor: pointer;
    min-width: 150px;
    transition: all 0.2s;
}

.filter-select:hover {
    border-color: var(--primary);
}

.filter-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.filter-group {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 6px 12px;
    background: rgba(102, 126, 234, 0.05);
    border: 1px solid rgba(102, 126, 234, 0.2);
    border-radius: 8px;
}

/* Content Grid */
.content-grid {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1px;
    background: var(--gray-200);
    overflow: hidden;
}

.positions-panel,
.details-panel {
    background: white;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panel-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.panel-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.panel-header h2 {
    font-size: 16px;
    font-weight: 600;
    color: var(--gray-900);
    flex-shrink: 0;
}

.panel-position-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--gray-700);
    min-width: 0;
}

.panel-pos-number {
    font-weight: 600;
    color: var(--primary);
    background: rgba(102, 126, 234, 0.1);
    padding: 4px 8px;
    border-radius: 4px;
    flex-shrink: 0;
}

.panel-pos-text {
    color: var(--gray-600);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.position-search-input {
    flex: 1;
    max-width: 250px;
    margin: 0 16px;
    padding: 6px 12px;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    font-size: 13px;
    background: white;
    color: var(--gray-700);
    transition: all 0.2s;
}

.position-search-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.position-search-input::placeholder {
    color: var(--gray-400);
}

.positions-tree,
.position-details {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.position-metrics {
    padding: 16px 24px;
    border-bottom: 1px solid var(--gray-200);
    background: var(--gray-50);
}

.position-invoices {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

/* Buttons */
.btn-primary,
.btn-secondary,
.btn-icon,
.btn-toggle {
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    outline: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    padding: 10px 20px;
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

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

.btn-secondary {
    background: white;
    color: var(--gray-700);
    padding: 10px 16px;
    border: 1px solid var(--gray-300);
}

.btn-secondary:hover {
    background: var(--gray-50);
    border-color: var(--gray-400);
}

.btn-icon {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    padding: 8px;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.3);
}

.btn-toggle {
    background: white;
    color: var(--primary);
    padding: 8px 16px;
    border: 2px solid var(--primary);
}

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

.btn-block {
    width: 100%;
    justify-content: center;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 16px;
}

.btn-close {
    background: none;
    border: none;
    font-size: 28px;
    color: var(--gray-400);
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 32px;
    height: 32px;
}

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

/* Inputs */
.search-input,
.filter-select {
    padding: 10px 16px;
    border: 2px solid var(--gray-300);
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.search-input {
    width: 320px;
}

.search-input:focus,
.filter-select:focus {
    border-color: var(--primary);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

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

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
}

.modal-subtitle {
    font-size: 13px;
    color: var(--gray-600);
    margin: 4px 0 0 0;
    font-weight: 500;
}

.modal-body {
    padding: 24px;
}

.modal-info {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 16px;
    background: #f0f4ff;
    border: 1px solid #d4e0ff;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 13px;
    color: var(--gray-700);
    line-height: 1.5;
}

.modal-info svg {
    flex-shrink: 0;
    margin-top: 2px;
}

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

.modal-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.projects-list, .invoices-list {
    max-height: 500px;
    overflow-y: auto;
}

.list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    margin-bottom: 12px;
    background: var(--gray-50);
    transition: all 0.2s;
    gap: 12px;
}

.list-item.selectable-item {
    cursor: pointer;
    user-select: none;
}

.list-item:hover {
    background: white;
    border-color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.list-item.active {
    background: #f0f4ff;
    border-color: var(--primary);
}

.list-item.selected {
    background: #e0e7ff;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.1);
}

.list-item-content {
    flex: 1;
}

.list-item-title {
    font-weight: 600;
    font-size: 14px;
    color: var(--gray-900);
    margin-bottom: 4px;
}

.list-item-meta {
    font-size: 12px;
    color: var(--gray-600);
}

.list-item-actions {
    display: flex;
    gap: 8px;
}

.btn-icon {
    padding: 6px 10px;
    background: white;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    cursor: pointer;
    color: var(--gray-700);
    transition: all 0.2s;
    font-size: 12px;
}

.btn-icon:hover {
    background: var(--gray-50);
    border-color: var(--gray-400);
}

.btn-icon.danger:hover {
    background: #fee;
    border-color: #ef4444;
    color: #ef4444;
}

/* Upload Zone */
.upload-zone {
    border: 2px dashed var(--gray-300);
    border-radius: 12px;
    padding: 48px 24px;
    text-align: center;
    transition: all 0.2s;
}

.upload-zone:hover {
    border-color: var(--primary);
    background: var(--gray-50);
}

.upload-zone svg {
    margin-bottom: 16px;
}

.upload-zone p {
    margin-bottom: 8px;
}

.text-muted {
    color: var(--gray-500);
    font-size: 13px;
}

.upload-zone button {
    margin-top: 16px;
}

/* Progress */
.upload-progress {
    text-align: center;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--gray-200);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 16px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary) 0%, var(--secondary) 100%);
    width: 0%;
    transition: width 0.3s;
}

/* Loading */
.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px;
    color: var(--gray-500);
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 16px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--gray-500);
}

.empty-state p {
    margin: 0;
}

/* Highlight */
.highlight {
    background: #fef3c7;
    color: var(--gray-900);
    padding: 2px 4px;
    border-radius: 3px;
    font-weight: 600;
}

/* Tree Structure */
.tree-node {
    margin-bottom: 2px;
}

.tree-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s;
    border-left: 3px solid transparent;
}

.tree-header:hover {
    background: var(--gray-50);
    border-left-color: var(--primary);
}

.tree-header.selected {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    border-left-color: var(--secondary);
}

.tree-header.category {
    background: #f8f9fc;
    font-weight: 600;
}

.tree-header.category.level-0 {
    background: #e8eaf6;
    font-size: 14px;
    font-weight: bold;
}

.tree-header.category.level-1 {
    background: #f3e5f5;
}

.tree-header.category.level-2 {
    background: #fce4ec;
}

.tree-header.category.level-3 {
    background: #fff3e0;
}

.tree-header.category.level-4 {
    background: #e8f5e9;
}

.tree-header.category:hover {
    background: #eef1f9;
}

.tree-header.selected,
.tree-header.category.selected,
.tree-header.category.level-0.selected,
.tree-header.category.level-1.selected,
.tree-header.category.level-2.selected,
.tree-header.category.level-3.selected,
.tree-header.category.level-4.selected,
.tree-header.item.selected {
    background: #667eea !important;
    color: white !important;
    border-left-color: #764ba2 !important;
}

.tree-header.item {
    background: white;
}

.tree-header.item:nth-child(even) {
    background: var(--gray-50);
}

/* Expand Icon */
.expand-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: bold;
    color: var(--primary);
    background: var(--gray-100);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
    flex-shrink: 0;
}

.expand-icon.empty {
    opacity: 0;
    pointer-events: none;
    background: transparent;
}

.expand-icon.collapsed {
    color: var(--gray-700);
    background: var(--gray-100);
}

.expand-icon.expanded {
    color: white;
    background: var(--primary);
}

.expand-icon:hover {
    color: white;
    background: var(--primary);
    transform: scale(1.15);
    box-shadow: var(--shadow-sm);
}

.tree-header.selected .expand-icon {
    color: white;
}

.tree-header.selected .expand-icon:hover {
    color: rgba(255, 255, 255, 0.8);
}

/* Position Number */
.pos-number {
    font-weight: 600;
    font-size: 13px;
    min-width: 90px;
    background: var(--gray-100);
    padding: 4px 10px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    color: white;
}

.tree-header.category .pos-number {
    background: #667eea;
    color: white;
}

.pos-number.level-0 {
    background: #667eea;
    color: white;
}

.pos-number.level-1 {
    background: #2c3a99;
    color: white;
}

.pos-number.level-2 {
    background: #3b4dad;
    color: white;
}

.pos-number.level-3 {
    background: #4a5fc1;
    color: white;
}

.pos-number.level-4 {
    background: #5e72d4;
    color: white;
}

.pos-number.level-5 {
    background: #667eea;
    color: white;
}

.tree-header.selected .pos-number,
.tree-header.category.selected .pos-number,
.tree-header.category.level-0.selected .pos-number,
.tree-header.category.level-1.selected .pos-number,
.tree-header.category.level-2.selected .pos-number,
.tree-header.category.level-3.selected .pos-number,
.tree-header.category.level-4.selected .pos-number {
    background: rgba(255, 255, 255, 0.2) !important;
    color: white !important;
}

.tree-header.selected .pos-short-text,
.tree-header.category.selected .pos-short-text,
.tree-header.category.level-0.selected .pos-short-text,
.tree-header.category.level-1.selected .pos-short-text,
.tree-header.category.level-2.selected .pos-short-text,
.tree-header.category.level-3.selected .pos-short-text,
.tree-header.category.level-4.selected .pos-short-text {
    color: white !important;
}

.tree-header.selected .pos-qty,
.tree-header.category.selected .pos-qty {
    color: white !important;
}

/* Position Text */
.pos-short-text {
    flex: 1;
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tree-header.category .pos-short-text {
    font-weight: 600;
}

/* Position Quantity */
.pos-qty {
    font-size: 13px;
    color: var(--gray-600);
    min-width: 100px;
    text-align: right;
    font-family: 'Courier New', monospace;
}

.tree-header.selected .pos-qty {
    color: rgba(255, 255, 255, 0.9);
}

/* Tree Children */
.tree-children {
    margin-left: 30px;
    padding-left: 16px;
    border-left: 2px solid var(--gray-200);
    display: none;
}

.tree-children[style*="display: block"] {
    display: block !important;
}

/* Search Highlighting */
.tree-node.search-match .tree-header {
    background: #fff9e6 !important;
    box-shadow: 0 0 0 2px #ffeb3b;
}

/* Selected state has priority over search highlighting */
.tree-node.search-match .tree-header.selected {
    background: #667eea !important;
    color: white !important;
    border-left-color: #764ba2 !important;
    box-shadow: 0 0 0 3px #764ba2;
}

.tree-node.search-match .tree-header.selected .pos-number {
    background: rgba(255, 255, 255, 0.2) !important;
    color: white !important;
}

.tree-node.search-match .tree-header.selected .pos-short-text {
    color: white !important;
}

.tree-node.search-match .tree-header.selected .pos-qty {
    color: white !important;
}

.tree-node.search-match .tree-header.selected .highlight {
    background-color: rgba(255, 255, 255, 0.3);
    color: white;
}

.tree-node.search-hidden {
    display: none;
}

.highlight {
    background-color: #ffeb3b;
    color: #000;
    font-weight: bold;
    padding: 1px 2px;
    border-radius: 2px;
}

/* Search Loading Overlay */
.search-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(2px);
}

.search-loading-overlay .spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.search-loading-overlay p {
    margin-top: 12px;
    color: var(--primary);
    font-weight: 600;
}

/* Level Colors */
.tree-header.level-0 {
    border-left-width: 4px;
}

.tree-header.level-1 {
    padding-left: 16px;
}

.tree-header.level-2 {
    padding-left: 20px;
}

.tree-header.level-3 {
    padding-left: 24px;
}

/* Loading States */
.spinner-small {
    width: 16px;
    height: 16px;
    border: 2px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    margin: 8px auto;
}

.empty-state-small,
.error-state-small {
    padding: 12px;
    text-align: center;
    font-size: 13px;
    color: var(--gray-500);
    font-style: italic;
}

.error-state-small {
    color: var(--danger);
}

/* Detail Sections */
.detail-header-section {
    border-bottom: 2px solid var(--primary);
    padding-bottom: 12px;
    margin-bottom: 15px;
}

.detail-header-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.detail-pos-number {
    font-family: 'Courier New', monospace;
    background: var(--primary);
    color: white;
    padding: 6px 12px;
    border-radius: 4px;
    font-weight: bold;
    font-size: 16px;
    display: inline-block;
}

.detail-short-text {
    font-size: 18px;
    font-weight: 600;
    color: var(--gray-900);
    line-height: 1.3;
    flex: 1 1 100%;
}

.detail-header-metrics {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.metrics-comparison-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

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

.metrics-row .detail-metric-chip {
    flex: 1;
    min-width: 180px;
}

.metrics-row.lv-row .detail-metric-chip {
    border-left-color: #4caf50;
}

.metrics-row.re-row .detail-metric-chip {
    border-left-color: #1976d2;
}

.diff-value {
    font-weight: 700;
    color: var(--primary);
}

.detail-metric-chip {
    background: #f5f5f5;
    padding: 6px 12px;
    border-radius: 4px;
    border-left: 3px solid #4caf50;
    display: flex;
    align-items: center;
    gap: 6px;
    justify-content: space-between;
}

.detail-metric-chip.price {
    background: #e8f5e9;
    border-left-color: #2e7d32;
}

.detail-metric-chip.comparison {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-left-width: 3px;
}

.detail-metric-chip.highlight-re {
    background: #e3f2fd;
    border-left-color: #1976d2;
    font-weight: 600;
}

.detail-metric-chip.highlight-re.price {
    background: #e1f5fe;
    border-left-color: #0277bd;
}

.detail-metric-chip.highlight-exceeded {
    background: #fff3e0;
    border-left-color: #f57c00;
    font-weight: 700;
}

.detail-metric-chip.highlight-exceeded.price {
    background: #ffe0b2;
    border-left-color: #e65100;
}

.detail-metric-chip.comparison-spacer {
    background: transparent;
    border: none;
    visibility: hidden;
}

.detail-metric-label {
    font-size: 10px;
    text-transform: uppercase;
    color: var(--gray-600);
    font-weight: bold;
    white-space: nowrap;
}

.detail-metric-value {
    font-family: 'Courier New', monospace;
    text-align: right;
    min-width: 80px;
    font-weight: 600;
}

.detail-metric-value {
    font-size: 14px;
    color: var(--gray-900);
    font-weight: 600;
}

.detail-section {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
}

.detail-section h3 {
    color: var(--primary);
    font-size: 13px;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: bold;
}

.detail-section-content {
    background: #f9f9f9;
    padding: 12px;
    border-radius: 4px;
    line-height: 1.6;
}

.detail-section-content p {
    margin: 0;
    color: var(--gray-700);
}

/* Notes */
.notes-list {
    padding: 16px;
    max-height: 400px;
    overflow-y: auto;
}

.note-item {
    background: var(--gray-50);
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 12px;
    border-left: 3px solid var(--primary);
}

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

.note-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.note-header strong {
    color: var(--gray-900);
    font-size: 13px;
}

.note-date {
    font-size: 12px;
    color: var(--gray-500);
}

.note-text {
    color: var(--gray-700);
    font-size: 14px;
    line-height: 1.6;
    white-space: pre-wrap;
}

.note-input {
    padding: 16px;
    border-top: 1px solid var(--gray-200);
}

.note-input textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--gray-300);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    outline: none;
    margin-bottom: 12px;
    transition: border-color 0.2s;
}

.note-input textarea:focus {
    border-color: var(--primary);
}

/* Note Actions */
.note-actions {
    display: flex;
    gap: 8px;
}

.btn-edit-note {
    background: transparent;
    border: 1px solid var(--gray-300);
    color: var(--gray-600);
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-edit-note:hover {
    background: var(--gray-100);
    border-color: var(--primary);
    color: var(--primary);
}

.btn-delete-note {
    background: transparent;
    border: 1px solid var(--gray-300);
    color: var(--gray-600);
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-delete-note:hover {
    background: #fee;
    border-color: var(--danger);
    color: var(--danger);
}

.note-edit-form {
    margin-top: 8px;
}

.note-edit-textarea {
    width: 100%;
    min-height: 80px;
    padding: 8px;
    border: 1px solid var(--gray-300);
    border-radius: 4px;
    font-family: inherit;
    font-size: 14px;
    resize: vertical;
    margin-bottom: 8px;
}

.note-edit-textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.note-edit-actions {
    display: flex;
    gap: 8px;
}

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

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--gray-100);
}

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

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

/* View Toggle & Invoice Filter */
.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    position: relative;
}

.view-toggle {
    display: flex;
    gap: 4px;
    background: var(--gray-100);
    border-radius: 8px;
    padding: 4px;
}

.toggle-btn {
    padding: 6px 16px;
    border: none;
    background: transparent;
    color: var(--gray-600);
    font-size: 13px;
    font-weight: 500;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.toggle-btn:hover {
    background: var(--gray-200);
    color: var(--gray-800);
}

.toggle-btn.active {
    background: white;
    color: var(--primary);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Invoice Table */
.position-invoices {
    padding: 20px;
    height: calc(100vh - 200px);
    overflow: hidden;
}

.invoice-table-wrapper {
    overflow-y: auto;
    max-height: calc(100vh - 240px);
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    padding-bottom: 150px;
}

.invoice-section {
    margin-bottom: 32px;
}

.invoice-section-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    padding: 12px 16px;
    border-radius: 8px 8px 0 0;
    font-weight: 600;
    font-size: 14px;
}

.invoice-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: 0 0 8px 8px;
    overflow: hidden;
}

.invoice-table thead {
    background: var(--gray-50);
}

.invoice-table th {
    padding: 12px;
    text-align: left;
    background: var(--gray-50);
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-700);
    border-bottom: 2px solid var(--gray-300);
    text-transform: uppercase;
    position: sticky;
    top: 0;
    z-index: 10;
}

.invoice-table td {
    padding: 10px 12px;
    font-size: 13px;
    border-bottom: 1px solid var(--gray-100);
    color: var(--gray-700);
}

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

.invoice-table tr:hover {
    background: var(--gray-50);
}

.invoice-table .line-description {
    color: var(--gray-900);
    font-weight: 500;
}

.invoice-table .line-detail {
    color: var(--gray-600);
    font-style: italic;
}

.invoice-table .line-calculation {
    font-family: 'Courier New', monospace;
    color: var(--primary);
    font-size: 12px;
}

.invoice-table .blatt-ref {
    background: #e3f2fd;
    color: #1976d2;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    display: inline-block;
}

.invoice-table .ar-badge {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    display: inline-block;
}

.invoice-table .ar-badge-1 {
    background: #e3f2fd;
    color: #1565c0;
}

.invoice-table .ar-badge-2 {
    background: #f3e5f5;
    color: #7b1fa2;
}

.invoice-table .ar-badge-3 {
    background: #e8f5e9;
    color: #2e7d32;
}

.invoice-table .ar-badge-4 {
    background: #fff3e0;
    color: #e65100;
}

.invoice-table .ar-badge-5 {
    background: #fce4ec;
    color: #c2185b;
}

.invoice-table .ar-badge-6 {
    background: #e0f2f1;
    color: #00695c;
}

.invoice-table .position-badge {
    background: #e3f2fd;
    color: #1976d2;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    display: inline-block;
}

.invoice-table .clickable-position {
    cursor: pointer;
    transition: all 0.2s;
}

.invoice-table .clickable-position:hover {
    background: #1976d2;
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

.invoice-table .result-value {
    font-weight: 600;
    color: var(--gray-900);
}

.invoice-table tr.position-group-end td {
    border-bottom: 2px solid #cbd5e0;
}

.invoice-table tr.hint-row {
    font-style: italic;
    color: #666;
    border-left: 3px solid #ff9800 !important;
}

.invoice-table tr.hint-row td {
    opacity: 0.75;
}

.invoice-table .hint-marker {
    color: #ff9800;
    font-weight: 500;
    font-style: normal;
}

.invoice-table .detail-marker {
    color: #2196F3;
    font-weight: 600;
}

.invoice-table .summary-row td {
    background: #f8f9fa !important;
    border-top: 2px solid var(--primary);
    padding: 12px 8px;
    font-size: 14px;
}

.invoice-summary {
    margin-top: 12px;
    padding: 16px;
    background: #f8f9fa;
    border-radius: 8px;
    display: flex;
    justify-content: flex-end;
    gap: 32px;
}

.invoice-summary-item {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.invoice-summary-label {
    font-size: 11px;
    color: var(--gray-600);
    text-transform: uppercase;
    margin-bottom: 4px;
}

.invoice-summary-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary);
}

/* ============================================================================
   MOBILE RESPONSIVE STYLES - OPTIMIZED
   ============================================================================ */

/* Prevent horizontal scroll on all elements */
html {
    overflow-x: hidden;
    max-width: 100vw;
}

body {
    overflow-x: hidden;
    max-width: 100vw;
}

/* Mobile Menu Buttons */
.mobile-menu-btn {
    display: none;
    width: 44px;
    height: 44px;
    min-width: 44px;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border-radius: 8px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: all 0.2s;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
}

.mobile-menu-btn:active {
    transform: scale(0.92);
    background: rgba(255, 255, 255, 0.3);
}

/* Overlay for mobile panels */
.mobile-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    z-index: 998;
    opacity: 0;
    transition: opacity 0.3s;
    -webkit-tap-highlight-color: transparent;
}

.mobile-overlay.active {
    opacity: 1;
}

/* Mobile Panel Container */
.mobile-panel {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: 85vw;
    max-width: 320px;
    background: white;
    z-index: 999;
    transform: translateX(-100%);
    transition: transform 0.3s ease-in-out;
    overflow-y: auto;
    overflow-x: hidden;
    box-shadow: 2px 0 20px rgba(0, 0, 0, 0.2);
    -webkit-overflow-scrolling: touch;
}

.mobile-panel.right {
    right: 0;
    left: auto;
    transform: translateX(100%);
    box-shadow: -2px 0 20px rgba(0, 0, 0, 0.2);
}

.mobile-panel.active {
    transform: translateX(0);
}

.mobile-panel-header {
    padding: 16px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 10;
    min-height: 56px;
}

.mobile-panel-title {
    font-size: 16px;
    font-weight: 600;
    flex: 1;
}

.mobile-panel-close {
    background: none;
    border: none;
    color: white;
    font-size: 28px;
    cursor: pointer;
    width: 44px;
    height: 44px;
    min-width: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
}

.mobile-panel-close:active {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(0.9);
}

.mobile-panel-content {
    padding: 16px;
    overflow-x: hidden;
}

/* Mobile Tablet Styles */
@media (max-width: 1024px) {
    .mobile-menu-btn {
        display: flex;
    }

    /* Hide toolbar filters on mobile, show in right panel */
    .toolbar {
        padding: 12px 16px;
        overflow-x: hidden;
    }

    .toolbar-section {
        flex-wrap: wrap;
        overflow-x: hidden;
    }

    .filter-group,
    .filter-label:not(:first-child),
    .filter-select:not(#unitFilter) {
        display: none !important;
    }

    .search-input {
        flex: 1;
        min-width: 0;
        max-width: 100%;
    }
}

/* Mobile Phone Styles */
@media (max-width: 768px) {
    /* Ensure no horizontal scroll */
    * {
        max-width: 100vw;
    }

    /* Adjust header for mobile */
    .app-header {
        padding: 0 8px;
        height: 56px;
        width: 100%;
        max-width: 100vw;
        overflow: hidden;
    }

    .header-content {
        gap: 4px;
        width: 100%;
        max-width: 100%;
        overflow: hidden;
    }

    .logo {
        min-width: 40px;
    }

    .logo-text {
        display: none;
    }

    .user-welcome {
        display: none;
    }

    .header-actions {
        gap: 4px;
        flex-shrink: 0;
    }

    .btn-secondary,
    .btn-logout {
        padding: 8px;
        font-size: 0;
        min-width: 40px;
        width: 40px;
        height: 40px;
    }

    .btn-secondary svg,
    .btn-logout svg {
        width: 18px;
        height: 18px;
        margin: 0;
    }

    .project-info {
        font-size: 12px;
        max-width: 150px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* Main container adjustments */
    .main-container {
        height: calc(100vh - 56px);
        width: 100vw;
        max-width: 100vw;
        overflow-x: hidden;
    }

    .main-content {
        width: 100vw;
        max-width: 100vw;
        overflow-x: hidden;
    }

    /* Simplify toolbar for mobile - hide most controls */
    .toolbar {
        padding: 8px;
        width: 100%;
        max-width: 100vw;
        overflow: hidden;
        box-sizing: border-box;
    }

    .toolbar-section {
        width: 100%;
        max-width: 100%;
        overflow: hidden;
        box-sizing: border-box;
    }

    /* Hide all toolbar filters and buttons on mobile - use panels instead */
    .toolbar .filter-label,
    .toolbar .filter-select,
    .toolbar .filter-group,
    .toolbar .btn-reset,
    .toolbar .expand-controls {
        display: none !important;
    }

    .search-input {
        width: 100% !important;
        max-width: 100% !important;
        font-size: 16px !important;
        padding: 12px !important;
        box-sizing: border-box;
        border-radius: 8px;
    }

    /* Position cards on mobile */
    .position-card {
        padding: 12px;
        margin: 8px;
        width: calc(100% - 16px);
        max-width: calc(100vw - 32px);
        overflow: hidden;
    }

    .position-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
        width: 100%;
    }

    .position-number {
        font-size: 13px;
        word-break: break-word;
    }

    .position-title {
        font-size: 14px;
        word-break: break-word;
    }

    .position-actions {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
        gap: 4px;
    }

    .position-actions button {
        font-size: 11px;
        padding: 6px 10px;
    }

    /* Detail panel adjustments */
    .detail-panel {
        padding: 12px;
        width: 100%;
        max-width: 100vw;
        overflow-x: hidden;
    }

    .detail-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
        width: 100%;
    }

    .detail-title {
        font-size: 16px;
        word-break: break-word;
    }

    .detail-actions {
        width: 100%;
        flex-direction: column;
        gap: 8px;
    }

    .detail-actions button {
        width: 100%;
        justify-content: center;
        min-height: 44px;
    }

    .detail-section {
        padding: 12px;
        overflow-x: hidden;
    }

    .detail-label {
        font-size: 12px;
    }

    .detail-value {
        font-size: 14px;
        word-break: break-word;
    }

    /* Tree structure in mobile panel */
    .mobile-panel .tree-header {
        padding: 12px;
        font-size: 13px;
        min-height: 44px;
        word-break: break-word;
    }

    .mobile-panel .tree-toggle {
        font-size: 16px;
        width: 28px;
        height: 28px;
        min-width: 28px;
        flex-shrink: 0;
    }

    .mobile-panel .tree-number {
        font-size: 11px;
        min-width: 50px;
    }

    .mobile-panel .tree-text {
        font-size: 13px;
        flex: 1;
        word-break: break-word;
    }

    /* Invoice table mobile */
    .invoice-table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        width: 100%;
        max-width: 100vw;
    }

    .invoice-table {
        min-width: 100%;
        font-size: 12px;
    }

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

    /* Notes on mobile */
    .note-card {
        padding: 12px;
        width: 100%;
        max-width: 100%;
        overflow: hidden;
    }

    .note-text {
        font-size: 13px;
        word-break: break-word;
    }

    .note-actions {
        flex-direction: row;
        gap: 8px;
        flex-wrap: wrap;
    }

    .note-actions button {
        min-width: 44px;
        min-height: 44px;
    }

    /* Modals on mobile */
    .modal {
        padding: 0;
    }

    .modal-content {
        width: 100vw;
        max-width: 100vw;
        height: 100vh;
        max-height: 100vh;
        margin: 0;
        border-radius: 0;
        overflow-y: auto;
    }

    .modal-header {
        position: sticky;
        top: 0;
        z-index: 10;
        padding: 12px;
    }

    .modal-title {
        font-size: 16px;
    }

    .modal-body {
        padding: 16px;
        overflow-x: hidden;
    }

    .modal-footer {
        position: sticky;
        bottom: 0;
        padding: 12px;
        background: white;
        border-top: 1px solid var(--gray-200);
    }

    .modal-footer button {
        min-height: 44px;
    }

    /* Forms on mobile */
    input[type="text"],
    input[type="number"],
    textarea,
    select {
        font-size: 16px;
        padding: 12px;
        min-height: 44px;
    }

    textarea {
        min-height: 120px;
    }

    /* Auth screens on mobile */
    .auth-screen {
        padding: 16px;
    }

    .auth-content {
        padding: 20px;
        max-width: 100%;
        width: 100%;
    }

    .auth-content h1 {
        font-size: 24px;
    }

    .auth-content p {
        font-size: 14px;
    }

    .auth-input {
        font-size: 16px;
        padding: 12px 16px;
        min-height: 48px;
    }

    .profiles-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 12px;
        width: 100%;
        max-width: 100%;
    }

    .profile-card {
        padding: 16px 12px;
        min-height: 120px;
    }

    .profile-avatar {
        width: 60px;
        height: 60px;
        font-size: 24px;
    }

    .profile-name {
        font-size: 13px;
        word-break: break-word;
    }

    /* Welcome screen on mobile */
    .welcome-screen {
        padding: 20px;
    }

    .welcome-content {
        padding: 20px;
    }

    .welcome-content svg {
        width: 100px;
        height: 100px;
    }

    .welcome-content h1 {
        font-size: 22px;
    }

    .welcome-content p {
        font-size: 14px;
    }

    .btn-lg {
        min-height: 48px;
        font-size: 16px;
    }
}

/* Small mobile phones */
@media (max-width: 480px) {
    .mobile-panel {
        width: 90vw;
        max-width: 90vw;
    }

    .app-header {
        padding: 0 6px;
    }

    .btn-secondary,
    .btn-logout {
        padding: 6px;
        width: 36px;
        height: 36px;
        min-width: 36px;
    }

    .btn-secondary svg,
    .btn-logout svg {
        width: 16px;
        height: 16px;
    }

    .position-card {
        padding: 10px;
        margin: 6px;
    }

    .detail-panel {
        padding: 10px;
    }

    .btn-primary,
    .btn-secondary:not(.header-actions .btn-secondary),
    .btn-danger {
        font-size: 14px;
        padding: 10px 12px;
        min-height: 44px;
    }

    .profiles-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .auth-content {
        padding: 16px;
    }

    /* Mobile tree structure in main panel - prevent overflow */
    .positions-panel {
        width: 100%;
        max-width: 100vw;
        overflow-x: hidden;
        box-sizing: border-box;
        padding: 0 !important;
    }

    .positions-tree {
        width: 100%;
        max-width: 100vw;
        overflow-x: hidden;
        box-sizing: border-box;
        padding: 8px;
    }

    .tree-node {
        width: 100%;
        max-width: 100%;
        overflow: hidden;
        box-sizing: border-box;
        margin-bottom: 2px;
    }

    .tree-header {
        padding: 12px 8px !important;
        min-height: 48px;
        font-size: 14px;
        width: 100%;
        max-width: 100%;
        overflow: hidden;
        box-sizing: border-box;
        display: flex;
        align-items: center;
        gap: 8px;
    }

    .expand-icon {
        font-size: 14px;
        width: 24px;
        min-width: 24px;
        height: 24px;
        flex-shrink: 0;
    }

    .pos-number {
        font-size: 12px;
        padding: 4px 8px;
        min-width: 50px;
        max-width: 80px;
        flex-shrink: 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .pos-short-text {
        font-size: 14px;
        line-height: 1.4;
        flex: 1;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .pos-qty {
        font-size: 13px;
        min-width: 60px;
        max-width: 80px;
        text-align: right;
        flex-shrink: 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Remove indentation on mobile */
    .tree-children {
        margin-left: 0 !important;
        padding-left: 20px !important;
        border-left: 2px solid var(--gray-200);
    }

    /* Show positions tree in main, hide details panel on mobile */
    .content-grid {
        grid-template-columns: 1fr !important;
    }

    .positions-panel {
        display: flex !important;
    }

    .details-panel {
        display: none !important;
    }

    /* Clean panel header for mobile */
    .panel-header {
        padding: 12px 8px !important;
        width: 100%;
        max-width: 100vw;
        overflow: hidden;
        box-sizing: border-box;
    }

    .panel-header h2 {
        font-size: 16px;
        line-height: 1.3;
        margin: 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .detail-row {
        padding: 14px 12px;
        font-size: 15px;
        min-height: 50px;
    }

    .hint-row {
        font-style: italic;
        color: #666;
        border-left: 3px solid #ff9800 !important;
        opacity: 0.75;
    }

    .hint-marker {
        color: #ff9800;
        font-weight: 500;
        font-style: normal;
    }

    .detail-marker {
        color: #2196F3;
        font-weight: 600;
    }

    .detail-label {
        font-size: 14px;
        font-weight: 600;
        margin-bottom: 6px;
    }

    .detail-value {
        font-size: 15px;
        line-height: 1.6;
    }

    /* Notes section */
    .notes-section {
        padding: 16px 12px;
    }

    .note-card {
        padding: 14px;
        margin-bottom: 14px;
        font-size: 15px;
        line-height: 1.6;
    }

    .note-header {
        font-size: 13px;
        margin-bottom: 10px;
    }

    .note-text {
        font-size: 15px;
        line-height: 1.6;
    }

    /* Buttons and inputs */
    button, .btn-primary, .btn-secondary {
        font-size: 15px !important;
        padding: 12px 16px !important;
        min-height: 48px;
        line-height: 1.5;
    }

    input, textarea, select {
        font-size: 16px !important;
        padding: 12px !important;
        min-height: 48px;
        line-height: 1.5;
    }

    textarea {
        min-height: 120px;
        line-height: 1.6;
    }

    /* Filter selects in mobile panel */
    .mobile-panel-content select {
        font-size: 15px;
        padding: 12px;
        min-height: 48px;
        margin-bottom: 16px;
    }

    .mobile-panel-content label {
        font-size: 14px;
        font-weight: 600;
        margin-bottom: 8px;
    }

    /* Rechnung (Invoice) section */
    .invoice-row {
        padding: 14px 12px;
        font-size: 15px;
        min-height: 50px;
    }

    .invoice-label {
        font-size: 14px;
        font-weight: 600;
    }

    .invoice-value {
        font-size: 15px;
    }
}

/* Project Totals */
.project-totals-container {
    background: #5b21b6;
    padding: 12px 20px;
    border-bottom: 1px solid rgba(0,0,0,0.2);
    /* Force sharp rendering - critical fixes */
    transform: translateZ(0) translate3d(0, 0, 0);
    -webkit-transform: translateZ(0) translate3d(0, 0, 0);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    perspective: 1000px;
    -webkit-perspective: 1000px;
    -webkit-font-smoothing: subpixel-antialiased;
    -moz-osx-font-smoothing: auto;
    image-rendering: -webkit-optimize-contrast;
}

.project-totals {
    max-width: 100%;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

.totals-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

.total-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

.total-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: rgba(255, 255, 255, 0.8);
}

.total-value {
    font-size: 18px;
    font-weight: 600;
    color: #ffffff;
    font-variant-numeric: tabular-nums;
    line-height: 1;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.total-value.re-total {
    color: #10b981;
}

.total-value.progress-value {
    color: #fbbf24;
}

@media (max-width: 1200px) {
    .totals-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Skeleton Loading */
.skeleton {
    animation: skeleton-loading 1.5s infinite ease-in-out;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    border-radius: 4px;
}

@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

.skeleton-text {
    height: 16px;
    margin: 4px 0;
}

.skeleton-text.large {
    height: 24px;
}

.skeleton-text.small {
    height: 12px;
}

.skeleton-tree-item {
    padding: 8px 12px;
    margin: 2px 0;
}

.skeleton-detail-section {
    padding: 16px;
    margin: 8px 0;
    height: 100px;
}

.skeleton-table-row {
    height: 40px;
    margin: 2px 0;
}

.skeleton-totals {
    height: 60px;
}

