:root {
  --bg: #0b1020;
  --bg-soft: #121935;
  --surface: rgba(255, 255, 255, 0.92);
  --surface-strong: #ffffff;
  --surface-dark: rgba(13, 18, 34, 0.88);
  --border: rgba(113, 133, 194, 0.18);
  --text: #101828;
  --text-soft: #667085;
  --text-on-dark: #f8fafc;
  --primary: #6d5efc;
  --primary-2: #3cc0ff;
  --success: #17b26a;
  --warning: #f79009;
  --danger: #f04438;
  --shadow: 0 20px 60px rgba(17, 24, 39, 0.14);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --max-width: 1600px;
}

* {
  box-sizing: border-box;
  font-family: 'Inter', Arial, Helvetica, sans-serif;
}

html, body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 10% 20%, rgba(109, 94, 252, 0.24), transparent 28%),
    radial-gradient(circle at 85% 15%, rgba(60, 192, 255, 0.22), transparent 22%),
    linear-gradient(180deg, #f5f7ff 0%, #eef2ff 100%);
  position: relative;
  overflow-x: hidden;
}

body.dark-mode {
  color: var(--text-on-dark);
  background:
    radial-gradient(circle at 10% 20%, rgba(109, 94, 252, 0.18), transparent 25%),
    radial-gradient(circle at 85% 15%, rgba(60, 192, 255, 0.14), transparent 20%),
    linear-gradient(180deg, #07111f 0%, #0b1020 100%);
}

.bg-orb,
.bg-grid {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.bg-orb {
  width: 38rem;
  height: 38rem;
  border-radius: 999px;
  filter: blur(60px);
  opacity: 0.4;
}

.orb-1 {
  top: -8rem;
  left: -10rem;
  background: rgba(109, 94, 252, 0.28);
  animation: floatOrb 12s ease-in-out infinite;
}

.orb-2 {
  top: -4rem;
  right: -8rem;
  background: rgba(60, 192, 255, 0.24);
  animation: floatOrb 14s ease-in-out infinite reverse;
}

.bg-grid {
  background-image: linear-gradient(rgba(113, 133, 194, 0.08) 1px, transparent 1px), linear-gradient(90deg, rgba(113, 133, 194, 0.08) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: linear-gradient(180deg, rgba(0,0,0,0.8), transparent 90%);
}

@keyframes floatOrb {
  0%, 100% { transform: translate3d(0,0,0) scale(1); }
  50% { transform: translate3d(0, 24px, 0) scale(1.05); }
}

body.dark-mode .bg-grid {
  background-image: linear-gradient(rgba(147, 163, 184, 0.06) 1px, transparent 1px), linear-gradient(90deg, rgba(147, 163, 184, 0.06) 1px, transparent 1px);
}

img {
  max-width: 100%;
}

a {
  color: inherit;
  text-decoration: none !important;
}

ul, ol {
  padding-left: 1.2rem;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  padding: 16px 20px 0;
}

.topbar-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 16px 20px;
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(20px);
  box-shadow: 0 18px 42px rgba(15, 23, 42, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

body.dark-mode .topbar-inner {
  background: rgba(10, 16, 32, 0.74);
  border-color: rgba(148, 163, 184, 0.12);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.32);
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 14px;
}

.logo-mark {
  width: 52px;
  height: 52px;
  border-radius: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: linear-gradient(135deg, rgba(109, 94, 252, 0.18), rgba(60, 192, 255, 0.14));
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.5), 0 12px 30px rgba(109, 94, 252, 0.2);
}

.logo-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.logo-text {
  display: block;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.logo-subtitle {
  display: block;
  color: var(--text-soft);
  font-size: 0.82rem;
}

body.dark-mode .logo-subtitle {
  color: rgba(226, 232, 240, 0.74);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.top-action-btn,
.user-icon {
  width: 46px;
  height: 46px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.74);
  border-radius: 16px;
  font-size: 1.3rem;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform .25s ease, box-shadow .25s ease, border-color .25s ease;
}

body.dark-mode .top-action-btn,
body.dark-mode .user-icon {
  background: rgba(18, 25, 53, 0.88);
  color: var(--text-on-dark);
}

.top-action-btn:hover,
.user-icon:hover,
.chat-input button:hover,
.btn:hover {
  transform: translateY(-2px);
}

.workspace-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(109, 94, 252, 0.16), rgba(60, 192, 255, 0.14));
  border: 1px solid rgba(109, 94, 252, 0.14);
  color: #344054;
  font-weight: 600;
  white-space: nowrap;
}

body.dark-mode .workspace-pill {
  color: #e2e8f0;
  background: linear-gradient(135deg, rgba(109, 94, 252, 0.22), rgba(60, 192, 255, 0.16));
  border-color: rgba(109, 94, 252, 0.18);
}

.user-menu {
  position: relative;
}

.user-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  min-width: 220px;
  border-radius: 18px;
  padding: 8px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.92);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(8px);
  visibility: hidden;
  transition: .2s ease;
}

