/* DocMind AI V4 — Unified institutional workspace */
:root {
  --dm-ink: #0b172f;
  --dm-navy: #0d1b34;
  --dm-blue: #2563eb;
  --dm-blue-dark: #1d4ed8;
  --dm-sky: #eaf2ff;
  --dm-canvas: #f4f7fb;
  --dm-line: #dce4ef;
  --dm-muted: #64748b;
  --dm-success: #15803d;
  --dm-radius: 14px;
  --dm-shadow: 0 14px 35px rgba(15, 23, 42, .07);
}

html { background: var(--dm-canvas); }
body { color: var(--dm-ink); background: var(--dm-canvas); -webkit-font-smoothing: antialiased; }
button, a, input, select, textarea { transition: border-color .16s ease, background-color .16s ease, color .16s ease, box-shadow .16s ease, transform .16s ease; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid rgba(37,99,235,.24); outline-offset: 2px; }

/* Application frame */
.docmind-app-shell { display: flex; height: 100dvh; overflow: hidden; background: var(--dm-canvas); }
.docmind-sidebar { position: relative; z-index: 50; display: flex; width: 272px; height: 100%; flex: 0 0 272px; flex-direction: column; color: #dbe7f7; background: linear-gradient(180deg, #0b1930 0%, #0d1b34 70%, #101f39 100%); border-right: 1px solid rgba(255,255,255,.08); }
.docmind-brand { display: flex; min-height: 88px; align-items: center; gap: 12px; padding: 18px 20px; border-bottom: 1px solid rgba(255,255,255,.09); }
.docmind-brand-mark, .docmind-login-mark { display: grid; place-items: center; width: 42px; height: 42px; flex: 0 0 auto; color: white; font-weight: 800; font-size: 18px; border-radius: 12px; background: linear-gradient(145deg, #3978f6, #1d4ed8); box-shadow: 0 8px 22px rgba(37,99,235,.35); }
.docmind-brand-copy { display: flex; min-width: 0; flex: 1; flex-direction: column; line-height: 1.1; }
.docmind-brand-copy strong { color: #fff; font-size: 16px; letter-spacing: -.01em; }
.docmind-brand-copy small { margin-top: 5px; color: #8fa5c2; font-size: 11px; letter-spacing: .04em; text-transform: uppercase; }
.docmind-sidebar-close { display: none; width: 44px; height: 44px; color: white; font-size: 28px; border-radius: 10px; }
.docmind-nav { flex: 1; overflow-y: auto; padding: 18px 12px; scrollbar-width: thin; scrollbar-color: #334660 transparent; }
.docmind-sidebar .nav-link { min-height: 44px; margin: 2px 0; padding: 10px 12px; gap: 11px; color: #aebed3; border-radius: 10px; font-size: 14px; font-weight: 550; }
.docmind-sidebar .nav-link:hover { color: #fff; background: rgba(255,255,255,.065); }
.docmind-sidebar .nav-link.active { color: #fff; background: linear-gradient(90deg, rgba(37,99,235,.95), rgba(37,99,235,.68)); box-shadow: inset 0 0 0 1px rgba(255,255,255,.08), 0 8px 18px rgba(0,0,0,.14); }
.docmind-sidebar .nav-link svg { width: 19px; height: 19px; }
.docmind-sidebar .nav-text-icon { border-color: rgba(255,255,255,.25); color: inherit; }
.docmind-sidebar nav > div.border-t { border-color: rgba(255,255,255,.1); }
.docmind-sidebar nav > p { color: #7489a6; }
.docmind-sidebar > div:last-child { border-color: rgba(255,255,255,.1); background: rgba(0,0,0,.08); }
.docmind-sidebar > div:last-child p:first-child { color: #f8fafc; }
.docmind-sidebar > div:last-child p:last-child { color: #8fa5c2; }
.docmind-sidebar > div:last-child button { min-height: 44px; color: #aebed3; }
.docmind-sidebar > div:last-child button:hover { color: #fff; background: rgba(255,255,255,.065); }
.docmind-main-column { display: flex; min-width: 0; flex: 1; flex-direction: column; }
.docmind-workspace { min-width: 0; flex: 1; overflow: auto; background: radial-gradient(circle at 90% -20%, #e8f0ff 0, transparent 30%), var(--dm-canvas); }
.docmind-mobile-header { display: none; }
.docmind-sidebar-scrim { display: none; }

/* Shared screen rhythm */
.docmind-page { width: min(100%, 1440px); margin-inline: auto; }
.docmind-page h1 { color: var(--dm-ink); font-size: clamp(1.65rem, 2vw, 2.15rem); letter-spacing: -.035em; }
.docmind-page-heading { padding: 28px 30px; color: white; border-radius: 20px; background: linear-gradient(128deg, #10213e 0%, #18345f 70%, #1d4ed8 140%); box-shadow: 0 20px 45px rgba(13,27,52,.17); }
.docmind-page-heading h1, .docmind-page-heading p { color: inherit; }
.docmind-page-heading p { opacity: .74; }
.card { border-color: var(--dm-line); border-radius: var(--dm-radius); box-shadow: 0 1px 2px rgba(15,23,42,.03); }
.card:hover { border-color: #cbd7e7; }
.btn-primary { min-height: 44px; padding-inline: 18px; border-radius: 10px; background: var(--dm-blue); box-shadow: 0 7px 16px rgba(37,99,235,.17); }
.btn-primary:hover { background: var(--dm-blue-dark); transform: translateY(-1px); }
.btn-secondary { min-height: 44px; padding-inline: 18px; border-radius: 10px; border-color: #cbd7e7; }
.form-input, select, textarea { min-height: 44px; border-color: #c8d4e3; border-radius: 10px; background: #fff; }
.form-input:focus, select:focus, textarea:focus { border-color: var(--dm-blue); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }

/* Dashboard */
.docmind-dashboard { padding: 36px clamp(20px, 3.5vw, 52px); }
.docmind-dashboard-heading { position: relative; overflow: hidden; }
.docmind-dashboard-heading::after { content: ""; position: absolute; right: -45px; top: -75px; width: 230px; height: 230px; border: 1px solid rgba(255,255,255,.14); border-radius: 50%; box-shadow: 0 0 0 38px rgba(255,255,255,.035), 0 0 0 76px rgba(255,255,255,.025); }
.docmind-stat-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 18px; margin-bottom: 20px; }
.docmind-stat-card { display: flex; min-height: 128px; align-items: center; gap: 16px; padding: 22px; }
.docmind-stat-card > div:first-child { width: 48px; height: 48px; border-radius: 13px; background: var(--dm-sky); }
.docmind-stat-card p:first-child { font-size: 1.75rem; letter-spacing: -.035em; }
.docmind-quick-actions { padding: 24px; }
.docmind-quick-actions h2 { font-size: 1.05rem; }

/* Login */
.docmind-login-page { display: grid; min-height: 100dvh; place-items: center; padding: 32px; background: linear-gradient(115deg, #0b1930 0 50%, #f4f7fb 50%); }
.docmind-login-layout { position: relative; display: grid; width: min(100%, 1060px); grid-template-columns: 1fr 1fr; overflow: hidden; border: 1px solid rgba(255,255,255,.16); border-radius: 24px; background: #fff; box-shadow: 0 32px 90px rgba(4,12,26,.28); }
.docmind-login-layout::before { content: "Institutional knowledge, grounded in evidence.\A\A Search controlled documents. Review cited sources. Identify conflicting evidence."; white-space: pre-wrap; grid-column: 1; grid-row: 1 / span 2; padding: 92px 56px 56px; color: #c6d6eb; font-size: 17px; line-height: 1.75; background: radial-gradient(circle at 15% 20%, rgba(37,99,235,.36), transparent 35%), #0d1b34; }
.docmind-login-heading, .docmind-login-layout > .docmind-login-card { grid-column: 2; margin-inline: 56px; }
.docmind-login-heading { align-items: flex-start; margin-top: 58px; margin-bottom: 22px; }
.docmind-login-heading h1 { color: var(--dm-ink); font-size: 1.65rem; letter-spacing: -.03em; }
.docmind-login-heading p { color: var(--dm-muted); }
.docmind-login-heading .login-guide-link { order: 5; margin-top: 8px; }
.docmind-login-card { margin-bottom: 58px; padding: 0; border: 0; box-shadow: none; }
.docmind-login-card label { color: #334155; }

/* Upload, documents, tables and forms */
.docmind-upload-page { padding-top: 42px; padding-bottom: 42px; }
.docmind-upload-page > div:first-child, .docmind-document-page > div:first-child { padding-bottom: 18px; border-bottom: 1px solid var(--dm-line); }
.docmind-upload-page > .card { min-height: 230px !important; background: rgba(255,255,255,.75); border-width: 1.5px; }
.docmind-upload-page > .card:hover { background: #fff; box-shadow: var(--dm-shadow); }
.docmind-document-page { padding: 36px clamp(20px, 3.5vw, 52px); }
table { border-collapse: separate; border-spacing: 0; }
thead th { color: #475569 !important; background: #f8fafc; font-size: 11px !important; letter-spacing: .055em; text-transform: uppercase; }
tbody tr:hover { background: #f8fbff; }
tbody td { border-color: #e6ecf3 !important; }

/* Chat */
.docmind-chat-workspace { min-height: 100%; background: #f7f9fc; }
.docmind-chat-history { width: 272px; border-color: var(--dm-line); background: #fbfcfe; }
.docmind-chat-history > div:first-child { padding: 16px; }
.docmind-chat-history .group { min-height: 54px; margin: 3px 8px; border: 1px solid transparent; }
.docmind-chat-history .group:hover { border-color: var(--dm-line); background: #fff; }
.docmind-chat-main > div:first-child { min-height: 68px; padding-inline: 24px; background: rgba(255,255,255,.88); backdrop-filter: blur(10px); }
.docmind-chat-main .chat-scroll { padding: 28px clamp(18px, 4vw, 58px); }
.docmind-chat-main .chat-scroll > div { max-width: 1000px; }
.docmind-chat-main textarea { border-radius: 14px; }
.evidence-panel { border-color: #d4deeb; border-radius: 12px; background: #fbfdff; }
.evidence-status { border-radius: 999px; font-weight: 700; }

/* Existing admin and governance screens */
.admin-page, .access-admin-page, .approval-page, .tool-logs-page { max-width: 1440px; margin-inline: auto; }
.admin-workspace, .access-management-grid, .governance-fields, .governance-edit-card { border-color: var(--dm-line); border-radius: var(--dm-radius); }

/* Document search readiness */
.doc-search-state { display: inline-flex; align-items: center; max-width: 260px; padding: 3px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; line-height: 1.25; }
.doc-search-current { color: #166534; background: #dcfce7; }
.doc-search-historical { color: #92400e; background: #fef3c7; }
.doc-search-blocked { color: #991b1b; background: #fee2e2; white-space: normal; }
.admin-user-table-wrap { border-color: var(--dm-line); box-shadow: 0 12px 30px rgba(15,23,42,.045); }
.admin-action-button { min-width: 44px; min-height: 44px; }

@media (max-width: 980px) {
  .docmind-sidebar { position: fixed; inset: 0 auto 0 0; width: min(88vw, 300px); transform: translateX(-105%); box-shadow: 24px 0 60px rgba(4,12,26,.34); transition: transform .2s ease; }
  .docmind-sidebar.mobile-open { transform: translateX(0); }
  .docmind-sidebar-close { display: grid; place-items: center; }
  .docmind-sidebar-scrim { display: block; position: fixed; z-index: 40; inset: 0; border: 0; background: rgba(4,12,26,.54); backdrop-filter: blur(2px); }
  .docmind-mobile-header { display: flex; min-height: 64px; align-items: center; justify-content: space-between; padding: 8px 14px; background: rgba(255,255,255,.94); border-bottom: 1px solid var(--dm-line); backdrop-filter: blur(12px); }
  .docmind-menu-button, .docmind-mobile-help { display: grid; min-width: 44px; min-height: 44px; place-items: center; border-radius: 10px; color: var(--dm-ink); }
  .docmind-menu-button:hover, .docmind-mobile-help:hover { background: #eef3f9; }
  .docmind-mobile-brand { display: flex; align-items: center; gap: 9px; }
  .docmind-mobile-brand span { display: grid; width: 32px; height: 32px; place-items: center; color: #fff; font-weight: 800; border-radius: 9px; background: var(--dm-blue); }
  .docmind-mobile-help { color: var(--dm-blue); font-size: 13px; font-weight: 700; }
  .docmind-stat-grid { grid-template-columns: 1fr 1fr; }
  .docmind-stat-grid > :last-child { grid-column: 1 / -1; }
  .docmind-chat-history { width: 220px; }
}

@media (max-width: 700px) {
  .docmind-dashboard, .docmind-document-page { padding: 20px 14px 34px; }
  .docmind-upload-page { padding: 24px 14px; }
  .docmind-page-heading { padding: 24px 20px; border-radius: 16px; }
  .docmind-stat-grid { grid-template-columns: 1fr; gap: 12px; }
  .docmind-stat-grid > :last-child { grid-column: auto; }
  .docmind-stat-card { min-height: 106px; }
  .docmind-login-page { padding: 18px; background: #f4f7fb; }
  .docmind-login-layout { display: block; max-width: 460px; border-radius: 18px; }
  .docmind-login-layout::before { display: block; padding: 26px 24px; font-size: 14px; line-height: 1.55; }
  .docmind-login-heading, .docmind-login-layout > .docmind-login-card { margin-inline: 24px; }
  .docmind-login-heading { margin-top: 28px; }
  .docmind-login-card { margin-bottom: 30px; }
  .docmind-chat-workspace { position: relative; display: block; }
  .docmind-chat-history { width: 100%; height: auto; max-height: 190px; border-right: 0; border-bottom: 1px solid var(--dm-line); }
  .docmind-chat-history > div:nth-child(2) { max-height: 90px; }
  .docmind-chat-main { min-height: calc(100dvh - 254px); }
  .docmind-chat-main .chat-scroll { padding: 18px 12px; }
  .docmind-document-page > div:first-child { align-items: flex-start; gap: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
.citation-marker-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-inline: 0.12rem;
  padding: 0.08rem 0.38rem;
  border: 1px solid #a9c8ff;
  border-radius: 0.45rem;
  background: #edf4ff;
  color: #1559c6;
  font-size: 0.82em;
  font-weight: 800;
  line-height: 1.45;
  text-decoration: none;
  vertical-align: baseline;
  cursor: pointer;
}

.citation-marker-link:hover,
.citation-marker-link:focus-visible {
  border-color: #2563eb;
  background: #dbeafe;
  color: #123f91;
  text-decoration: underline;
}

.evidence-id-link {
  cursor: pointer;
  text-decoration: none;
}

.evidence-id-link:hover,
.evidence-id-link:focus-visible {
  background: #c7dcff;
  color: #123f91;
  text-decoration: underline;
}
.doc-reprocess-action {
  border-color: #9db8ec;
  background: #eef4ff;
  color: #174ea6;
  cursor: pointer;
}

.doc-reprocess-action:hover:not(:disabled) {
  border-color: #2563eb;
  background: #dbeafe;
}

.doc-reprocess-action:disabled {
  cursor: wait;
  opacity: 0.65;
}
