/* BRIEF — Investigation & Briefing Tool */
/* Design: professional, government-adjacent, clean */

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

:root {
  --navy: #1a2744;
  --navy-light: #243459;
  --navy-hover: #2e3f68;
  --blue: #2563eb;
  --blue-light: #dbeafe;
  --blue-hover: #1d4ed8;
  --bg: #f1f5f9;
  --surface: #ffffff;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #1e293b;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --success: #16a34a;
  --success-bg: #dcfce7;
  --warning: #d97706;
  --warning-bg: #fef3c7;
  --danger: #dc2626;
  --danger-bg: #fee2e2;
  --info: #0891b2;
  --info-bg: #e0f2fe;
  --sidebar-w: 240px;
  --topbar-h: 56px;
  --radius: 8px;
  --radius-sm: 4px;
  --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -1px rgba(0,0,0,.06);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
}

body { font-family: var(--font); color: var(--text); background: var(--bg); font-size: 14px; line-height: 1.5; }

a { color: var(--blue); text-decoration: none; }
a:hover { color: var(--blue-hover); text-decoration: underline; }

/* ── Layout ────────────────────────────────────────────────────────────────── */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--navy);
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: width .2s ease, transform .2s ease;
  overflow: hidden;
}
.sidebar-header {
  padding: 14px 12px;
  border-bottom: 1px solid var(--navy-hover);
  display: flex; align-items: center;
  flex-shrink: 0;
}
.sidebar-icon-link { display: none; }
.sidebar-icon { display: block; width: 32px; height: 32px; object-fit: contain; }
.logo { display: block; font-size: 22px; font-weight: 700; color: #fff; letter-spacing: .5px; }
.logo-sub { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; }
.sidebar-logo-link { display: block; background: #fff; border-radius: 6px; padding: 6px 10px; line-height: 0; width: 100%; }
.sidebar-logo { display: block; width: 100%; height: auto; }

.sidebar-nav { flex: 1; padding: 12px 8px; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: var(--radius-sm);
  color: #cbd5e1; font-size: 13px; font-weight: 500;
  transition: background .15s, color .15s;
  text-decoration: none;
}
.nav-item:hover { background: var(--navy-hover); color: #fff; text-decoration: none; }
.nav-item.active { background: var(--blue); color: #fff; }
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }
.nav-divider { border: none; border-top: 1px solid var(--navy-hover); margin: 8px 0; }
.nav-section-label { padding: 4px 10px; font-size: 10px; text-transform: uppercase; letter-spacing: 1px; color: var(--text-muted); }

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--navy-hover);
}
.user-info { margin-bottom: 8px; }
.user-name { display: block; font-size: 13px; font-weight: 600; color: #f1f5f9; }
.footer-link { display: block; font-size: 12px; color: #94a3b8; padding: 2px 0; }
.footer-link:hover { color: #fff; text-decoration: none; }

.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left .2s ease;
}

.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
  position: sticky; top: 0; z-index: 50;
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.page-title { font-size: 16px; font-weight: 600; color: var(--text); }
.sidebar-toggle { background: none; border: none; cursor: pointer; padding: 6px; border-radius: var(--radius-sm); }
.sidebar-toggle svg { width: 20px; height: 20px; color: var(--text-muted); }

.content { padding: 24px; flex: 1; }

/* ── Auth layout ────────────────────────────────────────────────────────────── */
.auth-layout {
  min-height: 100vh;
  background: var(--navy);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  flex-direction: column;
}
.auth-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-md);
}
.auth-brand { text-align: center; margin-bottom: 28px; }
.auth-brand h1 { font-size: 28px; font-weight: 800; color: var(--navy); letter-spacing: .5px; }
.auth-brand p { color: var(--text-muted); font-size: 13px; margin-top: 8px; }
.auth-logo { display: block; height: 44px; width: auto; max-width: 240px; margin: 0 auto; }
.auth-info { color: var(--text-muted); font-size: 13px; text-align: center; margin-bottom: 20px; }
.auth-notice { font-size: 12px; color: var(--text-muted); text-align: center; margin-top: 20px; line-height: 1.6; }
.auth-form { display: flex; flex-direction: column; gap: 16px; }
.input-code {
  text-align: center;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 12px;
  font-family: var(--font-mono);
}

/* ── Cards ──────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 16px; }
.card h3 { font-size: 15px; font-weight: 600; margin-bottom: 14px; }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.card-header h3 { margin-bottom: 0; }
.card-footer { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.card-narrow { max-width: 500px; }
.card-medium { max-width: 700px; }
.card-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }

/* ── Stats ──────────────────────────────────────────────────────────────────── */
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; text-align: center; }
.stat-value { font-size: 36px; font-weight: 700; color: var(--navy); }
.stat-label { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.stat-link { font-size: 12px; color: var(--blue); display: inline-block; margin-top: 8px; }

/* ── Buttons ────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500; border: none; cursor: pointer;
  text-decoration: none; transition: background .15s, opacity .15s;
  line-height: 1;
}
.btn:hover { text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-hover); color: #fff; }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--border-strong); }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-success { background: var(--success); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-full { width: 100%; justify-content: center; }
.btn-icon { width: 16px; height: 16px; }
.inline { display: inline; }

/* ── Forms ──────────────────────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 5px; }
.field-hint { font-size: 12px; color: var(--text-muted); margin: 0; }
.field-hint code { background: var(--surface-raised, #f1f5f9); padding: 1px 4px; border-radius: 3px; font-size: 11px; }
.prompt-textarea { font-family: 'Courier New', monospace; font-size: 12px; line-height: 1.6; resize: vertical; }
.checkbox-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 4px 16px; margin-top: 6px; }
label { font-size: 13px; font-weight: 500; color: var(--text); }
input[type=text], input[type=email], input[type=password], input[type=date],
input[type=number], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); font-family: var(--font); font-size: 13px;
  color: var(--text); background: var(--surface); transition: border-color .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
textarea { resize: vertical; min-height: 80px; }
.form-row { display: flex; gap: 12px; }
.form-row-between { justify-content: space-between; align-items: center; }
.form-row-tight { gap: 6px; align-items: center; }
.form-actions { display: flex; gap: 8px; align-items: center; margin-top: 16px; }
.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.flex-1 { flex: 1; }
.flex-2 { flex: 2; }
.required { color: var(--danger); }
.checkbox-label { display: flex; align-items: center; gap: 8px; font-weight: 400; cursor: pointer; }
.doc-checkbox { padding: 8px; border-radius: var(--radius-sm); }
.doc-checkbox:hover { background: var(--bg); }
.mb-2 { margin-bottom: 8px; }

/* ── Tables ─────────────────────────────────────────────────────────────────── */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; padding: 10px 12px; border-bottom: 2px solid var(--border); font-weight: 600; color: var(--text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.table-hover tbody tr:hover td { background: var(--bg); }
.table-sm th, .table-sm td { padding: 7px 10px; }
.text-center { text-align: center; }

/* ── Badges ─────────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 600; text-transform: capitalize;
}
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-super_admin { background: #ede9fe; color: #7c3aed; }
.badge-org_admin { background: #dbeafe; color: #1d4ed8; }
.badge-org_user { background: #f0fdf4; color: #15803d; }
.badge-lead { background: #ffe4e6; color: #be123c; }
.badge-supporting { background: var(--bg); color: var(--text-muted); }

.tag { display: inline-block; padding: 2px 7px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 11px; color: var(--text-muted); }

/* ── Status and Priority badges ─────────────────────────────────────────────── */
.status-badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.status-open { background: var(--blue-light); color: var(--blue); }
.status-under_review { background: var(--warning-bg); color: var(--warning); }
.status-referred { background: #ede9fe; color: #7c3aed; }
.status-closed { background: var(--bg); color: var(--text-muted); }
.status-archived { background: var(--bg); color: var(--text-light); }

.priority-badge { display: inline-block; padding: 3px 10px; border-radius: var(--radius-sm); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; }
.priority-low { background: #f0fdf4; color: #15803d; }
.priority-medium { background: var(--warning-bg); color: var(--warning); }
.priority-high { background: #fff7ed; color: #ea580c; }
.priority-critical { background: var(--danger-bg); color: var(--danger); }

/* ── Alerts / Flash ─────────────────────────────────────────────────────────── */
.alert {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px; margin: 0 24px; margin-top: 12px;
  border-radius: var(--radius); font-size: 13px; border: 1px solid transparent;
}
.alert-success { background: var(--success-bg); color: var(--success); border-color: #bbf7d0; }
.alert-error { background: var(--danger-bg); color: var(--danger); border-color: #fecaca; }
.alert-warning { background: var(--warning-bg); color: var(--warning); border-color: #fde68a; }
.alert-info { background: var(--info-bg); color: var(--info); border-color: #bae6fd; }
.alert a { color: inherit; font-weight: 600; }
.alert-close { background: none; border: none; cursor: pointer; font-size: 18px; color: inherit; opacity: .6; padding: 0 4px; }
.alert-close:hover { opacity: 1; }

/* ── Detail lists ───────────────────────────────────────────────────────────── */
.detail-list { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; }
.detail-list dt { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; align-self: center; }
.detail-list dd { color: var(--text); align-self: center; overflow-wrap: break-word; word-break: break-all; min-width: 0; }
.detail-list-sm dt, .detail-list-sm dd { font-size: 12px; gap: 4px 12px; }

/* ── Case layout ────────────────────────────────────────────────────────────── */
.case-meta-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.case-grid { display: grid; grid-template-columns: 1fr 300px; gap: 16px; }
.case-main { display: flex; flex-direction: column; gap: 16px; }
.case-sidebar { display: flex; flex-direction: column; gap: 16px; }

/* ── Document layout ────────────────────────────────────────────────────────── */
.doc-view-grid { display: grid; grid-template-columns: 1fr 280px; gap: 16px; }
.doc-text { font-family: var(--font); font-size: 14px; line-height: 1.7; white-space: pre-wrap; color: var(--text); }
.doc-image { max-width: 100%; border-radius: var(--radius-sm); }
.doc-binary-notice { text-align: center; padding: 40px; }
.doc-meta-sidebar { display: flex; flex-direction: column; gap: 16px; }
.edit-details { border: none; }
.edit-summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--accent); padding: 6px 0; list-style: none; }
.edit-summary::-webkit-details-marker { display: none; }
.edit-summary::before { content: '▸ '; }
details[open] .edit-summary::before { content: '▾ '; }
.edit-doc-form { margin-top: 12px; display: flex; flex-direction: column; gap: 12px; }
.edit-doc-form .form-actions { margin-top: 4px; }

/* ── File upload ────────────────────────────────────────────────────────────── */
.file-drop-zone {
  position: relative; border: 2px dashed var(--border-strong);
  border-radius: var(--radius); padding: 32px 20px; text-align: center;
  cursor: pointer; transition: border-color .15s, background .15s;
}
.file-drop-zone:hover { border-color: var(--blue); background: var(--blue-light); }
.file-drop-zone input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.file-drop-content svg { width: 40px; height: 40px; color: var(--text-muted); margin-bottom: 8px; }
.file-drop-content p { color: var(--text-muted); }
.file-drop-content .link { color: var(--blue); }
.progress-bar { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; margin-bottom: 8px; }
.progress-fill { height: 100%; background: var(--blue); width: 0; transition: width .3s; animation: progress-indeterminate 1.5s infinite; }
@keyframes progress-indeterminate { 0%{width:0;margin-left:0} 50%{width:60%;margin-left:20%} 100%{width:0;margin-left:100%} }

/* ── AI layout ──────────────────────────────────────────────────────────────── */
.ai-layout { display: grid; grid-template-columns: 280px 1fr; gap: 16px; }
.ai-tasks-panel { display: flex; flex-direction: column; gap: 8px; }
.ai-tasks-panel h3 { margin-bottom: 4px; }
.task-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px; cursor: pointer; transition: border-color .15s, box-shadow .15s;
  display: flex; gap: 12px; align-items: flex-start;
}
.task-card:hover { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-light); }
.task-card-selected { border-color: var(--blue); background: var(--blue-light); }
.task-card-icon svg { width: 22px; height: 22px; color: var(--blue); flex-shrink: 0; margin-top: 2px; }
.task-card strong { display: block; font-size: 13px; margin-bottom: 2px; }

.result-layout { display: grid; grid-template-columns: 1fr 240px; gap: 16px; }
.result-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.result-content { line-height: 1.8; font-size: 14px; color: var(--text); }
.result-footer { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }
.result-sidebar { display: flex; flex-direction: column; gap: 16px; }
.ml-4 { margin-left: 16px; }
.mt-2 { margin-top: 8px; }

/* ── User list ──────────────────────────────────────────────────────────────── */
.user-list { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.user-list-item { display: flex; align-items: center; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--border); }
.user-list-item:last-child { border-bottom: none; }
.text-danger { color: var(--danger); }

/* ── Modals ─────────────────────────────────────────────────────────────────── */
.modal { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.5); }
.modal-box { position: relative; background: var(--surface); border-radius: var(--radius); padding: 28px; width: 100%; max-width: 480px; box-shadow: var(--shadow-md); z-index: 1; }
.modal-lg { max-width: 640px; }
.modal-box h2 { font-size: 18px; font-weight: 600; margin-bottom: 20px; }

/* ── Error pages ────────────────────────────────────────────────────────────── */
.error-page { text-align: center; padding: 80px 24px; }
.error-code { font-size: 80px; font-weight: 800; color: var(--border-strong); line-height: 1; }
.error-page h2 { font-size: 24px; margin: 12px 0; }
.error-page p { color: var(--text-muted); margin-bottom: 24px; }

/* ── Empty states ───────────────────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 60px 24px; }
.empty-icon { width: 48px; height: 48px; color: var(--text-light); margin: 0 auto 16px; }
.empty-state h3 { font-size: 18px; margin-bottom: 8px; }
.empty-state p { color: var(--text-muted); margin-bottom: 20px; }

/* ── Action list ────────────────────────────────────────────────────────────── */
.action-list { display: flex; flex-direction: column; gap: 8px; }
.action-item { display: flex; align-items: center; padding: 10px 14px; background: var(--bg); border-radius: var(--radius-sm); color: var(--text); font-size: 13px; }
.action-item:hover { background: var(--blue-light); color: var(--blue); text-decoration: none; }

/* ── Typography helpers ─────────────────────────────────────────────────────── */
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.text-danger { color: var(--danger); }
.text-nowrap { white-space: nowrap; }

/* ── Audit log ──────────────────────────────────────────────────────────────── */
.audit-action { display: inline-block; padding: 2px 8px; border-radius: var(--radius-sm); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px; background: var(--bg); color: var(--text-muted); border: 1px solid var(--border); }
.audit-action-case_created { background: #dbeafe; color: #1d4ed8; border-color: #bfdbfe; }
.audit-action-status_changed { background: #fef9c3; color: #854d0e; border-color: #fde68a; }
.audit-action-document_uploaded { background: #dcfce7; color: #15803d; border-color: #bbf7d0; }
.audit-action-document_deleted { background: #fee2e2; color: #b91c1c; border-color: #fecaca; }
.audit-action-document_edited { background: #e0f2fe; color: #0369a1; border-color: #bae6fd; }
.audit-action-user_assigned { background: #ede9fe; color: #6d28d9; border-color: #ddd6fe; }
.audit-action-user_unassigned { background: #fce7f3; color: #9d174d; border-color: #fbcfe8; }
.audit-action-bundle_generated { background: #ecfdf5; color: #065f46; border-color: #a7f3d0; }
.audit-action-bundle_downloaded { background: #f0fdf4; color: #166534; border-color: #bbf7d0; }
.audit-action-hearing_marked_heard { background: #f0fdf4; color: #166534; border-color: #bbf7d0; }
.audit-action-document_viewed { background: #f8fafc; color: #475569; border-color: #e2e8f0; }
.audit-action-document_downloaded { background: #f1f5f9; color: #334155; border-color: #cbd5e1; }
.audit-action-ai_analysis_run { background: #faf5ff; color: #7e22ce; border-color: #e9d5ff; }
.audit-action-ai_result_viewed { background: #fdf4ff; color: #86198f; border-color: #f0abfc; }
.audit-action-ai_result_confirmed { background: #ecfdf5; color: #065f46; border-color: #a7f3d0; }
.audit-action-ai_result_deleted { background: #fee2e2; color: #b91c1c; border-color: #fecaca; }
.audit-action-ai_result_saved_to_docs { background: #eff6ff; color: #1e40af; border-color: #bfdbfe; }
.audit-action-ai_result_downloaded { background: #f0f9ff; color: #0369a1; border-color: #bae6fd; }
.audit-detail-item { display: inline-block; margin-right: 10px; }
code { font-family: var(--font-mono); font-size: .9em; background: var(--bg); padding: 2px 5px; border-radius: var(--radius-sm); color: var(--navy); }
.whitespace-pre { white-space: pre-wrap; }

/* ── Case title link ────────────────────────────────────────────────────────── */
.case-title-link { font-weight: 500; color: var(--text); }
.case-title-link:hover { color: var(--blue); }

/* ── Scrollbar ──────────────────────────────────────────────────────────────── */
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--navy-hover); border-radius: 2px; }

/* ── Case sub-navigation ────────────────────────────────────────────────────── */
.case-subnav {
  display: flex; gap: 0; border-bottom: 2px solid var(--border);
  margin-bottom: 20px; overflow-x: auto;
}
.case-subnav-item {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 18px; font-size: 13px; font-weight: 500;
  color: var(--text-muted); border-bottom: 2px solid transparent;
  margin-bottom: -2px; white-space: nowrap;
  text-decoration: none; transition: color .15s, border-color .15s;
}
.case-subnav-item:hover { color: var(--text); text-decoration: none; }
.case-subnav-item.active { color: var(--blue); border-bottom-color: var(--blue); }
.subnav-count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px;
  background: var(--bg); border-radius: 999px;
  font-size: 10px; font-weight: 700; color: var(--text-muted);
}
.case-subnav-item.active .subnav-count { background: var(--blue-light); color: var(--blue); }

/* ── Hearing status badges ───────────────────────────────────────────────────── */
.hearing-status-badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600;
}
.hearing-status-scheduled { background: var(--blue-light); color: var(--blue); }
.hearing-status-heard { background: var(--warning-bg); color: var(--warning); }
.hearing-status-closed { background: var(--bg); color: var(--text-muted); }

/* ── Hearing summary list (case overview) ───────────────────────────────────── */
.hearing-summary-list { display: flex; flex-direction: column; gap: 0; }
.hearing-summary-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 0; border-bottom: 1px solid var(--border);
  text-decoration: none; color: var(--text);
  transition: background .1s;
}
.hearing-summary-item:last-child { border-bottom: none; }
.hearing-summary-item:hover { text-decoration: none; color: var(--blue); }
.hearing-summary-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.hearing-summary-title { font-weight: 500; font-size: 13px; }
.hearing-summary-meta { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

/* ── Hearing card grid (list page) ─────────────────────────────────────────── */
.hearing-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.hearing-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; display: flex;
  flex-direction: column; gap: 10px; text-decoration: none; color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
.hearing-card:hover { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-light); text-decoration: none; color: var(--text); }
.hearing-card-header { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.hearing-card-title { font-size: 15px; font-weight: 600; }
.hearing-card-meta { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; font-size: 12px; }
.hearing-card-meta dt { font-weight: 600; color: var(--text-muted); }
.hearing-card-meta dd { color: var(--text); }
.outcome-tag { background: var(--success-bg); color: var(--success); border-color: #bbf7d0; }

/* ── Hearing detail layout ──────────────────────────────────────────────────── */
.hearing-detail-grid { display: grid; grid-template-columns: 1fr 280px; gap: 16px; }
.hearing-main { display: flex; flex-direction: column; gap: 16px; }
.hearing-sidebar { display: flex; flex-direction: column; gap: 16px; }

/* ── DnD workspace ──────────────────────────────────────────────────────────── */
.dnd-workspace {
  display: grid;
  grid-template-columns: 1fr 32px 1fr;
  gap: 0;
  align-items: stretch;
  min-height: 320px;
}

.dnd-arrow {
  display: flex; align-items: center; justify-content: center;
  color: var(--border-strong); padding: 0 4px;
}
.dnd-arrow svg { width: 20px; height: 20px; }

.dnd-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.dnd-panel-bundle { border-color: var(--blue); background: #f5f8ff; }

.dnd-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.dnd-panel-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); }
.dnd-panel-count {
  min-width: 22px; height: 22px; padding: 0 6px;
  background: var(--border); border-radius: 999px;
  font-size: 11px; font-weight: 700; color: var(--text-muted);
  display: inline-flex; align-items: center; justify-content: center;
}
.dnd-panel-bundle .dnd-panel-count { background: var(--blue); color: #fff; }

.dnd-list {
  flex: 1;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  overflow-y: auto;
  max-height: 460px;
}

.dnd-empty-hint {
  font-size: 12px; color: var(--text-light);
  text-align: center; padding: 20px 12px;
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  pointer-events: none;
  margin: 4px 0;
}

/* ── Doc cards ──────────────────────────────────────────────────────────────── */
.doc-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 10px;
  display: flex; align-items: center; gap: 9px;
  cursor: grab;
  user-select: none;
  transition: box-shadow .1s, border-color .1s, opacity .1s;
  position: relative;
}
.doc-card:hover { border-color: var(--blue); box-shadow: 0 2px 6px rgba(37,99,235,.12); }
.doc-card.dragging { opacity: 0.35; cursor: grabbing; box-shadow: none; }

.doc-card-grip {
  color: var(--text-light); flex-shrink: 0; cursor: grab; line-height: 0;
}
.doc-card-grip svg { width: 14px; height: 14px; }

.doc-card-body { flex: 1; min-width: 0; }
.doc-card-title { display: block; font-size: 12px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-card-meta { display: flex; align-items: center; gap: 5px; margin-top: 3px; flex-wrap: wrap; }
.doc-card-meta .tag { font-size: 10px; padding: 1px 5px; }

.doc-card-pos {
  flex-shrink: 0;
  min-width: 20px; height: 20px; padding: 0 5px;
  background: var(--blue); color: #fff;
  border-radius: 999px; font-size: 10px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}

/* Document format badges */
.doc-fmt-badge {
  display: inline-block; padding: 1px 5px;
  border-radius: var(--radius-sm); font-size: 10px; font-weight: 600;
  background: var(--bg); color: var(--text-muted);
  border: 1px solid var(--border);
}
.doc-fmt-badge.doc-fmt-application-pdf { background: #fef3c7; color: #92400e; border-color: #fde68a; }
/* images, word, text share the default style */

/* ── Drop insertion line ─────────────────────────────────────────────────────── */
.dnd-drop-line {
  height: 2px;
  background: var(--blue);
  border-radius: 1px;
  margin: 1px 4px;
  pointer-events: none;
  flex-shrink: 0;
}

/* ── Save row ────────────────────────────────────────────────────────────────── */
.dnd-save-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

/* ── Outcome document display ───────────────────────────────────────────────── */
.outcome-doc-display {
  display: flex; align-items: center; gap: 12px;
  padding: 12px; background: var(--bg); border-radius: var(--radius-sm);
}
.outcome-doc-icon { width: 28px; height: 28px; color: var(--blue); flex-shrink: 0; }
.outcome-doc-title { font-weight: 500; font-size: 13px; }

/* ── Panel members ───────────────────────────────────────────────────────────── */
.panel-member-item { flex-direction: column; align-items: flex-start; gap: 4px; }
.panel-member-row { display: flex; align-items: center; gap: 8px; width: 100%; }
.panel-edit-btn {
  background: none; border: none; cursor: pointer; padding: 4px;
  border-radius: var(--radius-sm); color: var(--text-muted); line-height: 0;
  flex-shrink: 0; margin-left: auto;
}
.panel-edit-btn:hover { background: var(--bg); color: var(--blue); }
.panel-edit-btn svg { width: 14px; height: 14px; display: block; }
.panel-member-edit { width: 100%; }
.panel-member-edit > summary { display: none; }
.panel-delete-form { padding-top: 8px; margin-top: 6px; border-top: 1px solid var(--border); }
.panel-member-info { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; width: 100%; }
.panel-member-name { font-weight: 600; font-size: 13px; }
.panel-member-contacts { display: flex; gap: 10px; font-size: 12px; color: var(--text-muted); flex-wrap: wrap; }
.panel-contact { color: var(--text-muted); }
.panel-contact:hover { color: var(--blue); }

/* ── Duration inputs ─────────────────────────────────────────────────────────── */
.duration-row { display: flex; align-items: center; gap: 6px; }
.duration-input { width: 64px !important; }
.duration-select { width: 68px !important; }
.duration-label { font-size: 12px; color: var(--text-muted); white-space: nowrap; }

/* ── Card danger border variant ─────────────────────────────────────────────── */
.card-danger-border { border-color: #fecaca; background: #fff8f8; }
.card-danger-border h3 { color: var(--danger); }

/* ── Help / user manual ──────────────────────────────────────────────────────── */
.help-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 32px;
  align-items: start;
  max-width: 1100px;
}
.help-toc {
  position: sticky;
  top: calc(var(--topbar-h) + 24px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.help-toc-title {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; color: var(--text-muted); margin-bottom: 10px;
}
.help-toc-list { list-style: none; }
.help-toc-list ul { list-style: none; padding-left: 12px; margin-top: 2px; }
.help-toc-list li { margin-bottom: 2px; }
.help-toc-link {
  display: block; padding: 3px 6px; border-radius: var(--radius-sm);
  font-size: 13px; color: var(--text-muted); text-decoration: none;
}
.help-toc-link:hover { background: var(--bg); color: var(--blue); text-decoration: none; }
.help-toc-list > li > .help-toc-link { font-weight: 600; color: var(--text); }
.help-toc-list ul .help-toc-link { font-size: 12px; }

.help-content { min-width: 0; }
.help-section {
  margin-bottom: 48px;
  scroll-margin-top: calc(var(--topbar-h) + 16px);
}
.help-section h2 {
  font-size: 20px; font-weight: 700; color: var(--navy);
  padding-bottom: 8px; border-bottom: 2px solid var(--blue);
  margin-bottom: 16px;
}
.help-section h3 {
  font-size: 15px; font-weight: 600; color: var(--text);
  margin: 24px 0 8px; scroll-margin-top: calc(var(--topbar-h) + 16px);
}
.help-section p { margin-bottom: 10px; line-height: 1.65; }
.help-section ul, .help-section ol { padding-left: 20px; margin-bottom: 10px; }
.help-section li { margin-bottom: 4px; line-height: 1.6; }
.help-tip, .help-note {
  border-radius: var(--radius-sm);
  padding: 10px 14px; margin: 12px 0; font-size: 13px; line-height: 1.6;
}
.help-tip { background: #eff6ff; border-left: 3px solid var(--blue); color: #1e40af; }
.help-note { background: #fff7ed; border-left: 3px solid #f59e0b; color: #92400e; }
.help-table {
  width: 100%; border-collapse: collapse; font-size: 13px; margin-bottom: 12px;
}
.help-table th {
  text-align: left; padding: 7px 10px; background: var(--navy); color: #fff;
  font-weight: 600;
}
.help-table td { padding: 7px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.help-table tr:last-child td { border-bottom: none; }
.help-table tr:nth-child(even) td { background: var(--surface); }
.help-table code { background: #f1f5f9; padding: 1px 5px; border-radius: 3px; font-size: 12px; }

@media (max-width: 800px) {
  .help-layout { grid-template-columns: 1fr; }
  .help-toc { position: static; }
}

/* ── Desktop sidebar collapse — icon rail ────────────────────────────────────── */
@media (min-width: 641px) {
  body.sidebar-collapsed .sidebar { width: 52px; overflow: visible; }
  body.sidebar-collapsed .sidebar-nav { overflow: visible; }
  body.sidebar-collapsed .main-content { margin-left: 52px; }

  /* Header: hide full logo, show icon mark centred */
  body.sidebar-collapsed .sidebar-logo-link { display: none; }
  body.sidebar-collapsed .sidebar-icon-link { display: block; }
  body.sidebar-collapsed .sidebar-header { justify-content: center; padding: 12px 0; }

  /* Nav: hide labels, section text, dividers, footer */
  body.sidebar-collapsed .nav-label,
  body.sidebar-collapsed .nav-section-label,
  body.sidebar-collapsed .nav-divider,
  body.sidebar-collapsed .sidebar-footer { display: none; }

  /* Centre icons and make them slightly larger */
  body.sidebar-collapsed .nav-item {
    justify-content: center;
    padding: 10px 0;
    position: relative;
  }
  body.sidebar-collapsed .nav-item svg { width: 20px; height: 20px; }

  /* Hover tooltip */
  body.sidebar-collapsed .nav-item::after {
    content: attr(data-tooltip);
    position: absolute;
    left: calc(100% + 8px);
    top: 50%; transform: translateY(-50%);
    background: #1e293b; color: #f1f5f9;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    font-size: 12px; font-weight: 500;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity .12s;
    z-index: 200;
  }
  body.sidebar-collapsed .nav-item:hover::after { opacity: 1; }
}

/* ── Please-wait modal ───────────────────────────────────────────────────────── */
.pw-overlay {
  display: none;
  position: fixed; inset: 0; z-index: 9000;
  background: rgba(15, 23, 42, 0.55);
  align-items: center; justify-content: center;
}
.pw-overlay.active { display: flex; }
.pw-box {
  background: #fff; border-radius: 12px;
  padding: 36px 48px;
  display: flex; flex-direction: column; align-items: center; gap: 20px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  min-width: 220px;
}
.pw-spinner {
  width: 44px; height: 44px;
  border: 4px solid #e2e8f0;
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: pw-spin 0.8s linear infinite;
}
@keyframes pw-spin { to { transform: rotate(360deg); } }
.pw-label {
  font-size: 15px; font-weight: 500;
  color: var(--text-muted); letter-spacing: 0.01em;
}

/* ── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .card-grid, .case-grid, .doc-view-grid, .ai-layout, .result-layout { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  .sidebar { transform: translateX(-100%); overflow: hidden; }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .stat-grid { grid-template-columns: 1fr; }
  .form-row { flex-direction: column; }
}
