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

:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --success: #059669;
    --warning: #d97706;
    --danger: #dc2626;
    --bg: #f0f4f8;
    --card-bg: #ffffff;
    --text: #1e293b;
    --text-secondary: #64748b;
    --border: #e2e8f0;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

.app-container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.app-header {
    text-align: center;
    padding: 40px 0 24px;
}

.app-header h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 8px;
}

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

.app-main {
    flex: 1;
    padding-bottom: 40px;
}

.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 24px;
    overflow: hidden;
}

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

.card-header h2 {
    font-size: 1.2rem;
    font-weight: 600;
}

.card-body {
    padding: 24px;
}

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

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

.file-drop-zone {
    border: 2px dashed var(--border);
    border-radius: 8px;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.file-drop-zone:hover,
.file-drop-zone.drag-over {
    border-color: var(--primary);
    background: #eff6ff;
}

.file-drop-zone input[type="file"] {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.drop-zone-content {
    pointer-events: none;
}

.drop-icon {
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0;
    color: var(--primary);
    display: block;
    margin-bottom: 12px;
}

.file-hint {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 8px;
}

.file-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-top: 12px;
}

.file-info:last-child {
    margin-bottom: 0;
}

.file-list {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 8px;
    transition: background 0.2s;
}

.file-item:hover {
    background: #f1f5f9;
}

.file-item-icon {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--primary);
    margin-right: 10px;
    flex-shrink: 0;
    min-width: 32px;
}

.file-item-name {
    flex: 1;
    font-weight: 500;
    color: var(--text);
    font-size: 0.9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-item-size {
    color: var(--text-secondary);
    font-size: 0.8rem;
    margin-left: 12px;
    flex-shrink: 0;
}

.file-item-remove {
    background: none;
    border: none;
    font-size: 1.3rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0 4px;
    margin-left: 8px;
    line-height: 1;
    flex-shrink: 0;
}

.file-item-remove:hover {
    color: var(--danger);
}

.file-name {
    font-weight: 500;
    color: var(--primary);
}

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

.btn-remove:hover {
    color: var(--danger);
}

.form-row {
    display: flex;
    gap: 20px;
    align-items: flex-end;
}

.form-row .form-group {
    flex: 1;
    margin-bottom: 0;
}

.form-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.95rem;
    transition: border-color 0.2s;
    outline: none;
}

.form-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.checkbox-group {
    display: flex;
    align-items: flex-end;
    padding-bottom: 0;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: 400;
    padding: 10px 0;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}

.btn-primary {
    width: 100%;
    padding: 14px 24px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

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

.btn-primary:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.btn-text, .btn-loading {
    display: flex;
    align-items: center;
    gap: 8px;
}

.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.project-badge {
    background: #eff6ff;
    color: var(--primary);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
}

.progress-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 10px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 600;
}

.progress-track {
    width: 100%;
    height: 14px;
    background: #e2e8f0;
    border-radius: 999px;
    overflow: hidden;
}

.progress-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #2563eb, #059669);
    transition: width 0.35s ease;
}

.progress-message {
    margin-top: 14px;
    color: var(--text);
    font-weight: 500;
}

.progress-file {
    margin-top: 6px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    min-height: 1.4em;
}

.summary-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.summary-card {
    padding: 20px;
    border-radius: 8px;
    text-align: center;
}

.summary-card.material {
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
}

.summary-card.labor {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
}

.summary-card.total {
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.summary-label {
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 8px;
    opacity: 0.85;
}

.summary-value {
    font-size: 1.8rem;
    font-weight: 700;
}

.table-container {
    overflow-x: auto;
    margin-bottom: 16px;
}

.estimate-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.estimate-table th {
    background: #f8fafc;
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

.estimate-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}

.estimate-table tr:hover td {
    background: #f8fafc;
}

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

.type-badge.material {
    background: #dbeafe;
    color: #1d4ed8;
}

.type-badge.labor {
    background: #fef3c7;
    color: #92400e;
}

.notes-section {
    margin-top: 20px;
    padding: 16px;
    background: #f8fafc;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.notes-section h3 {
    font-size: 1rem;
    margin-bottom: 8px;
    color: var(--text);
}

.notes-section p {
    color: var(--text-secondary);
    line-height: 1.6;
    white-space: pre-wrap;
}

.disclaimer-section {
    margin-top: 20px;
    padding: 16px;
    background: #fffbeb;
    border-radius: 8px;
    border: 1px solid #fde68a;
}

.disclaimer-section h3 {
    font-size: 1rem;
    margin-bottom: 8px;
    color: #92400e;
}

.disclaimer-section p {
    color: #78350f;
    font-size: 0.9rem;
    line-height: 1.6;
    white-space: pre-wrap;
}

.action-bar {
    display: flex;
    gap: 12px;
    margin-top: 20px;
    justify-content: flex-end;
}

.btn-secondary {
    padding: 10px 20px;
    background: white;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
}

.btn-secondary.danger {
    color: var(--danger);
}

.btn-secondary.danger:hover {
    border-color: #fecaca;
    background: #fef2f2;
}

.result-error {
    padding: 16px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    color: var(--danger);
    margin-bottom: 20px;
}

.app-footer {
    text-align: center;
    padding: 20px 0;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

@media (max-width: 768px) {
    .form-row {
        flex-direction: column;
        gap: 16px;
    }

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

    .summary-cards {
        grid-template-columns: 1fr;
    }

    .app-header h1 {
        font-size: 1.5rem;
    }
}
