:root {
    --indigo-600: #4f46e5;
    --indigo-700: #4338ca;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --white: #ffffff;
    --red-500: #ef4444;
    --green-600: #16a34a;
    --border-color: #e5e7eb;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--gray-50);
    color: var(--gray-800);
    line-height: 1.5;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* Typography */
.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gray-900);
}
.logo span {
    color: var(--indigo-600);
}
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-sm { font-size: 0.875rem; }
.text-gray-500 { color: var(--gray-500); }
.text-gray-600 { color: var(--gray-600); }
.text-indigo-600 { color: var(--indigo-600); }

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    font-weight: 600;
    text-align: center;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background-color 0.2s;
}
.btn-primary {
    background-color: var(--indigo-600);
    color: var(--white);
}
.btn-primary:hover {
    background-color: var(--indigo-700);
}
.btn-primary.btn-lg {
    padding: 0.75rem 1.5rem;
    font-size: 1.125rem;
}
.btn-secondary {
    background-color: var(--gray-100);
    color: var(--gray-800);
    border-color: var(--border-color);
}
.btn-secondary:hover {
    background-color: #e5e7eb;
}
.btn-success {
    background-color: var(--green-600);
    color: var(--white);
}
.btn-link {
    background: none;
    border: none;
    color: var(--gray-600);
}
.btn-link:hover {
    color: var(--indigo-600);
}
.btn-link-inline {
    background: none;
    border: none;
    color: var(--indigo-600);
    font-weight: 600;
    cursor: pointer;
    text-decoration: underline;
}
.w-full { width: 100%; }

/* Forms */
.form {
    margin-top: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}
.input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    box-sizing: border-box;
    background-color: var(--white);
    color: var(--gray-900);
}
.input:focus {
    outline: none;
    border-color: var(--indigo-600);
    box-shadow: 0 0 0 1px var(--indigo-600);
}
textarea.input {
    resize: vertical;
}
fieldset {
    border: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
legend {
    font-size: 1.125rem;
    font-weight: 600;
    border-bottom: 1px solid var(--border-color);
    width: 100%;
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
}
.grid-col-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}
.error-message {
    color: var(--red-500);
    font-size: 0.875rem;
    text-align: center;
    margin-top: 1rem;
    display: none;
}
.error-message.show {
    display: block;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 1rem;
    padding-bottom: 1rem;
    background-color: var(--white);
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 1px 2px 0 rgba(0,0,0,0.05);
}

/* Footer */
.footer {
    padding: 2.5rem 0;
    background-color: var(--gray-50);
    color: var(--gray-500);
    text-align: center;
}
.footer .notice {
    background-color: #fffbeb;
    color: #b45309;
    border: 1px solid #fde68a;
    padding: 0.75rem;
    border-radius: 0.375rem;
    margin-bottom: 1rem;
    font-size: 0.875rem;
}


/* Main Views */
.view {
    min-height: 100vh;
}

/* Landing Page */
.hero {
    text-align: center;
    padding: 5rem 0;
    background-color: var(--gray-50);
}
.hero-title {
    font-size: 3rem;
    font-weight: 800;
    letter-spacing: -0.025em;
}
.hero-subtitle {
    margin: 1.5rem auto 0;
    max-width: 42rem;
    font-size: 1.125rem;
    color: var(--gray-600);
}
.hero-cta {
    margin-top: 2rem;
}
.features {
    padding: 5rem 0;
    background-color: var(--white);
}
.section-title {
    font-size: 2rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 4rem;
}
.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 3rem;
}
.feature-item {
    text-align: center;
}
.feature-item h4 {
    font-size: 1.125rem;
    font-weight: 600;
    margin: 1rem 0 0.5rem;
}
.feature-item p {
    color: var(--gray-600);
}


/* Auth Pages */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 2rem;
    box-sizing: border-box;
}
.auth-box {
    background-color: var(--white);
    padding: 2rem;
    border-radius: 0.5rem;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 28rem;
}
.auth-box.wide {
    max-width: 48rem;
}

/* App View */
#app-view .header {
    position: sticky;
    top: 0;
    z-index: 10;
}
.app-main {
    padding-top: 2rem;
    padding-bottom: 2rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}
.card {
    background-color: var(--white);
    padding: 1.5rem;
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px 0 rgba(0,0,0,0.1), 0 1px 2px -1px rgba(0,0,0,0.1);
}
.ai-input-group {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}
.ai-input-group textarea { flex-grow: 1; }
.ai-input-group button { height: fit-content; align-self: flex-start; padding: 0.75rem 1.5rem; }

.invoice-actions {
    display: flex;
    justify-content: flex-end;
}
.invoice-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}
.form-section {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}
#line-items-container {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.line-item {
    display: grid;
    grid-template-columns: 5fr 1fr 2fr 1fr;
    gap: 0.5rem;
    align-items: center;
}
.line-item .input {
    padding: 0.5rem;
}
.line-item button {
    background: none;
    border: none;
    color: var(--red-500);
    cursor: pointer;
}

/* Preview */
.preview-section {
    font-size: 0.8rem;
}
.preview-header {
    display: flex;
    justify-content: space-between;
    border-bottom: 2px solid var(--gray-100);
    padding-bottom: 1rem;
}
.preview-header h2 { font-size: 1.25rem; font-weight: 700; margin: 0; }
.preview-header p { margin: 0.25rem 0; color: var(--gray-500); }
.preview-title {
    font-size: 2.25rem;
    font-weight: 800;
    color: var(--gray-800);
    margin: 0;
}
.preview-client { margin-top: 2rem; }
.preview-client h3 { font-weight: 600; color: var(--gray-500); }
.preview-client p { font-weight: 700; margin: 0.25rem 0; }

.preview-table {
    width: 100%;
    margin-top: 2rem;
    border-collapse: collapse;
}
.preview-table th, .preview-table td {
    padding: 0.75rem;
    text-align: left;
}
.preview-table thead { background-color: var(--gray-50); }
.preview-table th { font-weight: 600; }
.preview-table tbody tr { border-bottom: 1px solid var(--border-color); }
.preview-table td:nth-child(2), .preview-table th:nth-child(2) { text-align: center; }
.preview-table td:nth-child(3), .preview-table th:nth-child(3) { text-align: right; }
.preview-table td:nth-child(4), .preview-table th:nth-child(4) { text-align: right; }

.preview-totals {
    margin-top: 2rem;
    display: flex;
    justify-content: flex-end;
}
.preview-totals > div {
    width: 250px;
}
.preview-totals p {
    display: flex;
    justify-content: space-between;
    margin: 0.5rem 0;
}
.preview-totals p.total {
    font-weight: 700;
    font-size: 1rem;
    border-top: 1px solid var(--border-color);
    padding-top: 0.5rem;
    margin-top: 0.5rem;
}

.preview-notes { margin-top: 2rem; border-top: 1px solid var(--border-color); padding-top: 1rem; }
.preview-notes h4 { font-weight: 600; }
.preview-notes p { white-space: pre-line; }

/* Responsive */
@media (max-width: 992px) {
    .invoice-layout {
        grid-template-columns: 1fr;
    }
}
@media (max-width: 768px) {
    .hero-title {
        font-size: 2.25rem;
    }
    .grid-col-2 {
        grid-template-columns: 1fr;
    }
}