body.dark-mode .user-dropdown {
  background: rgba(13, 18, 34, 0.94);
}

.user-dropdown.show {
  opacity: 1;
  transform: translateY(0);
  visibility: visible;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 14px;
}

.dropdown-item:hover {
  background: rgba(109, 94, 252, 0.08);
}

.app-shell {
  position: relative;
  z-index: 1;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 22px 20px 28px;
}

main.dashboard-container {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) 320px;
  gap: 22px;
  align-items: start;
  min-height: calc(100vh - 130px);
}

main.dashboard-container.documents-page,
main.dashboard-container.report-page,
main.dashboard-container.reminder-page,
main.dashboard-container.summary-page,
main.dashboard-container.risk-page {
  grid-template-columns: 300px minmax(0, 1fr);
}

.sidebar,
.chat-section,
.page-section,
.history-section {
  min-width: 0;
}

.sidebar {
  position: sticky;
  top: 118px;
  padding: 20px;
  border-radius: var(--radius-xl);
  border: 1px solid rgba(255,255,255,0.45);
  background: rgba(255,255,255,0.72);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.sidebar::before {
  content: "";
  position: absolute;
  inset: 0 auto auto 0;
  width: 100%;
  height: 140px;
  background: linear-gradient(180deg, rgba(109, 94, 252, 0.12), transparent);
  pointer-events: none;
}

body.dark-mode .sidebar,
body.dark-mode .chat-section,
body.dark-mode .page-section > .card,
body.dark-mode .history-section,
body.dark-mode .card,
body.dark-mode .stat-card,
body.dark-mode .page-hero,
body.dark-mode .glass-panel {
  background: rgba(11, 16, 32, 0.78);
  border-color: rgba(148, 163, 184, 0.14);
  color: var(--text-on-dark);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.32);
}

.side-tabs > ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  z-index: 1;
}

.side-tabs li {
  list-style: none;
}

.side-tabs li > a,
.has-sub .main-item,
.sub li {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border-radius: 16px;
  color: #344054;
  transition: .25s ease;
  font-weight: 500;
}

body.dark-mode .side-tabs li > a,
body.dark-mode .has-sub .main-item,
body.dark-mode .sub li {
  color: #e2e8f0;
}

.side-tabs li.active > a,
.side-tabs li > a:hover,
.has-sub .main-item:hover,
.sub li:hover {
  background: linear-gradient(135deg, rgba(109, 94, 252, 0.14), rgba(60, 192, 255, 0.08));
  color: #1d2939;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.35);
}

body.dark-mode .side-tabs li.active > a,
body.dark-mode .side-tabs li > a:hover,
body.dark-mode .has-sub .main-item:hover,
body.dark-mode .sub li:hover {
  color: #fff;
}

.side-tabs li.active > a {
  font-weight: 700;
}

.has-sub {
  overflow: hidden;
}

.has-sub .main-item {
  justify-content: space-between;
  cursor: pointer;
}

.has-sub .arrow {
  transition: transform .25s ease;
}

.sub {
  padding-left: 16px;
  margin: 8px 0 0;
  border-left: 1px solid rgba(109, 94, 252, 0.18);
  display: none;
}

.has-sub.open .sub {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.has-sub.open .arrow {
  transform: rotate(180deg);
}

.page-hero {
  position: relative;
  margin-bottom: 18px;
  padding: 24px 24px 22px;
  border-radius: var(--radius-xl);
  background: linear-gradient(135deg, rgba(109, 94, 252, 0.14), rgba(60, 192, 255, 0.12), rgba(255,255,255,0.72));
  border: 1px solid rgba(255,255,255,0.48);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.page-hero::after {
  content: "";
  position: absolute;
  right: -40px;
  top: -40px;
  width: 180px;
  height: 180px;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(255,255,255,0.75), rgba(255,255,255,0));
}

.page-hero .hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255,255,255,0.62);
  color: #344054;
  font-size: .82rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 14px;
}

.page-hero h1 {
  font-size: clamp(1.55rem, 2vw, 2.35rem);
  font-weight: 800;
  margin-bottom: 10px;
}

.page-hero p {
  max-width: 860px;
  color: var(--text-soft);
  margin-bottom: 0;
  font-size: 1rem;
  line-height: 1.7;
}

body.dark-mode .page-hero p,
body.dark-mode .text-muted,
body.dark-mode .small,
body.dark-mode .form-text,
body.dark-mode .msg-time,
body.dark-mode .logo-subtitle {
  color: rgba(226, 232, 240, 0.74) !important;
}

