/* ── LegalPro — Main Stylesheet ─────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Playfair+Display:ital,wght@0,600;0,700;0,800;1,600;1,700&display=swap');

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

:root {
  --dark:      #111318;
  --dark2:     #1C2028;
  --charcoal:  #2A2F3A;
  --accent:    #5B8DB8;
  --accent-lt: #A8C5DC;
  --accent-bg: #EBF2F8;
  --light-bg:  #F3F5F7;
  --white:     #FFFFFF;
  --border:    #DDE2E9;
  --border2:   #C8D0DA;
  --text:      #1A1D23;
  --text2:     #3D4350;
  --muted:     #7A8291;
  --soft:      #9BA3AF;
  --status-ok:   #5A8A72;
  --status-warn: #8A7855;
  --status-err:  #8A5B5B;
  --shadow-sm: 0 1px 4px rgba(0,0,0,.06);
  --shadow-md: 0 4px 16px rgba(0,0,0,.09);
  --radius:    12px;
  --sidebar-w: 260px;
}

html, body { height: 100%; font-family: 'Inter', sans-serif; background: var(--light-bg); color: var(--text); }

h1, h2, h3, .topbar-title, .card-title, .stat-value,
.brand-text strong, .welcome-text h2, .panel-header,
.case-name, .doc-name, .user-row-name, .td-bold, .modal-title {
  font-family: 'Playfair Display', Georgia, serif;
}

/* ── APP LAYOUT ─── */
#app { display: flex; height: 100vh; overflow: hidden; }

/* ── SIDEBAR ─── */
aside {
  width: var(--sidebar-w); background: var(--dark);
  display: flex; flex-direction: column; flex-shrink: 0;
  box-shadow: 2px 0 20px rgba(0,0,0,.22); z-index: 10;
}
.sidebar-brand { padding: 26px 22px 18px; border-bottom: 1px solid rgba(255,255,255,.06); }
.brand-logo { display: flex; align-items: center; gap: 11px; }
.brand-icon {
  width: 38px; height: 38px; border-radius: 9px;
  background: var(--accent); display: grid; place-items: center;
  font-size: 16px; color: #fff; box-shadow: 0 3px 10px rgba(91,141,184,.35);
}
.brand-text strong { font-size: 16px; font-weight: 800; color: #fff; letter-spacing: -.3px; }
.brand-text span { font-size: 10.5px; color: rgba(255,255,255,.35); text-transform: uppercase; letter-spacing: 1.2px; }

.sidebar-nav { flex: 1; padding: 14px 10px; overflow-y: auto; }
.nav-section-label {
  font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.4px;
  color: rgba(255,255,255,.22); padding: 14px 12px 5px;
}
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 13px; border-radius: 8px; cursor: pointer;
  transition: all .16s; color: rgba(255,255,255,.5);
  font-size: 13px; font-weight: 500; margin-bottom: 1px;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: rgba(255,255,255,.85); }
