/* ═══════════════════════════════════════════════════════════
   LEXSIGN AI — Design System
   Aesthetic: Refined Legal Precision
   Fonts: Sora (display) + DM Mono (code/numbers)
   Palette: Slate-navy sidebar · White canvas · Amber accent
═══════════════════════════════════════════════════════════ */

/* ── Variables ─────────────────────────────────────────── */
:root {
  --sidebar-bg:       #0D1B2A;
  --sidebar-border:   #1A2D42;
  --sidebar-text:     #94A3B8;
  --sidebar-hover:    #1E3448;
  --sidebar-active:   #1D4ED8;
  --sidebar-width:    240px;

  --topbar-h:         58px;
  --topbar-bg:        #FFFFFF;
  --topbar-border:    #E9EEF4;

  --bg-app:           #F4F7FB;
  --bg-card:          #FFFFFF;
  --bg-canvas:        #EDF1F7;

  --text-primary:     #0D1B2A;
  --text-secondary:   #475569;
  --text-muted:       #94A3B8;
  --text-inverse:     #FFFFFF;

  --accent:           #E8A917;
  --accent-light:     #FEF3C7;
  --accent-dark:      #B45309;

  --blue:             #1D4ED8;
  --blue-light:       #DBEAFE;
  --blue-hover:       #1E40AF;

  --green:            #16A34A;
  --green-light:      #DCFCE7;
  --amber:            #D97706;
  --amber-light:      #FEF3C7;
  --red:              #DC2626;
  --red-light:        #FEE2E2;
  --orange:           #EA580C;
  --purple:           #7C3AED;
  --purple-light:     #EDE9FE;

  --border:           #E2E8F0;
  --border-focus:     #1D4ED8;

  --radius-sm:        6px;
  --radius-md:        10px;
  --radius-lg:        14px;
  --radius-xl:        20px;

  --shadow-xs:        0 1px 3px rgba(13,27,42,.06);
  --shadow-sm:        0 2px 8px rgba(13,27,42,.08);
  --shadow-md:        0 4px 16px rgba(13,27,42,.10);
  --shadow-lg:        0 8px 32px rgba(13,27,42,.14);
  --shadow-float:     0 20px 60px rgba(13,27,42,.20);

  --transition:       .18s cubic-bezier(.4,0,.2,1);
  --transition-slow:  .3s cubic-bezier(.4,0,.2,1);
}

/* ── Reset & Base ────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: 'Sora', sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-app);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}

.fw-mono { font-family: 'DM Mono', monospace; }

/* ── Override Bootstrap defaults ────────────────────────── */
.btn {
  font-family: 'Sora', sans-serif;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  letter-spacing: .01em;
}

.btn-primary {
  background: var(--blue);
  border-color: var(--blue);
}
.btn-primary:hover, .btn-primary:focus {
  background: var(--blue-hover);
  border-color: var(--blue-hover);
  box-shadow: 0 2px 8px rgba(29,78,216,.35);
}

.btn-success { background: var(--green); border-color: var(--green); }
.btn-success:hover { background: #15803d; border-color: #15803d; }

.btn-danger { background: var(--red); border-color: var(--red); }
.btn-danger:hover { background: #b91c1c; border-color: #b91c1c; }

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover { background: var(--bg-canvas); color: var(--text-primary); }

.btn-xs {
  padding: 3px 8px;
  font-size: 12px;
  border-radius: 5px;
}

.form-control, .form-select {
  font-family: 'Sora', sans-serif;
  font-size: 13.5px;
  border-color: var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-control:focus, .form-select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(29,78,216,.12);
}
.form-control::placeholder { color: var(--text-muted); }
.form-label { font-size: 13px; font-weight: 500; color: var(--text-secondary); margin-bottom: 5px; }

.badge { font-family: 'Sora', sans-serif; font-size: 11px; font-weight: 600; letter-spacing: .02em; padding: 3px 8px; border-radius: 4px; }

/* ── AUTH SCREENS ────────────────────────────────────────── */
#auth-wrapper {
  min-height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
  overflow: hidden;
}

#auth-wrapper::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    repeating-linear-gradient(0deg, transparent, transparent 59px, rgba(255,255,255,.03) 60px),
    repeating-linear-gradient(90deg, transparent, transparent 59px, rgba(255,255,255,.03) 60px);
  pointer-events: none;
}