.card,
.chat-section,
.history-section,
.stat-card,
.glass-panel {
  border: 1px solid rgba(255,255,255,0.46) !important;
  border-radius: var(--radius-xl) !important;
  background: rgba(255,255,255,0.76);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

.page-section > .card,
.page-section > div > .card,
.chat-section,
.history-section {
  overflow: hidden;
}

.card,
.stat-card,
.history-item,
.msg,
.page-hero,
.table tr,
.glass-panel {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity .55s ease, transform .55s ease, box-shadow .3s ease;
}

.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.page-section .card:hover,
.stat-card:hover,
.history-item:hover,
.msg:hover {
  box-shadow: 0 24px 70px rgba(17, 24, 39, 0.16);
}

.page-section {
  min-width: 0;
}

.chat-section {
  display: flex;
  flex-direction: column;
  padding: 20px;
  gap: 18px;
  min-height: 0;
}

.chat-window {
  flex: 1;
  min-height: 520px;
  max-height: calc(100vh - 305px);
  overflow-y: auto;
  padding: 20px;
  border-radius: 24px;
  border: 1px solid rgba(113, 133, 194, 0.12);
  background: linear-gradient(180deg, rgba(255,255,255,0.56), rgba(247, 249, 255, 0.82));
}

body.dark-mode .chat-window {
  background: linear-gradient(180deg, rgba(18, 25, 53, 0.88), rgba(11, 16, 32, 0.88));
  border-color: rgba(148, 163, 184, 0.14);
}

.msg {
  margin-bottom: 16px;
  max-width: min(78%, 740px);
  padding: 14px 16px;
  border-radius: 22px;
  position: relative;
}

.msg-user {
  margin-left: auto;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), #8b7bff);
}

.msg-bot,
.msg-file {
  margin-right: auto;
  background: rgba(255,255,255,0.9);
  border: 1px solid rgba(113, 133, 194, 0.14);
}

body.dark-mode .msg-bot,
body.dark-mode .msg-file {
  background: rgba(18, 25, 53, 0.92);
  color: var(--text-on-dark);
  border-color: rgba(148, 163, 184, 0.14);
}

.msg-time {
  margin-top: 8px;
  font-size: .75rem;
  text-align: right;
}

.msg-text {
  line-height: 1.7;
}

.msg-heading-1,
.msg-heading-2,
.msg-heading-3 {
  font-weight: 800;
  margin-bottom: 8px;
}

.msg-heading-1 { font-size: 1.2rem; }
.msg-heading-2 { font-size: 1.08rem; }
.msg-heading-3 { font-size: 1rem; }

.msg-file .file-meta {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.file-icon {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(109, 94, 252, 0.16), rgba(60, 192, 255, 0.14));
  color: var(--primary);
  font-size: 1.6rem;
}

.thumb {
  width: 140px;
  max-height: 120px;
  border-radius: 16px;
  object-fit: cover;
  box-shadow: 0 12px 28px rgba(17,24,39,.12);
}

.file-info pre,
.ocr-content,
.risk-rich-block {
  white-space: pre-wrap;
  border-radius: 18px;
  border: 1px solid rgba(113, 133, 194, 0.14);
  background: rgba(247, 249, 255, 0.84);
  padding: 14px;
}

body.dark-mode .file-info pre,
body.dark-mode .ocr-content,
body.dark-mode .risk-rich-block {
  background: rgba(18, 25, 53, 0.82);
  border-color: rgba(148, 163, 184, 0.14);
}

.chat-input {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 14px;
  border-radius: 24px;
  background: rgba(255,255,255,0.78);
  border: 1px solid rgba(255,255,255,0.52);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.52);
}

body.dark-mode .chat-input {
  background: rgba(11, 16, 32, 0.84);
  border-color: rgba(148, 163, 184, 0.14);
}

.chat-input button,
.btn {
  border-radius: 16px !important;
}

.chat-input button {
  width: 48px;
  height: 48px;
  border: 1px solid rgba(113, 133, 194, 0.14);
  background: rgba(255,255,255,0.88);
  color: #344054;
  font-size: 1.2rem;
}

body.dark-mode .chat-input button {
  background: rgba(18, 25, 53, 0.88);
  color: #f8fafc;
}

#chatInput,
.form-control,
.form-select,
textarea,
input[type="text"],
input[type="email"],
input[type="date"],
input[type="password"] {
  border-radius: 16px !important;
  border: 1px solid rgba(113, 133, 194, 0.18) !important;
  min-height: 50px;
  background: rgba(255,255,255,0.88) !important;
  box-shadow: none !important;
}

textarea.form-control,
textarea {
  min-height: 120px;
}

body.dark-mode #chatInput,
body.dark-mode .form-control,
body.dark-mode .form-select,
body.dark-mode textarea,
body.dark-mode input[type="text"],
body.dark-mode input[type="email"],
body.dark-mode input[type="date"],
body.dark-mode input[type="password"] {
  background: rgba(18, 25, 53, 0.88) !important;
  color: #f8fafc;
  border-color: rgba(148, 163, 184, 0.14) !important;
}

