/* SiftRAG — Minimal SaaS UI */
:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --danger: #dc2626;
    --success: #16a34a;
    --bg: #f8fafc;
    --card-bg: #fff;
    --border: #e2e8f0;
    --text: #1e293b;
    --muted: #64748b;
    --radius: 6px;
    --max-w: 960px;
}

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

body {
    font-family: system-ui, -apple-system, sans-serif;
    color: var(--text);
    background: var(--bg);
    line-height: 1.6;
}

.container { max-width: var(--max-w); margin: 0 auto; padding: 0 1rem; }

/* Navbar */
.navbar { background: var(--card-bg); border-bottom: 1px solid var(--border); padding: .75rem 0; }
.navbar .container { display: flex; align-items: center; justify-content: space-between; }
.logo { font-weight: 700; font-size: 1.25rem; color: var(--primary); text-decoration: none; }
.nav-links { display: flex; align-items: center; gap: .75rem; }
.nav-links a { color: var(--text); text-decoration: none; font-size: .9rem; }
.nav-links a:hover { color: var(--primary); }

/* Buttons */
.btn {
    display: inline-block; padding: .5rem 1rem; border-radius: var(--radius);
    font-size: .9rem; font-weight: 500; text-decoration: none; cursor: pointer;
    border: 1px solid transparent; transition: all .15s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { border-color: var(--border); background: transparent; color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: .25rem .5rem; font-size: .8rem; }
.btn-lg { padding: .75rem 1.5rem; font-size: 1rem; }
.btn-block { display: block; width: 100%; text-align: center; }

/* Alerts */
.alert { padding: .75rem 1rem; border-radius: var(--radius); margin: 1rem 0; font-size: .9rem; }
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

/* Forms */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-weight: 500; margin-bottom: .25rem; font-size: .9rem; }
.form-group input, .form-group select, .form-group textarea {
    width: 100%; padding: .5rem .75rem; border: 1px solid var(--border); border-radius: var(--radius);
    font-size: .9rem; background: var(--card-bg);
}
.form-group input:focus, .form-group select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px rgba(37,99,235,.15); }

.auth-form { max-width: 400px; margin: 3rem auto; }
.auth-form h2 { margin-bottom: 1.5rem; }
.auth-links { text-align: center; margin-top: 1rem; font-size: .9rem; color: var(--muted); }
.auth-links a { color: var(--primary); }

.inline-form { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.inline-form input, .inline-form select { flex: 1; min-width: 120px; padding: .35rem .5rem; border: 1px solid var(--border); border-radius: var(--radius); font-size: .85rem; }

/* Cards */
.card {
    background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 1rem; margin-bottom: .5rem; transition: box-shadow .15s;
}
.card:hover { box-shadow: 0 2px 8px rgba(0,0,0,.06); }
.card a { text-decoration: none; color: inherit; }
.card h4 { margin-bottom: .25rem; }
.card small { color: var(--muted); }

.item-card {
    display: flex; justify-content: space-between; align-items: center;
    background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius);
    padding: .75rem 1rem; margin-bottom: .5rem;
}
.item-info { display: flex; flex-direction: column; gap: .15rem; }
.item-actions { display: flex; gap: .5rem; }

/* Badges */
.badge { display: inline-block; padding: .1rem .4rem; border-radius: 3px; font-size: .75rem; font-weight: 500; background: var(--border); color: var(--text); }
.badge-success { background: #dcfce7; color: #166534; }
.badge-danger { background: #fef2f2; color: #991b1b; }
.badge-muted { background: #f1f5f9; color: var(--muted); }

/* Sections */
.section { margin: 2rem 0; }
.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.section h3 { margin-bottom: .5rem; }

/* Hero */
.hero { text-align: center; padding: 3rem 0; }
.hero h1 { font-size: 2.5rem; margin-bottom: .5rem; }
.lead { font-size: 1.1rem; color: var(--muted); max-width: 600px; margin: 0 auto 1.5rem; }
.hero-actions { display: flex; gap: .75rem; justify-content: center; }

/* Features */
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 1.5rem; padding: 2rem 0; }
.feature { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; }
.feature h3 { margin-bottom: .5rem; }
.feature p { color: var(--muted); font-size: .9rem; }

/* Dashboard */
.dashboard-stats { display: flex; gap: 1rem; margin-bottom: 2rem; }
.stat-card { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.5rem; flex: 1; }
.stat-label { display: block; font-size: .8rem; color: var(--muted); }
.stat-value { display: block; font-size: 1.5rem; font-weight: 700; }

/* Pricing */
.pricing-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 1.5rem; }
.pricing-card { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; text-align: center; }
.pricing-card h3 { margin-bottom: .5rem; }
.price { font-size: 1.5rem; font-weight: 700; margin-bottom: 1rem; }
.pricing-card ul { list-style: none; margin-bottom: 1.5rem; text-align: left; }
.pricing-card li { padding: .25rem 0; font-size: .9rem; color: var(--muted); }

/* Tabs */
.tabs { display: flex; gap: 0; border-bottom: 2px solid var(--border); margin-bottom: 1.5rem; }
.tab { padding: .5rem 1rem; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -2px; font-size: .9rem; }
.tab:hover, .tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* Search results */
.search-bar { display: flex; gap: .5rem; margin-bottom: 1rem; }
.search-bar input { flex: 1; padding: .5rem .75rem; border: 1px solid var(--border); border-radius: var(--radius); font-size: .9rem; }
.result-card { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; margin-bottom: .5rem; }
.result-card h4 { margin-bottom: .25rem; }
.chunk-text { font-size: .9rem; color: var(--text); margin-bottom: .5rem; }
.source-url { color: var(--primary); display: block; margin-bottom: .25rem; }
.score { color: var(--muted); }

/* Dossier header */
.dossier-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }
.dossier-actions { display: flex; gap: .5rem; }