#auth-wrapper::after {
  content: '';
  position: absolute;
  top: -200px; right: -200px;
  width: 500px; height: 500px;
  background: radial-gradient(circle, rgba(29,78,216,.15) 0%, transparent 70%);
  pointer-events: none;
}

.auth-screen { width: 100%; max-width: 440px; position: relative; z-index: 1; animation: authFadeIn .4s ease both; }

@keyframes authFadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.auth-card {
  background: rgba(255,255,255,.97);
  backdrop-filter: blur(20px);
  border-radius: var(--radius-xl);
  padding: 40px;
  box-shadow: var(--shadow-float), 0 0 0 1px rgba(255,255,255,.1);
}

.auth-card-wide { max-width: 560px; margin: 0 auto; }
.auth-screen.auth-card-wide { max-width: 560px; }

.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
}

.brand-icon {
  width: 38px; height: 38px;
  background: var(--blue);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: white;
  font-size: 16px;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(29,78,216,.4);
}

.brand-name {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -.02em;
}

.auth-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
  letter-spacing: -.025em;
}

.auth-subtitle {
  font-size: 13.5px;
  color: var(--text-muted);
  margin-bottom: 28px;
}

/* ── APP LAYOUT ──────────────────────────────────────────── */
#app-wrapper {
  display: flex;
  min-height: 100vh;
}

/* ── SIDEBAR ─────────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0; top: 0; bottom: 0;
  z-index: 100;
  transition: transform var(--transition-slow);
  border-right: 1px solid var(--sidebar-border);
}

#sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px 16px;
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

#sidebar-header .brand-name { color: var(--text-inverse); font-size: 16px; }
#sidebar-header .brand-icon { width: 32px; height: 32px; font-size: 14px; }

.btn-sidebar-toggle {
  background: none; border: none;
  color: var(--sidebar-text);
  margin-left: auto;
  padding: 4px 6px;
  font-size: 16px;
  cursor: pointer;
}

#sidebar-company {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

.company-avatar {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--blue) 0%, #3B82F6 100%);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: white;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
  letter-spacing: -.02em;
}

.company-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-inverse);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}

.plan-badge {
  font-size: 10px;
  font-weight: 600;
  color: var(--accent);
  background: rgba(232,169,23,.15);
  padding: 1px 7px;
  border-radius: 3px;
  letter-spacing: .04em;
  text-transform: uppercase;
  width: fit-content;
  margin-top: 2px;
}

#sidebar-nav {
  list-style: none;
  padding: 10px 0;
  flex: 1;
  overflow-y: auto;
  scrollbar-width: none;
}
#sidebar-nav::-webkit-scrollbar { display: none; }

.nav-section-label {
  padding: 14px 16px 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #3D5166;
  user-select: none;
}

.sidebar-nav .nav-link,
.sidebar-footer .nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 13px;
  font-weight: 450;
  border-radius: 0;
  transition: background var(--transition), color var(--transition);
  position: relative;
  cursor: pointer;
}

.sidebar-nav .nav-link i,
.sidebar-footer .nav-link i {
  width: 18px;
  text-align: center;
  font-size: 14px;
  flex-shrink: 0;
}

.sidebar-nav .nav-link:hover {
  background: var(--sidebar-hover);
  color: #CBD5E1;
}

.sidebar-nav .nav-link.active {
  background: rgba(29,78,216,.18);
  color: #93BBFC;
  font-weight: 600;
}

.sidebar-nav .nav-link.active::before {
  content: '';
  position: absolute;
  left: 0; top: 2px; bottom: 2px;
  width: 3px;
  background: var(--blue);
  border-radius: 0 2px 2px 0;
}

.badge-count {
  background: var(--red);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  margin-left: auto;
}

#sidebar-footer {
  padding: 10px 0;
  border-top: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

.sidebar-footer .nav-link:hover { background: var(--sidebar-hover); }
.sidebar-footer .nav-link.text-danger { color: #EF9393 !important; }
.sidebar-footer .nav-link.text-danger:hover { background: rgba(239,68,68,.12); color: #FCA5A5 !important; }

/* ── MAIN CONTENT ─────────────────────────────────────────── */
#main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
}

/* ── TOPBAR ──────────────────────────────────────────────── */
#topbar {
  height: var(--topbar-h);
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--topbar-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 1px 0 var(--topbar-border);
}