#sendBtn,
.btn-primary,
.btn-success {
  background: linear-gradient(135deg, var(--primary), #8b7bff) !important;
  border: none !important;
  color: #fff !important;
  min-height: 48px;
  padding-inline: 18px;
  box-shadow: 0 16px 32px rgba(109, 94, 252, 0.28);
}

.btn-outline-secondary,
.btn-outline-dark,
.btn-outline-primary,
.btn-outline-danger {
  border-color: rgba(113, 133, 194, 0.18) !important;
}

.table-responsive {
  border-radius: 20px;
}

.table {
  margin-bottom: 0;
  --bs-table-bg: transparent;
  --bs-table-hover-bg: rgba(109, 94, 252, 0.04);
}

.table thead th {
  border: none;
  padding: 16px 14px;
  text-transform: uppercase;
  letter-spacing: .03em;
  font-size: .76rem;
  color: var(--text-soft);
  background: rgba(109, 94, 252, 0.04) !important;
}

.table tbody td {
  padding: 16px 14px;
  border-color: rgba(113, 133, 194, 0.1);
  vertical-align: middle;
}

body.dark-mode .table {
  color: #f8fafc;
  --bs-table-border-color: rgba(148, 163, 184, 0.14);
  --bs-table-hover-bg: rgba(109, 94, 252, 0.08);
}

body.dark-mode .table thead th {
  color: rgba(226, 232, 240, 0.7);
  background: rgba(109, 94, 252, 0.08) !important;
}

.history-section {
  padding: 20px;
}

.history-section h5 {
  font-weight: 800;
  margin-bottom: 14px;
}

.history-item {
  padding: 14px;
  border-radius: 18px;
  border: 1px solid rgba(113, 133, 194, 0.12);
  background: rgba(255,255,255,0.66);
  margin-bottom: 10px;
}

body.dark-mode .history-item {
  background: rgba(18, 25, 53, 0.72);
  border-color: rgba(148, 163, 184, 0.12);
}

.time {
  margin-top: 6px;
  color: var(--text-soft);
  font-size: .78rem;
}

.stat-card {
  height: 100%;
  padding: 18px;
  border-radius: 24px;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: "";
  position: absolute;
  inset: 0 auto auto 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at top right, rgba(255,255,255,0.55), transparent 42%);
  pointer-events: none;
}

.stat-total { background: linear-gradient(135deg, rgba(109, 94, 252, 0.16), rgba(109, 94, 252, 0.05), rgba(255,255,255,0.78)); }
.stat-high { background: linear-gradient(135deg, rgba(240, 68, 56, 0.16), rgba(240, 68, 56, 0.04), rgba(255,255,255,0.78)); }
.stat-medium { background: linear-gradient(135deg, rgba(247, 144, 9, 0.16), rgba(247, 144, 9, 0.04), rgba(255,255,255,0.78)); }
.stat-low { background: linear-gradient(135deg, rgba(23, 178, 106, 0.16), rgba(23, 178, 106, 0.04), rgba(255,255,255,0.78)); }

.stat-label {
  color: var(--text-soft);
  font-size: .85rem;
  margin-bottom: 8px;
}

.stat-value {
  font-size: clamp(1.4rem, 2.4vw, 2.2rem);
  font-weight: 800;
  letter-spacing: -0.03em;
}

.risk-badge,
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 999px !important;
  padding: 8px 12px !important;
  font-weight: 700;
  letter-spacing: .01em;
}

.risk-safe,
.badge.bg-success {
  background: rgba(23, 178, 106, 0.14) !important;
  color: #067647 !important;
}

.risk-caution,
.badge.bg-warning {
  background: rgba(247, 144, 9, 0.16) !important;
  color: #b54708 !important;
}

.risk-critical,
.badge.bg-danger {
  background: rgba(240, 68, 56, 0.14) !important;
  color: #b42318 !important;
}

.risk-unknown,
.badge.bg-secondary,
.badge.bg-secondary-subtle {
  background: rgba(102, 112, 133, 0.14) !important;
  color: #475467 !important;
}

