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

:root {
    --ink: #0a0a0a;
    --paper: #fafaf9;
    --accent: #16a34a;
    --accent-soft: #dcfce7;
    --accent-dark: #15803d;
    --muted: #71717a;
    --border: #e4e4e7;
    --surface: #ffffff;
    --danger: #dc2626;
    --danger-soft: #fef2f2;
    --warning: #f59e0b;
    --warning-soft: #fffbeb;
    --info: #3b82f6;
    --info-soft: #eff6ff;
}

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--paper);
    color: var(--ink);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

.space { font-family: 'Space Grotesk', sans-serif; }

/* ─── NAV ─────────────────────────────── */

nav {
    padding: 1rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 1200px;
    margin: 0 auto;
}
.logo {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 1.25rem;
    letter-spacing: -0.03em;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}
.logo-dot {
    width: 8px;
    height: 8px;
    background: var(--accent);
    border-radius: 50%;
    display: inline-block;
    animation: pulse 2s infinite;
}
@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.8); }
}
.nav-links {
    display: flex;
    align-items: center;
    gap: 1rem;
}
.nav-link {
    font-size: 0.875rem;
    color: var(--muted);
    text-decoration: none;
    cursor: pointer;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    transition: all 0.15s;
}
.nav-link:hover { color: var(--ink); background: var(--accent-soft); }

/* ─── BUTTONS ─────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    border: none;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
}
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-secondary { background: var(--surface); color: var(--ink); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--paper); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #b91c1c; }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--ink); background: var(--paper); }
.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.8rem; }
.btn-lg { padding: 0.75rem 2rem; font-size: 1rem; }

/* ─── HERO (LANDING) ─────────────────── */

.hero {
    max-width: 1200px;
    margin: 0 auto;
    padding: 5rem 2rem 3rem;
    text-align: center;
}
.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--accent-dark);
    background: var(--accent-soft);
    padding: 0.375rem 1rem;
    border-radius: 100px;
    margin-bottom: 1.5rem;
}
.hero h1 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 3.5rem;
    font-weight: 700;
    letter-spacing: -0.04em;
    line-height: 1.1;
    margin-bottom: 1.25rem;
}
.hero h1 span { color: var(--accent); }
.hero p {
    font-size: 1.2rem;
    color: var(--muted);
    max-width: 600px;
    margin: 0 auto 2rem;
}
.hero-cta {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-bottom: 3rem;
}

/* ─── FEATURES ────────────────────────── */

.features {
    max-width: 1200px;
    margin: 0 auto;
    padding: 3rem 2rem;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}
.feature-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.75rem;
}
.feature-icon {
    width: 40px;
    height: 40px;
    background: var(--accent-soft);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    margin-bottom: 1rem;
}
.feature-card h3 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}
.feature-card p {
    font-size: 0.9rem;
    color: var(--muted);
    line-height: 1.5;
}

/* ─── HOW IT WORKS ────────────────────── */

.how-section {
    max-width: 800px;
    margin: 0 auto;
    padding: 4rem 2rem;
    text-align: center;
}
.how-section h2 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 2.5rem;
}
.steps {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    text-align: left;
}
.step {
    display: flex;
    gap: 1.25rem;
    align-items: flex-start;
}
.step-num {
    width: 36px;
    height: 36px;
    min-width: 36px;
    background: var(--accent);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
}
.step h4 { font-weight: 600; margin-bottom: 0.25rem; }
.step p { font-size: 0.9rem; color: var(--muted); }

/* ─── PRICING ─────────────────────────── */

.pricing-section {
    max-width: 500px;
    margin: 0 auto;
    padding: 3rem 2rem 4rem;
    text-align: center;
}
.pricing-card {
    background: var(--surface);
    border: 2px solid var(--accent);
    border-radius: 16px;
    padding: 2.5rem;
    margin-top: 1.5rem;
}
.pricing-card .price {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 3rem;
    font-weight: 700;
}
.pricing-card .price span { font-size: 1rem; color: var(--muted); font-weight: 400; }
.pricing-features {
    list-style: none;
    text-align: left;
    margin: 1.5rem 0;
}
.pricing-features li {
    padding: 0.5rem 0;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.pricing-features li::before {
    content: '\2713';
    color: var(--accent);
    font-weight: 700;
}

/* ─── FOOTER ──────────────────────────── */

footer {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--muted);
}

/* ─── AUTH FORMS ──────────────────────── */

.auth-page {
    max-width: 420px;
    margin: 4rem auto;
    padding: 0 2rem;
}
.auth-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 2rem;
}
.auth-card h2 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}
.auth-card .subtitle {
    color: var(--muted);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}
.form-group {
    margin-bottom: 1rem;
}
.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 0.375rem;
}
.form-group input, .form-group textarea, .form-group select {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.9rem;
    font-family: inherit;
    background: var(--surface);
    transition: border-color 0.15s;
}
.form-group input:focus, .form-group textarea:focus, .form-group select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
.form-group textarea { resize: vertical; min-height: 100px; }
.form-error {
    color: var(--danger);
    font-size: 0.8rem;
    margin-top: 0.5rem;
    display: none;
}
.form-error.visible { display: block; }
.auth-footer {
    text-align: center;
    margin-top: 1rem;
    font-size: 0.85rem;
    color: var(--muted);
}
.auth-footer a { color: var(--accent); text-decoration: none; cursor: pointer; }