#topbar-left { display: flex; align-items: center; gap: 14px; }
#topbar-right { display: flex; align-items: center; gap: 12px; }

.btn-mobile-menu {
  background: none; border: none;
  color: var(--text-secondary);
  font-size: 18px;
  padding: 4px 6px;
  cursor: pointer;
}

.topbar-breadcrumb {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -.01em;
}

.topbar-search {
  position: relative;
  display: flex;
  align-items: center;
}

.topbar-search > i {
  position: absolute;
  left: 11px;
  color: var(--text-muted);
  font-size: 13px;
  pointer-events: none;
}

.topbar-search-input {
  width: 220px;
  padding: 7px 12px 7px 34px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-family: 'Sora', sans-serif;
  background: var(--bg-canvas);
  color: var(--text-primary);
  transition: all var(--transition);
}

.topbar-search-input:focus {
  outline: none;
  border-color: var(--border-focus);
  background: white;
  box-shadow: 0 0 0 3px rgba(29,78,216,.1);
  width: 280px;
}

.topbar-icon-btn {
  background: none; border: none;
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 16px;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  position: relative;
}
.topbar-icon-btn:hover { background: var(--bg-canvas); color: var(--text-primary); }

.notification-dot {
  position: absolute;
  top: 7px; right: 7px;
  width: 7px; height: 7px;
  background: var(--red);
  border-radius: 50%;
  border: 1.5px solid white;
}

.topbar-user-btn {
  background: none; border: none;
  display: flex; align-items: center; gap: 9px;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
  font-family: 'Sora', sans-serif;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-primary);
}
.topbar-user-btn:hover { background: var(--bg-canvas); }
.topbar-user-btn::after { color: var(--text-muted); font-size: 10px; }

.user-avatar-sm {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, #1D4ED8, #3B82F6);
  color: white;
  font-size: 11px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  letter-spacing: -.02em;
  flex-shrink: 0;
}

.user-avatar-lg {
  width: 64px; height: 64px;
  border-radius: 14px;
  background: linear-gradient(135deg, #1D4ED8, #3B82F6);
  color: white;
  font-size: 20px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  letter-spacing: -.02em;
}

/* ── CONTENT AREA ─────────────────────────────────────────── */
#content-area {
  flex: 1;
  padding: 28px 28px;
  max-width: 1440px;
  width: 100%;
}

.content-section { animation: sectionFadeIn .22s ease both; }
@keyframes sectionFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
  flex-wrap: wrap;
  gap: 12px;
}

.section-header h2 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -.025em;
  margin: 0;
}

/* ── KPI CARDS ───────────────────────────────────────────── */
.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-xs);
  transition: transform var(--transition), box-shadow var(--transition);
}
.kpi-card:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.kpi-card-alert { border-color: #FED7AA; background: #FFFBF5; }

.kpi-icon {
  width: 48px; height: 48px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.kpi-blue     { background: var(--blue-light);   color: var(--blue); }
.kpi-green    { background: var(--green-light);  color: var(--green); }
.kpi-amber    { background: var(--amber-light);  color: var(--amber); }
.kpi-red      { background: var(--red-light);    color: var(--red); }
.kpi-purple   { background: var(--purple-light); color: var(--purple); }

.kpi-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -.03em;
  line-height: 1;
  font-family: 'DM Mono', monospace;
}

.kpi-label { font-size: 12.5px; color: var(--text-muted); margin-top: 4px; font-weight: 450; }

/* ── DASH CARDS ──────────────────────────────────────────── */
.dash-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}