body.dark-mode .risk-safe,
body.dark-mode .badge.bg-success { color: #73e2a3 !important; }
body.dark-mode .risk-caution,
body.dark-mode .badge.bg-warning { color: #fdb022 !important; }
body.dark-mode .risk-critical,
body.dark-mode .badge.bg-danger { color: #f97066 !important; }
body.dark-mode .risk-unknown,
body.dark-mode .badge.bg-secondary,
body.dark-mode .badge.bg-secondary-subtle { color: #cbd5e1 !important; }

.risk-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.risk-summary-card {
  padding: 18px;
  border-radius: 22px;
  background: rgba(255,255,255,0.68);
  border: 1px solid rgba(113, 133, 194, 0.14);
}

.risk-summary-card .label {
  font-size: .82rem;
  color: var(--text-soft);
  margin-bottom: 8px;
}

.risk-summary-card .value {
  font-size: 1.55rem;
  font-weight: 800;
}

.findings-list,
.key-warning-list,
.recommendation-list,
.negotiation-list {
  display: grid;
  gap: 14px;
}

.finding-card,
.warning-card,
.negotiation-card,
.recommendation-card {
  padding: 18px;
  border-radius: 22px;
  border: 1px solid rgba(113, 133, 194, 0.14);
  background: rgba(255,255,255,0.76);
}

body.dark-mode .finding-card,
body.dark-mode .warning-card,
body.dark-mode .negotiation-card,
body.dark-mode .recommendation-card,
body.dark-mode .risk-summary-card {
  background: rgba(18, 25, 53, 0.78);
  border-color: rgba(148, 163, 184, 0.14);
}

.finding-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.finding-title {
  font-weight: 800;
  margin-bottom: 4px;
}

.finding-meta,
.inline-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(109, 94, 252, 0.08);
  color: #4c1d95;
  font-size: .78rem;
  font-weight: 600;
}

body.dark-mode .meta-chip {
  background: rgba(109, 94, 252, 0.14);
  color: #ddd6fe;
}

.alert,
.login-content,
.doc-modal-content {
  border-radius: 24px !important;
  border: 1px solid rgba(113, 133, 194, 0.14) !important;
  background: rgba(255,255,255,0.88) !important;
  box-shadow: var(--shadow);
}

body.dark-mode .alert,
body.dark-mode .login-content,
body.dark-mode .doc-modal-content {
  background: rgba(11, 16, 32, 0.94) !important;
  color: var(--text-on-dark);
}

.login-modal,
.doc-modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(2, 6, 23, 0.5);
  z-index: 999;
  backdrop-filter: blur(8px);
}

.login-content,
.doc-modal-content {
  width: min(100%, 520px);
  padding: 24px;
}

.close-btn {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 14px;
  background: rgba(109, 94, 252, 0.08);
}

.loader-dots {
  display: inline-flex;
  gap: 6px;
}

.loader-dots span {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: rgba(109, 94, 252, 0.72);
  animation: pulse 1s infinite ease-in-out;
}

.loader-dots span:nth-child(2) { animation-delay: .1s; }
.loader-dots span:nth-child(3) { animation-delay: .2s; }
.loader-dots span:nth-child(4) { animation-delay: .3s; }
.loader-dots span:nth-child(5) { animation-delay: .4s; }
.loader-dots span:nth-child(6) { animation-delay: .5s; }
.loader-dots span:nth-child(7) { animation-delay: .6s; }
.loader-dots span:nth-child(8) { animation-delay: .7s; }

@keyframes pulse {
  0%, 100% { transform: translateY(0); opacity: .45; }
  50% { transform: translateY(-5px); opacity: 1; }
}

.type-caret::after {
  content: "";
  display: inline-block;
  width: 8px;
  height: 1.1em;
  margin-left: 3px;
  vertical-align: text-bottom;
  background: currentColor;
  animation: blink 1s steps(1) infinite;
}

@keyframes blink { 50% { opacity: 0; } }

@media (max-width: 1199px) {
  main.dashboard-container,
  main.dashboard-container.documents-page,
  main.dashboard-container.report-page,
  main.dashboard-container.reminder-page,
  main.dashboard-container.summary-page,
  main.dashboard-container.risk-page {
    grid-template-columns: 280px minmax(0, 1fr);
  }

  .history-section {
    grid-column: 1 / -1;
  }

  .risk-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 992px) {
  .topbar {
    padding-inline: 12px;
  }

  .topbar-inner {
    flex-wrap: wrap;
    justify-content: center;
  }

  main.dashboard-container,
  main.dashboard-container.documents-page,
  main.dashboard-container.report-page,
  main.dashboard-container.reminder-page,
  main.dashboard-container.summary-page,
  main.dashboard-container.risk-page {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

  .history-section {
    order: 3;
  }
}

@media (max-width: 768px) {
  .app-shell {
    padding-inline: 12px;
  }

  .top-actions {
    width: 100%;
    justify-content: space-between;
  }

  .workspace-pill {
    display: none;
  }

  .chat-window {
    min-height: 420px;
    max-height: unset;
  }

  .msg,
  .msg-user,
  .msg-bot,
  .msg-file {
    max-width: 100%;
  }

  .chat-input {
    flex-wrap: wrap;
  }

  #chatInput {
    width: 100%;
  }

  .risk-summary-grid {
    grid-template-columns: 1fr;
  }
}

.action-gradient {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  border: none;
  color: #fff;
  box-shadow: 0 14px 30px rgba(109, 94, 252, 0.22);
}

.action-gradient:hover {
  color: #fff;
}

.glass-panel {
  background: rgba(255,255,255,0.78);
  border: 1px solid rgba(255,255,255,0.54);
  box-shadow: var(--shadow);
  border-radius: 28px;
  padding: 26px;
  backdrop-filter: blur(18px);
}

body.dark-mode .glass-panel {
  background: rgba(13, 18, 34, 0.84);
  border-color: rgba(148, 163, 184, 0.12);
}

.eyebrow-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(109, 94, 252, 0.12);
  color: #4338ca;
  font-weight: 700;
  font-size: 0.86rem;
}

body.dark-mode .eyebrow-chip {
  color: #c7d2fe;
  background: rgba(109, 94, 252, 0.18);
}

.workstation-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.workstation-card {
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 16px 18px;
  background: rgba(255,255,255,0.82);
}

body.dark-mode .workstation-card {
  background: rgba(18, 25, 53, 0.9);
}

.workstation-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-soft);
}

