* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
    --primary: #10b981;
    --primary-dark: #059669;
    --secondary: #1e293b;
    --text: #334155;
    --text-light: #64748b;
    --bg: #fff;
    --bg-alt: #f8fafc;
    --border: #e2e8f0;
}
html { scroll-behavior: smooth; }
body { font-family: 'Inter', sans-serif; line-height: 1.6; color: var(--text); background: var(--bg); }
.container { max-width: 1200px; margin: 0 auto; padding: 0 24px; }
h1, h2, h3, h4 { color: var(--secondary); font-weight: 700; }
h1 { font-size: clamp(2.25rem, 5vw, 3rem); }
h2 { font-size: 2rem; text-align: center; margin-bottom: 16px; }
.hidden { display: none !important; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; padding: 12px 24px; border-radius: 8px; font-weight: 600; text-decoration: none; cursor: pointer; transition: all 0.2s; border: none; font-size: 1rem; }
.btn-sm { padding: 8px 16px; font-size: 0.875rem; }
.btn-large { padding: 16px 32px; font-size: 1.1rem; }
.btn-full { width: 100%; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:disabled { background: #94a3b8; cursor: not-allowed; }
.btn-outline { background: transparent; border: 2px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }

/* Navbar */
.navbar { position: fixed; top: 0; left: 0; right: 0; background: rgba(255,255,255,0.95); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); z-index: 1000; padding: 16px 0; }
.navbar .container { display: flex; justify-content: space-between; align-items: center; }
.logo { font-size: 1.5rem; font-weight: 800; color: var(--secondary); text-decoration: none; }
.nav-links { display: flex; align-items: center; gap: 24px; }
.nav-links a:not(.btn) { color: var(--text-light); text-decoration: none; font-weight: 500; }

/* Hero */
.hero { padding: 140px 0 80px; background: var(--bg-alt); text-align: center; }
.badge { display: inline-block; padding: 6px 14px; background: rgba(16,185,129,0.1); color: var(--primary); border-radius: 100px; font-size: 0.875rem; font-weight: 600; margin-bottom: 20px; }
.hero-subtitle { font-size: 1.2rem; color: var(--text-light); max-width: 600px; margin: 20px auto 32px; }
.hero-cta { margin-bottom: 48px; display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; }
.hero-stats { display: flex; justify-content: center; gap: 48px; }
.stat-number { display: block; font-size: 1.75rem; font-weight: 800; color: var(--primary); }
.stat-label { font-size: 0.875rem; color: var(--text-light); }

/* AI Create Section */
.ai-create-section { padding: 60px 0; background: linear-gradient(135deg, #ecfdf5 0%, #f0fdf4 100%); }
.ai-create-box {
    background: white;
    border: 2px solid var(--primary);
    border-radius: 16px;
    padding: 40px;
    max-width: 700px;
    margin: 0 auto;
    text-align: center;
    position: relative;
}
.ai-invoice-input {
    width: 100%;
    min-height: 100px;
    padding: 16px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    margin-bottom: 16px;
    resize: vertical;
}
.ai-invoice-input:focus { outline: none; border-color: var(--primary); }

/* Template Gallery Section */
.templates-section { padding: 80px 0; background: var(--bg); }
.section-subtitle { text-align: center; color: var(--text-light); margin-bottom: 32px; }

/* AI Generator Box */
.ai-generator-box {
    background: linear-gradient(135deg, #f0fdf4 0%, #ecfdf5 100%);
    border: 2px solid var(--primary);
    border-radius: 16px;
    padding: 32px;
    margin-bottom: 40px;
    text-align: center;
    position: relative;
}
.ai-badge {
    position: absolute;
    top: -12px;
    left: 24px;
    background: var(--primary);
    color: white;
    padding: 4px 12px;
    border-radius: 100px;
    font-size: 0.75rem;
    font-weight: 600;
}
.ai-generator-box h3 { margin-bottom: 8px; }
.ai-generator-box p { color: var(--text-light); margin-bottom: 20px; }
.ai-input-group { display: flex; gap: 12px; max-width: 600px; margin: 0 auto; }
.ai-input {
    flex: 1;
    padding: 14px 18px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    outline: none;
}
.ai-input:focus { border-color: var(--primary); }
.ai-loading { margin-top: 16px; color: var(--primary); font-weight: 500; }

/* Template Filters */
.template-filters { display: flex; gap: 8px; justify-content: center; margin-bottom: 32px; flex-wrap: wrap; }
.filter-btn {
    padding: 8px 20px;
    border: 2px solid var(--border);
    border-radius: 100px;
    background: white;
    color: var(--text);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}
.filter-btn:hover { border-color: var(--primary); color: var(--primary); }
.filter-btn.active { background: var(--primary); border-color: var(--primary); color: white; }

/* Template Grid */
.template-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 24px; }
.template-card {
    background: white;
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}
.template-card:hover { border-color: var(--primary); transform: translateY(-4px); box-shadow: 0 10px 30px rgba(0,0,0,0.1); }
.template-card.selected { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(16,185,129,0.2); }
.template-preview {
    height: 120px;
    border-radius: 8px;
    border: 1px solid var(--border);
    margin-bottom: 12px;
    overflow: hidden;
}
.template-preview-header { padding: 8px 12px; font-size: 10px; font-weight: 700; letter-spacing: 1px; }
.template-preview-content { padding: 12px; }
.template-preview-line { height: 6px; border-radius: 3px; margin-bottom: 8px; }
.template-preview-line.short { width: 60%; }
.template-preview-accent { height: 4px; width: 30%; border-radius: 2px; margin-top: 12px; }
.template-info h4 { font-size: 0.95rem; margin-bottom: 4px; }
.template-info p { font-size: 0.8rem; color: var(--text-light); }
.ai-badge-small {
    position: absolute;
    top: 8px;
    right: 8px;
    background: var(--primary);
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 600;
}

/* Features */
.features { padding: 80px 0; background: var(--bg-alt); }
.features-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; margin-top: 48px; }
.feature-card { padding: 28px; background: white; border: 1px solid var(--border); border-radius: 12px; transition: all 0.3s; }
.feature-card:hover { border-color: var(--primary); transform: translateY(-4px); }
.feature-icon { font-size: 2rem; margin-bottom: 12px; }
.feature-card h3 { margin-bottom: 8px; font-size: 1.1rem; }
.feature-card p { color: var(--text-light); font-size: 0.95rem; }

/* Generator */
.generator { padding: 80px 0; background: var(--bg); }
.selected-template-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 32px;
    padding: 16px;
    background: var(--bg-alt);
    border-radius: 8px;
}
.template-name { font-weight: 700; color: var(--primary); }
.generator-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; align-items: start; }