.dash-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.dash-card-header h6 {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.dash-card-body { padding: 20px; }
.link-see-all { font-size: 12px; color: var(--blue); text-decoration: none; font-weight: 500; }
.link-see-all:hover { text-decoration: underline; }

/* Status bars */
.status-bars { display: flex; flex-direction: column; gap: 12px; }
.status-bar-row { display: flex; align-items: center; gap: 10px; }
.status-bar-label { font-size: 12px; color: var(--text-muted); width: 130px; flex-shrink: 0; }
.status-bar-track { flex: 1; height: 8px; background: var(--bg-canvas); border-radius: 4px; overflow: hidden; }
.status-bar-fill  { height: 100%; border-radius: 4px; transition: width .6s ease; }
.status-bar-count { font-size: 12px; font-weight: 700; color: var(--text-primary); width: 28px; text-align: right; font-family: 'DM Mono', monospace; }

/* Risk dist */
.risk-dist-row { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.risk-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.risk-dist-label { font-size: 12.5px; color: var(--text-secondary); width: 60px; flex-shrink: 0; }
.risk-dist-track { flex: 1; height: 7px; background: var(--bg-canvas); border-radius: 4px; overflow: hidden; }
.risk-dist-fill  { height: 100%; border-radius: 4px; transition: width .6s ease; }
.risk-dist-count { font-size: 12px; font-weight: 700; font-family: 'DM Mono', monospace; width: 24px; text-align: right; }

/* Activity list */
.activity-list { list-style: none; padding: 0; }
.activity-item { display: flex; gap: 10px; padding: 12px 20px; border-bottom: 1px solid var(--border); }
.activity-item:last-child { border-bottom: none; }
.activity-avatar {
  width: 28px; height: 28px;
  border-radius: 6px;
  background: var(--bg-canvas);
  border: 1px solid var(--border);
  font-size: 10px;
  font-weight: 700;
  color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.activity-user { font-weight: 600; font-size: 12.5px; }
.activity-time { font-size: 11px; color: var(--text-muted); margin-top: 1px; }

/* ── STATUS & RISK BADGES ─────────────────────────────────── */
.badge-risk {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  letter-spacing: .03em;
}
.badge-risk-low      { background: var(--green-light);   color: #15803D; }
.badge-risk-medium   { background: var(--amber-light);   color: #92400E; }
.badge-risk-high     { background: #FFEDD5;              color: #C2410C; }
.badge-risk-critical { background: var(--red-light);     color: var(--red); }

/* ── FILTERS BAR ─────────────────────────────────────────── */
.filters-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 14px 18px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
}

.filter-search {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 200px;
}
.filter-search > i { position: absolute; left: 11px; color: var(--text-muted); font-size: 13px; pointer-events: none; }
.filter-search-input {
  width: 100%;
  padding: 7px 12px 7px 34px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: 'Sora', sans-serif;
  background: var(--bg-canvas);
  color: var(--text-primary);
  transition: all var(--transition);
}
.filter-search-input:focus { outline: none; border-color: var(--border-focus); background: white; box-shadow: 0 0 0 3px rgba(29,78,216,.08); }
.filter-select { max-width: 180px; font-size: 13px; padding: 7px 32px 7px 10px; }

/* ── TABLES ──────────────────────────────────────────────── */
.table-wrapper {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-xs);
}

.table {
  font-size: 13.5px;
  margin: 0;
}

.table thead tr { background: var(--bg-canvas); }
.table thead th {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  white-space: nowrap;
}

.table tbody td {
  padding: 13px 16px;
  border-bottom: 1px solid #F0F4F8;
  vertical-align: middle;
  color: var(--text-primary);
}

.table tbody tr:last-child td { border-bottom: none; }
.table-hover tbody tr:hover { background: #F8FAFD; }
.table-hover tbody tr { transition: background var(--transition); }

/* ── PAGINATION ──────────────────────────────────────────── */
.pagination-wrapper { padding: 14px 0; }

/* ── CONTRACT EDITOR ─────────────────────────────────────── */
.editor-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 20px;
  align-items: start;
}

.editor-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-xs);
}

.editor-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: #FAFBFC;
}
.editor-card-header h6 { font-size: 13px; font-weight: 600; margin: 0; color: var(--text-primary); }

.editor-card-body { padding: 18px; }

.party-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 10px;
}