.workstation-value {
  font-size: 1.2rem;
  font-weight: 800;
  margin-top: 6px;
}

.workspace-note {
  border: 1px solid rgba(109, 94, 252, 0.14);
  background: rgba(109, 94, 252, 0.06);
  border-radius: 18px;
  padding: 14px 16px;
  line-height: 1.6;
}

.workspace-note.subtle {
  background: rgba(60, 192, 255, 0.08);
  border-color: rgba(60, 192, 255, 0.16);
}

.analysis-cockpit .meta-chip strong,
.meta-grid-item strong {
  display: block;
  margin-top: 4px;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.meta-grid.compact {
  grid-template-columns: 1fr 1fr;
}

.meta-grid-item {
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgba(255,255,255,0.74);
  padding: 14px 16px;
}

.meta-grid-item span {
  display: block;
  font-size: 0.82rem;
  color: var(--text-soft);
}

body.dark-mode .meta-grid-item {
  background: rgba(18, 25, 53, 0.9);
}

.evidence-quote {
  border-left: 4px solid var(--primary);
  background: rgba(109, 94, 252, 0.08);
  padding: 12px 14px;
  border-radius: 14px;
  font-size: 0.95rem;
  margin: 14px 0;
  color: #344054;
}

body.dark-mode .evidence-quote {
  color: #e2e8f0;
  background: rgba(109, 94, 252, 0.16);
}

.compact-findings .finding-card,
.findings-list .finding-card,
.missing-card,
.playbook-card,
.clause-map-card {
  background: rgba(255,255,255,0.84);
  border: 1px solid var(--border);
  box-shadow: none;
}

body.dark-mode .compact-findings .finding-card,
body.dark-mode .findings-list .finding-card,
body.dark-mode .missing-card,
body.dark-mode .playbook-card,
body.dark-mode .clause-map-card {
  background: rgba(18, 25, 53, 0.92);
}

.missing-list,
.playbook-list {
  display: grid;
  gap: 14px;
}

.missing-card,
.playbook-card,
.clause-map-card {
  border-radius: 20px;
  padding: 16px;
}

.playbook-card {
  display: grid;
  grid-template-columns: 60px 1fr;
  gap: 14px;
}

.playbook-step {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(109, 94, 252, 0.18), rgba(60, 192, 255, 0.16));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
}

.finding-two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.clause-map-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.priority-badge,
.confidence-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 7px 11px;
  font-size: 0.78rem;
  font-weight: 700;
  border: 1px solid transparent;
  white-space: nowrap;
}