/* Invoice Form */
.invoice-form { background: white; padding: 32px; border-radius: 16px; border: 1px solid var(--border); }
.form-section { margin-bottom: 24px; padding-bottom: 24px; border-bottom: 1px solid var(--border); }
.form-section:last-of-type { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.form-section h4 { margin-bottom: 16px; font-size: 1rem; color: var(--primary); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-weight: 500; margin-bottom: 6px; font-size: 0.875rem; }
.form-group input, .form-group textarea, .form-group select {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
}
.form-group input:focus, .form-group textarea:focus, .form-group select:focus {
    outline: none;
    border-color: var(--primary);
}

/* Form Actions */
.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}
.form-actions .btn { flex: 1; }
@media (max-width: 500px) {
    .form-actions { flex-direction: column; }
}

/* Logo Upload */
.logo-upload { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.logo-input { display: none; }
.logo-preview {
    width: 150px;
    height: 80px;
    border: 2px dashed var(--border);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--text-light);
    transition: all 0.2s;
}
.logo-preview:hover { border-color: var(--primary); color: var(--primary); }

/* AI Suggest Row */
.ai-suggest-row { display: flex; gap: 8px; margin-bottom: 16px; }
.business-type-input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.875rem;
}
.business-type-input:focus { outline: none; border-color: var(--primary); }

