/* DocuSense AI - application styles (on top of Bootstrap 5) */
:root {
  --ds-primary: #1d4ed8;
  --ds-primary-dark: #1e3a8a;
  --ds-ink: #0f172a;
  --ds-sidebar: #0f1b33;
  --ds-sidebar-2: #16264a;
  --ds-muted: #64748b;
  --ds-bg: #f4f6fb;
  --ds-border: #e2e8f0;
  --ds-demo: #b45309;
  --ds-demo-bg: #fff7e6;
  --ds-ai: #6d28d9;
  --bs-primary: #1d4ed8;
  --bs-primary-rgb: 29, 78, 216;
  --bs-link-color: #1d4ed8;
  --bs-link-hover-color: #1e3a8a;
  --bs-body-font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}
body { background: var(--ds-bg); color: var(--ds-ink); }
.btn-primary { --bs-btn-bg: var(--ds-primary); --bs-btn-border-color: var(--ds-primary); --bs-btn-hover-bg: var(--ds-primary-dark); --bs-btn-hover-border-color: var(--ds-primary-dark); --bs-btn-active-bg: var(--ds-primary-dark); }
.btn-outline-primary { --bs-btn-color: var(--ds-primary); --bs-btn-border-color: var(--ds-primary); --bs-btn-hover-bg: var(--ds-primary); --bs-btn-hover-border-color: var(--ds-primary); }
.text-primary { color: var(--ds-primary) !important; }