.priority-critical { background: rgba(240, 68, 56, 0.14); color: #b42318; border-color: rgba(240, 68, 56, 0.18); }
.priority-high { background: rgba(247, 144, 9, 0.14); color: #b54708; border-color: rgba(247, 144, 9, 0.18); }
.priority-mid { background: rgba(109, 94, 252, 0.12); color: #4338ca; border-color: rgba(109, 94, 252, 0.18); }
.priority-low { background: rgba(23, 178, 106, 0.12); color: #027a48; border-color: rgba(23, 178, 106, 0.18); }
.confidence-high { background: rgba(23, 178, 106, 0.12); color: #027a48; border-color: rgba(23, 178, 106, 0.18); }
.confidence-mid { background: rgba(247, 144, 9, 0.14); color: #b54708; border-color: rgba(247, 144, 9, 0.18); }
.confidence-low { background: rgba(240, 68, 56, 0.14); color: #b42318; border-color: rgba(240, 68, 56, 0.18); }

.analysis-modal {
  position: fixed;
  inset: 0;
  background: rgba(7, 16, 32, 0.42);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 120;
}

.analysis-modal.show {
  display: flex;
}

.analysis-modal-dialog {
  width: min(920px, 100%);
  max-height: min(92vh, 980px);
  overflow-y: auto;
  border-radius: 28px;
  background: rgba(255,255,255,0.94);
  border: 1px solid rgba(255,255,255,0.55);
  box-shadow: 0 30px 80px rgba(15, 23, 42, 0.25);
  padding: 24px;
}

body.dark-mode .analysis-modal-dialog {
  background: rgba(13, 18, 34, 0.96);
  border-color: rgba(148, 163, 184, 0.14);
}

.analysis-modal-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 18px;
}

.modal-close-btn {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.75);
}

.analysis-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.analysis-form-grid .full-width {
  grid-column: 1 / -1;
}

.analysis-form-grid label {
  display: block;
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.analysis-form-grid select,
.analysis-form-grid textarea {
  width: 100%;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.86);
  padding: 12px 14px;
  color: var(--text);
}

body.dark-mode .analysis-form-grid select,
body.dark-mode .analysis-form-grid textarea,
body.dark-mode .modal-close-btn {
  background: rgba(18, 25, 53, 0.9);
  color: var(--text-on-dark);
}

.analysis-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 18px;
}

.analysis-status {
  margin-top: 14px;
  border-radius: 16px;
  padding: 0;
  min-height: 0;
}

.analysis-status.is-loading,
.analysis-status.is-success,
.analysis-status.is-error {
  padding: 12px 14px;
}

.analysis-status.is-loading { background: rgba(109, 94, 252, 0.1); color: #4338ca; }
.analysis-status.is-success { background: rgba(23, 178, 106, 0.12); color: #027a48; }
.analysis-status.is-error { background: rgba(240, 68, 56, 0.14); color: #b42318; }

.ocr-tall {
  max-height: 680px;
  overflow-y: auto;
}

@media (max-width: 1199px) {
  .workstation-grid,
  .clause-map-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 991px) {
  .finding-two-col,
  .analysis-form-grid,
  .meta-grid,
  .meta-grid.compact {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 767px) {
  .workstation-grid,
  .clause-map-grid {
    grid-template-columns: 1fr;
  }
  .playbook-card {
    grid-template-columns: 1fr;
  }
}


main.dashboard-container.chat-page {
  grid-template-columns: 300px minmax(0, 1fr);
}

.chat-page .chat-section {
  min-height: calc(100vh - 140px);
}

.chat-page .chat-window {
  min-height: 620px;
  max-height: calc(100vh - 380px);
}

#chatInput {
  flex: 1 1 auto;
  width: auto;
}

.inline-link-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 14px;
  margin: 8px 8px 0 0;
  background: rgba(109, 94, 252, 0.1);
  border: 1px solid rgba(109, 94, 252, 0.18);
  color: #4c1d95;
  font-weight: 700;
}

body.dark-mode .inline-link-btn {
  color: #ddd6fe;
  background: rgba(109, 94, 252, 0.16);
  border-color: rgba(109, 94, 252, 0.22);
}

.lgl-intro-card {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 1fr);
  gap: 18px;
  padding: 24px;
  border-radius: 24px;
  border: 1px solid rgba(113, 133, 194, 0.14);
  background: linear-gradient(135deg, rgba(109, 94, 252, 0.12), rgba(60, 192, 255, 0.12), rgba(255,255,255,0.82));
}

body.dark-mode .lgl-intro-card {
  background: linear-gradient(135deg, rgba(109, 94, 252, 0.16), rgba(60, 192, 255, 0.12), rgba(11, 16, 32, 0.9));
}

.lgl-intro-main h2 {
  font-size: clamp(1.5rem, 2.2vw, 2.4rem);
  font-weight: 800;
  margin: 12px 0;
}

.lgl-intro-main p {
  margin: 0;
  color: var(--text-soft);
  line-height: 1.75;
}

.lgl-intro-highlights {
  display: grid;
  gap: 12px;
}

.lgl-highlight-card {
  padding: 18px;
  border-radius: 20px;
  border: 1px solid rgba(113, 133, 194, 0.14);
  background: rgba(255,255,255,0.76);
  display: grid;
  gap: 6px;
}

body.dark-mode .lgl-highlight-card {
  background: rgba(18, 25, 53, 0.78);
  border-color: rgba(148, 163, 184, 0.14);
}

.lgl-highlight-card strong {
  font-size: 1rem;
}

.eyebrow-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255,255,255,0.72);
  color: #344054;
  font-size: .82rem;
  font-weight: 700;
}

body.dark-mode .eyebrow-chip {
  color: #e2e8f0;
  background: rgba(18, 25, 53, 0.84);
}

.chat-summary-grid {
  margin-bottom: 0;
}

.welcome-message {
  max-width: min(90%, 900px);
}

@media (max-width: 1199px) {
  main.dashboard-container.chat-page {
    grid-template-columns: 280px minmax(0, 1fr);
  }
}

@media (max-width: 992px) {
  main.dashboard-container.chat-page {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .lgl-intro-card {
    grid-template-columns: 1fr;
  }
  .chat-page .chat-window {
    min-height: 460px;
    max-height: unset;
  }
}


.contract-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1rem;
}
.contract-card {
  background: rgba(255,255,255,0.96);
}
.contract-meta-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .75rem;
}
.contract-meta-list div {
  padding: .75rem .9rem;
  border-radius: 16px;
  background: rgba(15, 23, 42, 0.04);
}
.contract-meta-list span {
  display: block;
  font-size: .78rem;
  color: #64748b;
  margin-bottom: .15rem;
}
.contract-meta-list strong {
  display: block;
  font-size: .95rem;
  color: #0f172a;
}
.contract-admin-form .form-control,
.contract-admin-form .form-select {
  border-radius: 14px;
}
.extracted-text-block {
  max-height: 440px;
  overflow: auto;
  white-space: pre-wrap;
  font-size: .95rem;
  line-height: 1.7;
  padding: 1rem 1.1rem;
  border-radius: 20px;
  background: rgba(15, 23, 42, 0.04);
}
.playbook-card {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 1rem;
  padding: 1rem;
  border-radius: 18px;
  background: rgba(15, 23, 42, 0.04);
  margin-bottom: .85rem;
}
.playbook-priority {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  background: linear-gradient(135deg, rgba(37,99,235,.16), rgba(30,41,59,.12));
  color: #1e3a8a;
}
@media (max-width: 768px) {
  .contract-meta-list {
    grid-template-columns: 1fr;
  }
  .playbook-card {
    grid-template-columns: 1fr;
  }
}

.workspace-panels-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.workspace-panel-card {
  align-self: start;
}

.review-config-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.review-quality-strip {
  border-radius: 18px;
  background: rgba(15, 23, 42, 0.04);
  padding: 14px 16px;
}

body.dark-mode .review-quality-strip {
  background: rgba(255,255,255,0.04);
}

.review-issues {
  display: grid;
  gap: 8px;
}

.missing-clauses-section {
  overflow: hidden;
}

.missing-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.missing-grid .missing-card {
  height: 100%;
}

@media (max-width: 991px) {
  .workspace-panels-grid,
  .missing-grid,
  .review-config-grid {
    grid-template-columns: 1fr;
  }
}

.risk-tab-panel { display: none; }
.risk-tab-panel.active { display: block; }
.contract-tab-nav .btn.active { box-shadow: 0 10px 24px rgba(109,94,252,.18); }
.sticky-summary-bar { position: sticky; top: 84px; z-index: 10; backdrop-filter: blur(12px); }
.feedback-form { padding-top: 12px; border-top: 1px solid rgba(109,94,252,.08); }
.compact-grid .risk-summary-card .value { font-size: 1.35rem; }
.review-config-grid .meta-grid-item strong { font-size: .98rem; }
.missing-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 16px; }
@media (max-width: 991px) {
  .missing-grid { grid-template-columns: 1fr; }
  .sticky-summary-bar { top: 68px; }
}

.brand-story-block {
  position: relative;
  overflow: hidden;
}

.brand-story-block::after {
  content: '';
  position: absolute;
  inset: auto -40px -40px auto;
  width: 180px;
  height: 180px;
  background: radial-gradient(circle, rgba(109,94,252,.18) 0%, rgba(109,94,252,0) 70%);
  pointer-events: none;
}

.brand-story-main {
  flex: 1 1 620px;
  min-width: 280px;
}

.brand-story-side {
  flex: 0 1 280px;
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(255,255,255,.72);
  border: 1px solid rgba(109,94,252,.10);
}

.brand-story-card {
  padding: 16px;
  border-radius: 18px;
  background: rgba(255,255,255,.78);
  border: 1px solid rgba(109,94,252,.10);
  box-shadow: 0 10px 28px rgba(17,24,39,.05);
}

@media (max-width: 991px) {
  .brand-story-side {
    flex-basis: 100%;
  }
}

.chart-box-lg {
  position: relative;
  min-height: 320px;
}

.chart-box-lg canvas {
  width: 100% !important;
  height: 320px !important;
}

.svg-chart-wrap {
  display: flex;
  align-items: stretch;
}

.svg-chart {
  width: 100%;
  height: 320px;
  overflow: visible;
}

.due-popup-card {
  padding: 16px 18px;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(255,249,219,.92), rgba(255,255,255,.98));
  border: 1px solid rgba(245, 158, 11, 0.18);
}

body.dark-mode .due-popup-card {
  background: linear-gradient(135deg, rgba(60,45,8,.72), rgba(18,25,53,.86));
  border-color: rgba(245, 158, 11, 0.24);
}


.legal-meta-card .msg-text {
  width: 100%;
}
.legal-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}
.legal-meta-card .meta-list {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(109, 94, 252, 0.05);
}
.legal-meta-card .meta-list ul {
  margin: 8px 0 0 18px;
}
.chat-mode-toolbar .inline-link-btn {
  pointer-events: none;
}
.legal-meta-details {
  width: 100%;
}
.legal-meta-details summary {
  cursor: pointer;
  font-weight: 700;
  margin-bottom: 10px;
}
.legal-meta-details[open] summary {
  margin-bottom: 14px;
}
