:root {
    --blue-900: #1e3a5f;
    --blue-700: #2563eb;
    --blue-600: #3b82f6;
    --blue-100: #dbeafe;
    --blue-50: #eff6ff;
    --gray-900: #111827;
    --gray-700: #374151;
    --gray-500: #6b7280;
    --gray-300: #d1d5db;
    --gray-100: #f3f4f6;
    --gray-50: #f9fafb;
    --green-600: #059669;
    --green-100: #d1fae5;
    --red-600: #dc2626;
    --red-100: #fee2e2;
    --yellow-600: #d97706;
    --yellow-100: #fef3c7;
    --white: #ffffff;
    --radius: 8px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: var(--gray-900);
    background: var(--gray-50);
    line-height: 1.6;
}

a { color: var(--blue-700); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Layout */
.nav {
    background: var(--blue-900);
    color: var(--white);
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
    position: sticky;
    top: 0;
    z-index: 100;
}
.nav-brand { font-size: 18px; font-weight: 700; color: var(--white); }
.nav-brand:hover { text-decoration: none; }
.nav-links { display: flex; gap: 16px; align-items: center; }
.nav-links a { color: var(--blue-100); font-size: 14px; }
.nav-links a:hover { color: var(--white); text-decoration: none; }

.container { max-width: 960px; margin: 0 auto; padding: 32px 24px; }
.container-wide { max-width: 1200px; margin: 0 auto; padding: 32px 24px; }

/* Cards */
.card {
    background: var(--white);
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 16px;
}
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}
.card h2 { font-size: 20px; color: var(--blue-900); }
.card h3 { font-size: 16px; color: var(--gray-700); margin-bottom: 8px; }

/* Buttons */
.btn {
    display: inline-block;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: background 0.15s;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--blue-700); color: var(--white); }
.btn-primary:hover { background: var(--blue-900); }
.btn-secondary { background: var(--gray-100); color: var(--gray-700); border: 1px solid var(--gray-300); }
.btn-secondary:hover { background: var(--gray-300); }
.btn-success { background: var(--green-600); color: var(--white); }
.btn-success:hover { opacity: 0.9; }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-block { display: block; width: 100%; }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 4px;
}
.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: inherit;
}
.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--blue-600);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}
.form-group textarea { min-height: 100px; resize: vertical; }
.form-hint { font-size: 12px; color: var(--gray-500); margin-top: 2px; }

/* Status badges */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}
.badge-pending { background: var(--yellow-100); color: var(--yellow-600); }
.badge-generating { background: var(--blue-100); color: var(--blue-700); }
.badge-completed { background: var(--green-100); color: var(--green-600); }
.badge-failed { background: var(--red-100); color: var(--red-600); }

/* Grid */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }

/* Chat */
.chat-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 200px);
    min-height: 400px;
}
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: var(--gray-50);
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
}
.chat-msg {
    margin-bottom: 12px;
    padding: 10px 14px;
    border-radius: var(--radius);
    max-width: 80%;
    word-wrap: break-word;
}
.chat-msg-user {
    background: var(--blue-100);
    margin-left: auto;
    text-align: right;
}
.chat-msg-ai {
    background: var(--white);
    border: 1px solid var(--gray-300);
}
.chat-msg-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-500);
    margin-bottom: 4px;
}
.chat-input {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}
.chat-input input { flex: 1; }

/* Document content preview */
.doc-content {
    background: var(--gray-50);
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    padding: 24px;
    white-space: pre-wrap;
    font-size: 14px;
    line-height: 1.7;
    max-height: 600px;
    overflow-y: auto;
}

/* Hero section */
.hero {
    text-align: center;
    padding: 60px 24px;
    background: linear-gradient(135deg, var(--blue-900), var(--blue-700));
    color: var(--white);
}
.hero h1 { font-size: 36px; margin-bottom: 12px; }
.hero p { font-size: 18px; opacity: 0.9; max-width: 600px; margin: 0 auto 24px; }

/* Features grid */
.feature-card {
    background: var(--white);
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    padding: 24px;
    text-align: center;
}
.feature-icon { font-size: 32px; margin-bottom: 12px; }
.feature-card h3 { color: var(--blue-900); margin-bottom: 8px; }
.feature-card p { color: var(--gray-500); font-size: 14px; }

/* Footer */
.footer {
    text-align: center;
    padding: 24px;
    color: var(--gray-500);
    font-size: 13px;
    border-top: 1px solid var(--gray-300);
    margin-top: 48px;
}
.footer a { color: var(--gray-500); margin: 0 8px; }

/* Doc type selector */
.doc-type-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.doc-type-btn {
    display: block;
    padding: 16px;
    background: var(--white);
    border: 2px solid var(--gray-300);
    border-radius: var(--radius);
    text-align: center;
    font-weight: 600;
    color: var(--gray-700);
    transition: border-color 0.15s;
}
.doc-type-btn:hover {
    border-color: var(--blue-600);
    color: var(--blue-700);
    text-decoration: none;
}
.doc-type-btn small { display: block; font-weight: 400; color: var(--gray-500); margin-top: 4px; font-size: 12px; }

/* Spinner */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid var(--gray-300);
    border-top-color: var(--blue-600);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Responsive */
@media (max-width: 640px) {
    .container { padding: 16px; }
    .hero { padding: 40px 16px; }
    .hero h1 { font-size: 28px; }
    .nav { padding: 0 12px; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .doc-type-grid { grid-template-columns: 1fr 1fr; }
}