/* Brand */
.brand { font-weight: 700; letter-spacing: -.01em; text-decoration: none; display: inline-flex; align-items: center; gap: .5rem; color: var(--ds-ink); }
.brand-mark { width: 32px; height: 32px; border-radius: 9px; display: inline-grid; place-items: center; background: linear-gradient(135deg, #2563eb, #7c3aed); color: #fff; font-size: 1rem; }

/* App shell */
.app-shell { display: flex; min-height: 100vh; }
.sidebar { width: 250px; background: var(--ds-sidebar) !important; color: #cbd5e1; display: flex; flex-direction: column; flex-shrink: 0; }
@media (min-width: 768px) { .sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; } }
.sidebar.offcanvas-md { --bs-offcanvas-width: 260px; --bs-offcanvas-bg: var(--ds-sidebar); }
.sidebar-head { padding: 1.1rem 1.1rem .6rem; display: flex; align-items: center; justify-content: space-between; }
.sidebar-org { margin: 0 1.1rem .8rem; padding: .45rem .7rem; background: var(--ds-sidebar-2); border-radius: 8px; font-size: .82rem; color: #e2e8f0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-nav { padding: 0 .6rem; gap: 2px; }
.sidebar-nav .nav-link { color: #cbd5e1; border-radius: 8px; padding: .55rem .75rem; display: flex; gap: .65rem; align-items: center; font-size: .93rem; }
.sidebar-nav .nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar-nav .nav-link.active { background: var(--ds-primary); color: #fff; }
.sidebar-label { text-transform: uppercase; font-size: .7rem; letter-spacing: .08em; color: #64748b; padding: 1rem .75rem .35rem; }
.sidebar-foot { margin-top: auto; padding: 1rem 1.1rem; }
.mode-pill { display: inline-flex; gap: .35rem; align-items: center; font-size: .78rem; padding: .3rem .6rem; border-radius: 999px; }
.mode-ai { background: rgba(124,58,237,.2); color: #ddd6fe; }
.mode-demo { background: rgba(245,158,11,.18); color: #fcd34d; }

.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { background: #fff; border-bottom: 1px solid var(--ds-border); padding: .7rem 1.25rem; display: flex; align-items: center; position: sticky; top: 0; z-index: 1020; }
.topbar-title { font-size: 1.15rem; font-weight: 650; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--ds-primary); color: #fff; display: inline-grid; place-items: center; font-size: .8rem; font-weight: 600; }
.app-content { padding: 1.25rem; flex: 1; }
@media (min-width: 992px) { .app-content { padding: 1.75rem 2rem; } }
.app-footer { padding: 1rem 2rem; font-size: .8rem; color: var(--ds-muted); }
.demo-banner { background: var(--ds-demo-bg); color: #7c4a03; border-bottom: 1px solid #fde4b0; padding: .5rem 1.25rem; font-size: .86rem; }

/* Cards & stats */
.card { border: 1px solid var(--ds-border); border-radius: 12px; box-shadow: 0 1px 2px rgba(15,23,42,.04); }
.card-header { background: #fff; border-bottom: 1px solid var(--ds-border); font-weight: 600; padding: .85rem 1.1rem; border-radius: 12px 12px 0 0 !important; }
.stat-card { padding: 1.05rem 1.15rem; }
.stat-card .stat-label { color: var(--ds-muted); font-size: .82rem; font-weight: 500; }
.stat-card .stat-value { font-size: 1.7rem; font-weight: 700; line-height: 1.2; margin-top: .15rem; }
.stat-card .stat-icon { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; font-size: 1.15rem; }
.chart-box { position: relative; height: 280px; }
.chart-box.sm { height: 230px; }

/* Badges */
.badge-ai { background: #ede9fe; color: var(--ds-ai); font-weight: 600; }
.badge-demo { background: #fef3c7; color: var(--ds-demo); font-weight: 700; border: 1px dashed #f59e0b; }
.cat-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; margin-right: .35rem; vertical-align: middle; }
.demo-note { background: var(--ds-demo-bg); border: 1px dashed #f59e0b; color: #7c4a03; border-radius: 10px; padding: .65rem .85rem; font-size: .86rem; }

/* Tables */
.table > :not(caption) > * > * { padding: .7rem .8rem; }
.table thead th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ds-muted); font-weight: 600; background: #f8fafc; }
.doc-icon { width: 36px; height: 36px; border-radius: 8px; display: inline-grid; place-items: center; font-size: 1.1rem; flex-shrink: 0; }
.doc-pdf { background: #fee2e2; color: #b91c1c; }
.doc-docx { background: #dbeafe; color: #1d4ed8; }
.doc-txt { background: #e2e8f0; color: #334155; }
.doc-img { background: #dcfce7; color: #15803d; }

/* Upload drop zone */
.dropzone { border: 2px dashed #cbd5e1; border-radius: 14px; background: #fff; padding: 2.5rem 1rem; text-align: center; cursor: pointer; transition: .15s; }
.dropzone.dragover, .dropzone:hover { border-color: var(--ds-primary); background: #eff6ff; }
.dropzone i { font-size: 2.6rem; color: var(--ds-primary); }

/* Processing steps */
.steps { list-style: none; padding: 0; margin: 0; }
.steps li { display: flex; align-items: center; gap: .6rem; padding: .45rem 0; color: var(--ds-muted); font-size: .92rem; }
.steps li .step-ic { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; border: 2px solid #cbd5e1; font-size: .75rem; flex-shrink: 0; }
.steps li.done { color: var(--ds-ink); }
.steps li.done .step-ic { background: #16a34a; border-color: #16a34a; color: #fff; }
.steps li.active { color: var(--ds-primary); font-weight: 600; }
.steps li.active .step-ic { border-color: var(--ds-primary); }
.steps li.error { color: #b91c1c; }
.steps li.error .step-ic { border-color: #b91c1c; background: #fee2e2; }

/* Document text & AI output */
.doc-text { white-space: pre-wrap; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .82rem; background: #f8fafc; border: 1px solid var(--ds-border); border-radius: 10px; padding: 1rem; max-height: 520px; overflow: auto; }
.ai-output { white-space: pre-wrap; line-height: 1.6; }
.kv-table th { width: 38%; color: var(--ds-muted); font-weight: 500; }

/* Chat */
.chat { display: flex; flex-direction: column; gap: .9rem; }
.chat-msg { max-width: 92%; padding: .75rem 1rem; border-radius: 14px; }
.chat-q { align-self: flex-end; background: var(--ds-primary); color: #fff; border-bottom-right-radius: 4px; }
.chat-a { align-self: flex-start; background: #fff; border: 1px solid var(--ds-border); border-bottom-left-radius: 4px; }
.chat-meta { font-size: .75rem; color: var(--ds-muted); margin-top: .35rem; }
.suggestion { border-radius: 999px; font-size: .82rem; }

/* Public pages */
.layout-public { background: #fff; }
.hero { background: radial-gradient(1000px 400px at 80% -10%, #dbeafe 0%, transparent 60%), radial-gradient(800px 400px at 0% 0%, #ede9fe 0%, transparent 55%), #fff; padding: 5rem 0 4rem; }
.hero h1 { font-size: clamp(2rem, 4.5vw, 3.2rem); font-weight: 800; letter-spacing: -.02em; }
.hero .lead { color: #475569; }
.feature-ic { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; font-size: 1.3rem; background: #eff6ff; color: var(--ds-primary); }
.section { padding: 4.5rem 0; }
.section-alt { background: var(--ds-bg); }
.price-card.featured { border: 2px solid var(--ds-primary); box-shadow: 0 10px 30px rgba(29,78,216,.12); }
.site-footer { border-top: 1px solid var(--ds-border); padding: 1.5rem 0; font-size: .88rem; }
.auth-wrap { min-height: calc(100vh - 140px); display: grid; place-items: center; padding: 2.5rem 1rem; background: var(--ds-bg); }
.auth-card { width: 100%; max-width: 440px; }
.hero-shot { background: #0f1b33; border-radius: 16px; padding: 1rem; box-shadow: 0 30px 60px rgba(15,23,42,.25); }
.hero-shot .mini { background: #fff; border-radius: 10px; padding: .8rem; }

.empty-state { text-align: center; padding: 3rem 1rem; color: var(--ds-muted); }
.empty-state i { font-size: 2.6rem; display: block; margin-bottom: .6rem; color: #94a3b8; }
.min-w-0 { min-width: 0; }