/* HTMX */
.htmx-indicator { display: none; color: var(--muted); font-style: italic; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: inline; }

.empty { color: var(--muted); font-style: italic; padding: 1rem 0; }

/* Footer */
.footer { text-align: center; padding: 2rem 0; color: var(--muted); font-size: .8rem; border-top: 1px solid var(--border); margin-top: 3rem; }
.footer-links { display: flex; justify-content: center; gap: 1.5rem; margin-bottom: .5rem; }
.footer-links a { color: var(--muted); text-decoration: none; font-size: .8rem; }
.footer-links a:hover { color: var(--primary); }

/* Legal pages */
.legal-content { max-width: 720px; margin: 2rem auto; line-height: 1.8; }
.legal-content h1 { font-size: 1.75rem; margin-bottom: 1rem; }
.legal-content h2 { font-size: 1.15rem; margin-top: 2rem; margin-bottom: .5rem; color: var(--text); }
.legal-content p { margin-bottom: .75rem; color: var(--text); font-size: .92rem; }
.legal-content ul { margin: .5rem 0 1rem 1.5rem; }
.legal-content li { margin-bottom: .35rem; font-size: .92rem; color: var(--text); }
.legal-content a { color: var(--primary); }
.legal-update { color: var(--muted); font-size: .85rem; font-style: italic; margin-bottom: 1.5rem; }

/* Checkbox */
.checkbox-label { display: flex; align-items: flex-start; gap: .5rem; font-size: .88rem; cursor: pointer; }
.checkbox-label input[type="checkbox"] { width: auto; margin-top: .25rem; }

/* Admin */
.admin-nav { display: flex; gap: .5rem; margin: 1rem 0; }

/* Email thread tree */
.email-thread { max-width: 860px; }
.thread-header { display: flex; align-items: baseline; gap: 1rem; margin-bottom: 1.5rem; }
.back-link { font-size: .85rem; color: var(--muted); text-decoration: none; }
.back-link:hover { color: var(--primary); }
.thread-tree { border-left: 2px solid var(--border); padding-left: 0; margin-left: .5rem; }
.thread-node { display: flex; gap: .5rem; margin-bottom: 1.25rem; }
.thread-node--focus > .thread-email { background: var(--surface); border-left: 3px solid var(--primary); padding-left: .75rem; }
.thread-connector { color: var(--muted); font-family: monospace; font-size: 1rem; white-space: nowrap; padding-top: .1rem; }
.tree-glyph { color: var(--muted); }
.thread-email { flex: 1; }
.email-meta { display: flex; flex-wrap: wrap; gap: .5rem; font-size: .82rem; color: var(--muted); margin-bottom: .4rem; }
.email-date { font-family: monospace; }
.email-from { font-weight: 600; color: var(--text); }
.email-subject { font-style: italic; }
.claim-list { margin: 0; padding: 0; list-style: none; }
.claim-item { font-size: .88rem; padding: .2rem 0 .2rem .75rem; border-left: 2px solid var(--border); margin-bottom: .25rem; color: var(--text); line-height: 1.5; }
.no-claims { color: var(--muted); font-size: .82rem; font-style: italic; }
.thread-link { font-size: .82rem; color: var(--primary); text-decoration: none; display: inline-block; margin-top: .35rem; }
.thread-link:hover { text-decoration: underline; }