/* ─── DASHBOARD ──────────────────────── */

.dash-layout {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem 2rem;
}
.dash-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}
.dash-header h1 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.75rem;
    font-weight: 700;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.25rem;
}
.stat-card .stat-label {
    font-size: 0.8rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}
.stat-card .stat-value {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 2rem;
    font-weight: 700;
}
.stat-card .stat-sub {
    font-size: 0.8rem;
    color: var(--muted);
    margin-top: 0.125rem;
}
.stat-card.accent .stat-value { color: var(--accent); }

/* Ticket List */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}
.section-header h2 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.25rem;
    font-weight: 600;
}
.filters {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.filter-btn {
    padding: 0.375rem 0.875rem;
    border: 1px solid var(--border);
    border-radius: 100px;
    background: var(--surface);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
}
.filter-btn:hover { border-color: var(--accent); }
.filter-btn.active { background: var(--accent); color: white; border-color: var(--accent); }

.ticket-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.ticket-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1rem 1.25rem;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.ticket-item:hover { border-color: var(--accent); box-shadow: 0 2px 8px rgba(0,0,0,0.04); }
.ticket-left { flex: 1; min-width: 0; }
.ticket-from {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.125rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.ticket-subject {
    font-size: 0.85rem;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ticket-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
}
.ticket-time {
    font-size: 0.75rem;
    color: var(--muted);
}

/* Status Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.625rem;
    border-radius: 100px;
    font-size: 0.75rem;
    font-weight: 500;
}
.badge-resolved { background: var(--accent-soft); color: var(--accent-dark); }
.badge-escalated { background: var(--warning-soft); color: #92400e; }
.badge-pending { background: var(--info-soft); color: #1d4ed8; }

/* Confidence Bar */
.confidence {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.75rem;
}
.confidence-bar {
    width: 50px;
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
}
.confidence-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s;
}
.confidence-high { background: var(--accent); }
.confidence-mid { background: var(--warning); }
.confidence-low { background: var(--danger); }

/* ─── TICKET DETAIL ──────────────────── */

.ticket-detail {
    max-width: 800px;
    margin: 0 auto;
}
.back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.85rem;
    color: var(--muted);
    cursor: pointer;
    margin-bottom: 1rem;
}
.back-link:hover { color: var(--ink); }
.detail-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.75rem;
    margin-bottom: 1rem;
}
.detail-card h3 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
}
.detail-meta {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
    font-size: 0.85rem;
    color: var(--muted);
    margin-bottom: 1rem;
}
.detail-body {
    font-size: 0.9rem;
    line-height: 1.7;
    white-space: pre-wrap;
}
.ai-response {
    background: var(--accent-soft);
    border: 1px solid #bbf7d0;
    border-radius: 10px;
    padding: 1.25rem;
    margin-bottom: 1rem;
}
.ai-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}
.ai-label {
    font-weight: 600;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.375rem;
}
.ai-reasoning {
    font-size: 0.8rem;
    color: var(--muted);
    font-style: italic;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid #bbf7d0;
}
.actions-bar {
    display: flex;
    gap: 0.75rem;
    margin-top: 1rem;
}
.reply-box {
    margin-top: 1rem;
}
.reply-box textarea {
    width: 100%;
    min-height: 120px;
    padding: 0.875rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.9rem;
    resize: vertical;
    margin-bottom: 0.75rem;
}

/* ─── KNOWLEDGE BASE ─────────────────── */

.kb-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
}
.kb-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.25rem;
}
.kb-card h4 {
    font-weight: 600;
    margin-bottom: 0.375rem;
}
.kb-card .kb-meta {
    font-size: 0.8rem;
    color: var(--muted);
    margin-bottom: 0.5rem;
}
.kb-card .kb-preview {
    font-size: 0.85rem;
    color: var(--muted);
    line-height: 1.5;
    max-height: 4.5em;
    overflow: hidden;
}

/* ─── MODAL ──────────────────────────── */

.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 2rem;
}
.modal {
    background: var(--surface);
    border-radius: 12px;
    padding: 2rem;
    max-width: 600px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
}
.modal h3 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

/* ─── EMPTY STATE ─────────────────────── */

.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--muted);
}
.empty-state .empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}
.empty-state h3 {
    font-family: 'Space Grotesk', sans-serif;
    color: var(--ink);
    margin-bottom: 0.5rem;
}

/* ─── TOAST ──────────────────────────── */

.toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.toast {
    background: var(--ink);
    color: white;
    padding: 0.75rem 1.25rem;
    border-radius: 8px;
    font-size: 0.85rem;
    animation: slideIn 0.2s ease-out;
}
@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ─── LOADING ─────────────────────────── */

.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem;
}
.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── RESPONSIVE ──────────────────────── */

@media (max-width: 768px) {
    .hero h1 { font-size: 2.25rem; }
    .hero-cta { flex-direction: column; align-items: center; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .dash-header { flex-direction: column; gap: 1rem; align-items: flex-start; }
    nav { padding: 1rem; }
    .features { grid-template-columns: 1fr; }
    footer { flex-direction: column; gap: 0.5rem; }
}