.nav-item.active { background: rgba(91,141,184,.18); color: #fff; border-left: 2px solid var(--accent); padding-left: 11px; }
.nav-item i { width: 16px; text-align: center; font-size: 13px; opacity: .8; }
.nav-badge {
  margin-left: auto; background: rgba(255,255,255,.12); color: rgba(255,255,255,.7);
  font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 10px; min-width: 20px; text-align: center;
}
.nav-badge.alert { background: rgba(138,91,91,.4); color: #D4A0A0; }

.sidebar-footer { padding: 14px 10px; border-top: 1px solid rgba(255,255,255,.06); }
.user-card {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 8px;
  background: rgba(255,255,255,.04); cursor: pointer;
}
.user-card:hover { background: rgba(255,255,255,.07); }

/* ── AVATARS ─── */
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--accent); display: grid; place-items: center;
  font-size: 12px; font-weight: 700; color: #fff; flex-shrink: 0;
}
.avatar.sm { width: 28px; height: 28px; font-size: 10px; }
.avatar.lg { width: 44px; height: 44px; font-size: 15px; }
.avatar-group { display: flex; }
.avatar-group .avatar { margin-left: -7px; border: 2px solid #fff; }
.avatar-group .avatar:first-child { margin-left: 0; }

.user-info strong { display: block; font-size: 12.5px; color: rgba(255,255,255,.9); font-weight: 600; }
.user-info span { font-size: 11px; color: rgba(255,255,255,.32); }

/* ── TOPBAR ─── */
header {
  background: var(--white); border-bottom: 1px solid var(--border);
  padding: 0 30px; height: 62px;
  display: flex; align-items: center; gap: 14px;
  flex-shrink: 0; box-shadow: var(--shadow-sm);
}
.topbar-title { font-size: 17px; font-weight: 700; color: var(--charcoal); flex: 1; }
.topbar-title span { color: var(--muted); font-family: 'Inter', sans-serif; font-weight: 400; font-size: 15px; }

.search-box {
  display: flex; align-items: center; gap: 8px;
  background: var(--light-bg); border: 1.5px solid var(--border);
  border-radius: 8px; padding: 7px 13px; width: 250px; transition: border-color .2s;
}
.search-box:focus-within { border-color: var(--accent); background: #fff; }
.search-box i { color: var(--soft); font-size: 12px; }
.search-box input { border: none; background: none; outline: none; font-size: 13px; color: var(--text); width: 100%; font-family: inherit; }

/* ── BUTTONS ─── */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 16px; border-radius: 7px; border: none;
  font-size: 13px; font-weight: 600; cursor: pointer;
  transition: all .16s; white-space: nowrap; font-family: inherit;
}
.btn-primary { background: var(--dark); color: #fff; box-shadow: 0 2px 8px rgba(0,0,0,.2); }
.btn-primary:hover { background: var(--charcoal); transform: translateY(-1px); }
.btn-outline { background: #fff; color: var(--text2); border: 1.5px solid var(--border); }
.btn-outline:hover { background: var(--light-bg); border-color: var(--border2); }
.btn-ghost { background: transparent; color: var(--muted); border: none; padding: 7px 9px; }
.btn-ghost:hover { background: var(--light-bg); color: var(--text); }
.btn-accent { background: var(--accent-bg); color: var(--accent); border: 1.5px solid var(--accent-lt); }
.btn-accent:hover { background: #dce9f3; }
.btn-danger { background: #f5eeee; color: var(--status-err); border: 1.5px solid #ddc4c4; }
.btn-danger:hover { background: #eedddd; }
.btn-sm { padding: 5px 11px; font-size: 12px; border-radius: 6px; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none !important; }

.icon-btn {
  width: 36px; height: 36px; border-radius: 8px;
  border: 1.5px solid var(--border); background: #fff;
  display: grid; place-items: center; cursor: pointer;
  color: var(--muted); font-size: 14px; transition: all .16s;
}
.icon-btn:hover { background: var(--light-bg); color: var(--text); border-color: var(--border2); }
.icon-btn.notif { position: relative; }
.notif-dot {
  position: absolute; top: 6px; right: 6px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--status-err); border: 2px solid #fff;
}

/* ── CONTENT ─── */
main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.content { flex: 1; overflow-y: auto; padding: 28px 30px; }

/* ── VIEWS ─── */
.view { display: none; }
.view.active { display: block; animation: fadeUp .22s ease; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* ── PAGE HEADER ─── */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 24px; }
.page-header h1 { font-size: 22px; font-weight: 800; color: var(--dark); }
.page-header p { font-size: 13px; color: var(--muted); margin-top: 4px; }
.page-actions { display: flex; gap: 8px; align-items: center; }

/* ── CARDS ─── */
.card { background: #fff; border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow-sm); }
.card-header { padding: 18px 22px 0; display: flex; align-items: center; justify-content: space-between; }
.card-title { font-size: 14px; font-weight: 700; color: var(--charcoal); }
.card-body { padding: 18px 22px; }

/* ── STAT CARDS ─── */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: #fff; border-radius: var(--radius); border: 1px solid var(--border);
  padding: 20px 22px; box-shadow: var(--shadow-sm);
  transition: box-shadow .2s, transform .2s; cursor: default;
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.stat-icon { width: 40px; height: 40px; border-radius: 9px; display: grid; place-items: center; font-size: 16px; margin-bottom: 14px; background: var(--light-bg); color: var(--accent); }
.stat-icon.warn { background: #f5eeee; color: var(--status-err); }
.stat-value { font-size: 26px; font-weight: 800; color: var(--dark); line-height: 1; }
.stat-label { font-size: 12.5px; color: var(--muted); margin-top: 4px; font-weight: 500; }
.stat-change { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 600; margin-top: 10px; padding: 3px 8px; border-radius: 20px; background: var(--light-bg); color: var(--muted); }
.stat-change.up { color: var(--status-ok); background: #f0f7f4; }
.stat-change.alert { color: var(--status-err); background: #f7f0f0; }

/* ── GRID LAYOUTS ─── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.grid-65-35 { display: grid; grid-template-columns: 1.85fr 1fr; gap: 16px; }

/* ── TABLES ─── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .8px; color: var(--soft); padding: 9px 14px; background: var(--light-bg); border-bottom: 1px solid var(--border); }
th:first-child { border-radius: 7px 0 0 7px; }
th:last-child { border-radius: 0 7px 7px 0; }
td { padding: 13px 14px; font-size: 13px; border-bottom: 1px solid #F0F3F6; color: var(--text2); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #FAFBFC; }
.td-bold { font-weight: 600; color: var(--charcoal); }

/* ── BADGES ─── */
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 20px; }
.badge::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.badge-blue   { background: var(--accent-bg); color: var(--accent); }
.badge-green  { background: #EEF5F1; color: var(--status-ok); }
.badge-amber  { background: #F5F0E8; color: var(--status-warn); }
.badge-red    { background: #F5EEEE; color: var(--status-err); }
.badge-grey   { background: var(--light-bg); color: var(--muted); }
.badge-dark   { background: var(--dark); color: rgba(255,255,255,.85); }
.badge-dark::before { opacity: .5; }

/* ── TAGS ─── */
.tag { display: inline-block; padding: 2px 7px; border-radius: 4px; font-size: 10.5px; font-weight: 600; background: var(--light-bg); color: var(--muted); border: 1px solid var(--border); }

/* ── PROGRESS ─── */
.progress-bar { height: 5px; background: var(--light-bg); border-radius: 10px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 10px; background: var(--accent); transition: width .4s ease; }

/* ── TIMELINE ─── */
.timeline { display: flex; flex-direction: column; }
.timeline-item { display: flex; gap: 12px; padding-bottom: 16px; position: relative; }
.timeline-item:not(:last-child)::before { content: ''; position: absolute; left: 15px; top: 34px; bottom: 0; width: 1px; background: var(--border); }
.timeline-dot { width: 32px; height: 32px; flex-shrink: 0; border-radius: 50%; display: grid; place-items: center; font-size: 12px; border: 1px solid var(--border); background: var(--light-bg); color: var(--muted); position: relative; z-index: 1; }
.timeline-dot.accent { background: var(--accent-bg); border-color: var(--accent-lt); color: var(--accent); }
.timeline-body { flex: 1; padding-top: 4px; }
.timeline-body strong { font-size: 13px; font-weight: 600; color: var(--charcoal); font-family: 'Playfair Display', serif; }
.timeline-body p { font-size: 12px; color: var(--muted); margin-top: 2px; }
.timeline-time { font-size: 11px; color: var(--soft); }

/* ── FILTER BAR ─── */
.filter-bar { display: flex; gap: 7px; align-items: center; margin-bottom: 18px; flex-wrap: wrap; }
.filter-pill { padding: 6px 13px; border-radius: 20px; font-size: 12px; font-weight: 600; border: 1.5px solid var(--border); background: #fff; cursor: pointer; transition: all .14s; color: var(--muted); }
.filter-pill:hover { border-color: var(--accent-lt); color: var(--accent); }
.filter-pill.active { background: var(--dark); border-color: var(--dark); color: #fff; }

/* ── DEADLINE ─── */
.deadline { font-size: 11.5px; font-weight: 600; display: inline-flex; align-items: center; gap: 4px; }
.deadline.urgent { color: var(--status-err); }
.deadline.soon   { color: var(--status-warn); }
.deadline.ok     { color: var(--status-ok); }

/* ── PRIORITY BAR ─── */
.priority { width: 3px; border-radius: 2px; align-self: stretch; flex-shrink: 0; }
.priority.high { background: var(--status-err); opacity: .7; }
.priority.med  { background: var(--status-warn); opacity: .7; }
.priority.low  { background: var(--status-ok); opacity: .7; }

/* ── WELCOME BANNER ─── */
.welcome-banner {
  background: var(--dark); border-radius: var(--radius);
  padding: 26px 30px; color: #fff; margin-bottom: 24px;
  position: relative; overflow: hidden;
}
.welcome-banner::before { content: ''; position: absolute; right: -40px; top: -40px; width: 220px; height: 220px; border-radius: 50%; background: rgba(91,141,184,.08); }
.welcome-banner::after { content: ''; position: absolute; right: 90px; bottom: -70px; width: 160px; height: 160px; border-radius: 50%; background: rgba(91,141,184,.06); }
.welcome-text h2 { font-size: 19px; font-weight: 800; color: #fff; }
.welcome-text p { font-size: 13px; color: rgba(255,255,255,.5); margin-top: 5px; }
.welcome-text strong { color: rgba(255,255,255,.85); font-weight: 600; }
.welcome-quick { display: flex; gap: 10px; margin-top: 18px; position: relative; z-index: 1; }
.quick-btn { padding: 8px 16px; border-radius: 7px; font-size: 12.5px; font-weight: 600; cursor: pointer; border: none; transition: all .18s; font-family: inherit; }
.quick-btn.white { background: #fff; color: var(--dark); }
.quick-btn.white:hover { background: #e8ecf0; }
.quick-btn.outline { background: rgba(255,255,255,.08); color: rgba(255,255,255,.75); border: 1.5px solid rgba(255,255,255,.14); }
.quick-btn.outline:hover { background: rgba(255,255,255,.13); }

/* ── DOCUMENT CARDS ─── */
.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
.doc-card { background: #fff; border: 1.5px solid var(--border); border-radius: 11px; padding: 18px; cursor: pointer; transition: all .18s; display: flex; flex-direction: column; gap: 10px; }
.doc-card:hover { border-color: var(--accent-lt); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.doc-icon { width: 44px; height: 52px; border-radius: 7px; background: var(--light-bg); border: 1.5px solid var(--border); display: grid; place-items: center; font-size: 20px; color: var(--accent); position: relative; }
.doc-icon::after { content: ''; position: absolute; top: -1px; right: -1px; width: 14px; height: 14px; background: var(--white); border-bottom-left-radius: 5px; border-top: 1.5px solid var(--border); border-left: 1.5px solid var(--border); }
.doc-meta { font-size: 11.5px; color: var(--muted); }
.doc-footer { display: flex; align-items: center; justify-content: space-between; margin-top: auto; }

/* ── NOTIF ─── */
.notif-item { display: flex; gap: 11px; padding: 13px; border-bottom: 1px solid #F2F4F7; cursor: pointer; transition: background .14s; }
.notif-item:hover { background: var(--light-bg); }
.notif-item.unread { border-left: 2px solid var(--accent); padding-left: 11px; }
.notif-icon { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; flex-shrink: 0; background: var(--light-bg); color: var(--muted); }
.notif-text strong { font-size: 12.5px; color: var(--charcoal); font-family: 'Playfair Display', serif; }
.notif-text p { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.notif-time { font-size: 10.5px; color: var(--soft); flex-shrink: 0; }

/* ── CASE ROWS ─── */
.case-row { display: flex; align-items: center; gap: 12px; padding: 14px; border: 1px solid var(--border); border-radius: 10px; background: #fff; margin-bottom: 8px; cursor: pointer; transition: all .18s; }
.case-row:hover { border-color: var(--accent-lt); box-shadow: var(--shadow-sm); }
.case-row.selected { border-color: var(--accent); background: var(--accent-bg); }
.case-id { font-size: 10.5px; font-weight: 700; color: var(--accent); font-family: monospace; }
.case-body { flex: 1; }

/* ── EDITOR ─── */
.editor-layout { display: grid; grid-template-columns: 260px 1fr 260px; gap: 16px; height: calc(100vh - 200px); }
.editor-panel { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.panel-header { padding: 14px 18px; background: var(--light-bg); border-bottom: 1px solid var(--border); font-size: 12.5px; font-weight: 700; color: var(--charcoal); display: flex; align-items: center; justify-content: space-between; }
.editor-toolbar { display: flex; gap: 3px; padding: 9px 14px; border-bottom: 1px solid var(--border); background: var(--light-bg); flex-wrap: wrap; align-items: center; }
.tool-btn { width: 28px; height: 28px; border-radius: 5px; border: 1px solid transparent; background: transparent; display: grid; place-items: center; cursor: pointer; font-size: 12px; color: var(--muted); transition: all .13s; font-family: inherit; }
.tool-btn:hover { background: var(--border); color: var(--charcoal); }
.tool-btn.active { background: var(--dark); color: #fff; }
.tool-sep { width: 1px; height: 18px; background: var(--border); margin: 0 4px; }
.editor-body { flex: 1; padding: 26px 34px; font-size: 14px; line-height: 1.85; color: var(--text); overflow-y: auto; outline: none; }
.editor-status { padding: 9px 14px; background: var(--light-bg); border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; font-size: 11.5px; color: var(--muted); }
.clause-item { padding: 10px 14px; cursor: pointer; border-bottom: 1px solid var(--border); font-size: 12.5px; transition: background .13s; }
.clause-item:hover { background: var(--light-bg); }
.clause-item.active { background: var(--accent-bg); border-left: 2px solid var(--accent); }
.clause-title { font-weight: 600; color: var(--charcoal); font-size: 12.5px; font-family: 'Playfair Display', serif; }
.clause-sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; }

/* ── CHAT ─── */
.chat-area { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.chat-msg { display: flex; gap: 9px; max-width: 86%; }
.chat-msg.mine { align-self: flex-end; flex-direction: row-reverse; }
.chat-bubble { padding: 9px 13px; border-radius: 12px; font-size: 13px; line-height: 1.5; }
.chat-msg:not(.mine) .chat-bubble { background: var(--light-bg); color: var(--text); border-bottom-left-radius: 3px; }
.chat-msg.mine .chat-bubble { background: var(--dark); color: rgba(255,255,255,.9); border-bottom-right-radius: 3px; }
.chat-name { font-size: 10.5px; color: var(--muted); margin-bottom: 3px; }
.chat-msg.mine .chat-name { text-align: right; }
.chat-time { font-size: 10px; color: var(--soft); margin-top: 3px; }
.chat-input-bar { padding: 11px 14px; border-top: 1px solid var(--border); display: flex; gap: 9px; align-items: center; }
.chat-input { flex: 1; padding: 9px 13px; border: 1.5px solid var(--border); border-radius: 7px; font-size: 13px; outline: none; font-family: inherit; color: var(--text); transition: border-color .2s; }
.chat-input:focus { border-color: var(--accent); }
.typing-indicator { font-size: 11px; color: var(--soft); padding: 4px 16px; font-style: italic; }

/* ── DONUT CHART ─── */
.donut-wrap { display: flex; align-items: center; gap: 18px; }
.donut { position: relative; width: 110px; height: 110px; flex-shrink: 0; }
.donut svg { transform: rotate(-90deg); }
.donut-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.donut-center strong { font-size: 20px; font-weight: 800; color: var(--dark); font-family: 'Playfair Display', serif; }
.donut-center span { font-size: 10.5px; color: var(--muted); }
.donut-legend { display: flex; flex-direction: column; gap: 7px; }
.legend-item { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text2); }
.legend-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }

/* ── BAR CHART ─── */
.chart-placeholder { width: 100%; height: 170px; background: var(--light-bg); border-radius: 9px; display: flex; align-items: flex-end; padding: 14px; gap: 7px; overflow: hidden; }
.chart-bar-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.chart-bar { width: 100%; border-radius: 5px 5px 0 0; background: var(--accent-lt); transition: opacity .2s; cursor: default; }
.chart-bar:hover { opacity: .75; }
.chart-bar.current { background: var(--accent); }
.chart-label { font-size: 10px; color: var(--soft); font-weight: 600; }

/* ── ADMIN ─── */
.admin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.user-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid #F0F3F6; }
.user-row:last-child { border-bottom: none; padding-bottom: 0; }
.user-row-info { flex: 1; }
.user-row-role { font-size: 11.5px; color: var(--muted); }
.role-badge { font-size: 10.5px; font-weight: 700; padding: 3px 9px; border-radius: 20px; }
.role-admin    { background: var(--dark); color: rgba(255,255,255,.85); }
.role-senior   { background: var(--accent-bg); color: var(--accent); }
.role-junior   { background: var(--light-bg); color: var(--muted); border: 1px solid var(--border); }
.role-paralegal{ background: #F5F0E8; color: var(--status-warn); }

/* ── PERMISSIONS GRID ─── */
.perm-grid { display: grid; grid-template-columns: 1fr auto auto auto auto; font-size: 12px; }
.perm-header { padding: 7px 0; font-weight: 700; color: var(--soft); border-bottom: 1px solid var(--border); }
.perm-header.center { text-align: center; padding: 7px; }
.perm-row-label { padding: 9px 0; border-bottom: 1px solid #F0F3F6; color: var(--text2); }
.perm-cell { padding: 9px; text-align: center; border-bottom: 1px solid #F0F3F6; }
.perm-cell .fa-check { color: var(--status-ok); }
.perm-cell .fa-times { color: var(--border2); }
.perm-cell:last-child, .perm-row-label:last-of-type { border-bottom: none; }

/* ── MODAL ─── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: grid; place-items: center; z-index: 1000;
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: #fff; border-radius: var(--radius);
  box-shadow: var(--shadow-lg); width: 500px; max-width: 90vw;
  transform: translateY(16px); transition: transform .2s;
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-header { padding: 22px 24px 0; display: flex; align-items: center; justify-content: space-between; }
.modal-title { font-size: 17px; font-weight: 700; color: var(--dark); }
.modal-body { padding: 18px 24px; }
.modal-footer { padding: 0 24px 22px; display: flex; gap: 10px; justify-content: flex-end; }

/* ── FORM ELEMENTS ─── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 12.5px; font-weight: 600; color: var(--charcoal); margin-bottom: 6px; }
.form-control {
  width: 100%; padding: 9px 13px; border: 1.5px solid var(--border);
  border-radius: 7px; font-size: 13px; font-family: inherit;
  color: var(--text); outline: none; transition: border-color .2s;
  background: #fff;
}
.form-control:focus { border-color: var(--accent); }
.form-control select, select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }

/* ── TOAST ─── */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--dark); color: #fff; padding: 12px 18px;
  border-radius: 9px; font-size: 13px; font-weight: 500;
  box-shadow: var(--shadow-lg); display: flex; align-items: center; gap: 10px;
  animation: slideIn .25s ease; max-width: 320px;
}
.toast.success { border-left: 3px solid var(--status-ok); }
.toast.error   { border-left: 3px solid var(--status-err); }
.toast.info    { border-left: 3px solid var(--accent); }
@keyframes slideIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }

/* ── ONLINE DOT ─── */
.online-dot { position: absolute; bottom: 0; right: 0; width: 9px; height: 9px; border-radius: 50%; background: var(--status-ok); border: 2px solid #fff; }
.online-dot.away { background: #C8D0DA; }

/* ── EMPTY STATE ─── */
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 60px 20px; text-align: center; color: var(--muted); }
.empty-state i { font-size: 42px; opacity: .2; margin-bottom: 14px; color: var(--accent); }
.empty-state h3 { font-size: 15px; color: var(--charcoal); margin-bottom: 6px; }
.empty-state p { font-size: 13px; }

/* ── SEARCH HIGHLIGHT ─── */
.highlight { background: #FFF3CD; border-radius: 2px; padding: 0 2px; }

/* ── COLLAB LAYOUT ─── */
.collab-layout { display: grid; grid-template-columns: 1fr 320px; gap: 16px; }

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

/* ── TOOLTIP ─── */
[data-tip] { position: relative; }
[data-tip]:hover::after { content: attr(data-tip); position: absolute; bottom: calc(100% + 5px); left: 50%; transform: translateX(-50%); background: var(--dark); color: rgba(255,255,255,.85); font-size: 11px; font-weight: 500; padding: 4px 9px; border-radius: 5px; white-space: nowrap; z-index: 99; pointer-events: none; }

/* ── RESPONSIVE ─── */
@media (max-width: 1200px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-65-35 { grid-template-columns: 1fr; }
  .editor-layout { grid-template-columns: 1fr; height: auto; }
  .ai-layout { grid-template-columns: 1fr; }
  .action-panel { height: 280px; border-top: 1px solid var(--border); }
}

/* ══════════════════════════════════════════
   AI ASSISTANT — LEX
══════════════════════════════════════════ */
#view-ai { padding: 0; overflow: hidden; }

.ai-layout {
  display: grid;
  grid-template-columns: 1fr 290px;
  height: calc(100vh - 56px);
  overflow: hidden;
}

/* ── Chat Panel ── */
.chat-panel {
  display: flex;
  flex-direction: column;
  background: #fff;
  border-right: 1px solid var(--border);
  min-height: 0;
}
.chat-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  background: #fff;
  flex-shrink: 0;
}
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 28px 10%;
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-height: 0;
}
.chat-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  text-align: center;
  padding: 60px 20px 40px;
  gap: 12px;
  min-height: 360px;
}
.chat-welcome h3 {
  font-family: 'Playfair Display', serif;
  font-size: 22px;
  color: var(--dark);
  margin: 0;
}
.chat-welcome p {
  font-size: 14px;
  color: var(--muted);
  max-width: 440px;
  line-height: 1.65;
  margin: 0;
}
.lex-avatar-lg {
  width: 68px;
  height: 68px;
  background: var(--dark);
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  color: #fff;
  margin-bottom: 6px;
  box-shadow: 0 4px 18px rgba(42,47,58,.18);
}
.chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 14px;
  max-width: 560px;
}
.suggestion-chip {
  padding: 9px 16px;
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: 22px;
  font-size: 13px;
  color: var(--charcoal);
  cursor: pointer;
  transition: all .15s;
  box-shadow: 0 1px 4px rgba(0,0,0,.05);
}
.suggestion-chip:hover {
  border-color: var(--accent);
  background: var(--accent-bg);
  color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(91,122,106,.15);
}
.chat-message {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  max-width: 88%;
}
.chat-message.user { align-self: flex-end; flex-direction: row-reverse; }
.chat-message.ai   { align-self: flex-start; }
.msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
  color: #fff;
}
.msg-avatar.ai-av   { background: var(--dark); }
.msg-avatar.user-av { background: var(--accent); }
.msg-bubble {
  padding: 11px 16px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.7;
}
.chat-message.user .msg-bubble {
  background: var(--dark);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.chat-message.ai .msg-bubble {
  background: var(--light-bg);
  color: var(--charcoal);
  border-bottom-left-radius: 4px;
  border: 1px solid var(--border);
}
.chat-message.ai .msg-bubble strong { color: var(--dark); }
.chat-message.ai .msg-bubble ul { margin: 8px 0 8px 18px; }
.chat-message.ai .msg-bubble li { margin-bottom: 4px; }
.chat-message.ai .msg-bubble h3,
.chat-message.ai .msg-bubble h4 { margin: 10px 0 4px; }
.chat-message.ai .msg-bubble code { font-size: .88em; }
.typing-bubble {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 13px 18px;
  background: var(--light-bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  border-bottom-left-radius: 4px;
}
.typing-dot {
  width: 7px; height: 7px;
  background: var(--muted);
  border-radius: 50%;
  animation: tdot 1.2s infinite;
}
.typing-dot:nth-child(2) { animation-delay: .2s; }
.typing-dot:nth-child(3) { animation-delay: .4s; }
@keyframes tdot { 0%,60%,100%{ transform:translateY(0) } 30%{ transform:translateY(-6px) } }

.chat-input-area {
  padding: 14px 10%;
  border-top: 1px solid var(--border);
  background: #fff;
  flex-shrink: 0;
}
.chat-input-wrap {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  background: var(--light-bg);
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 8px 8px 8px 14px;
  transition: border-color .2s, box-shadow .2s;
}
.chat-input-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(91,122,106,.1);
  background: #fff;
}
.chat-input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 4px 0;
  font-family: inherit;
  font-size: 14px;
  resize: none;
  outline: none;
  min-height: 28px;
  max-height: 130px;
  line-height: 1.55;
  color: var(--charcoal);
}
.chat-send-btn {
  width: 40px; height: 40px;
  border-radius: 10px;
  background: var(--dark);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .15s, transform .1s;
  font-size: 15px;
}
.chat-send-btn:hover:not(:disabled) { background: var(--accent); transform: scale(1.05); }
.chat-send-btn:disabled { opacity: .35; cursor: not-allowed; }

/* ── Action Panel (right sidebar) ── */
.action-panel {
  display: flex;
  flex-direction: column;
  background: var(--light-bg);
  border-left: 1px solid var(--border);
  min-height: 0;
  overflow: hidden;
}

/* Firm snapshot section */
.action-snapshot {
  background: var(--dark);
  padding: 14px 14px 12px;
  flex-shrink: 0;
}
.action-snapshot-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: rgba(255,255,255,.45);
  margin-bottom: 10px;
}
.snapshot-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  margin-bottom: 12px;
}
.snapshot-stat {
  background: rgba(255,255,255,.07);
  border-radius: 8px;
  padding: 8px 10px;
  border: 1px solid rgba(255,255,255,.09);
}
.snapshot-stat-val {
  font-size: 20px;
  font-weight: 800;
  color: #fff;
  line-height: 1;
}
.snapshot-stat-lbl {
  font-size: 10px;
  color: rgba(255,255,255,.45);
  margin-top: 3px;
  font-weight: 500;
}
.snapshot-stat-val.urgent { color: #F4A460; }
.snapshot-team-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .8px;
  text-transform: uppercase;
  color: rgba(255,255,255,.4);
  margin-bottom: 7px;
}
.snapshot-team-row {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 0;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.snapshot-team-row:last-child { border-bottom: none; }
.snapshot-team-av {
  width: 24px; height: 24px;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 9px; font-weight: 700; color: #fff;
  flex-shrink: 0;
}
.snapshot-team-name {
  font-size: 12px;
  color: rgba(255,255,255,.8);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.snapshot-online-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.snapshot-online-dot.on  { background: #4CAF7D; }
.snapshot-online-dot.off { background: rgba(255,255,255,.2); }

/* Live actions section */
.action-feed-section {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
.action-panel-hdr {
  padding: 10px 13px;
  border-bottom: 1px solid var(--border);
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 700;
  color: var(--charcoal);
  letter-spacing: .4px;
}
.action-feed {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 0;
}
.action-empty {
  text-align: center;
  padding: 30px 14px;
  color: var(--muted);
  font-size: 12px;
}
.action-card {
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: 9px;
  padding: 9px 11px;
  font-size: 12px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  transition: all .2s;
}
.action-card.running { border-color: var(--accent-lt); background: var(--accent-bg); }
.action-card.done    { border-color: #B8D4C0; background: #F0F7F2; }
.action-card.error   { border-color: #D4B8B8; background: #F7F0F0; }
.action-ico {
  width: 24px; height: 24px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  flex-shrink: 0;
  margin-top: 1px;
}
.action-ico.running { background: var(--accent-lt); color: var(--accent); }
.action-ico.done    { background: #C8E6C9; color: var(--status-ok); }
.action-ico.error   { background: #FFCDD2; color: var(--status-err); }
.action-name   { font-weight: 700; color: var(--charcoal); font-size: 11.5px; line-height: 1.3; }
.action-desc   { color: var(--muted); font-size: 10.5px; margin-top: 2px; }
.action-arg-key { font-weight: 600; color: var(--charcoal); }
.action-result { color: var(--charcoal); font-size: 10.5px; margin-top: 4px; opacity: .75; }
.action-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  margin-left: auto;
  flex-shrink: 0;
  margin-top: 6px;
}
.action-dot.running { background: var(--accent); animation: pulse 1s infinite; }
.action-dot.done    { background: var(--status-ok); }
.action-dot.error   { background: var(--status-err); }

/* ── AI Setup Screen ── */
.ai-setup {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 40px;
  text-align: center;
  background: #fff;
}
.ai-setup-card {
  max-width: 420px;
  width: 100%;
}
.ai-setup h2 { font-family:'Playfair Display',serif; font-size:24px; color:var(--dark); margin:10px 0 6px; }
.ai-setup p  { font-size:14px; color:var(--muted); line-height:1.65; margin:0 0 4px; }

@media(max-width:1100px) {
  .ai-layout { grid-template-columns: 1fr; }
  .action-panel { height: 300px; border-top: 1px solid var(--border); border-left: none; }
  .chat-messages { padding: 20px 5%; }
  .chat-input-area { padding: 12px 5%; }
}