/* Email thread enriched */
.email-header-row { display: flex; justify-content: space-between; align-items: flex-start; gap: .5rem; margin-bottom: .4rem; }
.email-indicators { display: flex; gap: .25rem; flex-shrink: 0; }
.email-to { color: var(--muted); }
.email-body-toggle { margin: .5rem 0; }
.email-body-toggle summary { cursor: pointer; }
.email-body-iframe { width: 100%; min-height: 200px; max-height: 500px; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; margin-top: .5rem; }
.email-body-text { font-size: .82rem; white-space: pre-wrap; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: .75rem; max-height: 400px; overflow-y: auto; margin-top: .5rem; }
.email-preview { font-size: .82rem; color: var(--muted); font-style: italic; margin: .25rem 0; }
.email-attachments { display: flex; flex-wrap: wrap; gap: .35rem; margin: .5rem 0; }
.attachment-chip { font-size: .78rem; background: var(--bg); border: 1px solid var(--border); border-radius: 12px; padding: .15rem .5rem; white-space: nowrap; }
.attachment-chip small { color: var(--muted); }
.claims-accordion { margin: .5rem 0; }
.claims-toggle { cursor: pointer; font-size: .82rem; color: var(--primary); font-weight: 600; }
.claim-text { flex: 1; }
.entity-badges { display: inline-flex; gap: .2rem; margin-left: .35rem; }
.entity-badge { font-size: .7rem; padding: .1rem .35rem; border-radius: 8px; background: var(--bg); border: 1px solid var(--border); white-space: nowrap; }
.entity-person { border-color: #818cf8; color: #4338ca; }
.entity-amount { border-color: #34d399; color: #047857; }
.entity-date { border-color: #fbbf24; color: #92400e; }
.entity-company { border-color: #f472b6; color: #be185d; }
.thread-children { margin-left: 1.5rem; border-left: 2px solid var(--border); padding-left: 0; }
.badge-danger { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; }
.email-thread-item { display: flex; justify-content: space-between; align-items: center; text-decoration: none; color: inherit; }
.email-thread-item:hover { border-color: var(--primary); }
.email-badges { display: flex; gap: .25rem; flex-shrink: 0; }
.result-card { border: 1px solid var(--border); border-radius: 6px; padding: .75rem 1rem; margin-bottom: .75rem; cursor: pointer; }
.result-card summary { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; list-style: none; }
.result-card summary::-webkit-details-marker { display: none; }
.result-title { font-size: .9rem; color: var(--text); }
.result-body { margin-top: .75rem; font-size: .875rem; }
.chunk-text { color: var(--text); line-height: 1.6; margin-bottom: .5rem; }
.score { font-size: .75rem; color: var(--muted); white-space: nowrap; }

/* Email search filters */
.email-type-filters { display: flex; gap: .35rem; margin-top: .5rem; flex-wrap: wrap; }
.filter-chip input[type="checkbox"] { display: none; }
.filter-chip .chip { font-size: .78rem; padding: .2rem .6rem; border: 1px solid var(--border); border-radius: 12px; cursor: pointer; transition: all .15s; }
.filter-chip input:checked + .chip { background: var(--primary); color: #fff; border-color: var(--primary); }
.result-type-badge { font-size: .7rem; margin-right: .35rem; background: #eff6ff; color: var(--primary); border: 1px solid #bfdbfe; }

/* Section header */
.section-header { display: flex; align-items: baseline; gap: 1rem; margin-bottom: 1.5rem; }
.section-header h3 { margin: 0; }

/* Data table */
.data-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.data-table th { text-align: left; padding: .5rem .75rem; border-bottom: 2px solid var(--border); color: var(--muted); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; }
.data-table td { padding: .5rem .75rem; border-bottom: 1px solid var(--border); }
.data-table .num { text-align: right; font-family: monospace; }
.data-table .date-cell { font-family: monospace; font-size: .82rem; color: var(--muted); }
.participant-link { color: var(--text); text-decoration: none; }
.participant-link:hover { color: var(--primary); }
.participant-name { color: var(--muted); margin-left: .25rem; }
.topics-cell { max-width: 200px; }
.topics-text { font-size: .82rem; color: var(--muted); }

/* Entity timeline */
.entity-summary { margin-bottom: 2rem; }
.summary-card { display: flex; align-items: center; gap: .5rem; padding: .5rem .75rem; border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: .5rem; }
.summary-conflict { border-color: #fecaca; background: #fef2f2; }
.summary-values { display: flex; flex-wrap: wrap; gap: .35rem; }
.summary-value { font-size: .85rem; }
.summary-value small { color: var(--muted); margin-left: .15rem; }
.timeline-list { max-width: 860px; }
.timeline-entry { display: flex; gap: 1rem; padding: .75rem 0; border-bottom: 1px solid var(--border); }
.timeline-date { font-family: monospace; font-size: .82rem; color: var(--muted); white-space: nowrap; min-width: 120px; }
.timeline-body { flex: 1; }
.timeline-meta { display: flex; align-items: center; gap: .35rem; flex-wrap: wrap; margin-bottom: .25rem; }
.timeline-value { font-size: .9rem; }
.timeline-from { font-size: .82rem; color: var(--muted); }
.timeline-claim { font-size: .85rem; color: var(--text); margin: .25rem 0; line-height: 1.5; }

/* Action items */
.action-list { max-width: 860px; }
.action-card { border: 1px solid var(--border); border-radius: var(--radius); padding: .75rem 1rem; margin-bottom: .75rem; }
.action-header { display: flex; align-items: center; gap: .5rem; margin-bottom: .35rem; }
.action-date { font-family: monospace; font-size: .82rem; color: var(--muted); }
.action-from { font-size: .85rem; font-weight: 600; }
.action-text { font-size: .88rem; line-height: 1.6; margin: .35rem 0; }
.badge-action { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.email-nav-links { display: flex; gap: .35rem; }