/* Quill overrides */
.ql-toolbar { border-radius: 0 !important; border: none !important; border-bottom: 1px solid var(--border) !important; background: #FAFBFC; }
.ql-container { border: none !important; font-family: 'Sora', sans-serif !important; font-size: 14px !important; }
.ql-editor { min-height: 400px; padding: 20px !important; }
.ql-editor p { margin-bottom: 8px; }

/* AI Risk panel in editor */
.risk-score-wrapper { display: flex; align-items: center; gap: 12px; }
.risk-score-circle { width: 64px; height: 64px; flex-shrink: 0; }
.score-svg { width: 100%; height: 100%; }
.score-svg-text { font-size: 9px; font-family: 'DM Mono', monospace; font-weight: 700; fill: var(--text-primary); }
.risk-level-badge .badge-risk { font-size: 12px; padding: 3px 10px; }
.risk-summary { font-size: 12px; line-height: 1.4; }

.risk-item-mini {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
}
.risk-item-mini:last-child { border-bottom: none; }
.severity-dot {
  width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0;
}
.severity-low      { background: var(--green); }
.severity-medium   { background: var(--amber); }
.severity-high     { background: var(--orange); }
.severity-critical { background: var(--red); }

/* Versions list */
.versions-list { list-style: none; padding: 0; }
.version-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
.version-item:hover { background: var(--bg-canvas); }
.version-item:last-child { border-bottom: none; }
.version-current { background: var(--blue-light); }
.version-number { font-family: 'DM Mono', monospace; font-size: 11px; font-weight: 700; color: var(--blue); background: var(--blue-light); padding: 2px 7px; border-radius: 4px; flex-shrink: 0; }
.version-meta { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* Comments */
.comment-item { display: flex; gap: 10px; margin-bottom: 12px; }
.comment-avatar { width: 28px; height: 28px; border-radius: 6px; background: var(--blue-light); color: var(--blue); font-size: 10px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.comment-header { display: flex; align-items: center; }
.comment-body { margin-top: 3px; line-height: 1.5; }

/* ── PIPELINE KANBAN ──────────────────────────────────────── */
.kanban-board {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 20px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.kanban-col {
  flex-shrink: 0;
  width: 230px;
  background: var(--bg-canvas);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  overflow: hidden;
}

.kanban-col-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-secondary);
  background: white;
}

.kanban-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.dot-gray   { background: #94A3B8; }
.dot-blue   { background: #3B82F6; }
.dot-purple { background: #8B5CF6; }
.dot-orange { background: #F97316; }
.dot-amber  { background: #F59E0B; }
.dot-green  { background: #22C55E; }
.dot-red    { background: #EF4444; }

.kanban-count { margin-left: auto; background: var(--border); color: var(--text-muted); font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 10px; }

.kanban-cards { padding: 10px; min-height: 120px; display: flex; flex-direction: column; gap: 8px; }

.kanban-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: var(--shadow-xs);
}
.kanban-card:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); border-color: #CBD5E1; }
.kanban-card-title { font-size: 12.5px; font-weight: 600; color: var(--text-primary); margin-bottom: 5px; line-height: 1.4; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.kanban-card-parties { font-size: 11px; color: var(--text-muted); margin-bottom: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kanban-card-footer { display: flex; justify-content: space-between; align-items: center; }
.kanban-empty { padding: 16px; text-align: center; font-size: 12px; color: var(--text-muted); }

/* ── AI PANELS ───────────────────────────────────────────── */
.ai-placeholder {
  text-align: center;
  padding: 48px 24px;
}

.ai-placeholder-icon {
  font-size: 40px;
  color: var(--text-muted);
  margin-bottom: 14px;
  opacity: .5;
}

.ai-placeholder p {
  font-size: 14px;
  color: var(--text-muted);
  max-width: 320px;
  margin: 0 auto 20px;
  line-height: 1.6;
}

.ai-features { display: flex; flex-direction: column; gap: 8px; max-width: 280px; margin: 0 auto; text-align: left; }
.ai-feature { font-size: 13px; color: var(--text-secondary); }

.ai-gen-output {
  padding: 20px;
  font-size: 14px;
  line-height: 1.8;
  color: var(--text-primary);
  max-height: 600px;
  overflow-y: auto;
  border-top: 1px solid var(--border);
}
.ai-gen-output h1, .ai-gen-output h2 { font-size: 16px; font-weight: 700; margin: 20px 0 10px; color: var(--text-primary); }
.ai-gen-output h3 { font-size: 14px; font-weight: 600; margin: 16px 0 8px; }
.ai-gen-output p  { margin-bottom: 10px; }

/* Risk analysis items */
.risk-item {
  border: 1px solid var(--border);
  border-left-width: 3px;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 10px;
  background: white;
}
.risk-low      { border-left-color: var(--green); }
.risk-medium   { border-left-color: var(--amber); }
.risk-high     { border-left-color: var(--orange); }
.risk-critical { border-left-color: var(--red); background: #FFF5F5; }

.risk-item-header { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.risk-item-title  { font-size: 13.5px; font-weight: 600; }
.risk-severity-badge {
  font-size: 10px; font-weight: 800;
  padding: 2px 7px; border-radius: 3px;
  letter-spacing: .06em; flex-shrink: 0;
}
.severity-low      { background: var(--green-light); color: var(--green); }
.severity-medium   { background: var(--amber-light); color: var(--amber); }
.severity-high     { background: #FFEDD5; color: var(--orange); }
.severity-critical { background: var(--red-light); color: var(--red); }

.risk-item-desc { color: var(--text-muted); line-height: 1.5; }
.risk-item-rec  { color: var(--text-secondary); margin-top: 6px; }

/* Score circle lg */
.analyze-score-section { display: flex; gap: 24px; align-items: center; }
.score-circle-lg {
  width: 80px; height: 80px; flex-shrink: 0;
  border-radius: 50%;
  background: conic-gradient(var(--green) calc(var(--pct, 0) * 1%), #E5E7EB 0);
  display: flex; align-items: center; justify-content: center;
  position: relative;
}
.score-circle-content {
  width: 60px; height: 60px;
  border-radius: 50%;
  background: white;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  position: absolute;
}
.score-number { font-family: 'DM Mono', monospace; font-size: 20px; font-weight: 700; line-height: 1; }
.score-label  { font-size: 10px; color: var(--text-muted); }

/* Devil Advocate */
.attack-point {
  border: 1px solid var(--border);
  border-left-width: 3px;
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 12px;
}
.attack-critical { border-left-color: var(--red); background: #FFF8F8; }
.attack-high     { border-left-color: var(--orange); }
.attack-medium   { border-left-color: var(--amber); }
.attack-low      { border-left-color: var(--blue); }

.attack-header { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.attack-title  { font-size: 13.5px; font-weight: 600; flex: 1; }
.attack-clause { font-family: 'DM Mono', monospace; font-size: 11px; background: var(--bg-canvas); padding: 2px 7px; border-radius: 3px; }
.attack-argument { font-size: 13px; color: var(--text-primary); line-height: 1.6; margin-bottom: 6px; }
.attack-legal { font-size: 12px; margin-bottom: 6px; }
.attack-counter { font-size: 12px; background: var(--green-light); padding: 6px 10px; border-radius: 5px; }

/* ── SIGNATURE ───────────────────────────────────────────── */
.signers-avatars { display: flex; gap: -4px; }
.signer-avatar {
  width: 26px; height: 26px;
  border-radius: 6px;
  font-size: 9px;
  font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
  border: 2px solid white;
  margin-right: -4px;
  color: white;
}
.signer-pending { background: var(--text-muted); }
.signer-sent    { background: var(--blue); }
.signer-signed  { background: var(--green); }
.signer-declined{ background: var(--red); }
.signer-viewed  { background: var(--amber); }

.sig-progress { width: 80px; height: 6px; background: var(--bg-canvas); border-radius: 3px; overflow: hidden; margin-bottom: 3px; }
.sig-progress-bar { height: 100%; background: var(--green); border-radius: 3px; transition: width .4s ease; }

/* Signer row in modal */
.signer-row { animation: slideDown .15s ease; }
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── MARKETPLACE ─────────────────────────────────────────── */
.lawyer-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-xs);
  transition: all var(--transition);
  display: flex;
  flex-direction: column;
  gap: 14px;
  height: 100%;
}
.lawyer-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: #CBD5E1; }

.lawyer-card-header { display: flex; align-items: flex-start; gap: 12px; }

.lawyer-avatar {
  width: 46px; height: 46px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--blue), #3B82F6);
  color: white;
  font-size: 14px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.lawyer-avatar-lg {
  width: 64px; height: 64px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--blue), #3B82F6);
  color: white;
  font-size: 20px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.lawyer-name  { font-size: 14px; font-weight: 700; }
.lawyer-headline { font-size: 12px; margin-top: 2px; }

.lawyer-rating { display: flex; align-items: center; gap: 5px; font-size: 12px; margin-bottom: 6px; }
.lawyer-rating .fa-star { font-size: 11px; }

.lawyer-details { display: flex; flex-direction: column; gap: 4px; }
.lawyer-detail  { font-size: 12px; color: var(--text-muted); }

.lawyer-specialties { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.specialty-tag {
  font-size: 11px;
  font-weight: 500;
  background: var(--blue-light);
  color: var(--blue);
  padding: 2px 9px;
  border-radius: 4px;
}

.lawyer-card-footer { display: flex; justify-content: space-between; align-items: center; margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border); }
.lawyer-rate { font-family: 'DM Mono', monospace; font-size: 14px; font-weight: 700; color: var(--text-primary); }

/* Requests */
.request-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-xs);
  transition: all var(--transition);
}
.request-card:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.request-proposals { font-size: 13px; color: var(--text-secondary); }

/* ── BILLING / PLANS ─────────────────────────────────────── */
.plan-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 28px 24px;
  box-shadow: var(--shadow-xs);
  transition: all var(--transition-slow);
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 20px;
  height: 100%;
}
.plan-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.plan-featured {
  border-color: var(--blue);
  box-shadow: 0 0 0 2px rgba(29,78,216,.15), var(--shadow-md);
}
.plan-current {
  border-color: var(--green);
  background: linear-gradient(135deg, #F0FDF4 0%, white 100%);
}

.plan-popular-badge {
  position: absolute;
  top: -11px; left: 50%; transform: translateX(-50%);
  background: var(--blue);
  color: white;
  font-size: 10px;
  font-weight: 800;
  padding: 3px 14px;
  border-radius: 20px;
  letter-spacing: .06em;
  text-transform: uppercase;
  white-space: nowrap;
}

.plan-name  { font-size: 14px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; }
.plan-price {
  font-family: 'DM Mono', monospace;
  font-size: 30px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -.03em;
  line-height: 1;
}
.plan-period { font-family: 'Sora', sans-serif; font-size: 14px; font-weight: 400; color: var(--text-muted); }
.plan-icon-circle {
  width: 48px; height: 48px;
  border-radius: var(--radius-md);
  background: var(--accent-light);
  color: var(--accent-dark);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
}

.plan-features {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}
.plan-features li { font-size: 13px; color: var(--text-secondary); display: flex; align-items: center; }

.current-plan-info { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }

/* Invoices */
.fw-mono { font-family: 'DM Mono', monospace; }

/* ── MESSAGES / CHAT ─────────────────────────────────────── */
.messages-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  height: calc(100vh - var(--topbar-h) - 130px);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-xs);
}

.conversations-sidebar {
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: #FAFBFC;
}

.conversations-search { padding: 12px; border-bottom: 1px solid var(--border); }

.conversations-list { flex: 1; overflow-y: auto; }

.conv-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
.conv-item:hover { background: #EDF1F7; }
.conv-active     { background: var(--blue-light); }
.conv-avatar {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  background: var(--blue);
  color: white;
  font-size: 12px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.chat-area { display: flex; flex-direction: column; }
.chat-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; }

.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: white;
  flex-shrink: 0;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #F8FAFD;
}

.chat-msg { display: flex; flex-direction: column; max-width: 70%; }
.chat-msg-mine  { align-self: flex-end; align-items: flex-end; }
.chat-msg-theirs{ align-self: flex-start; align-items: flex-start; }

.chat-bubble {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.5;
}
.chat-msg-mine  .chat-bubble { background: var(--blue); color: white; border-radius: 14px 14px 4px 14px; }
.chat-msg-theirs .chat-bubble { background: white; color: var(--text-primary); border: 1px solid var(--border); border-radius: 14px 14px 14px 4px; }
.chat-meta { font-size: 11px; margin-top: 3px; }

.chat-input-area {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: white;
  flex-shrink: 0;
}

/* ── SETTINGS ────────────────────────────────────────────── */
.settings-nav { padding: 8px; }
.settings-nav-btn {
  display: block;
  width: 100%;
  text-align: left;
  padding: 9px 12px;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-family: 'Sora', sans-serif;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  font-weight: 450;
}
.settings-nav-btn:hover  { background: var(--bg-canvas); color: var(--text-primary); }
.settings-nav-btn.active { background: var(--blue-light); color: var(--blue); font-weight: 600; }

/* Integrations */
.integration-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: all var(--transition);
}
.integration-card:hover { border-color: #CBD5E1; box-shadow: var(--shadow-xs); }
.integration-icon {
  width: 40px; height: 40px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.integration-card .btn { margin-left: auto; flex-shrink: 0; }

/* Team table */
#table-team { font-size: 13.5px; }

/* ── MODALS ──────────────────────────────────────────────── */
.modal-content {
  border: none;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-float);
  overflow: hidden;
}

.modal-header {
  background: #FAFBFC;
  border-bottom: 1px solid var(--border);
  padding: 18px 24px;
}

.modal-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -.01em;
}

.modal-body   { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); background: #FAFBFC; }

/* ── TOAST ───────────────────────────────────────────────── */
#toast-main {
  border: none;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  min-width: 300px;
}

/* ── LOADING OVERLAY ─────────────────────────────────────── */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(13,27,42,.7);
  backdrop-filter: blur(4px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.loading-spinner-wrapper {
  text-align: center;
  color: white;
}

.loading-brand {
  font-size: 36px;
  color: var(--blue);
  margin-bottom: 8px;
}

.loading-text {
  font-size: 14px;
  color: rgba(255,255,255,.7);
}

/* ── SIDEBAR OVERLAY (mobile) ─────────────────────────────── */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(13,27,42,.5);
  z-index: 99;
  backdrop-filter: blur(2px);
}

/* ── NOTIF SETTINGS ──────────────────────────────────────── */
.notif-group { padding-bottom: 20px; border-bottom: 1px solid var(--border); }
.notif-group:last-child { border-bottom: none; }

/* ── DROPDOWN ────────────────────────────────────────────── */
.dropdown-menu {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  font-size: 13.5px;
}

.dropdown-item {
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-family: 'Sora', sans-serif;
  font-size: 13.5px;
  transition: background var(--transition);
}
.dropdown-item:hover { background: var(--bg-canvas); }
.dropdown-item.text-danger:hover { background: var(--red-light); }

/* ── ALERTS ──────────────────────────────────────────────── */
.alert {
  border-radius: var(--radius-md);
  font-size: 13.5px;
  border: none;
  padding: 12px 16px;
}
.alert-warning { background: var(--amber-light); color: #92400E; }
.alert-success { background: var(--green-light); color: #14532D; }
.alert-danger  { background: var(--red-light);   color: #991B1B; }
.alert-info    { background: var(--blue-light);  color: #1E40AF; }
/* ── PDF Dropzone ── */
.pdf-dropzone {
  border: 2px dashed #D1D5DB;
  border-radius: 10px;
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: all .2s ease;
  background: #FAFAFA;
}
.pdf-dropzone:hover,
.pdf-dropzone.dragover {
  border-color: #1D4ED8;
  background: #EFF6FF;
  color: #1D4ED8;
}
/* ── RESPONSIVE ──────────────────────────────────────────── */
@media (max-width: 991.98px) {
  :root { --sidebar-width: 0px; }

  #sidebar {
    transform: translateX(-100%);
    width: 240px;
    z-index: 200;
  }
  #sidebar.sidebar-open { transform: translateX(0); }

  #main-content { margin-left: 0; }

  .editor-layout { grid-template-columns: 1fr; }
  #editor-sidebar { order: -1; }

  .kanban-board { padding-bottom: 16px; }
  .messages-layout { grid-template-columns: 1fr; height: auto; }
  .conversations-sidebar { display: none; }

  #content-area { padding: 16px; }
  .section-header h2 { font-size: 17px; }
  .topbar-search { display: none; }
}

@media (max-width: 767.98px) {
  .kpi-card { padding: 14px; }
  .kpi-value { font-size: 22px; }
  .kpi-icon { width: 40px; height: 40px; font-size: 16px; }

  .filters-bar { padding: 10px 12px; }
  .filter-select { max-width: 140px; }

  .auth-card { padding: 28px 22px; }
  .plans-grid .col-md-4 { width: 100%; }

  .analyze-score-section { flex-direction: column; align-items: flex-start; }
}

/* ── SCROLLBAR ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #CBD5E1; }

/* ── SELECTION ───────────────────────────────────────────── */
::selection { background: rgba(29,78,216,.18); color: var(--text-primary); }

/* ── PRINT ───────────────────────────────────────────────── */
@media print {
  #sidebar, #topbar, .editor-sidebar, .filters-bar { display: none !important; }
  #main-content { margin-left: 0; }
  .editor-main { width: 100%; }
}