/* Line Items */
.line-items-header {
    display: grid;
    grid-template-columns: 2fr 80px 100px 100px 40px;
    gap: 8px;
    padding: 8px 0;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-light);
    text-transform: uppercase;
}
.line-item {
    display: grid;
    grid-template-columns: 2fr 80px 100px 100px 40px;
    gap: 8px;
    margin-bottom: 8px;
    align-items: center;
}
.line-item input { padding: 10px; }
.item-amount { font-weight: 600; text-align: right; font-size: 0.9rem; }
.btn-remove-item {
    width: 32px;
    height: 32px;
    border: none;
    background: #fee2e2;
    color: #dc2626;
    border-radius: 6px;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.btn-remove-item:hover { background: #fecaca; }

/* Totals */
.totals-grid { background: var(--bg-alt); padding: 16px; border-radius: 8px; }
.total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
}
.total-row label { display: flex; align-items: center; gap: 8px; }
.tax-input, .discount-input { width: 80px; padding: 6px 8px; font-size: 0.875rem; }
.total-final { font-size: 1.25rem; font-weight: 700; border-top: 2px solid var(--secondary); padding-top: 12px; margin-top: 8px; }

/* Invoice Preview */
.invoice-preview {
    background: white;
    padding: 32px;
    border-radius: 16px;
    border: 2px solid var(--border);
    position: sticky;
    top: 100px;
    font-size: 0.9rem;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
}
.preview-logo { margin-bottom: 16px; }
.preview-logo img { max-height: 60px; }
.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 2px solid var(--primary);
}
.preview-header h3 { color: var(--primary); font-size: 1.5rem; }
.preview-tagline { color: var(--text-light); font-size: 0.85rem; margin-top: 4px; }
.preview-meta { text-align: right; font-size: 0.85rem; color: var(--text-light); }
.preview-number { font-weight: 600; color: var(--secondary); margin-bottom: 4px; }
.preview-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-bottom: 24px; }
.preview-parties strong { font-size: 0.75rem; text-transform: uppercase; color: var(--text-light); }
.preview-parties p { white-space: pre-line; font-size: 0.85rem; margin-top: 4px; }
.preview-service-title {
    background: var(--bg-alt);
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 0.9rem;
}
.preview-items { margin-bottom: 16px; }
.preview-item-header, .preview-item { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 8px; padding: 8px 0; font-size: 0.85rem; }
.preview-item-header { font-weight: 600; border-bottom: 1px solid var(--border); }
.preview-totals { border-top: 1px solid var(--border); padding-top: 12px; }
.preview-total-row { display: flex; justify-content: space-between; padding: 6px 0; font-size: 0.9rem; }
.preview-total-final { font-weight: 700; font-size: 1.1rem; border-top: 2px solid var(--secondary); padding-top: 8px; margin-top: 8px; }
.preview-payment { margin-top: 24px; padding: 16px; background: var(--bg-alt); border-radius: 8px; font-size: 0.85rem; }
.preview-terms { margin-top: 16px; padding: 16px; background: var(--bg-alt); border-radius: 8px; font-size: 0.8rem; white-space: pre-line; }
.preview-footer { text-align: center; margin-top: 24px; color: var(--text-light); font-size: 0.85rem; font-weight: 500; }

/* Footer */
.footer { padding: 40px 0; text-align: center; color: var(--text-light); background: var(--bg-alt); }

/* Responsive */
@media (max-width: 1024px) {
    .generator-grid { grid-template-columns: 1fr; }
    .invoice-preview { position: static; max-height: none; }
    .features-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
    .nav-links a:not(.btn) { display: none; }
    .hero-stats { flex-direction: column; gap: 16px; }
    .features-grid { grid-template-columns: 1fr; }
    .line-items-header { display: none; }
    .line-item { grid-template-columns: 1fr; gap: 4px; padding: 12px; background: var(--bg-alt); border-radius: 8px; margin-bottom: 12px; }
    .line-item input { width: 100%; }
    .item-amount { text-align: left; padding: 8px 0; }
    .btn-remove-item { width: 100%; justify-content: center; }
    .template-grid { grid-template-columns: repeat(2, 1fr); }
    .ai-input-group { flex-direction: column; }
    .hero-cta { flex-direction: column; align-items: center; }
    .form-row { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
    .template-grid { grid-template-columns: 1fr; }
}
